Added a progress monitor for indexing job.
authorFrancois Chouinard <fchouinard@gmail.com>
Mon, 14 Sep 2009 16:05:22 +0000 (16:05 +0000)
committerFrancois Chouinard <fchouinard@gmail.com>
Mon, 14 Sep 2009 16:05:22 +0000 (16:05 +0000)
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java

index 3d12f29c2bd304324f510c435c0ed5a9f3d7b394..3717ef884054960f1d2f0ff761e38b9f19d2c66f 100644 (file)
@@ -46,11 +46,16 @@ public interface ITmfTrace {
                }
        }
     
+       /**
+        * @return the trace path 
+        */
+       public String getPath();
+    
        /**
         * @return the trace name 
         */
        public String getName();
-    
+
        /**
         * @return the number of events in the trace
         */
index 893a68891c54fd73d5da9f35a1fc21f1270c9092..b7c93e7819377bae3e7c7f432be35b520b5f855d 100644 (file)
@@ -12,7 +12,9 @@
 
 package org.eclipse.linuxtools.tmf.trace;
 
+import java.io.File;
 import java.io.FileNotFoundException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Collections;
 import java.util.Vector;
 
@@ -20,6 +22,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
@@ -46,7 +50,10 @@ public abstract class TmfTrace implements ITmfTrace {
     // Attributes
     // ========================================================================
 
-    // The stream name
+    // The trace path
+    private final String fPath;
+
+    // The trace name
     private final String fName;
 
     // The checkpoints page size
@@ -74,8 +81,10 @@ public abstract class TmfTrace implements ITmfTrace {
      * @param index
      * @throws FileNotFoundException
      */
-    protected TmfTrace(String name, int pageSize, boolean index) throws FileNotFoundException {
-       fName = name;
+    protected TmfTrace(String path, int pageSize, boolean index) throws FileNotFoundException {
+       int sep = path.lastIndexOf(File.separator);
+       fName = (sep >= 0) ? path.substring(sep + 1) : path;
+       fPath = path;
         fPageSize = pageSize;
         fIndex = index;
     }
@@ -111,10 +120,10 @@ public abstract class TmfTrace implements ITmfTrace {
     // ========================================================================
 
     /**
-     * @return the size of the cache
+     * @return the trace path
      */
-    public int getPageSize() {
-        return fPageSize;
+    public String getPath() {
+        return fPath;
     }
 
     /**
@@ -131,6 +140,13 @@ public abstract class TmfTrace implements ITmfTrace {
         return fNbEvents;
     }
 
+    /**
+     * @return the size of the cache
+     */
+    public int getPageSize() {
+        return fPageSize;
+    }
+
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getTimeRange()
      */
@@ -291,15 +307,23 @@ public abstract class TmfTrace implements ITmfTrace {
     // ========================================================================
 
     public void indexStream() {
-       IndexingJob job = new IndexingJob(fName);
+       final IndexingJob job = new IndexingJob(fName);
        job.schedule();
        if (fIndex) {
-               try {
-                               job.join();
-                       } catch (InterruptedException e) {
-                               // TODO Auto-generated catch block
-                               e.printStackTrace();
-                       }
+            ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
+            try {
+                dialog.run(true, true, new IRunnableWithProgress() {
+                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                        monitor.beginTask("Indexing " + getName(), IProgressMonitor.UNKNOWN);
+                                       job.join();
+                        monitor.done();
+                    }
+                });
+            } catch (InvocationTargetException e) {
+                e.printStackTrace();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
        }
     }
 
This page took 0.026141 seconds and 5 git commands to generate.