@Override public void init(final ICommonActionExtensionSite aSite) { delegateSelectionProvider = new DelegateSelectionProvider( aSite.getViewSite().getSelectionProvider()); propertiesAction = new PropertyDialogAction(new IShellProvider() { @Override public Shell getShell() { return aSite.getViewSite().getShell(); } },delegateSelectionProvider); propertiesAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES); }
public void run(IAction action) { PropertyDialogAction propertyDialogAction = new PropertyDialogAction( new SameShellProvider(mParentShell), this); propertyDialogAction .selectionChanged((IStructuredSelection) getSelection()); if (!mConnectionProfile.arePropertiesComplete() && propertyDialogAction.isApplicableForSelection()) { PreferenceDialog dialog = propertyDialogAction.createDialog(); String initialPage = getInitialPropertyPageID(); if (initialPage != null) { ((IWorkbenchPreferenceContainer) dialog).openPage( initialPage, null); } if (dialog.open() == Dialog.CANCEL) { return; } } new PingJob(mParentShell, mConnectionProfile).schedule(); }
public void fillContextMenu(IMenuManager menu) { // view must exist if we create a context menu for it. ISelection selection= getContext().getSelection(); if (selection instanceof IStructuredSelection) { addOpenWithMenu(menu, (IStructuredSelection) selection); if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && fOpenPropertiesDialog.isApplicableForSelection((IStructuredSelection) selection)) menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog); } }
/** * Returns whether this action is actually applicable to the current * selection. If this action is disabled, it will return <code>false</code> * without further calculation. If it is enabled, it will check with the * workbench's property page manager to see if there are any property pages * registered for the selected element's type. * <p> * This method is generally too expensive to use when updating the enabled * state of the action on each selection change. * </p> * * @return <code>true</code> if the selection is not empty and there are * property pages for the selected element, and <code>false</code> * otherwise */ public boolean isApplicableForSelection() { if (!isEnabled()) { return false; } return isApplicableForSelection(getStructuredSelection()); }
/** * @see IActionDelegate#run(IAction) */ public void run(IAction action) { if(fBreakpoint != null) { IShellProvider provider; if (fPart != null) { provider = fPart.getSite(); } else { provider = new IShellProvider() { public Shell getShell() { return JDIDebugUIPlugin.getActiveWorkbenchShell(); } }; } PropertyDialogAction propertyAction= new PropertyDialogAction(provider, new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return new StructuredSelection(fBreakpoint); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); propertyAction.run(); } }
public NewTextSearchActionGroup(IViewPart part) { Assert.isNotNull(part); IWorkbenchPartSite site= part.getSite(); fSelectionProvider= site.getSelectionProvider(); fPage= site.getPage(); fOpenPropertiesDialog= new PropertyDialogAction(site, fSelectionProvider); fOpenAction= new OpenFileAction(fPage); ISelection selection= fSelectionProvider.getSelection(); if (selection instanceof IStructuredSelection) fOpenPropertiesDialog.selectionChanged((IStructuredSelection)selection); else fOpenPropertiesDialog.selectionChanged(selection); }
/** * Create actions for this rendering */ protected void createActions() { fCopyToClipboardAction = new AsyncCopyTableRenderingAction(this, fTableViewer); fGoToAddressAction = new RenderingGoToAddressAction(getMemoryRenderingContainer(), this); fResetMemoryBlockAction = new ResetToBaseAddressAction(this); fPrintViewTabAction = new AsyncPrintTableRenderingAction(this, fTableViewer); fFormatRenderingAction = new FormatTableRenderingAction(this); fReformatAction = new ReformatAction(this); fToggleAddressColumnAction = new ToggleAddressColumnAction(); IMemoryRenderingSite site = getMemoryRenderingContainer().getMemoryRenderingSite(); if (site.getSite().getSelectionProvider() != null) { fPropertiesDialogAction = new PropertyDialogAction(site.getSite(), site.getSite().getSelectionProvider()); } fNextAction = new NextPageAction(); fPrevAction = new PrevPageAction(); }
@Override public void setContext(ActionContext context) { super.setContext(context); propertiesAction.selectionChanged(delegateSelectionProvider .getSelection()); }
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (propertiesAction.isApplicableForSelection()) { menu.appendToGroup(ICommonMenuConstants.GROUP_PROPERTIES, propertiesAction); } }
action.setEnabled(action.isApplicableForSelection() && !(element instanceof ILaunch)); menu.add(action); menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
@Override public void selectionChanged(IStructuredSelection selection) { setEnabled(!selection.isEmpty()); } }
public NewTextSearchActionGroup(IViewPart part) { Assert.isNotNull(part); IWorkbenchPartSite site= part.getSite(); fSelectionProvider= site.getSelectionProvider(); fPage= site.getPage(); fOpenPropertiesDialog= new PropertyDialogAction(site, fSelectionProvider); fOpenAction= new OpenFileAction(fPage); ISelection selection= fSelectionProvider.getSelection(); if (selection instanceof IStructuredSelection) fOpenPropertiesDialog.selectionChanged((IStructuredSelection)selection); else fOpenPropertiesDialog.selectionChanged(selection); }
/** * Create actions for this rendering */ protected void createActions() { fCopyToClipboardAction = new CopyTableRenderingToClipboardAction(this, fTableViewer); fGoToAddressAction = new GoToAddressAction(getMemoryRenderingContainer(), this); fResetMemoryBlockAction = new ResetToBaseAddressAction(this); fPrintViewTabAction = new PrintTableRenderingAction(this, fTableViewer); fFormatRenderingAction = new FormatTableRenderingAction(this); fReformatAction = new ReformatAction(this); fToggleAddressColumnAction = new ToggleAddressColumnAction(); IMemoryRenderingSite site = getMemoryRenderingContainer().getMemoryRenderingSite(); if (site.getSite().getSelectionProvider() != null) { fPropertiesAction = new PropertyDialogAction(site.getSite(),site.getSite().getSelectionProvider()); } fNextAction = new NextPageAction(); fPrevAction = new PrevPageAction(); }
/** * @see Action#run() */ public void run() { if (getBreakpoint() != null) { PropertyDialogAction action= new PropertyDialogAction(getEditor().getEditorSite(), new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { } public ISelection getSelection() { return new StructuredSelection(getBreakpoint()); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { } public void setSelection(ISelection selection) { } }); action.run(); } }
private void initialize(ISelectionProvider provider) { fSelectionProvider= provider; ISelection selection= provider.getSelection(); fOpenSuperImplementation.update(selection); fOpenExternalJavadoc.update(selection); fOpenTypeHierarchy.update(selection); fOpenCallHierarchy.update(selection); if (!fEditorIsOwner) { if (fShowOpenPropertiesAction) { if (selection instanceof IStructuredSelection) { fOpenPropertiesDialog.selectionChanged((IStructuredSelection) selection); } else { fOpenPropertiesDialog.selectionChanged(selection); } } provider.addSelectionChangedListener(fOpenSuperImplementation); provider.addSelectionChangedListener(fOpenExternalJavadoc); provider.addSelectionChangedListener(fOpenTypeHierarchy); provider.addSelectionChangedListener(fOpenCallHierarchy); // no need to register the open properties dialog action since it registers itself } }
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (!fIsTypeHiararchyViewerOwner) appendToGroup(menu, fOpenTypeHierarchy); if (!fIsCallHiararchyViewerOwner) appendToGroup(menu, fOpenCallHierarchy); if (fShowShowInMenu) { MenuManager showInSubMenu= new MenuManager(getShowInMenuLabel()); IWorkbenchWindow workbenchWindow= fOpenSuperImplementation.getSite().getWorkbenchWindow(); showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(workbenchWindow)); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, showInSubMenu); } IStructuredSelection selection= getStructuredSelection(); if (fShowOpenPropertiesAction && selection != null && fOpenPropertiesDialog.isApplicableForSelection()) menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog); }
/** * Updates the actions which were added to the action bars, * delegating to the subgroups as necessary. */ @Override public void updateActionBars() { IStructuredSelection selection = (IStructuredSelection) getContext() .getSelection(); propertyDialogAction.setEnabled(selection.size() == 1); addBookmarkAction.selectionChanged(selection); addTaskAction.selectionChanged(selection); gotoGroup.updateActionBars(); openGroup.updateActionBars(); refactorGroup.updateActionBars(); workingSetGroup.updateActionBars(); sortAndFilterGroup.updateActionBars(); workspaceGroup.updateActionBars(); undoRedoGroup.updateActionBars(); }
private void createSiteActions(IWorkbenchSite site, ISelectionProvider specialProvider) { fOpenSuperImplementation= new OpenSuperImplementationAction(site); fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION); fOpenSuperImplementation.setSpecialSelectionProvider(specialProvider); fOpenExternalJavadoc= new OpenExternalJavadocAction(site); fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC); fOpenExternalJavadoc.setSpecialSelectionProvider(specialProvider); fOpenTypeHierarchy= new OpenTypeHierarchyAction(site); fOpenTypeHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY); fOpenTypeHierarchy.setSpecialSelectionProvider(specialProvider); fOpenCallHierarchy= new OpenCallHierarchyAction(site); fOpenCallHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY); fOpenCallHierarchy.setSpecialSelectionProvider(specialProvider); ISelectionProvider provider= specialProvider != null ? specialProvider : site.getSelectionProvider(); fOpenPropertiesDialog= new PropertyDialogAction(site, provider); fOpenPropertiesDialog.setActionDefinitionId(IWorkbenchActionDefinitionIds.PROPERTIES); initialize(provider); }
public void run(IAction action) { if (mSelection != null && allProfilesInSelectionAreDisconnected(mSelection)) { List list = mSelection.toList(); if (list == null || list.size() == 0) return; for (int i = 0; i < list.size(); i++) { PropertyDialogAction propertyDialogAction = new PropertyDialogAction( new SameShellProvider(mShell), this); if (list.get(i) instanceof IConnectionProfile) { IConnectionProfile profile = (IConnectionProfile) list.get(i); StructuredSelection ssel = new StructuredSelection(profile); propertyDialogAction.selectionChanged(ssel); if (!profile.arePropertiesComplete() && propertyDialogAction.isApplicableForSelection()) { PreferenceDialog dialog = propertyDialogAction.createDialog(); String initialPage = getInitialPropertyPageID(profile); if (initialPage != null) { ((IWorkbenchPreferenceContainer) dialog).openPage( initialPage, null); } if (dialog.open() == Dialog.CANCEL) { return; } } profile.connect(null); } } } }
public NewTextSearchActionGroup(IViewPart part) { Assert.isNotNull(part); IWorkbenchPartSite site= part.getSite(); fSelectionProvider= site.getSelectionProvider(); fPage= site.getPage(); fOpenPropertiesDialog= new PropertyDialogAction(site, fSelectionProvider); fOpenAction= new OpenFileAction(fPage); ISelection selection= fSelectionProvider.getSelection(); if (selection instanceof IStructuredSelection) fOpenPropertiesDialog.selectionChanged((IStructuredSelection)selection); else fOpenPropertiesDialog.selectionChanged(selection); }