protected void selectFileInCurrentView(final IFile file, IWorkbenchPage page) { final IWorkbenchPart activePart = page.getActivePart(); if (activePart instanceof ISetSelectionTarget) { final ISelection targetSelection = new StructuredSelection(file); Shell shell = getShell(); Display display = shell.getDisplay(); Runnable runnable = new Runnable() { public void run() { ISetSelectionTarget setSelectionTarget = (ISetSelectionTarget) activePart; setSelectionTarget.selectReveal(targetSelection); } }; display.asyncExec(runnable); } }
/** * Run. * * @param workbench the workbench * @param shell the shell */ public void run(IWorkbench workbench, Shell shell) { // Select the new file resource in the current view IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = workbenchWindow.getActivePage(); final IWorkbenchPart activePart = page.getActivePart(); // Open an editor on the new file try { if (activePart instanceof ISetSelectionTarget) { final ISelection targetSelection = new StructuredSelection(traceFile); shell.getDisplay().asyncExec(new Runnable() { public void run() { ((ISetSelectionTarget)activePart).selectReveal(targetSelection); } }); } page.openEditor(new FileEditorInput(traceFile), workbench.getEditorRegistry().getDefaultEditor(traceFile.getFullPath().toString()).getId()); } catch (PartInitException exception) { MessageDialog.openError(workbenchWindow.getShell(), "Error opening the editor.", exception.getMessage()); logger.error("Error opening the editor.",exception); } }
private void openFile(final IFile file) { fDisplay.asyncExec(new Runnable() { public void run() { IWorkbenchWindow ww = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); if (ww == null) { return; } IWorkbenchPage page = ww.getActivePage(); if (page == null || !file.exists()) return; IWorkbenchPart focusPart = page.getActivePart(); if (focusPart instanceof ISetSelectionTarget) { ISelection selection = new StructuredSelection(file); ((ISetSelectionTarget) focusPart).selectReveal(selection); } try { page.openEditor(new FileEditorInput(file), EDITOR_ID); } catch (PartInitException e) { } } }); }
/** * Select the given element in the view of the given id * * @param element */ public static void selectReveal(Object element, String viewId) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); // Select in the Project Explorer the generated files. IViewPart view = page.findView(viewId); if (view instanceof ISetSelectionTarget) { ((ISetSelectionTarget) view).selectReveal(new StructuredSelection(element)); } }
public void run(IResource resource) { if (resource == null) return; try { IWorkbenchPage page= getSite().getWorkbenchWindow().getActivePage(); IViewPart view= page.showView(JavaPlugin.ID_RES_NAV); if (view instanceof ISetSelectionTarget) { ISelection selection= new StructuredSelection(resource); ((ISetSelectionTarget)view).selectReveal(selection); } } catch(PartInitException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.ShowInNavigatorView_error_activation_failed); } }
private AddArchiveToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.ADD_LIB_TO_BP); fContext= context; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddJarCP_label); setImageDescriptor(JavaPluginImages.DESC_OBJS_EXTJAR); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddJarCP_tooltip); }
private ExcludeFromBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.EXCLUDE); fContext= context; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_label); setImageDescriptor(JavaPluginImages.DESC_ELCL_EXCLUDE_FROM_BUILDPATH); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_tooltip); setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_EXCLUDE_FROM_BUILDPATH); }
private CreateLinkedSourceFolderAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.CREATE_LINK); setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_label); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_tooltip); setImageDescriptor(JavaPluginImages.DESC_ELCL_ADD_LINKED_SOURCE_TO_BUILDPATH); setDescription(NewWizardMessages.PackageExplorerActionGroup_FormText_createLinkedFolder); }
private CreateSourceFolderAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.CREATE_FOLDER); setText(ActionMessages.OpenNewSourceFolderWizardAction_text2); setDescription(ActionMessages.OpenNewSourceFolderWizardAction_description); setToolTipText(ActionMessages.OpenNewSourceFolderWizardAction_tooltip); setImageDescriptor(JavaPluginImages.DESC_TOOL_NEWPACKROOT); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_SOURCEFOLDER_WIZARD_ACTION); }
public BuildpathModifierAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, int id, int style) { super("", style); //$NON-NLS-1$ fSite= site; fSelectionTarget= selectionTarget; fSelectedElements= new ArrayList<Object>(); fListeners= new ArrayList<IBuildpathModifierListener>(); setId(Integer.toString(id)); }
private EditFilterAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.EDIT_FILTERS); setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_label); setImageDescriptor(JavaPluginImages.DESC_ELCL_CONFIGURE_BUILDPATH_FILTERS); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_tooltip); setDescription(NewWizardMessages.PackageExplorerActionGroup_FormText_Edit); setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CONFIGURE_BUILDPATH_FILTERS); }
private AddSelectedLibraryToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.ADD_SEL_LIB_TO_BP); fContext= context; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelLibToCP_label); setImageDescriptor(JavaPluginImages.DESC_OBJS_EXTJAR); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelLibToCP_tooltip); }
private AddFolderToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.ADD_SEL_SF_TO_BP); fContext= context; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_label); setImageDescriptor(JavaPluginImages.DESC_ELCL_ADD_AS_SOURCE_FOLDER); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_tooltip); }
private IncludeToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.INCLUDE); fContext= context; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_label); setImageDescriptor(JavaPluginImages.DESC_ELCL_INCLUDE_ON_BUILDPATH); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_tooltip); setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_INCLUDE_ON_BUILDPATH); }
public ResetAllOutputFoldersAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context, IJavaProject javaProject) { super(site, selectionTarget, BuildpathModifierAction.RESET_ALL_OUTPUT_FOLDERS); fContext= context; fJavaProject= javaProject; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip); }
public ResetAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.RESET); fContext= context; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip); }
private EditOutputFolderAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.EDIT_OUTPUT); fContext= context; fShowOutputFolders= false; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_EditOutput_label); setImageDescriptor(JavaPluginImages.DESC_ELCL_CONFIGURE_OUTPUT_FOLDER); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_EditOutput_tooltip); setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CONFIGURE_OUTPUT_FOLDER); }
public ResetAllAction(HintTextGroup provider, IRunnableContext context, ISetSelectionTarget selectionTarget) { super(null, selectionTarget, BuildpathModifierAction.RESET_ALL); fProvider= provider; fContext= context; setImageDescriptor(JavaPluginImages.DESC_ELCL_CLEAR); setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CLEAR); setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_label); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_tooltip); setEnabled(false); }
public RemoveFromBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) { super(site, selectionTarget, BuildpathModifierAction.REMOVE_FROM_BP); fContext= context; setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_label); setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_tooltip); }
public void run(IAction action) { if (data == null) { return; } IViewPart part = getView(JavaUI.ID_PACKAGES); if (part instanceof ISetSelectionTarget) { ISetSelectionTarget target = (ISetSelectionTarget) part; target.selectReveal(new StructuredSelection(data)); } }
public void restore(Object newElement) { if (fDisplay == null) return; for (int i = 0; i < fParts.size(); i++) { IStructuredSelection currentSelection = (IStructuredSelection) fSelections.get(i); boolean changed = false; final ISetSelectionTarget target = (ISetSelectionTarget) fParts.get(i); final IStructuredSelection[] newSelection = new IStructuredSelection[1]; newSelection[0] = currentSelection; if (currentSelection instanceof TreeSelection) { TreeSelection treeSelection = (TreeSelection) currentSelection; TreePath[] paths = treeSelection.getPaths(); for (int p = 0; p < paths.length; p++) { TreePath path = paths[p]; if (path.getSegmentCount() > 0 && path.getLastSegment().equals(fElement)) { paths[p] = createTreePath(path, newElement); changed = true; } } if (changed) { newSelection[0] = new TreeSelection(paths, treeSelection.getElementComparer()); } } else { Object[] elements = currentSelection.toArray(); for (int e = 0; e < elements.length; e++) { if (elements[e].equals(fElement)) { elements[e] = newElement; changed = true; } } if (changed) { newSelection[0] = new StructuredSelection(elements); } } if (changed) { fDisplay.asyncExec(new Runnable() { public void run() { target.selectReveal(newSelection[0]); } }); } } }
@Override public void run(IAction action) { String textData = getClipboardText(); if (textData != null) { String fileName = null; String[] tokens = textData.split("/|\\?"); for (int t = 0; t < tokens.length; t++) { if (tokens[t].matches("([^\\s]+(\\.(?i)(" + filetypes + "))$)")) { fileName = tokens[t]; break; } } if (fileName != null) { IFile ff = findFile(fileName); if (ff != null) { IWorkbenchPage page = DITAToolsPlugin.getDefault() .getWorkbench().getActiveWorkbenchWindow() .getActivePage(); for (int i = 0; i < navigators.length; i++) { IViewPart view = page.findView(navigators[i]); if (view != null) { ISetSelectionTarget target = (ISetSelectionTarget) view; target.selectReveal(new StructuredSelection(ff)); } } } else { createMarker(IMarker.SEVERITY_ERROR, "File not found from clipboard text : " + textData); } } else { createMarker(IMarker.SEVERITY_ERROR, "File not found from clipboard text : " + textData); } } }
public void restore(Object newElement) { if (fDisplay == null) return; for (int i= 0; i < fParts.size(); i++) { IStructuredSelection currentSelection= fSelections.get(i); boolean changed= false; final ISetSelectionTarget target= (ISetSelectionTarget)fParts.get(i); final IStructuredSelection[] newSelection= new IStructuredSelection[1]; newSelection[0]= currentSelection; if (currentSelection instanceof TreeSelection) { TreeSelection treeSelection= (TreeSelection)currentSelection; TreePath[] paths= treeSelection.getPaths(); for (int p= 0; p < paths.length; p++) { TreePath path= paths[p]; if (path.getSegmentCount() > 0 && path.getLastSegment().equals(fElement)) { paths[p]= createTreePath(path, newElement); changed= true; } } if (changed) { newSelection[0]= new TreeSelection(paths, treeSelection.getElementComparer()); } } else { Object[] elements= currentSelection.toArray(); for (int e= 0; e < elements.length; e++) { if (elements[e].equals(fElement)) { elements[e]= newElement; changed= true; } } if (changed) { newSelection[0]= new StructuredSelection(elements); } } if (changed) { fDisplay.asyncExec(new Runnable() { public void run() { target.selectReveal(newSelection[0]); } }); } } }
public AddArchiveToBuildpathAction(IRunnableContext context, ISetSelectionTarget selectionTarget) { this(null, selectionTarget, context); }
public CreateSourceFolderAction2(HintTextGroup provider, IRunnableContext context, ISetSelectionTarget selectionTarget) { super(context, selectionTarget); fProvider= provider; }