-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\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
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;\r
-\r
-/**\r
- * Provider for decorations in the time chart view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeChartDecorationProvider {\r
-\r
- private final IFile fBookmarksFile;\r
- private final Set<Long> fBookmarksSet = new HashSet<Long>();\r
- private ITmfFilter fFilterFilter;\r
- private ITmfFilter fSearchFilter;\r
-\r
- /**\r
- * Constructor\r
- *\r
- * @param bookmarksFile\r
- * Bookmark file associated with the trace\r
- */\r
- public TimeChartDecorationProvider(IFile bookmarksFile) {\r
- fBookmarksFile = bookmarksFile;\r
- refreshBookmarks();\r
- }\r
-\r
- /**\r
- * Retrieve the bookmark file that was assigned to this provider\r
- *\r
- * @return The bookmark file\r
- */\r
- public IFile getBookmarksFile() {\r
- return fBookmarksFile;\r
- }\r
-\r
- /**\r
- * Verify if the selected rank has a bookmark assigned to it.\r
- *\r
- * @param rank\r
- * The rank to check for\r
- * @return If there is a bookmark there\r
- */\r
- public boolean isBookmark(long rank) {\r
- return fBookmarksSet.contains(rank);\r
- }\r
-\r
- /**\r
- * Refresh the bookmark display.\r
- */\r
- public void refreshBookmarks() {\r
- try {\r
- fBookmarksSet.clear();\r
- for (IMarker bookmark : fBookmarksFile.findMarkers(\r
- IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {\r
- int location = bookmark.getAttribute(IMarker.LOCATION, -1);\r
- if (location != -1) {\r
- Long rank = (long) location;\r
- fBookmarksSet.add(rank);\r
- }\r
- }\r
- } catch (CoreException e) {\r
- Activator.getDefault().logError("Error refreshing bookmarks", e); //$NON-NLS-1$\r
- }\r
- }\r
-\r
- /**\r
- * Notify that a filter is now applied on the view.\r
- *\r
- * @param filter\r
- * The filter that was applied\r
- */\r
- public void filterApplied(ITmfFilter filter) {\r
- fFilterFilter = filter;\r
- }\r
-\r
- /**\r
- * Check if an event is currently visible in the view or not.\r
- *\r
- * @param event\r
- * The event to check for\r
- * @return If the event is visible or not\r
- */\r
- public boolean isVisible(ITmfEvent event) {\r
- if (fFilterFilter != null) {\r
- return fFilterFilter.matches(event);\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * Notify that a search is applied on the view.\r
- *\r
- * @param filter\r
- * The search filter that was applied\r
- */\r
- public void searchApplied(ITmfFilter filter) {\r
- fSearchFilter = filter;\r
- }\r
-\r
- /**\r
- * Verify if the currently active search filter applies to the given event\r
- * or not.\r
- *\r
- * @param event\r
- * The event to check for\r
- * @return If the event matches\r
- */\r
- public boolean isSearchMatch(ITmfEvent event) {\r
- if (fSearchFilter != null) {\r
- return fSearchFilter.matches(event);\r
- }\r
- return false;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.timechart;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
+
+/**
+ * Provider for decorations in the time chart view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeChartDecorationProvider {
+
+ private final IFile fBookmarksFile;
+ private final Set<Long> fBookmarksSet = new HashSet<Long>();
+ private ITmfFilter fFilterFilter;
+ private ITmfFilter fSearchFilter;
+
+ /**
+ * Constructor
+ *
+ * @param bookmarksFile
+ * Bookmark file associated with the trace
+ */
+ public TimeChartDecorationProvider(IFile bookmarksFile) {
+ fBookmarksFile = bookmarksFile;
+ refreshBookmarks();
+ }
+
+ /**
+ * Retrieve the bookmark file that was assigned to this provider
+ *
+ * @return The bookmark file
+ */
+ public IFile getBookmarksFile() {
+ return fBookmarksFile;
+ }
+
+ /**
+ * Verify if the selected rank has a bookmark assigned to it.
+ *
+ * @param rank
+ * The rank to check for
+ * @return If there is a bookmark there
+ */
+ public boolean isBookmark(long rank) {
+ return fBookmarksSet.contains(rank);
+ }
+
+ /**
+ * Refresh the bookmark display.
+ */
+ public void refreshBookmarks() {
+ try {
+ fBookmarksSet.clear();
+ for (IMarker bookmark : fBookmarksFile.findMarkers(
+ IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {
+ int location = bookmark.getAttribute(IMarker.LOCATION, -1);
+ if (location != -1) {
+ Long rank = (long) location;
+ fBookmarksSet.add(rank);
+ }
+ }
+ } catch (CoreException e) {
+ Activator.getDefault().logError("Error refreshing bookmarks", e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Notify that a filter is now applied on the view.
+ *
+ * @param filter
+ * The filter that was applied
+ */
+ public void filterApplied(ITmfFilter filter) {
+ fFilterFilter = filter;
+ }
+
+ /**
+ * Check if an event is currently visible in the view or not.
+ *
+ * @param event
+ * The event to check for
+ * @return If the event is visible or not
+ */
+ public boolean isVisible(ITmfEvent event) {
+ if (fFilterFilter != null) {
+ return fFilterFilter.matches(event);
+ }
+ return true;
+ }
+
+ /**
+ * Notify that a search is applied on the view.
+ *
+ * @param filter
+ * The search filter that was applied
+ */
+ public void searchApplied(ITmfFilter filter) {
+ fSearchFilter = filter;
+ }
+
+ /**
+ * Verify if the currently active search filter applies to the given event
+ * or not.
+ *
+ * @param event
+ * The event to check for
+ * @return If the event matches
+ */
+ public boolean isSearchMatch(ITmfEvent event) {
+ if (fSearchFilter != null) {
+ return fSearchFilter.matches(event);
+ }
+ return false;
+ }
+
+}