diff options
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org/eclipse/team/ui')
6 files changed, 62 insertions, 150 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageCompareEditorInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageCompareEditorInput.java index 0b9ed7274..0fb9d4831 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageCompareEditorInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageCompareEditorInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,6 @@ import org.eclipse.compare.structuremergeviewer.ICompareInput; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.ToolBarManager; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.*; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; @@ -138,9 +137,6 @@ public abstract class PageCompareEditorInput extends CompareEditorInput implemen pagePane.setText(title); } - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#handleDispose() - */ @Override protected void handleDispose() { super.handleDispose(); @@ -237,12 +233,9 @@ public abstract class PageCompareEditorInput extends CompareEditorInput implemen IProgressService manager = PlatformUI.getWorkbench().getProgressService(); try { // TODO: we need a better progress story here (i.e. support for cancellation) bug 127075 - manager.busyCursorWhile(new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - prepareInput(input, getCompareConfiguration(), monitor); - hookContentChangeListener(input); - } + manager.busyCursorWhile(monitor -> { + prepareInput(input, getCompareConfiguration(), monitor); + hookContentChangeListener(input); }); } catch (InvocationTargetException e) { Utils.handle(e); @@ -251,17 +244,11 @@ public abstract class PageCompareEditorInput extends CompareEditorInput implemen } } - /* (non-Javadoc) - * @see org.eclipse.compare.IContentChangeListener#contentChanged(org.eclipse.compare.IContentChangeNotifier) - */ @Override public void contentChanged(IContentChangeNotifier source) { setDirty(true); } - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#canRunInBackground() - */ @Override public boolean canRunAsJob() { return true; diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java index 80c5990a1..58fa174fd 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -53,17 +53,11 @@ public class SaveablePartDialog extends TrayDialog { this.input = input; } - /* (non-Javadoc) - * Method declared on Dialog. - */ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); } - /* (non-Javadoc) - * Method declared on Dialog. - */ @Override protected Control createDialogArea(Composite parent2) { Composite parent = (Composite) super.createDialogArea(parent2); @@ -75,9 +69,6 @@ public class SaveablePartDialog extends TrayDialog { return parent; } - /* (non-Javadoc) - * @see org.eclipse.compare.internal.ResizableDialog#close() - */ @Override public boolean close() { saveChanges(); @@ -94,12 +85,7 @@ public class SaveablePartDialog extends TrayDialog { IDialogConstants.NO_LABEL}, 0); // YES is the default if (input.isDirty() && dialog.open() == IDialogConstants.OK_ID) { - BusyIndicator.showWhile(null, new Runnable() { - @Override - public void run() { - input.doSave(new NullProgressMonitor()); - } - }); + BusyIndicator.showWhile(null, () -> input.doSave(new NullProgressMonitor())); } } @@ -112,9 +98,6 @@ public class SaveablePartDialog extends TrayDialog { return input; } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings() - */ @Override protected IDialogSettings getDialogBoundsSettings() { IDialogSettings compareSettings = TeamUIPlugin.getPlugin().getDialogSettings(); @@ -135,9 +118,6 @@ public class SaveablePartDialog extends TrayDialog { fContextId= contextId; } - /* - * @see org.eclipse.jface.window.Window#configureShell(Shell) - */ @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); @@ -145,9 +125,6 @@ public class SaveablePartDialog extends TrayDialog { PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, fContextId); } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() - */ @Override protected Point getInitialSize() { Point initialSize = super.getInitialSize(); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java index 91d86b17b..bda3e50e3 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -81,9 +81,6 @@ public abstract class TeamOperation extends JobChangeAdapter implements IRunnabl job.setProperty(IProgressConstants.ICON_PROPERTY, icon); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.JobRunnableContext#belongsTo(org.eclipse.team.internal.ui.actions.JobRunnableContext.IContextJob, java.lang.Object) - */ @Override protected boolean belongsTo(IContextJob job, Object family) { if (family instanceof IContextJob) { @@ -96,9 +93,6 @@ public abstract class TeamOperation extends JobChangeAdapter implements IRunnabl return operation.belongsTo(family); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.JobRunnableContext#getCompletionStatus() - */ @Override protected IStatus getCompletionStatus() { if (gotoAction != null) { @@ -107,9 +101,6 @@ public abstract class TeamOperation extends JobChangeAdapter implements IRunnabl return super.getCompletionStatus(); } - /* (non-Javadoc) - * @see org.eclipse.team.internal.ui.actions.JobRunnableContext#isUser() - */ @Override protected boolean isUser() { return operation.isUserInitiated(); @@ -330,12 +321,7 @@ public abstract class TeamOperation extends JobChangeAdapter implements IRunnabl protected Shell getShell() { final Shell[] shell = new Shell[] { null }; if (Display.getCurrent() == null) { - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - shell[0] = Utils.getShell(getSite()); - } - }); + Display.getDefault().syncExec(() -> shell[0] = Utils.getShell(getSite())); } else { shell[0] = Utils.getShell(getSite()); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java index 872a91809..520fa594a 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java @@ -385,18 +385,15 @@ public abstract class ModelOperation extends TeamOperation { private boolean showAllMappings(final String requestPreviewMessage) { final boolean[] canceled = new boolean[] { false }; final boolean[] forcePreview = new boolean[] { false }; - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - AdditionalMappingsDialog dialog = new AdditionalMappingsDialog(getShell(), TeamUIMessages.ResourceMappingOperation_0, getScope(), getContext()); - dialog.setPreviewMessage(requestPreviewMessage); - int result = dialog.open(); - canceled[0] = result != Window.OK; - if (requestPreviewMessage != null) { - forcePreview[0] = dialog.isForcePreview(); - } - } - }); + Display.getDefault().syncExec(() -> { + AdditionalMappingsDialog dialog = new AdditionalMappingsDialog(getShell(), TeamUIMessages.ResourceMappingOperation_0, getScope(), getContext()); + dialog.setPreviewMessage(requestPreviewMessage); + int result = dialog.open(); + canceled[0] = result != Window.OK; + if (requestPreviewMessage != null) { + forcePreview[0] = dialog.isForcePreview(); + } + }); if (canceled[0]) { throw new OperationCanceledException(); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelParticipantAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelParticipantAction.java index 0faf4fef6..f2d8182f2 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelParticipantAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelParticipantAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,11 +16,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.*; import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.diff.*; import org.eclipse.team.core.mapping.ISynchronizationContext; @@ -51,12 +48,7 @@ public abstract class ModelParticipantAction extends BaseSelectionListenerAction private void initialize(ISynchronizePageConfiguration configuration) { configuration.getSite().getSelectionProvider().addSelectionChangedListener(this); - configuration.getPage().getViewer().getControl().addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - getConfiguration().getSite().getSelectionProvider().removeSelectionChangedListener(ModelParticipantAction.this); - } - }); + configuration.getPage().getViewer().getControl().addDisposeListener(e -> getConfiguration().getSite().getSelectionProvider().removeSelectionChangedListener(ModelParticipantAction.this)); } /** @@ -154,15 +146,12 @@ public abstract class ModelParticipantAction extends BaseSelectionListenerAction final SaveableComparison targetSaveable = getTargetSaveable(); final SaveableComparison activeSaveable = getActiveSaveable(); if (activeSaveable != null && activeSaveable.isDirty()) { - PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - try { - handleTargetSaveableChange(configuration.getSite().getShell(), targetSaveable, activeSaveable, true, monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> { + try { + handleTargetSaveableChange(configuration.getSite().getShell(), targetSaveable, activeSaveable, true, + monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); } }); } @@ -202,24 +191,21 @@ public abstract class ModelParticipantAction extends BaseSelectionListenerAction */ public static boolean promptToSaveChanges(final Shell shell, final SaveableComparison saveable, final boolean allowCancel) throws InterruptedException { final int[] result = new int[] { 0 }; - Runnable runnable = new Runnable() { - @Override - public void run() { - String[] options; - if (allowCancel) { - options = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}; - } else { - options = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}; - } - MessageDialog dialog = new MessageDialog( - shell, - TeamUIMessages.ModelParticipantAction_0, null, - NLS.bind(TeamUIMessages.ModelParticipantAction_1, saveable.getName()), - MessageDialog.QUESTION, - options, - result[0]); - result[0] = dialog.open(); + Runnable runnable = () -> { + String[] options; + if (allowCancel) { + options = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}; + } else { + options = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}; } + MessageDialog dialog = new MessageDialog( + shell, + TeamUIMessages.ModelParticipantAction_0, null, + NLS.bind(TeamUIMessages.ModelParticipantAction_1, saveable.getName()), + MessageDialog.QUESTION, + options, + result[0]); + result[0] = dialog.open(); }; shell.getDisplay().syncExec(runnable); if (result[0] == 2) diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java index 852901c23..f5cf92bc7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,8 +25,6 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ui.*; @@ -181,20 +179,17 @@ public abstract class SaveableCompareEditorInput extends CompareEditorInput impl logTrace("compareInputChangeListener assigned"); //$NON-NLS-1$ logStackTrace(); } - compareInputChangeListener = new ICompareInputChangeListener() { - @Override - public void compareInputChanged(ICompareInput source) { - if (source == getCompareResult()) { - boolean closed = false; - if (source.getKind() == Differencer.NO_CHANGE) { - closed = closeEditor(true); - } - if (!closed) { - // The editor was closed either because the compare input still has changes - // or because the editor input is dirty. In either case, fire the changes - // to the registered listeners. - propogateInputChange(); - } + compareInputChangeListener = source -> { + if (source == getCompareResult()) { + boolean closed = false; + if (source.getKind() == Differencer.NO_CHANGE) { + closed = closeEditor(true); + } + if (!closed) { + // The editor was closed either because the compare input still has changes + // or because the editor input is dirty. In either case, fire the changes + // to the registered listeners. + propogateInputChange(); } } }; @@ -202,12 +197,9 @@ public abstract class SaveableCompareEditorInput extends CompareEditorInput impl if (getSaveable() instanceof SaveableComparison) { SaveableComparison scm = (SaveableComparison) saveable; - propertyListener = new IPropertyListener() { - @Override - public void propertyChanged(Object source, int propId) { - if (propId == SaveableComparison.PROP_DIRTY) { - setDirty(saveable.isDirty()); - } + propertyListener = (source, propId) -> { + if (propId == SaveableComparison.PROP_DIRTY) { + setDirty(saveable.isDirty()); } }; scm.addPropertyListener(propertyListener); @@ -326,16 +318,13 @@ public abstract class SaveableCompareEditorInput extends CompareEditorInput impl if (page == null) return false; - Runnable runnable = new Runnable() { - @Override - public void run() { - Shell shell= page.getWorkbenchWindow().getShell(); - if (shell == null) - return; + Runnable runnable = () -> { + Shell shell= page.getWorkbenchWindow().getShell(); + if (shell == null) + return; - IEditorPart part= page.findEditor(SaveableCompareEditorInput.this); - getPage().closeEditor(part, false); - } + IEditorPart part= page.findEditor(SaveableCompareEditorInput.this); + getPage().closeEditor(part, false); }; if (Display.getCurrent() != null) { runnable.run(); @@ -471,12 +460,7 @@ public abstract class SaveableCompareEditorInput extends CompareEditorInput impl dsp.addPropertyChangeListener(pcl); Control c= newViewer.getControl(); c.addDisposeListener( - new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - dsp.removePropertyChangeListener(pcl); - } - } + e -> dsp.removePropertyChangeListener(pcl) ); } return newViewer; @@ -500,12 +484,7 @@ public abstract class SaveableCompareEditorInput extends CompareEditorInput impl final Saveable saveable = getSaveable(); if (saveable instanceof LocalResourceSaveableComparison) { final ITypedElement element= getFileElement(getCompareInput(), this); - menu.addMenuListener(new IMenuListener() { - @Override - public void menuAboutToShow(IMenuManager manager) { - SaveablesCompareEditorInput.handleMenuAboutToShow(manager, getContainer(), saveable, element, selectionProvider); - } - }); + menu.addMenuListener(manager -> SaveablesCompareEditorInput.handleMenuAboutToShow(manager, getContainer(), saveable, element, selectionProvider)); } } } |