@Override public IStructuredSelection findSelection(IEditorInput anInput) { IFile file = ResourceUtil.getFile(anInput); if (file != null) { return new StructuredSelection(file); } return StructuredSelection.EMPTY; }
/** * @param event * the execution event, must not be null * @return the current selection * @throws ExecutionException * if the selection can't be determined */ protected IStructuredSelection getSelection(ExecutionEvent event) throws ExecutionException { if (event == null) throw new IllegalArgumentException("event must not be NULL"); //$NON-NLS-1$ Object selection = HandlerUtil.getActiveMenuSelection(event); if (selection == null) selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection instanceof TextSelection) { IEditorInput editorInput = (IEditorInput) HandlerUtil.getVariable( event, ISources.ACTIVE_EDITOR_INPUT_NAME); IResource resource = ResourceUtil.getResource(editorInput); if (resource != null) return new StructuredSelection(resource); resource = ResourceUtil.getFile(editorInput); if (resource != null) return new StructuredSelection(resource); } if (selection instanceof IStructuredSelection) return (IStructuredSelection) selection; return StructuredSelection.EMPTY; }
ResourceMapping mapping = ResourceUtil.getResourceMapping(saveable); if (mapping != null) { try { IFile file = ResourceUtil.getFile(saveable); if (file != null) { return isDescendantOfRoots(file);
ResourceMapping mapping = getResourceMapping(element); if (mapping != null) { return getFileFromResourceMapping(mapping);
for (int i = 0; i < selection.length; i++) { Object element = selection[i]; IResource resource = ResourceUtil.getResource(element); if (resource != null) { projects.add(resource.getProject()); } else { ResourceMapping mapping = ResourceUtil.getResourceMapping(element); if (mapping != null) { IProject[] theProjects = mapping.getProjects(); Object marker = ResourceUtil.getAdapter(element, IMarker.class, false); if (marker instanceof IMarker) { IProject project = ((IMarker) marker).getResource().getProject();
Object currentElement = elements.next(); IResource resource = ResourceUtil.getResource(currentElement); .getResourceMapping(currentElement); if (mapping == null) continue;
private static boolean isWorkingSetSupported(IWorkingSet workingSet) { if (!workingSet.isEmpty() && !workingSet.isAggregateWorkingSet()) { IAdaptable[] elements = workingSet.getElements(); for (int i = 0; i < elements.length; i++) { IResource resource = ResourceUtil.getResource(elements[i]); if (resource != null) // support a working set if it contains at least one resource return true; } } return false; }
/** * Brings the corresponding editor to top if the selected resource is open. * * @since 3.5 */ protected void linkToEditor(ISelection selection) { if (this != this.getSite().getPage().getActivePart()) return; Object obj = getSingleElement(selection); if (obj instanceof IFile) { IFile file = (IFile) obj; IWorkbenchPage page = getSite().getPage(); IEditorPart editor = ResourceUtil.findEditor(page, file); if (editor != null) { page.bringToTop(editor); return; } } }
private static boolean isWorkingSetSupported(IWorkingSet workingSet) { if (!workingSet.isEmpty() && !workingSet.isAggregateWorkingSet()) { IAdaptable[] elements = workingSet.getElements(); for (int i = 0; i < elements.length; i++) { IResource resource = ResourceUtil.getResource(elements[i]); if (resource != null) // support a working set if it contains at least one resource return true; } } return false; }
/** * Return whether the given dirty editor part is editing resources that are * descendants of the given roots. * * @param part the dirty editor part * @return whether the given dirty editor part is editing resources that are * descendants of the given roots */ private boolean isEditingDescendantOf(IEditorPart part) { IFile file = ResourceUtil.getFile(part.getEditorInput()); if (file != null) { return isDescendantOfRoots(file); } return false; }
ResourceMapping mapping = ResourceUtil.getResourceMapping(saveable); if (mapping != null) { try { IFile file = ResourceUtil.getFile(saveable); if (file != null) { return isDescendantOfRoots(file);
public void setActiveEditor(ITextEditor editor) { if (GitTraceLocation.QUICKDIFF.isActive()) GitTraceLocation.getTrace().traceEntry( GitTraceLocation.QUICKDIFF.getLocation(), editor.getTitle()); IEditorInput editorInput = editor.getEditorInput(); resource = ResourceUtil.getResource(editorInput); }
/** * Return whether the given dirty editor part is editing resources that are * descendants of the given roots. * * @param part the dirty editor part * @return whether the given dirty editor part is editing resources that are * descendants of the given roots */ private boolean isEditingDescendantOf(IEditorPart part) { IFile file = ResourceUtil.getFile(part.getEditorInput()); if (file != null) { return isDescendantOfRoots(file); } return false; }
private IStructuredSelection convertSelection(IEvaluationContext aContext, Object aSelection) { IEvaluationContext ctx; if (aContext == null && aSelection == null) return StructuredSelection.EMPTY; else ctx = aContext; Object selection; if (aSelection == null && ctx != null) { selection = ctx.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); if (!(selection instanceof ISelection)) selection = ctx .getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME); } else if (aSelection != null) selection = aSelection; else return StructuredSelection.EMPTY; if (selection instanceof TextSelection) { if (ctx == null) ctx = getEvaluationContext(); IResource resource = ResourceUtil.getResource(ctx .getVariable(ISources.ACTIVE_EDITOR_INPUT_NAME)); if (resource != null) return new StructuredSelection(resource); } if (selection instanceof IStructuredSelection) return (IStructuredSelection) selection; return StructuredSelection.EMPTY; }
public IStructuredSelection findSelection(IEditorInput input) { IJavaElement element= JavaUI.getEditorInputJavaElement(input); if (element == null) { IFile file = ResourceUtil.getFile(input); if (file != null) { element= JavaCore.create(file); } } return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY; }
IEditorInput input = ((IEditorPart) focusPart).getEditorInput(); if (input != null) { IResource resource = ResourceUtil.getResource(input); if (resource != null) { list.add(resource);
@Override public IStructuredSelection findSelection(IEditorInput input) { IJavaElement element= JavaUI.getEditorInputJavaElement(input); if (element == null) { IFile file = ResourceUtil.getFile(input); if (file != null) { element= JavaCore.create(file); } } return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY; }
if (activeEditor != null && activeEditor == activePage.getActivePart()) { IEditorInput editorInput = activeEditor.getEditorInput(); resource = ResourceUtil.getResource(editorInput); } else { ISelection selection = ww.getSelectionService().getSelection(); IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.size() == 1) { resource = ResourceUtil.getResource(structuredSelection.getFirstElement());
@Override public IStructuredSelection findSelection(IEditorInput input) { IJavaElement element= JavaUI.getEditorInputJavaElement(input); if (element == null) { IFile file = ResourceUtil.getFile(input); if (file != null) { element= JavaCore.create(file); } } return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY; }
public void fillContextMenu(IMenuManager menu) { IStructuredSelection selection = (IStructuredSelection) getContext() .getSelection(); if (selection.isEmpty()) return; Object element = selection.getFirstElement(); IResource resource = ResourceUtil.getResource(element); if (resource != null) { // add standard git action for 'workspace' models menu.appendToGroup(GIT_ACTIONS, createItem(COMMIT_ACTION)); menu.appendToGroup(GIT_ACTIONS, createItem(ADD_TO_INDEX)); menu.appendToGroup(GIT_ACTIONS, createItem(IGNORE_ACTION)); menu.appendToGroup(GIT_ACTIONS, createItem(MERGE_TOOL_ACTION)); menu.appendToGroup(GIT_ACTIONS, createItem(CREATE_PATCH)); } else if (element instanceof GitModelObject && selection.size() == 1) createMenuForGitModelObject(menu, (GitModelObject) element); IContributionItem fileGroup = findGroup(menu, ISynchronizePageConfiguration.FILE_GROUP); if (fileGroup != null) { ModelSynchronizeParticipant msp = ((ModelSynchronizeParticipant) getConfiguration() .getParticipant()); if (msp.hasCompareInputFor(element)) menu.appendToGroup(fileGroup.getId(), openWorkingFileAction); } }