org.eclipse.compare.CompareUI Java Examples
The following examples show how to use
org.eclipse.compare.CompareUI.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XpectCompareCommandHandler.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Display comparison view of test file with expected and actual xpect expectation */ private void displayComparisonView(ComparisonFailure cf, Description desc) { IXpectURIProvider uriProfider = XpectRunner.INSTANCE.getUriProvider(); IFile fileTest = null; if (uriProfider instanceof N4IDEXpectTestURIProvider) { N4IDEXpectTestURIProvider fileCollector = (N4IDEXpectTestURIProvider) uriProfider; fileTest = ResourcesPlugin.getWorkspace().getRoot() .getFileForLocation(new Path(fileCollector.findRawLocation(desc))); } if (fileTest != null && fileTest.isAccessible()) { N4IDEXpectCompareEditorInput inp = new N4IDEXpectCompareEditorInput(fileTest, cf); CompareUI.openCompareEditor(inp); } else { throw new RuntimeException("paths in descriptions changed!"); } }
Example #2
Source File: ScriptRefactoringAction.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void run(final IAction action) { setCancelled(false); if (askConfirmation()) { final BonitaCompareEditorInput editorInput = createCompareEditorInput(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { CompareUI.openCompareDialog(editorInput); editorInput.dispose(); } }); if (editorInput.applyChanges()) { doRefactor(); } else { setCancelled(true); } } else {// Apply refactor by default doRefactor(); } }
Example #3
Source File: ResourceSelectionTreeDecorator.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public Image getImage(Image base, int kind) { Object key= base; // kind &= 3; Image[] a= (Image[]) fgMap.get(key); if (a == null) { a= new Image[6]; fgMap.put(key, a); } Image b= a[kind]; if (b == null) { boolean onLeft = kind == PROPERTY_CHANGE; b= new DiffImage(base, fgImages[kind], 22, onLeft).createImage(); CompareUI.disposeOnShutdown(b); a[kind]= b; } return b; }
Example #4
Source File: ConversionProblemsDialog.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void handleMemberSelect(Widget item) { Object data = null; if (item != null) data = item.getData(); if (data instanceof ICompilationUnit) { this.currentCU = (ICompilationUnit) data; problemsPane.setImage(CompareUI.getImage(this.currentCU.getResource())); String pattern = "Problems in file {0}"; String title = MessageFormat.format(pattern, new Object[] { this.currentCU.getResource().getName() }); problemsPane.setText(title); if (problemsTable != null) { problemsTable.setRedraw(false); problemsTable.removeAll(); ConversionResult conversionResult = input.get(currentCU); for (String problem : conversionResult.getProblems()) { addProblemItem(problem); } problemsTable.setRedraw(true); } } else this.currentCU = null; }
Example #5
Source File: ConversionProblemsDialog.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public void create() { super.create(); if (javaFilesTable != null && !javaFilesTable.isDisposed()) { for (Entry<ICompilationUnit, ConversionResult> entry : input.entrySet()) { if (entry.getValue().getProblems().iterator().hasNext()) { ICompilationUnit cu = entry.getKey(); IResource resource = cu.getResource(); TableItem ti = new TableItem(javaFilesTable, SWT.NONE); ti.setImage(CompareUI.getImage(resource)); ti.setText(resource.getName()); ti.setData(cu); ti.setChecked(true); } } if (javaFilesTable.getItems().length > 0) { javaFilesTable.select(0); handleMemberSelect(javaFilesTable.getItems()[0]); } } }
Example #6
Source File: Utilities.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static String getString(String key) { try { return CompareUI.getResourceBundle().getString(key); } catch (MissingResourceException e) { return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ } }
Example #7
Source File: CompareAction.java From ADT_Frontend with MIT License | 5 votes |
private void openFileCompareEditor(IAbapGitFile file, IAbapGitObject abapObject) { if (!checkCompareActionSupported(file, abapObject)) { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.AbapGitStaging_compare_objects_dialog_title, NLS.bind(Messages.AbapGitStaging_compare_not_supported_xmg, file.getName())); return; } Job openFileComparisonEditor = new Job(Messages.AbapGitStaging_compare_job_title) { @Override protected IStatus run(IProgressMonitor monitor) { try { String leftFileContents = CompareAction.this.fileService.readLocalFileContents(file, CompareAction.this.credentials, getDestination(CompareAction.this.view.getProject())); String rightFileContents = CompareAction.this.fileService.readRemoteFileContents(file, CompareAction.this.credentials, getDestination(CompareAction.this.view.getProject())); AbapGitCompareItem left = new AbapGitCompareItem(getFileNameLocal(file), getFileExtension(file, abapObject), leftFileContents); AbapGitCompareItem right = new AbapGitCompareItem(getFileNameRemote(file), getFileExtension(file, abapObject), rightFileContents); if (isContentIdentical(left.getContents(), right.getContents())) { Display.getDefault().syncExec(() -> { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.AbapGitStaging_compare_objects_dialog_title, NLS.bind(Messages.AbapGitStaging_compare_objects_identical_xmsg, file.getName())); }); return Status.OK_STATUS; } AbapGitCompareInput compareInput = new AbapGitCompareInput(left, right, abapObject.getName(), CompareAction.this.view.getProject()); Display.getDefault().asyncExec(() -> CompareUI.openCompareEditor(compareInput)); return Status.OK_STATUS; } catch (IOException | CoreException e) { return Status.CANCEL_STATUS; } } }; openFileComparisonEditor.schedule(); }
Example #8
Source File: JavaCompareWithEditionActionImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void run(ISelection selection) { IMember input= getEditionElement(selection); if (input == null) { MessageDialog.openInformation(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_invalidSelectionMessage); return; } JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance(); final IFile file= pageSource.getFile(input); if (file == null) { MessageDialog.openError(getShell(), CompareMessages.CompareWithHistory_title, CompareMessages.CompareWithHistory_internalErrorMessage); return; } if (USE_MODAL_COMPARE) { CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(false); cc.setRightEditable(false); HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input); ci.setTitle(CompareMessages.JavaCompareWithEditionActionImpl_0); ci.setHelpContextId(IJavaHelpContextIds.COMPARE_ELEMENT_WITH_HISTORY_DIALOG); CompareUI.openCompareDialog(ci); } else { TeamUI.showHistoryFor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, pageSource); } }
Example #9
Source File: BuiltInEditConflictsAction.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void editConflictsInternal() throws InvocationTargetException, InterruptedException { CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(true); builtInConflictsCompareInput = new BuiltInConflictsCompareInput(cc, conflictDescriptor); builtInConflictsCompareInput.setResources(conflictOldFile, conflictWorkingFile, conflictNewFile, mergedFile, fileName); CompareUI.openCompareEditorOnPage(builtInConflictsCompareInput, getTargetPage()); }
Example #10
Source File: DatastoreIndexesUpdatedStatusHandler.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override public Object handleStatus(IStatus status, Object source) throws CoreException { Preconditions.checkArgument(source instanceof DatastoreIndexUpdateData); DatastoreIndexUpdateData update = (DatastoreIndexUpdateData) source; Preconditions.checkState(update.datastoreIndexesAutoXml != null); if (DebugUITools.isPrivate(update.configuration)) { return null; } IWorkbenchPage page = getActivePage(); Shell shell = page.getWorkbenchWindow().getShell(); String[] buttonLabels = new String[] {Messages.getString("REVIEW_CHANGES"), Messages.getString("IGNORE_CHANGES")}; MessageDialog dialog = new MessageDialog(shell, Messages.getString("REVIEW_DATASTORE_INDEXES_UPDATE_TITLE"), //$NON-NLS-1$ null, Messages.getString("REVIEW_DATASTORE_INDEXES_UPDATE_MESSAGE"), //$NON-NLS-1$ MessageDialog.QUESTION, 0, buttonLabels); if (dialog.open() != 0) { return null; } // create an empty source file if it doesn't exist IFile datastoreIndexesXml = update.datastoreIndexesXml; if (datastoreIndexesXml == null) { IProject project = update.module.getProject(); try { datastoreIndexesXml = createNewDatastoreIndexesXml(project, null /* monitor */); } catch (CoreException ex) { logger.log(Level.SEVERE, "could not create empty datastore-indexes.xml in " + project, ex); //$NON-NLS-1$ } } CompareEditorInput input = new GeneratedDatastoreIndexesUpdateEditorInput(page, datastoreIndexesXml, update.datastoreIndexesAutoXml.toFile()); CompareUI.openCompareEditor(input); return null; }
Example #11
Source File: Utilities.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static String getFormattedString(String key, String arg0, String arg1) { try { return MessageFormat.format(CompareUI.getResourceBundle().getString(key), new String[] { arg0, arg1 }); } catch (MissingResourceException e) { return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ } }
Example #12
Source File: Utilities.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static String getFormattedString(String key, String arg) { try { return MessageFormat.format(CompareUI.getResourceBundle().getString(key), new String[] { arg }); } catch (MissingResourceException e) { return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ } }
Example #13
Source File: EditConflictsSynchronizeOperation.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * edit the conflicts using built-in merger * * @param resource * @param conflictOldFile * @param conflictWorkingFile * @param conflictNewFile * @throws InvocationTargetException */ private void editConflictsInternal(IFile resource, IFile conflictOldFile, IFile conflictWorkingFile, IFile conflictNewFile) throws InvocationTargetException, InterruptedException { CompareConfiguration cc = new CompareConfiguration(); final ConflictsCompareInput fInput = new ConflictsCompareInput(cc); fInput.setResources(conflictOldFile, conflictWorkingFile, conflictNewFile, (IFile) resource); getShell().getDisplay().syncExec(new Runnable() { public void run() { CompareUI.openCompareEditorOnPage(fInput, getPart().getSite().getPage()); } }); }
Example #14
Source File: EditConflictsAction.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * edit the conflicts using built-in merger * * @param resource * @param conflictOldFile * @param conflictWorkingFile * @param conflictNewFile * @throws InvocationTargetException */ private void editConflictsInternal(IFile resource, IFile conflictOldFile, IFile conflictWorkingFile, IFile conflictNewFile) throws InvocationTargetException, InterruptedException { CompareConfiguration cc = new CompareConfiguration(); ConflictsCompareInput fInput = new ConflictsCompareInput(cc); fInput.setResources(conflictOldFile, conflictWorkingFile, conflictNewFile, (IFile) resource); CompareUI.openCompareEditorOnPage(fInput, getTargetPage()); }
Example #15
Source File: RepositoriesViewDecorator.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public Image getImage(Image base) { Image decoratedImage = (Image) fgMap.get(base); if (decoratedImage != null) { return decoratedImage; } decoratedImage = new DiffImage(base, locked, 18, false).createImage(); fgMap.put(base, decoratedImage); CompareUI.disposeOnShutdown(decoratedImage); return decoratedImage; }
Example #16
Source File: DatastoreIndexesUpdatedStatusHandler.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override protected ICompareInput prepareCompareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { CompareConfiguration cc = getCompareConfiguration(); cc.setLeftEditable(true); cc.setRightEditable(false); cc.setLeftLabel(source.getName()); cc.setLeftImage(CompareUI.getImage(source)); cc.setRightLabel(generatedUpdate.getName()); cc.setRightImage(CompareUI.getImage(source)); // same type ITypedElement left = SaveableCompareEditorInput.createFileElement(source); ITypedElement right = new LocalDiskContent(generatedUpdate); return new DiffNode(left, right); }
Example #17
Source File: ResourceEditionNode.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public Image getImage() { return CompareUI.getImage(resource); }
Example #18
Source File: PropertyCompareLocalResourceNode.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public Image getImage() { return CompareUI.getImage(resource); }
Example #19
Source File: PropertyCompareRemoteResourceNode.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public Image getImage() { return CompareUI.getImage(remoteResource); }
Example #20
Source File: SummaryEditionNode.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public Image getImage() { return CompareUI.getImage(resource); }
Example #21
Source File: CompareSvnPropertiesAction.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void execute(IAction action) { exception = null; IResource[] resources = getSelectedResources(); IPropertyProvider left = null; right = null; if (resources != null && resources.length > 0) { left = new PropertyCompareLocalResourceNode(resources[0], true, null); if (resources.length > 1) { right = new PropertyCompareLocalResourceNode(resources[1], true, null); } else { final ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]); BusyIndicator.showWhile(Display.getDefault(), new Runnable() { public void run() { try { right = new PropertyCompareRemoteResourceNode(svnResource.getRemoteResource(SVNRevision.HEAD), SVNRevision.HEAD, true, null); } catch (SVNException e) { exception = e; } } }); if (exception != null) { MessageDialog.openError(getShell(), Policy.bind("CompareSvnPropertiesAction.0"), exception.getMessage()); //$NON-NLS-1$ return; } } } else { ISVNRemoteResource[] remoteResources = getSelectedRemoteResources(); if (remoteResources != null && remoteResources.length > 0) { left = new PropertyCompareRemoteResourceNode(remoteResources[0], SVNRevision.HEAD, true, null); if (remoteResources.length > 1) { right = new PropertyCompareRemoteResourceNode(remoteResources[1], SVNRevision.HEAD, true, null); } } } ComparePropertiesDialog dialog = new ComparePropertiesDialog(getShell(), left, right); if (dialog.open() == ComparePropertiesDialog.OK) { CompareUI.openCompareEditorOnPage(dialog.getInput(), getTargetPage()); } }
Example #22
Source File: CompareDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected Viewer getViewer(Viewer oldViewer, Object input) { if (input instanceof ICompareInput) return CompareUI.findContentViewer(oldViewer, (ICompareInput)input, this, fCompareConfiguration); return null; }
Example #23
Source File: ResizableDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public ResizableDialog(Shell parent, ResourceBundle bundle) { super(parent); fBundle= bundle; fSettings= CompareUI.getPlugin().getDialogSettings(); }
Example #24
Source File: AbstractCompareWithRouteActionHandler.java From eip-designer with Apache License 2.0 | 4 votes |
/** * The command has been executed, so extract the needed information * from the application context. */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection currentSelection = HandlerUtil.getCurrentSelection(event); if (currentSelection != null && currentSelection instanceof IStructuredSelection) { // Retrieve file corresponding to current selection. IStructuredSelection selection = (IStructuredSelection)currentSelection; IFile selectionFile = (IFile)selection.getFirstElement(); // Open compare target selection dialog. CompareTargetSelectionDialog dialog = new CompareTargetSelectionDialog( HandlerUtil.getActiveShellChecked(event), selectionFile.getName()); if (dialog.open() != Window.OK) { return null; } // Ask concrete subclass to parse source file and extract Route for comparison. Route left = extractRouteFromFile(selectionFile); // Retrieve EMF Object corresponding to selected reference Route. Route right = dialog.getSelectedRoute(); // Cause Spring parser cannot retrieve route name, force it using those of the model. // TODO Find a fix later for that in the generator/parser couple left.setName(right.getName()); // Launch EMFCompare UI with input. EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration()); ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(left, right, null); AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); EMFCompare comparator = EMFCompare.builder().setPostProcessorRegistry(EMFCompareRCPPlugin.getDefault().getPostProcessorRegistry()).build(); IComparisonScope scope = new DefaultComparisonScope(left, right, null); CompareEditorInput input = new ComparisonScopeEditorInput(configuration, editingDomain, adapterFactory, comparator, scope); CompareUI.openCompareDialog(input); } return null; }
Example #25
Source File: PropertiesStructureCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public Image getImage() { return CompareUI.getImage(getType()); }
Example #26
Source File: JavaReplaceWithEditionActionImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void run(ISelection selection) { Shell shell= getShell(); final IMember input= getEditionElement(selection); if (input == null) { MessageDialog.openInformation(shell, CompareMessages.ReplaceFromHistory_title, CompareMessages.ReplaceFromHistory_invalidSelectionMessage); return; } final IFile file= getFile(input); if (file == null) { showError(); return; } IStatus status= Resources.makeCommittable(file, shell); if (!status.isOK()) { return; } if (fPrevious) { String errorTitle= CompareMessages.ReplaceFromHistory_title; String errorMessage= CompareMessages.ReplaceFromHistory_internalErrorMessage; try { ITypedElement ti = ElementLocalHistoryPageSource.getPreviousEdition(file, input); if (ti == null) { MessageDialog.openInformation(shell, errorTitle, CompareMessages.ReplaceFromHistory_parsingErrorMessage); return; } replace(input, file, ti); } catch (TeamException e) { ExceptionHandler.handle(e, shell, errorTitle, errorMessage); } } else { JavaElementHistoryPageSource pageSource = JavaElementHistoryPageSource.getInstance(); CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(false); cc.setRightEditable(false); HistoryPageCompareEditorInput ci = new HistoryPageCompareEditorInput(cc, pageSource, input) { @Override protected void performReplace(Object selectedElement) { if (selectedElement instanceof ITypedElement) { JavaReplaceWithEditionActionImpl.this.replace(input, file, (ITypedElement)selectedElement); } } }; ci.setReplace(true); ci.setTitle(CompareMessages.JavaReplaceWithEditionActionImpl_0); ci.setHelpContextId(IJavaHelpContextIds.REPLACE_ELEMENT_WITH_HISTORY_DIALOG); CompareUI.openCompareDialog(ci); } }
Example #27
Source File: DuplicatedCode.java From JDeodorant with MIT License | 4 votes |
private void showCompareDialog() { CloneInstance[] selectedCloneInstances = getSelectedCloneInstances(); if (selectedCloneInstances.length == 2) { final CloneInstance instance1 = selectedCloneInstances[0]; final CloneInstance instance2 = selectedCloneInstances[1]; CompareEditorInput input = new CompareInput(instance1.getOriginalCodeFragment(), instance2.getOriginalCodeFragment()); CompareUI.openCompareDialog(input); } else { wrongSelectionMessage(); } }