org.eclipse.ui.texteditor.IUpdate Java Examples

The following examples show how to use org.eclipse.ui.texteditor.IUpdate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaSelectMarkerRulerAction2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
			}
		}
	}
}
 
Example #2
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example #3
Source File: GenerateBuildPathActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
      }
  }
 
Example #4
Source File: ActivationCodeTrigger.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
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;
				}
			}
		}
	}
}
 
Example #5
Source File: EmbeddedEditorFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) {
	IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
	final IUndoContext context = undoManager.getUndoContext();
	IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
	OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() {
		@Override
		public void update() {
			actions.updateAction(ITextEditorActionConstants.REDO);
			actions.updateAction(ITextEditorActionConstants.UNDO);
		}
	});
	operationHistory.addOperationHistoryListener(operationHistoryListener);
	return operationHistoryListener;
}
 
Example #6
Source File: GenerateActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: DecoratedScriptEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 );
	}
}
 
Example #9
Source File: PromptOverlayReplaceGlobalActionHandlers.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected void updateSelectionDependentActions() {
    for (String string : selectionDependentActionIds) {
        IAction action = newActions.get(string);
        if (action instanceof IUpdate) {
            ((IUpdate) action).update();
        }
    }
}
 
Example #10
Source File: OperationHistoryListener.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public OperationHistoryListener(IUndoContext context, IUpdate update) {
	this.context = context;
	this.update = update;
}
 
Example #11
Source File: EmbeddedEditorActions.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private void update(IAction action) {
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
Example #12
Source File: EditTemplateDialog.java    From typescript.java with MIT License 4 votes vote down vote up
protected void updateUndoAction() {
	IAction action = (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO);
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
Example #13
Source File: EditTemplateDialog.java    From typescript.java with MIT License 4 votes vote down vote up
protected void updateAction(String actionId) {
	IAction action = (IAction) fGlobalActions.get(actionId);
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
Example #14
Source File: EditTemplateDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected void updateAction(String actionId) {
	IAction action= fGlobalActions.get(actionId);
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
Example #15
Source File: KillRingListeners.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.ui.texteditor.IUpdate#update()
 */
public void update() {
	if (action instanceof IUpdate) {
		((IUpdate)action).update();
	}
}