@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == DrawingEditor.ACTIVE_VIEW_PROPERTY) { if (activeView != null) { activeView.removeFigureSelectionListener(this); activeView.removePropertyChangeListener(this); } if (evt.getNewValue() != null) { activeView = ((DrawingView) evt.getNewValue()); activeView.addFigureSelectionListener(this); activeView.addPropertyChangeListener(this); } updateEnabledState(); } else if (evt.getPropertyName().equals("enabled")) { updateEnabledState(); } }
public SelectionComponentDisplayer(DrawingEditor editor, JComponent component) { this.editor = editor; this.weakRef = new WeakReference<JComponent>(component); if (editor.getActiveView() != null) { view = editor.getActiveView(); view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); } editor.addPropertyChangeListener(this); updateVisibility(); }
@Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (name == DrawingEditor.ACTIVE_VIEW_PROPERTY) { if (view != null) { view.removePropertyChangeListener(this); view.removeFigureSelectionListener(this); } view = (DrawingView) evt.getNewValue(); if (view != null) { view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); } updateVisibility(); } else if (name == DrawingEditor.TOOL_PROPERTY) { updateVisibility(); } }
/** Registers the event handler from the drawing editor and the * active drawing view. */ private void registerEventHandler() { if (editor != null) { editor.addPropertyChangeListener(new WeakPropertyChangeListener(eventHandler)); if (activeView != null) { activeView.removeFigureSelectionListener(eventHandler); activeView.removePropertyChangeListener(eventHandler); } activeView = editor.getActiveView(); if (activeView != null) { activeView.addFigureSelectionListener(eventHandler); activeView.addPropertyChangeListener(eventHandler); } } } }
if (view != null) { view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); if (view.getDrawing() != null) { view.getDrawing().addFigureListener(this);
public SelectionComponentRepainter(DrawingEditor editor, JComponent component) { this.editor = editor; this.component = component; if (editor != null) { if (editor.getActiveView() != null) { DrawingView view = editor.getActiveView(); view.addPropertyChangeListener(this); view.addFigureSelectionListener(this); if (view.getDrawing() != null) { view.getDrawing().addFigureListener(this); } } editor.addPropertyChangeListener(this); } }
protected void updateActiveView() { DrawingView newValue = (view != null) ? // view : // ((editor != null && editor.getActiveView() != null) ? // editor.getActiveView() : null); DrawingView oldValue = activeView; if (activeView != null) { activeView.removePropertyChangeListener(eventHandler); activeView.removeFigureSelectionListener(eventHandler); if (figuresOfInterest != null) { for (Figure f : figuresOfInterest) { f.removeFigureListener(eventHandler); } } } activeView = newValue; if (activeView != null) { activeView.addPropertyChangeListener(eventHandler); activeView.addFigureSelectionListener(eventHandler); figuresOfInterest = getEditedFigures(); for (Figure f : figuresOfInterest) { f.addFigureListener(eventHandler); } } attributeRestoreData = null; updateAttributeEditor(); }