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 File: ViewDocumentToolbarMenuAction.java    From birt with 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 #2
Source File: LoadFileAction.java    From gef with 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 #3
Source File: DefaultMergeViewer.java    From xtext-eclipse with 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 #4
Source File: VisManLauncher.java    From JAADAS with 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 #5
Source File: ProfileActionBarContributor.java    From neoscada with 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 #6
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 #7
Source File: TeamAction.java    From APICloud-Studio with 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 #8
Source File: TypeScriptEditor.java    From typescript.java with 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 #9
Source File: CommonActionProvider.java    From neoscada with 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 #10
Source File: ProfileActionBarContributor.java    From neoscada with 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 #11
Source File: SDView.java    From tracecompass with 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 #12
Source File: BasicCompilationUnitEditorActionContributor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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 #13
Source File: AcceleoGenerateGeneratorAction.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
 *      org.eclipse.jface.viewers.ISelection)
 * @generated
 */
@Override
@SuppressWarnings ( "unchecked" )
public void selectionChanged ( final IAction action, final ISelection selection )
{
    if ( selection instanceof IStructuredSelection )
    {
        this.files = ( (IStructuredSelection)selection ).toList ();
    }
}
 
Example #14
Source File: ApplyRefactoringScriptAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@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 #15
Source File: ShowWhitespaceCharactersActionContributor.java    From xtext-xtend with 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 #16
Source File: KonsExtension.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IAction[] getActions(){
	IAction[] ret = new IAction[] {
		new AddFindingAction(this)
	};
	return ret;
}
 
Example #17
Source File: WriteAttributesOperationAction.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run ( final IAction action )
{
    if ( this.selection == null )
    {
        return;
    }

    final IWorkbenchWizard wiz = new WriteAttributesOperationWizard ();
    wiz.init ( this.site.getWorkbenchWindow ().getWorkbench (), this.selection );

    // Embed the wizard into a dialog
    final WizardDialog dialog = new WizardDialog ( this.site.getShell (), wiz );
    dialog.open ();
}
 
Example #18
Source File: AbstractChangeDesignAction.java    From ermaster-b with 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 #19
Source File: DecoratedScriptEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void setAction( String actionID, IAction action )
{
	super.setAction( actionID, action );
	if ( action != null && action.getId( ) == null )
	{
		action.setId( actionID );
	}
	if ( action != null )
		getActionRegistry( ).registerAction( action );
}
 
Example #20
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 #21
Source File: ProcessInitDiagramFileAction.java    From bonita-studio with 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 #22
Source File: GlobalizeActionBarContributor.java    From neoscada with 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 #23
Source File: PlayAction.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * The constructor
 * </p>
 * 
 * @param parent
 *            <p>
 *            The PlayableViewPart to whom the object of this class belongs.
 *            </p>
 */
public PlayAction(PlayableViewPart parent) {

	// Call this class' super constructor for a drop-down menu and declare
	// this class as the menu creator
	super(null, IAction.AS_DROP_DOWN_MENU);
	setMenuCreator(this);

	// Store the calling class in the local field
	viewer = parent;

	// Set the text of the "hover" display
	this.setText("Play");

	// Set the button image
	Bundle bundle = FrameworkUtil.getBundle(getClass());
	Path imagePath = new Path(
			"icons" + System.getProperty("file.separator") + "play.gif");
	URL imageURL = FileLocator.find(bundle, imagePath, null);
	ImageDescriptor imageDescriptor = ImageDescriptor
			.createFromURL(imageURL);
	this.setImageDescriptor(imageDescriptor);

	// Create the drop-down selections for 12, 24, and 30 fps and a
	// selection to access the custom frame rate dialog
	FrameRateChangeAction fps12 = new FrameRateChangeAction(12, this,
			"12fps");
	rateActions.add(fps12);
	FrameRateChangeAction fps24 = new FrameRateChangeAction(24, this,
			"24fps");
	rateActions.add(fps24);
	FrameRateChangeAction fps30 = new FrameRateChangeAction(30, this,
			"30fps");
	rateActions.add(fps30);
	FrameRateChangeAction fpsCustom = new FrameRateChangeAction(this,
			"Custom...");
	rateActions.add(fpsCustom);

	return;
}
 
Example #24
Source File: JavaStructureDiffViewer.java    From Eclipse-Postfix-Code-Completion with 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 #25
Source File: TexHardLineWrapAction.java    From texlipse with 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 #26
Source File: PackagesView.java    From Eclipse-Postfix-Code-Completion with 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 #27
Source File: ShowBrowserEditorAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IAction action) {
	try {
		IWorkbenchBrowserSupport workbenchBrowserSupport = PlatformUI.getWorkbench().getBrowserSupport();
		if (workbenchBrowserSupport.isInternalWebBrowserAvailable()) {
			IWebBrowser webBrowser = workbenchBrowserSupport.createBrowser(IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.STATUS, null, null, null);
			if (webBrowser != null) {
				webBrowser.openURL(null);
			}
		}
	} catch (PartInitException e) {
		IdeLog.logError(BrowserPlugin.getDefault(), e);
	}
}
 
Example #28
Source File: AcceleoGenerateSwitchyardAction.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**{@inheritDoc}
 *
 * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
 * @generated
 */
@SuppressWarnings("unchecked")
public void selectionChanged(IAction action, ISelection selection) {
	if (selection instanceof IStructuredSelection) {
		files = ((IStructuredSelection) selection).toList();
	}
}
 
Example #29
Source File: PyToggleForceTabs.java    From Pydev with 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 File: AddDerbyNature.java    From gemfirexd-oss with 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);
    }

}