protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) { IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document); final IUndoContext context = undoManager.getUndoContext(); // XXX cp uncommented // IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory(); OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() { public void update() { actions.updateAction(ITextEditorActionConstants.REDO); actions.updateAction(ITextEditorActionConstants.UNDO); } }); viewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { actions.updateAction(ITextEditorActionConstants.REDO); actions.updateAction(ITextEditorActionConstants.UNDO); } }); // // operationHistory.addOperationHistoryListener(operationHistoryListener); return operationHistoryListener; }
private void triggerAction(String actionID, Event event) { IAction action= getTextEditor().getAction(actionID); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); // hack to propagate line change if (action instanceof ISelectionListener) { ((ISelectionListener)action).selectionChanged(null, null); } if (action.isEnabled()) { if (event == null) { action.run(); } else { event.type= SWT.MouseDoubleClick; event.count= 2; action.runWithEvent(event); } } } }
/** * Convenience method to add the action installed under the given actionID to the * specified group of the menu. * * @param menu the menu manager * @param group the group to which to add the action * @param actionID the ID of the new action */ protected void addAction(IMenuManager menu, String group, String actionID) { IAction action= getAction(actionID); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); if (action.isEnabled()) { IMenuManager subMenu= menu.findMenuUsingPath(group); if (subMenu != null) subMenu.add(action); else menu.appendToGroup(group, action); } } }
private void fillViewSubMenu(IMenuManager source) { int added= 0; int i=0; for (Iterator<Action> iter= fActions.iterator(); iter.hasNext();) { Action action= iter.next(); if (action instanceof IUpdate) ((IUpdate) action).update(); if (i == 2) source.add(new Separator(GROUP_BUILDPATH)); else if (i == 8) source.add(new Separator(GROUP_FILTER)); else if (i == 10) source.add(new Separator(GROUP_CUSTOMIZE)); added+= addAction(source, action); i++; } if (added == 0) { source.add(fNoActionAvailable); } }
/** * Updates the enabled state of all <code>IUpdate</code> actions associated * with the project viewer. */ private void updateProjectActions() { Iterator iter = updateProjectActions.iterator(); while (iter.hasNext()) { ((IUpdate) iter.next()).update(); } }
public void verifyKey(VerifyEvent event) { ActionActivationCode code= null; int size= activationCodes.size(); for (int i= 0; i < size; i++) { code= activationCodes.get(i); if (code.matches(event)) { IAction action= actions.get(code.fActionId); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); if (!action.isEnabled() && action instanceof IReadOnlyDependent) { IReadOnlyDependent dependent= (IReadOnlyDependent) action; boolean writable= dependent.isEnabled(true); if (writable) { event.doit= false; return; } } else if (action.isEnabled()) { event.doit= false; action.run(); return; } } } } }
private int addEditorAction(IMenuManager menu, String actionID) { if (fEditor == null) return 0; IAction action= fEditor.getAction(actionID); if (action == null) return 0; if (action instanceof IUpdate) ((IUpdate)action).update(); if (action.isEnabled()) { menu.add(action); return 1; } return 0; }
@Override protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler) { if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER)) return super.createAnnotationRulerColumn(ruler); AnnotationRulerColumn column= new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess()); column.setHover(new JavaExpandHover(ruler, getAnnotationAccess(), new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { // for now: just invoke ruler double click action triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK); } private void triggerAction(String actionID) { IAction action= getAction(actionID); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); // hack to propagate line change if (action instanceof ISelectionListener) { ((ISelectionListener)action).selectionChanged(null, null); } if (action.isEnabled()) action.run(); } } })); return column; }
/** * Set the specified action enabled. * * @param action * the specified action to set enable. */ private void enableAction( IAction action ) { if ( action instanceof IUpdate ) { ( (IUpdate) action ).update( ); } else { ISourceViewer viewer = getViewer( ); action.setEnabled( viewer instanceof ProjectionViewer ? ( (ProjectionViewer) viewer ).isProjectionMode( ) : true ); } }
protected void updateSelectionDependentActions() { for (String string : selectionDependentActionIds) { IAction action = newActions.get(string); if (action instanceof IUpdate) { ((IUpdate) action).update(); } } }
protected void updateUndoAction() { IAction action = (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO); if (action instanceof IUpdate) ((IUpdate) action).update(); }
protected void updateAction(String actionId) { IAction action = (IAction) fGlobalActions.get(actionId); if (action instanceof IUpdate) ((IUpdate) action).update(); }
private void updateAction(String actionId) { IAction action= (IAction) fGlobalActions.get(actionId); if (action instanceof IUpdate) ((IUpdate) action).update(); }
public OperationHistoryListener(IUndoContext context, IUpdate update) { this.context = context; this.update = update; }
private void update(IAction action) { if (action instanceof IUpdate) ((IUpdate) action).update(); }
protected void updateAction(String actionId) { IAction action= fGlobalActions.get(actionId); if (action instanceof IUpdate) ((IUpdate) action).update(); }
/** * @see org.eclipse.ui.texteditor.IUpdate#update() */ public void update() { if (action instanceof IUpdate) { ((IUpdate)action).update(); } }