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
.Activator
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.ITmfFilter
;
27 * Provider for decorations in the time chart view
30 * @author Patrick Tasse
32 public class TimeChartDecorationProvider
{
34 private final IFile fBookmarksFile
;
35 private final Set
<Long
> fBookmarksSet
= new HashSet
<Long
>();
36 private ITmfFilter fFilterFilter
;
37 private ITmfFilter fSearchFilter
;
39 public TimeChartDecorationProvider(IFile bookmarksFile
) {
40 fBookmarksFile
= bookmarksFile
;
44 public IFile
getBookmarksFile() {
45 return fBookmarksFile
;
48 public boolean isBookmark(long rank
) {
49 return fBookmarksSet
.contains(rank
);
52 public void refreshBookmarks() {
54 fBookmarksSet
.clear();
55 for (IMarker bookmark
: fBookmarksFile
.findMarkers(IMarker
.BOOKMARK
, false, IResource
.DEPTH_ZERO
)) {
56 int location
= bookmark
.getAttribute(IMarker
.LOCATION
, -1);
58 Long rank
= (long) location
;
59 fBookmarksSet
.add(rank
);
62 } catch (CoreException e
) {
63 Activator
.getDefault().logError("Error refreshing bookmarks", e
); //$NON-NLS-1$
67 public void filterApplied(ITmfFilter filter
) {
68 fFilterFilter
= filter
;
71 public boolean isVisible(ITmfEvent event
) {
72 if (fFilterFilter
!= null) {
73 return fFilterFilter
.matches(event
);
78 public void searchApplied(ITmfFilter filter
) {
79 fSearchFilter
= filter
;
82 public boolean isSearchMatch(ITmfEvent event
) {
83 if (fSearchFilter
!= null) {
84 return fSearchFilter
.matches(event
);