tmf: Update Javadoc throughout tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / timechart / TimeChartDecorationProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.views.timechart;
14
15 import java.util.HashSet;
16 import java.util.Set;
17
18 import org.eclipse.core.resources.IFile;
19 import org.eclipse.core.resources.IMarker;
20 import org.eclipse.core.resources.IResource;
21 import org.eclipse.core.runtime.CoreException;
22 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
23 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
24 import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
25
26 /**
27 * Provider for decorations in the time chart view
28 *
29 * @version 1.0
30 * @author Patrick Tasse
31 */
32 public class TimeChartDecorationProvider {
33
34 private final IFile fBookmarksFile;
35 private final Set<Long> fBookmarksSet = new HashSet<Long>();
36 private ITmfFilter fFilterFilter;
37 private ITmfFilter fSearchFilter;
38
39 public TimeChartDecorationProvider(IFile bookmarksFile) {
40 fBookmarksFile = bookmarksFile;
41 refreshBookmarks();
42 }
43
44 public IFile getBookmarksFile() {
45 return fBookmarksFile;
46 }
47
48 public boolean isBookmark(long rank) {
49 return fBookmarksSet.contains(rank);
50 }
51
52 public void refreshBookmarks() {
53 try {
54 fBookmarksSet.clear();
55 for (IMarker bookmark : fBookmarksFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {
56 int location = bookmark.getAttribute(IMarker.LOCATION, -1);
57 if (location != -1) {
58 Long rank = (long) location;
59 fBookmarksSet.add(rank);
60 }
61 }
62 } catch (CoreException e) {
63 Activator.getDefault().logError("Error refreshing bookmarks", e); //$NON-NLS-1$
64 }
65 }
66
67 public void filterApplied(ITmfFilter filter) {
68 fFilterFilter = filter;
69 }
70
71 public boolean isVisible(ITmfEvent event) {
72 if (fFilterFilter != null) {
73 return fFilterFilter.matches(event);
74 }
75 return true;
76 }
77
78 public void searchApplied(ITmfFilter filter) {
79 fSearchFilter = filter;
80 }
81
82 public boolean isSearchMatch(ITmfEvent event) {
83 if (fSearchFilter != null) {
84 return fSearchFilter.matches(event);
85 }
86 return false;
87 }
88
89 }
This page took 0.033118 seconds and 6 git commands to generate.