From 293a2626f262d8048c6667b56ca6348a83aefc91 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Tue, 30 Oct 2018 09:29:54 +0200 Subject: Lambda conversions. Change-Id: I82abbfbcfd6d7485cf76711d685f79030f5b7306 Signed-off-by: Alexander Kurtakov --- .../internal/ccvs/ui/CVSFolderPropertiesPage.java | 32 ++-- .../internal/ccvs/ui/CVSLightweightDecorator.java | 40 ++--- .../internal/ccvs/ui/CVSProjectSetSerializer.java | 24 +-- .../eclipse/team/internal/ccvs/ui/CVSUIPlugin.java | 67 ++++---- .../ccvs/ui/FileModificationValidator.java | 57 +++---- .../team/internal/ccvs/ui/ResourceEditionNode.java | 43 +++--- .../ccvs/ui/WorkbenchUserAuthenticator.java | 68 ++++---- .../team/internal/ccvs/ui/actions/CVSAction.java | 124 +++++++-------- .../internal/ccvs/ui/actions/CommitAction.java | 67 ++++---- .../ui/actions/CompareRemoteWithTagAction.java | 17 +- .../ccvs/ui/actions/CompareWithRevisionAction.java | 24 ++- .../actions/ConfigureTagsFromRepoViewOnFolder.java | 31 ++-- .../team/internal/ccvs/ui/actions/EditAction.java | 35 ++--- .../ccvs/ui/actions/GenerateDiffFileAction.java | 24 +-- .../internal/ccvs/ui/actions/IgnoreAction.java | 35 +++-- .../team/internal/ccvs/ui/actions/MergeAction.java | 13 +- .../ccvs/ui/actions/OpenLogEntryAction.java | 22 +-- .../ccvs/ui/actions/OpenRemoteFileAction.java | 15 +- .../ccvs/ui/actions/ReplaceWithRemoteAction.java | 22 +-- .../ccvs/ui/actions/ReplaceWithTagAction.java | 54 ++++--- .../ui/actions/RestoreFromRepositoryAction.java | 25 +-- .../ccvs/ui/actions/ShowEditorsAction.java | 14 +- .../ccvs/ui/actions/ShowHistoryAction.java | 12 +- .../ui/actions/ShowResourceInHistoryAction.java | 21 ++- .../team/internal/ccvs/ui/actions/SyncAction.java | 33 ++-- .../team/internal/ccvs/ui/actions/TagAction.java | 25 ++- .../internal/ccvs/ui/actions/TagLocalAction.java | 22 +-- .../internal/ccvs/ui/actions/UnmanageAction.java | 11 +- .../internal/ccvs/ui/actions/WorkspaceAction.java | 49 +++--- .../ccvs/ui/actions/WorkspaceTraversalAction.java | 47 +++--- .../internal/ccvs/ui/console/CVSOutputConsole.java | 27 ++-- .../ccvs/ui/mappings/AbstractCommitAction.java | 16 +- .../ui/mappings/CVSSubscriberMergeContext.java | 38 ++--- .../ccvs/ui/mappings/ChangeSetActionProvider.java | 22 ++- .../ccvs/ui/mappings/ChangeSetContentProvider.java | 144 +++++++++-------- .../ccvs/ui/mappings/CreatePatchAction.java | 22 +-- .../ccvs/ui/mappings/MergeSubscriberContext.java | 65 ++++---- .../ccvs/ui/mappings/ModelReplaceOperation.java | 31 ++-- .../ccvs/ui/mappings/OpenChangeSetAction.java | 9 +- .../ui/mappings/WorkspaceModelParticipant.java | 37 +++-- .../ui/mappings/WorkspaceSubscriberContext.java | 171 +++++++++++---------- .../ccvs/ui/model/CVSRemoteFilePropertySource.java | 36 ++--- .../ccvs/ui/operations/BranchOperation.java | 94 +++++------ .../ui/operations/CacheBaseContentsOperation.java | 28 ++-- .../ccvs/ui/operations/CheckoutIntoOperation.java | 38 +++-- .../ui/operations/CheckoutProjectOperation.java | 21 ++- .../ccvs/ui/operations/ClipboardDiffOperation.java | 21 ++- .../ui/operations/FetchAllMembersOperation.java | 9 +- .../ui/operations/ReconcileProjectOperation.java | 12 +- .../ccvs/ui/operations/RemoteCompareOperation.java | 20 ++- .../ccvs/ui/operations/ReplaceOperation.java | 26 ++-- .../ccvs/ui/operations/ShareProjectOperation.java | 20 ++- .../ui/operations/ShowAnnotationOperation.java | 58 +++---- .../internal/ccvs/ui/repo/AddToBranchAction.java | 56 +++---- .../ccvs/ui/repo/RefreshRemoteProjectWizard.java | 73 ++++----- .../internal/ccvs/ui/repo/RemoveRootAction.java | 66 ++++---- .../internal/ccvs/ui/repo/RepositoryManager.java | 75 ++++----- .../ccvs/ui/subscriber/CVSChangeSetCollector.java | 52 ++++--- .../ccvs/ui/subscriber/CVSSubscriberOperation.java | 37 ++--- .../ui/subscriber/RefreshDirtyStateOperation.java | 24 ++- .../ccvs/ui/subscriber/SafeUpdateOperation.java | 54 ++++--- .../ui/subscriber/WorkspaceCommitOperation.java | 18 ++- .../ccvs/ui/tags/MultiFolderTagSource.java | 41 ++--- .../ccvs/ui/tags/SingleFolderTagSource.java | 65 ++++---- .../ccvs/ui/tags/TagRefreshButtonArea.java | 109 ++++++------- .../team/internal/ccvs/ui/wizards/AddWizard.java | 101 ++++++------ .../ccvs/ui/wizards/AlternativeLocationWizard.java | 18 +-- .../internal/ccvs/ui/wizards/CheckoutWizard.java | 35 +++-- .../internal/ccvs/ui/wizards/CommitWizard.java | 18 +-- .../ccvs/ui/wizards/CommitWizardCommitPage.java | 30 ++-- .../ccvs/ui/wizards/CommitWizardParticipant.java | 66 ++++---- .../team/internal/ccvs/ui/wizards/ModeWizard.java | 85 ++++------ .../ccvs/ui/wizards/ModuleSelectionPage.java | 42 ++--- .../ccvs/ui/wizards/NewLocationWizard.java | 17 +- .../RestoreFromRepositoryFileSelectionPage.java | 92 +++++------ .../internal/ccvs/ui/wizards/SharingWizard.java | 133 ++++++++-------- .../ccvs/ui/wizards/SharingWizardSyncPage.java | 55 ++++--- 77 files changed, 1665 insertions(+), 1735 deletions(-) (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui') diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java index 6085da9c1..bd7b0d6f6 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java @@ -17,10 +17,9 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IFolder; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -44,6 +43,7 @@ public class CVSFolderPropertiesPage extends CVSPropertiesPage { /** * @see PreferencePage#createContents(Composite) */ + @Override protected Control createContents(Composite parent) { initialize(); noDefaultAndApplyButton(); @@ -97,14 +97,12 @@ public class CVSFolderPropertiesPage extends CVSPropertiesPage { int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, disconnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); disconnect.setLayoutData(data); - disconnect.addListener(SWT.Selection, new Listener() { - public void handleEvent (Event event) { - // perform a disconnect - if (disconnectFolder()) { - root.setText(CVSUIMessages.CVSFilePropertiesPage_none); - repository.setText(CVSUIMessages.CVSFilePropertiesPage_none); - disconnect.setEnabled(false); - } + disconnect.addListener(SWT.Selection, event -> { + // perform a disconnect + if (disconnectFolder()) { + root.setText(CVSUIMessages.CVSFilePropertiesPage_none); + repository.setText(CVSUIMessages.CVSFilePropertiesPage_none); + disconnect.setEnabled(false); } }); } @@ -138,13 +136,11 @@ public class CVSFolderPropertiesPage extends CVSPropertiesPage { if (MessageDialog.openQuestion(getShell(), CVSUIMessages.CVSFolderPropertiesPage_disconnectTitle, CVSUIMessages.CVSFolderPropertiesPage_disconnectQuestion)) { // final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder); try { - PlatformUI.getWorkbench().getProgressService().run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - cvsFolder.unmanage(null); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().run(true, false, monitor -> { + try { + cvsFolder.unmanage(null); + } catch (CVSException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java index 27ee4572f..326dd447e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java @@ -88,16 +88,14 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig * @param colors color ids to cache */ private void ensureFontAndColorsCreated(final String[] fonts, final String[] colors) { - CVSUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); - for (int i = 0; i < colors.length; i++) { - theme.getColorRegistry().get(colors[i]); - - } - for (int i = 0; i < fonts.length; i++) { - theme.getFontRegistry().get(fonts[i]); - } + CVSUIPlugin.getStandardDisplay().syncExec(() -> { + ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); + for (int i1 = 0; i1 < colors.length; i1++) { + theme.getColorRegistry().get(colors[i1]); + + } + for (int i2 = 0; i2 < fonts.length; i2++) { + theme.getFontRegistry().get(fonts[i2]); } }); } @@ -136,6 +134,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig * * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) */ + @Override public void decorate(Object element, IDecoration decoration) { // Don't decorate the workspace root @@ -487,11 +486,9 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig public void refresh(IProject project) { final List resources = new ArrayList(); try { - project.accept(new IResourceVisitor() { - public boolean visit(IResource resource) { - resources.add(resource); - return true; - } + project.accept(resource -> { + resources.add(resource); + return true; }); postLabelEvent(new LabelProviderChangedEvent(this, resources.toArray())); } catch (CoreException e) { @@ -502,6 +499,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceSyncInfoChanged(org.eclipse.core.resources.IResource[]) */ + @Override public void resourceSyncInfoChanged(IResource[] changedResources) { resourceStateChanged(changedResources); } @@ -509,6 +507,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#externalSyncInfoChange(org.eclipse.core.resources.IResource[]) */ + @Override public void externalSyncInfoChange(IResource[] changedResources) { resourceStateChanged(changedResources); } @@ -516,6 +515,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceModificationStateChanged(org.eclipse.core.resources.IResource[]) */ + @Override public void resourceModified(IResource[] changedResources) { resourceStateChanged(changedResources); } @@ -547,12 +547,14 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /** * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectConfigured(org.eclipse.core.resources.IProject) */ + @Override public void projectConfigured(IProject project) { refresh(project); } /** * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectDeconfigured(org.eclipse.core.resources.IProject) */ + @Override public void projectDeconfigured(IProject project) { refresh(project); } @@ -563,16 +565,13 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig * @param events the events to post */ private void postLabelEvent(final LabelProviderChangedEvent event) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - fireLabelProviderChanged(event); - } - }); + Display.getDefault().asyncExec(() -> fireLabelProviderChanged(event)); } /* (non-Javadoc) * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() */ + @Override public void dispose() { super.dispose(); PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().removePropertyChangeListener(this); @@ -615,6 +614,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /* (non-Javadoc) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ + @Override public void propertyChange(PropertyChangeEvent event) { if (isEventOfInterest(event)) { ensureFontAndColorsCreated(fonts, colors); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java index 32d6a91f0..90b5be933 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectSetSerializer.java @@ -14,9 +14,7 @@ package org.eclipse.team.internal.ccvs.ui; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; +import java.util.*; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -26,15 +24,8 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.core.IProjectSetSerializer; -import org.eclipse.team.core.RepositoryProvider; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.core.*; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder; @@ -50,6 +41,7 @@ public class CVSProjectSetSerializer implements IProjectSetSerializer { * * "1.0,repoLocation,module,projectName[,tag]" */ + @Override public String[] asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor) throws TeamException { String[] result = new String[providerProjects.length]; for (int i = 0; i < providerProjects.length; i++) { @@ -89,6 +81,7 @@ public class CVSProjectSetSerializer implements IProjectSetSerializer { /** * @see IProjectSetSerializer#addToWorkspace(String[]) */ + @Override public IProject[] addToWorkspace(String[] referenceStrings, String filename, Object context, IProgressMonitor monitor) throws TeamException { final int size = referenceStrings.length; final IProject[] projects = new IProject[size]; @@ -152,6 +145,7 @@ public class CVSProjectSetSerializer implements IProjectSetSerializer { } } WorkspaceModifyOperation op = new WorkspaceModifyOperation() { + @Override public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { monitor.beginTask("", 1000 * num[0]); //$NON-NLS-1$ try { @@ -213,11 +207,7 @@ public class CVSProjectSetSerializer implements IProjectSetSerializer { IDialogConstants.CANCEL_LABEL}, 0); final int[] result = new int[1]; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = dialog.open(); - } - }); + shell.getDisplay().syncExec(() -> result[0] = dialog.open()); return result[0]; } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java index 9d94bd3cc..b4ff98f41 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java @@ -206,21 +206,20 @@ public class CVSUIPlugin extends AbstractUIPlugin { private static boolean promptToRefresh(final Shell shell, final IResource[] resources, final IStatus status) { final boolean[] result = new boolean[] { false}; - Runnable runnable = new Runnable() { - @Override - public void run() { - Shell shellToUse = shell; - if (shell == null) { - shellToUse = new Shell(Display.getCurrent()); - } - String question; - if (resources.length == 1) { - question = NLS.bind(CVSUIMessages.CVSUIPlugin_refreshQuestion, new String[] { status.getMessage(), resources[0].getFullPath().toString() }); - } else { - question = NLS.bind(CVSUIMessages.CVSUIPlugin_refreshMultipleQuestion, new String[] { status.getMessage() }); - } - result[0] = MessageDialog.openQuestion(shellToUse, CVSUIMessages.CVSUIPlugin_refreshTitle, question); + Runnable runnable = () -> { + Shell shellToUse = shell; + if (shell == null) { + shellToUse = new Shell(Display.getCurrent()); } + String question; + if (resources.length == 1) { + question = NLS.bind(CVSUIMessages.CVSUIPlugin_refreshQuestion, + new String[] { status.getMessage(), resources[0].getFullPath().toString() }); + } else { + question = NLS.bind(CVSUIMessages.CVSUIPlugin_refreshMultipleQuestion, + new String[] { status.getMessage() }); + } + result[0] = MessageDialog.openQuestion(shellToUse, CVSUIMessages.CVSUIPlugin_refreshTitle, question); }; Display.getDefault().syncExec(runnable); return result[0]; @@ -487,16 +486,11 @@ public class CVSUIPlugin extends AbstractUIPlugin { private static IStatus openDialog(Shell providedShell, final String title, final String message, final IStatus status, int flags) { // Create a runnable that will display the error status - final IOpenableInShell openable = new IOpenableInShell() { - @Override - public void open(Shell shell) { - if (status.getSeverity() == IStatus.INFO - && !status.isMultiStatus()) { - MessageDialog.openInformation(shell, - CVSUIMessages.information, status.getMessage()); - } else { - ErrorDialog.openError(shell, title, message, status); - } + final IOpenableInShell openable = shell -> { + if (status.getSeverity() == IStatus.INFO && !status.isMultiStatus()) { + MessageDialog.openInformation(shell, CVSUIMessages.information, status.getMessage()); + } else { + ErrorDialog.openError(shell, title, message, status); } }; openDialog(providedShell, openable, flags); @@ -535,20 +529,17 @@ public class CVSUIPlugin extends AbstractUIPlugin { // Create a runnable that will display the error status final Shell shell = providedShell; - Runnable outerRunnable = new Runnable() { - @Override - public void run() { - Shell displayShell; - if (shell == null) { - Display display = Display.getCurrent(); - displayShell = new Shell(display); - } else { - displayShell = shell; - } - openable.open(displayShell); - if (shell == null) { - displayShell.dispose(); - } + Runnable outerRunnable = () -> { + Shell displayShell; + if (shell == null) { + Display display = Display.getCurrent(); + displayShell = new Shell(display); + } else { + displayShell = shell; + } + openable.open(displayShell); + if (shell == null) { + displayShell.dispose(); } }; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java index 9955e99e9..aa484435a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java @@ -48,7 +48,8 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.CVSCoreFileModificationValidator#edit(org.eclipse.core.resources.IFile[], org.eclipse.core.resources.team.FileModificationValidationContext) */ - protected IStatus edit(IFile[] readOnlyFiles, FileModificationValidationContext context) { + @Override + protected IStatus edit(IFile[] readOnlyFiles, FileModificationValidationContext context) { return edit(readOnlyFiles, getShell(context)); } @@ -84,11 +85,7 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator // The user wants to update the file // Run the update in a runnable in order to get a busy cursor. // This runnable is syncExeced in order to get a busy cursor - IRunnableWithProgress updateRunnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - performUpdate(files, monitor); - } - }; + IRunnableWithProgress updateRunnable = monitor -> performUpdate(files, monitor); if (isRunningInUIThread()) { // Only show a busy cursor if validate edit is blocking the UI CVSUIPlugin.runWithProgress(shell, false, updateRunnable); @@ -103,15 +100,13 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator // Run the edit in a runnable in order to get a busy cursor. // This runnable is syncExeced in order to get a busy cursor - IRunnableWithProgress editRunnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - performEdit(files, monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }; + IRunnableWithProgress editRunnable = monitor -> { + try { + performEdit(files, monitor); + } catch (CVSException e) { + throw new InvocationTargetException(e); + } + }; if (isRunningInUIThread()) { // Only show a busy cursor if validate edit is blocking the UI CVSUIPlugin.runWithProgress(shell, false, editRunnable); @@ -142,7 +137,8 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator } - protected void scheduleEditJob(Job job) { + @Override + protected void scheduleEditJob(Job job) { job.setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE); job.setProperty(IProgressConstants.ICON_PROPERTY, getOperationIcon()); super.scheduleEditJob(job); @@ -196,11 +192,11 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator // were called from the UI thread final boolean[] result = new boolean[] { false }; int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC; - CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { - public void open(Shell shell) { - result[0] = MessageDialog.openQuestion(shell,CVSUIMessages.FileModificationValidator_3,CVSUIMessages.FileModificationValidator_4); // - } - }, flags); + CVSUIPlugin + .openDialog(shell, + shell1 -> result[0] = MessageDialog.openQuestion(shell1, + CVSUIMessages.FileModificationValidator_3, CVSUIMessages.FileModificationValidator_4), + flags); return result[0]; } @@ -209,11 +205,11 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator // were called from the UI thread final boolean[] result = new boolean[] { false }; int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC; - CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { - public void open(Shell shell) { - result[0] = MessageDialog.openQuestion(shell,CVSUIMessages.FileModificationValidator_5,CVSUIMessages.FileModificationValidator_6); - } - }, flags); + CVSUIPlugin + .openDialog(shell, + shell1 -> result[0] = MessageDialog.openQuestion(shell1, + CVSUIMessages.FileModificationValidator_5, CVSUIMessages.FileModificationValidator_6), + flags); return result[0]; } @@ -227,11 +223,7 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator private EditorsAction fetchEditors(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { final EditorsAction editors = new EditorsAction(getProvider(files), files); - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - editors.run(monitor); - } - }; + IRunnableWithProgress runnable = monitor -> editors.run(monitor); if (isRunningInUIThread()) { // Show a busy cursor if we are running in the UI thread CVSUIPlugin.runWithProgress(shell, false, runnable); @@ -285,7 +277,8 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator return ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT)); } - public ISchedulingRule validateEditRule(CVSResourceRuleFactory factory, IResource[] resources) { + @Override + public ISchedulingRule validateEditRule(CVSResourceRuleFactory factory, IResource[] resources) { if (!isNeverUpdate()) { // We may need to perform an update so we need to obtain the lock on each project Set projects = new HashSet(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java index 9cc95d4f7..2e743c1b9 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourceEditionNode.java @@ -19,9 +19,9 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.compare.*; import org.eclipse.compare.structuremergeviewer.IStructureComparator; +import org.eclipse.core.internal.dtree.IComparator; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.text.IDocument; import org.eclipse.swt.graphics.Image; import org.eclipse.team.core.TeamException; @@ -54,6 +54,7 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, * The content is not considered. * @see IComparator#equals */ + @Override public boolean equals(Object other) { if (other instanceof ITypedElement) { String otherName = ((ITypedElement)other).getName(); @@ -65,22 +66,21 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, /** * Enumerate children of this node (if any). */ + @Override public Object[] getChildren() { if (children == null) { children = new ResourceEditionNode[0]; if (resource != null) { try { - CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSRemoteResource[] members = resource.members(monitor); - children = new ResourceEditionNode[members.length]; - for (int i = 0; i < members.length; i++) { - children[i] = new ResourceEditionNode(members[i]); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); + CVSUIPlugin.runWithProgress(null, true /* cancelable */, monitor -> { + try { + ICVSRemoteResource[] members = resource.members(monitor); + children = new ResourceEditionNode[members.length]; + for (int i = 0; i < members.length; i++) { + children[i] = new ResourceEditionNode(members[i]); } + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); } catch (InterruptedException e) { @@ -99,6 +99,7 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, /** * @see IStreamContentAccessor#getContents() */ + @Override public InputStream getContents() throws CoreException { IStorage storage = getStorage(); if (storage != null) { @@ -107,6 +108,7 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, return new ByteArrayInputStream(new byte[0]); } + @Override public Image getImage() { return CompareUI.getImage(resource); } @@ -114,6 +116,7 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, /** * Returns the name of this node. */ + @Override public String getName() { return resource == null ? "" : resource.getName(); //$NON-NLS-1$ } @@ -125,6 +128,7 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, /** * Returns the comparison type for this node. */ + @Override public String getType() { if (resource == null) { return UNKNOWN_TYPE; @@ -140,6 +144,7 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, /** * @see IComparator#equals */ + @Override public int hashCode() { return getName().hashCode(); } @@ -147,6 +152,7 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, /* (non-Javadoc) * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset() */ + @Override public String getCharset() throws CoreException { // Use the local file encoding if there is one IResource local = resource.getIResource(); @@ -170,13 +176,11 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, } final IStorage[] holder = new IStorage[1]; try { - CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - holder[0] = ((IResourceVariant)resource).getStorage(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } + CVSUIPlugin.runWithProgress(null, true /* cancelable */, monitor -> { + try { + holder[0] = ((IResourceVariant) resource).getStorage(monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e) { @@ -187,16 +191,19 @@ public class ResourceEditionNode implements IStructureComparator, ITypedElement, return holder[0]; } + @Override public T getAdapter(Class adapter) { if (adapter == ISharedDocumentAdapter.class) { synchronized (this) { if (sharedDocumentAdapter == null) sharedDocumentAdapter = new SharedDocumentAdapter() { + @Override public IEditorInput getDocumentKey(Object element) { return ResourceEditionNode.this .getDocumentKey(element); } + @Override public void flushDocument(IDocumentProvider provider, IEditorInput documentKey, IDocument document, boolean overwrite) throws CoreException { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java index 78cec911a..7d5066821 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java @@ -17,7 +17,8 @@ package org.eclipse.team.internal.ccvs.ui; import java.util.Map; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.jface.dialogs.*; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.window.Window; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Display; @@ -58,6 +59,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { /** * @see IUserAuthenticator#authenticateUser */ + @Override public void promptForUserInfo(final ICVSRepositoryLocation location, final IUserInfo userinfo, final String message) throws CVSException { if (!userinfo.isUsernameMutable() && USE_ALTERNATE_PROMPTER) { alternatePromptForUserInfo(userinfo); @@ -72,13 +74,12 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { } else { // sync exec in default thread final CVSException[] exception = new CVSException[] { null }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - try { - allowCaching[0] = promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result); - } catch (CVSException e) { - exception[0] = e; - } + Display.getDefault().syncExec(() -> { + try { + allowCaching[0] = promptForPassword(location, userinfo.getUsername(), message, + userinfo.isUsernameMutable(), result); + } catch (CVSException e) { + exception[0] = e; } }); if (exception[0] != null) { @@ -166,6 +167,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { * @param echo '*' should be used or not * @param result the entered values, or null if user canceled. */ + @Override public String[] promptForKeyboradInteractive(final ICVSRepositoryLocation location, final String destination, final String name, @@ -180,11 +182,8 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { } else { // sync exec in default thread - Display.getDefault().syncExec(new Runnable() { - public void run() { - result[0]=_promptForUserInteractive(location, destination, name, instruction, prompt, echo, allowCaching); - } - }); + Display.getDefault().syncExec(() -> result[0] = _promptForUserInteractive(location, destination, name, + instruction, prompt, echo, allowCaching)); } if (result[0] != null && location != null && KeyboardInteractiveDialog.isPasswordAuth(prompt)) { @@ -265,11 +264,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { result[0] = alternatePromptForPassword(userinfo.getUsername()); } else { // sync exec in default thread - Display.getDefault().syncExec(new Runnable() { - public void run() { - result[0] = alternatePromptForPassword(userinfo.getUsername()); - } - }); + Display.getDefault().syncExec(() -> result[0] = alternatePromptForPassword(userinfo.getUsername())); } if (result[0] == null) { @@ -282,6 +277,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#prompt(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, int, java.lang.String, java.lang.String, int[], int) */ + @Override public int prompt(final ICVSRepositoryLocation location, final int promptType, final String title, final String message, final int[] promptResponses, final int defaultResponse) { final Display display = CVSUIPlugin.getStandardDisplay(); final int[] retval = new int[1]; @@ -296,31 +292,22 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { } } - display.syncExec(new Runnable() { - public void run() { - final MessageDialog dialog = new MessageDialog( - new Shell(display), - title, - null /* title image */, - NLS.bind(CVSUIMessages.WorkbenchUserAuthenticator_0, message, location.getLocation(true)), - promptType, - buttons, - 1 - ); - retval[0] = dialog.open(); - } + display.syncExec(() -> { + final MessageDialog dialog = new MessageDialog(new Shell(display), title, null /* title image */, + NLS.bind(CVSUIMessages.WorkbenchUserAuthenticator_0, message, location.getLocation(true)), + promptType, buttons, 1); + retval[0] = dialog.open(); }); return retval[0]; } - public boolean promptForHostKeyChange(final ICVSRepositoryLocation location) { + @Override + public boolean promptForHostKeyChange(final ICVSRepositoryLocation location) { final boolean[] openConfirm = new boolean[] { false }; final Display display = CVSUIPlugin.getStandardDisplay(); - display.syncExec(new Runnable() { - public void run() { - openConfirm[0] = MessageDialog.openConfirm(null, CVSUIMessages.WorkbenchUserAuthenticator_1, NLS.bind(CVSUIMessages.WorkbenchUserAuthenticator_2, new String[] { location.getHost() })); // - } - }); + display.syncExec( + () -> openConfirm[0] = MessageDialog.openConfirm(null, CVSUIMessages.WorkbenchUserAuthenticator_1, + NLS.bind(CVSUIMessages.WorkbenchUserAuthenticator_2, new String[] { location.getHost() }))); if (!openConfirm[0]) { throw new OperationCanceledException(); } @@ -332,6 +319,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { * * @see org.eclipse.team.internal.ccvs.core.IUserAuthenticator#promptToConfigureRepositoryLocations(java.util.Map) */ + @Override public Map promptToConfigureRepositoryLocations(final Map alternativeMap) { final Map[] result = new Map[1]; Display display = Display.getCurrent(); @@ -339,11 +327,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { result[0] = openAlternativeRepositoryDialog(alternativeMap); } else { // sync exec in default thread - Display.getDefault().syncExec(new Runnable() { - public void run() { - result[0] = openAlternativeRepositoryDialog(alternativeMap); - } - }); + Display.getDefault().syncExec(() -> result[0] = openAlternativeRepositoryDialog(alternativeMap)); } return result[0]; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java index b223725e6..7b0ec93b5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java @@ -16,17 +16,16 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; import java.util.*; -import org.eclipse.core.commands.*; +import org.eclipse.core.commands.IHandlerListener; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.runtime.*; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.*; +import org.eclipse.jface.dialogs.MessageDialogWithToggle; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.*; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.custom.BusyIndicator; @@ -41,7 +40,7 @@ import org.eclipse.team.internal.ccvs.ui.*; import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; import org.eclipse.team.internal.ccvs.ui.tags.TagSource; import org.eclipse.team.internal.ccvs.ui.tags.TagSourceWorkbenchAdapter; -import org.eclipse.team.internal.ui.*; +import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.actions.TeamAction; import org.eclipse.team.internal.ui.dialogs.IPromptCondition; import org.eclipse.ui.*; @@ -74,32 +73,30 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg // Don't need to specify a the title because it will use this actions // title instead. retargetAction = new RetargetAction(getId(), ""); //$NON-NLS-1$ - retargetAction.addPropertyChangeListener(new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(IAction.ENABLED)) { - Object val = event.getNewValue(); - if (val instanceof Boolean && action != null) { - action.setEnabled(((Boolean) val).booleanValue()); - } - } else if (event.getProperty().equals(IAction.CHECKED)) { - Object val = event.getNewValue(); - if (val instanceof Boolean && action != null) { - action.setChecked(((Boolean) val).booleanValue()); - } - } else if (event.getProperty().equals(IAction.TEXT)) { - Object val = event.getNewValue(); - if (val instanceof String && action != null) { - action.setText((String) val); - } - } else if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) { - Object val = event.getNewValue(); - if (val instanceof String && action != null) { - action.setToolTipText((String) val); - } - } else if (event.getProperty().equals(SubActionBars.P_ACTION_HANDLERS)) { - if(action != null && retargetAction != null) { - action.setEnabled(retargetAction.isEnabled()); - } + retargetAction.addPropertyChangeListener(event -> { + if (event.getProperty().equals(IAction.ENABLED)) { + Object val1 = event.getNewValue(); + if (val1 instanceof Boolean && action != null) { + action.setEnabled(((Boolean) val1).booleanValue()); + } + } else if (event.getProperty().equals(IAction.CHECKED)) { + Object val2 = event.getNewValue(); + if (val2 instanceof Boolean && action != null) { + action.setChecked(((Boolean) val2).booleanValue()); + } + } else if (event.getProperty().equals(IAction.TEXT)) { + Object val3 = event.getNewValue(); + if (val3 instanceof String && action != null) { + action.setText((String) val3); + } + } else if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) { + Object val4 = event.getNewValue(); + if (val4 instanceof String && action != null) { + action.setToolTipText((String) val4); + } + } else if (event.getProperty().equals(SubActionBars.P_ACTION_HANDLERS)) { + if (action != null && retargetAction != null) { + action.setEnabled(retargetAction.isEnabled()); } } }); @@ -112,6 +109,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg /** * Common run method for all CVS actions. */ + @Override final public void run(IAction action) { try { if (!beginExecution(action)) return; @@ -150,11 +148,13 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg * Called when this action is added to a top-level menu or toolbar (e.g. IWorkbenchWindowDelegate) * @since 3.1 */ + @Override public void init(IWorkbenchWindow window) { super.init(window); initializeRetargetAction(window); } + @Override public boolean isEnabled() { if(retargetAction != null && retargetAction.getActionHandler() != null) { return retargetAction.isEnabled(); @@ -163,6 +163,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg return false; } + @Override public void dispose() { super.dispose(); IWorkbenchWindow window = getWindow(); @@ -178,6 +179,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg } } + @Override public void selectionChanged(final IAction action, ISelection selection) { if (selection instanceof TextSelection) { // Since we have a text selection, we will assume that the target is the active editor. @@ -202,6 +204,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg this.action = action; } + @Override protected void setActionEnablement(IAction action) { if(retargetAction != null && retargetAction.getActionHandler() != null) { action.setEnabled(retargetAction.isEnabled()); @@ -308,6 +311,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg * @param status any status accumulated by the action before the end of * the action or the exception occurred. */ + @Override protected void handle(Exception exception) { // Get the non-OK status List problems = new ArrayList(); @@ -362,23 +366,17 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg final Exception[] exceptions = new Exception[] {null}; // Ensure that no repository view refresh happens until after the action - final IRunnableWithProgress innerRunnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - getRepositoryManager().run(runnable, monitor); - } - }; + final IRunnableWithProgress innerRunnable = monitor -> getRepositoryManager().run(runnable, monitor); switch (progressKind) { case PROGRESS_BUSYCURSOR : - BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { - public void run() { - try { - innerRunnable.run(new NullProgressMonitor()); - } catch (InvocationTargetException e) { - exceptions[0] = e; - } catch (InterruptedException e) { - exceptions[0] = e; - } + BusyIndicator.showWhile(Display.getCurrent(), () -> { + try { + innerRunnable.run(new NullProgressMonitor()); + } catch (InvocationTargetException e1) { + exceptions[0] = e1; + } catch (InterruptedException e2) { + exceptions[0] = e2; } }); break; @@ -513,9 +511,11 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg public static IPromptCondition getOverwriteLocalChangesPrompt(final IResource[] dirtyResources) { return new IPromptCondition() { List resources = Arrays.asList(dirtyResources); + @Override public boolean needsPrompt(IResource resource) { return resources.contains(resource); } + @Override public String promptMessage(IResource resource) { return NLS.bind(CVSUIMessages.ReplaceWithAction_localChanges, new String[] { resource.getName() }); } @@ -543,15 +543,13 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg // prompt if the tags are not equal // consider BASE to be equal the parent tag since we don't make BASE sticky on replace if (!CVSTag.equalTags(tag, parentTag) && !CVSTag.equalTags(tag, CVSTag.BASE)) { - shell.getDisplay().syncExec(new Runnable() { - public void run() { - MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, - CVSUIMessages.CVSAction_mixingTagsTitle, - NLS.bind(CVSUIMessages.CVSAction_mixingTags, new String[] { tag.getName() }), - CVSUIMessages.CVSAction_doNotShowThisAgain, false, - store, ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS); - result[0] = dialog.getReturnCode() == 0; - } + shell.getDisplay().syncExec(() -> { + MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, + CVSUIMessages.CVSAction_mixingTagsTitle, + NLS.bind(CVSUIMessages.CVSAction_mixingTags, new String[] { tag.getName() }), + CVSUIMessages.CVSAction_doNotShowThisAgain, false, store, + ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS); + result[0] = dialog.getReturnCode() == 0; }); // only prompt once break; @@ -572,13 +570,11 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg final int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS); final boolean[] okToContinue = new boolean[] {true}; if (option != ICVSUIConstants.OPTION_NEVER) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - boolean confirm = option == ICVSUIConstants.OPTION_PROMPT; - IResource[] selectedResources = getSelectedResources(); - if (selectedResources != null) { - okToContinue[0] = IDE.saveAllEditors(selectedResources, confirm); - } + Display.getDefault().syncExec(() -> { + boolean confirm = option == ICVSUIConstants.OPTION_PROMPT; + IResource[] selectedResources = getSelectedResources(); + if (selectedResources != null) { + okToContinue[0] = IDE.saveAllEditors(selectedResources, confirm); } }); } @@ -587,6 +583,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg /** * @see org.eclipse.team.internal.ui.actions.TeamAction#handle(java.lang.Exception, java.lang.String, java.lang.String) */ + @Override protected void handle(Exception exception, String title, String message) { CVSUIPlugin.openError(getShell(), title, message, exception, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS); } @@ -610,6 +607,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg /* (non-Javadoc) * @see org.eclipse.team.internal.ui.actions.TeamAction#getSelectedResources() */ + @Override protected final IResource[] getSelectedResources() { IStructuredSelection selection = getSelection(); CVSActionSelectionProperties props = CVSActionSelectionProperties.getProperties(getSelection()); @@ -622,6 +620,7 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg /* (non-Javadoc) * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) */ + @Override public void setActiveEditor(IAction action, IEditorPart targetEditor) { } @@ -631,14 +630,17 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg * @param handlerListener * @since 3.1 */ + @Override public void removeHandlerListener(IHandlerListener handlerListener) { } + @Override public void addHandlerListener(IHandlerListener handlerListener) { } /* (non-Javadoc) * @see org.eclipse.core.commands.IHandler#isHandled() */ + @Override public boolean isHandled() { return true; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java index 8d063e5df..acdf26374 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java @@ -17,7 +17,6 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.mapping.*; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialogWithToggle; @@ -45,6 +44,7 @@ public class CommitAction extends WorkspaceTraversalAction { includeChangeSets = isIncludeChangeSets(getShell(), CVSUIMessages.CommitAction_2); } + @Override protected ResourceTraversal[] adjustInputTraversals(ResourceTraversal[] traversals) { if (includeChangeSets) return ((CVSActiveChangeSetCollector)CVSUIPlugin.getPlugin().getChangeSetManager()).adjustInputTraversals(traversals); @@ -55,36 +55,32 @@ public class CommitAction extends WorkspaceTraversalAction { /* * @see CVSAction#execute(IAction) */ + @Override public void execute(IAction action) throws InvocationTargetException, InterruptedException { final ResourceTraversal[][] traversals = new ResourceTraversal[][] { null }; - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask(CVSUIMessages.CommitAction_0, 100); - traversals[0] = getTraversals(Policy.subMonitorFor(monitor, 80)); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - try { - CommitWizard.run(getTargetPart(), getShell(), traversals[0]); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }, false, PROGRESS_BUSYCURSOR); + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + try { + monitor.beginTask(CVSUIMessages.CommitAction_0, 100); + traversals[0] = getTraversals(Policy.subMonitorFor(monitor, 80)); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + }); + run((IRunnableWithProgress) monitor -> { + try { + CommitWizard.run(getTargetPart(), getShell(), traversals[0]); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + }, false, PROGRESS_BUSYCURSOR); } /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.CommitAction_commitFailed; } @@ -92,6 +88,7 @@ public class CommitAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForUnmanagedResources() */ + @Override protected boolean isEnabledForUnmanagedResources() { return true; } @@ -99,6 +96,7 @@ public class CommitAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() */ + @Override protected boolean isEnabledForNonExistantResources() { return true; } @@ -106,10 +104,12 @@ public class CommitAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId() */ + @Override public String getId() { return ICVSUIConstants.CMD_COMMIT; } + @Override protected SynchronizationScopeManager getScopeManager() { return new CommitScopeManager(getCVSResourceMappings(), getResourceMappingContext(), true); } @@ -127,19 +127,12 @@ public class CommitAction extends WorkspaceTraversalAction { // Ask the user whether to switch final int[] result = new int[] { 0 }; - Utils.syncExec(new Runnable() { - public void run() { - final MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion( - shell, - CVSUIMessages.CommitAction_1, - message, - CVSUIMessages.ShowAnnotationOperation_4, - false /* toggle state */, - store, - ICVSUIConstants.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT); - - result[0] = m.getReturnCode(); - } + Utils.syncExec((Runnable) () -> { + final MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(shell, + CVSUIMessages.CommitAction_1, message, CVSUIMessages.ShowAnnotationOperation_4, + false /* toggle state */, store, ICVSUIConstants.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT); + + result[0] = m.getReturnCode(); }, shell); switch (result[0]) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java index 294f0c421..0a160d5ef 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteWithTagAction.java @@ -15,7 +15,6 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.internal.ccvs.core.*; @@ -31,6 +30,7 @@ public class CompareRemoteWithTagAction extends CVSAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) */ + @Override protected void execute(IAction action) throws InvocationTargetException, InterruptedException { final ICVSRemoteResource[] resources = getSelectedRemoteResources(); @@ -39,15 +39,11 @@ public class CompareRemoteWithTagAction extends CVSAction { // Obtain the tag to compare against final ICVSRemoteResource resource = resources[0]; final CVSTag[] tag = new CVSTag[] { null}; - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - tag[0] = TagSelectionDialog.getTagToCompareWith(getShell(), TagSource.create(resources), - TagSelectionDialog.INCLUDE_BRANCHES | - TagSelectionDialog.INCLUDE_VERSIONS | - TagSelectionDialog.INCLUDE_DATES | - TagSelectionDialog.INCLUDE_HEAD_TAG); - } - }, false /* cancelable */, PROGRESS_BUSYCURSOR); + run((IRunnableWithProgress) monitor -> tag[0] = TagSelectionDialog.getTagToCompareWith(getShell(), + TagSource.create(resources), + TagSelectionDialog.INCLUDE_BRANCHES | TagSelectionDialog.INCLUDE_VERSIONS + | TagSelectionDialog.INCLUDE_DATES | TagSelectionDialog.INCLUDE_HEAD_TAG), + false /* cancelable */, PROGRESS_BUSYCURSOR); if (tag[0] == null) return; // Run the compare operation in the background @@ -62,6 +58,7 @@ public class CompareRemoteWithTagAction extends CVSAction { /** * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() */ + @Override public boolean isEnabled() { ICVSRemoteResource[] resources = getSelectedRemoteResources(); // Only support single select for now. diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java index 0dcce6704..6b9dd3339 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java @@ -44,19 +44,17 @@ public class CompareWithRevisionAction extends WorkspaceAction { public void execute(IAction action) throws InvocationTargetException, InterruptedException { // Show the compare viewer - run(new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - if (isShowInDialog()) { - IFile file = (IFile) getSelectedResources()[0]; - showCompareInDialog(getShell(), file); - } else { - IHistoryView view = TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), getSelectedResources()[0], null); - IHistoryPage page = view.getHistoryPage(); - if (page instanceof CVSHistoryPage){ - CVSHistoryPage cvsHistoryPage = (CVSHistoryPage) page; - cvsHistoryPage.setClickAction(true); - } + run((IRunnableWithProgress) monitor -> { + if (isShowInDialog()) { + IFile file = (IFile) getSelectedResources()[0]; + showCompareInDialog(getShell(), file); + } else { + IHistoryView view = TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), getSelectedResources()[0], + null); + IHistoryPage page = view.getHistoryPage(); + if (page instanceof CVSHistoryPage) { + CVSHistoryPage cvsHistoryPage = (CVSHistoryPage) page; + cvsHistoryPage.setClickAction(true); } } }, false /* cancelable */, PROGRESS_BUSYCURSOR); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java index 7d2a985cb..50ada4aad 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ConfigureTagsFromRepoViewOnFolder.java @@ -17,7 +17,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Iterator; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; @@ -38,6 +37,7 @@ public class ConfigureTagsFromRepoViewOnFolder extends CVSAction { /** * Returns the selected remote folders */ + @Override protected ICVSRemoteFolder[] getSelectedRemoteFolders() { ArrayList resources = null; IStructuredSelection selection = getSelection(); @@ -63,34 +63,33 @@ public class ConfigureTagsFromRepoViewOnFolder extends CVSAction { /* * @see CVSAction@execute(IAction) */ + @Override public void execute(IAction action) throws InvocationTargetException, InterruptedException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - final ICVSRemoteFolder[] roots = getSelectedRemoteFolders(); - final Shell shell = getShell(); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - ICVSFolder[] cvsFolders = new ICVSFolder[roots.length]; - for (int i = 0; i < roots.length; i++) { - cvsFolders[i] = roots[i]; - } - TagConfigurationDialog d = new TagConfigurationDialog(shell, TagSource.create(cvsFolders)); - d.open(); - } - }); - } + run((IRunnableWithProgress) monitor -> { + final ICVSRemoteFolder[] roots = getSelectedRemoteFolders(); + final Shell shell = getShell(); + shell.getDisplay().syncExec(() -> { + ICVSFolder[] cvsFolders = new ICVSFolder[roots.length]; + for (int i = 0; i < roots.length; i++) { + cvsFolders[i] = roots[i]; + } + TagConfigurationDialog d = new TagConfigurationDialog(shell, TagSource.create(cvsFolders)); + d.open(); + }); }, false /* cancelable */, PROGRESS_BUSYCURSOR); } /* * @see TeamAction#isEnabled() */ + @Override public boolean isEnabled() { return true; } /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.ConfigureTagsFromRepoViewConfigure_Tag_Error_1; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java index d922f7c00..f697745d2 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditAction.java @@ -15,11 +15,7 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.core.Team; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.ui.Policy; @@ -30,37 +26,38 @@ public class EditAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) */ + @Override protected void execute(IAction action) throws InvocationTargetException, InterruptedException { // Get the editors final EditorsAction editors = new EditorsAction(); - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - executeProviderAction(editors, Policy.subMonitorFor(monitor, 25)); - - // If there are editors show them and prompt the user to execute the edit command - if (!editors.promptToEdit(getShell())) { - return; - } - - executeProviderAction(new IProviderAction() { - public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException { - provider.edit(resources, false /* recurse */, true /* notify server */, false /* notifyForWritable*/, ICVSFile.NO_NOTIFICATION, monitor); - return Team.OK_STATUS; - } - }, Policy.subMonitorFor(monitor, 75)); + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + executeProviderAction(editors, Policy.subMonitorFor(monitor, 25)); + + // If there are editors show them and prompt the user to execute the edit + // command + if (!editors.promptToEdit(getShell())) { + return; } + + executeProviderAction((provider, resources, monitor1) -> { + provider.edit(resources, false /* recurse */, true /* notify server */, false /* notifyForWritable */, + ICVSFile.NO_NOTIFICATION, monitor1); + return Team.OK_STATUS; + }, Policy.subMonitorFor(monitor, 75)); }); } /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() */ + @Override protected boolean isEnabledForAddedResources() { return false; } /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) */ + @Override protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { if (cvsResource.isFolder()) return false; if (super.isEnabledForCVSResource(cvsResource)) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java index 0748f2e5a..e2072517e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java @@ -14,16 +14,14 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.resources.mapping.ResourceTraversal; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext; import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; @@ -42,17 +40,16 @@ public class GenerateDiffFileAction extends WorkspaceTraversalAction{ /** (Non-javadoc) * Method declared on IActionDelegate. */ + @Override public void execute(IAction action) { try { final IResource [][] resources = new IResource[][] { null }; - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - resources[0] = getDeepResourcesToPatch(monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + try { + resources[0] = getDeepResourcesToPatch(monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); } }); GenerateDiffFileWizard.run(getTargetPart(), resources[0]); @@ -106,6 +103,7 @@ public class GenerateDiffFileAction extends WorkspaceTraversalAction{ /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() */ + @Override protected boolean isEnabledForMultipleResources() { return true; } @@ -113,6 +111,7 @@ public class GenerateDiffFileAction extends WorkspaceTraversalAction{ /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForUnmanagedResources() */ + @Override protected boolean isEnabledForUnmanagedResources() { return true; } @@ -121,6 +120,7 @@ public class GenerateDiffFileAction extends WorkspaceTraversalAction{ /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId() */ + @Override public String getId() { return ICVSUIConstants.CMD_CREATEPATCH; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java index f37b05ad7..8beb68d8b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java @@ -48,14 +48,16 @@ public class IgnoreAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) */ - protected String getTaskName(CVSTeamProvider provider) { + @Override + protected String getTaskName(CVSTeamProvider provider) { return NLS.bind(CVSUIMessages.IgnoreAction_0, new String[] { provider.getProject().getName() }); } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) */ - protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { + @Override + protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { try { monitor.beginTask(null, resources.length); for (int i = 0; i < resources.length; i++) { @@ -77,34 +79,37 @@ public class IgnoreAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ - protected String getTaskName() { + @Override + protected String getTaskName() { return CVSUIMessages.IgnoreAction_1; } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#consultModelsForMappings() */ - public boolean consultModelsForMappings() { + @Override + public boolean consultModelsForMappings() { return false; } } + @Override protected void execute(final IAction action) throws InvocationTargetException, InterruptedException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IResource[] resources = getSelectedResources(); - IgnoreResourcesDialog dialog = new IgnoreResourcesDialog(getShell(), resources); - if (dialog.open() != Window.OK) return; - new IgnoreOperation(getTargetPart(), resources, dialog).run(); - - //if (action != null) action.setEnabled(isEnabled()); - } + run((IRunnableWithProgress) monitor -> { + IResource[] resources = getSelectedResources(); + IgnoreResourcesDialog dialog = new IgnoreResourcesDialog(getShell(), resources); + if (dialog.open() != Window.OK) + return; + new IgnoreOperation(getTargetPart(), resources, dialog).run(); + + // if (action != null) action.setEnabled(isEnabled()); }, false /* cancelable */, PROGRESS_BUSYCURSOR); } /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.IgnoreAction_ignore; } @@ -112,6 +117,7 @@ public class IgnoreAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForManagedResources() */ + @Override protected boolean isEnabledForManagedResources() { return false; } @@ -119,6 +125,7 @@ public class IgnoreAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForUnmanagedResources() */ + @Override protected boolean isEnabledForUnmanagedResources() { return true; } @@ -126,6 +133,7 @@ public class IgnoreAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) */ + @Override protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { if (super.isEnabledForCVSResource(cvsResource)) { // Perform an extra check against the subscriber to ensure there is no conflict @@ -146,6 +154,7 @@ public class IgnoreAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId() */ + @Override public String getId() { return ICVSUIConstants.CMD_IGNORE; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java index c0d3974af..c0004f162 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java @@ -25,20 +25,21 @@ public class MergeAction extends WorkspaceTraversalAction { /* * @see CVSAction#execute() */ + @Override public void execute(IAction action) { final Shell shell = getShell(); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - MergeWizard wizard = new MergeWizard(getTargetPart(), getSelectedResources(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId())); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } + shell.getDisplay().syncExec(() -> { + MergeWizard wizard = new MergeWizard(getTargetPart(), getSelectedResources(), + getSelectedResourceMappings(CVSProviderPlugin.getTypeId())); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.open(); }); } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId() */ + @Override public String getId() { return ICVSUIConstants.CMD_MERGE; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java index cce0831cb..0205a977b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenLogEntryAction.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.Iterator; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableWithProgress; @@ -64,17 +63,17 @@ public class OpenLogEntryAction extends CVSAction { /* * @see CVSAction#execute(IAction) */ + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - final ILogEntry[] entries = getSelectedLogEntries(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].isDeletion()) { - MessageDialog.openError(getShell(), CVSUIMessages.OpenLogEntryAction_deletedTitle, CVSUIMessages.OpenLogEntryAction_deleted); // - } else { - ICVSRemoteFile file = entries[i].getRemoteFile(); - CVSUIPlugin.getPlugin().openEditor(file, monitor); - } + run((IRunnableWithProgress) monitor -> { + final ILogEntry[] entries = getSelectedLogEntries(); + for (int i = 0; i < entries.length; i++) { + if (entries[i].isDeletion()) { + MessageDialog.openError(getShell(), CVSUIMessages.OpenLogEntryAction_deletedTitle, + CVSUIMessages.OpenLogEntryAction_deleted); // + } else { + ICVSRemoteFile file = entries[i].getRemoteFile(); + CVSUIPlugin.getPlugin().openEditor(file, monitor); } } }, false, PROGRESS_BUSYCURSOR); @@ -82,6 +81,7 @@ public class OpenLogEntryAction extends CVSAction { /* * @see TeamAction#isEnabled() */ + @Override public boolean isEnabled() { ILogEntry[] entries = getSelectedLogEntries(); if (entries.length == 0) return false; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java index bf3b6fdf0..248ede37a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRemoteFileAction.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.Iterator; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; @@ -66,20 +65,20 @@ public class OpenRemoteFileAction extends CVSAction { /* * @see CVSAction#execute(IAction) */ + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - ICVSRemoteFile[] files = getSelectedRemoteFiles(); - for (int i = 0; i < files.length; i++) { - ICVSRemoteFile file = files[i]; - CVSUIPlugin.getPlugin().openEditor(file, monitor); - } + run((IRunnableWithProgress) monitor -> { + ICVSRemoteFile[] files = getSelectedRemoteFiles(); + for (int i = 0; i < files.length; i++) { + ICVSRemoteFile file = files[i]; + CVSUIPlugin.getPlugin().openEditor(file, monitor); } }, false, PROGRESS_BUSYCURSOR); } /* * @see TeamAction#isEnabled() */ + @Override public boolean isEnabled() { ICVSRemoteFile[] resources = getSelectedRemoteFiles(); if (resources.length == 0) return false; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java index 1028b38ef..b47d425d6 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java @@ -24,21 +24,19 @@ import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; public class ReplaceWithRemoteAction extends WorkspaceTraversalAction { + @Override public void execute(IAction action) throws InvocationTargetException, InterruptedException { final ReplaceOperation replaceOperation = new ReplaceOperation(getTargetPart(), getCVSResourceMappings(), resourceCommonTag); if (hasOutgoingChanges(replaceOperation)) { final boolean[] keepGoing = new boolean[] { true }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), replaceOperation.getScopeManager(), - CVSUIMessages.ReplaceWithTagAction_2, - CVSUIMessages.ReplaceWithTagAction_0, - CVSUIMessages.ReplaceWithTagAction_1); - dialog.setHelpContextId(IHelpContextIds.REPLACE_OUTGOING_CHANGES_DIALOG); - int result = dialog.open(); - keepGoing[0] = result == Window.OK; - } + Display.getDefault().syncExec(() -> { + OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), replaceOperation.getScopeManager(), + CVSUIMessages.ReplaceWithTagAction_2, CVSUIMessages.ReplaceWithTagAction_0, + CVSUIMessages.ReplaceWithTagAction_1); + dialog.setHelpContextId(IHelpContextIds.REPLACE_OUTGOING_CHANGES_DIALOG); + int result = dialog.open(); + keepGoing[0] = result == Window.OK; }); if (!keepGoing[0]) return; @@ -49,6 +47,7 @@ public class ReplaceWithRemoteAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.ReplaceWithRemoteAction_problemMessage; } @@ -56,6 +55,7 @@ public class ReplaceWithRemoteAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() */ + @Override protected boolean isEnabledForAddedResources() { return false; } @@ -63,6 +63,7 @@ public class ReplaceWithRemoteAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() */ + @Override protected boolean isEnabledForNonExistantResources() { return true; } @@ -73,6 +74,7 @@ public class ReplaceWithRemoteAction extends WorkspaceTraversalAction { * * @see TeamAction#setActionEnablement(org.eclipse.jface.action.IAction) */ + @Override protected void setActionEnablement(IAction action) { super.setActionEnablement(action); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java index 9efdc31d7..540cfc05b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java @@ -16,7 +16,6 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.window.Window; @@ -33,20 +32,18 @@ public abstract class ReplaceWithTagAction extends WorkspaceTraversalAction { /* * Method declared on IActionDelegate. */ + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { final ReplaceOperation replaceOperation= createReplaceOperation(); if (hasOutgoingChanges(replaceOperation)) { final boolean[] keepGoing = new boolean[] { true }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), replaceOperation.getScopeManager(), - CVSUIMessages.ReplaceWithTagAction_2, - CVSUIMessages.ReplaceWithTagAction_0, - CVSUIMessages.ReplaceWithTagAction_1); - dialog.setHelpContextId(IHelpContextIds.REPLACE_OUTGOING_CHANGES_DIALOG); - int result = dialog.open(); - keepGoing[0] = result == Window.OK; - } + Display.getDefault().syncExec(() -> { + OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), replaceOperation.getScopeManager(), + CVSUIMessages.ReplaceWithTagAction_2, CVSUIMessages.ReplaceWithTagAction_0, + CVSUIMessages.ReplaceWithTagAction_1); + dialog.setHelpContextId(IHelpContextIds.REPLACE_OUTGOING_CHANGES_DIALOG); + int result = dialog.open(); + keepGoing[0] = result == Window.OK; }); if (!keepGoing[0]) return; @@ -56,25 +53,24 @@ public abstract class ReplaceWithTagAction extends WorkspaceTraversalAction { final CVSTag[] tag= new CVSTag[] { null }; // Show a busy cursor while display the tag selection dialog - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { - monitor= Policy.monitorFor(monitor); - tag[0] = getTag(replaceOperation); - - // finish, when tag can't be obtained - if (tag[0] == null) + run((IRunnableWithProgress) monitor -> { + monitor = Policy.monitorFor(monitor); + tag[0] = getTag(replaceOperation); + + // finish, when tag can't be obtained + if (tag[0] == null) + return; + + // For non-projects determine if the tag being loaded is the same as the + // resource's parent + // If it's not, warn the user that they will have strange sync behavior + try { + if (!CVSAction.checkForMixingTags(getShell(), replaceOperation.getScope().getRoots(), tag[0])) { + tag[0] = null; return; - - // For non-projects determine if the tag being loaded is the same as the resource's parent - // If it's not, warn the user that they will have strange sync behavior - try { - if(!CVSAction.checkForMixingTags(getShell(), replaceOperation.getScope().getRoots(), tag[0])) { - tag[0] = null; - return; - } - } catch (CoreException e) { - throw new InvocationTargetException(e); } + } catch (CoreException e) { + throw new InvocationTargetException(e); } }, false /* cancelable */, PROGRESS_BUSYCURSOR); @@ -97,6 +93,7 @@ public abstract class ReplaceWithTagAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.ReplaceWithTagAction_replace; } @@ -104,6 +101,7 @@ public abstract class ReplaceWithTagAction extends WorkspaceTraversalAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() */ + @Override protected boolean isEnabledForNonExistantResources() { return true; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java index ad6960cfb..2b938715b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java @@ -35,8 +35,9 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; import org.eclipse.team.internal.ccvs.ui.Policy; +import org.eclipse.team.internal.ccvs.ui.ResizableWizardDialog; import org.eclipse.team.internal.ccvs.ui.wizards.RestoreFromRepositoryWizard; /** @@ -60,6 +61,7 @@ public class RestoreFromRepositoryAction extends WorkspaceTraversalAction { ICVSFolder currentFolder; List atticFiles = new ArrayList(); + @Override public IStatus messageLine( String line, ICVSRepositoryLocation location, @@ -116,6 +118,7 @@ public class RestoreFromRepositoryAction extends WorkspaceTraversalAction { return OK; } + @Override public IStatus errorLine( String line, ICVSRepositoryLocation location, @@ -146,6 +149,7 @@ public class RestoreFromRepositoryAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) */ + @Override protected void execute(IAction action) throws InvocationTargetException, InterruptedException { IContainer resource = (IContainer)getSelectedResources()[0]; ICVSFile[] files = fetchDeletedFiles(resource); @@ -163,6 +167,7 @@ public class RestoreFromRepositoryAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() */ + @Override public boolean isEnabled() { IResource[] resources = getSelectedResources(); if (resources.length != 1) return false; @@ -180,16 +185,14 @@ public class RestoreFromRepositoryAction extends WorkspaceTraversalAction { final ICVSFile[][] files = new ICVSFile[1][0]; files[0] = null; try { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(parent); - FolderSyncInfo info = folder.getFolderSyncInfo(); - ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(info.getRoot()); - files[0] = fetchFilesInAttic(location, folder, monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } + run((IRunnableWithProgress) monitor -> { + try { + ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(parent); + FolderSyncInfo info = folder.getFolderSyncInfo(); + ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(info.getRoot()); + files[0] = fetchFilesInAttic(location, folder, monitor); + } catch (CVSException e) { + throw new InvocationTargetException(e); } }, true, PROGRESS_DIALOG); } catch (InvocationTargetException e) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java index 5cc3d8aaa..7117646e1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java @@ -15,7 +15,7 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.IProgressMonitor; + import org.eclipse.jface.action.IAction; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.internal.ccvs.core.EditorsInfo; @@ -30,14 +30,11 @@ import org.eclipse.team.internal.ccvs.ui.EditorsView; */ public class ShowEditorsAction extends WorkspaceAction { + @Override protected void execute(IAction action) throws InvocationTargetException, InterruptedException { final EditorsAction editorsAction = new EditorsAction(); - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - executeProviderAction(editorsAction, monitor); - } - }, true /* cancelable */ , PROGRESS_DIALOG); + run((IRunnableWithProgress) monitor -> executeProviderAction(editorsAction, monitor), true /* cancelable */ , + PROGRESS_DIALOG); EditorsInfo[] infos = editorsAction.getEditorsInfo(); EditorsView view = (EditorsView)showView(EditorsView.VIEW_ID); if (view != null) { @@ -49,6 +46,7 @@ public class ShowEditorsAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() */ + @Override protected boolean isEnabledForAddedResources() { return false; } @@ -56,6 +54,7 @@ public class ShowEditorsAction extends WorkspaceAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() */ + @Override protected boolean isEnabledForNonExistantResources() { return true; } @@ -63,6 +62,7 @@ public class ShowEditorsAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() */ + @Override protected boolean isEnabledForMultipleResources() { // We support one selected Resource, // because the editors command will diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java index 79f8a721d..b4f885037 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.Iterator; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; @@ -62,17 +61,17 @@ public class ShowHistoryAction extends CVSAction { /* * @see CVSAction#executeIAction) */ + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - ICVSRemoteFile[] files = getSelectedRemoteFiles(); - TeamUI.showHistoryFor(getTargetPage(), files[0], null); - } + run((IRunnableWithProgress) monitor -> { + ICVSRemoteFile[] files = getSelectedRemoteFiles(); + TeamUI.showHistoryFor(getTargetPage(), files[0], null); }, false /* cancelable */, PROGRESS_BUSYCURSOR); } /* * @see TeamAction#isEnabled() */ + @Override public boolean isEnabled() { ICVSRemoteFile[] resources = getSelectedRemoteFiles(); return resources.length == 1; @@ -80,6 +79,7 @@ public class ShowHistoryAction extends CVSAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.ShowHistoryAction_showHistory; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java index d54f085b9..fd8f8bc1d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java @@ -16,7 +16,6 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.internal.ccvs.core.CVSException; @@ -30,19 +29,20 @@ public class ShowResourceInHistoryAction extends WorkspaceAction { /* * @see IActionDelegate#run(IAction) */ + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - IResource[] resources = getSelectedResources(); - if (resources.length != 1) return; - TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), resources[0], null); - } + run((IRunnableWithProgress) monitor -> { + IResource[] resources = getSelectedResources(); + if (resources.length != 1) + return; + TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), resources[0], null); }, false /* cancelable */, PROGRESS_BUSYCURSOR); } /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.ShowHistoryAction_showHistory; } @@ -50,6 +50,7 @@ public class ShowResourceInHistoryAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForMultipleResources() */ + @Override protected boolean isEnabledForMultipleResources() { return false; } @@ -57,6 +58,7 @@ public class ShowResourceInHistoryAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() */ + @Override protected boolean isEnabledForAddedResources() { return true; } @@ -64,6 +66,7 @@ public class ShowResourceInHistoryAction extends WorkspaceAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForNonExistantResources() */ + @Override protected boolean isEnabledForNonExistantResources() { return true; } @@ -71,6 +74,7 @@ public class ShowResourceInHistoryAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) */ + @Override protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { return (!cvsResource.isFolder() && super.isEnabledForCVSResource(cvsResource)); } @@ -78,14 +82,17 @@ public class ShowResourceInHistoryAction extends WorkspaceAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId() */ + @Override public String getId() { return ICVSUIConstants.CMD_HISTORY; } + @Override protected boolean isEnabledForUnmanagedResources() { return true; } + @Override protected boolean isEnabledForIgnoredResources() { return true; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java index f883d4959..b44e6082e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java @@ -18,10 +18,10 @@ import java.util.*; import org.eclipse.core.resources.*; import org.eclipse.core.resources.mapping.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; @@ -187,27 +187,22 @@ public class SyncAction extends WorkspaceTraversalAction { */ public static void showSingleFileComparison(final Shell shell, final Subscriber subscriber, final IResource resource, final IWorkbenchPage page) { try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - subscriber.refresh(new IResource[]{resource}, IResource.DEPTH_ZERO, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + try { + subscriber.refresh(new IResource[] { resource }, IResource.DEPTH_ZERO, monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); final SyncInfo info = subscriber.getSyncInfo(resource); if (info == null) return; - shell.getDisplay().syncExec(new Runnable() { - @Override - public void run() { - if (info.getKind() == SyncInfo.IN_SYNC) { - MessageDialog.openInformation(shell, CVSUIMessages.SyncAction_noChangesTitle, CVSUIMessages.SyncAction_noChangesMessage); // - } else { - SyncInfoCompareInput input = new SyncInfoCompareInput(subscriber.getName(), info); - OpenInCompareAction.openCompareEditor(input, page); - } + shell.getDisplay().syncExec(() -> { + if (info.getKind() == SyncInfo.IN_SYNC) { + MessageDialog.openInformation(shell, CVSUIMessages.SyncAction_noChangesTitle, + CVSUIMessages.SyncAction_noChangesMessage); // + } else { + SyncInfoCompareInput input = new SyncInfoCompareInput(subscriber.getName(), info); + OpenInCompareAction.openCompareEditor(input, page); } }); } catch (InvocationTargetException e) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java index 6c71e42e8..4ac4955c8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java @@ -24,13 +24,8 @@ import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.window.Window; import org.eclipse.osgi.util.NLS; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation; import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; import org.eclipse.team.internal.ccvs.ui.tags.TagAsVersionDialog; @@ -46,18 +41,18 @@ public abstract class TagAction extends WorkspaceTraversalAction { /** * @see CVSAction#execute(IAction) */ + @Override public void execute(IAction action) throws InvocationTargetException, InterruptedException { setWasCancelled(false); // Prompt for the tag name final ITagOperation[] result = new ITagOperation[1]; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = configureOperation(); - if (result[0] == null) { - return; - } - }}); + getShell().getDisplay().syncExec(() -> { + result[0] = configureOperation(); + if (result[0] == null) { + return; + } + }); if (result[0] == null) { setWasCancelled(true); @@ -113,10 +108,12 @@ public abstract class TagAction extends WorkspaceTraversalAction { protected abstract ITagOperation createTagOperation(); + @Override protected String getErrorTitle() { return CVSUIMessages.TagAction_tagErrorTitle; } + @Override protected String getWarningTitle() { return CVSUIMessages.TagAction_tagWarningTitle; } @@ -124,6 +121,7 @@ public abstract class TagAction extends WorkspaceTraversalAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources() */ + @Override protected boolean isEnabledForAddedResources() { return false; } @@ -139,6 +137,7 @@ public abstract class TagAction extends WorkspaceTraversalAction { public static void broadcastTagChange(final ICVSResource[] resources, final CVSTag tag) throws InvocationTargetException, InterruptedException { final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); manager.run(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { try { for (int i = 0; i < resources.length; i++) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java index eea9ed336..d1b223690 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java @@ -29,22 +29,20 @@ public class TagLocalAction extends TagAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.TagAction#performPrompting(org.eclipse.team.internal.ccvs.ui.operations.ITagOperation) */ + @Override protected boolean performPrompting(ITagOperation operation) { if (operation instanceof TagOperation) { final TagOperation tagOperation = (TagOperation) operation; try { if (hasOutgoingChanges(tagOperation)) { final boolean[] keepGoing = new boolean[] { true }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), tagOperation.getScopeManager(), - CVSUIMessages.TagLocalAction_2, - CVSUIMessages.TagLocalAction_0, - ""); //$NON-NLS-1$ - dialog.setHelpContextId(IHelpContextIds.TAG_OUTGOING_CHANGES_DIALOG); - int result = dialog.open(); - keepGoing[0] = result == Window.OK; - } + Display.getDefault().syncExec(() -> { + OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), + tagOperation.getScopeManager(), CVSUIMessages.TagLocalAction_2, + CVSUIMessages.TagLocalAction_0, ""); //$NON-NLS-1$ + dialog.setHelpContextId(IHelpContextIds.TAG_OUTGOING_CHANGES_DIALOG); + int result = dialog.open(); + keepGoing[0] = result == Window.OK; }); return keepGoing[0]; } @@ -61,13 +59,15 @@ public class TagLocalAction extends TagAction { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.TagAction#createTagOperation() */ - protected ITagOperation createTagOperation() { + @Override + protected ITagOperation createTagOperation() { return new TagOperation(getTargetPart(), getCVSResourceMappings()); } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getId() */ + @Override public String getId() { return ICVSUIConstants.CMD_TAGASVERSION; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java index 48a1fe2ff..ee384f64e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java @@ -73,6 +73,7 @@ public class UnmanageAction extends WorkspaceAction { } } + @Override protected Control createCustomArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); @@ -96,6 +97,7 @@ public class UnmanageAction extends WorkspaceAction { } private SelectionListener selectionListener = new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { Button button = (Button) e.widget; if (button.getSelection()) { @@ -114,6 +116,7 @@ public class UnmanageAction extends WorkspaceAction { /* * @see IActionDelegate#run(IAction) */ + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { if(confirmDeleteProjects()) { new DisconnectOperation(getTargetPart(), getSelectedProjects(), deleteContent) @@ -125,11 +128,7 @@ public class UnmanageAction extends WorkspaceAction { final int[] result = new int[] { Window.OK }; IProject[] projects = getSelectedProjects(); final DeleteProjectDialog dialog = new DeleteProjectDialog(getShell(), projects); - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = dialog.open(); - } - }); + getShell().getDisplay().syncExec(() -> result[0] = dialog.open()); deleteContent = dialog.getDeleteContent(); return result[0] == 0; // YES } @@ -137,6 +136,7 @@ public class UnmanageAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.Unmanage_unmanagingError; } @@ -144,6 +144,7 @@ public class UnmanageAction extends WorkspaceAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource) */ + @Override protected boolean isEnabledForCVSResource(ICVSResource cvsResource) throws CVSException { IResource resource = cvsResource.getIResource(); return resource != null && resource.getType() == IResource.PROJECT; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java index 850436e1e..7ad0355dd 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java @@ -14,12 +14,7 @@ package org.eclipse.team.internal.ccvs.ui.actions; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.util.*; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; @@ -57,6 +52,7 @@ public abstract class WorkspaceAction extends CVSAction { /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#beginExecution(IAction) */ + @Override protected boolean beginExecution(IAction action) throws TeamException { if (super.beginExecution(action)) { // Ensure that the required sync info is loaded @@ -117,13 +113,11 @@ public abstract class WorkspaceAction extends CVSAction { if (folder.getIResource().getType() == IResource.PROJECT) return; if (CVSWorkspaceRoot.isOrphanedSubtree((IContainer)folder.getIResource())) { try { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - folder.unmanage(null); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - } + run((IRunnableWithProgress) monitor -> { + try { + folder.unmanage(null); + } catch (CVSException e) { + CVSProviderPlugin.log(e); } }, true, PROGRESS_BUSYCURSOR); } catch (InvocationTargetException e) { @@ -209,6 +203,7 @@ public abstract class WorkspaceAction extends CVSAction { * * @see org.eclipse.team.internal.ui.actions.TeamAction#setActionEnablement(IAction) */ + @Override protected void setActionEnablement(IAction action) { try { boolean requires = requiresLocalSyncInfo(); @@ -246,20 +241,20 @@ public abstract class WorkspaceAction extends CVSAction { protected boolean promptToRefresh(final Shell shell, final IResource[] resources, final IStatus status) { final boolean[] result = new boolean[] { false}; - Runnable runnable = new Runnable() { - public void run() { - Shell shellToUse = shell; - if (shell == null) { - shellToUse = new Shell(Display.getCurrent()); - } - String question; - if (resources.length == 1) { - question = NLS.bind(CVSUIMessages.CVSAction_refreshQuestion, new String[] { status.getMessage(), resources[0].getFullPath().toString() }); - } else { - question = NLS.bind(CVSUIMessages.CVSAction_refreshMultipleQuestion, new String[] { status.getMessage() }); - } - result[0] = MessageDialog.openQuestion(shellToUse, CVSUIMessages.CVSAction_refreshTitle, question); + Runnable runnable = () -> { + Shell shellToUse = shell; + if (shell == null) { + shellToUse = new Shell(Display.getCurrent()); + } + String question; + if (resources.length == 1) { + question = NLS.bind(CVSUIMessages.CVSAction_refreshQuestion, + new String[] { status.getMessage(), resources[0].getFullPath().toString() }); + } else { + question = NLS.bind(CVSUIMessages.CVSAction_refreshMultipleQuestion, + new String[] { status.getMessage() }); } + result[0] = MessageDialog.openQuestion(shellToUse, CVSUIMessages.CVSAction_refreshTitle, question); }; Display.getDefault().syncExec(runnable); return result[0]; @@ -270,6 +265,7 @@ public abstract class WorkspaceAction extends CVSAction { * save dirty editors. * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#needsToSaveDirtyEditors() */ + @Override protected boolean needsToSaveDirtyEditors() { return true; } @@ -290,6 +286,7 @@ public abstract class WorkspaceAction extends CVSAction { * * @see TeamAction#isEnabled() */ + @Override public boolean isEnabled() { // allow the super to decide enablement. if the super doesn't know it will return false. diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java index cac821285..b02879137 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java @@ -21,7 +21,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.*; import org.eclipse.core.runtime.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.mapping.ISynchronizationScopeManager; @@ -108,18 +107,13 @@ public abstract class WorkspaceTraversalAction extends WorkspaceAction { // Use a resource mapping context to include any relevant remote resources final IResource[][] resources = new IResource[][] { null }; try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - resources[0] = getRootTraversalResources( - manager, - monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - - }); + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + try { + resources[0] = getRootTraversalResources(manager, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + }); } catch (InterruptedException e) { // Canceled return null; @@ -143,7 +137,8 @@ public abstract class WorkspaceTraversalAction extends WorkspaceAction { * * @deprecated need to find a better way to do this */ - public static boolean isLogicalModel(ResourceMapping[] mappings) { + @Deprecated + public static boolean isLogicalModel(ResourceMapping[] mappings) { for (int i = 0; i < mappings.length; i++) { ResourceMapping mapping = mappings[i]; if (! (mapping.getModelObject() instanceof IResource) ) { @@ -165,20 +160,16 @@ public abstract class WorkspaceTraversalAction extends WorkspaceAction { protected boolean hasOutgoingChanges(final RepositoryProviderOperation operation) throws InvocationTargetException, InterruptedException { final boolean[] hasChange = new boolean[] { false }; - PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - try { - monitor.beginTask(CVSUIMessages.WorkspaceTraversalAction_0, 100); - operation.buildScope(Policy.subMonitorFor(monitor, 50)); - hasChange[0] = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().hasLocalChanges( - operation.getScope().getTraversals(), - Policy.subMonitorFor(monitor, 50)); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } + PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> { + try { + monitor.beginTask(CVSUIMessages.WorkspaceTraversalAction_0, 100); + operation.buildScope(Policy.subMonitorFor(monitor, 50)); + hasChange[0] = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber() + .hasLocalChanges(operation.getScope().getTraversals(), Policy.subMonitorFor(monitor, 50)); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); } }); return hasChange[0]; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java index 985f05f0d..03b2bbb6b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java @@ -13,8 +13,6 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.console; -import com.ibm.icu.text.DateFormat; -import com.ibm.icu.text.SimpleDateFormat; import java.util.Date; import org.eclipse.core.runtime.*; @@ -35,6 +33,9 @@ import org.eclipse.team.internal.ccvs.ui.*; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.console.*; +import com.ibm.icu.text.DateFormat; +import com.ibm.icu.text.SimpleDateFormat; + /** * Console that shows the output of CVS commands. It is shown as a page in the generic * console view. It supports coloring for message, command, and error lines in addition @@ -92,6 +93,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener * and dispose(). */ public class MyLifecycle implements org.eclipse.ui.console.IConsoleListener { + @Override public void consolesAdded(IConsole[] consoles) { for (int i = 0; i < consoles.length; i++) { IConsole console = consoles[i]; @@ -101,6 +103,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener } } + @Override public void consolesRemoved(IConsole[] consoles) { for (int i = 0; i < consoles.length; i++) { IConsole console = consoles[i]; @@ -128,6 +131,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* (non-Javadoc) * @see org.eclipse.ui.console.AbstractConsole#init() */ + @Override protected void init() { // Called when console is added to the console view super.init(); @@ -136,12 +140,10 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener initWrapSetting(); // Ensure that initialization occurs in the ui thread - CVSUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - JFaceResources.getFontRegistry().addListener(CVSOutputConsole.this); - initializeStreams(); - dump(); - } + CVSUIPlugin.getStandardDisplay().asyncExec(() -> { + JFaceResources.getFontRegistry().addListener(CVSOutputConsole.this); + initializeStreams(); + dump(); }); } @@ -228,6 +230,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* (non-Javadoc) * @see org.eclipse.ui.console.MessageConsole#dispose() */ + @Override protected void dispose() { // Here we can't call super.dispose() because we actually want the partitioner to remain // connected, but we won't show lines until the console is added to the console manager @@ -259,6 +262,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandInvoked(java.lang.String) */ + @Override public void commandInvoked(Session session, String line) { if (!session.isOutputToConsole()) return; commandStarted = System.currentTimeMillis(); @@ -269,6 +273,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#messageLineReceived(java.lang.String) */ + @Override public void messageLineReceived(Session session, String line, IStatus status) { if (session.isOutputToConsole()) { appendLine(ConsoleDocument.MESSAGE, " " + line); //$NON-NLS-1$ @@ -278,6 +283,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#errorLineReceived(java.lang.String) */ + @Override public void errorLineReceived(Session session, String line, IStatus status) { if (session.isOutputToConsole()) { appendLine(ConsoleDocument.ERROR, " " + line); //$NON-NLS-1$ @@ -287,6 +293,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandCompleted(org.eclipse.core.runtime.IStatus, java.lang.Exception) */ + @Override public void commandCompleted(Session session, IStatus status, Exception exception) { if (!session.isOutputToConsole()) return; long commandRuntime = System.currentTimeMillis() - commandStarted; @@ -356,6 +363,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* (non-Javadoc) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ + @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); // colors @@ -433,7 +441,8 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener } } - public String getHelpContextId() { + @Override + public String getHelpContextId() { return IHelpContextIds.CONSOLE_VIEW; } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java index 43ba0892e..52e83242e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java @@ -21,7 +21,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.diff.IDiff; @@ -44,18 +43,17 @@ public abstract class AbstractCommitAction extends CVSModelProviderAction { /* (non-Javadoc) * @see org.eclipse.jface.action.Action#run() */ + @Override public void execute() { final List resources = new ArrayList(); try { final IStructuredSelection selection = getActualSelection(); - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ResourceTraversal[] traversals = getCommitTraversals(selection, monitor); - resources.add(getOutgoingChanges(getSynchronizationContext().getDiffTree(), traversals, monitor)); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + try { + ResourceTraversal[] traversals = getCommitTraversals(selection, monitor); + resources.add(getOutgoingChanges(getSynchronizationContext().getDiffTree(), traversals, monitor)); + } catch (CoreException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java index e6fdc2aea..bbc815a95 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java @@ -26,7 +26,8 @@ import org.eclipse.team.core.mapping.provider.MergeStatus; import org.eclipse.team.core.mapping.provider.ResourceDiffTree; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.subscribers.SubscriberMergeContext; -import org.eclipse.team.internal.ccvs.core.*; +import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.ICVSFile; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; @@ -37,6 +38,7 @@ import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext { private static final IStorageMerger MERGER = new DelegatingStorageMerger() { + @Override protected IStorageMerger createDelegateMerger(IStorage target) throws CoreException { IStorageMerger storageMerger = super.createDelegateMerger(target); if (storageMerger == null) { @@ -49,6 +51,7 @@ public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext { return storageMerger; } + @Override protected int getType(IStorage target) { if (target instanceof IFile) { IFile file = (IFile) target; @@ -79,26 +82,21 @@ public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext { /* (non-Javadoc) * @see org.eclipse.team.core.mapping.MergeContext#run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.jobs.ISchedulingRule, int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void run(final IWorkspaceRunnable runnable, final ISchedulingRule rule, int flags, IProgressMonitor monitor) throws CoreException { - super.run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - EclipseSynchronizer.getInstance().run(rule, new ICVSRunnable(){ - public void run(IProgressMonitor monitor) throws CVSException { - try { - runnable.run(monitor); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } - } - }, monitor); + super.run(monitor1 -> EclipseSynchronizer.getInstance().run(rule, monitor2 -> { + try { + runnable.run(monitor2); + } catch (CoreException e) { + throw CVSException.wrapException(e); } - - }, rule, flags, monitor); + }, monitor1), rule, flags, monitor); } /* (non-Javadoc) * @see org.eclipse.team.core.mapping.MergeContext#getMergeRule(org.eclipse.core.resources.IResource) */ + @Override public ISchedulingRule getMergeRule(IDiff node) { // Return the project since that is what the EclipseSynchronize needs return getDiffTree().getResource(node).getProject(); @@ -107,6 +105,7 @@ public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext { /* (non-Javadoc) * @see org.eclipse.team.core.mapping.provider.MergeContext#makeInSync(org.eclipse.team.core.diff.IDiff, org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException { markAsMerged(diff, true, monitor); } @@ -114,18 +113,17 @@ public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext { /* (non-Javadoc) * @see org.eclipse.team.core.mapping.IMergeContext#reject(org.eclipse.team.core.diff.IDiff, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void reject(IDiff diff, IProgressMonitor monitor) throws CoreException { markAsMerged(diff, false, monitor); } + @Override public IStatus merge(final IDiff[] diffs, final boolean ignoreLocalChanges, IProgressMonitor monitor) throws CoreException { final IStatus[] result = new IStatus[] { Status.OK_STATUS }; if (diffs.length > 0) - run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - result[0] = internalMerge(diffs, ignoreLocalChanges, monitor); - } - }, getMergeRule(diffs), IWorkspace.AVOID_UPDATE, monitor); + run(monitor1 -> result[0] = internalMerge(diffs, ignoreLocalChanges, monitor1), getMergeRule(diffs), + IWorkspace.AVOID_UPDATE, monitor); return result[0]; } @@ -190,6 +188,7 @@ public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext { if (!folderDiffs.isEmpty()) { // Order the diffs so empty added children will get deleted before their parents are visited Collections.sort(folderDiffs, new Comparator() { + @Override public int compare(Object o1, Object o2) { return ((IDiff)o2).getPath().toString().compareTo(((IDiff)o1).getPath().toString()); } @@ -243,6 +242,7 @@ public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext { return (IFile[]) failures.toArray(new IFile[failures.size()]); } + @Override public T getAdapter(Class adapter) { if (adapter == IStorageMerger.class) return adapter.cast(MERGER); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java index b9e955b90..1d6212196 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java @@ -62,13 +62,10 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { super(TeamUIMessages.ChangeLogModelProvider_0, configuration); } + @Override public void run() { final IDiff[] diffs = getLocalChanges(getStructuredSelection()); - syncExec(new Runnable() { - public void run() { - createChangeSet(diffs); - } - }); + syncExec(() -> createChangeSet(diffs)); } /* package */void createChangeSet(IDiff[] diffs) { @@ -78,6 +75,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { } } + @Override protected boolean isEnabledForSelection(IStructuredSelection selection) { return isContentProviderEnabled() && containsOnlyLocalChanges(selection); @@ -118,6 +116,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { selectionChanged(selection); } + @Override public void run() { IDiff[] diffArray = getLocalChanges(getStructuredSelection()); if (set != null) { @@ -132,6 +131,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { } } + @Override protected boolean isEnabledForSelection(IStructuredSelection selection) { return isContentProviderEnabled() && containsOnlyLocalChanges(selection); @@ -147,6 +147,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { /* (non-Javadoc) * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) */ + @Override protected boolean updateSelection(IStructuredSelection selection) { return getSelectedSet() != null; } @@ -171,6 +172,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { super(TeamUIMessages.ChangeLogModelProvider_6, configuration); } + @Override public void run() { ActiveChangeSet set = getSelectedSet(); if (set == null) return; @@ -184,6 +186,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { super(TeamUIMessages.ChangeLogModelProvider_7, configuration); } + @Override public void run() { IDiff[] diffArray = getLocalChanges(getStructuredSelection()); ChangeSet[] sets = getActiveChangeSetManager().getSets(); @@ -194,6 +197,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { } } + @Override protected boolean isEnabledForSelection(IStructuredSelection selection) { return isContentProviderEnabled() && containsOnlyLocalChanges(selection); @@ -206,6 +210,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { super(TeamUIMessages.ChangeLogModelProvider_9, configuration); } + @Override protected boolean updateSelection(IStructuredSelection selection) { if (getSelectedSet() != null) { setText(TeamUIMessages.ChangeLogModelProvider_9); @@ -218,6 +223,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { return true; } + @Override public void run() { getActiveChangeSetManager().makeDefault( isChecked() ? getSelectedSet() : null); @@ -239,6 +245,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { update(); } + @Override public void run() { int sortCriteria = getSortCriteria(internalGetSynchronizePageConfiguration()); if (isChecked() && sortCriteria != criteria) { @@ -295,6 +302,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { super(); } + @Override protected void initialize() { super.initialize(); if (getChangeSetCapability().supportsCheckedInChangeSets()) { @@ -341,6 +349,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { return (IResource[]) result.toArray(new IResource[result.size()]); } + @Override public void fillContextMenu(IMenuManager menu) { if (isContentProviderEnabled()) { super.fillContextMenu(menu); @@ -395,6 +404,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { manager.add(new Separator()); } + @Override public void dispose() { if (addToChangeSet != null) { addToChangeSet.dispose(); @@ -539,6 +549,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { private FastDiffFilter getNonLocalChangesFilter() { return new FastDiffFilter() { + @Override public boolean select(IDiff diff) { if (diff instanceof IThreeWayDiff && isVisible(diff)) { IThreeWayDiff twd = (IThreeWayDiff) diff; @@ -589,6 +600,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { return TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_LAYOUT); } + @Override public void setContext(ActionContext context) { super.setContext(context); if (context != null) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java index 4c6840d80..3b826025f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java @@ -47,16 +47,15 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.internal.core.subscribers.IChangeSetChangeListener#setAdded(org.eclipse.team.internal.core.subscribers.ChangeSet) */ + @Override public void setAdded(final ChangeSet set) { // We only react here for active change sets. // Checked-in change set changes are batched if (set instanceof ActiveChangeSet) { if (isVisibleInMode(set)) { - Utils.syncExec(new Runnable() { - public void run() { - Object input = getViewer().getInput(); - ((AbstractTreeViewer)getViewer()).add(input, set); - } + Utils.syncExec((Runnable) () -> { + Object input = getViewer().getInput(); + ((AbstractTreeViewer) getViewer()).add(input, set); }, (StructuredViewer)getViewer()); } handleSetAddition(set); @@ -70,19 +69,18 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.internal.core.subscribers.IChangeSetChangeListener#defaultSetChanged(org.eclipse.team.internal.core.subscribers.ChangeSet, org.eclipse.team.internal.core.subscribers.ChangeSet) */ + @Override public void defaultSetChanged(final ChangeSet previousDefault, final ChangeSet set) { if (isVisibleInMode(set) || isVisibleInMode(previousDefault)) { - Utils.asyncExec(new Runnable() { - public void run() { - if (set == null) { - // unset default changeset - ((AbstractTreeViewer)getViewer()).update(previousDefault, null); - } else if (previousDefault != null) { - ((AbstractTreeViewer)getViewer()).update(new Object[] {previousDefault, set}, null); - } else { - // when called for the first time previous default change set is null - ((AbstractTreeViewer)getViewer()).update(set, null); - } + Utils.asyncExec((Runnable) () -> { + if (set == null) { + // unset default changeset + ((AbstractTreeViewer) getViewer()).update(previousDefault, null); + } else if (previousDefault != null) { + ((AbstractTreeViewer) getViewer()).update(new Object[] { previousDefault, set }, null); + } else { + // when called for the first time previous default change set is null + ((AbstractTreeViewer) getViewer()).update(set, null); } }, (StructuredViewer)getViewer()); } @@ -91,16 +89,14 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.internal.core.subscribers.IChangeSetChangeListener#setRemoved(org.eclipse.team.internal.core.subscribers.ChangeSet) */ + @Override public void setRemoved(final ChangeSet set) { // We only react here for active change sets. // Checked-in change set changes are batched if (set instanceof ActiveChangeSet) { if (isVisibleInMode(set)) { - Utils.syncExec(new Runnable() { - public void run() { - ((AbstractTreeViewer)getViewer()).remove(TreePath.EMPTY.createChildPath(set)); - } - }, (StructuredViewer)getViewer()); + Utils.syncExec((Runnable) () -> ((AbstractTreeViewer) getViewer()) + .remove(TreePath.EMPTY.createChildPath(set)), (StructuredViewer) getViewer()); } handleSetRemoval(set); } @@ -121,34 +117,31 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.internal.core.subscribers.IChangeSetChangeListener#nameChanged(org.eclipse.team.internal.core.subscribers.ChangeSet) */ + @Override public void nameChanged(final ChangeSet set) { if (isVisibleInMode(set)) { - Utils.asyncExec(new Runnable() { - public void run() { - ((AbstractTreeViewer)getViewer()).update(set, null); - } - }, (StructuredViewer)getViewer()); + Utils.asyncExec((Runnable) () -> ((AbstractTreeViewer) getViewer()).update(set, null), + (StructuredViewer) getViewer()); } } /* (non-Javadoc) * @see org.eclipse.team.internal.core.subscribers.IChangeSetChangeListener#resourcesChanged(org.eclipse.team.internal.core.subscribers.ChangeSet, org.eclipse.core.runtime.IPath[]) */ + @Override public void resourcesChanged(final ChangeSet set, final IPath[] paths) { // We only react here for active change sets. // Checked-in change set changes are batched if (set instanceof ActiveChangeSet) { if (isVisibleInMode(set)) { - Utils.syncExec(new Runnable() { - public void run() { - if (hasChildrenInContext(set)) - if (getVisibleSetsInViewer().contains(set)) - ((AbstractTreeViewer)getViewer()).refresh(set, true); - else - ((AbstractTreeViewer)getViewer()).add(getViewer().getInput(), set); - else - ((AbstractTreeViewer)getViewer()).remove(set); - } + Utils.syncExec((Runnable) () -> { + if (hasChildrenInContext(set)) + if (getVisibleSetsInViewer().contains(set)) + ((AbstractTreeViewer) getViewer()).refresh(set, true); + else + ((AbstractTreeViewer) getViewer()).add(getViewer().getInput(), set); + else + ((AbstractTreeViewer) getViewer()).remove(set); }, (StructuredViewer)getViewer()); } handleSetChange(set, paths); @@ -178,6 +171,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple } } + @Override public void changeSetChanges(final CollectorChangeEvent event, IProgressMonitor monitor) { ChangeSet[] addedSets = event.getAddedSets(); final ChangeSet[] visibleAddedSets = getVisibleSets(addedSets); @@ -186,23 +180,21 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple ChangeSet[] changedSets = event.getChangedSets(); final ChangeSet[] visibleChangedSets = getVisibleSets(changedSets); if (visibleAddedSets.length > 0 || visibleRemovedSets.length > 0 || visibleChangedSets.length > 0) { - Utils.syncExec(new Runnable() { - public void run() { - try { - getViewer().getControl().setRedraw(false); - if (visibleAddedSets.length > 0) { - Object input = getViewer().getInput(); - ((AbstractTreeViewer)getViewer()).add(input, visibleAddedSets); - } - if (visibleRemovedSets.length > 0) - ((AbstractTreeViewer)getViewer()).remove(visibleRemovedSets); - for (int i = 0; i < visibleChangedSets.length; i++) { - ChangeSet set = visibleChangedSets[i]; - ((AbstractTreeViewer)getViewer()).refresh(set, true); - } - } finally { - getViewer().getControl().setRedraw(true); + Utils.syncExec((Runnable) () -> { + try { + getViewer().getControl().setRedraw(false); + if (visibleAddedSets.length > 0) { + Object input = getViewer().getInput(); + ((AbstractTreeViewer) getViewer()).add(input, visibleAddedSets); } + if (visibleRemovedSets.length > 0) + ((AbstractTreeViewer) getViewer()).remove(visibleRemovedSets); + for (int i = 0; i < visibleChangedSets.length; i++) { + ChangeSet set = visibleChangedSets[i]; + ((AbstractTreeViewer) getViewer()).refresh(set, true); + } + } finally { + getViewer().getControl().setRedraw(true); } }, (StructuredViewer)getViewer()); } @@ -268,6 +260,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.core.diff.IDiffChangeListener#propertyChanged(org.eclipse.team.core.diff.IDiffTree, int, org.eclipse.core.runtime.IPath[]) */ + @Override public void propertyChanged(IDiffTree tree, int property, IPath[] paths) { // Ignore } @@ -279,19 +272,18 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.core.diff.IDiffChangeListener#diffsChanged(org.eclipse.team.core.diff.IDiffChangeEvent, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { Object input = getViewer().getInput(); if (input instanceof ChangeSetModelProvider && unassignedDiffs != null && event.getTree() == unassignedDiffs.getDiffTree()) { - Utils.asyncExec(new Runnable() { - public void run() { - if (unassignedDiffs.isEmpty() || !hasChildren(TreePath.EMPTY.createChildPath(getUnassignedSet()))) { - ((AbstractTreeViewer)getViewer()).remove(unassignedDiffs); - } else if (!isSetVisible(unassignedDiffs)) { - Object input = getViewer().getInput(); - ((AbstractTreeViewer)getViewer()).add(input, unassignedDiffs); - } else { - ((AbstractTreeViewer)getViewer()).refresh(unassignedDiffs); - } + Utils.asyncExec((Runnable) () -> { + if (unassignedDiffs.isEmpty() || !hasChildren(TreePath.EMPTY.createChildPath(getUnassignedSet()))) { + ((AbstractTreeViewer) getViewer()).remove(unassignedDiffs); + } else if (!isSetVisible(unassignedDiffs)) { + Object input1 = getViewer().getInput(); + ((AbstractTreeViewer) getViewer()).add(input1, unassignedDiffs); + } else { + ((AbstractTreeViewer) getViewer()).refresh(unassignedDiffs); } }, (StructuredViewer)getViewer()); } @@ -304,6 +296,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.internal.ui.mapping.ResourceModelContentProvider#getModelProviderId() */ + @Override protected String getModelProviderId() { return ChangeSetModelProvider.ID; } @@ -329,6 +322,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.internal.ui.mapping.ResourceModelContentProvider#getElements(java.lang.Object) */ + @Override public Object[] getElements(Object parent) { if (parent instanceof ISynchronizationContext) { // Do not show change sets when all models are visible because @@ -374,12 +368,10 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple private void addAllUnassignedToUnassignedSet() { IResourceDiffTree allChanges = getContext().getDiffTree(); final List diffs = new ArrayList(); - allChanges.accept(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new IDiffVisitor() { - public boolean visit(IDiff diff) { - if (!isContainedInSet(diff)) - diffs.add(diff); - return true; - } + allChanges.accept(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), diff -> { + if (!isContainedInSet(diff)) + diffs.add(diff); + return true; }, IResource.DEPTH_INFINITE); unassignedDiffs.add((IDiff[]) diffs.toArray(new IDiff[diffs.size()])); } @@ -409,6 +401,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple /* (non-Javadoc) * @see org.eclipse.team.internal.ui.mapping.ResourceModelContentProvider#getTraversals(org.eclipse.team.core.mapping.ISynchronizationContext, java.lang.Object) */ + @Override protected ResourceTraversal[] getTraversals( ISynchronizationContext context, Object object) { if (object instanceof ChangeSet) { @@ -419,6 +412,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple return super.getTraversals(context, object); } + @Override public Object[] getChildren(TreePath parentPath) { if (!isEnabled()) return new Object[0]; @@ -524,6 +518,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple return false; } + @Override public boolean hasChildren(TreePath path) { if (path.getSegmentCount() == 1) { Object first = path.getFirstSegment(); @@ -544,6 +539,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple return false; } + @Override public TreePath[] getParents(Object element) { if (element instanceof ChangeSet) { return new TreePath[] { TreePath.EMPTY }; @@ -655,6 +651,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple return result; } + @Override public void init(ICommonContentExtensionSite site) { super.init(site); ChangeSetCapability csc = getChangeSetCapability(); @@ -690,6 +687,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple } } + @Override public void dispose() { ChangeSetCapability csc = getChangeSetCapability(); if (csc.supportsActiveChangeSets()) { @@ -705,6 +703,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple super.dispose(); } + @Override public boolean isVisible(IDiff diff) { return super.isVisible(diff); } @@ -720,6 +719,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple return getTheRest(); } + @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { // Override inherited method to reconcile sub-trees IPath[] removed = event.getRemovals(); @@ -754,14 +754,12 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple if (firstDiffChange) { // One the first diff event, refresh the viewer to ensure outgoing change sets appear firstDiffChange = false; - Utils.asyncExec(new Runnable() { - public void run() { - ((AbstractTreeViewer)getViewer()).refresh(); - } - }, (StructuredViewer)getViewer()); + Utils.asyncExec((Runnable) () -> ((AbstractTreeViewer) getViewer()).refresh(), + (StructuredViewer) getViewer()); } } + @Override protected void updateLabels(ISynchronizationContext context, IPath[] paths) { super.updateLabels(context, paths); ChangeSet[] sets = getSetsShowingPropogatedStateFrom(paths); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java index 646579e41..67c1e1d3a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java @@ -21,7 +21,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.team.core.diff.*; import org.eclipse.team.core.mapping.IResourceDiffTree; @@ -41,6 +40,7 @@ public class CreatePatchAction extends CVSModelProviderAction implements IDiffCh /* (non-Javadoc) * @see org.eclipse.team.internal.ui.mapping.ModelProviderAction#isEnabledForSelection(org.eclipse.jface.viewers.IStructuredSelection) */ + @Override protected boolean isEnabledForSelection(IStructuredSelection selection) { return internalIsEnabled(selection); } @@ -75,20 +75,20 @@ public class CreatePatchAction extends CVSModelProviderAction implements IDiffCh /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.mappings.CVSModelProviderAction#getBundleKeyPrefix() */ - protected String getBundleKeyPrefix() { + @Override + protected String getBundleKeyPrefix() { return "GenerateDiffFileAction."; //$NON-NLS-1$ } - public void execute() { + @Override + public void execute() { final ResourceTraversal [][] traversals = new ResourceTraversal[][] { null }; try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - traversals[0] = getResourceTraversals(getStructuredSelection(), monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + try { + traversals[0] = getResourceTraversals(getStructuredSelection(), monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e) { @@ -106,10 +106,12 @@ public class CreatePatchAction extends CVSModelProviderAction implements IDiffCh } } + @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { updateEnablement(); } + @Override public void propertyChanged(IDiffTree tree, int property, IPath[] paths) { // Nothing to do } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java index b390c93de..d7b903203 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java @@ -51,26 +51,20 @@ public class MergeSubscriberContext extends CVSSubscriberMergeContext { */ @Override public void markAsMerged(final IDiff diff, boolean inSyncHint, IProgressMonitor monitor) throws CoreException { - run(new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - ((CVSMergeSubscriber)getSubscriber()).merged(new IResource[] { getDiffTree().getResource(diff)}); - } - }, getMergeRule(diff), IResource.NONE, monitor); + run(monitor1 -> ((CVSMergeSubscriber) getSubscriber()) + .merged(new IResource[] { getDiffTree().getResource(diff) }), getMergeRule(diff), IResource.NONE, + monitor); } @Override public void markAsMerged(final IDiff[] diffs, boolean inSyncHint, IProgressMonitor monitor) throws CoreException { - run(new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - List result = new ArrayList(); - for (int i = 0; i < diffs.length; i++) { - IDiff diff = diffs[i]; - result.add(getDiffTree().getResource(diff)); - } - ((CVSMergeSubscriber)getSubscriber()).merged((IResource[]) result.toArray(new IResource[result.size()])); + run(monitor1 -> { + List result = new ArrayList(); + for (int i = 0; i < diffs.length; i++) { + IDiff diff = diffs[i]; + result.add(getDiffTree().getResource(diff)); } + ((CVSMergeSubscriber) getSubscriber()).merged((IResource[]) result.toArray(new IResource[result.size()])); }, getMergeRule(diffs), IResource.NONE, monitor); } @@ -88,31 +82,28 @@ public class MergeSubscriberContext extends CVSSubscriberMergeContext { @Override public IStatus merge(final IDiff diff, final boolean ignoreLocalChanges, IProgressMonitor monitor) throws CoreException { final IStatus[] status = new IStatus[] { Status.OK_STATUS }; - run(new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - IThreeWayDiff currentDiff = (IThreeWayDiff)getSubscriber().getDiff(getDiffTree().getResource(diff)); - if (!MergeSubscriberContext.this.equals(currentDiff, (IThreeWayDiff)diff)) { - throw new CVSException(NLS.bind(CVSUIMessages.CVSMergeContext_1, diff.getPath())); - } - status[0] = MergeSubscriberContext.super.merge(diff, ignoreLocalChanges, monitor); - if (status[0].isOK()) { - IResource resource = ResourceDiffTree.getResourceFor(diff); - if (resource.getType() == IResource.FILE && resource.exists() && diff instanceof IThreeWayDiff) { - IThreeWayDiff twd = (IThreeWayDiff) diff; - if (twd.getKind() == IDiff.ADD && twd.getDirection() == IThreeWayDiff.INCOMING) { - IFileRevision remote = Utils.getRemote(diff); - IResourceVariant variant = Adapters.adapt(remote, IResourceVariant.class); - byte[] syncBytes = variant.asBytes(); - MutableResourceSyncInfo info = new MutableResourceSyncInfo(resource.getName(), ResourceSyncInfo.ADDED_REVISION); - info.setKeywordMode(ResourceSyncInfo.getKeywordMode(syncBytes)); - info.setTag(getTag(resource.getParent())); - CVSWorkspaceRoot.getCVSFileFor((IFile)resource).setSyncInfo(info, ICVSFile.DIRTY); - } + run(monitor1 -> { + IThreeWayDiff currentDiff = (IThreeWayDiff) getSubscriber().getDiff(getDiffTree().getResource(diff)); + if (!MergeSubscriberContext.this.equals(currentDiff, (IThreeWayDiff) diff)) { + throw new CVSException(NLS.bind(CVSUIMessages.CVSMergeContext_1, diff.getPath())); + } + status[0] = MergeSubscriberContext.super.merge(diff, ignoreLocalChanges, monitor1); + if (status[0].isOK()) { + IResource resource = ResourceDiffTree.getResourceFor(diff); + if (resource.getType() == IResource.FILE && resource.exists() && diff instanceof IThreeWayDiff) { + IThreeWayDiff twd = (IThreeWayDiff) diff; + if (twd.getKind() == IDiff.ADD && twd.getDirection() == IThreeWayDiff.INCOMING) { + IFileRevision remote = Utils.getRemote(diff); + IResourceVariant variant = Adapters.adapt(remote, IResourceVariant.class); + byte[] syncBytes = variant.asBytes(); + MutableResourceSyncInfo info = new MutableResourceSyncInfo(resource.getName(), + ResourceSyncInfo.ADDED_REVISION); + info.setKeywordMode(ResourceSyncInfo.getKeywordMode(syncBytes)); + info.setTag(getTag(resource.getParent())); + CVSWorkspaceRoot.getCVSFileFor((IFile) resource).setSyncInfo(info, ICVSFile.DIRTY); } } } - }, getMergeRule(diff), IWorkspace.AVOID_UPDATE, monitor); return status[0]; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java index c1d7bc66a..3f2cf9ccc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java @@ -37,6 +37,7 @@ public class ModelReplaceOperation extends ModelUpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.ui.TeamOperation#getJobName() */ + @Override protected String getJobName() { return CVSUIMessages.ReplaceOperation_taskName; } @@ -44,6 +45,7 @@ public class ModelReplaceOperation extends ModelUpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.ui.operations.ResourceMappingMergeOperation#isAttemptHeadlessMerge() */ + @Override protected boolean isAttemptHeadlessMerge() { return true; } @@ -51,6 +53,7 @@ public class ModelReplaceOperation extends ModelUpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.ui.operations.ResourceMappingMergeOperation#hasChangesOfInterest() */ + @Override protected boolean hasChangesOfInterest() { IMergeContext context = (IMergeContext)getContext(); return !context.getDiffTree().isEmpty(); @@ -59,6 +62,7 @@ public class ModelReplaceOperation extends ModelUpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.mappings.ModelUpdateOperation#getMergeType() */ + @Override protected int getMergeType() { return ISynchronizationContext.TWO_WAY; } @@ -66,6 +70,7 @@ public class ModelReplaceOperation extends ModelUpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.ui.operations.ResourceMappingMergeOperation#performMerge(org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected IStatus performMerge(IProgressMonitor monitor) throws CoreException { if (!hasLocalChanges() || promptForOverwrite()) { return super.performMerge(monitor); @@ -80,20 +85,19 @@ public class ModelReplaceOperation extends ModelUpdateOperation { if (hasPrompted) return true; final int[] result = new int[] { 1 }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.ModelReplaceOperation_0, null, // accept - // the - // default - // window - // icon - CVSUIMessages.ModelReplaceOperation_1, - MessageDialog.QUESTION, new String[] { CVSUIMessages.ModelReplaceOperation_2, CVSUIMessages.ModelReplaceOperation_3, - IDialogConstants.CANCEL_LABEL }, result[0]); // preview is the default - - result[0] = dialog.open(); + Display.getDefault().syncExec(() -> { + MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.ModelReplaceOperation_0, null, // accept + // the + // default + // window + // icon + CVSUIMessages.ModelReplaceOperation_1, MessageDialog.QUESTION, + new String[] { CVSUIMessages.ModelReplaceOperation_2, CVSUIMessages.ModelReplaceOperation_3, + IDialogConstants.CANCEL_LABEL }, + result[0]); // preview is the default + + result[0] = dialog.open(); - }; }); if (result[0] == 2) throw new OperationCanceledException(); @@ -103,6 +107,7 @@ public class ModelReplaceOperation extends ModelUpdateOperation { private boolean hasLocalChanges() { return getContext().getDiffTree().hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() { + @Override public boolean select(IDiff node) { if (node instanceof IThreeWayDiff) { IThreeWayDiff twd = (IThreeWayDiff) node; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java index 365f33c47..7cd2e0035 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java @@ -18,7 +18,6 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.*; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.RepositoryProvider; @@ -212,13 +211,7 @@ class OpenChangeSetAction extends ResourceModelParticipantAction { @Override public void run() { try { - PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - openEditor(monitor); - } - }); + PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> openEditor(monitor)); } catch (InvocationTargetException e) { Utils.handle(e); } catch (InterruptedException e) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java index f4e7599a7..943a45573 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java @@ -59,13 +59,16 @@ public class WorkspaceModelParticipant extends public class WorkspaceMergeActionGroup extends ModelSynchronizeParticipantActionGroup { private WorkspaceCommitAction commitToolbar; + @Override public void initialize(ISynchronizePageConfiguration configuration) { configuration.setProperty(MERGE_ALL_ACTION_ID, new MergeAllActionHandler(configuration) { + @Override protected String getJobName() { String name = getConfiguration().getParticipant().getName(); return NLS.bind(CVSUIMessages.WorkspaceModelParticipant_0, Utils.shortenText(SynchronizeView.MAX_NAME_LENGTH, name)); } + @Override protected boolean promptToUpdate() { final IResourceDiffTree tree = getMergeContext().getDiffTree(); if (tree.isEmpty()) { @@ -75,23 +78,28 @@ public class WorkspaceModelParticipant extends if (count == 0) return false; final boolean[] result = new boolean[] {true}; - TeamUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - String sizeString = Long.toString(count); - String message = tree.size() > 1 ? NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateSeveral, new String[] { sizeString }) : NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateOne, new String[] { sizeString }); // - result[0] = MessageDialog.openQuestion(getConfiguration().getSite().getShell(), NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateTitle, new String[] { sizeString }), message); - - } + TeamUIPlugin.getStandardDisplay().syncExec(() -> { + String sizeString = Long.toString(count); + String message = tree.size() > 1 + ? NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateSeveral, + new String[] { sizeString }) + : NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateOne, new String[] { sizeString }); // + result[0] = MessageDialog.openQuestion(getConfiguration().getSite().getShell(), + NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateTitle, new String[] { sizeString }), + message); + }); return result[0]; } private IMergeContext getMergeContext() { return ((IMergeContext)getConfiguration().getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT)); } + @Override protected boolean needsToSaveDirtyEditors() { int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS); return option != ICVSUIConstants.OPTION_NEVER; } + @Override protected boolean confirmSaveOfDirtyEditor() { int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS); return option == ICVSUIConstants.OPTION_PROMPT; @@ -154,6 +162,7 @@ public class WorkspaceModelParticipant extends /* (non-Javadoc) * @see org.eclipse.team.ui.operations.MergeActionGroup#configureMergeAction(java.lang.String, org.eclipse.jface.action.Action) */ + @Override protected void configureMergeAction(String mergeActionId, Action action) { if (mergeActionId == SynchronizationActionProvider.MERGE_ACTION_ID) { Utils.initAction(action, "WorkspaceUpdateAction.", Policy.getActionBundle()); //$NON-NLS-1$ @@ -172,6 +181,7 @@ public class WorkspaceModelParticipant extends } } + @Override protected void addToContextMenu(String mergeActionId, Action action, IMenuManager manager) { IContributionItem group = null;; if (mergeActionId == SynchronizationActionProvider.MERGE_ACTION_ID) { @@ -213,6 +223,7 @@ public class WorkspaceModelParticipant extends /* (non-Javadoc) * @see org.eclipse.team.ui.operations.ModelSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) */ + @Override protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { configuration.setProperty(ISynchronizePageConfiguration.P_VIEWER_ID, VIEWER_ID); super.initializeConfiguration(configuration); @@ -221,6 +232,7 @@ public class WorkspaceModelParticipant extends /* (non-Javadoc) * @see org.eclipse.team.ui.operations.ResourceMappingSynchronizeParticipant#createMergeActionGroup() */ + @Override protected ModelSynchronizeParticipantActionGroup createMergeActionGroup() { return new WorkspaceMergeActionGroup(); } @@ -228,6 +240,7 @@ public class WorkspaceModelParticipant extends /* (non-Javadoc) * @see org.eclipse.team.ui.operations.ModelSynchronizeParticipant#restoreContext(org.eclipse.team.core.mapping.IResourceMappingScope, org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected MergeContext restoreContext(ISynchronizationScopeManager manager) { return WorkspaceSubscriberContext.createContext(manager, ISynchronizationContext.THREE_WAY); } @@ -235,23 +248,27 @@ public class WorkspaceModelParticipant extends /* (non-Javadoc) * @see org.eclipse.team.ui.operations.ModelSynchronizeParticipant#createScopeManager(org.eclipse.core.resources.mapping.ResourceMapping[]) */ + @Override protected ISynchronizationScopeManager createScopeManager(ResourceMapping[] mappings) { return WorkspaceSubscriberContext.createWorkspaceScopeManager(mappings, true, isConsultChangeSets); } - public ChangeSetCapability getChangeSetCapability() { + @Override + public ChangeSetCapability getChangeSetCapability() { if (capability == null) { capability = new WorkspaceChangeSetCapability(); } return capability; } - public void saveState(IMemento memento) { + @Override + public void saveState(IMemento memento) { super.saveState(memento); memento.putString(CTX_CONSULT_CHANGE_SETS, Boolean.toString(isConsultChangeSets)); } - public void init(String secondaryId, IMemento memento) throws PartInitException { + @Override + public void init(String secondaryId, IMemento memento) throws PartInitException { try { String consult = memento.getString(CTX_CONSULT_CHANGE_SETS); if (consult != null) diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java index 1fe0d9932..5fbbc116e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java @@ -20,7 +20,7 @@ import java.util.List; import org.eclipse.core.resources.*; import org.eclipse.core.resources.mapping.*; import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.preferences.*; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; import org.eclipse.osgi.util.NLS; @@ -32,7 +32,8 @@ import org.eclipse.team.core.mapping.*; import org.eclipse.team.core.mapping.provider.ResourceDiffTree; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.subscribers.SubscriberScopeManager; -import org.eclipse.team.core.synchronize.*; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.SyncInfoFilter; import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter; import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.internal.ccvs.core.*; @@ -59,6 +60,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem this.consultSets = consultSets; } + @Override protected ResourceTraversal[] adjustInputTraversals(ResourceTraversal[] traversals) { if (isConsultSets()) return ((CVSActiveChangeSetCollector)CVSUIPlugin.getPlugin().getChangeSetManager()).adjustInputTraversals(traversals); @@ -90,11 +92,13 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.SubscriberMergeContext#getDiffFilter() */ + @Override protected DiffFilter getDiffFilter() { final DiffFilter contentFilter = createContentFilter(); final DiffFilter regexFilter = createRegexFilter(); if (contentFilter != null && regexFilter != null) { return new DiffFilter() { + @Override public boolean select(IDiff diff, IProgressMonitor monitor) { return !contentFilter.select(diff, monitor) && !regexFilter.select(diff, monitor); @@ -102,12 +106,14 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem }; } else if (contentFilter != null) { return new DiffFilter() { + @Override public boolean select(IDiff diff, IProgressMonitor monitor) { return !contentFilter.select(diff, monitor); } }; } else if (regexFilter != null) { return new DiffFilter() { + @Override public boolean select(IDiff diff, IProgressMonitor monitor) { return !regexFilter.select(diff, monitor); } @@ -125,6 +131,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.SubscriberMergeContext#dispose() */ + @Override public void dispose() { super.dispose(); ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).removePreferenceChangeListener(this); //$NON-NLS-1$ @@ -156,6 +163,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem /* (non-Javadoc) * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) */ + @Override public void preferenceChange(PreferenceChangeEvent event) { if (event.getKey().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS) || event.getKey().equals(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN)) { SubscriberDiffTreeEventHandler handler = getHandler(); @@ -166,6 +174,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem } } + @Override public void markAsMerged(IDiff[] nodes, boolean inSyncHint, IProgressMonitor monitor) throws CoreException { if (getType() == TWO_WAY) { // For, TWO_WAY merges (i.e. replace) should not adjust sync info @@ -186,88 +195,86 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem } } + @Override public void markAsMerged(final IDiff diff, final boolean inSyncHint, IProgressMonitor monitor) throws CoreException { - run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - // Get the latest sync info for the file (i.e. not what is in the set). - // We do this because the client may have modified the file since the - // set was populated. - IResource resource = getDiffTree().getResource(diff); - if (resource.getType() != IResource.FILE) { - if (diff instanceof IThreeWayDiff) { - IThreeWayDiff twd = (IThreeWayDiff) diff; - if (resource.getType() == IResource.FOLDER - && twd.getKind() == IDiff.ADD - && twd.getDirection() == IThreeWayDiff.INCOMING - && resource.exists()) { - // The folder was created by merge - SyncInfo info = getSyncInfo(resource); - if (info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo = (CVSSyncInfo) info; - cvsInfo.makeInSync(); - } + run(monitor1 -> { + // Get the latest sync info for the file (i.e. not what is in the set). + // We do this because the client may have modified the file since the + // set was populated. + IResource resource = getDiffTree().getResource(diff); + if (resource.getType() != IResource.FILE) { + if (diff instanceof IThreeWayDiff) { + IThreeWayDiff twd = (IThreeWayDiff) diff; + if (resource.getType() == IResource.FOLDER + && twd.getKind() == IDiff.ADD + && twd.getDirection() == IThreeWayDiff.INCOMING + && resource.exists()) { + // The folder was created by merge + SyncInfo info1 = getSyncInfo(resource); + if (info1 instanceof CVSSyncInfo) { + CVSSyncInfo cvsInfo1 = (CVSSyncInfo) info1; + cvsInfo1.makeInSync(); } } - return; } - if (getType() == TWO_WAY) { - // For, TWO_WAY merges (i.e. replace) should not adjust sync info - // but should remove the node from the tree so that other models do - // not modify the file - ((DiffTree)getDiffTree()).remove(diff.getPath()); - } else { - SyncInfo info = getSyncInfo(resource); - ensureRemotesMatch(resource, diff, info); - if (info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo = (CVSSyncInfo) info; - monitor.beginTask(null, 50 + (inSyncHint ? 100 : 0)); - cvsInfo.makeOutgoing(Policy.subMonitorFor(monitor, 50)); - if (inSyncHint) { - // Compare the contents of the file with the remote - // and make the file in-sync if they match - ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); - if (resource.getType() == IResource.FILE && info.getRemote() != null) { - if (comparator.compareContents((IFile)resource, info.getRemote(), Policy.subMonitorFor(monitor, 100))) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - cvsFile.checkedIn(null, false /* not a commit */); - } + return; + } + if (getType() == TWO_WAY) { + // For, TWO_WAY merges (i.e. replace) should not adjust sync info + // but should remove the node from the tree so that other models do + // not modify the file + ((DiffTree)getDiffTree()).remove(diff.getPath()); + } else { + SyncInfo info2 = getSyncInfo(resource); + ensureRemotesMatch(resource, diff, info2); + if (info2 instanceof CVSSyncInfo) { + CVSSyncInfo cvsInfo2 = (CVSSyncInfo) info2; + monitor1.beginTask(null, 50 + (inSyncHint ? 100 : 0)); + cvsInfo2.makeOutgoing(Policy.subMonitorFor(monitor1, 50)); + if (inSyncHint) { + // Compare the contents of the file with the remote + // and make the file in-sync if they match + ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); + if (resource.getType() == IResource.FILE && info2.getRemote() != null) { + if (comparator.compareContents((IFile)resource, info2.getRemote(), Policy.subMonitorFor(monitor1, 100))) { + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); + cvsFile.checkedIn(null, false /* not a commit */); } } - monitor.done(); } + monitor1.done(); } } }, getMergeRule(diff), IResource.NONE, monitor); } + @Override protected void makeInSync(final IDiff diff, IProgressMonitor monitor) throws CoreException { - run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - // Get the latest sync info for the file (i.e. not what is in the set). - // We do this because the client may have modified the file since the - // set was populated. - IResource resource = getDiffTree().getResource(diff); - if (resource.getType() != IResource.FILE) - return; - SyncInfo info = getSyncInfo(resource); - ensureRemotesMatch(resource, diff, info); - IResourceVariant remote = info.getRemote(); - RemoteFile file = (RemoteFile)remote; - if (file != null) - remote = file.getCachedHandle(); - - if (info instanceof CVSSyncInfo) { - CVSSyncInfo cvsInfo = (CVSSyncInfo) info; - cvsInfo.makeOutgoing(monitor); - if (resource.getType() == IResource.FILE && info.getRemote() != null) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - if (remote != null && remote instanceof RemoteFile){ - cvsFile.setExecutable(((RemoteFile)remote).isExecutable()); - cvsFile.setTimeStamp(((RemoteFile) remote).getTimeStamp()); - cvsFile.setReadOnly(getReadOnly(cvsFile)); - } - cvsFile.checkedIn(null , false /* not a commit */); + run(monitor1 -> { + // Get the latest sync info for the file (i.e. not what is in the set). + // We do this because the client may have modified the file since the + // set was populated. + IResource resource = getDiffTree().getResource(diff); + if (resource.getType() != IResource.FILE) + return; + SyncInfo info = getSyncInfo(resource); + ensureRemotesMatch(resource, diff, info); + IResourceVariant remote = info.getRemote(); + RemoteFile file = (RemoteFile)remote; + if (file != null) + remote = file.getCachedHandle(); + + if (info instanceof CVSSyncInfo) { + CVSSyncInfo cvsInfo = (CVSSyncInfo) info; + cvsInfo.makeOutgoing(monitor1); + if (resource.getType() == IResource.FILE && info.getRemote() != null) { + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); + if (remote != null && remote instanceof RemoteFile){ + cvsFile.setExecutable(((RemoteFile)remote).isExecutable()); + cvsFile.setTimeStamp(((RemoteFile) remote).getTimeStamp()); + cvsFile.setReadOnly(getReadOnly(cvsFile)); } + cvsFile.checkedIn(null , false /* not a commit */); } } }, getMergeRule(diff), IResource.NONE, monitor); @@ -315,6 +322,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem /* (non-Javadoc) * @see org.eclipse.team.core.mapping.MergeContext#merge(org.eclipse.team.core.diff.IDiffNode, boolean, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public IStatus merge(IDiff delta, boolean force, IProgressMonitor monitor) throws CoreException { if (getMergeType() == ISynchronizationContext.TWO_WAY) { force = true; @@ -369,6 +377,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem /* (non-Javadoc) * @see org.eclipse.team.core.mapping.provider.MergeContext#getMergeType() */ + @Override public int getMergeType() { return type; } @@ -376,6 +385,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.SubscriberMergeContext#refresh(org.eclipse.core.resources.mapping.ResourceTraversal[], int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void refresh(final ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException { SubscriberDiffTreeEventHandler handler = getHandler(); if (handler != null) { @@ -384,18 +394,10 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem handler.setProgressGroupHint(group.getGroup(), group.getTicks()); handler.initializeIfNeeded(); ((CVSWorkspaceSubscriber)getSubscriber()).refreshWithContentFetch(traversals, monitor); - runInBackground(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - cacheContents(traversals, getDiffTree(), true, monitor); - } - }); + runInBackground(monitor1 -> cacheContents(traversals, getDiffTree(), true, monitor1)); } else { super.refresh(traversals, flags, monitor); - runInBackground(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - cacheContents(traversals, getDiffTree(), false, monitor); - } - }); + runInBackground(monitor1 -> cacheContents(traversals, getDiffTree(), false, monitor1)); } } @@ -416,18 +418,23 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem // OPTIMIZE: remote state and contents could be obtained in 1 // OPTIMIZE: Based could be avoided if we always cached base locally ResourceMapping[] mappings = new ResourceMapping[] { new ResourceMapping() { + @Override public Object getModelObject() { return WorkspaceSubscriberContext.this; } + @Override public IProject[] getProjects() { return ResourcesPlugin.getWorkspace().getRoot().getProjects(); } + @Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return traversals; } - public boolean contains(ResourceMapping mapping) { + @Override + public boolean contains(ResourceMapping mapping) { return false; } + @Override public String getModelProviderId() { return ModelProvider.RESOURCE_MODEL_PROVIDER_ID; } @@ -447,6 +454,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem } } + @Override public IStatus merge(IDiff[] deltas, boolean force, IProgressMonitor monitor) throws CoreException { try { if (deltas.length == 0) @@ -497,6 +505,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem return tree; } + @Override protected void performReplace(IDiff diff, IProgressMonitor monitor) throws CoreException { IResource resource = ResourceDiffTree.getResourceFor(diff); if (resource.getType() == IResource.FILE){ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java index ca730811d..a63d91f58 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSRemoteFilePropertySource.java @@ -16,17 +16,11 @@ package org.eclipse.team.internal.ccvs.ui.model; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; import org.eclipse.team.internal.ccvs.core.ILogEntry; import org.eclipse.team.internal.ccvs.ui.*; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.ui.views.properties.*; public class CVSRemoteFilePropertySource implements IPropertySource { ICVSRemoteFile file; @@ -76,6 +70,7 @@ public class CVSRemoteFilePropertySource implements IPropertySource { /** * Do nothing because properties are read only. */ + @Override public Object getEditableValue() { return this; } @@ -83,6 +78,7 @@ public class CVSRemoteFilePropertySource implements IPropertySource { /** * Return the Property Descriptors for the receiver. */ + @Override public IPropertyDescriptor[] getPropertyDescriptors() { return propertyDescriptors; } @@ -90,6 +86,7 @@ public class CVSRemoteFilePropertySource implements IPropertySource { /* * @see IPropertySource#getPropertyValue(Object) */ + @Override public Object getPropertyValue(Object id) { if (!initialized) { initialize(); @@ -119,6 +116,7 @@ public class CVSRemoteFilePropertySource implements IPropertySource { * Answer true if the value of the specified property * for this object has been changed from the default. */ + @Override public boolean isPropertySet(Object property) { return false; } @@ -128,30 +126,30 @@ public class CVSRemoteFilePropertySource implements IPropertySource { * * @param property The property to reset. */ + @Override public void resetPropertyValue(Object property) { } /** * Do nothing because properties are read only. */ + @Override public void setPropertyValue(Object name, Object value) { } private void initialize() { try { - CVSUIPlugin.runWithProgress(null, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ILogEntry[] entries = file.getLogEntries(monitor); - String revision = file.getRevision(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getRevision().equals(revision)) { - entry = entries[i]; - return; - } + CVSUIPlugin.runWithProgress(null, true /* cancelable */, monitor -> { + try { + ILogEntry[] entries = file.getLogEntries(monitor); + String revision = file.getRevision(); + for (int i = 0; i < entries.length; i++) { + if (entries[i].getRevision().equals(revision)) { + entry = entries[i]; + return; } - } catch (TeamException e) { - throw new InvocationTargetException(e); } + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); } catch (InterruptedException e) { // ignore cancellation diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java index 4442e49c5..c01cc73b8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java @@ -18,18 +18,18 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.*; import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.runtime.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.window.Window; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Session; import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; +import org.eclipse.team.internal.ccvs.core.client.Session; import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.syncinfo.*; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; @@ -59,16 +59,14 @@ public class BranchOperation extends RepositoryProviderOperation { /* (non-Javadoc) * @see org.eclipse.team.ui.TeamOperation#shouldRun() */ + @Override protected boolean shouldRun() { try { - PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - try { - buildScope(monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> { + try { + buildScope(monitor); + } catch (CVSException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e1) { @@ -116,6 +114,7 @@ public class BranchOperation extends RepositoryProviderOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected void execute(CVSTeamProvider provider, IResource[] providerResources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { try { monitor.beginTask(null, 100); @@ -215,41 +214,47 @@ public class BranchOperation extends RepositoryProviderOperation { * It expects to be passed an InfiniteSubProgressMonitor */ private void setTag(final CVSTeamProvider provider, final IResource[] resources, final CVSTag tag, final boolean recurse, IProgressMonitor monitor) throws TeamException { - getLocalRoot(provider).run(new ICVSRunnable() { - public void run(IProgressMonitor progress) throws CVSException { - try { - // 512 ticks gives us a maximum of 2048 which seems reasonable for folders and files in a project - progress.beginTask(null, 100); - final IProgressMonitor monitor = Policy.infiniteSubMonitorFor(progress, 100); - monitor.beginTask(NLS.bind(CVSUIMessages.CVSTeamProvider_folderInfo, new String[] { provider.getProject().getName() }), 512); - - // Visit all the children folders in order to set the root in the folder sync info - for (int i = 0; i < resources.length; i++) { - CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - monitor.worked(1); - //ResourceSyncInfo info = file.getSyncInfo(); - byte[] syncBytes = file.getSyncBytes(); - if (syncBytes != null) { - monitor.subTask(NLS.bind(CVSUIMessages.CVSTeamProvider_updatingFile, new String[] { file.getName() })); - file.setSyncBytes(ResourceSyncInfo.setTag(syncBytes, tag), ICVSFile.UNKNOWN); - } + getLocalRoot(provider).run(progress -> { + try { + // 512 ticks gives us a maximum of 2048 which seems reasonable for folders and + // files in a project + progress.beginTask(null, 100); + final IProgressMonitor monitor1 = Policy.infiniteSubMonitorFor(progress, 100); + monitor1.beginTask(NLS.bind(CVSUIMessages.CVSTeamProvider_folderInfo, + new String[] { provider.getProject().getName() }), 512); + + // Visit all the children folders in order to set the root in the folder sync + // info + for (int i = 0; i < resources.length; i++) { + CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(new ICVSResourceVisitor() { + @Override + public void visitFile(ICVSFile file) throws CVSException { + monitor1.worked(1); + // ResourceSyncInfo info = file.getSyncInfo(); + byte[] syncBytes = file.getSyncBytes(); + if (syncBytes != null) { + monitor1.subTask(NLS.bind(CVSUIMessages.CVSTeamProvider_updatingFile, + new String[] { file.getName() })); + file.setSyncBytes(ResourceSyncInfo.setTag(syncBytes, tag), ICVSFile.UNKNOWN); } - public void visitFolder(ICVSFolder folder) throws CVSException { - monitor.worked(1); - FolderSyncInfo info = folder.getFolderSyncInfo(); - if (info != null) { - monitor.subTask(NLS.bind(CVSUIMessages.CVSTeamProvider_updatingFolder, new String[] { info.getRepository() })); - MutableFolderSyncInfo newInfo = info.cloneMutable(); - newInfo.setTag(tag); - folder.setFolderSyncInfo(newInfo); - } + } + + @Override + public void visitFolder(ICVSFolder folder) throws CVSException { + monitor1.worked(1); + FolderSyncInfo info = folder.getFolderSyncInfo(); + if (info != null) { + monitor1.subTask(NLS.bind(CVSUIMessages.CVSTeamProvider_updatingFolder, + new String[] { info.getRepository() })); + MutableFolderSyncInfo newInfo = info.cloneMutable(); + newInfo.setTag(tag); + folder.setFolderSyncInfo(newInfo); } - }, recurse); - } - } finally { - progress.done(); + } + }, recurse); } + } finally { + progress.done(); } }, monitor); } @@ -273,6 +278,7 @@ public class BranchOperation extends RepositoryProviderOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ + @Override protected String getTaskName() { return CVSUIMessages.BranchOperation_0; } @@ -280,6 +286,7 @@ public class BranchOperation extends RepositoryProviderOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) */ + @Override protected String getTaskName(CVSTeamProvider provider) { return NLS.bind(CVSUIMessages.BranchOperation_1, new String[] { provider.getProject().getName() }); } @@ -341,6 +348,7 @@ public class BranchOperation extends RepositoryProviderOperation { return versionName; } + @Override protected boolean isReportableError(IStatus status) { return super.isReportableError(status) || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java index 7be70be84..2e3988729 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java @@ -47,6 +47,7 @@ public class CacheBaseContentsOperation extends CacheTreeContentsOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CacheTreeContentsOperation#getRemoteFileState(org.eclipse.team.core.diff.IThreeWayDiff) */ + @Override protected IFileRevision getRemoteFileState(IThreeWayDiff twd) { IResourceDiff diff = (IResourceDiff)twd.getRemoteChange(); if (diff == null) @@ -58,6 +59,7 @@ public class CacheBaseContentsOperation extends CacheTreeContentsOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CacheTreeContentsOperation#isEnabledForDirection(int) */ + @Override protected boolean isEnabledForDirection(int direction) { return true; } @@ -65,10 +67,12 @@ public class CacheBaseContentsOperation extends CacheTreeContentsOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CacheTreeContentsOperation#buildTree(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) */ + @Override protected ICVSRemoteResource buildTree(CVSTeamProvider provider) throws TeamException { return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().buildBaseTree(provider.getProject(), true, new NullProgressMonitor()); } + @Override protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { IResource[] localChanges = getFilesWithLocalChanges(resources, recurse); super.execute(provider, resources, recurse, monitor); @@ -105,21 +109,21 @@ public class CacheBaseContentsOperation extends CacheTreeContentsOperation { private void performCleanTimestamps(IProject project, final IResource[] resources, IProgressMonitor monitor) throws CVSException { ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); - folder.run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, resources.length * 100); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (resource.exists() && resource.getType() == IResource.FILE) { - IResourceVariant remoteResource = (IResourceVariant)CVSWorkspaceRoot.getRemoteResourceFor(resource); - if (remoteResource != null && comparator.compareContents((IFile)resource, remoteResource, Policy.subMonitorFor(monitor, 100))) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - cvsFile.checkedIn(null, false /* not a commit */); - } + folder.run(monitor1 -> { + monitor1.beginTask(null, resources.length * 100); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (resource.exists() && resource.getType() == IResource.FILE) { + IResourceVariant remoteResource = (IResourceVariant) CVSWorkspaceRoot + .getRemoteResourceFor(resource); + if (remoteResource != null && comparator.compareContents((IFile) resource, remoteResource, + Policy.subMonitorFor(monitor1, 100))) { + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) resource); + cvsFile.checkedIn(null, false /* not a commit */); } } - monitor.done(); } + monitor1.done(); }, Policy.subMonitorFor(monitor, 100)); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java index cadf5b8fb..23770afdc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java @@ -13,10 +13,7 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.operations; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; @@ -30,7 +27,7 @@ import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.ui.IWorkbenchPart; @@ -67,6 +64,7 @@ public class CheckoutIntoOperation extends CheckoutOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#getTaskName() */ + @Override protected String getTaskName() { ICVSRemoteFolder[] remoteFolders = getRemoteFolders(); String localFolderName = ""; //$NON-NLS-1$ @@ -91,6 +89,7 @@ public class CheckoutIntoOperation extends CheckoutOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected IStatus checkout(final ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException { final IStatus[] result = new IStatus[] { null }; try { @@ -100,11 +99,8 @@ public class CheckoutIntoOperation extends CheckoutOperation { // orphaned (i.e. unmanaged) subtrees and we will // purposely create some which we subsequently manage // from their parent (see manageFolders()) - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - result[0] = checkout(folder, getLocalFolder(), isRecursive(), monitor); - } - }, getSchedulingRule(), 0, monitor); + ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> result[0] = checkout(folder, + getLocalFolder(), isRecursive(), monitor1), getSchedulingRule(), 0, monitor); } catch (CoreException e) { result[0] = CVSException.wrapException(e).getStatus(); } @@ -114,18 +110,17 @@ public class CheckoutIntoOperation extends CheckoutOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder[], org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected void checkout(final ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException { // Batch sync info changes with the CVS synchronizer to optimize cache writing - EclipseSynchronizer.getInstance().run(getSchedulingRule(), new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 100); - try { - // Obtain a scheduling rule on the projects were about to overwrite - CheckoutIntoOperation.super.checkout(folders, Policy.subMonitorFor(monitor, 90)); - refreshRoot(getLocalRoot(getLocalFolder()), Policy.subMonitorFor(monitor, 10)); - } finally { - monitor.done(); - } + EclipseSynchronizer.getInstance().run(getSchedulingRule(), monitor1 -> { + monitor1.beginTask(null, 100); + try { + // Obtain a scheduling rule on the projects were about to overwrite + CheckoutIntoOperation.super.checkout(folders, Policy.subMonitorFor(monitor1, 90)); + refreshRoot(getLocalRoot(getLocalFolder()), Policy.subMonitorFor(monitor1, 10)); + } finally { + monitor1.done(); } }, Policy.monitorFor(monitor)); } @@ -252,9 +247,11 @@ public class CheckoutIntoOperation extends CheckoutOperation { ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(root); try { cvsFolder.accept(new ICVSResourceVisitor() { + @Override public void visitFile(ICVSFile file) throws CVSException { // do nothing } + @Override public void visitFolder(ICVSFolder folder) throws CVSException { if (!folder.isCVSFolder()) return; IResource resource = folder.getIResource(); @@ -428,6 +425,7 @@ public class CheckoutIntoOperation extends CheckoutOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getSchedulingRule() */ + @Override protected ISchedulingRule getSchedulingRule() { //use the modfiy rule for the time being //TODO: Just lock the project not the entire workspace (so can't use modifyRule) diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java index f22a54b38..cdfc3aff5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java @@ -30,7 +30,8 @@ import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ui.wizards.WorkingSetsDialog; import org.eclipse.ui.*; @@ -160,20 +161,17 @@ public abstract class CheckoutProjectOperation extends CheckoutOperation { try { Job.getJobManager().beginRule(schedulingRule, pm); // Still use the projects as the inner rule so we get the proper batching of sync info write - EclipseSynchronizer.getInstance().run(MultiRule.combine(targetProjects), new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - result[0] = performCheckout(session, resource, targetProjects, sendModuleName, monitor); - } - }, Policy.subMonitorFor(pm, 90)); + EclipseSynchronizer + .getInstance().run( + MultiRule.combine(targetProjects), monitor -> result[0] = performCheckout(session, + resource, targetProjects, sendModuleName, monitor), + Policy.subMonitorFor(pm, 90)); } finally { Job.getJobManager().endRule(schedulingRule); } } else { - EclipseSynchronizer.getInstance().run(schedulingRule, new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - result[0] = performCheckout(session, resource, targetProjects, sendModuleName, monitor); - } - }, Policy.subMonitorFor(pm, 90)); + EclipseSynchronizer.getInstance().run(schedulingRule, monitor -> result[0] = performCheckout(session, + resource, targetProjects, sendModuleName, monitor), Policy.subMonitorFor(pm, 90)); } IWorkingSet[] ws = getWorkingSets(); if (ws != null) { @@ -504,6 +502,7 @@ public abstract class CheckoutProjectOperation extends CheckoutOperation { } } + @Override protected String getTaskName() { ICVSRemoteFolder[] remoteFolders = getRemoteFolders(); if (remoteFolders.length == 1) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java index 5b2800ce1..1fc4c9e50 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java @@ -17,7 +17,8 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.swt.dnd.*; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; @@ -34,6 +35,7 @@ public class ClipboardDiffOperation extends DiffOperation { super(part, mappings, options, isMultiPatch, includeFullPathInformation, patchRoot, DESTINATION_CLIPBOARD); } + @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { super.execute(monitor); @@ -46,21 +48,18 @@ public class ClipboardDiffOperation extends DiffOperation { } private void copyToClipboard(final ByteArrayOutputStream baos) { - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - TextTransfer plainTextTransfer = TextTransfer.getInstance(); - Clipboard clipboard = new Clipboard(getShell().getDisplay()); - clipboard.setContents( - new String[]{baos.toString()}, - new Transfer[]{plainTextTransfer}); - clipboard.dispose(); - } - }); + getShell().getDisplay().syncExec(() -> { + TextTransfer plainTextTransfer = TextTransfer.getInstance(); + Clipboard clipboard = new Clipboard(getShell().getDisplay()); + clipboard.setContents(new String[] { baos.toString() }, new Transfer[] { plainTextTransfer }); + clipboard.dispose(); + }); } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.DiffOperation#openStream() */ + @Override protected PrintStream openStream() { return new PrintStream(os); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java index 022e4204a..cb531e0dd 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java @@ -114,6 +114,7 @@ public class FetchAllMembersOperation extends RemoteOperation { this.repoLocation = repoLocation; } + @Override protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { //expand each folder selected in the tree ICVSRemoteResource[] restest = getRemoteResources(); @@ -163,11 +164,8 @@ public class FetchAllMembersOperation extends RemoteOperation { prov.addCachedTree(project, remoteTree); final TreeViewer tree = repView.getViewer(); - Utils.asyncExec( new Runnable() { - public void run() { - tree.expandToLevel(project, AbstractTreeViewer.ALL_LEVELS); - } - }, repView.getViewer()); + Utils.asyncExec((Runnable) () -> tree.expandToLevel(project, AbstractTreeViewer.ALL_LEVELS), + repView.getViewer()); } } catch (InvocationTargetException e) { @@ -195,6 +193,7 @@ public class FetchAllMembersOperation extends RemoteOperation { } } + @Override protected String getTaskName() { return CVSUIMessages.FetchAllMembersOperation_0; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java index fa78fba12..b4ea0683e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java @@ -27,7 +27,7 @@ import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; @@ -47,6 +47,7 @@ public class ReconcileProjectOperation extends ShareProjectOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ + @Override protected String getTaskName() { return NLS.bind(CVSUIMessages.ReconcileProjectOperation_0, new String[] { getProject().getName(), folder.getRepositoryRelativePath() }); } @@ -54,6 +55,7 @@ public class ReconcileProjectOperation extends ShareProjectOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.ShareProjectOperation#createRemoteFolder(org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected ICVSRemoteFolder createRemoteFolder(IProgressMonitor monitor) throws CVSException { // The folder already exists so just return the handle return folder; @@ -62,6 +64,7 @@ public class ReconcileProjectOperation extends ShareProjectOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.ShareProjectOperation#mapProjectToRemoteFolder(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected void mapProjectToRemoteFolder(ICVSRemoteFolder remote, IProgressMonitor monitor) throws TeamException { // Map the project monitor.beginTask(null, 100); @@ -95,11 +98,8 @@ public class ReconcileProjectOperation extends ShareProjectOperation { } private void populateWorkspace(final ICVSRemoteFolder remote, IProgressMonitor monitor) throws CVSException { - CVSWorkspaceRoot.getCVSFolderFor(getProject()).run(new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { - populateWorkspace(getProject(), remote, monitor); - } - }, monitor); + CVSWorkspaceRoot.getCVSFolderFor(getProject()) + .run(monitor1 -> populateWorkspace(getProject(), remote, monitor1), monitor); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java index c68d8ca0f..b5eab3267 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java @@ -13,11 +13,7 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.operations; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import org.eclipse.compare.CompareUI; import org.eclipse.core.runtime.*; @@ -95,12 +91,8 @@ public class RemoteCompareOperation extends RemoteOperation { */ public void openCompareEditor(final IWorkbenchPage page, final String title, final String toolTip) { if (leftTree == null || rightTree == null) return; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - CompareUI.openCompareEditorOnPage( - new CVSCompareEditorInput(title, toolTip, new ResourceEditionNode(leftTree), new ResourceEditionNode(rightTree)), page); - } - }); + Display.getDefault().asyncExec(() -> CompareUI.openCompareEditorOnPage(new CVSCompareEditorInput(title, + toolTip, new ResourceEditionNode(leftTree), new ResourceEditionNode(rightTree)), page)); } /** @@ -177,6 +169,7 @@ public class RemoteCompareOperation extends RemoteOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#fileDiff(java.lang.String, java.lang.String, java.lang.String) */ + @Override public void fileDiff(String remoteFilePath, String leftRevision, String rightRevision) { try { addFile(rightTree, right, new Path(null, remoteFilePath), rightRevision); @@ -193,6 +186,7 @@ public class RemoteCompareOperation extends RemoteOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#newFile(java.lang.String, java.lang.String) */ + @Override public void newFile(String remoteFilePath, String rightRevision) { try { addFile(rightTree, right, new Path(null, remoteFilePath), rightRevision); @@ -204,6 +198,7 @@ public class RemoteCompareOperation extends RemoteOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#deletedFile(java.lang.String) */ + @Override public void deletedFile(String remoteFilePath, String leftRevision) { // The leftRevision may be null in which case the tag is used try { @@ -216,6 +211,7 @@ public class RemoteCompareOperation extends RemoteOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#directory(java.lang.String) */ + @Override public void directory(String remoteFolderPath) { try { getFolder(leftTree, left, new Path(null, remoteFolderPath), Path.EMPTY); @@ -331,6 +327,7 @@ public class RemoteCompareOperation extends RemoteOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected void execute(IProgressMonitor monitor) throws CVSException { boolean fetchContents = CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS); monitor.beginTask(getTaskName(), 50 + (fetchContents ? 100 : 0)); @@ -390,6 +387,7 @@ public class RemoteCompareOperation extends RemoteOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ + @Override protected String getTaskName() { return NLS.bind(CVSUIMessages.RemoteCompareOperation_0, (new Object[] {left.getName(), right.getName(), getRemoteResource().getRepositoryRelativePath()})); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java index 737cf1f20..2c6ee8083 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java @@ -23,11 +23,12 @@ import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; import org.eclipse.team.internal.ccvs.core.client.*; +import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; import org.eclipse.team.internal.ccvs.core.util.PrepareForReplaceVisitor; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.tags.TagSource; import org.eclipse.team.internal.ccvs.ui.tags.TagSourceWorkbenchAdapter; @@ -49,6 +50,7 @@ public class ReplaceOperation extends UpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ + @Override protected String getTaskName() { return CVSUIMessages.ReplaceOperation_taskName; } @@ -56,6 +58,7 @@ public class ReplaceOperation extends UpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected IStatus executeCommand( final Session session, final CVSTeamProvider provider, @@ -65,16 +68,13 @@ public class ReplaceOperation extends UpdateOperation { final IStatus[] status = new IStatus[] { Status.OK_STATUS }; try { - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - try { - status[0] = internalExecuteCommand(session, provider, resources, recurse, monitor); - } catch (InterruptedException e) { - throw new OperationCanceledException(); - } - } - - }, null, IWorkspace.AVOID_UPDATE, monitor); + ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> { + try { + status[0] = internalExecuteCommand(session, provider, resources, recurse, monitor1); + } catch (InterruptedException e) { + throw new OperationCanceledException(); + } + }, null, IWorkspace.AVOID_UPDATE, monitor); } catch (CoreException e) { throw CVSException.wrapException(e); } @@ -189,6 +189,7 @@ public class ReplaceOperation extends UpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation#getUpdateCommand() */ + @Override protected Update getUpdateCommand() { // Use a special replace command that doesn't set back the timestamps // of files in the passed set if it recreates them. @@ -198,6 +199,7 @@ public class ReplaceOperation extends UpdateOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider) */ + @Override protected String getTaskName(CVSTeamProvider provider) { return NLS.bind(CVSUIMessages.ReplaceOperation_0, new String[] { provider.getProject().getName() }); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java index c23d0bea4..ef21ca0be 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java @@ -25,7 +25,8 @@ import org.eclipse.team.internal.ccvs.core.client.Session; import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; /** @@ -49,6 +50,7 @@ public class ShareProjectOperation extends CVSOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) */ + @Override protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { try { monitor.beginTask(getTaskName(), 100); @@ -56,13 +58,11 @@ public class ShareProjectOperation extends CVSOperation { final ICVSRemoteFolder remote = createRemoteFolder(Policy.subMonitorFor(monitor, 50)); // Map the project to the module in a workspace runnable final TeamException[] exception = new TeamException[] {null}; - ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - try { - mapProjectToRemoteFolder(remote, monitor); - } catch (TeamException e) { - exception[0] = e; - } + ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> { + try { + mapProjectToRemoteFolder(remote, monitor1); + } catch (TeamException e) { + exception[0] = e; } }, ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(project), 0, Policy.subMonitorFor(monitor, 100)); if (exception[0] != null) @@ -169,6 +169,7 @@ public class ShareProjectOperation extends CVSOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ + @Override protected String getTaskName() { return NLS.bind(CVSUIMessages.ShareProjectOperation_0, new String[] { project.getName(), moduleName }); } @@ -183,6 +184,7 @@ public class ShareProjectOperation extends CVSOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getShell() */ + @Override public Shell getShell() { return shell; } @@ -197,9 +199,11 @@ public class ShareProjectOperation extends CVSOperation { monitor.beginTask(null, IProgressMonitor.UNKNOWN); ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); folder.accept(new ICVSResourceVisitor() { + @Override public void visitFile(ICVSFile file) throws CVSException { // nothing to do for files } + @Override public void visitFolder(ICVSFolder folder) throws CVSException { monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_2, new String[] { folder.getIResource().getFullPath().toString() } )); if (folder.isCVSFolder()) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java index 9d7808fc5..3a9518101 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java @@ -72,7 +72,8 @@ public class ShowAnnotationOperation extends CVSOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor) */ - protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { + @Override + protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { monitor.beginTask(null, 100); @@ -85,20 +86,18 @@ public class ShowAnnotationOperation extends CVSOperation { // Open the view and display it from the UI thread. final Display display= getPart().getSite().getShell().getDisplay(); - display.asyncExec(new Runnable() { - public void run() { - try { - //is there an open editor for the given input? If yes, use live annotate - final AbstractDecoratedTextEditor editor= getEditor(listener); - if (editor != null) { - editor.showRevisionInformation(information, "org.eclipse.quickdiff.providers.CVSReferenceProvider"); //$NON-NLS-1$ - final IWorkbenchPage page= getPart().getSite().getPage(); - showHistoryView(page, editor); - page.activate(editor); - } - } catch (PartInitException e) { - CVSException.wrapException(e); + display.asyncExec(() -> { + try { + // is there an open editor for the given input? If yes, use live annotate + final AbstractDecoratedTextEditor editor = getEditor(listener); + if (editor != null) { + editor.showRevisionInformation(information, "org.eclipse.quickdiff.providers.CVSReferenceProvider"); //$NON-NLS-1$ + final IWorkbenchPage page = getPart().getSite().getPage(); + showHistoryView(page, editor); + page.activate(editor); } + } catch (PartInitException e) { + CVSException.wrapException(e); } }); @@ -132,7 +131,8 @@ public class ShowAnnotationOperation extends CVSOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ - protected String getTaskName() { + @Override + protected String getTaskName() { return CVSUIMessages.ShowAnnotationOperation_taskName; } @@ -218,19 +218,18 @@ public class ShowAnnotationOperation extends CVSOperation { this.isResizable= isResizable; } + @Override public IInformationControl createInformationControl(Shell parent) { - IInformationPresenter presenter= new IInformationPresenter() { - public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) { - - // decorate header - StyleRange styleRange = new StyleRange(); - styleRange.start = 0; - styleRange.length = hoverInfo.indexOf('\n'); - styleRange.fontStyle = SWT.BOLD; - presentation.addStyleRange(styleRange); - - return hoverInfo; - } + IInformationPresenter presenter = (display, hoverInfo, presentation, maxWidth, maxHeight) -> { + + // decorate header + StyleRange styleRange = new StyleRange(); + styleRange.start = 0; + styleRange.length = hoverInfo.indexOf('\n'); + styleRange.fontStyle = SWT.BOLD; + presentation.addStyleRange(styleRange); + + return hoverInfo; }; if (isResizable) return new DefaultInformationControl(parent, (ToolBarManager) null, presenter); @@ -256,6 +255,7 @@ public class ShowAnnotationOperation extends CVSOperation { revision= new Revision() { private String fCommitter= null; + @Override public Object getHoverInfo() { return entry.getAuthor() + " " + entry.getRevision() + " " + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(entry.getDate()) //$NON-NLS-1$ //$NON-NLS-2$ @@ -268,18 +268,22 @@ public class ShowAnnotationOperation extends CVSOperation { return fCommitter; } + @Override public String getId() { return revisionString; } + @Override public Date getDate() { return entry.getDate(); } + @Override public RGB getColor() { return colors.getCommitterRGB(getCommitterId()); } + @Override public String getAuthor() { return getCommitterId(); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java index aefa2f5a6..9fac87af9 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AddToBranchAction.java @@ -15,7 +15,8 @@ package org.eclipse.team.internal.ccvs.ui.repo; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; @@ -32,46 +33,45 @@ import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; */ public class AddToBranchAction extends CVSAction { - IInputValidator validator = new IInputValidator() { - public String isValid(String newText) { - IStatus status = CVSTag.validateTagName(newText); - if (status.isOK()) return null; - return status.getMessage(); - } + IInputValidator validator = newText -> { + IStatus status = CVSTag.validateTagName(newText); + if (status.isOK()) + return null; + return status.getMessage(); }; /** * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction) */ + @Override protected void execute(IAction action) throws InvocationTargetException, InterruptedException { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - final ICVSRemoteFolder folder = getSelectedRootFolder(); - if (folder == null) return; - Shell shell = getShell(); - final CVSException[] exception = new CVSException[] { null }; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - InputDialog dialog = new InputDialog(getShell(), CVSUIMessages.AddToBranchAction_enterTag, CVSUIMessages.AddToBranchAction_enterTagLong, null, validator); // - if (dialog.open() == Window.OK) { - CVSTag tag = new CVSTag(dialog.getValue(), CVSTag.BRANCH); - try { - CVSUIPlugin.getPlugin().getRepositoryManager().addTags(folder, new CVSTag[] {tag}); - } catch (CVSException e) { - exception[0] = e; - } - } + run((IRunnableWithProgress) monitor -> { + final ICVSRemoteFolder folder = getSelectedRootFolder(); + if (folder == null) + return; + Shell shell = getShell(); + final CVSException[] exception = new CVSException[] { null }; + shell.getDisplay().syncExec(() -> { + InputDialog dialog = new InputDialog(getShell(), CVSUIMessages.AddToBranchAction_enterTag, + CVSUIMessages.AddToBranchAction_enterTagLong, null, validator); // + if (dialog.open() == Window.OK) { + CVSTag tag = new CVSTag(dialog.getValue(), CVSTag.BRANCH); + try { + CVSUIPlugin.getPlugin().getRepositoryManager().addTags(folder, new CVSTag[] { tag }); + } catch (CVSException e) { + exception[0] = e; } - }); - if (exception[0] != null) - throw new InvocationTargetException(exception[0]); - } + } + }); + if (exception[0] != null) + throw new InvocationTargetException(exception[0]); }, false, PROGRESS_BUSYCURSOR); } /** * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled() */ + @Override public boolean isEnabled() { return getSelectedRootFolder() != null; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java index 24896e0fb..50c3d52c8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java @@ -20,7 +20,6 @@ import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.Wizard; @@ -50,13 +49,12 @@ public class RefreshRemoteProjectWizard extends Wizard { final ICVSRemoteResource[][] rootFolders = new ICVSRemoteResource[1][0]; rootFolders[0] = null; try { - new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - rootFolders[0] = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, CVSTag.DEFAULT, monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } + new ProgressMonitorDialog(shell).run(true, true, monitor -> { + try { + rootFolders[0] = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, + CVSTag.DEFAULT, monitor); + } catch (CVSException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e) { @@ -89,6 +87,7 @@ public class RefreshRemoteProjectWizard extends Wizard { /** * @see org.eclipse.jface.wizard.IWizard#addPages() */ + @Override public void addPages() { setNeedsProgressMonitor(true); ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION); @@ -104,26 +103,25 @@ public class RefreshRemoteProjectWizard extends Wizard { /** * @see org.eclipse.jface.wizard.Wizard#performFinish() */ + @Override public boolean performFinish() { final ICVSRemoteResource[] selectedFolders = projectSelectionPage.getSelectedRemoteProject(); try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - // Run in the manager to avoid multiple repo view updates - manager.run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException,InterruptedException { - monitor.beginTask(null, 100); - ICVSRemoteResource[] failedFolders = internalRefresh(manager, selectedFolders, false /* recurse */, Policy.subMonitorFor(monitor, 80)); - if (failedFolders.length > 0) { - // Go deep any any failed folders. - if (promptForDeepRefresh(failedFolders)) - internalRefresh(manager, failedFolders, true /* recurse */, Policy.subMonitorFor(monitor, 20)); - } - monitor.done(); - } - }, monitor); - } + getContainer().run(true, true, monitor -> { + final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); + // Run in the manager to avoid multiple repo view updates + manager.run(monitor1 -> { + monitor1.beginTask(null, 100); + ICVSRemoteResource[] failedFolders = internalRefresh(manager, selectedFolders, false /* recurse */, + Policy.subMonitorFor(monitor1, 80)); + if (failedFolders.length > 0) { + // Go deep any any failed folders. + if (promptForDeepRefresh(failedFolders)) + internalRefresh(manager, failedFolders, true /* recurse */, + Policy.subMonitorFor(monitor1, 20)); + } + monitor1.done(); + }, monitor); }); return true; } catch (InvocationTargetException e) { @@ -157,22 +155,17 @@ public class RefreshRemoteProjectWizard extends Wizard { private boolean promptForDeepRefresh(final ICVSRemoteResource[] folders) { final boolean[] prompt = new boolean[] { false }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.RefreshRemoteProjectWizard_0, null, - getNoTagsMessage(folders), - MessageDialog.INFORMATION, - new String[] { - CVSUIMessages.RefreshRemoteProjectWizard_1, - CVSUIMessages.RefreshRemoteProjectWizard_2 - }, 1); - int code = dialog.open(); - if (code == 0) { - prompt[0] = true; - } + getShell().getDisplay().syncExec(() -> { + MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.RefreshRemoteProjectWizard_0, null, + getNoTagsMessage(folders), MessageDialog.INFORMATION, new String[] { + CVSUIMessages.RefreshRemoteProjectWizard_1, CVSUIMessages.RefreshRemoteProjectWizard_2 }, + 1); + int code = dialog.open(); + if (code == 0) { + prompt[0] = true; + } - } - }); + }); return prompt[0]; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java index e74e26683..e0cdec34b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java @@ -19,12 +19,10 @@ import java.util.Iterator; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Shell; @@ -78,22 +76,22 @@ public class RemoveRootAction extends SelectionListenerAction { return new ICVSRepositoryLocation[0]; } + @Override public void run() { final ICVSRepositoryLocation[] roots = getSelectedRemoteRoots(); if (roots.length == 0) return; final boolean[] proceed = new boolean[1]; - shell.getDisplay().syncExec(new Runnable(){ - public void run() { - String message; - if(roots.length == 1){ - message = NLS.bind(CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogMessageSingle, roots[0].getLocation(true)); - } else { - message = NLS.bind(CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogMessageMultiple, Integer.valueOf(roots.length)); - } - proceed[0] = MessageDialog.openQuestion(shell, - CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogTitle, - message); + shell.getDisplay().syncExec(() -> { + String message; + if (roots.length == 1) { + message = NLS.bind(CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogMessageSingle, + roots[0].getLocation(true)); + } else { + message = NLS.bind(CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogMessageMultiple, + Integer.valueOf(roots.length)); } + proceed[0] = MessageDialog.openQuestion(shell, CVSUIMessages.RemoveRootAction_RepositoryRemovalDialogTitle, + message); }); if(!proceed[0]){ return; @@ -117,34 +115,29 @@ public class RemoveRootAction extends SelectionListenerAction { // This will notify the RepositoryManager of the removal if (!shared.isEmpty()) { final String location = roots[i].getLocation(true); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - DetailsDialogWithProjects dialog = new DetailsDialogWithProjects( - shell, - CVSUIMessages.RemoteRootAction_Unable_to_Discard_Location_1, - NLS.bind(CVSUIMessages.RemoteRootAction_Projects_in_the_local_workspace_are_shared_with__2, new String[] { location }), - CVSUIMessages.RemoteRootAction_The_projects_that_are_shared_with_the_above_repository_are__4, - (IProject[]) shared.toArray(new IProject[shared.size()]), - false, - Dialog.DLG_IMG_ERROR); - dialog.open(); - } + shell.getDisplay().syncExec(() -> { + DetailsDialogWithProjects dialog = new DetailsDialogWithProjects(shell, + CVSUIMessages.RemoteRootAction_Unable_to_Discard_Location_1, + NLS.bind( + CVSUIMessages.RemoteRootAction_Projects_in_the_local_workspace_are_shared_with__2, + new String[] { location }), + CVSUIMessages.RemoteRootAction_The_projects_that_are_shared_with_the_above_repository_are__4, + (IProject[]) shared.toArray(new IProject[shared.size()]), false, Dialog.DLG_IMG_ERROR); + dialog.open(); }); } else { IProgressService manager = PlatformUI.getWorkbench().getProgressService(); try { - manager.busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - final ISchedulingRule rule = new RepositoryLocationSchedulingRule(root); - try { - Job.getJobManager().beginRule(rule, monitor); - view.getContentProvider().cancelJobs(root); - KnownRepositories.getInstance().disposeRepository(root); - } finally { - Job.getJobManager().endRule(rule); - } - + manager.busyCursorWhile(monitor -> { + final ISchedulingRule rule = new RepositoryLocationSchedulingRule(root); + try { + Job.getJobManager().beginRule(rule, monitor); + view.getContentProvider().cancelJobs(root); + KnownRepositories.getInstance().disposeRepository(root); + } finally { + Job.getJobManager().endRule(rule); } + }); } catch (InvocationTargetException e) { throw CVSException.wrapException(e); @@ -159,6 +152,7 @@ public class RemoveRootAction extends SelectionListenerAction { } } + @Override protected boolean updateSelection(IStructuredSelection selection) { this.selection = selection; ICVSRepositoryLocation[] roots = getSelectedRemoteRoots(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java index 86c8a498e..3d16bf0c0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java @@ -29,8 +29,6 @@ import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.window.Window; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Shell; @@ -379,30 +377,28 @@ public class RepositoryManager { loadCommentHistory(); loadCommentTemplates(); CVSProviderPlugin.getPlugin().addRepositoryListener(new ICVSListener() { + @Override public void repositoryAdded(ICVSRepositoryLocation root) { rootAdded(root); } + @Override public void repositoryRemoved(ICVSRepositoryLocation root) { rootRemoved(root); } }); IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - store.addPropertyChangeListener(new IPropertyChangeListener() { - - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY)) { - Object newValue = event.getNewValue(); - if (newValue instanceof String) { - try { - setMaxComments(Integer.parseInt((String) newValue)); - } catch (NumberFormatException e) { - // fail silently - } + store.addPropertyChangeListener(event -> { + if (event.getProperty().equals(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY)) { + Object newValue = event.getNewValue(); + if (newValue instanceof String) { + try { + setMaxComments(Integer.parseInt((String) newValue)); + } catch (NumberFormatException e) { + // fail silently } } } - }); setMaxComments(store.getInt(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY)); } @@ -651,11 +647,10 @@ public class RepositoryManager { public String promptForComment(final Shell shell, IResource[] resourcesToCommit, String proposedComment) { final int[] result = new int[1]; final ReleaseCommentDialog dialog = new ReleaseCommentDialog(shell, resourcesToCommit, proposedComment, IResource.DEPTH_INFINITE); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = dialog.open(); - if (result[0] != Window.OK) return; - } + shell.getDisplay().syncExec(() -> { + result[0] = dialog.open(); + if (result[0] != Window.OK) + return; }); if (result[0] != Window.OK) return null; return dialog.getComment(); @@ -675,15 +670,13 @@ public class RepositoryManager { final IResource[][] result = new IResource[1][0]; result[0] = null; final AddToVersionControlDialog dialog = new AddToVersionControlDialog(shell, unadded); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - int code = dialog.open(); - if (code == IDialogConstants.YES_ID) { - result[0] = dialog.getResourcesToAdd(); - } else if(code == IDialogConstants.NO_ID) { - // allow the commit to continue. - result[0] = new IResource[0]; - } + shell.getDisplay().syncExec(() -> { + int code = dialog.open(); + if (code == IDialogConstants.YES_ID) { + result[0] = dialog.getResourcesToAdd(); + } else if (code == IDialogConstants.NO_ID) { + // allow the commit to continue. + result[0] = new IResource[0]; } }); return result[0]; @@ -856,20 +849,18 @@ public class RepositoryManager { final CVSRepositoryLocation newLocation) { try { - run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - RepositoryRoot root = getRepositoryRootFor(oldLocation); - // Disposing of the old location will result in the deletion of the - // cached root through a listener callback - KnownRepositories.getInstance().disposeRepository(oldLocation); - - // Get the new location from the CVS plugin to ensure we use the - // instance that will be returned by future calls to getRepository() - boolean isNew = !KnownRepositories.getInstance().isKnownRepository(newLocation.getLocation()); - root.setRepositoryLocation( - KnownRepositories.getInstance().addRepository(newLocation, isNew /* broadcast */)); - add(root); - } + run(monitor -> { + RepositoryRoot root = getRepositoryRootFor(oldLocation); + // Disposing of the old location will result in the deletion of the + // cached root through a listener callback + KnownRepositories.getInstance().disposeRepository(oldLocation); + + // Get the new location from the CVS plugin to ensure we use the + // instance that will be returned by future calls to getRepository() + boolean isNew = !KnownRepositories.getInstance().isKnownRepository(newLocation.getLocation()); + root.setRepositoryLocation( + KnownRepositories.getInstance().addRepository(newLocation, isNew /* broadcast */)); + add(root); }, Policy.monitorFor(null)); } catch (InvocationTargetException e) { CVSException.wrapException(e); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java index f12dd50ef..c24bed962 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java @@ -13,11 +13,9 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.subscriber; -import com.ibm.icu.text.DateFormat; import java.util.Date; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.jobs.Job; @@ -31,14 +29,18 @@ import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.resources.RemoteResource; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; import org.eclipse.team.internal.ccvs.core.util.Util; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache; -import org.eclipse.team.internal.core.subscribers.*; +import org.eclipse.team.internal.core.subscribers.ChangeSet; +import org.eclipse.team.internal.core.subscribers.CheckedInChangeSet; import org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangeSetCollector; import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; +import com.ibm.icu.text.DateFormat; + /** * Collector that fetches the log for incoming CVS change sets */ @@ -72,6 +74,7 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme this.kind = kind; } + @Override protected int calculateKind() throws TeamException { return kind; } @@ -87,21 +90,24 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getAuthor() */ - public String getAuthor() { + @Override + public String getAuthor() { return ""; //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getDate() */ - public Date getDate() { + @Override + public Date getDate() { return date; } /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.ChangeSet#getComment() */ - public String getComment() { + @Override + public String getComment() { return ""; //$NON-NLS-1$ } @@ -126,21 +132,24 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getAuthor() */ - public String getAuthor() { + @Override + public String getAuthor() { return entry.getAuthor(); } /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.CheckedInChangeSet#getDate() */ - public Date getDate() { + @Override + public Date getDate() { return entry.getDate(); } /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.ChangeSet#getComment() */ - public String getComment() { + @Override + public String getComment() { return entry.getComment(); } } @@ -167,7 +176,8 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme configuration.setProperty(LOG_ENTRY_HANDLER, logEntryHandler); // Use an action group to get notified when the configuration is disposed configuration.addActionContribution(new SynchronizePageActionGroup() { - public void dispose() { + @Override + public void dispose() { super.dispose(); LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)configuration.getProperty(LOG_ENTRY_HANDLER); if (handler != null) { @@ -184,7 +194,8 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /* (non-Javadoc) * @see org.eclipse.team.core.subscribers.SyncInfoSetChangeSetCollector#add(org.eclipse.team.core.synchronize.SyncInfo[]) */ - protected void add(SyncInfo[] infos) { + @Override + protected void add(SyncInfo[] infos) { LogEntryCacheUpdateHandler handler = getLogEntryHandler(); if (handler != null) try { @@ -197,7 +208,8 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector#reset(org.eclipse.team.core.synchronize.SyncInfoSet) */ - public void reset(SyncInfoSet seedSet) { + @Override + public void reset(SyncInfoSet seedSet) { // Notify that handler to stop any fetches in progress LogEntryCacheUpdateHandler handler = getLogEntryHandler(); if (handler != null) { @@ -209,6 +221,7 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.views.HierarchicalModelProvider#dispose() */ + @Override public void dispose() { // No longer listen for log entry changes // (The handler is disposed with the page) @@ -225,11 +238,7 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme * to add each resource to an appropriate commit set. */ private void handleRemoteChanges(final SyncInfo[] infos, final LogEntryCache logEntries, final IProgressMonitor monitor) { - performUpdate(new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) { - addLogEntries(infos, logEntries, monitor); - } - }, true /* preserver expansion */, monitor); + performUpdate(monitor1 -> addLogEntries(infos, logEntries, monitor1), true /* preserver expansion */, monitor); } /* @@ -419,7 +428,8 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector#waitUntilDone(org.eclipse.core.runtime.IProgressMonitor) */ - public void waitUntilDone(IProgressMonitor monitor) { + @Override + public void waitUntilDone(IProgressMonitor monitor) { super.waitUntilDone(monitor); monitor.worked(1); // wait for the event handler to process changes. @@ -440,7 +450,8 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.LogEntryCacheUpdateHandler.ILogsFetchedListener#logEntriesFetched(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) */ - public void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor) { + @Override + public void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor) { if (disposed) return; // Hold on to the cache so we can use it while commit sets are visible this.logEntryCache = logEntryCache; @@ -453,6 +464,7 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme return null; } + @Override protected void initializeSets() { // Nothing to do } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java index ed466037e..d3c0aa738 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberOperation.java @@ -14,24 +14,13 @@ package org.eclipse.team.internal.ccvs.ui.subscriber; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.*; import org.eclipse.jface.window.Window; import org.eclipse.osgi.util.NLS; -import org.eclipse.team.internal.ccvs.core.CVSStatus; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.synchronize.SyncInfoSet; @@ -40,7 +29,8 @@ import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.PruneFolderVisitor; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; @@ -55,6 +45,7 @@ public abstract class CVSSubscriberOperation extends SynchronizeModelOperation { /* (non-Javadoc) * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // Divide the sync info by project final Map projectSyncInfos = getProjectSyncInfoSetMap(); @@ -80,13 +71,12 @@ public abstract class CVSSubscriberOperation extends SynchronizeModelOperation { // and cache commits to disk are batched EclipseSynchronizer.getInstance().run( project, - new ICVSRunnable() { - public void run(IProgressMonitor monitor) throws CVSException { + monitor1 -> { try { - CVSSubscriberOperation.this.runWithProjectRule(project, (SyncInfoSet)projectSyncInfos.get(project), monitor); + CVSSubscriberOperation.this.runWithProjectRule(project, + (SyncInfoSet) projectSyncInfos.get(project), monitor1); } catch (TeamException e) { throw CVSException.wrapException(e); - } } }, Policy.subMonitorFor(monitor, 100)); } catch (TeamException e) { @@ -210,6 +200,7 @@ public abstract class CVSSubscriberOperation extends SynchronizeModelOperation { return null; } + @Override protected boolean canRunAsJob() { return true; } @@ -254,11 +245,9 @@ public abstract class CVSSubscriberOperation extends SynchronizeModelOperation { */ protected boolean promptForOverwrite(final SyncInfoSet syncSet) { final int[] result = new int[] {Window.CANCEL}; - TeamUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - UpdateDialog dialog = new UpdateDialog(getShell(), syncSet); - result[0] = dialog.open(); - } + TeamUIPlugin.getStandardDisplay().syncExec(() -> { + UpdateDialog dialog = new UpdateDialog(getShell(), syncSet); + result[0] = dialog.open(); }); return (result[0] == UpdateDialog.YES); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java index 1f115f650..3d8af0505 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java @@ -62,22 +62,20 @@ public class RefreshDirtyStateOperation extends CVSSubscriberOperation { private void performCleanTimestamps(IProject project, final SyncInfo[] infos, IProgressMonitor monitor) throws CVSException { ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); - folder.run(new ICVSRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, infos.length * 100); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IResource resource = info.getLocal(); - if (resource.getType() == IResource.FILE) { - if (comparator.compareContents((IFile)resource, info.getBase(), Policy.subMonitorFor(monitor, 100))) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - cvsFile.checkedIn(null, false /* not a commit */); - } + folder.run(monitor1 -> { + monitor1.beginTask(null, infos.length * 100); + for (int i = 0; i < infos.length; i++) { + SyncInfo info = infos[i]; + IResource resource = info.getLocal(); + if (resource.getType() == IResource.FILE) { + if (comparator.compareContents((IFile) resource, info.getBase(), + Policy.subMonitorFor(monitor1, 100))) { + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) resource); + cvsFile.checkedIn(null, false /* not a commit */); } } - monitor.done(); } + monitor1.done(); }, Policy.subMonitorFor(monitor, 100)); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java index bd7a06312..cbd3a35d7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java @@ -36,7 +36,8 @@ import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.operations.*; import org.eclipse.team.internal.ui.TeamUIPlugin; @@ -64,6 +65,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.ui.TeamOperation#shouldRun() */ + @Override public boolean shouldRun() { return promptIfNeeded(); } @@ -76,6 +78,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { * @param monitor a progress monitor * @throws InvocationTargetException */ + @Override protected void run(final Map projectSyncInfos, final IProject project, IProgressMonitor monitor) throws InvocationTargetException { try { @@ -93,16 +96,11 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { // Pass the scheduling rule to the synchronizer so that sync change // events and cache commits to disk are batched EclipseSynchronizer.getInstance().run(getUpdateRule(manager), - new ICVSRunnable() { - public void run(IProgressMonitor monitor) - throws CVSException { - try { - runWithProjectRule(project, - (SyncInfoSet) projectSyncInfos - .get(project), monitor); - } catch (TeamException e) { - throw CVSException.wrapException(e); - } + monitor1 -> { + try { + runWithProjectRule(project, (SyncInfoSet) projectSyncInfos.get(project), monitor1); + } catch (TeamException e) { + throw CVSException.wrapException(e); } }, Policy.subMonitorFor(monitor, 100)); } catch (TeamException e) { @@ -132,6 +130,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { skipped.clear(); super.run(monitor); @@ -145,6 +144,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#run(org.eclipse.team.ui.sync.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void runWithProjectRule(IProject project, SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { try { monitor.beginTask(null, 100); @@ -158,6 +158,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { // Remove all failed conflicts from the original sync set syncSet.rejectNodes(new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { return skipped.getSyncInfo(info.getLocal()) != null; } @@ -321,6 +322,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { new AndSyncInfoFilter(new FastSyncInfoFilter[] { FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.ADDITION), new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { return info.getLocal().getType() == IResource.FILE; } @@ -331,6 +333,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { new AndSyncInfoFilter(new FastSyncInfoFilter[] { FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE), new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { if (info.getLocal().getType() == IResource.FILE) { try { @@ -350,6 +353,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { new AndSyncInfoFilter(new FastSyncInfoFilter[] { FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE), new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { IResourceVariant remote = info.getRemote(); IResourceVariant base = info.getBase(); @@ -368,6 +372,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { new AndSyncInfoFilter(new FastSyncInfoFilter[] { FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE), new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { IResource local = info.getLocal(); if (local.getType() == IResource.FILE) { @@ -398,13 +403,10 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { * Note: This method is designed to be overridden by test cases. */ protected void warnAboutFailedResources(final SyncInfoSet syncSet) { - TeamUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog.openInformation(getShell(), - CVSUIMessages.SafeUpdateAction_warnFilesWithConflictsTitle, - CVSUIMessages.SafeUpdateAction_warnFilesWithConflictsDescription); - } - }); + TeamUIPlugin.getStandardDisplay() + .syncExec(() -> MessageDialog.openInformation(getShell(), + CVSUIMessages.SafeUpdateAction_warnFilesWithConflictsTitle, + CVSUIMessages.SafeUpdateAction_warnFilesWithConflictsDescription)); } /** @@ -453,6 +455,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { } } + @Override protected String getErrorTitle() { return CVSUIMessages.UpdateAction_update; } @@ -460,6 +463,7 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#getJobName(org.eclipse.team.ui.sync.SyncInfoSet) */ + @Override protected String getJobName() { SyncInfoSet syncSet = getSyncInfoSet(); return NLS.bind(CVSUIMessages.UpdateAction_jobName, new String[] { Integer.valueOf(syncSet.size()).toString() }); @@ -477,12 +481,14 @@ public abstract class SafeUpdateOperation extends CVSSubscriberOperation { final SyncInfoSet set = getSyncInfoSet(); final boolean[] result = new boolean[] {true}; if(getPromptBeforeUpdate()) { - TeamUIPlugin.getStandardDisplay().syncExec(new Runnable() { - public void run() { - String sizeString = Integer.toString(set.size()); - String message = set.size() > 1 ? NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateSeveral, new String[] { sizeString }) : NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateOne, new String[] { sizeString }); // - result[0] = MessageDialog.openQuestion(getShell(), NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateTitle, new String[] { sizeString }), message); - } + TeamUIPlugin.getStandardDisplay().syncExec(() -> { + String sizeString = Integer.toString(set.size()); + String message = set.size() > 1 + ? NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateSeveral, new String[] { sizeString }) + : NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateOne, new String[] { sizeString }); // + result[0] = MessageDialog.openQuestion(getShell(), + NLS.bind(CVSUIMessages.UpdateAction_promptForUpdateTitle, new String[] { sizeString }), + message); }); } return result[0]; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java index 570d6ce51..b178d6ae1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java @@ -33,7 +33,8 @@ import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.Command; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.mappings.ChangeSetComparator; import org.eclipse.team.internal.ccvs.ui.operations.*; @@ -56,6 +57,7 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#getErrorTitle() */ + @Override protected String getErrorTitle() { return CVSUIMessages.CommitAction_commitFailed; } @@ -63,6 +65,7 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ui.actions.TeamOperation#getJobName() */ + @Override protected String getJobName() { SyncInfoSet syncSet = getSyncInfoSet(); return NLS.bind(CVSUIMessages.CommitAction_jobName, new String[] { Integer.valueOf(syncSet.size()).toString() }); @@ -71,6 +74,7 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.ui.TeamOperation#shouldRun() */ + @Override public boolean shouldRun() { SyncInfoSet set = getSyncInfoSet(); return !set.isEmpty(); @@ -79,6 +83,7 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { /* (non-Javadoc) * @see org.eclipse.team.internal.ui.actions.SubscriberOperation#getSyncInfoSet() */ + @Override protected SyncInfoSet getSyncInfoSet() { if (syncSet == null) { syncSet = super.getSyncInfoSet(); @@ -128,6 +133,7 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { * (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void runWithProjectRule(IProject project, SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException { final SyncInfo[] changed = syncSet.getSyncInfos(); @@ -217,9 +223,11 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { try { CommitOperation commitOperation = new CommitOperation(getPart(), RepositoryProviderOperation.asResourceMappers(commits), new Command.LocalOption[0], comment) { + @Override protected ResourceMappingContext getResourceMappingContext() { return new SingleProjectSubscriberContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), false, project); } + @Override protected SynchronizationScopeManager createScopeManager(boolean consultModels) { return new SingleProjectScopeManager(getJobName(), getSelectedMappings(), getResourceMappingContext(), consultModels, project); } @@ -236,9 +244,11 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { private void add(final IProject project, IResource[] additions, IProgressMonitor monitor) throws TeamException { try { new AddOperation(getPart(), RepositoryProviderOperation.asResourceMappers(additions)) { + @Override protected ResourceMappingContext getResourceMappingContext() { return new SingleProjectSubscriberContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), false, project); } + @Override protected SynchronizationScopeManager createScopeManager(boolean consultModels) { return new SingleProjectScopeManager(getJobName(), getSelectedMappings(), getResourceMappingContext(), consultModels, project); } @@ -266,11 +276,7 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { }; Shell shell = getShell(); final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, tips, 0); - shell.getDisplay().syncExec(new Runnable() { - public void run() { - dialog.open(); - } - }); + shell.getDisplay().syncExec(() -> dialog.open()); return dialog.getReturnCode(); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java index 0b016e3ec..e2960f94a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java @@ -17,7 +17,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.*; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.*; @@ -43,14 +42,16 @@ public class MultiFolderTagSource extends SingleFolderTagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.SingleFolderTagSource#getShortDescription() */ - public String getShortDescription() { + @Override + public String getShortDescription() { return NLS.bind(CVSUIMessages.MultiFolderTagSource_0, new String[] { Integer.toString(folders.length) }); } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getTags(int) */ - public CVSTag[] getTags(int type) { + @Override + public CVSTag[] getTags(int type) { if (type == CVSTag.HEAD || type == BASE) { return super.getTags(type); } @@ -64,7 +65,8 @@ public class MultiFolderTagSource extends SingleFolderTagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.tags.SingleFolderTagSource#refresh(boolean, org.eclipse.core.runtime.IProgressMonitor) */ - public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { + @Override + public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { monitor.beginTask("", folders.length); //$NON-NLS-1$ Set result= new HashSet(); for (int i= 0; i < folders.length; i++) { @@ -80,7 +82,8 @@ public class MultiFolderTagSource extends SingleFolderTagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.tags.SingleFolderTagSource#getCVSResources() */ - public ICVSResource[] getCVSResources() { + @Override + public ICVSResource[] getCVSResources() { return folders; } @@ -91,26 +94,24 @@ public class MultiFolderTagSource extends SingleFolderTagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#commit(org.eclipse.team.internal.ccvs.core.CVSTag[], boolean, org.eclipse.core.runtime.IProgressMonitor) */ - public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { + @Override + public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { try { final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - manager.run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSFolder[] folders = getFolders(); - for (int i = 0; i < folders.length; i++) { - if (replace) { - CVSTag[] oldTags = manager - .getKnownTags(folders[i]); - manager.removeTags(folders[i], oldTags); - } - manager.addTags(folders[i], tags); + manager.run(monitor1 -> { + try { + ICVSFolder[] folders = getFolders(); + for (int i = 0; i < folders.length; i++) { + if (replace) { + CVSTag[] oldTags = manager.getKnownTags(folders[i]); + manager.removeTags(folders[i], oldTags); } - } catch (CVSException e) { - throw new InvocationTargetException(e); + manager.addTags(folders[i], tags); } + } catch (CVSException e) { + throw new InvocationTargetException(e); } - }, monitor); + }, monitor); } catch (InvocationTargetException e) { throw CVSException.wrapException(e); } catch (InterruptedException e) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java index a653bc38f..ea8c2af4e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java @@ -17,7 +17,6 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; @@ -44,7 +43,8 @@ public class SingleFolderTagSource extends TagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getTags(int) */ - public CVSTag[] getTags(int type) { + @Override + public CVSTag[] getTags(int type) { if (type == CVSTag.HEAD || type == BASE) { return super.getTags(type); } @@ -62,7 +62,8 @@ public class SingleFolderTagSource extends TagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#refresh(org.eclipse.core.runtime.IProgressMonitor) */ - public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { + @Override + public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(getFolder(), bestEffort /* recurse */, true /* notify */, monitor); fireChange(); return tags; @@ -71,7 +72,8 @@ public class SingleFolderTagSource extends TagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getLocation() */ - public ICVSRepositoryLocation getLocation() { + @Override + public ICVSRepositoryLocation getLocation() { RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); ICVSRepositoryLocation location = mgr.getRepositoryLocationFor(getFolder()); return location; @@ -80,30 +82,30 @@ public class SingleFolderTagSource extends TagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#getShortDescription() */ - public String getShortDescription() { + @Override + public String getShortDescription() { return getFolder().getName(); } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.merge.TagSource#commit(org.eclipse.team.internal.ccvs.core.CVSTag[], boolean, org.eclipse.core.runtime.IProgressMonitor) */ - public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { + @Override + public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { try { final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); - manager.run(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSFolder folder = getFolder(); - if (replace) { - CVSTag[] oldTags = manager.getKnownTags(folder); - manager.removeTags(folder, oldTags); - } - manager.addTags(folder, tags); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - } - }, monitor); + manager.run(monitor1 -> { + try { + ICVSFolder folder = getFolder(); + if (replace) { + CVSTag[] oldTags = manager.getKnownTags(folder); + manager.removeTags(folder, oldTags); + } + manager.addTags(folder, tags); + } catch (CVSException e) { + throw new InvocationTargetException(e); + } + }, monitor); } catch (InvocationTargetException e) { throw CVSException.wrapException(e); } catch (InterruptedException e) { @@ -115,20 +117,19 @@ public class SingleFolderTagSource extends TagSource { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.tags.TagSource#getCVSResources() */ - public ICVSResource[] getCVSResources() { + @Override + public ICVSResource[] getCVSResources() { final ICVSResource[][] resources = new ICVSResource[][] { null }; try { - getRunnableContext().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - resources[0] = folder.fetchChildren(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); + getRunnableContext().run(true, true, monitor -> { + try { + resources[0] = folder.fetchChildren(monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + }); return resources[0]; } catch (InvocationTargetException e) { CVSUIPlugin.log(CVSException.wrapException(e)); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java index c1707bde6..43033cc64 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java @@ -16,11 +16,9 @@ package org.eclipse.team.internal.ccvs.ui.tags; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.*; @@ -55,7 +53,8 @@ public class TagRefreshButtonArea extends DialogArea { /* (non-Javadoc) * @see org.eclipse.team.internal.ui.dialogs.DialogArea#createArea(org.eclipse.swt.widgets.Composite) */ - public void createArea(Composite parent) { + @Override + public void createArea(Composite parent) { final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent); @@ -87,18 +86,12 @@ public class TagRefreshButtonArea extends DialogArea { refreshButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.END, SWT.CENTER, false, false)); configureTagsButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.END, SWT.CENTER, false, false)); - refreshButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - refresh(false); - } - }); + refreshButton.addListener(SWT.Selection, event -> refresh(false)); - configureTagsButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - TagConfigurationDialog d = new TagConfigurationDialog(shell, tagSource); - d.open(); - } - }); + configureTagsButton.addListener(SWT.Selection, event -> { + TagConfigurationDialog d = new TagConfigurationDialog(shell, tagSource); + d.open(); + }); PlatformUI.getWorkbench().getHelpSystem().setHelp(refreshButton, IHelpContextIds.TAG_CONFIGURATION_REFRESHACTION); PlatformUI.getWorkbench().getHelpSystem().setHelp(configureTagsButton, IHelpContextIds.TAG_CONFIGURATION_OVERVIEW); @@ -108,33 +101,28 @@ public class TagRefreshButtonArea extends DialogArea { public void refresh(final boolean background) { try { - getRunnableContext().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - setBusy(true); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if (!fMessageLabel.isDisposed()) - fMessageLabel.setText(CVSUIMessages.TagRefreshButtonArea_6); - } - }); - monitor.beginTask(CVSUIMessages.TagRefreshButtonArea_5, 100); - final CVSTag[] tags = tagSource.refresh(false, Policy.subMonitorFor(monitor, 70)); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if (!fMessageLabel.isDisposed()) - fMessageLabel.setText(background && tags.length == 0 ? CVSUIMessages.TagRefreshButtonArea_7 : ""); //$NON-NLS-1$ - } - }); - if (!background && tags.length == 0 && promptForBestEffort()) { - tagSource.refresh(true, Policy.subMonitorFor(monitor, 30)); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - setBusy(false); - monitor.done(); + getRunnableContext().run(true, true, monitor -> { + try { + setBusy(true); + Display.getDefault().asyncExec(() -> { + if (!fMessageLabel.isDisposed()) + fMessageLabel.setText(CVSUIMessages.TagRefreshButtonArea_6); + }); + monitor.beginTask(CVSUIMessages.TagRefreshButtonArea_5, 100); + final CVSTag[] tags = tagSource.refresh(false, Policy.subMonitorFor(monitor, 70)); + Display.getDefault().asyncExec(() -> { + if (!fMessageLabel.isDisposed()) + fMessageLabel.setText( + background && tags.length == 0 ? CVSUIMessages.TagRefreshButtonArea_7 : ""); //$NON-NLS-1$ + }); + if (!background && tags.length == 0 && promptForBestEffort()) { + tagSource.refresh(true, Policy.subMonitorFor(monitor, 30)); } + } catch (TeamException e) { + throw new InvocationTargetException(e); + } finally { + setBusy(false); + monitor.done(); } }); } catch (InterruptedException e) { @@ -146,36 +134,29 @@ public class TagRefreshButtonArea extends DialogArea { private void setBusy(final boolean busy) { if (shell != null && !shell.isDisposed()) - shell.getDisplay().asyncExec(new Runnable() { - public void run() { - if (!refreshButton.isDisposed()) - refreshButton.setEnabled(!busy); - } + shell.getDisplay().asyncExec(() -> { + if (!refreshButton.isDisposed()) + refreshButton.setEnabled(!busy); }); } private boolean promptForBestEffort() { final boolean[] prompt = new boolean[] { false }; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - MessageDialog dialog = new MessageDialog(shell, CVSUIMessages.TagRefreshButtonArea_0, null, - getNoTagsFoundMessage(), - MessageDialog.INFORMATION, - new String[] { - CVSUIMessages.TagRefreshButtonArea_1, - CVSUIMessages.TagRefreshButtonArea_2, - CVSUIMessages.TagRefreshButtonArea_3 - }, 1); - int code = dialog.open(); - if (code == 0) { - prompt[0] = true; - } else if (code == 1) { - TagConfigurationDialog d = new TagConfigurationDialog(shell, tagSource); - d.open(); - } + shell.getDisplay().syncExec(() -> { + MessageDialog dialog = new MessageDialog(shell, CVSUIMessages.TagRefreshButtonArea_0, null, + getNoTagsFoundMessage(), MessageDialog.INFORMATION, + new String[] { CVSUIMessages.TagRefreshButtonArea_1, CVSUIMessages.TagRefreshButtonArea_2, + CVSUIMessages.TagRefreshButtonArea_3 }, + 1); + int code = dialog.open(); + if (code == 0) { + prompt[0] = true; + } else if (code == 1) { + TagConfigurationDialog d = new TagConfigurationDialog(shell, tagSource); + d.open(); + } - } - }); + }); return prompt[0]; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java index 5228a7dd4..c3eb200b4 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java @@ -14,17 +14,11 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import org.eclipse.core.resources.*; import org.eclipse.core.resources.mapping.ResourceTraversal; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.IFileContentManager; import org.eclipse.team.core.Team; @@ -43,14 +37,11 @@ public class AddWizard extends ResizableWizard { public static void run(Shell shell, final AddOperation op) throws InvocationTargetException, InterruptedException { // Prompt if there are files of unknown type being added - PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - try { - op.buildScope(monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } + PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> { + try { + op.buildScope(monitor); + } catch (CVSException e) { + throw new InvocationTargetException(e); } }); @@ -65,46 +56,40 @@ public class AddWizard extends ResizableWizard { private static IFile[] getUnaddedWithUnknownFileType(final ResourceTraversal[] traversals) throws InvocationTargetException, InterruptedException { final List unadded = new ArrayList(); - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - final IFileContentManager manager= Team.getFileContentManager(); - for (int i = 0; i < traversals.length; i++) { - ResourceTraversal traversal = traversals[i]; - IResource[] resources = traversal.getResources(); - for (int j = 0; j < resources.length; j++) { - final IResource resource = resources[j]; - try { - resource.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - if (resource.getType() == IResource.FILE) { - ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - if (!file.isManaged()) { - if (!file.isIgnored() || file.equals(resource)) { - final String extension= ((IFile)resource).getFileExtension(); - if (manager.getType((IFile)resource) == Team.UNKNOWN) { - if (extension != null && !manager.isKnownExtension(extension)) { - unadded.add(resource); - } else { - final String name= file.getName(); - if (extension == null && name != null && !manager.isKnownFilename(name)) - unadded.add(resource); - } - } - } - } - } - return true; - } - }, traversal.getDepth(), false); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - } + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + final IFileContentManager manager = Team.getFileContentManager(); + for (int i = 0; i < traversals.length; i++) { + ResourceTraversal traversal = traversals[i]; + IResource[] resources = traversal.getResources(); + for (int j = 0; j < resources.length; j++) { + final IResource resource = resources[j]; + try { + resource.accept((IResourceVisitor) resource1 -> { + if (resource1.getType() == IResource.FILE) { + ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile) resource1); + if (!file.isManaged()) { + if (!file.isIgnored() || file.equals(resource1)) { + final String extension = ((IFile) resource1).getFileExtension(); + if (manager.getType((IFile) resource1) == Team.UNKNOWN) { + if (extension != null && !manager.isKnownExtension(extension)) { + unadded.add(resource1); + } else { + final String name = file.getName(); + if (extension == null && name != null && !manager.isKnownFilename(name)) + unadded.add(resource1); + } + } + } + } + } + return true; + }, traversal.getDepth(), false); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + } } - - }); + }); return (IFile[]) unadded.toArray(new IFile[unadded.size()]); } @@ -116,7 +101,8 @@ public class AddWizard extends ResizableWizard { setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); } - public void addPages() { + @Override + public void addPages() { final Collection names= new HashSet(); final Collection extensions= new HashSet(); @@ -148,7 +134,8 @@ public class AddWizard extends ResizableWizard { } } - public boolean performFinish() { + @Override + public boolean performFinish() { final Map extensionsToSave= new HashMap(); final Map extensionsNotToSave= new HashMap(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java index 7440a7fcb..14bb3b1a0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AlternativeLocationWizard.java @@ -16,10 +16,8 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.lang.reflect.InvocationTargetException; import java.util.Properties; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; @@ -32,6 +30,7 @@ public class AlternativeLocationWizard extends NewLocationWizard { private ICVSRepositoryLocation location; + @Override public boolean performFinish() { final ICVSRepositoryLocation[] location = new ICVSRepositoryLocation[] { null }; boolean useLocation = true; @@ -43,13 +42,11 @@ public class AlternativeLocationWizard extends NewLocationWizard { if (mainPage.getValidate()) { try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - location[0].validateConnection(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } + getContainer().run(true, true, monitor -> { + try { + location[0].validateConnection(monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); } catch (InterruptedException e) { @@ -104,10 +101,12 @@ public class AlternativeLocationWizard extends NewLocationWizard { /** * Creates the wizard pages */ + @Override public void addPages() { super.addPages(); } + @Override protected ConfigurationWizardMainPage createMainPage() { return new AlternativeConfigurationWizardMainPage("repositoryPage1", CVSUIMessages.AlternativeLocationWizard_heading, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); //$NON-NLS-1$ } @@ -142,6 +141,7 @@ public class AlternativeLocationWizard extends NewLocationWizard { * * @see org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage#validateFields() */ + @Override protected void validateFields() { super.validateFields(); if (!isPageComplete() diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java index c9ede92a8..cc3be767d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutWizard.java @@ -16,8 +16,6 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.IWizardPage; @@ -51,6 +49,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { /* (non-Javadoc) * @see org.eclipse.jface.wizard.Wizard#addPages() */ + @Override public void addPages() { setNeedsProgressMonitor(true); @@ -77,6 +76,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { // Dummy page to allow lazy creation of CheckoutAsWizard dummyPage = new CVSWizardPage("dummyPage") { //$NON-NLS-1$ + @Override public void createControl(Composite parent) { Composite composite = createComposite(parent, 1, false); setControl(composite); @@ -92,6 +92,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { /* (non-Javadoc) * @see org.eclipse.jface.wizard.Wizard#canFinish() */ + @Override public boolean canFinish() { return (wizard == null && getSelectedModules().length > 0) || (wizard != null && wizard.canFinish()); @@ -100,6 +101,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizard#performFinish() */ + @Override public boolean performFinish() { if (wizard != null) { // The finish of the child wizard will get called directly. @@ -133,6 +135,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { /* (non-Javadoc) * @see org.eclipse.jface.wizard.Wizard#performCancel() */ + @Override public boolean performCancel() { if (location != null && isNewLocation) { KnownRepositories.getInstance().disposeRepository(location); @@ -144,6 +147,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) */ + @Override public IWizardPage getNextPage(IWizardPage page) { // Assume the page is about to be shown when this method is // invoked @@ -153,6 +157,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.wizards.ICVSWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage, boolean) */ + @Override public IWizardPage getNextPage(IWizardPage page, boolean aboutToShow) { if (page == locationPage) { if (locationPage.getLocation() == null) { @@ -204,13 +209,12 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { final ICVSRemoteFolder[] folderResult = new ICVSRemoteFolder [1]; final boolean[] booleanResult = new boolean[] { true }; - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - ProjectMetaFileOperation op = new ProjectMetaFileOperation(getPart(), new ICVSRemoteFolder[] {folders[0]}, withName); - op.run(monitor); - folderResult[0] = op.getUpdatedFolders()[0]; - booleanResult[0] = op.metaFileExists(); - } + getContainer().run(true, true, monitor -> { + ProjectMetaFileOperation op = new ProjectMetaFileOperation(getPart(), + new ICVSRemoteFolder[] { folders[0] }, withName); + op.run(monitor); + folderResult[0] = op.getUpdatedFolders()[0]; + booleanResult[0] = op.metaFileExists(); }); hasMetafile = booleanResult[0]; if (withName && hasMetafile) @@ -261,13 +265,11 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { // Otherwise, get the location from the create location page final ICVSRepositoryLocation[] locations = new ICVSRepositoryLocation[] { null }; final CVSException[] exception = new CVSException[] { null }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - try { - locations[0] = createLocationPage.getLocation(); - } catch (CVSException e) { - exception[0] = e; - } + getShell().getDisplay().syncExec(() -> { + try { + locations[0] = createLocationPage.getLocation(); + } catch (CVSException e) { + exception[0] = e; } }); if (exception[0] != null) { @@ -296,6 +298,7 @@ public class CheckoutWizard extends Wizard implements ICVSWizard, INewWizard { /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ + @Override public void init(IWorkbench workbench, IStructuredSelection selection) { } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java index 72f9a9dd9..d0747130f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java @@ -26,7 +26,6 @@ import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.*; import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardDialog; @@ -386,16 +385,13 @@ public class CommitWizard extends ResizableWizard { public static void run(IWorkbenchPart part, Shell shell, final ResourceTraversal[] traversals) throws CVSException { try { final IResource [][] resources = new IResource[][] { null }; - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - resources[0] = getDeepResourcesToCommit(traversals, monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } - }); + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { + try { + resources[0] = getDeepResourcesToCommit(traversals, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + }); run(part, shell, resources[0]); } catch (OperationCanceledException e) { // Ignore diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java index b99de0bc7..334a6c4c7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java @@ -92,15 +92,13 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang if (resources.length > 0) fCommentArea.setProject(resources[0].getProject()); fWizard.getDiffTree().addDiffChangeListener(new IDiffChangeListener() { + @Override public void propertyChanged(IDiffTree tree, int property, IPath[] paths) { // ignore property changes } + @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { - Utils.syncExec(new Runnable() { - public void run() { - updateEnablements(); - } - }, CommitWizardCommitPage.this.getControl()); + Utils.syncExec((Runnable) () -> updateEnablements(), CommitWizardCommitPage.this.getControl()); } }); } @@ -108,7 +106,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ - public void createControl(Composite parent) { + @Override + public void createControl(Composite parent) { initializeDialogUnits(parent); Dialog.applyDialogFont(parent); final PixelConverter converter= new PixelConverter(parent); @@ -197,7 +196,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang Button showChanges = new Button(changeDesc, SWT.PUSH); showChanges.setText(CVSUIMessages.CommitWizardCommitPage_5); showChanges.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { + @Override + public void widgetSelected(SelectionEvent e) { showChangesPane(); } }); @@ -247,15 +247,18 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang super(cc, configuration, participant); } + @Override protected boolean isOfferToRememberParticipant() { return false; } + @Override protected CompareViewerSwitchingPane createContentViewerSwitchingPane( Splitter parent, int style, CompareEditorInput cei) { return super.createContentViewerSwitchingPane(placeholder, style, cei); } + @Override protected void setPageDescription(String title) { super.setPageDescription(TeamUIMessages.ParticipantPageSaveablePart_0); } @@ -268,6 +271,7 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang /* (non-Javadoc) * @see org.eclipse.jface.dialogs.DialogPage#dispose() */ + @Override public void dispose() { super.dispose(); // Disposing of the page pane will dispose of the page and the configuration @@ -287,7 +291,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang /* (non-Javadoc) * @see org.eclipse.jface.wizard.WizardPage#isPageComplete() */ - public boolean isPageComplete() { + @Override + public boolean isPageComplete() { /* if empty comment is not allowed (see bug 114678) */ final IPreferenceStore store = CVSUIPlugin.getPlugin() .getPreferenceStore(); @@ -308,7 +313,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang * * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) */ - public void setVisible(boolean visible) { + @Override + public void setVisible(boolean visible) { super.setVisible(visible); expand(); if (visible && fConfiguration != null) { @@ -393,7 +399,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang validatePage(true); } - protected IWizardContainer getContainer() { + @Override + protected IWizardContainer getContainer() { return super.getContainer(); } @@ -404,7 +411,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang /* (non-Javadoc) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ - public void propertyChange(PropertyChangeEvent event) { + @Override + public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(CommitCommentArea.OK_REQUESTED)) { final IWizardContainer container= getContainer(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java index 795ac6957..b99762df0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java @@ -14,15 +14,11 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.wizards; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.*; import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.*; import org.eclipse.swt.widgets.Display; import org.eclipse.team.core.mapping.provider.SynchronizationContext; @@ -46,27 +42,29 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { * The actions to be displayed in the context menu. */ private class ActionContribution extends SynchronizePageActionGroup { - public void modelChanged(final ISynchronizeModelElement root) { + @Override + public void modelChanged(final ISynchronizeModelElement root) { super.modelChanged(root); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - final CommitWizardCommitPage page= fWizard.getCommitPage(); - if (page != null) - page.updateForModelChange(); - } - }); + Display.getDefault().asyncExec(() -> { + final CommitWizardCommitPage page = fWizard.getCommitPage(); + if (page != null) + page.updateForModelChange(); + }); } } private WorkspaceChangeSetCapability capability; - public ChangeSetCapability getChangeSetCapability() { + @Override + public ChangeSetCapability getChangeSetCapability() { if (capability == null) { capability = new WorkspaceChangeSetCapability() { - public boolean supportsCheckedInChangeSets() { + @Override + public boolean supportsCheckedInChangeSets() { return false; } - public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { + @Override + public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { return false; }; }; @@ -87,7 +85,8 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { fWizard= wizard; } - protected CVSDecoration getDecoration(IResource resource) throws CoreException { + @Override + protected CVSDecoration getDecoration(IResource resource) throws CoreException { final CVSDecoration decoration= super.getDecoration(resource); final CommitWizardFileTypePage page= fWizard.getFileTypePage(); @@ -107,14 +106,16 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { fWizard= wizard; } - protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) { + @Override + protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) { return new Decorator(configuration, fWizard); } /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration) */ - protected void initializeConfiguration(final ISynchronizePageConfiguration configuration) { + @Override + protected void initializeConfiguration(final ISynchronizePageConfiguration configuration) { super.initializeConfiguration(configuration); configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ACTION_GROUP, ISynchronizePageConfiguration.NAVIGATE_GROUP}); configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU); @@ -126,23 +127,21 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { // Wrap the container so that we can update the enablements after the runnable // (i.e. the container resets the state to what it was at the beginning of the // run even if the state of the page changed. Remove from View changes the state) - configuration.setRunnableContext(new IRunnableContext() { - public void run(boolean fork, boolean cancelable, - IRunnableWithProgress runnable) - throws InvocationTargetException, InterruptedException { - fWizard.getContainer().run(fork, cancelable, runnable); - final CommitWizardCommitPage page= fWizard.getCommitPage(); - if (page != null) - page.updateEnablements(); - } - }); + configuration.setRunnableContext((fork, cancelable, runnable) -> { + fWizard.getContainer().run(fork, cancelable, runnable); + final CommitWizardCommitPage page = fWizard.getCommitPage(); + if (page != null) + page.updateEnablements(); + }); configuration.setSupportedModes(ISynchronizePageConfiguration.OUTGOING_MODE); configuration.setMode(ISynchronizePageConfiguration.OUTGOING_MODE); configuration.addActionContribution(new SynchronizePageActionGroup() { - public void initialize(ISynchronizePageConfiguration configuration) { + @Override + public void initialize(ISynchronizePageConfiguration configuration) { super.initialize(configuration); showComparePaneAction = new Action(null, Action.AS_CHECK_BOX) { - public void run() { + @Override + public void run() { fWizard.getCommitPage().showComparePane(this.isChecked()); } }; @@ -152,6 +151,7 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { } }); configuration.setProperty(SynchronizePageConfiguration.P_OPEN_ACTION, new Action() { + @Override public void run() { ISelection selection = configuration.getSite().getSelectionProvider().getSelection(); if(selection instanceof IStructuredSelection) { @@ -168,7 +168,8 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { /* (non-Javadoc) * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#doesSupportSynchronize() */ - public boolean doesSupportSynchronize() { + @Override + public boolean doesSupportSynchronize() { return false; } @@ -177,8 +178,10 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { return section == null ? false : section.getBoolean(CommitWizardCommitPage.SHOW_COMPARE); } + @Override protected ModelSynchronizeParticipantActionGroup createMergeActionGroup() { return new WorkspaceMergeActionGroup() { + @Override protected void addToContextMenu(String mergeActionId, Action action, IMenuManager manager) { if (mergeActionId == SynchronizationActionProvider.MERGE_ACTION_ID || mergeActionId == SynchronizationActionProvider.OVERWRITE_ACTION_ID @@ -189,6 +192,7 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { super.addToContextMenu(mergeActionId, action, manager); } + @Override protected void appendToGroup(String menuId, String groupId, IAction action) { if (menuId == ISynchronizePageConfiguration.P_CONTEXT_MENU && groupId == WorkspaceModelParticipant.CONTEXT_MENU_COMMIT_GROUP_1) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java index 3280cbd0a..8c7e55a2c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java @@ -15,36 +15,21 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.*; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFile; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.Policy; @@ -106,11 +91,7 @@ public class ModeWizard extends ResizableWizard { final ModeWizard [] wizard= new ModeWizard[1]; - BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { - public void run() { - wizard[0]= new ModeWizard(shell, resources); - } - }); + BusyIndicator.showWhile(shell.getDisplay(), () -> wizard[0] = new ModeWizard(shell, resources)); open(shell, wizard[0]); return wizard[0]; @@ -134,14 +115,16 @@ public class ModeWizard extends ResizableWizard { } - public void addPages() { + @Override + public void addPages() { addPage(fPage); } /* (Non-javadoc) * Method declared on IWizard. */ - public boolean needsProgressMonitor() { + @Override + public boolean needsProgressMonitor() { return true; } @@ -153,28 +136,26 @@ public class ModeWizard extends ResizableWizard { for (int i = 0; i < resources.length; i++) { final IResource currentResource = resources[i]; try { - currentResource.accept(new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - try { - if (visited.contains(resource) || resource.getType() != IResource.FILE || !resource.exists()) - return true; - visited.add(resource); - IFile file = (IFile) resource; - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); - if (!cvsFile.isManaged()) - return true; - final ResourceSyncInfo info = cvsFile.getSyncInfo(); - final KSubstOption mode = info.getKeywordMode(); - - changes.add(new ModeChange(file, mode)); - - } catch (TeamException e) { - throw new CoreException(e.getStatus()); - } - // always return true and let the depth determine if children are visited - return true; - } - }, IResource.DEPTH_INFINITE, false); + currentResource.accept((IResourceVisitor) resource -> { + try { + if (visited.contains(resource) || resource.getType() != IResource.FILE || !resource.exists()) + return true; + visited.add(resource); + IFile file = (IFile) resource; + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); + if (!cvsFile.isManaged()) + return true; + final ResourceSyncInfo info = cvsFile.getSyncInfo(); + final KSubstOption mode = info.getKeywordMode(); + + changes.add(new ModeChange(file, mode)); + + } catch (TeamException e) { + throw new CoreException(e.getStatus()); + } + // always return true and let the depth determine if children are visited + return true; + }, IResource.DEPTH_INFINITE, false); } catch (CoreException e) { CVSUIPlugin.openError(shell, CVSUIMessages.ModeWizard_2, null, e); } @@ -182,7 +163,8 @@ public class ModeWizard extends ResizableWizard { return changes; } - public boolean performFinish() { + @Override + public boolean performFinish() { try { final List messages = new ArrayList(); final List changes= fPage.getChanges(); @@ -194,7 +176,8 @@ public class ModeWizard extends ResizableWizard { return false; getContainer().run(false /*fork*/, true /*cancelable*/, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { final int totalWork= 10000; monitor.beginTask(CVSUIMessages.ModeWizard_3, totalWork); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java index 1cf02db0f..5f310ad47 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java @@ -21,7 +21,6 @@ import java.util.Iterator; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.*; import org.eclipse.jface.wizard.IWizard; @@ -69,17 +68,14 @@ public class ModuleSelectionPage extends CVSWizardPage { this.helpContextId = helpContextId; } + @Override public void createControl(Composite parent) { Composite composite = createComposite(parent, 2, false); if (helpContextId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContextId); - Listener listener = new Listener() { - public void handleEvent(Event event) { - updateEnablements(false); - } - }; + Listener listener = event -> updateEnablements(false); if (project != null) { useProjectNameButton = createRadioButton(composite, CVSUIMessages.ModuleSelectionPage_moduleIsProject, 2); @@ -101,11 +97,7 @@ public class ModuleSelectionPage extends CVSWizardPage { data.horizontalSpan = 2; data.horizontalIndent = 10; useModuleAndProjectNameButton.setLayoutData(data); - useModuleAndProjectNameButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - updateText(); - } - }); + useModuleAndProjectNameButton.addListener(SWT.Selection, event -> updateText()); } moduleList = createModuleTree(composite, 2); @@ -145,6 +137,7 @@ public class ModuleSelectionPage extends CVSWizardPage { && useModuleAndProjectNameButton.getSelection(); } + @Override public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { @@ -205,13 +198,11 @@ public class ModuleSelectionPage extends CVSWizardPage { if (fetchModules) { // Validate the location first since the module fecthing is // done in a deferred fashion - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - validateLocation(monitor); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } + getContainer().run(true, true, monitor -> { + try { + validateLocation(monitor); + } catch (CVSException e) { + throw new InvocationTargetException(e); } }); setModuleListInput(); @@ -300,11 +291,7 @@ public class ModuleSelectionPage extends CVSWizardPage { public ICVSRemoteFolder[] getSelectedModules() { final ICVSRemoteFolder[][] folder = new ICVSRemoteFolder[][] { null }; - Display.getDefault().syncExec(new Runnable() { - public void run() { - folder[0] = internalGetSelectedModules(); - } - }); + Display.getDefault().syncExec(() -> folder[0] = internalGetSelectedModules()); return folder[0]; } @@ -322,6 +309,7 @@ public class ModuleSelectionPage extends CVSWizardPage { * Fix to allow filtering to be used without triggering fetching * of the contents of all children (see bug 62268) */ + @Override public boolean isExpandable(Object element) { ITreeContentProvider cp = (ITreeContentProvider) getContentProvider(); if(cp == null) @@ -333,16 +321,14 @@ public class ModuleSelectionPage extends CVSWizardPage { result.setContentProvider(new RemoteContentProvider()); result.setLabelProvider(new WorkbenchLabelProvider()); result.addFilter(new ViewerFilter() { + @Override public boolean select(Viewer viewer, Object parentElement, Object element) { return !(element instanceof ICVSRemoteFile); } }); - result.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateText(); - } - }); + result.addSelectionChangedListener(event -> updateText()); result.getTree().addMouseListener(new MouseAdapter() { + @Override public void mouseDoubleClick(MouseEvent e) { if (getSelectedModule() != null) { gotoNextPage(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java index d97c77f96..d16e99685 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java @@ -17,10 +17,8 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.lang.reflect.InvocationTargetException; import java.util.Properties; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; @@ -67,6 +65,7 @@ public class NewLocationWizard extends Wizard implements INewWizard { /** * Creates the wizard pages */ + @Override public void addPages() { mainPage = createMainPage(); if (properties != null) { @@ -85,6 +84,7 @@ public class NewLocationWizard extends Wizard implements INewWizard { /* * @see IWizard#performFinish */ + @Override public boolean performFinish() { final ICVSRepositoryLocation[] location = new ICVSRepositoryLocation[] { null }; boolean keepLocation = false; @@ -96,13 +96,11 @@ public class NewLocationWizard extends Wizard implements INewWizard { if (mainPage.getValidate()) { try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - location[0].validateConnection(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } + getContainer().run(true, true, monitor -> { + try { + location[0].validateConnection(monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); keepLocation = true; @@ -164,6 +162,7 @@ public class NewLocationWizard extends Wizard implements INewWizard { return keepLocation; } + @Override public void init(IWorkbench workbench, IStructuredSelection selection) { // Nothing to do } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java index 284151117..9eaf0314e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java @@ -20,9 +20,9 @@ import java.util.*; import org.eclipse.compare.*; import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.*; import org.eclipse.osgi.util.NLS; @@ -74,23 +74,29 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { this.file= file; this.logEntry = logEntry; } + @Override public InputStream getContents() throws CoreException { IStorage s = getStorageFromLogEntry(logEntry); if (s == null) return null; return new BufferedInputStream(s.getContents()); } + @Override public String getName() { return file.getName(); } + @Override public String getType() { return file.getFileExtension(); } + @Override public Image getImage() { return CompareUI.getImage(file); } + @Override public long getModificationDate() { return logEntry.getDate().getTime(); } + @Override public String getCharset() throws CoreException { IStorage s = getStorageFromLogEntry(logEntry); if (s instanceof IEncodedStorage) { @@ -118,6 +124,7 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { /** * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { Composite composite= createComposite(parent, 1, false); setControl(composite); @@ -151,6 +158,7 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { // Bottom: File content viewer fileContentPane = new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) { + @Override protected Viewer getViewer(Viewer oldViewer, Object input) { return CompareUI.findContentViewer(oldViewer, input, this, null); } @@ -166,19 +174,23 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { protected CheckboxTableViewer createRevisionSelectionTable(CompareViewerPane composite, HistoryTableProvider tableProvider) { CheckboxTableViewer table = tableProvider.createCheckBoxTable(composite); table.setContentProvider(new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { ILogEntry[] entries = getSelectedEntries(); if (entries != null) return entries; return new Object[0]; } + @Override public void dispose() { } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); table.setInput(this); table.getTable().addSelectionListener( new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { // Handle check selection in the check state listener if (e.detail == SWT.CHECK) return; @@ -186,11 +198,7 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { } } ); - table.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - handleRevisionChecked(event); - } - }); + table.addCheckStateListener(event -> handleRevisionChecked(event)); composite.setContent(table.getControl()); return table; } @@ -202,6 +210,7 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { tree.setLabelProvider( new DecoratingLabelProvider( new WorkbenchLabelProvider() { + @Override protected String decorateText(String input, Object element) { String text; if (element instanceof IFolder && element.equals(folder)) { @@ -222,11 +231,7 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); tree.getTree().setLayoutData(data); - tree.addPostSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - handleFileSelection(event); - } - }); + tree.addPostSelectionChangedListener(event -> handleFileSelection(event)); composite.setContent(tree.getControl()); return tree; } @@ -400,16 +405,14 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { final ICVSRemoteFile remoteFile = location.getRemoteFile(new Path(null, info.getRepository()).append(file.getName()).toString(), CVSTag.DEFAULT); // Then we need to fetch the log entries - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - // fetch the entries - ILogEntry[] entries = remoteFile.getLogEntries(monitor); - // cache the entries with the selected file - entriesCache.put(selectedFile, entries); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } + getContainer().run(true, true, monitor -> { + try { + // fetch the entries + ILogEntry[] entries = remoteFile.getLogEntries(monitor); + // cache the entries with the selected file + entriesCache.put(selectedFile, entries); + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); } catch (CVSException e) { @@ -438,14 +441,12 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { private IStorage getStorageFromLogEntry(final ILogEntry logEntry) { final IStorage[] s = new IStorage[] { null }; try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSRemoteFile remoteFile = logEntry.getRemoteFile(); - s[0] = ((IResourceVariant)remoteFile).getStorage(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } + getContainer().run(true, true, monitor -> { + try { + ICVSRemoteFile remoteFile = logEntry.getRemoteFile(); + s[0] = ((IResourceVariant) remoteFile).getStorage(monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); } catch (InvocationTargetException e) { @@ -506,23 +507,22 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { public boolean restoreSelectedFiles() { try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - monitor.beginTask(null, 100 * filesToRestore.size()); - for (Iterator iter = filesToRestore.keySet().iterator();iter.hasNext();) { - IFile file = (IFile) iter.next(); - ILogEntry entry = (ILogEntry)filesToRestore.get(file); - ensureParentExists(file); - file.create(entry.getRemoteFile().getContents(Policy.subMonitorFor(monitor, 50)), false, Policy.subMonitorFor(monitor, 50)); - } - } catch (TeamException e) { - throw new InvocationTargetException(e); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); + getContainer().run(true, true, monitor -> { + try { + monitor.beginTask(null, 100 * filesToRestore.size()); + for (Iterator iter = filesToRestore.keySet().iterator(); iter.hasNext();) { + IFile file = (IFile) iter.next(); + ILogEntry entry = (ILogEntry) filesToRestore.get(file); + ensureParentExists(file); + file.create(entry.getRemoteFile().getContents(Policy.subMonitorFor(monitor, 50)), false, + Policy.subMonitorFor(monitor, 50)); } + } catch (TeamException e1) { + throw new InvocationTargetException(e1); + } catch (CoreException e2) { + throw new InvocationTargetException(e2); + } finally { + monitor.done(); } }); } catch (InvocationTargetException e) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java index 9bae903e8..c19406af1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java @@ -21,7 +21,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; @@ -89,6 +88,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW setWindowTitle(CVSUIMessages.SharingWizard_title); } + @Override public void addPages() { ImageDescriptor sharingImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_SHARE); boolean autoconnect = false; @@ -146,17 +146,20 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW addPage(syncPage); } + @Override public boolean canFinish() { IWizardPage page = getContainer().getCurrentPage(); return (page == autoconnectPage || page == syncPage); } + @Override public IWizardPage getNextPage(IWizardPage page) { // Assume the page is about to be shown when this method is // invoked return getNextPage(page, true /* about to show*/); } + @Override public IWizardPage getNextPage(IWizardPage page, boolean aboutToShow) { if (page == autoconnectPage) return null; if (page == locationPage) { @@ -227,19 +230,18 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW /* * @see IWizard#performFinish */ + @Override public boolean performFinish() { final boolean[] result = new boolean[] { true }; if (isAutoconnect()) { try { - getContainer().run(true /* fork */, true /* cancel */, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - result[0] = autoconnectCVSProject(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } + getContainer().run(true /* fork */, true /* cancel */, monitor -> { + try { + result[0] = autoconnectCVSProject(monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); } }); } catch (InterruptedException e) { @@ -258,14 +260,12 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW if (getContainer().getCurrentPage() == syncPage) { syncPage.saveSettings(); if (syncPage.commitChanges()) { - Display.getCurrent().asyncExec(new Runnable() { - public void run() { - try { - CommitWizard.run(null, parentShell, new IResource[] { syncPage.getProject() }); - } catch (CVSException e) { - //TODO:handle - CVSUIPlugin.log(e); - } + Display.getCurrent().asyncExec(() -> { + try { + CommitWizard.run(null, parentShell, new IResource[] { syncPage.getProject() }); + } catch (CVSException e) { + // TODO:handle + CVSUIPlugin.log(e); } }); } @@ -276,6 +276,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizard#performCancel() */ + @Override public boolean performCancel() { boolean disposeLocation = isNewLocation; ICVSRepositoryLocation location; @@ -299,12 +300,8 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW } } else { try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - new DisconnectOperation(null, new IProject[] { project }, true) - .run(monitor); - } - }); + getContainer().run(true, true, + monitor -> new DisconnectOperation(null, new IProject[] { project }, true).run(monitor)); } catch (InvocationTargetException e) { CVSUIPlugin.log(IStatus.ERROR, e.getMessage(), e.getTargetException()); } catch (InterruptedException e) { @@ -347,13 +344,11 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW // Otherwise, get the location from the create location page final ICVSRepositoryLocation[] locations = new ICVSRepositoryLocation[] { null }; final CVSException[] exception = new CVSException[] { null }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - try { - locations[0] = createLocationPage.getLocation(); - } catch (CVSException e) { - exception[0] = e; - } + getShell().getDisplay().syncExec(() -> { + try { + locations[0] = createLocationPage.getLocation(); + } catch (CVSException e) { + exception[0] = e; } }); if (exception[0] != null) { @@ -382,6 +377,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW /* * @see IConfigurationWizard#init(IWorkbench, IProject) */ + @Override public void init(IWorkbench workbench, IProject project) { this.project = project; } @@ -395,15 +391,13 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW } final boolean[] isCVSFolder = new boolean[] { false }; try { - CVSUIPlugin.runWithRefresh(shell, new IResource[] { project }, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project); - FolderSyncInfo info = folder.getFolderSyncInfo(); - isCVSFolder[0] = info != null; - } catch (final TeamException e) { - throw new InvocationTargetException(e); - } + CVSUIPlugin.runWithRefresh(shell, new IResource[] { project }, monitor -> { + try { + ICVSFolder folder = (ICVSFolder) CVSWorkspaceRoot.getCVSResourceFor(project); + FolderSyncInfo info = folder.getFolderSyncInfo(); + isCVSFolder[0] = info != null; + } catch (final TeamException e) { + throw new InvocationTargetException(e); } }, null); } catch (InvocationTargetException e) { @@ -446,13 +440,11 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW } catch (final TeamException e) { // Exception validating. We can continue if the user wishes. final boolean[] keep = new boolean[] { false }; - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - keep[0] = MessageDialog.openQuestion(getContainer().getShell(), - CVSUIMessages.SharingWizard_validationFailedTitle, - NLS.bind(CVSUIMessages.SharingWizard_validationFailedText, (new Object[] {e.getStatus().getMessage()}))); - } - }); + getShell().getDisplay() + .syncExec(() -> keep[0] = MessageDialog.openQuestion(getContainer().getShell(), + CVSUIMessages.SharingWizard_validationFailedTitle, + NLS.bind(CVSUIMessages.SharingWizard_validationFailedText, + (new Object[] { e.getStatus().getMessage() })))); if (!keep[0]) { return false; } @@ -515,44 +507,41 @@ public class SharingWizard extends Wizard implements IConfigurationWizard, ICVSW private boolean exists(final ICVSRemoteFolder folder) throws InvocationTargetException, InterruptedException { final boolean[] result = new boolean[] { false }; - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - try { - result[0] = exists(folder, monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } + getContainer().run(true, true, monitor -> { + try { + result[0] = exists(folder, monitor); + } catch (TeamException e) { + throw new InvocationTargetException(e); } }); return result[0]; } private void populateSyncPage(final boolean exists) throws InvocationTargetException, InterruptedException { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask(null, IProgressMonitor.UNKNOWN); - if (exists) { - reconcileProject(Policy.subMonitorFor(monitor, 50)); - } else { - shareProject(Policy.subMonitorFor(monitor, 50)); - } - try { - getParticipant().getContext().refresh(Utils.getResourceMappings(new IProject[] { project }), Policy.subMonitorFor(monitor, 50)); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - if (monitor.isCanceled()) { - throw new InterruptedException(); - } - monitor.done(); + getContainer().run(true, true, monitor -> { + monitor.beginTask(null, IProgressMonitor.UNKNOWN); + if (exists) { + reconcileProject(Policy.subMonitorFor(monitor, 50)); + } else { + shareProject(Policy.subMonitorFor(monitor, 50)); } + try { + getParticipant().getContext().refresh(Utils.getResourceMappings(new IProject[] { project }), + Policy.subMonitorFor(monitor, 50)); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + if (monitor.isCanceled()) { + throw new InterruptedException(); + } + monitor.done(); }); } /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) */ + @Override public IWizardPage getPreviousPage(IWizardPage page) { if (page == syncPage) { // There's no going back from the sync page diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java index e09f5f117..30db2a3a6 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java @@ -18,8 +18,9 @@ import org.eclipse.compare.Splitter; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.Viewer; @@ -31,7 +32,8 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; import org.eclipse.team.core.diff.*; import org.eclipse.team.core.mapping.IResourceDiffTree; -import org.eclipse.team.internal.ccvs.ui.*; +import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; import org.eclipse.team.internal.ccvs.ui.mappings.ModelSynchronizeWizard; import org.eclipse.team.internal.ui.*; @@ -72,6 +74,7 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent); @@ -128,21 +131,19 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL /* private */ void showErrors(final IStatus[] status) { if (status.length == 0) return; - getShell().getDisplay().syncExec(new Runnable() { - - public void run() { - String title = CVSUIMessages.SharingWizardSyncPage_8; - if (status.length == 1) { - IStatus s = status[0]; - if (s.getException() instanceof CoreException) { - s = ((CoreException)s.getException()).getStatus(); - } - ErrorDialog.openError(getShell(), title, null, s); - } else { - MultiStatus multi = new MultiStatus(CVSUIPlugin.ID, 0, status, CVSUIMessages.SharingWizardSyncPage_9, null); - ErrorDialog.openError(getShell(), title, null, multi); + getShell().getDisplay().syncExec(() -> { + String title = CVSUIMessages.SharingWizardSyncPage_8; + if (status.length == 1) { + IStatus s = status[0]; + if (s.getException() instanceof CoreException) { + s = ((CoreException) s.getException()).getStatus(); } - } + ErrorDialog.openError(getShell(), title, null, s); + } else { + MultiStatus multi = new MultiStatus(CVSUIPlugin.ID, 0, status, CVSUIMessages.SharingWizardSyncPage_9, + null); + ErrorDialog.openError(getShell(), title, null, multi); + } }); } @@ -158,6 +159,7 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL cc.setLeftEditable(false); cc.setRightEditable(false); ParticipantPageCompareEditorInput part = new ParticipantPageCompareEditorInput(cc, configuration, participant) { + @Override protected boolean isOfferToRememberParticipant() { return false; } @@ -172,6 +174,7 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#dispose() */ + @Override public void dispose() { if (input != null) { input.getParticipant().dispose(); @@ -181,20 +184,20 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL /* (non-Javadoc) * @see org.eclipse.jface.wizard.WizardPage#setPreviousPage(org.eclipse.jface.wizard.IWizardPage) */ + @Override public void setPreviousPage(IWizardPage page) { // There's no going back from this page super.setPreviousPage(null); } private void updatePage() { - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (pageBook.isDisposed()) return; - if (getDiffTree().isEmpty()) { - pageBook.showPage(noChangesPage); - } else { - pageBook.showPage(syncPage); - } + Display.getDefault().syncExec(() -> { + if (pageBook.isDisposed()) + return; + if (getDiffTree().isEmpty()) { + pageBook.showPage(noChangesPage); + } else { + pageBook.showPage(syncPage); } }); } @@ -206,6 +209,7 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean) */ + @Override public void setVisible(boolean visible) { super.setVisible(visible); if (syncPage.isVisible()) { @@ -253,6 +257,7 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL private boolean hasOutgoingChanges() { IResourceDiffTree tree = getDiffTree(); return tree != null && tree.hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() { + @Override public boolean select(IDiff diff) { if (diff instanceof IThreeWayDiff) { IThreeWayDiff twd = (IThreeWayDiff) diff; @@ -270,11 +275,13 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL return project; } + @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { showErrors(event.getErrors()); updatePage(); } + @Override public void propertyChanged(IDiffTree tree, int property, IPath[] paths) { // Ignore } -- cgit v1.2.3