类org.eclipse.ui.texteditor.IUpdate源码实例Demo

下面列出了怎么用org.eclipse.ui.texteditor.IUpdate的API类实例代码及写法,或者点击链接到github查看源代码。

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);
      }
  }
 
源代码4 项目: xtext-eclipse   文件: ActivationCodeTrigger.java
@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;
				}
			}
		}
	}
}
 
源代码5 项目: xtext-eclipse   文件: EmbeddedEditorFactory.java
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;
}
 
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;
}
 
源代码8 项目: birt   文件: DecoratedScriptEditor.java
/**
 * 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();
        }
    }
}
 
源代码10 项目: xtext-eclipse   文件: OperationHistoryListener.java
public OperationHistoryListener(IUndoContext context, IUpdate update) {
	this.context = context;
	this.update = update;
}
 
源代码11 项目: xtext-eclipse   文件: EmbeddedEditorActions.java
private void update(IAction action) {
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
源代码12 项目: typescript.java   文件: EditTemplateDialog.java
protected void updateUndoAction() {
	IAction action = (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO);
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
源代码13 项目: typescript.java   文件: EditTemplateDialog.java
protected void updateAction(String actionId) {
	IAction action = (IAction) fGlobalActions.get(actionId);
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
protected void updateAction(String actionId) {
	IAction action= fGlobalActions.get(actionId);
	if (action instanceof IUpdate)
		((IUpdate) action).update();
}
 
源代码15 项目: e4macs   文件: KillRingListeners.java
/**
 * @see org.eclipse.ui.texteditor.IUpdate#update()
 */
public void update() {
	if (action instanceof IUpdate) {
		((IUpdate)action).update();
	}
}
 
 类所在包
 同包方法