Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-07-20 18:01:20 -0400
committerAlexander Kurtakov2017-07-20 18:01:20 -0400
commit2f9785951b4c9c1279231cb7736c30e7beb50c6b (patch)
treec620a9434febd62d6cf937ddf9c6281b2769caa5 /bundles
parentf5c32aad77cc1028c986e525a81fd9c8405c1480 (diff)
downloadeclipse.platform.team-2f9785951b4c9c1279231cb7736c30e7beb50c6b.tar.gz
eclipse.platform.team-2f9785951b4c9c1279231cb7736c30e7beb50c6b.tar.xz
eclipse.platform.team-2f9785951b4c9c1279231cb7736c30e7beb50c6b.zip
Bug 519977 - Modernize org.eclipse.compare
Generifications, using lambdas and removing non-javadoc. Change-Id: I262eae91d1596f9da8f10a8bd9f71358a8c3c774
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java217
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java21
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java23
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java119
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java39
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java19
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java43
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java190
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AdapterFactory.java24
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java57
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java26
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java31
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java38
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java9
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java46
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java8
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java67
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java9
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java93
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java41
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java41
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java8
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java34
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java57
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java8
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java12
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java22
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java18
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java67
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java180
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java15
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DiffViewerComparator.java35
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java88
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java61
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java14
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java58
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java36
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java153
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java56
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java22
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java44
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java15
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java110
47 files changed, 777 insertions, 1521 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index eb38000fb..f20f71ec1 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -55,22 +55,10 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.IFindReplaceTarget;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.*;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -252,17 +240,14 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
fCompareConfiguration= configuration;
Assert.isNotNull(configuration);
- fDirtyStateListener= new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent e) {
- String propertyName= e.getProperty();
- if (CompareEditorInput.DIRTY_STATE.equals(propertyName)) {
- boolean changed= false;
- Object newValue= e.getNewValue();
- if (newValue instanceof Boolean)
- changed= ((Boolean) newValue).booleanValue();
- setDirty(e.getSource(), changed);
- }
+ fDirtyStateListener= e -> {
+ String propertyName= e.getProperty();
+ if (CompareEditorInput.DIRTY_STATE.equals(propertyName)) {
+ boolean changed= false;
+ Object newValue= e.getNewValue();
+ if (newValue instanceof Boolean)
+ changed= ((Boolean) newValue).booleanValue();
+ setDirty(e.getSource(), changed);
}
};
@@ -292,12 +277,7 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
if (adapter == IShowInSource.class) {
final IFile file = Adapters.adapt(this, IFile.class);
if (file != null)
- return (T) new IShowInSource() {
- @Override
- public ShowInContext getShowInContext() {
- return new ShowInContext(new FileEditorInput(file), StructuredSelection.EMPTY);
- }
- };
+ return (T) (IShowInSource) () -> new ShowInContext(new FileEditorInput(file), StructuredSelection.EMPTY);
}
if (adapter == OutlineViewerCreator.class) {
synchronized (this) {
@@ -552,34 +532,26 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
feedInput();
parent.requestLayout();
- fComposite.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- /*
- * When the UI associated with this compare editor input is
- * disposed each composite being part of the UI releases its
- * children first. A dispose listener is added to the last
- * widget found in that structure. Therefore, compare editor
- * input is disposed at the end making it possible to refer
- * during widgets disposal.
- */
- Composite composite = (Composite) e.widget;
- Control control = composite;
- while (composite.getChildren().length > 0) {
- control = composite.getChildren()[composite.getChildren().length - 1];
- if (control instanceof Composite) {
- composite = (Composite) control;
- } else {
- break;
- }
+ fComposite.addDisposeListener(e -> {
+ /*
+ * When the UI associated with this compare editor input is
+ * disposed each composite being part of the UI releases its
+ * children first. A dispose listener is added to the last
+ * widget found in that structure. Therefore, compare editor
+ * input is disposed at the end making it possible to refer
+ * during widgets disposal.
+ */
+ Composite composite = (Composite) e.widget;
+ Control control = composite;
+ while (composite.getChildren().length > 0) {
+ control = composite.getChildren()[composite.getChildren().length - 1];
+ if (control instanceof Composite) {
+ composite = (Composite) control;
+ } else {
+ break;
}
- control.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent ev) {
- handleDispose();
- }
- });
}
+ control.addDisposeListener(ev -> handleDispose());
});
if (fHelpContextId != null)
PlatformUI.getWorkbench().getHelpSystem().setHelp(fComposite, fHelpContextId);
@@ -654,12 +626,7 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
// setup the wiring for top left pane
fStructureInputPane.addOpenListener(
- new IOpenListener() {
- @Override
- public void open(OpenEvent oe) {
- feed1(oe.getSelection());
- }
- }
+ oe -> feed1(oe.getSelection())
);
fStructureInputPane.addSelectionChangedListener(
new ISelectionChangedListener() {
@@ -674,30 +641,15 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
}
);
fStructureInputPane.addDoubleClickListener(
- new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- feedDefault1(event.getSelection());
- }
- }
+ event -> feedDefault1(event.getSelection())
);
fStructurePane1.addSelectionChangedListener(
- new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent e) {
- feed2(e.getSelection());
- }
- }
+ e -> feed2(e.getSelection())
);
fStructurePane2.addSelectionChangedListener(
- new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent e) {
- feed3(e.getSelection());
- }
- }
+ e -> feed3(e.getSelection())
);
return h;
@@ -777,28 +729,25 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
private void feed1(final ISelection selection) {
BusyIndicator.showWhile(fComposite.getDisplay(),
- new Runnable() {
- @Override
- public void run() {
- if (selection == null || selection.isEmpty()) {
- Object input= fStructureInputPane.getInput();
- if (input != null)
- internalSetContentPaneInput(input);
- if (!Utilities.okToUse(fStructurePane1) || !Utilities.okToUse(fStructurePane2))
- return;
- fStructurePane2.setInput(null); // clear downstream pane
+ () -> {
+ if (selection == null || selection.isEmpty()) {
+ Object input1= fStructureInputPane.getInput();
+ if (input1 != null)
+ internalSetContentPaneInput(input1);
+ if (!Utilities.okToUse(fStructurePane1) || !Utilities.okToUse(fStructurePane2))
+ return;
+ fStructurePane2.setInput(null); // clear downstream pane
+ fStructurePane1.setInput(null);
+ } else {
+ Object input2= getElement(selection);
+ internalSetContentPaneInput(input2);
+ if (!Utilities.okToUse(fStructurePane1) || !Utilities.okToUse(fStructurePane2))
+ return;
+ if (structureCompareOnSingleClick() || hasUnusableContentViewer())
+ fStructurePane1.setInput(input2);
+ fStructurePane2.setInput(null); // clear downstream pane
+ if (fStructurePane1.getInput() != input2)
fStructurePane1.setInput(null);
- } else {
- Object input= getElement(selection);
- internalSetContentPaneInput(input);
- if (!Utilities.okToUse(fStructurePane1) || !Utilities.okToUse(fStructurePane2))
- return;
- if (structureCompareOnSingleClick() || hasUnusableContentViewer())
- fStructurePane1.setInput(input);
- fStructurePane2.setInput(null); // clear downstream pane
- if (fStructurePane1.getInput() != input)
- fStructurePane1.setInput(null);
- }
}
}
);
@@ -806,30 +755,24 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
private void feedDefault1(final ISelection selection) {
BusyIndicator.showWhile(fComposite.getDisplay(),
- new Runnable() {
- @Override
- public void run() {
- if (!selection.isEmpty())
- fStructurePane1.setInput(getElement(selection));
- }
+ () -> {
+ if (!selection.isEmpty())
+ fStructurePane1.setInput(getElement(selection));
}
);
}
private void feed2(final ISelection selection) {
BusyIndicator.showWhile(fComposite.getDisplay(),
- new Runnable() {
- @Override
- public void run() {
- if (selection.isEmpty()) {
- Object input= fStructurePane1.getInput();
- internalSetContentPaneInput(input);
- fStructurePane2.setInput(null);
- } else {
- Object input= getElement(selection);
- internalSetContentPaneInput(input);
- fStructurePane2.setInput(input);
- }
+ () -> {
+ if (selection.isEmpty()) {
+ Object input1= fStructurePane1.getInput();
+ internalSetContentPaneInput(input1);
+ fStructurePane2.setInput(null);
+ } else {
+ Object input2= getElement(selection);
+ internalSetContentPaneInput(input2);
+ fStructurePane2.setInput(input2);
}
}
);
@@ -837,14 +780,11 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
private void feed3(final ISelection selection) {
BusyIndicator.showWhile(fComposite.getDisplay(),
- new Runnable() {
- @Override
- public void run() {
- if (selection.isEmpty())
- internalSetContentPaneInput(fStructurePane2.getInput());
- else
- internalSetContentPaneInput(getElement(selection));
- }
+ () -> {
+ if (selection.isEmpty())
+ internalSetContentPaneInput(fStructurePane2.getInput());
+ else
+ internalSetContentPaneInput(getElement(selection));
}
);
@@ -974,12 +914,7 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
Control c= newViewer.getControl();
c.addDisposeListener(
- new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- dsp.removePropertyChangeListener(fDirtyStateListener);
- }
- }
+ e -> dsp.removePropertyChangeListener(fDirtyStateListener)
);
}
@@ -1514,16 +1449,12 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
private boolean saveChanges() {
try {
- PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- saveChanges(monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
+ PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> {
+ try {
+ saveChanges(monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
}
-
});
return true;
} catch (InterruptedException x) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java
index fc040e1a7..1d0e8d6ad 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,8 +28,6 @@ import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
@@ -97,17 +95,14 @@ public class CompareViewerPane extends ViewForm implements ISelectionProvider,
addMouseListener(ml);
getTopLeft().addMouseListener(ml);
- addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fToolBarManager != null) {
- fToolBarManager.removeAll();
- fToolBarManager.dispose();
- }
- fInput= null;
- fSelectionListeners= null;
- setImage(null);
+ addDisposeListener(e -> {
+ if (fToolBarManager != null) {
+ fToolBarManager.removeAll();
+ fToolBarManager.dispose();
}
+ fInput= null;
+ fSelectionListeners= null;
+ setImage(null);
});
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java
index ceffe679a..41e7ac9bb 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,8 +20,6 @@ import org.eclipse.core.runtime.Adapters;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -89,18 +87,15 @@ public abstract class CompareViewerSwitchingPane extends CompareViewerPane {
setViewer(new NullViewer(this));
addDisposeListener(
- new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fViewer != null)
- fViewer.removeSelectionChangedListener(CompareViewerSwitchingPane.this);
- if (fViewer instanceof StructuredViewer) {
- StructuredViewer sv= (StructuredViewer) fViewer;
- sv.removeDoubleClickListener(CompareViewerSwitchingPane.this);
- sv.removeOpenListener(CompareViewerSwitchingPane.this);
- }
- fViewer= null;
+ e -> {
+ if (fViewer != null)
+ fViewer.removeSelectionChangedListener(CompareViewerSwitchingPane.this);
+ if (fViewer instanceof StructuredViewer) {
+ StructuredViewer sv= (StructuredViewer) fViewer;
+ sv.removeDoubleClickListener(CompareViewerSwitchingPane.this);
+ sv.removeOpenListener(CompareViewerSwitchingPane.this);
}
+ fViewer= null;
}
);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
index 952b75336..9e6f35d1b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,23 +10,11 @@
*******************************************************************************/
package org.eclipse.compare;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
import com.ibm.icu.text.DateFormat;
import com.ibm.icu.text.MessageFormat;
import com.ibm.icu.util.Calendar;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
@@ -49,11 +37,9 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.*;
+
+import java.util.*;
import org.eclipse.compare.internal.CompareContainer;
import org.eclipse.compare.internal.CompareUIPlugin;
@@ -175,7 +161,7 @@ public class EditionSelectionDialog extends ResizableDialog {
// Configuration options
private CompareConfiguration fCompareConfiguration;
- private ArrayList fArrayList= new ArrayList();
+ private ArrayList<Object> fArrayList= new ArrayList<>();
/** use a side-by-side compare viewer */
private boolean fCompare= true;
/** show target on right hand side */
@@ -195,11 +181,11 @@ public class EditionSelectionDialog extends ResizableDialog {
* Maps from members to their corresponding editions.
* Has only a single entry if dialog is used in "Replace" (and not "Add") mode.
*/
- private HashMap fMemberEditions;
+ private HashMap<ITypedElement, List<Pair>> fMemberEditions;
/**
* Maps from members to their corresponding selected edition.
*/
- private HashMap fMemberSelection;
+ private HashMap<List, ITypedElement> fMemberSelection;
/** The editions of the current selected member */
private List fCurrentEditions;
private Thread fThread;
@@ -466,7 +452,7 @@ public class EditionSelectionDialog extends ResizableDialog {
return null; // error
// extract all elements of container
- final HashSet current= new HashSet();
+ final HashSet<Object> current= new HashSet<>();
IStructureComparator sco= structureCreator.locate(container, target);
if (sco != null) {
Object[] children= sco.getChildren();
@@ -594,18 +580,18 @@ public class EditionSelectionDialog extends ResizableDialog {
* @since 2.1
*/
public ITypedElement[] getSelection() {
- ArrayList result= new ArrayList();
+ ArrayList<ITypedElement> result= new ArrayList<>();
if (fMemberSelection != null) {
- Iterator iter= fArrayList.iterator();
+ Iterator<Object> iter= fArrayList.iterator();
while (iter.hasNext()) {
Object edition= iter.next();
Object item= fMemberSelection.get(edition);
if (item != null)
- result.add(item);
+ result.add((ITypedElement) item);
}
} else if (fSelectedItem != null)
result.add(fSelectedItem);
- return (ITypedElement[]) result.toArray(new ITypedElement[result.size()]);
+ return result.toArray(new ITypedElement[result.size()]);
}
/**
@@ -744,9 +730,6 @@ public class EditionSelectionDialog extends ResizableDialog {
return null;
}
- /* (non Javadoc)
- * Creates SWT control tree.
- */
@Override
protected synchronized Control createDialogArea(Composite parent2) {
@@ -759,21 +742,18 @@ public class EditionSelectionDialog extends ResizableDialog {
| GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
vsplitter.addDisposeListener(
- new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fCompareConfiguration != null) {
- fCompareConfiguration.dispose();
- fCompareConfiguration= null;
- }
- if (fDateImage != null) {
- fDateImage.dispose();
- fDateImage= null;
- }
- if (fTimeImage != null) {
- fTimeImage.dispose();
- fTimeImage= null;
- }
+ e -> {
+ if (fCompareConfiguration != null) {
+ fCompareConfiguration.dispose();
+ fCompareConfiguration= null;
+ }
+ if (fDateImage != null) {
+ fDateImage.dispose();
+ fDateImage= null;
+ }
+ if (fTimeImage != null) {
+ fTimeImage.dispose();
+ fTimeImage= null;
}
}
);
@@ -831,12 +811,7 @@ public class EditionSelectionDialog extends ResizableDialog {
}
};
fStructuredComparePane.addSelectionChangedListener(
- new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent e) {
- feedInput2(e.getSelection());
- }
- }
+ e -> feedInput2(e.getSelection())
);
} else {
// only a single pane showing the editions
@@ -886,9 +861,6 @@ public class EditionSelectionDialog extends ResizableDialog {
return parent;
}
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
@Override
protected void createButtonsForButtonBar(Composite parent) {
String buttonLabel= Utilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$
@@ -924,29 +896,19 @@ public class EditionSelectionDialog extends ResizableDialog {
if (fEditionTree != null && !fEditionTree.isDisposed()) {
Display display= fEditionTree.getDisplay();
display.asyncExec(
- new Runnable() {
- @Override
- public void run() {
- addMemberEdition(pair);
- }
- }
+ () -> addMemberEdition(pair)
);
}
}
private static void internalSort(IModificationDate[] keys) {
- Arrays.sort(keys, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- IModificationDate d1= (IModificationDate) o1;
- IModificationDate d2= (IModificationDate) o2;
- long d= d2.getModificationDate() - d1.getModificationDate();
- if (d < 0)
- return -1;
- if (d > 0)
- return 1;
- return 0;
- }
+ Arrays.sort(keys, (d1, d2) -> {
+ long d= d2.getModificationDate() - d1.getModificationDate();
+ if (d < 0)
+ return -1;
+ if (d > 0)
+ return 1;
+ return 0;
});
}
@@ -980,14 +942,14 @@ public class EditionSelectionDialog extends ResizableDialog {
}
if (fMemberEditions == null)
- fMemberEditions= new HashMap();
+ fMemberEditions= new HashMap<>();
if (fMultiSelect && fMemberSelection == null)
- fMemberSelection= new HashMap();
+ fMemberSelection= new HashMap<>();
ITypedElement item= pair.getItem();
- List editions= (List) fMemberEditions.get(item);
+ List<Pair> editions= fMemberEditions.get(item);
if (editions == null) {
- editions= new ArrayList();
+ editions= new ArrayList<>();
fMemberEditions.put(item, editions);
if (fMemberTable != null && !fMemberTable.isDisposed()) {
ITypedElement te= item;
@@ -1014,7 +976,7 @@ public class EditionSelectionDialog extends ResizableDialog {
Pair last= fTargetPair;
int size= editions.size();
if (size > 0)
- last= (Pair) editions.get(size-1);
+ last= editions.get(size-1);
if (last != null && last.equals(pair))
return; // don't add since the new one is equal to old
}
@@ -1124,7 +1086,8 @@ public class EditionSelectionDialog extends ResizableDialog {
private void handleMemberSelect(Widget w) {
Object data= w.getData();
if (data instanceof List) {
- List editions= (List) data;
+ @SuppressWarnings("unchecked")
+ List<Object> editions= (List<Object>) data;
if (editions != fCurrentEditions) {
fCurrentEditions= editions;
fEditionTree.removeAll();
@@ -1133,7 +1096,7 @@ public class EditionSelectionDialog extends ResizableDialog {
String title= MessageFormat.format(pattern, new Object[] { ((Item)w).getText() });
fEditionPane.setText(title);
- Iterator iter= editions.iterator();
+ Iterator<Object> iter= editions.iterator();
while (iter.hasNext()) {
Object item= iter.next();
if (item instanceof Pair)
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java
index 2c81d63aa..077de1e78 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,7 +34,7 @@ public class ResourceNode extends BufferedContent
IEditableContent, IModificationDate, IResourceProvider, IEditableContentExtension {
private IResource fResource;
- private ArrayList fChildren;
+ private ArrayList<Object> fChildren;
/**
@@ -57,9 +57,6 @@ public class ResourceNode extends BufferedContent
return fResource;
}
- /* (non Javadoc)
- * see IStreamContentAccessor.getContents
- */
@Override
public InputStream getContents() throws CoreException {
if (fResource instanceof IStorage)
@@ -67,17 +64,11 @@ public class ResourceNode extends BufferedContent
return null;
}
- /* (non Javadoc)
- * see IModificationDate.getModificationDate
- */
@Override
public long getModificationDate() {
return fResource.getLocalTimeStamp();
}
- /* (non Javadoc)
- * see ITypedElement.getName
- */
@Override
public String getName() {
if (fResource != null)
@@ -85,9 +76,6 @@ public class ResourceNode extends BufferedContent
return null;
}
- /* (non Javadoc)
- * see ITypedElement.getType
- */
@Override
public String getType() {
if (fResource instanceof IContainer)
@@ -100,9 +88,6 @@ public class ResourceNode extends BufferedContent
return ITypedElement.UNKNOWN_TYPE;
}
- /* (non Javadoc)
- * see ITypedElement.getImage
- */
@Override
public Image getImage() {
return CompareUI.getImage(fResource);
@@ -130,13 +115,10 @@ public class ResourceNode extends BufferedContent
return getName().hashCode();
}
- /* (non Javadoc)
- * see IStructureComparator.getChildren
- */
@Override
public Object[] getChildren() {
if (fChildren == null) {
- fChildren= new ArrayList();
+ fChildren= new ArrayList<>();
if (fResource instanceof IContainer) {
try {
IResource members[]= ((IContainer)fResource).members();
@@ -194,33 +176,21 @@ public class ResourceNode extends BufferedContent
return null;
}
- /* (non Javadoc)
- * see IEditableContent.isEditable
- */
@Override
public boolean isEditable() {
return true;
}
- /* (non Javadoc)
- * see IEditableContent.replace
- */
@Override
public ITypedElement replace(ITypedElement child, ITypedElement other) {
return child;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEncodedStreamContentAccessor#getCharset()
- */
@Override
public String getCharset() {
return Utilities.getCharset(fResource);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEditableContentExtension#isReadOnly()
- */
@Override
public boolean isReadOnly() {
if (fResource.getType() == IResource.FILE) {
@@ -232,9 +202,6 @@ public class ResourceNode extends BufferedContent
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEditableContentExtension#validateEdit(org.eclipse.swt.widgets.Shell)
- */
@Override
public IStatus validateEdit(Shell shell) {
if (isReadOnly())
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java
index 260ba9952..951dab332 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.compare;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.zip.ZipEntry;
@@ -20,10 +18,7 @@ import java.util.zip.ZipInputStream;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.Utilities;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IStructureComparator;
-import org.eclipse.compare.structuremergeviewer.IStructureCreator;
+import org.eclipse.compare.structuremergeviewer.*;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
@@ -79,7 +74,7 @@ public class ZipFileStructureCreator implements IStructureCreator {
static class ZipFolder extends ZipResource {
- private HashMap fChildren= new HashMap(10);
+ private HashMap<String, ZipResource> fChildren= new HashMap<>(10);
ZipFolder(String name) {
super(name);
@@ -93,7 +88,7 @@ public class ZipFileStructureCreator implements IStructureCreator {
@Override
public Object[] getChildren() {
Object[] children= new Object[fChildren.size()];
- Iterator iter= fChildren.values().iterator();
+ Iterator<ZipResource> iter= fChildren.values().iterator();
for (int i= 0; iter.hasNext(); i++)
children[i]= iter.next();
return children;
@@ -269,8 +264,8 @@ public class ZipFileStructureCreator implements IStructureCreator {
}
if (root.fChildren.size() == 1) {
- Iterator iter= root.fChildren.values().iterator();
- return (IStructureComparator) iter.next();
+ Iterator<ZipResource> iter= root.fChildren.values().iterator();
+ return iter.next();
}
return root;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index a5e82b2d0..065620b11 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -57,20 +57,12 @@ import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ContentViewer;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.*;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.TextProcessor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
@@ -236,12 +228,7 @@ public abstract class ContentMergeViewer extends ContentViewer
fControl.addMouseListener(this);
fControl.addMouseMoveListener(this);
fControl.addDisposeListener(
- new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- fControl= null;
- }
- }
+ e -> fControl= null
);
}
@@ -357,15 +344,12 @@ public abstract class ContentMergeViewer extends ContentViewer
private Cursor fVSashCursor;
private Cursor fHVSashCursor;
- private ILabelProviderListener labelChangeListener = new ILabelProviderListener() {
- @Override
- public void labelProviderChanged(LabelProviderChangedEvent event) {
- Object[] elements = event.getElements();
- for (int i = 0; i < elements.length; i++) {
- Object object = elements[i];
- if (object == getInput())
- updateHeader();
- }
+ private ILabelProviderListener labelChangeListener = event -> {
+ Object[] elements = event.getElements();
+ for (int i = 0; i < elements.length; i++) {
+ Object object = elements[i];
+ if (object == getInput())
+ updateHeader();
}
};
@@ -561,12 +545,7 @@ public abstract class ContentMergeViewer extends ContentViewer
*/
@Override
public ISelection getSelection() {
- return new ISelection() {
- @Override
- public boolean isEmpty() {
- return true;
- }
- };
+ return () -> true;
}
/**
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index 7c120419d..f2d3426e5 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -97,29 +97,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.CursorLinePainter;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IFindReplaceTarget;
-import org.eclipse.jface.text.IFindReplaceTargetExtension;
-import org.eclipse.jface.text.IFindReplaceTargetExtension3;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextPresentationListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.*;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
@@ -138,25 +116,9 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.LineBackgroundEvent;
-import org.eclipse.swt.custom.LineBackgroundListener;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
@@ -165,16 +127,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TypedListener;
+import org.eclipse.swt.widgets.*;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IKeyBindingService;
@@ -465,12 +418,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
return null;
final Viewer v = CompareUI.findStructureViewer(oldViewer, input, parent, configuration);
if (v != null) {
- v.getControl().addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- v.removeSelectionChangedListener(InternalOutlineViewerCreator.this);
- }
- });
+ v.getControl().addDisposeListener(e -> v.removeSelectionChangedListener(InternalOutlineViewerCreator.this));
v.addSelectionChangedListener(this);
}
@@ -1493,12 +1441,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration);
- operationHistoryListener = new IOperationHistoryListener() {
- @Override
- public void historyNotification(OperationHistoryEvent event) {
- TextMergeViewer.this.historyNotification(event);
- }
- };
+ operationHistoryListener = event -> TextMergeViewer.this.historyNotification(event);
OperationHistoryFactory.getOperationHistory()
.addOperationHistoryListener(operationHistoryListener);
@@ -1593,12 +1536,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (fIsMotif)
fMarginWidth= 0;
- fPreferenceChangeListener= new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- TextMergeViewer.this.handlePropertyChangeEvent(event);
- }
- };
+ fPreferenceChangeListener= event -> TextMergeViewer.this.handlePropertyChangeEvent(event);
fPreferenceStore= createChainedPreferenceStore();
if (fPreferenceStore != null) {
@@ -2157,12 +2095,9 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
fVScrollBar.setIncrement(1);
fVScrollBar.setVisible(true);
fVScrollBar.addListener(SWT.Selection,
- new Listener() {
- @Override
- public void handleEvent(Event e) {
- int vpos= ((ScrollBar) e.widget).getSelection();
- synchronizedScrollVertical(vpos);
- }
+ e -> {
+ int vpos= ((ScrollBar) e.widget).getSelection();
+ synchronizedScrollVertical(vpos);
}
);
@@ -2640,12 +2575,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
viewer.hideSaveAction();
te.addPaintListener(
- new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- paint(e, viewer);
- }
- }
+ e -> paint(e, viewer)
);
te.addKeyListener(
new KeyAdapter() {
@@ -2679,12 +2609,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
);
viewer.getSourceViewer().addViewportListener(
- new IViewportListener() {
- @Override
- public void viewportChanged(int verticalPosition) {
- syncViewport(viewer);
- }
- }
+ verticalPosition -> syncViewport(viewer)
);
Font font= JFaceResources.getFont(fSymbolicFontName);
@@ -2735,7 +2660,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
}
private void contributeGotoLineAction(MergeSourceViewer viewer) {
- IAction action = new GotoLineAction((ITextEditor) viewer.getAdapter(ITextEditor.class));
+ IAction action = new GotoLineAction(viewer.getAdapter(ITextEditor.class));
action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO);
viewer.addAction(MergeSourceViewer.GOTO_LINE_ID, action);
}
@@ -2747,29 +2672,26 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private void contributeDiffBackgroundListener(final MergeSourceViewer viewer) {
viewer.getSourceViewer().getTextWidget().addLineBackgroundListener(
- new LineBackgroundListener() {
- @Override
- public void lineGetBackground(LineBackgroundEvent event) {
- StyledText textWidget = viewer.getSourceViewer().getTextWidget();
- if (textWidget != null) {
-
- int caret = textWidget.getCaretOffset();
- int length = event.lineText.length();
-
- if (event.lineOffset <= caret
- && caret <= event.lineOffset + length) {
- // current line, do nothing
- // decorated by CursorLinePainter
- } else {
- // find diff for the event line
- Diff diff = findDiff(viewer, event.lineOffset,
- event.lineOffset + length);
- if (diff != null && updateDiffBackground(diff)) {
- // highlights only the event line, not the
- // whole diff
- event.lineBackground = getColor(fComposite
- .getDisplay(), getFillColor(diff));
- }
+ event -> {
+ StyledText textWidget = viewer.getSourceViewer().getTextWidget();
+ if (textWidget != null) {
+
+ int caret = textWidget.getCaretOffset();
+ int length = event.lineText.length();
+
+ if (event.lineOffset <= caret
+ && caret <= event.lineOffset + length) {
+ // current line, do nothing
+ // decorated by CursorLinePainter
+ } else {
+ // find diff for the event line
+ Diff diff = findDiff(viewer, event.lineOffset,
+ event.lineOffset + length);
+ if (diff != null && updateDiffBackground(diff)) {
+ // highlights only the event line, not the
+ // whole diff
+ event.lineBackground = getColor(fComposite
+ .getDisplay(), getFillColor(diff));
}
}
}
@@ -2780,16 +2702,13 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (fHandlerService != null) {
if (part != null)
part.updateActions();
- fHandlerService.updatePaneActionHandlers(new Runnable() {
- @Override
- public void run() {
- for (int i= 0; i < GLOBAL_ACTIONS.length; i++) {
- IAction action= null;
- if (part != null) {
- action= part.getAction(TEXT_ACTIONS[i]);
- }
- fHandlerService.setGlobalActionHandler(GLOBAL_ACTIONS[i], action);
+ fHandlerService.updatePaneActionHandlers(() -> {
+ for (int i= 0; i < GLOBAL_ACTIONS.length; i++) {
+ IAction action= null;
+ if (part != null) {
+ action= part.getAction(TEXT_ACTIONS[i]);
}
+ fHandlerService.setGlobalActionHandler(GLOBAL_ACTIONS[i], action);
}
});
}
@@ -2797,23 +2716,20 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private void connectContributedActions(final MergeSourceViewer viewer, final boolean connect) {
if (fHandlerService != null) {
- fHandlerService.updatePaneActionHandlers(new Runnable() {
- @Override
- public void run() {
- if (viewer != null) {
- setActionsActivated(viewer.getSourceViewer(), connect);
- if (isEditorBacked(viewer.getSourceViewer()) && connect) {
- /*
- * If editor backed, activating contributed actions
- * might have disconnected actions provided in
- * CompareEditorContributor => when connecting,
- * refresh active editor in the contributor, when
- * disconnecting do nothing. See bug 261229.
- */
- IWorkbenchPart part = getCompareConfiguration().getContainer().getWorkbenchPart();
- if (part instanceof CompareEditor) {
- ((CompareEditor) part).refreshActionBarsContributor();
- }
+ fHandlerService.updatePaneActionHandlers(() -> {
+ if (viewer != null) {
+ setActionsActivated(viewer.getSourceViewer(), connect);
+ if (isEditorBacked(viewer.getSourceViewer()) && connect) {
+ /*
+ * If editor backed, activating contributed actions
+ * might have disconnected actions provided in
+ * CompareEditorContributor => when connecting,
+ * refresh active editor in the contributor, when
+ * disconnecting do nothing. See bug 261229.
+ */
+ IWorkbenchPart part = getCompareConfiguration().getContainer().getWorkbenchPart();
+ if (part instanceof CompareEditor) {
+ ((CompareEditor) part).refreshActionBarsContributor();
}
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AdapterFactory.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AdapterFactory.java
index 76b93723a..bc8cddc7d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AdapterFactory.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,8 +11,6 @@
package org.eclipse.compare.internal;
import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.IContributorResourceAdapter;
import org.eclipse.ui.IEditorInput;
@@ -20,27 +18,25 @@ import org.eclipse.ui.IFileEditorInput;
public class AdapterFactory implements IAdapterFactory {
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(final Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(final Object adaptableObject, Class<T> adapterType) {
if (IContributorResourceAdapter.class.equals(adapterType)
&& adaptableObject instanceof CompareEditorInput) {
- return new IContributorResourceAdapter() {
- @Override
- public IResource getAdaptedResource(IAdaptable adaptable) {
- Object ei = ((CompareEditorInput) adaptableObject)
- .getAdapter(IEditorInput.class);
- if (ei instanceof IFileEditorInput) {
- return ((IFileEditorInput) ei).getFile();
- }
- return null;
+ return (T) (IContributorResourceAdapter) adaptable -> {
+ Object ei = ((CompareEditorInput) adaptableObject)
+ .getAdapter(IEditorInput.class);
+ if (ei instanceof IFileEditorInput) {
+ return ((IFileEditorInput) ei).getFile();
}
+ return null;
};
}
return null;
}
@Override
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return new Class[] { IContributorResourceAdapter.class };
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
index dc6a7b984..bd259b466 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,29 +10,27 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import java.io.*;
-import com.ibm.icu.text.DateFormat;
-import com.ibm.icu.text.MessageFormat;
-import java.util.ArrayList;
-import com.ibm.icu.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.ResourceBundle;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.util.*;
+import org.eclipse.compare.*;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
-import org.eclipse.jface.dialogs.*;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-
-import org.eclipse.compare.*;
+import com.ibm.icu.text.DateFormat;
+import com.ibm.icu.text.MessageFormat;
+import com.ibm.icu.util.Calendar;
public class AddFromHistoryDialog extends ResizableDialog {
@@ -126,7 +124,7 @@ public class AddFromHistoryDialog extends ResizableDialog {
}
private CompareConfiguration fCompareConfiguration;
- private ArrayList fArrayList= new ArrayList();
+ private ArrayList<FileHistory> fArrayList= new ArrayList<>();
private FileHistory fCurrentFileHistory;
// SWT controls
@@ -199,9 +197,9 @@ public class AddFromHistoryDialog extends ResizableDialog {
HistoryInput[] getSelected() {
HistoryInput[] selected= new HistoryInput[fArrayList.size()];
- Iterator iter= fArrayList.iterator();
+ Iterator<FileHistory> iter= fArrayList.iterator();
for (int i= 0; iter.hasNext(); i++) {
- FileHistory h= (FileHistory) iter.next();
+ FileHistory h= iter.next();
selected[i]= h.getHistoryInput();
}
return selected;
@@ -219,14 +217,11 @@ public class AddFromHistoryDialog extends ResizableDialog {
| GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
vsplitter.addDisposeListener(
- new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fDateImage != null)
- fDateImage.dispose();
- if (fTimeImage != null)
- fTimeImage.dispose();
- }
+ e -> {
+ if (fDateImage != null)
+ fDateImage.dispose();
+ if (fTimeImage != null)
+ fTimeImage.dispose();
}
);
@@ -255,7 +250,7 @@ public class AddFromHistoryDialog extends ResizableDialog {
if (e.item instanceof TableItem) {
TableItem ti= (TableItem) e.item;
if (ti.getChecked())
- fArrayList.add(ti.getData());
+ fArrayList.add((FileHistory) ti.getData());
else
fArrayList.remove(ti.getData());
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java
index 2af3acd31..c8d04a6cb 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
/**
* A Canvas which reduces flicker by drawing in an off screen buffer.
@@ -30,22 +30,14 @@ public abstract class BufferedCanvas extends Canvas {
super(parent, flags | SWT.NO_BACKGROUND);
addPaintListener(
- new PaintListener() {
- @Override
- public void paintControl(PaintEvent event) {
- doubleBufferPaint(event.gc);
- }
- }
+ event -> doubleBufferPaint(event.gc)
);
addDisposeListener(
- new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fBuffer != null) {
- fBuffer.dispose();
- fBuffer= null;
- }
+ e -> {
+ if (fBuffer != null) {
+ fBuffer.dispose();
+ fBuffer= null;
}
}
);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
index eb43148a4..7a6f23596 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,16 +25,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -142,13 +133,10 @@ public class CompareContentViewerSwitchingPane extends CompareViewerSwitchingPan
labelOptimized.setImage(CompareUIPlugin.getImageDescriptor(
OPTIMIZED_INFO_IMAGE_NAME).createImage());
labelOptimized.setVisible(false); // hide by default
- labelOptimized.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- Image img = labelOptimized.getImage();
- if ((img != null) && (!img.isDisposed())) {
- img.dispose();
- }
+ labelOptimized.addDisposeListener(e -> {
+ Image img = labelOptimized.getImage();
+ if ((img != null) && (!img.isDisposed())) {
+ img.dispose();
}
});
@@ -251,12 +239,7 @@ public class CompareContentViewerSwitchingPane extends CompareViewerSwitchingPan
@Override
public void menuHidden(MenuEvent e) {
menuShowing= false;
- e.display.asyncExec(new Runnable() {
- @Override
- public void run() {
- menu.dispose();
- }
- });
+ e.display.asyncExec(() -> menu.dispose());
}
});
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
index f8ea37b3c..c597ce35e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -346,20 +346,17 @@ public class CompareEditor extends EditorPart
} finally {
if (monitor.isCanceled())
newState[0] = CANCELED;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (fPageBook.isDisposed())
- return;
- // we need to register the saveable if we had a previous input or if
- // there are knownSaveables (which means that the workbench called
- // getSaveables and got an empty list
- if (hadPreviousInput || (knownSaveables != null && !isAllSaveablesKnown())) {
- registerSaveable();
- }
- setState(newState[0]);
- createCompareControl();
+ Display.getDefault().syncExec(() -> {
+ if (fPageBook.isDisposed())
+ return;
+ // we need to register the saveable if we had a previous input or if
+ // there are knownSaveables (which means that the workbench called
+ // getSaveables and got an empty list
+ if (hadPreviousInput || (knownSaveables != null && !isAllSaveablesKnown())) {
+ registerSaveable();
}
+ setState(newState[0]);
+ createCompareControl();
});
monitor.done();
}
@@ -464,14 +461,11 @@ public class CompareEditor extends EditorPart
}
private void setPageLater() {
- Display.getCurrent().timerExec(1000, new Runnable() {
- @Override
- public void run() {
- synchronized(CompareEditor.this) {
- if (getState() == INITIALIZING) {
- setState(STILL_INITIALIZING);
- createCompareControl();
- }
+ Display.getCurrent().timerExec(1000, () -> {
+ synchronized(CompareEditor.this) {
+ if (getState() == INITIALIZING) {
+ setState(STILL_INITIALIZING);
+ createCompareControl();
}
}
});
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java
index 8127c1498..41d9d315d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,7 +46,7 @@ public class CompareEditorInputNavigator extends CompareNavigator {
@Override
protected INavigatable[] getNavigatables() {
- List result = new ArrayList();
+ List<INavigatable> result = new ArrayList<>();
Object[] panes = getPanes();
for (int i = 0; i < panes.length; i++) {
Object pane = panes[i];
@@ -54,12 +54,9 @@ public class CompareEditorInputNavigator extends CompareNavigator {
if (navigator != null)
result.add(navigator);
}
- return (INavigatable[]) result.toArray(new INavigatable[result.size()]);
+ return result.toArray(new INavigatable[result.size()]);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ICompareNavigator#selectChange(boolean)
- */
@Override
public boolean selectChange(boolean next) {
// Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java
index fc8702d28..e99514c97 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,26 +40,17 @@ import org.eclipse.jface.text.TextViewer;
public class CompareEditorSelectionProvider implements IPostSelectionProvider {
private class InternalListener implements ISelectionChangedListener, FocusListener {
- /*
- * @see ISelectionChangedListener#selectionChanged
- */
@Override
public void selectionChanged(SelectionChangedEvent event) {
doSelectionChanged(event);
}
- /*
- * @see FocusListener#focusGained
- */
@Override
public void focusGained(FocusEvent e) {
// expecting a StyledText widget here
doFocusChanged(e.widget);
}
- /*
- * @see FocusListener#focusLost
- */
@Override
public void focusLost(FocusEvent e) {
// do not reset due to focus behavior on GTK
@@ -78,12 +69,12 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider {
private TextViewer[] fViewers;
private TextViewer fViewerInFocus;
- private ListenerList fSelectionChangedListeners;
- private ListenerList fPostSelectionChangedListeners;
+ private ListenerList<ISelectionChangedListener> fSelectionChangedListeners;
+ private ListenerList<ISelectionChangedListener> fPostSelectionChangedListeners;
public CompareEditorSelectionProvider() {
- fSelectionChangedListeners = new ListenerList();
- fPostSelectionChangedListeners = new ListenerList();
+ fSelectionChangedListeners = new ListenerList<>();
+ fPostSelectionChangedListeners = new ListenerList<>();
// nothing more to do here, Compare Editor is initializing
}
@@ -141,9 +132,7 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider {
if (fSelectionChangedListeners != null) {
SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
- Object[] listeners= fSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
+ for (ISelectionChangedListener listener : fSelectionChangedListeners) {
listener.selectionChanged(event);
}
}
@@ -153,50 +142,32 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider {
if (fPostSelectionChangedListeners != null) {
SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
- Object[] listeners= fPostSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
+ for (ISelectionChangedListener listener: fPostSelectionChangedListeners) {
listener.selectionChanged(event);
}
}
}
- /*
- * @see ISelectionProvider#addSelectionChangedListener
- */
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
fSelectionChangedListeners.add(listener);
}
- /*
- * @see ISelectionProvider#removeSelectionChangedListener
- */
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
fSelectionChangedListeners.remove(listener);
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
@Override
public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
fPostSelectionChangedListeners.add(listener);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
@Override
public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
fPostSelectionChangedListeners.remove(listener);
}
- /*
- * @see ISelectionProvider#getSelection
- */
@Override
public ISelection getSelection() {
if (fViewerInFocus != null) {
@@ -205,9 +176,6 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider {
return TextSelection.emptySelection();
}
- /*
- * @see ISelectionProvider#setSelection
- */
@Override
public void setSelection(ISelection selection) {
setSelection(selection, true);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java
index aaefb69b3..92ef3f6ae 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,7 +37,7 @@ public class CompareFilterDescriptor {
private ResourceBundle fResourceBundle;
private ImageDescriptor fImageDescriptor;
- private class ConfigurationKeysEnumeration implements Enumeration {
+ private class ConfigurationKeysEnumeration implements Enumeration<String> {
private String[] keySet;
private int cursor = 0;
@@ -53,7 +53,7 @@ public class CompareFilterDescriptor {
}
@Override
- public Object nextElement() {
+ public String nextElement() {
return keySet[cursor++];
}
@@ -68,7 +68,7 @@ public class CompareFilterDescriptor {
}
@Override
- public Enumeration getKeys() {
+ public Enumeration<String> getKeys() {
return new ConfigurationKeysEnumeration(fConfiguration);
}
};
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java
index 085ebd839..db713533d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,11 +25,11 @@ import org.eclipse.ui.services.IServiceLocator;
public class CompareHandlerService {
- private final List fActivations = new ArrayList();
+ private final List<IHandlerActivation> fActivations = new ArrayList<>();
private final Expression fExpression;
private ICompareContainer fContainer;
private boolean fDisposed;
- private List fPaneActivations = new ArrayList();
+ private List<IHandlerActivation> fPaneActivations = new ArrayList<>();
private IHandlerService fHandlerService;
public static CompareHandlerService createFor(ICompareContainer container, Shell shell) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index 20c1f46c8..f192ad980 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,15 +33,8 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -174,32 +167,23 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
setPreferenceStore(CompareUIPlugin.getDefault().getPreferenceStore());
fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
- fPreferenceChangeListener= new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String key= event.getProperty();
- if (key.equals(INITIALLY_SHOW_ANCESTOR_PANE)) {
- boolean b= fOverlayStore.getBoolean(INITIALLY_SHOW_ANCESTOR_PANE);
- if (fCompareConfiguration != null) {
- fCompareConfiguration.setProperty(INITIALLY_SHOW_ANCESTOR_PANE, Boolean.valueOf(b));
- }
+ fPreferenceChangeListener= event -> {
+ String key= event.getProperty();
+ if (key.equals(INITIALLY_SHOW_ANCESTOR_PANE)) {
+ boolean b= fOverlayStore.getBoolean(INITIALLY_SHOW_ANCESTOR_PANE);
+ if (fCompareConfiguration != null) {
+ fCompareConfiguration.setProperty(INITIALLY_SHOW_ANCESTOR_PANE, Boolean.valueOf(b));
}
}
};
fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener);
}
- /*
- * @see IWorkbenchPreferencePage#init()
- */
@Override
public void init(IWorkbench workbench) {
// empty
}
- /*
- * @see PreferencePage#performOk()
- */
@Override
public boolean performOk() {
fOverlayStore.setValue(ADDED_LINES_REGEX, addedLinesRegex.getText());
@@ -214,9 +198,6 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
return true;
}
- /*
- * @see PreferencePage#performDefaults()
- */
@Override
protected void performDefaults() {
@@ -226,9 +207,6 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
super.performDefaults();
}
- /*
- * @see DialogPage#dispose()
- */
@Override
public void dispose() {
@@ -254,9 +232,6 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
store.setValue(PREF_SAVE_ALL_EDITORS, value);
}
- /*
- * @see PreferencePage#createContents(Composite)
- */
@Override
protected Control createContents(Composite parent) {
@@ -343,16 +318,13 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fFilters.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fFilters.setText(fOverlayStore.getString(PATH_FILTER));
fFilters.addModifyListener(
- new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- String filters= fFilters.getText();
- String message= CompareResourceFilter.validateResourceFilters(filters);
- setValid(message == null);
- setMessage(null);
- setErrorMessage(message);
- fOverlayStore.setValue(PATH_FILTER, filters);
- }
+ e -> {
+ String filters= fFilters.getText();
+ String message= CompareResourceFilter.validateResourceFilters(filters);
+ setValid(message == null);
+ setMessage(null);
+ setErrorMessage(message);
+ fOverlayStore.setValue(PATH_FILTER, filters);
}
);
@@ -438,12 +410,9 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
);
Control c= fPreviewViewer.getControl();
- c.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fCompareConfiguration != null)
- fCompareConfiguration.dispose();
- }
+ c.addDisposeListener(e -> {
+ if (fCompareConfiguration != null)
+ fCompareConfiguration.dispose();
});
return c;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java
index 1e1656b0f..bfc8282f0 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 IBM Corporation and others.
+ * Copyright (c) 2009, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -196,12 +196,7 @@ public class CompareStructureViewerSwitchingPane extends
menu.addMenuListener(new MenuAdapter() {
@Override
public void menuHidden(MenuEvent e) {
- e.display.asyncExec(new Runnable() {
- @Override
- public void run() {
- menu.dispose();
- }
- });
+ e.display.asyncExec(() -> menu.dispose());
}
});
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index cb2754e57..6d985b15e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,21 +17,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.StringTokenizer;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
@@ -66,7 +53,6 @@ import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
@@ -557,29 +543,26 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
private void internalOpenEditor(final CompareEditorInput input,
final IWorkbenchPage wp, final IReusableEditor editor,
final boolean activate) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- if (editor != null && !editor.getSite().getShell().isDisposed()) { // reuse the given editor
- editor.setInput(input);
- return;
- }
+ Runnable runnable = () -> {
+ if (editor != null && !editor.getSite().getShell().isDisposed()) { // reuse the given editor
+ editor.setInput(input);
+ return;
+ }
- IWorkbenchPage page = wp;
- if (page == null)
- page= getActivePage();
- if (page != null) {
- // open new CompareEditor on page
- try {
- page.openEditor(input, COMPARE_EDITOR, activate);
- } catch (PartInitException e) {
- MessageDialog.openError(getShell(), Utilities.getString("CompareUIPlugin.openEditorError"), e.getMessage()); //$NON-NLS-1$
- }
- } else {
- MessageDialog.openError(getShell(),
- Utilities.getString("CompareUIPlugin.openEditorError"), //$NON-NLS-1$
- Utilities.getString("CompareUIPlugin.noActiveWorkbenchPage")); //$NON-NLS-1$
+ IWorkbenchPage page = wp;
+ if (page == null)
+ page= getActivePage();
+ if (page != null) {
+ // open new CompareEditor on page
+ try {
+ page.openEditor(input, COMPARE_EDITOR, activate);
+ } catch (PartInitException e) {
+ MessageDialog.openError(getShell(), Utilities.getString("CompareUIPlugin.openEditorError"), e.getMessage()); //$NON-NLS-1$
}
+ } else {
+ MessageDialog.openError(getShell(),
+ Utilities.getString("CompareUIPlugin.openEditorError"), //$NON-NLS-1$
+ Utilities.getString("CompareUIPlugin.noActiveWorkbenchPage")); //$NON-NLS-1$
}
};
syncExec(runnable);
@@ -914,12 +897,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
}
ArrayList<CompareFilterDescriptor> list = new ArrayList<>(result);
- Collections.sort(list, new Comparator<CompareFilterDescriptor>() {
- @Override
- public int compare(CompareFilterDescriptor left, CompareFilterDescriptor right) {
- return left.getFilterId().compareTo(right.getFilterId());
- }
- });
+ Collections.sort(list, (left, right) -> left.getFilterId().compareTo(right.getFilterId()));
return result.toArray(new CompareFilterDescriptor[result.size()]);
}
@@ -1387,12 +1365,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
fFilter= new CompareResourceFilter();
final IPreferenceStore ps= getPreferenceStore();
fFilter.setFilters(ps.getString(ComparePreferencePage.PATH_FILTER));
- fPropertyChangeListener= new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (ComparePreferencePage.PATH_FILTER.equals(event.getProperty()))
- fFilter.setFilters(ps.getString(ComparePreferencePage.PATH_FILTER));
- }
+ fPropertyChangeListener= event -> {
+ if (ComparePreferencePage.PATH_FILTER.equals(event.getProperty()))
+ fFilter.setFilters(ps.getString(ComparePreferencePage.PATH_FILTER));
};
ps.addPropertyChangeListener(fPropertyChangeListener);
}
@@ -1400,14 +1375,11 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
}
private void internalOpenDialog(final CompareEditorInput input) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- CompareDialog dialog = new CompareDialog(PlatformUI
- .getWorkbench().getModalDialogShellProvider()
- .getShell(), input);
- dialog.open();
- }
+ Runnable runnable = () -> {
+ CompareDialog dialog = new CompareDialog(PlatformUI
+ .getWorkbench().getModalDialogShellProvider()
+ .getShell(), input);
+ dialog.open();
};
syncExec(runnable);
}
@@ -1423,12 +1395,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
//---- more utilities
protected void handleNoDifference() {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- MessageDialog.openInformation(getShell(), Utilities.getString("CompareUIPlugin.dialogTitle"), Utilities.getString("CompareUIPlugin.noDifferences")); //$NON-NLS-1$//$NON-NLS-2$
- }
- };
+ Runnable runnable = () -> MessageDialog.openInformation(getShell(), Utilities.getString("CompareUIPlugin.dialogTitle"), Utilities.getString("CompareUIPlugin.noDifferences"));
syncExec(runnable);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
index b2d279da0..6b3d1cee7 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Aleksandra Wozniak and others.
+ * Copyright (c) 2008, 2017 Aleksandra Wozniak and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -44,22 +44,11 @@ import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.*;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
@@ -270,12 +259,9 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
super.createText(parent);
text.setEditable(true);
- text.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- section.setResource(text.getText());
- updateErrorInfo();
- }
+ text.addModifyListener(e -> {
+ section.setResource(text.getText());
+ updateErrorInfo();
});
text.addSelectionListener(new SelectionListener() {
@@ -421,16 +407,13 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
final ContentTypeElement[] elements = new ContentTypeElement[] { workspaceContent,
externalFileContent, externalFolderContent };
for (int i = 0; i < elements.length; i++) {
- elements[i].getRadioButton().addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- for (int j = 0; j < elements.length; j++) {
- if (event.widget != elements[j].getRadioButton())
- elements[j].setEnabled(false);
- else {
- elements[j].setEnabled(true);
- setResource(elements[j].getResource());
- }
+ elements[i].getRadioButton().addListener(SWT.Selection, event -> {
+ for (int j = 0; j < elements.length; j++) {
+ if (event.widget != elements[j].getRadioButton())
+ elements[j].setEnabled(false);
+ else {
+ elements[j].setEnabled(true);
+ setResource(elements[j].getResource());
}
}
});
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java
index 155e50f45..b9c220131 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,26 +22,20 @@ import org.eclipse.swt.widgets.Display;
*/
public class ContentChangeNotifier implements IContentChangeNotifier {
- private ListenerList fListenerList;
+ private ListenerList<IContentChangeListener> fListenerList;
private final IContentChangeNotifier element;
public ContentChangeNotifier(IContentChangeNotifier element) {
this.element = element;
}
- /* (non-Javadoc)
- * see IContentChangeNotifier.addChangeListener
- */
@Override
public void addContentChangeListener(IContentChangeListener listener) {
if (fListenerList == null)
- fListenerList= new ListenerList();
+ fListenerList= new ListenerList<>();
fListenerList.add(listener);
}
- /* (non-Javadoc)
- * see IContentChangeNotifier.removeChangeListener
- */
@Override
public void removeContentChangeListener(IContentChangeListener listener) {
if (fListenerList != null) {
@@ -59,23 +53,18 @@ public class ContentChangeNotifier implements IContentChangeNotifier {
return;
}
// Legacy listeners may expect to be notified in the UI thread.
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- Object[] listeners= fListenerList.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- final IContentChangeListener contentChangeListener = (IContentChangeListener)listeners[i];
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void run() throws Exception {
- contentChangeListener.contentChanged(element);
- }
- @Override
- public void handleException(Throwable exception) {
- // Logged by safe runner
- }
- });
- }
+ Runnable runnable = () -> {
+ for (final IContentChangeListener contentChangeListener : fListenerList) {
+ SafeRunner.run(new ISafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ contentChangeListener.contentChanged(element);
+ }
+ @Override
+ public void handleException(Throwable exception) {
+ // Logged by safe runner
+ }
+ });
}
};
if (Display.getCurrent() == null) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java
index 3fc20f1c1..0d1c99590 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,14 +21,14 @@ public class DocumentManager {
private static final boolean DEBUG= false;
- private static ArrayList fgKeys= new ArrayList();
- private static ArrayList fgValues= new ArrayList();
+ private static ArrayList<Object> fgKeys= new ArrayList<>();
+ private static ArrayList<IDocument> fgValues= new ArrayList<>();
public static IDocument get(Object o) {
for (int i= 0; i < fgKeys.size(); i++) {
if (fgKeys.get(i) == o)
- return (IDocument) fgValues.get(i);
+ return fgValues.get(i);
}
return null;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java
index a18b609a0..e7befa2c9 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageCanvas.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,35 +32,15 @@ class ImageCanvas extends Canvas {
ScrollBar sb= getHorizontalBar();
sb.setIncrement(20);
- sb.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- repaint();
- }
- });
+ sb.addListener(SWT.Selection, e -> repaint());
sb= getVerticalBar();
sb.setIncrement(20);
- sb.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- repaint();
- }
- });
-
- addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event e) {
- updateScrollbars();
- }
- });
-
- addListener(SWT.Paint, new Listener() {
- @Override
- public void handleEvent(Event event) {
- paint(event.gc);
- }
- });
+ sb.addListener(SWT.Selection, e -> repaint());
+
+ addListener(SWT.Resize, e -> updateScrollbars());
+
+ addListener(SWT.Paint, event -> paint(event.gc));
}
/*
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
index 9de69fd18..2887708b1 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -295,9 +295,6 @@ public class MergeSourceViewer implements ISelectionChangedListener,
selectAndReveal(start, length, start, length);
}
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#selectAndReveal(int, int, int, int)
- */
private void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) {
ISelection selection = getSelectionProvider().getSelection();
@@ -320,16 +317,10 @@ public class MergeSourceViewer implements ISelectionChangedListener,
widget.setRedraw(true);
}
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#markInNavigationHistory()
- */
private void markInNavigationHistory() {
getSite().getPage().getNavigationHistory().markLocation(this);
}
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#adjustHighlightRange(int, int)
- */
private void adjustHighlightRange(int offset, int length) {
if (MergeSourceViewer.this instanceof ITextViewerExtension5) {
@@ -340,9 +331,6 @@ public class MergeSourceViewer implements ISelectionChangedListener,
}
}
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#isVisible(ISourceViewer, int, int)
- */
private /*static*/ final boolean isVisible(ITextViewer viewer, int offset, int length) {
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
@@ -448,7 +436,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
// defining interface method
return null;
}
@@ -487,7 +475,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
private SourceViewer fSourceViewer;
private Position fRegion;
private boolean fEnabled= true;
- private HashMap fActions= new HashMap();
+ private HashMap<String, IAction> fActions= new HashMap<>();
private IDocument fRememberedDocument;
private boolean fAddSaveAction= true;
@@ -497,7 +485,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
private IPropertyChangeListener fPreferenceChangeListener;
private boolean fShowLineNumber=false;
private LineNumberRulerColumn fLineNumberColumn;
- private List textActions = new ArrayList();
+ private List<IAction> textActions = new ArrayList<>();
private CommandContributionItem fSaveContributionItem;
public MergeSourceViewer(SourceViewer sourceViewer, ResourceBundle bundle, ICompareContainer container) {
@@ -514,12 +502,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
fContainer.registerContextMenu(menu, getSourceViewer());
// for listening to editor show/hide line number preference value
- fPreferenceChangeListener= new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- MergeSourceViewer.this.handlePropertyChangeEvent(event);
- }
- };
+ fPreferenceChangeListener= event -> MergeSourceViewer.this.handlePropertyChangeEvent(event);
EditorsUI.getPreferenceStore().addPropertyChangeListener(fPreferenceChangeListener);
fShowLineNumber= EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);
if(fShowLineNumber){
@@ -773,7 +756,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
}
public IAction getAction(String actionId) {
- IAction action= (IAction) fActions.get(actionId);
+ IAction action= fActions.get(actionId);
if (action == null) {
action= createAction(actionId);
if (action == null)
@@ -818,9 +801,9 @@ public class MergeSourceViewer implements ISelectionChangedListener,
@Override
public void selectionChanged(SelectionChangedEvent event) {
- Iterator e= fActions.values().iterator();
+ Iterator<IAction> e= fActions.values().iterator();
while (e.hasNext()) {
- Object next = e.next();
+ IAction next = e.next();
if (next instanceof MergeViewerAction) {
MergeViewerAction action = (MergeViewerAction) next;
if (action.isSelectionDependent())
@@ -835,9 +818,9 @@ public class MergeSourceViewer implements ISelectionChangedListener,
}
void updateContentDependantActions() {
- Iterator e= fActions.values().iterator();
+ Iterator<IAction> e= fActions.values().iterator();
while (e.hasNext()) {
- Object next = e.next();
+ IAction next = e.next();
if (next instanceof MergeViewerAction) {
MergeViewerAction action = (MergeViewerAction) next;
if (action.isContentDependent())
@@ -875,8 +858,8 @@ public class MergeSourceViewer implements ISelectionChangedListener,
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator("text")); //$NON-NLS-1$
- for (Iterator iterator = textActions.iterator(); iterator.hasNext();) {
- IAction action = (IAction) iterator.next();
+ for (Iterator<IAction> iterator = textActions.iterator(); iterator.hasNext();) {
+ IAction action = iterator.next();
menu.add(action);
}
@@ -933,9 +916,9 @@ public class MergeSourceViewer implements ISelectionChangedListener,
*
*/
public void updateActions() {
- Iterator e= fActions.values().iterator();
+ Iterator<IAction> e= fActions.values().iterator();
while (e.hasNext()) {
- Object next = e.next();
+ IAction next = e.next();
if (next instanceof MergeViewerAction) {
MergeViewerAction action = (MergeViewerAction) next;
action.update();
@@ -1076,12 +1059,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
// when the undo history changes. It could be localized to UNDO and REDO.
IUndoContext context = getUndoContext();
if (context != null && event.getOperation().hasContext(context)) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- updateContentDependantActions();
- }
- });
+ Display.getDefault().asyncExec(() -> updateContentDependantActions());
}
}
@@ -1099,10 +1077,11 @@ public class MergeSourceViewer implements ISelectionChangedListener,
return fSourceViewer;
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == ITextEditor.class) {
- return new TextEditorAdapter();
+ return (T) new TextEditorAdapter();
}
return null;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java
index 78686a560..d34913b70 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,7 +29,7 @@ public abstract class OutlineViewerCreator {
*/
public static final String PROP_INPUT = "org.eclipse.compare.OutlineInput"; //$NON-NLS-1$
- private ListenerList listeners = new ListenerList(ListenerList.IDENTITY);
+ private ListenerList<IPropertyChangeListener> listeners = new ListenerList<>(ListenerList.IDENTITY);
/**
* Method called by the editor to create a structure viewer for the current content merge viewer.
@@ -53,10 +53,8 @@ public abstract class OutlineViewerCreator {
}
public void fireInputChange(Object oldInput, Object newInput) {
- Object[] list = listeners.getListeners();
final PropertyChangeEvent event = new PropertyChangeEvent(this, PROP_INPUT, oldInput, newInput);
- for (int i = 0; i < list.length; i++) {
- final IPropertyChangeListener listener = (IPropertyChangeListener)list[i];
+ for (final IPropertyChangeListener listener : listeners) {
SafeRunner.run(new ISafeRunnable() {
@Override
public void run() throws Exception {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java
index 5f4058035..3c85544bd 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Google, Inc and others.
+ * Copyright (c) 2015, 2017 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
/**
@@ -21,11 +20,8 @@ public class Policy {
// Debug flags
public static boolean debugContentMergeViewer = false;
- static final DebugOptionsListener DEBUG_OPTIONS_LISTENER = new DebugOptionsListener() {
- @Override
- public void optionsChanged(DebugOptions options) {
- boolean DEBUG = options.getBooleanOption(CompareUIPlugin.PLUGIN_ID + "/debug", false); //$NON-NLS-1$
- debugContentMergeViewer = DEBUG && options.getBooleanOption(CompareUIPlugin.PLUGIN_ID + "/content_merge_viewer", false); //$NON-NLS-1$
- }
+ static final DebugOptionsListener DEBUG_OPTIONS_LISTENER = options -> {
+ boolean DEBUG = options.getBooleanOption(CompareUIPlugin.PLUGIN_ID + "/debug", false); //$NON-NLS-1$
+ debugContentMergeViewer = DEBUG && options.getBooleanOption(CompareUIPlugin.PLUGIN_ID + "/content_merge_viewer", false); //$NON-NLS-1$
};
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
index caa32774a..cec5869dd 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -497,29 +497,27 @@ class ResourceCompareInput extends CompareEditorInput {
}
}
- /* (non Javadoc)
- * see IAdaptable.getAdapter
- */
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (IFile.class.equals(adapter)) {
IProgressMonitor pm= new NullProgressMonitor();
// flush changes in any dirty viewer
flushViewers(pm);
- IFile[] files= (IFile[]) getAdapter(IFile[].class);
+ IFile[] files= getAdapter(IFile[].class);
if (files != null && files.length > 0)
- return files[0]; // can only return one: limitation on IDE.saveAllEditors; see #64617
+ return (T) files[0]; // can only return one: limitation on IDE.saveAllEditors; see #64617
return null;
}
if (IFile[].class.equals(adapter)) {
- HashSet collector= new HashSet();
+ HashSet<IFile> collector= new HashSet<>();
collectDirtyResources(fRoot, collector);
- return collector.toArray(new IFile[collector.size()]);
+ return (T) collector.toArray(new IFile[collector.size()]);
}
return super.getAdapter(adapter);
}
- private void collectDirtyResources(Object o, Set collector) {
+ private void collectDirtyResources(Object o, Set<IFile> collector) {
if (o instanceof DiffNode) {
DiffNode node= (DiffNode) o;
@@ -529,7 +527,7 @@ class ResourceCompareInput extends CompareEditorInput {
if (bn.isDirty()) {
IResource resource= bn.getResource();
if (resource instanceof IFile)
- collector.add(resource);
+ collector.add((IFile) resource);
}
}
@@ -539,7 +537,7 @@ class ResourceCompareInput extends CompareEditorInput {
if (bn.isDirty()) {
IResource resource= bn.getResource();
if (resource instanceof IFile)
- collector.add(resource);
+ collector.add((IFile) resource);
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
index 0767de353..ebf70c91a 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,7 +23,7 @@ import org.eclipse.ui.texteditor.AbstractTextEditor;
public class ShowWhitespaceAction extends TextEditorPropertyAction {
- private Map fPainters;
+ private Map<MergeSourceViewer, WhitespaceCharacterPainter> fPainters;
private boolean isWhitespaceShowing;
private boolean[] fNeedsPainters;
/** @since 3.7 */
@@ -119,9 +119,9 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction {
return true;
}
- private synchronized Map getPainters() {
+ private synchronized Map<MergeSourceViewer, WhitespaceCharacterPainter> getPainters() {
if (fPainters == null)
- fPainters = new HashMap();
+ fPainters = new HashMap<>();
return fPainters;
}
@@ -129,7 +129,7 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction {
if (isWhitespaceShowing)
return;
try {
- Map painters = getPainters();
+ Map<MergeSourceViewer, WhitespaceCharacterPainter> painters = getPainters();
MergeSourceViewer[] viewers = getViewers();
for (int i = 0; i < viewers.length; i++) {
if (fNeedsPainters[i]) {
@@ -152,10 +152,10 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction {
}
private void hideWhitespace() {
- Map painters = getPainters();
- for (Iterator iterator = painters.keySet().iterator(); iterator.hasNext();) {
- MergeSourceViewer viewer = (MergeSourceViewer) iterator.next();
- WhitespaceCharacterPainter painter = (WhitespaceCharacterPainter)painters.get(viewer);
+ Map<MergeSourceViewer, WhitespaceCharacterPainter> painters = getPainters();
+ for (Iterator<MergeSourceViewer> iterator = painters.keySet().iterator(); iterator.hasNext();) {
+ MergeSourceViewer viewer = iterator.next();
+ WhitespaceCharacterPainter painter = painters.get(viewer);
if (painter != null) {
viewer.getSourceViewer().removePainter(painter);
painter.deactivate(true);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
index 89d3b4dc1..c99c59c28 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -66,7 +66,6 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -165,12 +164,9 @@ public class Utilities {
if (listenerList == null || listenerList.isEmpty())
return;
// Legacy listeners may expect to get notified in the UI thread
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- for (IPropertyChangeListener listener : listenerList) {
- SafeRunner.run(() -> listener.propertyChange(event));
- }
+ Runnable runnable = () -> {
+ for (IPropertyChangeListener listener : listenerList) {
+ SafeRunner.run(() -> listener.propertyChange(event));
}
};
if (Display.getCurrent() == null) {
@@ -565,12 +561,7 @@ public class Utilities {
if (Display.getCurrent() != null) {
ErrorDialog.openError(shell, title, message, status);
} else {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog.openError(shell, title, message, status);
- }
- });
+ Display.getDefault().syncExec(() -> ErrorDialog.openError(shell, title, message, status));
}
}
@@ -804,12 +795,7 @@ public class Utilities {
if (Display.getCurrent() != null) {
BusyIndicator.showWhile(Display.getCurrent(), runnable);
} else {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- BusyIndicator.showWhile(Display.getCurrent(), runnable);
- }
- });
+ Display.getDefault().syncExec(() -> BusyIndicator.showWhile(Display.getCurrent(), runnable));
}
}
@@ -850,28 +836,25 @@ public class Utilities {
throws InvocationTargetException, OperationCanceledException,
InterruptedException {
final String[] result = new String[1];
- context.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- SubMonitor progress = SubMonitor.convert(monitor,
- PatchMessages.InputPatchPage_URLConnecting, 100);
- try {
- URLConnection connection = url.openConnection();
- progress.worked(10);
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- setReadTimeout(connection, 60 * 1000);
- progress.setTaskName(PatchMessages.InputPatchPage_URLFetchingContent);
- String enc = connection.getContentEncoding();
- if (enc == null)
- enc = ResourcesPlugin.getEncoding();
- result[0] = Utilities.readString(
- connection.getInputStream(), enc,
- connection.getContentLength(),
- progress.newChild(90));
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- }
+ context.run(true, true, monitor -> {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ PatchMessages.InputPatchPage_URLConnecting, 100);
+ try {
+ URLConnection connection = url.openConnection();
+ progress.worked(10);
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
+ setReadTimeout(connection, 60 * 1000);
+ progress.setTaskName(PatchMessages.InputPatchPage_URLFetchingContent);
+ String enc = connection.getContentEncoding();
+ if (enc == null)
+ enc = ResourcesPlugin.getEncoding();
+ result[0] = Utilities.readString(
+ connection.getInputStream(), enc,
+ connection.getContentLength(),
+ progress.newChild(90));
+ } catch (IOException e) {
+ throw new InvocationTargetException(e);
}
});
return result[0];
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java
index 55b3a07fe..3e7990ae8 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,7 +22,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
*/
public class WorkQueue {
- private List runnables = new ArrayList();
+ private List<IRunnableWithProgress> runnables = new ArrayList<>();
public boolean add(IRunnableWithProgress runnable) {
if (runnables.contains(runnable))
@@ -50,7 +50,7 @@ public class WorkQueue {
return runnables.size();
}
public IRunnableWithProgress remove() {
- return (IRunnableWithProgress)runnables.remove(0);
+ return runnables.remove(0);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java
index 2ba246b51..678ff4891 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,12 +41,12 @@ public class WorkerJob extends Job {
return Status.OK_STATUS;
if (errors.length == 1)
return new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, errors[0].getMessage(), errors[0]);
- List statii = new ArrayList();
+ List<IStatus> statii = new ArrayList<>();
for (int i = 0; i < errors.length; i++) {
Throwable throwable = errors[i];
statii.add(new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, errors[0].getMessage(), throwable));
}
- return new MultiStatus(CompareUIPlugin.PLUGIN_ID, 0, (IStatus[]) statii.toArray(new IStatus[statii.size()]), CompareMessages.WorkerJob_0, null);
+ return new MultiStatus(CompareUIPlugin.PLUGIN_ID, 0, statii.toArray(new IStatus[statii.size()]), CompareMessages.WorkerJob_0, null);
}
@Override
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
index d16424ca6..ef1ce78b4 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,46 +12,22 @@
package org.eclipse.compare.internal.merge;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
+import java.util.*;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.ICompareFilter;
import org.eclipse.compare.contentmergeviewer.ITokenComparator;
-import org.eclipse.compare.internal.CompareContentViewerSwitchingPane;
-import org.eclipse.compare.internal.CompareMessages;
-import org.eclipse.compare.internal.ComparePreferencePage;
-import org.eclipse.compare.internal.CompareUIPlugin;
-import org.eclipse.compare.internal.DocLineComparator;
-import org.eclipse.compare.internal.MergeViewerContentProvider;
-import org.eclipse.compare.internal.Utilities;
+import org.eclipse.compare.internal.*;
import org.eclipse.compare.internal.core.LCS;
-import org.eclipse.compare.rangedifferencer.IRangeComparator;
-import org.eclipse.compare.rangedifferencer.RangeDifference;
-import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.compare.rangedifferencer.*;
import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
/**
* A document merger manages the differences between two documents
@@ -70,9 +46,9 @@ public class DocumentMerger {
private static final boolean APPEND_CONFLICT= true;
/** All diffs for calculating scrolling position (includes line ranges without changes) */
- private ArrayList fAllDiffs;
+ private ArrayList<Diff> fAllDiffs;
/** Subset of above: just real differences. */
- private ArrayList fChangeDiffs;
+ private ArrayList<Diff> fChangeDiffs;
private IDocumentMergerInput fInput;
@@ -242,9 +218,9 @@ public class DocumentMerger {
public boolean isResolved() {
if (!fResolved && fDiffs != null) {
- Iterator e= fDiffs.iterator();
+ Iterator<Diff> e= fDiffs.iterator();
while (e.hasNext()) {
- Diff d= (Diff) e.next();
+ Diff d= e.next();
if (!d.isResolved())
return false;
}
@@ -304,14 +280,14 @@ public class DocumentMerger {
public Diff[] getChangeDiffs(int contributor, IRegion region) {
if (fDiffs != null && intersectsRegion(contributor, region)) {
- List result = new ArrayList();
- for (Iterator iterator = fDiffs.iterator(); iterator.hasNext();) {
- Diff diff = (Diff) iterator.next();
+ List<Diff> result = new ArrayList<>();
+ for (Iterator<Diff> iterator = fDiffs.iterator(); iterator.hasNext();) {
+ Diff diff = iterator.next();
if (diff.intersectsRegion(contributor, region)) {
result.add(diff);
}
}
- return (Diff[]) result.toArray(new Diff[result.size()]);
+ return result.toArray(new Diff[result.size()]);
}
return new Diff[0];
}
@@ -339,9 +315,9 @@ public class DocumentMerger {
return fParent;
}
- public Iterator childIterator() {
+ public Iterator<Diff> childIterator() {
if (fDiffs == null)
- return new ArrayList().iterator();
+ return new ArrayList<Diff>().iterator();
return fDiffs.iterator();
}
}
@@ -357,7 +333,7 @@ public class DocumentMerger {
*/
public void doDiff() throws CoreException {
- fChangeDiffs= new ArrayList();
+ fChangeDiffs= new ArrayList<>();
IDocument lDoc = getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR);
IDocument rDoc = getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR);
@@ -403,21 +379,18 @@ public class DocumentMerger {
final Object[] result= new Object[1];
final DocLineComparator sa= sancestor, sl= sleft, sr= sright;
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- monitor.beginTask(CompareMessages.DocumentMerger_0, maxWork(sa, sl, sr));
- try {
- result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr);
- } catch (OutOfMemoryError ex) {
- System.gc();
- throw new InvocationTargetException(ex);
- }
- if (monitor.isCanceled()) { // canceled
- throw new InterruptedException();
- }
- monitor.done();
+ IRunnableWithProgress runnable= monitor -> {
+ monitor.beginTask(CompareMessages.DocumentMerger_0, maxWork(sa, sl, sr));
+ try {
+ result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr);
+ } catch (OutOfMemoryError ex) {
+ System.gc();
+ throw new InvocationTargetException(ex);
}
+ if (monitor.isCanceled()) { // canceled
+ throw new InterruptedException();
+ }
+ monitor.done();
};
RangeDifference[] e= null;
@@ -431,7 +404,7 @@ public class DocumentMerger {
lDoc, lRegion, 0, lDoc.getLength(),
rDoc, rRegion, 0, rDoc.getLength());
- fAllDiffs = new ArrayList();
+ fAllDiffs = new ArrayList<>();
fAllDiffs.add(diff);
throw new CoreException(new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, CompareMessages.DocumentMerger_1, ex.getTargetException()));
} catch (InterruptedException ex) {
@@ -441,7 +414,7 @@ public class DocumentMerger {
lDoc, lRegion, 0, lDoc.getLength(),
rDoc, rRegion, 0, rDoc.getLength());
- fAllDiffs = new ArrayList();
+ fAllDiffs = new ArrayList<>();
fAllDiffs.add(diff);
return;
}
@@ -455,7 +428,7 @@ public class DocumentMerger {
CompareContentViewerSwitchingPane.OPTIMIZED_ALGORITHM_USED,
Boolean.FALSE);
- ArrayList newAllDiffs = new ArrayList();
+ ArrayList<Diff> newAllDiffs = new ArrayList<>();
for (int i= 0; i < e.length; i++) {
RangeDifference es= e[i];
@@ -569,21 +542,18 @@ public class DocumentMerger {
final Object[] result= new Object[1];
final DocLineComparator sa= sancestor, sl= sleft, sr= sright;
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- monitor.beginTask(CompareMessages.DocumentMerger_2, maxWork(sa, sl, sr));
- try {
- result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr);
- } catch (OutOfMemoryError ex) {
- System.gc();
- throw new InvocationTargetException(ex);
- }
- if (monitor.isCanceled()) { // canceled
- throw new InterruptedException();
- }
- monitor.done();
+ IRunnableWithProgress runnable= monitor -> {
+ monitor.beginTask(CompareMessages.DocumentMerger_2, maxWork(sa, sl, sr));
+ try {
+ result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr);
+ } catch (OutOfMemoryError ex) {
+ System.gc();
+ throw new InvocationTargetException(ex);
+ }
+ if (monitor.isCanceled()) { // canceled
+ throw new InterruptedException();
}
+ monitor.done();
};
IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
@@ -986,8 +956,8 @@ public class DocumentMerger {
}
public Diff findDiff(Position p, boolean left) {
- for (Iterator iterator = fAllDiffs.iterator(); iterator.hasNext();) {
- Diff diff = (Diff) iterator.next();
+ for (Iterator<Diff> iterator = fAllDiffs.iterator(); iterator.hasNext();) {
+ Diff diff = iterator.next();
Position diffPos;
if (left) {
diffPos = diff.fLeftPos;
@@ -1024,9 +994,9 @@ public class DocumentMerger {
int virtualPos= 0; // virtual position
Point region= new Point(0, 0);
- Iterator e= fAllDiffs.iterator();
+ Iterator<Diff> e= fAllDiffs.iterator();
while (e.hasNext()) {
- Diff diff= (Diff) e.next();
+ Diff diff= e.next();
Position pos= diff.getPosition(contributor);
getLineRange(getDocument(contributor),pos, region);
int realHeight= region.y;
@@ -1061,9 +1031,9 @@ public class DocumentMerger {
int viewPos= 0;
Point region= new Point(0, 0);
- Iterator e= fAllDiffs.iterator();
+ Iterator<Diff> e= fAllDiffs.iterator();
while (e.hasNext()) {
- Diff diff= (Diff) e.next();
+ Diff diff= e.next();
Position pos= diff.getPosition(contributor);
int viewHeight= getLineRange(getDocument(contributor), pos, region).y;
int virtualHeight= diff.getMaxDiffHeight();
@@ -1088,9 +1058,9 @@ public class DocumentMerger {
public int getVirtualHeight() {
int h= 1;
if (fAllDiffs != null) {
- Iterator e= fAllDiffs.iterator();
+ Iterator<Diff> e= fAllDiffs.iterator();
while (e.hasNext()) {
- Diff diff= (Diff) e.next();
+ Diff diff= e.next();
h+= diff.getMaxDiffHeight();
}
}
@@ -1103,9 +1073,9 @@ public class DocumentMerger {
public int getRightHeight() {
int h= 1;
if (fAllDiffs != null) {
- Iterator e= fAllDiffs.iterator();
+ Iterator<Diff> e= fAllDiffs.iterator();
while (e.hasNext()) {
- Diff diff= (Diff) e.next();
+ Diff diff= e.next();
h+= diff.getRightHeight();
}
}
@@ -1135,16 +1105,16 @@ public class DocumentMerger {
public Diff[] getChangeDiffs(char contributor, IRegion region) {
if (fChangeDiffs == null)
return new Diff[0];
- List intersectingDiffs = new ArrayList();
- for (Iterator iterator = fChangeDiffs.iterator(); iterator.hasNext();) {
- Diff diff = (Diff) iterator.next();
+ List<Diff> intersectingDiffs = new ArrayList<>();
+ for (Iterator<Diff> iterator = fChangeDiffs.iterator(); iterator.hasNext();) {
+ Diff diff = iterator.next();
Diff[] changeDiffs = diff.getChangeDiffs(contributor, region);
for (int i = 0; i < changeDiffs.length; i++) {
Diff changeDiff = changeDiffs[i];
intersectingDiffs.add(changeDiff);
}
}
- return (Diff[]) intersectingDiffs.toArray(new Diff[intersectingDiffs.size()]);
+ return intersectingDiffs.toArray(new Diff[intersectingDiffs.size()]);
}
public Diff findDiff(int viewportHeight, boolean synchronizedScrolling, Point size, int my) {
@@ -1155,9 +1125,9 @@ public class DocumentMerger {
int yy, hh;
int y= 0;
if (fAllDiffs != null) {
- Iterator e= fAllDiffs.iterator();
+ Iterator<Diff> e= fAllDiffs.iterator();
while (e.hasNext()) {
- Diff diff= (Diff) e.next();
+ Diff diff= e.next();
int h= synchronizedScrolling ? diff.getMaxDiffHeight()
: diff.getRightHeight();
if (useChange(diff.getKind()) && !diff.fIsWhitespace) {
@@ -1180,15 +1150,15 @@ public class DocumentMerger {
return fChangeDiffs != null && !fChangeDiffs.isEmpty();
}
- public Iterator changesIterator() {
+ public Iterator<Diff> changesIterator() {
if (fChangeDiffs == null)
- return new ArrayList().iterator();
+ return new ArrayList<Diff>().iterator();
return fChangeDiffs.iterator();
}
- public Iterator rangesIterator() {
+ public Iterator<Diff> rangesIterator() {
if (fAllDiffs == null)
- return new ArrayList().iterator();
+ return new ArrayList<Diff>().iterator();
return fAllDiffs.iterator();
}
@@ -1203,8 +1173,8 @@ public class DocumentMerger {
public Diff getWrappedDiff(Diff diff, boolean down) {
if (fChangeDiffs != null && fChangeDiffs.size() > 0) {
if (down)
- return (Diff) fChangeDiffs.get(0);
- return (Diff) fChangeDiffs.get(fChangeDiffs.size()-1);
+ return fChangeDiffs.get(0);
+ return fChangeDiffs.get(fChangeDiffs.size()-1);
}
return null;
}
@@ -1288,8 +1258,8 @@ public class DocumentMerger {
public Diff findDiff(char contributor, int rangeStart, int rangeEnd) {
if (hasChanges()) {
- for (Iterator iterator = changesIterator(); iterator.hasNext();) {
- Diff diff = (Diff) iterator.next();
+ for (Iterator<Diff> iterator = changesIterator(); iterator.hasNext();) {
+ Diff diff = iterator.next();
if (diff.isDeleted() || diff.getKind() == RangeDifference.NOCHANGE)
continue;
if (diff.overlaps(contributor, rangeStart, rangeEnd, getDocument(contributor).getLength()))
@@ -1309,11 +1279,11 @@ public class DocumentMerger {
return findNext(contributor, fChangeDiffs, start, end, deep);
}
- private Diff findNext(char contributor, List v, int start, int end, boolean deep) {
+ private Diff findNext(char contributor, List<Diff> v, int start, int end, boolean deep) {
if (v == null)
return null;
for (int i= 0; i < v.size(); i++) {
- Diff diff= (Diff) v.get(i);
+ Diff diff= v.get(i);
Position p= diff.getPosition(contributor);
if (p != null) {
int startOffset= p.getOffset();
@@ -1339,11 +1309,11 @@ public class DocumentMerger {
return findPrev(contributor, fChangeDiffs, start, end, deep);
}
- private Diff findPrev(char contributor, List v, int start, int end, boolean deep) {
+ private Diff findPrev(char contributor, List<Diff> v, int start, int end, boolean deep) {
if (v == null)
return null;
for (int i= v.size()-1; i >= 0; i--) {
- Diff diff= (Diff) v.get(i);
+ Diff diff= v.get(i);
Position p= diff.getPosition(contributor);
if (p != null) {
int startOffset= p.getOffset();
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java
index e39d9b4c6..f19c63d6b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,29 +25,23 @@ class LineComparator implements IRangeComparator {
BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding));
String line;
- ArrayList ar = new ArrayList();
+ ArrayList<String> ar = new ArrayList<>();
while ((line = br.readLine()) != null) {
ar.add(line);
}
// It is the responsibility of the caller to close the stream
- fLines = (String[]) ar.toArray(new String[ar.size()]);
+ fLines = ar.toArray(new String[ar.size()]);
}
String getLine(int ix) {
return fLines[ix];
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount()
- */
@Override
public int getRangeCount() {
return fLines.length;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int)
- */
@Override
public boolean rangesEqual(int thisIndex, IRangeComparator other,
int otherIndex) {
@@ -56,9 +50,6 @@ class LineComparator implements IRangeComparator {
return s1.equals(s2);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator)
- */
@Override
public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
return false;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DiffViewerComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DiffViewerComparator.java
index cd76bfca0..424dae582 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DiffViewerComparator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DiffViewerComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -35,25 +35,22 @@ public class DiffViewerComparator extends ViewerSorter {
}
@Override
- protected Comparator getComparator() {
- return new Comparator() {
- @Override
- public int compare(Object arg0, Object arg1) {
- String label0 = arg0 == null ? "" : arg0.toString(); //$NON-NLS-1$
- String label1 = arg1 == null ? "" : arg1.toString(); //$NON-NLS-1$
-
- // see org.eclipse.compare.internal.patch.Hunk.getDescription()
- String pattern = "\\d+,\\d+ -> \\d+,\\d+.*"; //$NON-NLS-1$
-
- if (Pattern.matches(pattern, label0)
- && Pattern.matches(pattern, label1)) {
- int oldStart0 = Integer.parseInt(label0.split(",")[0]); //$NON-NLS-1$
- int oldStart1 = Integer.parseInt(label1.split(",")[0]); //$NON-NLS-1$
-
- return oldStart0 - oldStart1;
- }
- return Policy.getComparator().compare(arg0, arg1);
+ protected Comparator<? super String> getComparator() {
+ return (arg0, arg1) -> {
+ String label0 = arg0 == null ? "" : arg0.toString(); //$NON-NLS-1$
+ String label1 = arg1 == null ? "" : arg1.toString(); //$NON-NLS-1$
+
+ // see org.eclipse.compare.internal.patch.Hunk.getDescription()
+ String pattern = "\\d+,\\d+ -> \\d+,\\d+.*"; //$NON-NLS-1$
+
+ if (Pattern.matches(pattern, label0)
+ && Pattern.matches(pattern, label1)) {
+ int oldStart0 = Integer.parseInt(label0.split(",")[0]); //$NON-NLS-1$
+ int oldStart1 = Integer.parseInt(label1.split(",")[0]); //$NON-NLS-1$
+
+ return oldStart0 - oldStart1;
}
+ return Policy.getComparator().compare(arg0, arg1);
};
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
index 3f45f8210..9a2d51362 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,18 +22,15 @@ import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -60,14 +57,7 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.*;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
@@ -456,14 +446,11 @@ public class InputPatchPage extends WizardPage {
updateWidgetEnablements();
}
});
- fPatchFileNameField.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- clearErrorMessage();
- fShowError= true;
- fPatchRead = false;
- updateWidgetEnablements();
- }
+ fPatchFileNameField.addModifyListener(e -> {
+ clearErrorMessage();
+ fShowError= true;
+ fPatchRead = false;
+ updateWidgetEnablements();
});
fPatchFileBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
@@ -486,14 +473,11 @@ public class InputPatchPage extends WizardPage {
updateWidgetEnablements();
}
});
- fPatchURLField.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- clearErrorMessage();
- fShowError = true;
- fPatchRead = false;
- updateWidgetEnablements();
- }
+ fPatchURLField.addModifyListener(e -> {
+ clearErrorMessage();
+ fShowError = true;
+ fPatchRead = false;
+ updateWidgetEnablements();
});
fUseWorkspaceButton.addSelectionListener(new SelectionAdapter() {
@Override
@@ -512,30 +496,24 @@ public class InputPatchPage extends WizardPage {
}
});
- fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- clearErrorMessage();
- updateWidgetEnablements();
- }
+ fTreeViewer.addSelectionChangedListener(event -> {
+ clearErrorMessage();
+ updateWidgetEnablements();
});
- fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- ISelection selection= event.getSelection();
- if (selection instanceof TreeSelection) {
- TreeSelection treeSel= (TreeSelection) selection;
- Object res= treeSel.getFirstElement();
- if (res != null) {
- if (res instanceof IProject || res instanceof IFolder) {
- if (fTreeViewer.getExpandedState(res))
- fTreeViewer.collapseToLevel(res, 1);
- else
- fTreeViewer.expandToLevel(res, 1);
- } else if (res instanceof IFile)
- fPatchWizard.showPage(getNextPage());
- }
+ fTreeViewer.addDoubleClickListener(event -> {
+ ISelection selection= event.getSelection();
+ if (selection instanceof TreeSelection) {
+ TreeSelection treeSel= (TreeSelection) selection;
+ Object res= treeSel.getFirstElement();
+ if (res != null) {
+ if (res instanceof IProject || res instanceof IFolder) {
+ if (fTreeViewer.getExpandedState(res))
+ fTreeViewer.collapseToLevel(res, 1);
+ else
+ fTreeViewer.expandToLevel(res, 1);
+ } else if (res instanceof IFile)
+ fPatchWizard.showPage(getNextPage());
}
}
});
@@ -1010,7 +988,7 @@ public class InputPatchPage extends WizardPage {
* @param newEntry the entry to add to the history
*/
protected static String[] addToHistory(String[] history, String newEntry) {
- java.util.ArrayList l= new java.util.ArrayList(java.util.Arrays.asList(history));
+ ArrayList<String> l= new ArrayList<>(Arrays.asList(history));
l.remove(newEntry);
l.add(0,newEntry);
@@ -1020,7 +998,7 @@ public class InputPatchPage extends WizardPage {
if (l.size() > COMBO_HISTORY_LENGTH)
l.remove(COMBO_HISTORY_LENGTH);
- return (String[]) l.toArray(new String[l.size()]);
+ return l.toArray(new String[l.size()]);
}
public boolean isPatchRead() {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java
index c5bfbdccb..a6cf5ee1e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,12 +13,7 @@ package org.eclipse.compare.internal.patch;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.CompareViewerPane;
-import org.eclipse.compare.IContentChangeListener;
-import org.eclipse.compare.IContentChangeNotifier;
+import org.eclipse.compare.*;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.ICompareUIConstants;
import org.eclipse.compare.internal.core.patch.DiffProject;
@@ -41,15 +36,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.*;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
@@ -272,13 +259,10 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput {
Object left = hunkNode.getLeft();
if (left instanceof UnmatchedHunkTypedElement) {
UnmatchedHunkTypedElement element = (UnmatchedHunkTypedElement) left;
- element.addContentChangeListener(new IContentChangeListener() {
- @Override
- public void contentChanged(IContentChangeNotifier source) {
- if (getViewer() == null || getViewer().getControl().isDisposed())
- return;
- getViewer().refresh(true);
- }
+ element.addContentChangeListener(source -> {
+ if (getViewer() == null || getViewer().getControl().isDisposed())
+ return;
+ getViewer().refresh(true);
});
}
} else if (showMatched) {
@@ -287,9 +271,6 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.CompareEditorInput#createDiffViewer(org.eclipse.swt.widgets.Composite)
- */
@Override
public Viewer createDiffViewer(Composite parent) {
viewer = new DiffTreeViewer(parent, getCompareConfiguration()){
@@ -301,25 +282,21 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput {
viewer.setLabelProvider(new PatcherCompareEditorLabelProvider((ILabelProvider)viewer.getLabelProvider()));
viewer.getTree().setData(CompareUI.COMPARE_VIEWER_TITLE, PatchMessages.PatcherCompareEditorInput_PatchContents);
- viewer.addOpenListener(new IOpenListener() {
- @Override
- public void open(OpenEvent event) {
- IStructuredSelection sel= (IStructuredSelection) event.getSelection();
- Object obj= sel.getFirstElement();
- if (obj instanceof HunkDiffNode) {
- if (((HunkDiffNode) obj).getHunkResult().isOK()) {
- getCompareConfiguration().setLeftLabel(PatchMessages.PatcherCompareEditorInput_LocalCopy);
- getCompareConfiguration().setRightLabel(PatchMessages.PreviewPatchPage2_MatchedHunk);
- } else {
- getCompareConfiguration().setLeftLabel(PatchMessages.PreviewPatchPage2_PatchedLocalFile);
- getCompareConfiguration().setRightLabel(PatchMessages.PreviewPatchPage2_OrphanedHunk);
- }
- } else {
+ viewer.addOpenListener(event -> {
+ IStructuredSelection sel= (IStructuredSelection) event.getSelection();
+ Object obj= sel.getFirstElement();
+ if (obj instanceof HunkDiffNode) {
+ if (((HunkDiffNode) obj).getHunkResult().isOK()) {
getCompareConfiguration().setLeftLabel(PatchMessages.PatcherCompareEditorInput_LocalCopy);
- getCompareConfiguration().setRightLabel(PatchMessages.PatcherCompareEditorInput_AfterPatch);
+ getCompareConfiguration().setRightLabel(PatchMessages.PreviewPatchPage2_MatchedHunk);
+ } else {
+ getCompareConfiguration().setLeftLabel(PatchMessages.PreviewPatchPage2_PatchedLocalFile);
+ getCompareConfiguration().setRightLabel(PatchMessages.PreviewPatchPage2_OrphanedHunk);
}
+ } else {
+ getCompareConfiguration().setLeftLabel(PatchMessages.PatcherCompareEditorInput_LocalCopy);
+ getCompareConfiguration().setRightLabel(PatchMessages.PatcherCompareEditorInput_AfterPatch);
}
-
});
viewer.setFilters(getFilters());
viewer.setInput(root);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
index 06c7ad733..8778a1b79 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -71,21 +71,11 @@ public class PatchFileTypedElement implements ITypedElement,
return image;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.compare.ITypedElement#getName()
- */
@Override
public String getName() {
return result.getTargetPath().toString();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.compare.ITypedElement#getType()
- */
@Override
public String getType() {
return result.getTargetPath().getFileExtension();
@@ -103,7 +93,7 @@ public class PatchFileTypedElement implements ITypedElement,
return new ByteArrayInputStream(getPatcher().getCachedContents(
result.getDiff()));
// Otherwise, get the lines from the diff result
- List lines;
+ List<String> lines;
if (isAfterState) {
lines = result.getAfterLines();
} else {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
index 954013e82..e2853256a 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,10 +20,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizardPage;
@@ -31,12 +27,7 @@ import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.*;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -93,21 +84,18 @@ public class PatchTargetPage extends WizardPage {
Dialog.applyDialogFont(composite);
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE);
- useWorkspaceAsTarget.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- fShowError = true;
- if (useWorkspaceAsTarget.getSelection()) {
- fPatchTargets.getTree().setEnabled(false);
- fPatcher.setTarget(ResourcesPlugin.getWorkspace().getRoot());
- } else {
- fPatchTargets.getTree().setEnabled(true);
- fPatcher.setTarget(Utilities.getFirstResource(fPatchTargets.getSelection()));
- }
- markPreviewPageToRecalucateIfNonWorkspacePatch();
- updateWidgetEnablements();
- }
- });
+ useWorkspaceAsTarget.addListener(SWT.Selection, event -> {
+ fShowError = true;
+ if (useWorkspaceAsTarget.getSelection()) {
+ fPatchTargets.getTree().setEnabled(false);
+ fPatcher.setTarget(ResourcesPlugin.getWorkspace().getRoot());
+ } else {
+ fPatchTargets.getTree().setEnabled(true);
+ fPatcher.setTarget(Utilities.getFirstResource(fPatchTargets.getSelection()));
+ }
+ markPreviewPageToRecalucateIfNonWorkspacePatch();
+ updateWidgetEnablements();
+ });
}
private void markPreviewPageToRecalucateIfNonWorkspacePatch() {
@@ -189,21 +177,13 @@ public class PatchTargetPage extends WizardPage {
}
// register listeners
- fPatchTargets.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- fShowError = true;
- fPatcher.setTarget(Utilities.getFirstResource(event.getSelection()));
- updateWidgetEnablements();
- }
+ fPatchTargets.addSelectionChangedListener(event -> {
+ fShowError = true;
+ fPatcher.setTarget(Utilities.getFirstResource(event.getSelection()));
+ updateWidgetEnablements();
});
- fPatchTargets.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- ((PatchWizard)getWizard()).showPage(getNextPage());
- }
- });
+ fPatchTargets.addDoubleClickListener(event -> ((PatchWizard)getWizard()).showPage(getNextPage()));
}
/**
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index 81b7d617c..cda13f343 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -88,9 +88,9 @@ public class Patcher implements IHunkFilter {
private IResource fTarget;
// patch options
private Set disabledElements = new HashSet();
- private Map diffResults = new HashMap();
- private final Map contentCache = new HashMap();
- private Set mergedHunks = new HashSet();
+ private Map<FilePatch2, FileDiffResult> diffResults = new HashMap<>();
+ private final Map<FilePatch2, byte[]> contentCache = new HashMap<>();
+ private Set<Hunk> mergedHunks = new HashSet<>();
private final PatchConfiguration configuration;
private boolean fGenerateRejectFile = false;
@@ -242,7 +242,7 @@ public class Patcher implements IHunkFilter {
}
// get all files to be modified in order to call validateEdit
- List list= new ArrayList();
+ List<IFile> list= new ArrayList<>();
if (singleFile != null)
list.add(singleFile);
else {
@@ -257,7 +257,7 @@ public class Patcher implements IHunkFilter {
}
}
}
- if (! validator.validateResources((IFile[])list.toArray(new IFile[list.size()]))) {
+ if (! validator.validateResources(list.toArray(new IFile[list.size()]))) {
return;
}
@@ -282,13 +282,13 @@ public class Patcher implements IHunkFilter {
? singleFile
: createPath(container, path);
- List failed= new ArrayList();
+ List<Hunk> failed= new ArrayList<>();
int type= diff.getDiffType(isReversed());
switch (type) {
case FilePatch2.ADDITION:
// patch it and collect rejected hunks
- List result= apply(diff, file, true, failed);
+ List<String> result= apply(diff, file, true, failed);
if (result != null)
store(LineReader.createString(isPreserveLineDelimeters(), result), file, new SubProgressMonitor(pm, workTicks));
workTicks-= WORK_UNIT;
@@ -341,7 +341,7 @@ public class Patcher implements IHunkFilter {
return pp;
}
- List apply(FilePatch2 diff, IFile file, boolean create, List failedHunks) {
+ List<String> apply(FilePatch2 diff, IFile file, boolean create, List<Hunk> failedHunks) {
FileDiffResult result = getDiffResult(diff);
List<String> lines = LineReader.load(file, create);
result.patch(lines, null);
@@ -420,15 +420,15 @@ public class Patcher implements IHunkFilter {
return true;
}
- public static String getRejected(List failedHunks) {
+ public static String getRejected(List<Hunk> failedHunks) {
if (failedHunks.size() <= 0)
return null;
String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$
StringBuilder sb= new StringBuilder();
- Iterator iter= failedHunks.iterator();
+ Iterator<Hunk> iter= failedHunks.iterator();
while (iter.hasNext()) {
- Hunk hunk= (Hunk) iter.next();
+ Hunk hunk= iter.next();
sb.append(hunk.getRejectedDescription());
sb.append(lineSeparator);
sb.append(hunk.getContent());
@@ -620,7 +620,7 @@ public class Patcher implements IHunkFilter {
FilePatch2 d= diffs[i];
IFile file= getTargetFile(d);
if (file != null && file.exists()) {
- List lines= LineReader.load(file, false);
+ List<String> lines= LineReader.load(file, false);
FileDiffResult result = getDiffResult(d);
int f = result.calculateFuzz(lines, monitor);
if (f > fuzz)
@@ -647,7 +647,7 @@ public class Patcher implements IHunkFilter {
}
public FileDiffResult getDiffResult(FilePatch2 diff) {
- FileDiffResult result = (FileDiffResult)diffResults.get(diff);
+ FileDiffResult result = diffResults.get(diff);
if (result == null) {
result = new WorkspaceFileDiffResult(diff, getConfiguration());
diffResults.put(diff, result);
@@ -715,7 +715,7 @@ public class Patcher implements IHunkFilter {
* @return the content lines that are cached for the file diff
*/
public List<String> getCachedLines(FilePatch2 diff) {
- byte[] contents = (byte[])contentCache.get(diff);
+ byte[] contents = contentCache.get(diff);
if (contents != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(contents)));
return LineReader.readLines(reader);
@@ -731,7 +731,7 @@ public class Patcher implements IHunkFilter {
* <code>null</code>
*/
public byte[] getCachedContents(FilePatch2 diff) {
- return (byte[])contentCache.get(diff);
+ return contentCache.get(diff);
}
/**
@@ -786,8 +786,8 @@ public class Patcher implements IHunkFilter {
}
public boolean hasRejects() {
- for (Iterator iterator = diffResults.values().iterator(); iterator.hasNext();) {
- FileDiffResult result = (FileDiffResult) iterator.next();
+ for (Iterator<FileDiffResult> iterator = diffResults.values().iterator(); iterator.hasNext();) {
+ FileDiffResult result = iterator.next();
if (result.hasRejects())
return true;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
index 6eda0af90..b083e705f 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,22 +33,13 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.*;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
@@ -105,12 +96,9 @@ public class PreviewPatchPage2 extends WizardPage {
Assert.isNotNull(configuration);
this.fPatcher = patcher;
this.fConfiguration = configuration;
- this.fConfiguration.addPropertyChangeListener(new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(CompareConfiguration.IGNORE_WHITESPACE)){
- rebuildTree();
- }
+ this.fConfiguration.addPropertyChangeListener(event -> {
+ if (event.getProperty().equals(CompareConfiguration.IGNORE_WHITESPACE)){
+ rebuildTree();
}
});
}
@@ -152,17 +140,15 @@ public class PreviewPatchPage2 extends WizardPage {
Control c = fInput.createContents(composite);
initializeActions();
fInput.contributeDiffViewerToolbarItems(getContributedActions(), getPatcher().isWorkspacePatch());
- fInput.getViewer().addSelectionChangedListener(new ISelectionChangedListener(){
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection s = event.getSelection();
- if (s != null && !s.isEmpty()) {
- if (s instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection) s;
- updateActions(ss);
- }
+ fInput.getViewer().addSelectionChangedListener(event -> {
+ ISelection s = event.getSelection();
+ if (s != null && !s.isEmpty()) {
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) s;
+ updateActions(ss);
}
- }});
+ }
+ });
c.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -233,22 +219,19 @@ public class PreviewPatchPage2 extends WizardPage {
};
fMoveAction .setToolTipText(PatchMessages.PreviewPatchPage2_RetargetTooltip);
fMoveAction.setEnabled(true);
- fInput.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection sel= (IStructuredSelection) event.getSelection();
- Object obj= sel.getFirstElement();
- boolean enable = false;
- if (obj instanceof PatchProjectDiffNode) {
- enable = true;
- } else if (obj instanceof PatchFileDiffNode) {
- PatchFileDiffNode node = (PatchFileDiffNode) obj;
- enable = node.getDiffResult().getDiffProblem();
- } else if (obj instanceof HunkDiffNode) {
- enable = true;
- }
- fMoveAction.setEnabled(enable);
+ fInput.getViewer().addSelectionChangedListener(event -> {
+ IStructuredSelection sel= (IStructuredSelection) event.getSelection();
+ Object obj= sel.getFirstElement();
+ boolean enable = false;
+ if (obj instanceof PatchProjectDiffNode) {
+ enable = true;
+ } else if (obj instanceof PatchFileDiffNode) {
+ PatchFileDiffNode node = (PatchFileDiffNode) obj;
+ enable = node.getDiffResult().getDiffProblem();
+ } else if (obj instanceof HunkDiffNode) {
+ enable = true;
}
+ fMoveAction.setEnabled(enable);
});
fExcludeAction = new Action(PatchMessages.PreviewPatchPage2_0) {
@@ -299,21 +282,18 @@ public class PreviewPatchPage2 extends WizardPage {
@Override
public void run(){
try {
- getContainer().run(false, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask(PatchMessages.PreviewPatchPage2_IgnoreWhitespace, IProgressMonitor.UNKNOWN);
- if (isChecked() != getPatcher().isIgnoreWhitespace()) {
- if (promptToRebuild(PatchMessages.PreviewPatchPage2_2)) {
- if (getPatcher().setIgnoreWhitespace(isChecked())){
- getCompareConfiguration().setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.valueOf(isChecked()));
- }
- } else {
- fIgnoreWhiteSpace.setChecked(!isChecked());
+ getContainer().run(false, true, monitor -> {
+ monitor.beginTask(PatchMessages.PreviewPatchPage2_IgnoreWhitespace, IProgressMonitor.UNKNOWN);
+ if (isChecked() != getPatcher().isIgnoreWhitespace()) {
+ if (promptToRebuild(PatchMessages.PreviewPatchPage2_2)) {
+ if (getPatcher().setIgnoreWhitespace(isChecked())){
+ getCompareConfiguration().setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.valueOf(isChecked()));
}
+ } else {
+ fIgnoreWhiteSpace.setChecked(!isChecked());
}
- monitor.done();
}
+ monitor.done();
});
} catch (InvocationTargetException e) { //ignore
} catch (InterruptedException e) { //ignore
@@ -328,21 +308,18 @@ public class PreviewPatchPage2 extends WizardPage {
@Override
public void run(){
try {
- getContainer().run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask(PatchMessages.PreviewPatchPage2_CalculateReverse, IProgressMonitor.UNKNOWN);
- if (isChecked() != getPatcher().isReversed()) {
- if (promptToRebuild(PatchMessages.PreviewPatchPage2_3)) {
- if (getPatcher().setReversed(isChecked())){
- rebuildTree();
- }
- } else {
- fReversePatch.setChecked(!isChecked());
+ getContainer().run(true, true, monitor -> {
+ monitor.beginTask(PatchMessages.PreviewPatchPage2_CalculateReverse, IProgressMonitor.UNKNOWN);
+ if (isChecked() != getPatcher().isReversed()) {
+ if (promptToRebuild(PatchMessages.PreviewPatchPage2_3)) {
+ if (getPatcher().setReversed(isChecked())){
+ rebuildTree();
}
+ } else {
+ fReversePatch.setChecked(!isChecked());
}
- monitor.done();
}
+ monitor.done();
});
} catch (InvocationTargetException e) { //ignore
} catch (InterruptedException e) { //ignore
@@ -381,18 +358,15 @@ public class PreviewPatchPage2 extends WizardPage {
final Control ctrl = getControl();
final boolean[] result = new boolean[] { false };
if (ctrl != null && !ctrl.isDisposed()){
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- if (!ctrl.isDisposed()) {
- // flush any viewers before prompting
- try {
- fInput.saveChanges(null);
- } catch (CoreException e) {
- CompareUIPlugin.log(e);
- }
- result[0] = fInput.confirmRebuild(promptToConfirm);
+ Runnable runnable = () -> {
+ if (!ctrl.isDisposed()) {
+ // flush any viewers before prompting
+ try {
+ fInput.saveChanges(null);
+ } catch (CoreException e) {
+ CompareUIPlugin.log(e);
}
+ result[0] = fInput.confirmRebuild(promptToConfirm);
}
};
if (Display.getCurrent() == null)
@@ -406,13 +380,10 @@ public class PreviewPatchPage2 extends WizardPage {
private void rebuildTree(){
final Control ctrl = getControl();
if (ctrl != null && !ctrl.isDisposed()){
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- if (!ctrl.isDisposed()) {
- fInput.buildTree();
- updateEnablements();
- }
+ Runnable runnable = () -> {
+ if (!ctrl.isDisposed()) {
+ fInput.buildTree();
+ updateEnablements();
}
};
if (Display.getCurrent() == null)
@@ -497,9 +468,7 @@ public class PreviewPatchPage2 extends WizardPage {
fFuzzField.addModifyListener(
- new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
+ e -> {
if (patcher.getFuzz() != getFuzzFactor()) {
if (promptToRebuild(PatchMessages.PreviewPatchPage2_5)) {
if (patcher.setFuzz(getFuzzFactor()))
@@ -508,8 +477,7 @@ public class PreviewPatchPage2 extends WizardPage {
fFuzzField.setText(Integer.toString(patcher.getFuzz()));
}
}
- }
- });
+ });
}
private void createFuzzFactorChooser(Composite parent) {
@@ -682,12 +650,7 @@ public class PreviewPatchPage2 extends WizardPage {
final int[] result= new int[] { -1 };
try {
PlatformUI.getWorkbench().getProgressService().run(true, true,
- new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) {
- result[0]= patcher.guessFuzzFactor(monitor);
- }
- }
+ monitor -> result[0]= patcher.guessFuzzFactor(monitor)
);
} catch (InvocationTargetException ex) {
// NeedWork
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java
index f98808ea0..42edcd234 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,7 +42,7 @@ class RetargetPatchElementDialog extends Dialog {
if (element instanceof IWorkspaceRoot) {
// Don't show closed projects
IProject[] allProjects= ((IWorkspaceRoot) element).getProjects();
- ArrayList accessibleProjects= new ArrayList();
+ ArrayList<IProject> accessibleProjects= new ArrayList<>();
for (int i= 0; i<allProjects.length; i++) {
if (allProjects[i].isOpen()) {
accessibleProjects.add(allProjects[i]);
@@ -182,40 +182,34 @@ class RetargetPatchElementDialog extends Dialog {
}
void setupListeners() {
- fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection s= (IStructuredSelection) event.getSelection();
- Object obj= s.getFirstElement();
- if (obj instanceof IResource){
- fSelectedResource = (IResource) obj;
- if (fSelectedNode instanceof PatchProjectDiffNode) {
- if (fSelectedResource instanceof IProject){
- Button okButton = getButton(IDialogConstants.OK_ID);
- okButton.setEnabled(true);
- }
- } else if (fSelectedNode instanceof PatchFileDiffNode
- || fSelectedNode instanceof HunkDiffNode) {
- if (fSelectedResource instanceof IFile){
- Button okButton = getButton(IDialogConstants.OK_ID);
- okButton.setEnabled(true);
- }
+ fViewer.addSelectionChangedListener(event -> {
+ IStructuredSelection s= (IStructuredSelection) event.getSelection();
+ Object obj= s.getFirstElement();
+ if (obj instanceof IResource){
+ fSelectedResource = (IResource) obj;
+ if (fSelectedNode instanceof PatchProjectDiffNode) {
+ if (fSelectedResource instanceof IProject){
+ Button okButton1 = getButton(IDialogConstants.OK_ID);
+ okButton1.setEnabled(true);
+ }
+ } else if (fSelectedNode instanceof PatchFileDiffNode
+ || fSelectedNode instanceof HunkDiffNode) {
+ if (fSelectedResource instanceof IFile){
+ Button okButton2 = getButton(IDialogConstants.OK_ID);
+ okButton2.setEnabled(true);
}
}
}
});
- fViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- ISelection s= event.getSelection();
- if (s instanceof IStructuredSelection) {
- Object item= ((IStructuredSelection) s).getFirstElement();
- if (fViewer.getExpandedState(item))
- fViewer.collapseToLevel(item, 1);
- else
- fViewer.expandToLevel(item, 1);
- }
+ fViewer.addDoubleClickListener(event -> {
+ ISelection s= event.getSelection();
+ if (s instanceof IStructuredSelection) {
+ Object item= ((IStructuredSelection) s).getFirstElement();
+ if (fViewer.getExpandedState(item))
+ fViewer.collapseToLevel(item, 1);
+ else
+ fViewer.expandToLevel(item, 1);
}
});
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java
index c3d6a8b75..a899e71b6 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,9 +36,6 @@ public class UnmatchedHunkTypedElement extends HunkTypedElement implements ICont
super(result, false, true);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IContentChangeNotifier#addContentChangeListener(org.eclipse.compare.IContentChangeListener)
- */
@Override
public synchronized void addContentChangeListener(IContentChangeListener listener) {
if (changeNotifier == null)
@@ -46,36 +43,24 @@ public class UnmatchedHunkTypedElement extends HunkTypedElement implements ICont
changeNotifier.addContentChangeListener(listener);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IContentChangeNotifier#removeContentChangeListener(org.eclipse.compare.IContentChangeListener)
- */
@Override
public synchronized void removeContentChangeListener(IContentChangeListener listener) {
if (changeNotifier != null)
changeNotifier.removeContentChangeListener(listener);
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEditableContent#isEditable()
- */
@Override
public boolean isEditable() {
IFile file = ((WorkspaceFileDiffResult)getHunkResult().getDiffResult()).getTargetFile();
return file != null && file.isAccessible();
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEditableContent#replace(org.eclipse.compare.ITypedElement, org.eclipse.compare.ITypedElement)
- */
@Override
public ITypedElement replace(ITypedElement dest, ITypedElement src) {
// Not supported
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IEditableContent#setContent(byte[])
- */
@Override
public void setContent(byte[] newContent) {
getPatcher().setManuallyMerged(getHunkResult().getHunk(), true);
@@ -92,16 +77,13 @@ public class UnmatchedHunkTypedElement extends HunkTypedElement implements ICont
return Patcher.getPatcher(getConfiguration());
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.internal.patch.HunkTypedElement#getContents()
- */
@Override
public InputStream getContents() throws CoreException {
// If there are cached contents, use them
if (getPatcher().hasCachedContents(getDiff()))
return new ByteArrayInputStream(getPatcher().getCachedContents(getDiff()));
// Otherwise return the after state of the diff result
- List lines = getHunkResult().getDiffResult().getAfterLines();
+ List<String> lines = getHunkResult().getDiffResult().getAfterLines();
String content = LineReader.createString(getHunkResult().getDiffResult().isPreserveLineDelimeters(), lines);
byte[] bytes = null;
if (getCharset() != null)
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java
index 0ff61096f..18e5197b6 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,9 +38,9 @@ public class WorkspaceFileDiffResult extends FileDiffResult {
return file != null && file.isAccessible();
}
- protected List getLines(IStorage storage, boolean create) {
+ protected List<String> getLines(IStorage storage, boolean create) {
IFile file= getTargetFile();
- List lines = LineReader.load(file, create);
+ List<String> lines = LineReader.load(file, create);
return lines;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java
index c1aac5067..20f71f3ec 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,31 +10,13 @@
*******************************************************************************/
package org.eclipse.compare.internal.patch;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import org.eclipse.compare.internal.core.Messages;
-import org.eclipse.compare.internal.core.patch.DiffProject;
-import org.eclipse.compare.internal.core.patch.FilePatch2;
-import org.eclipse.compare.internal.core.patch.Hunk;
-import org.eclipse.compare.internal.core.patch.PatchReader;
+import org.eclipse.compare.internal.core.patch.*;
import org.eclipse.compare.patch.IHunk;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceRuleFactory;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.MultiRule;
@@ -91,14 +73,14 @@ public class WorkspacePatcher extends Patcher {
final int WORK_UNIT= 10;
// get all files to be modified in order to call validateEdit
- List list= new ArrayList();
+ List<IFile> list= new ArrayList<>();
for (int j= 0; j < fDiffProjects.length; j++) {
DiffProject diffProject= fDiffProjects[j];
if (Utilities.getProject(diffProject).isAccessible())
list.addAll(Arrays.asList(getTargetFiles(diffProject)));
}
// validate the files for editing
- if (!validator.validateResources((IFile[])list.toArray(new IFile[list.size()]))) {
+ if (!validator.validateResources(list.toArray(new IFile[list.size()]))) {
return;
}
@@ -120,13 +102,13 @@ public class WorkspacePatcher extends Patcher {
pm.subTask(path.toString());
createPath(file.getProject(), path);
- List failed= new ArrayList();
+ List<Hunk> failed= new ArrayList<>();
int type= diff.getDiffType(isReversed());
switch (type) {
case FilePatch2.ADDITION :
// patch it and collect rejected hunks
- List result= apply(diff, file, true, failed);
+ List<String> result= apply(diff, file, true, failed);
if (result != null)
store(LineReader.createString(isPreserveLineDelimeters(), result), file, new SubProgressMonitor(pm, workTicks));
workTicks -= WORK_UNIT;
@@ -186,7 +168,7 @@ public class WorkspacePatcher extends Patcher {
* @return An array of IFiles that are targeted by the Diffs
*/
public IFile[] getTargetFiles(DiffProject project) {
- List files= new ArrayList();
+ List<IFile> files= new ArrayList<>();
FilePatch2[] diffs = project.getFileDiffs();
for (int i = 0; i < diffs.length; i++) {
FilePatch2 diff = diffs[i];
@@ -194,7 +176,7 @@ public class WorkspacePatcher extends Patcher {
files.add(getTargetFile(diff));
}
}
- return (IFile[]) files.toArray(new IFile[files.size()]);
+ return files.toArray(new IFile[files.size()]);
}
@Override
@@ -215,7 +197,7 @@ public class WorkspacePatcher extends Patcher {
}
public ISchedulingRule[] getTargetProjects() {
- List projects= new ArrayList();
+ List<ISchedulingRule> projects= new ArrayList<>();
IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
// Determine the appropriate scheduling rules
for (int i= 0; i < fDiffProjects.length; i++) {
@@ -230,7 +212,7 @@ public class WorkspacePatcher extends Patcher {
projects.add(multiRule);
}
- return (ISchedulingRule[]) projects.toArray(new ISchedulingRule[projects.size()]);
+ return projects.toArray(new ISchedulingRule[projects.size()]);
}
public void setDiffProjects(DiffProject[] newProjectArray) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java
index 32eb38ea8..9264a199d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 IBM Corporation and others.
+ * Copyright (c) 2006, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -86,14 +86,11 @@ public abstract class StructureCreator implements IStructureCreator2 {
public IStructureComparator createStructure(final Object element,
final IProgressMonitor monitor) throws CoreException {
final IStructureComparator[] result = new IStructureComparator[] { null };
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- try {
- result[0]= internalCreateStructure(element, monitor);
- } catch (OperationCanceledException ex) {
- return;
- }
+ Runnable runnable = () -> {
+ try {
+ result[0]= internalCreateStructure(element, monitor);
+ } catch (OperationCanceledException ex) {
+ return;
}
};
Utilities.runInUIThread(runnable);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
index 0155bd5fe..f6f8ace85 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -73,25 +73,17 @@ public class StructureDiffViewer extends DiffTreeViewer {
/*
* A set of background tasks for updating the structure
*/
- private IRunnableWithProgress diffTask = new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(CompareMessages.StructureDiffViewer_0, 100);
- diff(new SubProgressMonitor(monitor, 100));
- monitor.done();
- }
+ private IRunnableWithProgress diffTask = monitor -> {
+ monitor.beginTask(CompareMessages.StructureDiffViewer_0, 100);
+ diff(new SubProgressMonitor(monitor, 100));
+ monitor.done();
};
- private IRunnableWithProgress inputChangedTask = new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(CompareMessages.StructureDiffViewer_1, 100);
- // TODO: Should we always force
- compareInputChanged((ICompareInput)getInput(), true, new SubProgressMonitor(monitor, 100));
- monitor.done();
- }
+ private IRunnableWithProgress inputChangedTask = monitor -> {
+ monitor.beginTask(CompareMessages.StructureDiffViewer_1, 100);
+ // TODO: Should we always force
+ compareInputChanged((ICompareInput) getInput(), true, new SubProgressMonitor(monitor, 100));
+ monitor.done();
};
/*
@@ -101,13 +93,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
private class StructureInfo {
private ITypedElement fInput;
private IStructureComparator fStructureComparator;
- private IRunnableWithProgress refreshTask = new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- refresh(monitor);
- }
- };
+ private IRunnableWithProgress refreshTask = monitor -> refresh(monitor);
public boolean setInput(ITypedElement newInput, boolean force, IProgressMonitor monitor) {
boolean changed = false;
@@ -222,18 +208,8 @@ public class StructureDiffViewer extends DiffTreeViewer {
setAutoExpandLevel(3);
- fContentChangedListener= new IContentChangeListener() {
- @Override
- public void contentChanged(IContentChangeNotifier changed) {
- StructureDiffViewer.this.contentChanged(changed);
- }
- };
- fCompareInputChangeListener = new ICompareInputChangeListener() {
- @Override
- public void compareInputChanged(ICompareInput input) {
- StructureDiffViewer.this.compareInputChanged(input, true);
- }
- };
+ fContentChangedListener= changed -> StructureDiffViewer.this.contentChanged(changed);
+ fCompareInputChangeListener = input -> StructureDiffViewer.this.compareInputChanged(input, true);
}
/**
@@ -342,16 +318,13 @@ public class StructureDiffViewer extends DiffTreeViewer {
CompareConfiguration cc = getCompareConfiguration();
// The compare configuration is nulled when the viewer is disposed
if (cc != null) {
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- @Override
- public void run() {
- try {
- inputChangedTask.run(new NullProgressMonitor());
- } catch (InvocationTargetException e) {
- CompareUIPlugin.log(e.getTargetException());
- } catch (InterruptedException e) {
- // Ignore
- }
+ BusyIndicator.showWhile(Display.getDefault(), () -> {
+ try {
+ inputChangedTask.run(new NullProgressMonitor());
+ } catch (InvocationTargetException e1) {
+ CompareUIPlugin.log(e1.getTargetException());
+ } catch (InterruptedException e2) {
+ // Ignore
}
});
}
@@ -466,12 +439,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
* @since 3.3
*/
protected void preDiffHook(final IStructureComparator ancestor, final IStructureComparator left, final IStructureComparator right, IProgressMonitor monitor) {
- syncExec(new Runnable() {
- @Override
- public void run() {
- preDiffHook(ancestor, left, right);
- }
- });
+ syncExec(() -> preDiffHook(ancestor, left, right));
}
/**
@@ -530,12 +498,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
refreshAfterDiff(message);
} else {
final String theMessage = message;
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- refreshAfterDiff(theMessage);
- }
- });
+ Display.getDefault().asyncExec(() -> refreshAfterDiff(theMessage));
}
} finally {
endWork(monitor);
@@ -561,13 +524,10 @@ public class StructureDiffViewer extends DiffTreeViewer {
CompareConfiguration compareConfiguration = getCompareConfiguration();
// A null compare configuration indicates that the viewer was disposed
if (compareConfiguration != null) {
- compareConfiguration.getContainer().run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask(CompareMessages.StructureDiffViewer_2, 100);
- diffTask.run(new SubProgressMonitor(monitor, 100));
- monitor.done();
- }
+ compareConfiguration.getContainer().run(true, true, monitor -> {
+ monitor.beginTask(CompareMessages.StructureDiffViewer_2, 100);
+ diffTask.run(new SubProgressMonitor(monitor, 100));
+ monitor.done();
});
}
} catch (InvocationTargetException e) {
@@ -581,13 +541,10 @@ public class StructureDiffViewer extends DiffTreeViewer {
}
private void handleFailedRefresh(final String message) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- if (getControl().isDisposed())
- return;
- refreshAfterDiff(message);
- }
+ Runnable runnable = () -> {
+ if (getControl().isDisposed())
+ return;
+ refreshAfterDiff(message);
};
if (Display.getCurrent() != null) {
runnable.run();
@@ -631,12 +588,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
* @since 3.3
*/
protected void postDiffHook(final Differencer differencer, final IDiffContainer root, IProgressMonitor monitor) {
- syncExec(new Runnable() {
- @Override
- public void run() {
- postDiffHook(differencer, root);
- }
- });
+ syncExec(() -> postDiffHook(differencer, root));
}
/*

Back to the top