org.eclipse.jface.action.IAction Java Examples

The following examples show how to use org.eclipse.jface.action.IAction. 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 Project: JAADAS   Author: flankerhqd   File: VisManLauncher.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void selectionChanged(IAction action, ISelection selection) {
	if (selection instanceof IStructuredSelection){
		IStructuredSelection struct = (IStructuredSelection)selection;
		Iterator it = struct.iterator();
		while (it.hasNext()){
			Object next = it.next();
			if (next instanceof IResource) {
				setProj(((IResource)next).getProject());
				setRec((IResource)next);
			}
			else if (next instanceof IJavaElement) {
				IJavaElement jElem = (IJavaElement)next;
				setProj(jElem.getJavaProject().getProject());
				setRec(jElem.getResource());
			}
		}
	}
}
 
Example #2
Source Project: neoscada   Author: eclipse   File: ProfileActionBarContributor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.MenuManager}s containing
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> collection, by inserting them before the specified contribution
 * item <code>contributionID</code>.
 * If <code>contributionID</code> is <code>null</code>, they are simply added.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void populateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions, String contributionID )
{
    if ( submenuActions != null )
    {
        for ( Map.Entry<String, Collection<IAction>> entry : submenuActions.entrySet () )
        {
            MenuManager submenuManager = new MenuManager ( entry.getKey () );
            if ( contributionID != null )
            {
                manager.insertBefore ( contributionID, submenuManager );
            }
            else
            {
                manager.add ( submenuManager );
            }
            populateManager ( submenuManager, entry.getValue (), null );
        }
    }
}
 
Example #3
Source Project: APICloud-Studio   Author: apicloudcom   File: TeamAction.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void selectionChanged(IAction action, ISelection sel) {
	if (sel instanceof IStructuredSelection) {
		this.selection = (IStructuredSelection) sel;
		if (action != null) {
			setActionEnablement(action);
		}
	}
	if (sel instanceof ITextSelection){
			IEditorPart part = getTargetPage().getActiveEditor();
			if (part != null) {
				IEditorInput input = part.getEditorInput();
				IResource r = (IResource) input.getAdapter(IResource.class);
				if (r != null) {
					switch(r.getType()){
						case IResource.FILE:
							this.selection = new StructuredSelection(r);
							if (action != null) {
								setActionEnablement(action);
							}
						break;
					}
				}	//	set selection to current editor file;
			}
	}
}
 
Example #4
Source Project: birt   Author: eclipse   File: ViewDocumentToolbarMenuAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void gendoc( IAction action )
{
	ReportDocumentEditor editor = getActiveReportEditor( false );
	String url = null;
	if ( editor != null )
	{
		url = editor.getFileName( );
	}
	if (url == null)
	{
		return ;
	}
	Map options = new HashMap( );
	options.put( WebViewer.FORMAT_KEY, WebViewer.HTML );
	options.put( WebViewer.RESOURCE_FOLDER_KEY,
			ReportPlugin.getDefault( )
					.getResourceFolder( UIUtil.getCurrentProject( ) ) );

	WebViewer.display( url, options );
}
 
Example #5
Source Project: typescript.java   Author: angelozerr   File: TypeScriptEditor.java    License: MIT License 6 votes vote down vote up
@Override
public void editorContextMenuAboutToShow(IMenuManager menu) {

	super.editorContextMenuAboutToShow(menu);
	menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));

	ActionContext context = new ActionContext(getSelectionProvider().getSelection());
	fContextMenuGroup.setContext(context);
	fContextMenuGroup.fillContextMenu(menu);
	fContextMenuGroup.setContext(null);

	// Quick views
	IAction action = getAction(ITypeScriptEditorActionDefinitionIds.SHOW_OUTLINE);
	menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
	action = getAction(ITypeScriptEditorActionDefinitionIds.OPEN_IMPLEMENTATION);
	menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);

}
 
Example #6
Source Project: neoscada   Author: eclipse   File: CommonActionProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init ( final ICommonActionExtensionSite aSite )
{
    super.init ( aSite );
    final ICommonViewerSite viewSite = aSite.getViewSite ();
    if ( viewSite instanceof ICommonViewerWorkbenchSite )
    {
        final ICommonViewerWorkbenchSite workbenchSite = (ICommonViewerWorkbenchSite)viewSite;
        this.openAction = new Action ( "Open", IAction.AS_PUSH_BUTTON ) {
            @Override
            public void run ()
            {
                handleOpen ( workbenchSite );
            }
        };
    }
}
 
Example #7
Source Project: gef   Author: eclipse   File: LoadFileAction.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void run(IAction action) {
	FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);

	dialog.setText("Select text file...");
	String sourceFile = dialog.open();
	if (sourceFile == null)
		return;
	ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell());
	try {
		List<Type> types = TypeCollector.getData(new File(sourceFile), "UTF-8");
		pd.setBlockOnOpen(false);
		pd.open();
		pd.getProgressMonitor().beginTask("Generating cloud...", 200);
		TagCloudViewer viewer = getViewer();
		viewer.setInput(types, pd.getProgressMonitor());
		// viewer.getCloud().layoutCloud(pd.getProgressMonitor(), false);
	} catch (IOException e) {
		e.printStackTrace();
	} finally {
		pd.close();
	}
}
 
Example #8
Source Project: neoscada   Author: eclipse   File: ProfileActionBarContributor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
 * by inserting them before the specified contribution item <code>contributionID</code>.
 * If <code>contributionID</code> is <code>null</code>, they are simply added.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void populateManager ( IContributionManager manager, Collection<? extends IAction> actions, String contributionID )
{
    if ( actions != null )
    {
        for ( IAction action : actions )
        {
            if ( contributionID != null )
            {
                manager.insertBefore ( contributionID, action );
            }
            else
            {
                manager.add ( action );
            }
        }
    }
}
 
Example #9
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 #10
Source Project: xtext-eclipse   Author: eclipse   File: DefaultMergeViewer.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void setActionsActivated(SourceViewer sourceViewer, boolean state) {
	DefaultMergeEditor mergeEditor = getEditor(sourceViewer);
	if (mergeEditor != null) {
		mergeEditor.setActionsActivated(state);
		IAction saveAction = mergeEditor.getAction(ITextEditorActionConstants.SAVE);
		if (saveAction instanceof IPageListener) {
			PartEventAction partEventAction = (PartEventAction) saveAction;
			IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart();
			if (state) {
				partEventAction.partActivated(compareEditorPart);
			} else {
				partEventAction.partDeactivated(compareEditorPart);
			}
		}
	}
}
 
Example #11
Source Project: spotbugs   Author: spotbugs   File: FilterPatternAction.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
    if (targetPart instanceof CommonNavigator) {
        navigator = (CommonNavigator) targetPart;
        useSpecificPattern = action.getId().startsWith("de.tobject.findbugs.filterSpecificPattern");
    }
}
 
Example #12
Source Project: gama   Author: gama-platform   File: DelegateForAllElements.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run(final IAction action) {
	try {
		WorkbenchHelper.runCommand("org.eclipse.xtext.ui.shared.OpenXtextElementCommand");
	} catch (final ExecutionException e) {
		e.printStackTrace();
	}
}
 
Example #13
Source Project: statecharts   Author: Yakindu   File: DocumentationMenuAction.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public DocumentationMenuAction() {
	super("Toggle Documentation", IAction.AS_DROP_DOWN_MENU);
	setId(ID);
	setMenuCreator(this);
	setImageDescriptor(StatechartImages.MENU.imageDescriptor());
	actions = new ArrayList<Action>();
	createActions();
}
 
Example #14
Source Project: spotbugs   Author: spotbugs   File: LoadXmlAction.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void run(final IAction action) {
    if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
        return;
    }
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;

    IProject project = getProject(structuredSelection);
    if (project == null) {
        return;
    }

    // Get the file name from a file dialog
    FileDialog dialog = createFileDialog(project);
    boolean validFileName = false;
    do {
        String fileName = openFileDialog(dialog);
        if (fileName == null) {
            // user cancel
            return;
        }
        validFileName = validateSelectedFileName(fileName);
        if (!validFileName) {
            MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning", fileName
                    + " is not a file or is not readable!");
            continue;
        }
        getDialogSettings().put(LOAD_XML_PATH_KEY, fileName);
        work(project, fileName);
    } while (!validFileName);
}
 
Example #15
Source Project: ermaster-b   Author: naoki-iwami   File: AbstractChangeDesignAction.java    License: Apache License 2.0 5 votes vote down vote up
public AbstractChangeDesignAction(String ID, String type,
		ERDiagramEditor editor) {
	super(ID, ResourceString
			.getResourceString("action.title.change.design." + type),
			IAction.AS_RADIO_BUTTON, editor);

	this.type = type;
}
 
Example #16
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: JavaPluginImages.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private static void setImageDescriptors(IAction action, String type, String relPath) {
	ImageDescriptor id= create("d" + type, relPath, false); //$NON-NLS-1$
	if (id != null)
		action.setDisabledImageDescriptor(id);

	/*
	 * id= create("c" + type, relPath, false); //$NON-NLS-1$
	 * if (id != null)
	 * 		action.setHoverImageDescriptor(id);
	 */

	ImageDescriptor descriptor= create("e" + type, relPath, true); //$NON-NLS-1$
	action.setHoverImageDescriptor(descriptor);
	action.setImageDescriptor(descriptor);
}
 
Example #17
Source Project: M2Doc   Author: ObeoNetwork   File: GenconfActionBarContributor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
 * by inserting them before the specified contribution item <code>contributionID</code>.
 * If <code>contributionID</code> is <code>null</code>, they are simply added.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions,
        String contributionID) {
    if (actions != null) {
        for (IAction action : actions) {
            if (contributionID != null) {
                manager.insertBefore(contributionID, action);
            } else {
                manager.add(action);
            }
        }
    }
}
 
Example #18
Source Project: statecharts   Author: Yakindu   File: StyledTextActionHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the default <code>IAction</code> handler for the Paste action. This
 * <code>IAction</code> is only active if the <code>StyledText</code> is not in
 * focus.
 *
 * @param action
 *            the <code>IAction</code> to run for the Paste action, or
 *            <code>null</null> if not interested.
 */
public void setPasteAction(IAction action) {
	if (pasteAction == action)
		return;

	if (pasteAction != null)
		pasteAction.removePropertyChangeListener(pasteActionListener);

	pasteAction = action;

	if (pasteAction != null)
		pasteAction.addPropertyChangeListener(pasteActionListener);
	styledTextPasteActionHandler.updateEnabledState();
}
 
Example #19
Source Project: bonita-studio   Author: bonitasoft   File: ProcessInitDiagramFileAction.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public void selectionChanged(IAction action, ISelection selection) {
	domainModelURI = null;
	action.setEnabled(false);
	if (selection instanceof IStructuredSelection == false || selection.isEmpty()) {
		return;
	}
	IFile file = (IFile) ((IStructuredSelection) selection).getFirstElement();
	domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
	action.setEnabled(true);
}
 
Example #20
Source Project: xtext-xtend   Author: eclipse   File: ShowWhitespaceCharactersActionContributor.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
	public void contributeActions(XtextEditor editor) {
		IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
		IAction action = editor.getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
		action.setImageDescriptor(imageHelper
				.getImageDescriptor("full/etool16/show_whitespace_chars.gif"));
		action.setDisabledImageDescriptor(imageHelper
				.getImageDescriptor("full/dtool16/show_whitespace_chars.gif"));
		if(toolBarManager.find(action.getId())==null) {
			toolBarManager.add(new ActionContributionItemExtension(action));				
//			toolBarManager.add(action);				
		}
	}
 
Example #21
Source Project: tracecompass   Author: tracecompass   File: SDView.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Enables or disables the Pages... menu item, depending on the number of pages
 *
 * @param bar the bar containing the action
 */
protected void updatePagesMenuItem(IActionBars bar) {
    if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) {
        IMenuManager menuManager = bar.getMenuManager();
        ActionContributionItem contributionItem = (ActionContributionItem) menuManager.find(OpenSDPagesDialog.ID);
        IAction openSDPagesDialog = null;
        if (contributionItem != null) {
            openSDPagesDialog = contributionItem.getAction();
        }

        if (openSDPagesDialog instanceof OpenSDPagesDialog) {
            openSDPagesDialog.setEnabled(((ISDAdvancedPagingProvider) fSdPagingProvider).pagesCount() > 1);
        }
    }
}
 
Example #22
@Override
public void contributeToMenu(IMenuManager menu) {

	super.contributeToMenu(menu);
	if (fContentAssistMenuListener != null)
		fContentAssistMenuListener.dispose();

	IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
	if (editMenu != null) {
		editMenu.add(fChangeEncodingAction);
		IMenuManager caMenu= new MenuManager(JavaEditorMessages.BasicEditorActionContributor_specific_content_assist_menu, "specific_content_assist"); //$NON-NLS-1$
		editMenu.insertAfter(ITextEditorActionConstants.GROUP_ASSIST, caMenu);

		caMenu.add(fRetargetContentAssist);
		Collection<CompletionProposalCategory> descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
		List<IAction> specificAssistActions= new ArrayList<IAction>(descriptors.size());
		for (Iterator<CompletionProposalCategory> it= descriptors.iterator(); it.hasNext();) {
			final CompletionProposalCategory cat= it.next();
			if (cat.hasComputers()) {
				IAction caAction= new SpecificContentAssistAction(cat);
				caMenu.add(caAction);
				specificAssistActions.add(caAction);
			}
		}
		fSpecificAssistActions= specificAssistActions.toArray(new SpecificContentAssistAction[specificAssistActions.size()]);
		if (fSpecificAssistActions.length > 0) {
			fContentAssistMenuListener= new MenuListener(caMenu);
			caMenu.addMenuListener(fContentAssistMenuListener);
		}
		caMenu.add(new Separator("context_info")); //$NON-NLS-1$
		caMenu.add(fContextInformation);

		editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, fQuickAssistAction);
	}
}
 
Example #23
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: JavaBrowsingPart.java    License: 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 #24
/**
 * {@inheritDoc}
 */
public void run(final IAction a) {
	if (fWindow != null) {
		org.eclipse.ltk.ui.refactoring.actions.ApplyRefactoringScriptAction action= new org.eclipse.ltk.ui.refactoring.actions.ApplyRefactoringScriptAction();
		action.init(fWindow);
		action.run(a);
	}
}
 
Example #25
Source Project: neoscada   Author: eclipse   File: GlobalizeActionBarContributor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
 * and returns the collection of these actions.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected Collection<IAction> generateCreateSiblingActions ( Collection<?> descriptors, ISelection selection )
{
    Collection<IAction> actions = new ArrayList<IAction> ();
    if ( descriptors != null )
    {
        for ( Object descriptor : descriptors )
        {
            actions.add ( new CreateSiblingAction ( activeEditorPart, selection, descriptor ) );
        }
    }
    return actions;
}
 
Example #26
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: JavaStructureDiffViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Overriden to create a "smart" button in the viewer's pane control bar.
 * <p>
 * Clients can override this method and are free to decide whether they want to call
 * the inherited method.
 *
 * @param toolBarManager the toolbar manager for which to add the buttons
 */
@Override
protected void createToolItems(ToolBarManager toolBarManager) {

	super.createToolItems(toolBarManager);

	IAction a= new ChangePropertyAction(getBundle(), getCompareConfiguration(), "action.Smart.", SMART); //$NON-NLS-1$
	fSmartActionItem= new ActionContributionItem(a);
	fSmartActionItem.setVisible(fThreeWay);
	toolBarManager.appendToGroup("modes", fSmartActionItem); //$NON-NLS-1$
}
 
Example #27
Source Project: texlipse   Author: eclipse   File: TexHardLineWrapAction.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/** 
 * When the user presses <code>Esc, q</code> or selects from menu bar
 * <code>Wrap Lines</code> this method is invoked.
 * @param action	an action that invokes  
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 */
public void run(IAction action) {
    this.lineLength = TexlipsePlugin.getDefault().getPreferenceStore().getInt(TexlipseProperties.WORDWRAP_LENGTH);
    this.tabWidth = TexlipsePlugin.getDefault().getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
    TexSelections selection = new TexSelections(getTexEditor());
    try {
        doWrapB(selection);
    } catch(BadLocationException e) {
        TexlipsePlugin.log("TexCorrectIndentationAction.run", e);
    }
}
 
Example #28
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: PackagesView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private MultiActionGroup createSwitchActionGroup(){

		LayoutAction switchToFlatViewAction= new LayoutAction(JavaBrowsingMessages.PackagesView_flatLayoutAction_label,LIST_VIEW_STATE);
		LayoutAction switchToHierarchicalViewAction= new LayoutAction(JavaBrowsingMessages.PackagesView_HierarchicalLayoutAction_label, TREE_VIEW_STATE);
		JavaPluginImages.setLocalImageDescriptors(switchToFlatViewAction, "flatLayout.gif"); //$NON-NLS-1$
		JavaPluginImages.setLocalImageDescriptors(switchToHierarchicalViewAction, "hierarchicalLayout.gif"); //$NON-NLS-1$

		return new LayoutActionGroup(new IAction[]{switchToFlatViewAction,switchToHierarchicalViewAction}, fCurrViewState);
	}
 
Example #29
Source Project: Pydev   Author: fabioz   File: PyToggleForceTabs.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run(IAction action) {
    if (targetEditor instanceof PyEdit) {
        PyEdit pyEdit = (PyEdit) targetEditor;
        IIndentPrefs indentPrefs = pyEdit.getIndentPrefs();
        indentPrefs.setForceTabs(!indentPrefs.getForceTabs());
        updateActionState(indentPrefs);
    }
}
 
Example #30
Source Project: gemfirexd-oss   Author: gemxd   File: AddDerbyNature.java    License: Apache License 2.0 5 votes vote down vote up
public void selectionChanged(IAction action, ISelection selection)
{
    currentJavaProject = SelectionUtil.findSelectedJavaProject(selection);

    if (currentJavaProject == null)
    {
        currentProject = com.pivotal.gemfirexd.internal.ui.util.SelectionUtil
                .findSelectedProject(selection);
    }

}