Fix for bug 373718: Updates for editor input and bookmarks file
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / viewers / events / TmfEventsTable.java
index 0f383327772cc2cf6f2210537eb3c126d715538a..91ab72ef401d276a34d8fe70c896db69de5aadf1 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Map.Entry;
 import java.util.regex.Pattern;\r
 import java.util.regex.PatternSyntaxException;\r
 \r
+import org.eclipse.core.resources.IFile;\r
 import org.eclipse.core.resources.IMarker;\r
 import org.eclipse.core.resources.IResource;\r
 import org.eclipse.core.runtime.CoreException;\r
@@ -173,7 +174,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
 \r
     // Bookmark map <Rank, MarkerId>\r
     protected Map<Long, Long> fBookmarksMap = new HashMap<Long, Long>();\r
-    protected IResource fBookmarksResource;\r
+    protected IFile fBookmarksFile;\r
     protected long fPendingGotoRank = -1;\r
 \r
     // SWT resources\r
@@ -535,7 +536,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                     if (point.x <= imageBounds.x + imageBounds.width) {\r
                         // Right-click on left margin\r
                         Long rank = (Long) item.getData(Key.RANK);\r
-                        if (rank != null && fBookmarksResource != null) {\r
+                        if (rank != null && fBookmarksFile != null) {\r
                             if (fBookmarksMap.containsKey(rank)) {\r
                                 tablePopupMenu.add(new ToggleBookmarkAction(\r
                                         Messages.TmfEventsTable_RemoveBookmarkActionText, rank));\r
@@ -664,7 +665,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
         if (markerId != null) {\r
             bookmark = true;\r
             try {\r
-                IMarker marker = fBookmarksResource.findMarker(markerId);\r
+                IMarker marker = fBookmarksFile.findMarker(markerId);\r
                 item.setData(Key.BOOKMARK, marker.getAttribute(IMarker.MESSAGE));\r
             } catch (CoreException e) {\r
                 displayException(e);\r
@@ -1480,8 +1481,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
     // Bookmark handling\r
     // ------------------------------------------------------------------------\r
 \r
-    public void addBookmark(IResource resource) {\r
-        fBookmarksResource = resource;\r
+    public void addBookmark(IFile bookmarksFile) {\r
+        fBookmarksFile = bookmarksFile;\r
         TableItem[] selection = fTable.getSelection();\r
         if (selection.length > 0) {\r
             TableItem tableItem = selection[0];\r
@@ -1499,7 +1500,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                 if (dialog.open() == Dialog.OK) {\r
                     String message = dialog.getValue();\r
                     try {\r
-                        IMarker bookmark = resource.createMarker(IMarker.BOOKMARK);\r
+                        IMarker bookmark = bookmarksFile.createMarker(IMarker.BOOKMARK);\r
                         if (bookmark.exists()) {\r
                             bookmark.setAttribute(IMarker.MESSAGE, message.toString());\r
                             long rank = (Long) tableItem.getData(Key.RANK);\r
@@ -1528,14 +1529,14 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
     }\r
 \r
     private void toggleBookmark(long rank) {\r
-        if (fBookmarksResource == null) {\r
+        if (fBookmarksFile == null) {\r
             return;\r
         }\r
         if (fBookmarksMap.containsKey(rank)) {\r
             Long markerId = fBookmarksMap.remove(rank);\r
             fTable.refresh();\r
             try {\r
-                IMarker bookmark = fBookmarksResource.findMarker(markerId);\r
+                IMarker bookmark = fBookmarksFile.findMarker(markerId);\r
                 if (bookmark != null) {\r
                     bookmark.delete();\r
                 }\r
@@ -1543,15 +1544,15 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                 displayException(e);\r
             }\r
         } else {\r
-            addBookmark(fBookmarksResource);\r
+            addBookmark(fBookmarksFile);\r
         }\r
     }\r
 \r
-    public void refreshBookmarks(IResource resource) {\r
-        fBookmarksResource = resource;\r
+    public void refreshBookmarks(IFile bookmarksFile) {\r
+        fBookmarksFile = bookmarksFile;\r
         try {\r
             fBookmarksMap.clear();\r
-            for (IMarker bookmark : resource.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {\r
+            for (IMarker bookmark : bookmarksFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {\r
                 int location = bookmark.getAttribute(IMarker.LOCATION, -1);\r
                 if (location != -1) {\r
                     long rank = location;\r
This page took 0.025189 seconds and 5 git commands to generate.