private void fireModelChanged(AnnotationModelEvent event) { event.markSealed(); if (!event.isEmpty()) { for (final IAnnotationModelListener l : annotationModelListeners) { if (l instanceof IAnnotationModelListenerExtension) { ((IAnnotationModelListenerExtension) l).modelChanged(event); } else { l.modelChanged(this); } } } }
@Override public IAnnotationModel createAnnotationModel(Object element) { IAnnotationModel annotationModel = super.createAnnotationModel(element); IAnnotationModelListener listener = annotationModelListeners.get(element); if (listener != null) { annotationModel.addAnnotationModelListener(listener); } return annotationModel; }
/** * @see IAnnotationModelListener#modelChanged(IAnnotationModel) */ public void modelChanged(IAnnotationModel model) { Object[] listeners= fListenerList.getListeners(); for (int i= 0; i < listeners.length; i++) { ((IAnnotationModelListener) listeners[i]).modelChanged(model); } }
/** * Creates an editor representation instance. * * @param embeddedEditor the embedded editor * @param viewer the underlying source viewer * @param partialEditorModelAccess the model access * @param requireWorkspaceResource whether the editor requires a workspace resource and shall complain at least in * the logs or whether it shall be silent */ public EmbeddedXtextSourceEditor(EmbeddedEditor embeddedEditor, XtextSourceViewer viewer, EmbeddedEditorModelAccess partialEditorModelAccess, boolean requireWorkspaceResource) { this.embeddedEditor = embeddedEditor; this.viewer = viewer; this.partialEditorModelAccess = partialEditorModelAccess; try { URI uri = embeddedEditor.getDocument().getResourceURI(); java.net.URI netURI = new java.net.URI(uri.toString()); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(netURI); if (null != files && files.length > 0) { resource = files[0]; } else { if (requireWorkspaceResource) { getLogger().error("No resource for " + uri); } } } catch (URISyntaxException e) { getLogger().exception(e); } viewer.getAnnotationModel().addAnnotationModelListener(new IAnnotationModelListener() { @Override public void modelChanged(IAnnotationModel model) { if (!skipNextUpdateEvent) { // loading / updating the model dirty = true; } skipNextUpdateEvent = false; } }); }
@Override public void addValidationStateListener(IValidationStateListener listener) { if (null != listener) { IAnnotationModelListener delegatingListener = new ValidationStateListener(listener); validationStateListeners.put(listener, delegatingListener); viewer.getAnnotationModel().addAnnotationModelListener(delegatingListener); } }
@Override public void removeValidationStateListener(IValidationStateListener listener) { if (null != listener) { IAnnotationModelListener delegatingListener = validationStateListeners.remove(listener); if (null != delegatingListener && null != viewer) { IAnnotationModel model = viewer.getAnnotationModel(); if (null != model) { model.removeAnnotationModelListener(delegatingListener); } } } }
public void addAnnotationModelListener(IAnnotationModelListener listener) { if (!annotationModelListeners.contains(listener)) { annotationModelListeners.add(listener); fireModelChanged(new AnnotationModelEvent(this, true)); } }
public void removeAnnotationModelListener(IAnnotationModelListener listener) { annotationModelListeners.remove(listener); }
public void addListener(IAnnotationModelListener listener) { fListenerList.add(listener); }
public void removeListener(IAnnotationModelListener listener) { fListenerList.remove(listener); }
public void addGlobalAnnotationModelListener(IAnnotationModelListener listener) { fGlobalAnnotationModelListener.addListener(listener); }
public void removeGlobalAnnotationModelListener(IAnnotationModelListener listener) { fGlobalAnnotationModelListener.removeListener(listener); }
/** * Adds a listener that reports changes from all compilation unit annotation models. * * @param listener the listener */ void addGlobalAnnotationModelListener(IAnnotationModelListener listener);
/** * Removes the listener. * * @param listener the listener */ void removeGlobalAnnotationModelListener(IAnnotationModelListener listener);