public void run(final IAction action) { if (resource != null) { final SourceCode sourceCode = EclipseSonar.getInstance(resource.getProject()).search(resource); CompareUI.openCompareEditor( new SonarCompareInput(resource.getResource(), sourceCode.getRemoteContent())); } }
/** * Method getToolTipText. * * @return String * @see org.eclipse.ui.IEditorInput#getToolTipText() */ @Override public String getToolTipText() { String targetTooltip = fCurrentDiffNode.getTargetLabel(); String baseTooltip = fCurrentDiffNode.getBaseLabel(); String format = CompareUI.getResourceBundle().getString("ResourceCompare.twoWay.tooltip"); // $NON-NLS-1$ return MessageFormat.format(format, new Object[] {targetTooltip, baseTooltip}); }
private void doOpen(IReviewItemSet items, IFileItem item) { if (item.getBase() == null || item.getTarget() == null) { getTaskEditorPage() .getEditor() .setMessage("The selected file is not available, yet", IMessageProvider.WARNING); return; } GerritReviewBehavior behavior = new GerritReviewBehavior(getTask()); CompareConfiguration configuration = new CompareConfiguration(); CompareUI.openCompareEditor(new FileItemCompareEditorInput(configuration, item, behavior)); }
private void openInCompare(ITypedElement ancestor, ITypedElement left, ITypedElement right) { IWorkbenchPage workBenchPage = getTargetPage(); CompareEditorInput input = new SaveablesCompareEditorInput(ancestor, left, right, workBenchPage); IEditorPart editor = Utils.findReusableCompareEditor( input, workBenchPage, new Class[] {CompareFileRevisionEditorInput.class}); if (editor != null) { IEditorInput otherInput = editor.getEditorInput(); if (otherInput.equals(input)) { // simply provide focus to editor workBenchPage.activate(editor); } else { // if editor is currently not open on that input either re-use // existing CompareUI.reuseCompareEditor(input, (IReusableEditor) editor); workBenchPage.activate(editor); } } else { CompareUI.openCompareEditor(input); } }
public Object execute(ExecutionEvent event) throws ExecutionException { final Repository repository = getRepository(true, event); // assert all resources map to the same repository if (repository == null) return null; final IResource[] resources = getSelectedResources(event); if (resources.length == 1 && resources[0] instanceof IFile) { final IFile baseFile = (IFile) resources[0]; final String gitPath = RepositoryMapping.getMapping(baseFile.getProject()).getRepoRelativePath(baseFile); final ITypedElement base = SaveableCompareEditorInput.createFileElement(baseFile); ITypedElement next; try { Ref head = repository.getRef(Constants.HEAD); RevWalk rw = new RevWalk(repository); RevCommit commit = rw.parseCommit(head.getObjectId()); next = CompareUtils.getFileRevisionTypedElement(gitPath, commit, repository); } catch (IOException e) { Activator.handleError(e.getMessage(), e, true); return null; } final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(base, next, null); CompareUI.openCompareEditor(in); return null; } else { CompareTreeView view; try { view = (CompareTreeView) PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .showView(CompareTreeView.ID); try { view.setInput(resources, repository.resolve(Constants.HEAD).name()); } catch (IOException e) { Activator.handleError(e.getMessage(), e, true); return null; } } catch (PartInitException e) { Activator.handleError(e.getMessage(), e, true); return null; } return null; } }
protected void exec(IJavaElement element1, IJavaElement element2) throws Exception { final BitSet modes = getModes(); CompareUI.openCompareEditor( new BytecodeCompare( createTypedElement(element1, modes), createTypedElement(element2, modes))); }