@Override protected void handleDispose() { super.handleDispose(); // we do NOT dispose the images, as these are shared }
protected Viewer getViewer(Viewer oldViewer, Object input) { if (input instanceof ICompareInput) return findContentViewer(oldViewer, (ICompareInput)input, this); return null; } };
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(final Object adaptableObject, Class<T> adapterType) { if (IContributorResourceAdapter.class.equals(adapterType) && adaptableObject instanceof CompareEditorInput) { return (T) (IContributorResourceAdapter) adaptable -> { Object ei = ((CompareEditorInput) adaptableObject) .getAdapter(IEditorInput.class); if (ei instanceof IFileEditorInput) { return ((IFileEditorInput) ei).getFile(); } return null; }; } return null; }
/** * The <code>OK</code> button was pressed in a dialog. If one or both of * the sides of the input is editable then any changes will be saved. If the * input is for edition selection (see {@link #isEditionSelectionDialog()}), * it is up to subclasses to override this method in order to perform the * appropriate operation on the selected edition. * * @return whether the dialog should be closed or not. * @since 3.3 */ public boolean okPressed() { if (isEditable()) { if (!saveChanges()) return false; } return true; }
private boolean hasOutlineViewer(Object input) { if (!isShowStructureInOutlineView()) return false; OutlineViewerCreator creator = getAdapter(OutlineViewerCreator.class); if (creator != null) return creator.hasViewerFor(input); return false; }
@Override protected Viewer getViewer(Viewer oldViewer, Object input) { if (fSelectedViewerDescriptor != null) { ViewerDescriptor[] array = CompareUIPlugin.getDefault().findContentViewerDescriptor( oldViewer, input, getCompareConfiguration()); List<ViewerDescriptor> list = array != null ? Arrays.asList(array) : Collections.emptyList(); if (list.contains(fSelectedViewerDescriptor)) { // use selected viewer only when appropriate for the new input fCompareEditorInput .setContentViewerDescriptor(fSelectedViewerDescriptor); Viewer viewer = fCompareEditorInput.findContentViewer( oldViewer, (ICompareInput) input, this); return viewer; } // Fallback to default otherwise fSelectedViewerDescriptor = null; } if (input instanceof ICompareInput) { fCompareEditorInput.setContentViewerDescriptor(null); Viewer viewer = fCompareEditorInput.findContentViewer(oldViewer, (ICompareInput) input, this); fCompareEditorInput.setContentViewerDescriptor(fSelectedViewerDescriptor); return viewer; } return null; }
cei.setContainer(fContainer); setTitleImage(cei.getTitleImage()); setPartName(cei.getTitle()); setTitleToolTip(cei.getToolTipText()); setState(cei.getCompareResult() == null ? INITIALIZING : INITIALIZED); if (fPageBook != null) createCompareControl(); fControl.setSize(oldSize); boolean hasResult = cei.getCompareResult() != null; if (!hasResult) { initializeInBackground(cei, hadPreviousInput);
fComposite.setData(this); Control outline= createOutlineContents(fComposite, SWT.HORIZONTAL); fContentInputPane= createContentViewerSwitchingPane(fComposite, SWT.BORDER | SWT.FLAT, this); fComposite.setWeights(new int[] { 30, 70 }); feedInput(); parent.requestLayout(); fComposite.addDisposeListener(e -> { control.addDisposeListener(ev -> handleDispose()); }); if (fHelpContextId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(fComposite, fHelpContextId); contentsCreated(); return fComposite;
final Splitter h= new Splitter(parent, direction); fStructureInputPane= createStructureInputPane(h); if (hasChildren(getCompareResult())) fFocusPane= fStructureInputPane; oe -> feed1(oe.getSelection()) ); fStructureInputPane.addSelectionChangedListener( event -> feedDefault1(event.getSelection()) ); e -> feed2(e.getSelection()) ); e -> feed3(e.getSelection()) );
/** * Returns <code>true</code> if there are unsaved changes. * The method should be called by any parts or dialogs * that contain the input. * By default, this method calls {@link #isSaveNeeded()} * but subclasses may extend. * @return <code>true</code> if there are unsaved changes * @since 3.3 */ public boolean isDirty() { return isSaveNeeded(); }
public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(CompareEditorInput.DIRTY_STATE)) { Object old_value= event.getOldValue(); Object new_value= event.getNewValue(); if (old_value == null || new_value == null || !old_value.equals(new_value)) firePropertyChange(PROP_DIRTY); } else if (event.getProperty().equals(CompareEditorInput.PROP_TITLE)) { setPartName(((CompareEditorInput)getEditorInput()).getTitle()); setTitleToolTip(((CompareEditorInput)getEditorInput()).getToolTipText()); } else if (event.getProperty().equals(CompareEditorInput.PROP_TITLE_IMAGE)) { setTitleImage(((CompareEditorInput)getEditorInput()).getTitleImage()); } }
@Override protected void contentsCreated() { super.contentsCreated(); // select the first conflict getNavigator().selectChange(true); }
@Override public void execute(IProgressMonitor pm) throws CoreException { if (input instanceof CompareEditorInput) ((CompareEditorInput)input).saveChanges(pm); } };
@Override public boolean isDirty() { if (saveable != null) return saveable.isDirty(); return super.isDirty(); }
fComposite.setData(this); Control outline= createOutlineContents(fComposite, SWT.HORIZONTAL); feedInput(); if (fHelpContextId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(fComposite, fHelpContextId); contentsCreated(); return fComposite;
public IStatus prepareInput(CompareEditorInput input, IProgressMonitor monitor) { try { input.run(monitor); String message= input.getMessage(); if (message != null) { return new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, message, null); } if (input.getCompareResult() == null) { return new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, NO_DIFFERENCE, Utilities.getString("CompareUIPlugin.noDifferences"), null); //$NON-NLS-1$ } return Status.OK_STATUS; } catch (InterruptedException e) { throw new OperationCanceledException(); } catch (InvocationTargetException e) { return new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, Utilities.getString("CompareUIPlugin.compareFailed"), e.getTargetException()); //$NON-NLS-1$ } }
final Splitter h= new Splitter(parent, direction); fStructureInputPane= createStructureInputPane(h); if (hasChildren(getCompareResult())) fFocusPane= fStructureInputPane;
@Override public String getToolTipText() { return editorInput.getToolTipText(); }
public Object getAdapter(Class adapter) { if (ICompareNavigator.class.equals(adapter) || CompareNavigator.class.equals(adapter)) { return getNavigator();
public boolean compareResultOK(CompareEditorInput input, IRunnableContext context) { final Shell shell= getShell(); try { // run operation in separate thread and make it cancelable if (context == null) context = PlatformUI.getWorkbench().getProgressService(); context.run(true, true, input); String message= input.getMessage(); if (message != null) { MessageDialog.openError(shell, Utilities.getString("CompareUIPlugin.compareFailed"), message); //$NON-NLS-1$ return false; } if (input.getCompareResult() == null) { MessageDialog.openInformation(shell, Utilities.getString("CompareUIPlugin.dialogTitle"), Utilities.getString("CompareUIPlugin.noDifferences")); //$NON-NLS-2$ //$NON-NLS-1$ return false; } return true; } catch (InterruptedException x) { // canceled by user } catch (InvocationTargetException x) { MessageDialog.openError(shell, Utilities.getString("CompareUIPlugin.compareFailed"), x.getTargetException().getMessage()); //$NON-NLS-1$ } return false; }