Java Code Examples for org.eclipse.jface.action.IAction#run()

The following examples show how to use org.eclipse.jface.action.IAction#run() . 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: TableEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void performRequest( Request request )
{
	if ( RequestConstants.REQ_OPEN.equals( request.getType( ) ) )
	{
		Object obj = request.getExtendedData( )
				.get( DesignerConstants.TABLE_ROW_NUMBER );
		if ( obj != null )
		{
			int rowNum = ( (Integer) obj ).intValue( );
			RowHandle row = (RowHandle) getRow( rowNum );
			if ( row.getContainer( ) instanceof TableGroupHandle )
			{
				IAction action = new EditGroupAction( null,
						(TableGroupHandle) row.getContainer( ) );
				if ( action.isEnabled( ) )
				{
					action.run( );
				}
			}
		}
	}
}
 
Example 2
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 3
Source File: EditorUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static void initializeHighlightRange(IEditorPart editorPart) {
	if (editorPart instanceof ITextEditor) {
		IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
		boolean enable= toggleAction != null;
		if (enable && editorPart instanceof JavaEditor)
			enable= JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
		else
			enable= enable && toggleAction.isEnabled() && toggleAction.isChecked();
		if (enable) {
			if (toggleAction instanceof TextEditorAction) {
				// Reset the action
				((TextEditorAction)toggleAction).setEditor(null);
				// Restore the action
				((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart);
			} else {
				// Uncheck
				toggleAction.run();
				// Check
				toggleAction.run();
			}
		}
	}
}
 
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: ListBandEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void performDirectEdit( )
{
	ListBandProxy listBand = (ListBandProxy) getModel( );
	if ( listBand.getElemtHandle( ) instanceof ListGroupHandle )
	{
		IAction action = new EditGroupAction( null,
				(ListGroupHandle) listBand.getElemtHandle( ) );
		if ( action.isEnabled( ) )
		{
			action.run( );
		}
	}

}
 
Example 6
Source File: TemplateBaseAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void run( String[] params, ICheatSheetManager manager )
{
	this.params = params;
	IEditorPart editor = UIUtil.getActiveReportEditor( );
	if ( editor instanceof MultiPageReportEditor )
	{
		// switch to Design Page
		( (MultiPageReportEditor) editor ).setActivePage( ReportLayoutEditorFormPage.ID);

		// init some variables
		ReportLayoutEditor reportDesigner = (ReportLayoutEditor) ( (MultiPageReportEditor) editor )
				.getActivePageInstance( );
		AbstractEditPartViewer viewer = (AbstractEditPartViewer) reportDesigner
				.getGraphicalViewer( );

		// tries to select the EditPart for the item name
		selectEditPartForItemName( params[0], (MultiPageReportEditor) editor, viewer );

		// if the viewer selection contains a match for the class, proceed
		selection = matchSelectionType( viewer );
		if ( selection != null )
		{
			IAction action = getAction( reportDesigner );
			if ( action != null && action.isEnabled( ) )
			{
				action.run( );
			}
		}
		else
		{
			// show an error dialog asking to select the right element
			showErrorWrongElementSelection( );
		}
	}
	else
	{
		// show an error asking to select the right editor
		showErrorWrongEditor( );
	}
}
 
Example 7
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void handleKeyReleased(KeyEvent event) {
	if (event.stateMask != 0)
		return;

	int key= event.keyCode;
	if (key == SWT.F5) {
		IAction action= fBuildActionGroup.getRefreshAction();
		if (action.isEnabled())
			action.run();
	}
}
 
Example 8
Source File: PropertiesHandler.java    From tlaplus with MIT License 5 votes vote down vote up
/**
    * {@inheritDoc}
    */
public Object execute(ExecutionEvent event) throws ExecutionException {
	final IAction action = new PropertyDialogAction(UIHelper.getShellProvider(), Activator.getSpecManager());

	action.run();

	return null;
}
 
Example 9
Source File: ModulePropertiesHandler.java    From tlaplus with MIT License 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{

    IAction action = new PropertyDialogAction(UIHelper.getShellProvider(), UIHelper
            .getActiveEditorFileSelectionProvider());
    action.run();

    return null;
}
 
Example 10
Source File: PackageExplorerActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Called by Package Explorer.
 *
 * @param event the open event
 * @param activate <code>true</code> if the opened editor should be activated
 */
/* package */void handleOpen(ISelection event, boolean activate) {
	IAction openAction= fNavigateActionGroup.getOpenAction();
	if (openAction != null && openAction.isEnabled()) {
		// XXX: should use the given arguments instead of using org.eclipse.jface.util.OpenStrategy.activateOnOpen()
		openAction.run();
		return;
	}
}
 
Example 11
Source File: OfflineActionsManager.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @return if an action was binded and was successfully executed
 */
public boolean onOfflineAction(String requestedStr, OfflineActionTarget target) {

    ActionInfo actionInfo = onOfflineActionListeners.get(requestedStr.toLowerCase());
    List<String> parameters = null;
    if (actionInfo == null) {
        List<String> split = StringUtils.split(requestedStr, ' ');
        //We have one more shot: if we have spaces, it can be bound to the first part and have
        //parameters
        if (split.size() > 0) {
            actionInfo = onOfflineActionListeners.get(split.remove(0));
            parameters = split;
        }

        if (actionInfo == null) {
            target.statusError("No action info was found binded to:" + requestedStr);
            return false;
        } else {
            //it has parameters.
        }
    }

    IAction action = actionInfo.action;
    if (action == null) {
        target.statusError("No action was found binded to:" + requestedStr);
        return false;
    }
    if (action instanceof IOfflineActionWithParameters) {
        if (parameters == null) {
            parameters = new ArrayList<String>();
        }
        ((IOfflineActionWithParameters) action).setParameters(parameters);
    }

    try {
        action.run();
    } catch (Throwable e) {
        target.statusError("Exception raised when executing action:" + requestedStr + " - " + e.getMessage());
        Log.log(e);
        return false;
    }
    return true;
}
 
Example 12
Source File: AbstractWorkbenchTestCase.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
protected IAction executePyUnitViewAction(ViewPart view, Class<?> class1) {
    IAction action = getPyUnitViewAction(view, class1);
    action.run();
    return action;
}
 
Example 13
Source File: AbstractCursorHandlingTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void toLineStart(XtextEditor editor) {
	IAction action = editor.getAction(ITextEditorActionDefinitionIds.LINE_START);
	action.run();
}
 
Example 14
Source File: AbstractCursorHandlingTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void navigateRight(XtextEditor editor) {
	IAction action = editor.getAction(ITextEditorActionDefinitionIds.WORD_NEXT);
	action.run();
}
 
Example 15
Source File: AbstractCursorHandlingTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void navigateLeft(XtextEditor editor) {
	IAction action = editor.getAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS);
	action.run();
}
 
Example 16
Source File: AbstractCursorHandlingTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void toLineStart(XtextEditor editor) {
	IAction action = editor.getAction(ITextEditorActionDefinitionIds.LINE_START);
	action.run();
}
 
Example 17
Source File: AbstractCursorHandlingTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void navigateRight(XtextEditor editor) {
	IAction action = editor.getAction(ITextEditorActionDefinitionIds.WORD_NEXT);
	action.run();
}
 
Example 18
Source File: AbstractCursorHandlingTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void navigateLeft(XtextEditor editor) {
	IAction action = editor.getAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS);
	action.run();
}