public void selectionChanged(SelectionChangedEvent event) { Iterator e = fActions.values().iterator(); while (e.hasNext()) { Object next = e.next(); if (next instanceof MergeViewerAction) { MergeViewerAction action = (MergeViewerAction) next; if (action.isSelectionDependent()) action.update(); } } }
void updateContentDependantActions() { Iterator e = fActions.values().iterator(); while (e.hasNext()) { Object next = e.next(); if (next instanceof MergeViewerAction) { MergeViewerAction action = (MergeViewerAction) next; if (action.isContentDependent()) action.update(); } } }
/** update all actions independent of their type */ public void updateActions() { Iterator e = fActions.values().iterator(); while (e.hasNext()) { Object next = e.next(); if (next instanceof MergeViewerAction) { MergeViewerAction action = (MergeViewerAction) next; action.update(); } else if (next instanceof FindReplaceAction) { FindReplaceAction action = (FindReplaceAction) next; action.update(); } else if (next instanceof ChangeEncodingAction) { ChangeEncodingAction action = (ChangeEncodingAction) next; action.update(); } } }
/** * Sets the dirty state of the right side of this viewer. If the new value differs from the old * all registered listener are notified with a <code>PropertyChangeEvent</code> with the property * name <code>CompareEditorInput.DIRTY_STATE</code>. * * @param dirty the state of the right side dirty flag */ protected void setRightDirty(boolean dirty) { if (isRightDirty() != dirty) { fRightSaveAction.setEnabled(dirty); // Only fire the event if the combined dirty state has changed if ((!isRightDirty() && !isLeftDirty()) || (isRightDirty() && !isLeftDirty())) fireDirtyState(dirty); } }
public IAction getAction(String actionId) { IAction action = (IAction) fActions.get(actionId); if (action == null) { action = createAction(actionId); if (action == null) return null; if (action instanceof MergeViewerAction) { MergeViewerAction mva = (MergeViewerAction) action; if (mva.isContentDependent()) getSourceViewer().addTextListener(this); if (mva.isSelectionDependent()) getSourceViewer().addSelectionChangedListener(this); Utilities.initAction( action, fResourceBundle, "action." + actionId + "."); // $NON-NLS-1$ //$NON-NLS-2$ } addAction(actionId, action); } if (action instanceof MergeViewerAction) { MergeViewerAction mva = (MergeViewerAction) action; if (mva.isEditableDependent() && !getSourceViewer().isEditable()) return null; } return action; }
/** * Creates a new content merge viewer and initializes with a resource bundle and a configuration. * * @param style SWT style bits * @param bundle the resource bundle * @param cc the configuration object */ protected ContentMergeViewer(int style, ResourceBundle bundle, CompareConfiguration cc) { fStyles = style & ~(SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); // remove // BIDI // direction // bits fBundle = bundle; fAncestorVisible = Utilities.getBoolean(cc, ICompareUIConstants.PROP_ANCESTOR_VISIBLE, fAncestorVisible); fConfirmSave = Utilities.getBoolean(cc, CompareEditor.CONFIRM_SAVE_PROPERTY, fConfirmSave); setContentProvider(new MergeViewerContentProvider(cc)); fCompareInputChangeListener = new ICompareInputChangeListener() { public void compareInputChanged(ICompareInput input) { if (input == getInput()) { handleCompareInputChange(); } } }; // Make sure the compare configuration is not null if (cc == null) fCompareConfiguration = new CompareConfiguration(); else fCompareConfiguration = cc; fPropertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { ContentMergeViewer.this.handlePropertyChangeEvent(event); } }; fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener); fLeftSaveAction = new SaveAction(true); fLeftSaveAction.setEnabled(false); fRightSaveAction = new SaveAction(false); fRightSaveAction.setEnabled(false); // this is used to update the dirty status,if we use // org.eclipse.php.internal.ui.compare.ContentMergeViewer,we will get a // ClassCastException cmv = new org.eclipse.compare.contentmergeviewer.ContentMergeViewer( fStyles, fBundle, fCompareConfiguration) { @Override protected void createControls(Composite composite) {} @Override protected void handleResizeAncestor(int x, int y, int width, int height) {} @Override protected void handleResizeLeftRight( int x, int y, int leftWidth, int centerWidth, int rightWidth, int height) {} @Override protected void updateContent(Object ancestor, Object left, Object right) {} @Override protected void copy(boolean leftToRight) {} @Override protected byte[] getContents(boolean left) { return null; } @Override public boolean internalIsLeftDirty() { return ContentMergeViewer.this.isLeftDirty(); } @Override public boolean internalIsRightDirty() { return ContentMergeViewer.this.isRightDirty(); } }; }
/** * Return the dirty state of the left side of this viewer. * * @return the dirty state of the left side of this viewer * @since 3.3 */ protected boolean isLeftDirty() { return fLeftSaveAction.isEnabled(); }
/** * Return the dirty state of the right side of this viewer. * * @return the dirty state of the right side of this viewer * @since 3.3 */ protected boolean isRightDirty() { return fRightSaveAction.isEnabled(); }