Java Code Examples for org.eclipse.jface.action.IAction#isEnabled()
The following examples show how to use
org.eclipse.jface.action.IAction#isEnabled() .
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: UpdateAction.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public void execute(IAction action) throws InterruptedException, InvocationTargetException { if (action != null && !action.isEnabled()) { action.setEnabled(true); } else { IPreferenceStore store = SVNUIPlugin.getPlugin().getPreferenceStore(); IResource[] resources = getSelectedResources(); SVNConflictResolver conflictResolver = new SVNConflictResolver(resources[0], store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_TEXT_FILES), store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_BINARY_FILES), store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_PROPERTIES), store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_TREE_CONFLICTS)); UpdateOperation updateOperation = new UpdateOperation(getTargetPart(), resources, SVNRevision.HEAD); updateOperation.setDepth(depth); updateOperation.setSetDepth(setDepth); updateOperation.setForce(store.getBoolean(ISVNUIConstants.PREF_UPDATE_TO_HEAD_ALLOW_UNVERSIONED_OBSTRUCTIONS)); updateOperation.setIgnoreExternals(store.getBoolean(ISVNUIConstants.PREF_UPDATE_TO_HEAD_IGNORE_EXTERNALS)); updateOperation.setCanRunAsJob(canRunAsJob); updateOperation.setConflictResolver(conflictResolver); updateOperation.run(); } }
Example 2
Source File: TabularDimensionNodeProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates the context menu for the given object. Gets the action from the * actionRegistry and adds the action to the menu. * * @param menu * the menu * @param object * the object */ public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { super.createContextMenu( sourceViewer, object, menu ); if ( ( (DimensionHandle) object ).canEdit( ) ) { menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS, new EditCubeDimensionAction( object, Messages.getString( "CubeDimensionNodeProvider.menu.text" ) ) ); //$NON-NLS-1$ } menu.insertBefore( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", //$NON-NLS-1$ new ShowPropertyAction( object ) ); menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", new Separator( ) ); //$NON-NLS-1$ IAction action = new RefreshAction( sourceViewer ); if (action.isEnabled( )) { menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", action ); //$NON-NLS-1$ } }
Example 3
Source File: EditorUtility.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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: DataSetNodeProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates the context menu for the given object. Gets the action from the * actionRegistry and adds the action to the menu. * * @param menu * the menu * @param object * the object */ public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { super.createContextMenu( sourceViewer, object, menu ); menu.insertBefore( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", //$NON-NLS-1$ new ShowPropertyAction( object ) ); menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", new Separator( ) ); //$NON-NLS-1$ IAction action = new RefreshAction( sourceViewer ); if (action.isEnabled( )) { menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", action ); //$NON-NLS-1$ } }
Example 5
Source File: LeveAttributelNodeProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates the context menu for the given object. Gets the action from the * actionRegistry and adds the action to the menu. * * @param menu * the menu * @param object * the object */ public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { super.createContextMenu( sourceViewer, object, menu ); menu.insertBefore( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", //$NON-NLS-1$ new ShowPropertyAction( object ) ); menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", new Separator( ) ); //$NON-NLS-1$ IAction action = new RefreshAction( sourceViewer ); if (action.isEnabled( )) { menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", action ); //$NON-NLS-1$ } }
Example 6
Source File: TableEditPart.java From birt with Eclipse Public License 1.0 | 6 votes |
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 7
Source File: GenerateActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private int addAction(IMenuManager menu, IAction action) { if (action != null && action.isEnabled()) { menu.add(action); return 1; } return 0; }
Example 8
Source File: TemplateBaseAction.java From birt with Eclipse Public License 1.0 | 5 votes |
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 9
Source File: ShowAnnotationAction.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Action to open a SVN Annotate View */ public void execute(IAction action) throws InvocationTargetException, InterruptedException { // try to enable action if not enabled, for keyboard activated actions if (action != null && !action.isEnabled()) { action.setEnabled(true); } else { // Get the selected resource. final ISVNRemoteFile svnResource = getSingleSelectedSVNRemoteFile(); execute(svnResource); } }
Example 10
Source File: UnlockAction.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void execute(IAction action) throws InvocationTargetException, InterruptedException { if (action != null && !action.isEnabled()) { action.setEnabled(true); } else { if (getSelectedResources() != null && getSelectedResources().length > 0) { final IResource[] resources = getSelectedResources(); run(new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { try { Hashtable table = getProviderMapping(getSelectedResources()); Set keySet = table.keySet(); Iterator iterator = keySet.iterator(); while (iterator.hasNext()) { SVNTeamProvider provider = (SVNTeamProvider)iterator.next(); UnlockResourcesCommand command = new UnlockResourcesCommand(provider.getSVNWorkspaceRoot(), resources, false); command.run(Policy.subMonitorFor(monitor,1000)); } } catch (TeamException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }, true /* cancelable */, PROGRESS_DIALOG); } } }
Example 11
Source File: PackageExplorerActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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 12
Source File: ListBandEditPart.java From birt with Eclipse Public License 1.0 | 5 votes |
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 13
Source File: JavaBrowsingPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 14
Source File: ActivationCodeTrigger.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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 15
Source File: TabularCubeNodeProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Creates the context menu for the given object. Gets the action from the * actionRegistry and adds the action to the menu. * * @param menu * the menu * @param object * the object */ public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { menu.add( new Separator( ) ); InsertCubeInLayoutAction insertAction = new InsertCubeInLayoutAction( object ); if ( insertAction.isEnabled( ) ) { menu.add( insertAction ); } super.createContextMenu( sourceViewer, object, menu ); if ( ( (CubeHandle) object ).canEdit( ) ) { menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS, new EditCubeAction( object, Messages.getString( "InsertCubeInLayoutAction.menu.text" ) ) ); //$NON-NLS-1$ } menu.insertBefore( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", //$NON-NLS-1$ new ShowPropertyAction( object ) ); menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", new Separator( ) ); //$NON-NLS-1$ IAction action = new RefreshAction( sourceViewer ); if ( action.isEnabled( ) ) { menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", action ); //$NON-NLS-1$ } }
Example 16
Source File: DeclarationsSearchGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void addAction(IAction action, IMenuManager manager) { if (action.isEnabled()) { manager.add(action); } }
Example 17
Source File: OpenEditorActionGroup.java From typescript.java with MIT License | 4 votes |
private void appendToGroup(IMenuManager menu, IAction action) { if (action.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action); }
Example 18
Source File: ShowActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void appendToGroup(IMenuManager menu, IAction action) { if (action.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, action); }
Example 19
Source File: OpenEditorActionGroup.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
private void appendToGroup(IMenuManager menu, IAction action) { if (action.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action); }
Example 20
Source File: ReferencesSearchGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void addAction(IAction action, IMenuManager manager) { if (action.isEnabled()) { manager.add(action); } }