1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.timechart
;
15 import java
.util
.HashSet
;
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
;
26 public class TimeChartDecorationProvider
{
28 private IFile fBookmarksFile
;
29 private Set
<Long
> fBookmarksSet
= new HashSet
<Long
>();
30 private ITmfFilter fFilterFilter
;
31 private ITmfFilter fSearchFilter
;
33 public TimeChartDecorationProvider(IFile bookmarksFile
) {
34 fBookmarksFile
= bookmarksFile
;
38 public IFile
getBookmarksFile() {
39 return fBookmarksFile
;
42 public boolean isBookmark(long rank
) {
43 return fBookmarksSet
.contains(rank
);
46 public void refreshBookmarks() {
48 fBookmarksSet
.clear();
49 for (IMarker bookmark
: fBookmarksFile
.findMarkers(IMarker
.BOOKMARK
, false, IResource
.DEPTH_ZERO
)) {
50 int location
= bookmark
.getAttribute(IMarker
.LOCATION
, -1);
52 Long rank
= (long) location
;
53 fBookmarksSet
.add(rank
);
56 } catch (CoreException e
) {
57 TmfUiPlugin
.getDefault().logError("Error refreshing bookmarks", e
); //$NON-NLS-1$
61 public void filterApplied(ITmfFilter filter
) {
62 fFilterFilter
= filter
;
65 public boolean isVisible(ITmfEvent event
) {
66 if (fFilterFilter
!= null) {
67 return fFilterFilter
.matches(event
);
72 public void searchApplied(ITmfFilter filter
) {
73 fSearchFilter
= filter
;
76 public boolean isSearchMatch(ITmfEvent event
) {
77 if (fSearchFilter
!= null) {
78 return fSearchFilter
.matches(event
);