org.eclipse.jface.viewers.EditingSupport#org.eclipse.jface.action.IAction源码实例Demo

下面列出了org.eclipse.jface.viewers.EditingSupport#org.eclipse.jface.action.IAction 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: JAADAS   文件: VisManLauncher.java
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());
			}
		}
	}
}
 
源代码2 项目: neoscada   文件: ProfileActionBarContributor.java
/**
 * 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 );
        }
    }
}
 
源代码3 项目: APICloud-Studio   文件: TeamAction.java
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;
			}
	}
}
 
源代码4 项目: birt   文件: ViewDocumentToolbarMenuAction.java
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 );
}
 
源代码5 项目: typescript.java   文件: TypeScriptEditor.java
@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);

}
 
源代码6 项目: neoscada   文件: CommonActionProvider.java
@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 );
            }
        };
    }
}
 
源代码7 项目: gef   文件: LoadFileAction.java
@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();
	}
}
 
源代码8 项目: neoscada   文件: ProfileActionBarContributor.java
/**
 * 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 );
            }
        }
    }
}
 
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);
			}
		}
	}
}
 
源代码10 项目: xtext-eclipse   文件: DefaultMergeViewer.java
@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);
			}
		}
	}
}
 
源代码11 项目: spotbugs   文件: FilterPatternAction.java
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
    if (targetPart instanceof CommonNavigator) {
        navigator = (CommonNavigator) targetPart;
        useSpecificPattern = action.getId().startsWith("de.tobject.findbugs.filterSpecificPattern");
    }
}
 
源代码12 项目: gama   文件: DelegateForAllElements.java
@Override
public void run(final IAction action) {
	try {
		WorkbenchHelper.runCommand("org.eclipse.xtext.ui.shared.OpenXtextElementCommand");
	} catch (final ExecutionException e) {
		e.printStackTrace();
	}
}
 
源代码13 项目: statecharts   文件: DocumentationMenuAction.java
public DocumentationMenuAction() {
	super("Toggle Documentation", IAction.AS_DROP_DOWN_MENU);
	setId(ID);
	setMenuCreator(this);
	setImageDescriptor(StatechartImages.MENU.imageDescriptor());
	actions = new ArrayList<Action>();
	createActions();
}
 
源代码14 项目: spotbugs   文件: LoadXmlAction.java
@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);
}
 
源代码15 项目: ermaster-b   文件: AbstractChangeDesignAction.java
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;
}
 
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);
}
 
源代码17 项目: M2Doc   文件: GenconfActionBarContributor.java
/**
 * 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);
            }
        }
    }
}
 
源代码18 项目: statecharts   文件: StyledTextActionHandler.java
/**
 * 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();
}
 
/**
* @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);
}
 
@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);				
		}
	}
 
源代码21 项目: tracecompass   文件: SDView.java
/**
 * 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);
        }
    }
}
 
@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);
	}
}
 
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();
	}
}
 
/**
 * {@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);
	}
}
 
源代码25 项目: neoscada   文件: GlobalizeActionBarContributor.java
/**
 * 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;
}
 
/**
 * 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$
}
 
源代码27 项目: texlipse   文件: TexHardLineWrapAction.java
/** 
 * 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);
    }
}
 
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);
	}
 
源代码29 项目: Pydev   文件: PyToggleForceTabs.java
@Override
public void run(IAction action) {
    if (targetEditor instanceof PyEdit) {
        PyEdit pyEdit = (PyEdit) targetEditor;
        IIndentPrefs indentPrefs = pyEdit.getIndentPrefs();
        indentPrefs.setForceTabs(!indentPrefs.getForceTabs());
        updateActionState(indentPrefs);
    }
}
 
源代码30 项目: gemfirexd-oss   文件: AddDerbyNature.java
public void selectionChanged(IAction action, ISelection selection)
{
    currentJavaProject = SelectionUtil.findSelectedJavaProject(selection);

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

}