Replace printStackTrace() with proper logging in TMF and LTTng
[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.TmfUiPlugin;
23 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
24 import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
25
26 public class TimeChartDecorationProvider {
27
28 private IFile fBookmarksFile;
29 private Set<Long> fBookmarksSet = new HashSet<Long>();
30 private ITmfFilter fFilterFilter;
31 private ITmfFilter fSearchFilter;
32
33 public TimeChartDecorationProvider(IFile bookmarksFile) {
34 fBookmarksFile = bookmarksFile;
35 refreshBookmarks();
36 }
37
38 public IFile getBookmarksFile() {
39 return fBookmarksFile;
40 }
41
42 public boolean isBookmark(long rank) {
43 return fBookmarksSet.contains(rank);
44 }
45
46 public void refreshBookmarks() {
47 try {
48 fBookmarksSet.clear();
49 for (IMarker bookmark : fBookmarksFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {
50 int location = bookmark.getAttribute(IMarker.LOCATION, -1);
51 if (location != -1) {
52 Long rank = (long) location;
53 fBookmarksSet.add(rank);
54 }
55 }
56 } catch (CoreException e) {
57 TmfUiPlugin.getDefault().logError("Error refreshing bookmarks", e); //$NON-NLS-1$
58 }
59 }
60
61 public void filterApplied(ITmfFilter filter) {
62 fFilterFilter = filter;
63 }
64
65 public boolean isVisible(ITmfEvent event) {
66 if (fFilterFilter != null) {
67 return fFilterFilter.matches(event);
68 }
69 return true;
70 }
71
72 public void searchApplied(ITmfFilter filter) {
73 fSearchFilter = filter;
74 }
75
76 public boolean isSearchMatch(ITmfEvent event) {
77 if (fSearchFilter != null) {
78 return fSearchFilter.matches(event);
79 }
80 return false;
81 }
82
83 }
This page took 0.032722 seconds and 6 git commands to generate.