/** * Performs the comparison described by the given input and opens a * compare editor on the result in the given workbench page. * * @param input the input on which to open the compare editor * @param page the workbench page in which to open the compare editor * @since 2.1 */ public static void openCompareEditorOnPage(CompareEditorInput input, IWorkbenchPage page) { openCompareEditorOnPage(input, page, true); }
/** * Performs the comparison described by the given input and opens a * compare editor on the result in the currently active workbench page. * * @param input the input on which to open the compare editor */ public static void openCompareEditor(CompareEditorInput input) { openCompareEditorOnPage(input, null); }
/** * Performs the comparison described by the given input and opens a compare * editor on the result in the currently active workbench page. * * @param input * the input on which to open the compare editor * @param activate * if <code>true</code> the editor will be activated * @see IWorkbenchPage#openEditor(org.eclipse.ui.IEditorInput, String, * boolean) * @since 3.5 */ public static void openCompareEditor(CompareEditorInput input, boolean activate) { openCompareEditorOnPage(input, null, activate); }
public void run(ISelection selection) { if (fInput != null) { // Pass the shell so setSelection can prompt the user for which // resource should be the ancestor boolean ok = fInput.setSelection(selection, fWorkbenchPage.getWorkbenchWindow().getShell()); if (!ok) return; fInput.initializeCompareConfiguration(); CompareUI.openCompareEditorOnPage(fInput, fWorkbenchPage); fInput= null; // don't reuse this input! } }
@Override public void run(ISelection selection) { if (fInput != null) { // Pass the shell so setSelection can prompt the user for which // resource should be the ancestor boolean ok = fInput.setSelection(selection, fWorkbenchPage .getWorkbenchWindow().getShell(), showSelectAncestorDialog); if (!ok) return; fInput.initializeCompareConfiguration(); CompareUI.openCompareEditorOnPage(fInput, fWorkbenchPage); fInput= null; // don't reuse this input! } }
public static void openCompareEditor(CompareEditorInput input, IWorkbenchPage page, boolean reuseEditorIfPossible) { if (page == null || input == null) return; IEditorPart editor = findReusableCompareEditor(input, page); // reuse editor only for single selection if(editor != null && reuseEditorIfPossible) { IEditorInput otherInput = editor.getEditorInput(); if(otherInput.equals(input)) { // simply provide focus to editor page.activate(editor); } else { // if editor is currently not open on that input either re-use existing CompareUI.reuseCompareEditor(input, (IReusableEditor)editor); page.activate(editor); } } else { CompareUI.openCompareEditorOnPage(input, page); } }
public static void openCompareEditor(CompareEditorInput input, IWorkbenchPage page, boolean reuseEditorIfPossible) { if (page == null || input == null) return; IEditorPart editor = Utils.findReusableCompareEditor(input, page, new Class[] { SyncInfoCompareInput.class, ModelCompareEditorInput.class }); // reuse editor only for single selection if(editor != null && reuseEditorIfPossible) { IEditorInput otherInput = editor.getEditorInput(); if(otherInput.equals(input)) { // simply provide focus to editor page.activate(editor); } else { // if editor is currently not open on that input either re-use existing CompareUI.reuseCompareEditor(input, (IReusableEditor)editor); page.activate(editor); } } else { CompareUI.openCompareEditorOnPage(input, page); } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelection(event); IWorkbenchPage workbenchPage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); // CompareAction#isEnabled(ISelection) CompareConfiguration cc = new CompareConfiguration(); cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, Boolean.FALSE); ResourceCompareInput input = new ResourceCompareInput(cc); int selectionSize = 0; if (selection instanceof IStructuredSelection) { selectionSize = ((IStructuredSelection) selection).toArray().length; } if (input.isEnabled(selection) || selectionSize == 1) { // CompareAction#run(ISelection) if (!input.setSelection(selection, workbenchPage.getWorkbenchWindow().getShell(), false)) return null; input.initializeCompareConfiguration(); CompareUI.openCompareEditorOnPage(input, workbenchPage); } return null; } }