+ @Override
+ public void dispose() {
+ super.dispose();
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void resourceChanged(final IResourceChangeEvent event) {
+ for (final IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {
+ if (delta.getResource().equals(fEditorFile)) {
+ fTimeGraphWrapper.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile));
+ redraw();
+ return;
+ }
+ }
+ }
+
+ private List<IMarkerEvent> refreshBookmarks(final IFile editorFile) {
+ List<IMarkerEvent> bookmarks = new ArrayList<>();
+ try {
+ for (Color color : fColors) {
+ color.dispose();
+ }
+ fColors.clear();
+ IMarker[] markers = editorFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO);
+ for (IMarker marker : markers) {
+ String label = marker.getAttribute(IMarker.MESSAGE, (String) null);
+ String time = marker.getAttribute(MARKER_TIME, (String) null);
+ String duration = marker.getAttribute(MARKER_DURATION, Long.toString(0));
+ String rgba = marker.getAttribute(MARKER_COLOR, (String) null);
+ if (label != null && time != null && rgba != null) {
+ Matcher matcher = RGBA_PATTERN.matcher(rgba);
+ if (matcher.matches()) {
+ try {
+ int red = Integer.valueOf(matcher.group(1));
+ int green = Integer.valueOf(matcher.group(2));
+ int blue = Integer.valueOf(matcher.group(3));
+ int alpha = Integer.valueOf(matcher.group(4));
+ Color color = new Color(Display.getDefault(), red, green, blue, alpha);
+ fColors.add(color);
+ bookmarks.add(new MarkerEvent(null, Long.valueOf(time), Long.valueOf(duration), color, label, true));
+ } catch (NumberFormatException e) {
+ Activator.getDefault().logError(e.getMessage());
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ Activator.getDefault().logError(e.getMessage());
+ }
+ return bookmarks;
+ }
+