Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-05-12 10:09:36 -0400
committerMichael Keppler2019-05-15 01:20:10 -0400
commitf7252caf1b30cd08badd7480a8130f0e55daf723 (patch)
treebed74295d3610de1f0e36831933e488c2a33a1d1
parent7258517aa01f4dbf4ed45ed1f0e14e6d88f79ef0 (diff)
downloadegit-f7252caf1b30cd08badd7480a8130f0e55daf723.tar.gz
egit-f7252caf1b30cd08badd7480a8130f0e55daf723.tar.xz
egit-f7252caf1b30cd08badd7480a8130f0e55daf723.zip
Convert to lambda or member reference
Convert anonymous inner classes to lambda expressions or member references. Change-Id: I80ef719e9282eac73f178e4d45cc2ed57280cb25 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/NetUtil.java10
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCache.java8
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContext.java21
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java76
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CommonUtils.java37
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPage.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java29
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java26
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java34
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/ConfigurationEditorComponent.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullWizardPage.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java27
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushTagsPage.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java76
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java38
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java10
21 files changed, 181 insertions, 302 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/NetUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/NetUtil.java
index a88fbfaf1..4187d817f 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/NetUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/NetUtil.java
@@ -20,7 +20,6 @@ import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
@@ -50,13 +49,8 @@ public class NetUtil {
}
} };
- private static HostnameVerifier trustAllHostNames = new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- // always accept
- return true;
- }
- };
+ private static HostnameVerifier trustAllHostNames = (hostname,
+ session) -> true; // always accept
/**
* Configures a {@link HttpURLConnection} according to the value of the
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCache.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCache.java
index b33d39988..1e54bb4fd 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCache.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCache.java
@@ -262,13 +262,7 @@ public class IndexDiffCache {
}
private void createGlobalListener() {
- globalListener = new IndexDiffChangedListener() {
- @Override
- public void indexDiffChanged(Repository repository,
- IndexDiffData indexDiffData) {
- notifyListeners(repository, indexDiffData);
- }
- };
+ globalListener = this::notifyListeners;
}
private void notifyListeners(Repository repository,
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContext.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContext.java
index fe83a8d0d..ba8f2122d 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContext.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContext.java
@@ -15,7 +15,6 @@ import java.util.Collection;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -28,7 +27,6 @@ import org.eclipse.egit.core.internal.CoreText;
import org.eclipse.egit.core.internal.indexdiff.GitResourceDeltaVisitor;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffCache;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffChangedListener;
-import org.eclipse.egit.core.internal.indexdiff.IndexDiffData;
import org.eclipse.egit.core.op.AddToIndexOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
@@ -64,21 +62,10 @@ public class GitSubscriberMergeContext extends SubscriberMergeContext {
this.gsds = gsds;
- indexChangeListener = new IndexDiffChangedListener() {
- @Override
- public void indexDiffChanged(Repository repository,
- IndexDiffData indexDiffData) {
- handleRepositoryChange(repository);
- }
- };
- resourceChangeListener = new IResourceChangeListener() {
-
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- if (delta == null)
- return;
-
+ indexChangeListener = (repository, indexDiffData) -> handleRepositoryChange(repository);
+ resourceChangeListener = event -> {
+ IResourceDelta delta = event.getDelta();
+ if (delta != null) {
handleResourceChange(delta);
}
};
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
index ccd8e682b..b88faf4a2 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
@@ -599,12 +599,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
protected void shareProjects(File repositoryDir) throws Exception {
Repository myRepository = lookupRepository(repositoryDir);
- FilenameFilter projectFilter = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.equals(".project");
- }
- };
+ FilenameFilter projectFilter = (File dir, String name) -> name.equals(".project");
for (File file : myRepository.getWorkTree().listFiles()) {
if (file.isDirectory()) {
if (file.list(projectFilter).length > 0) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java
index e8213f336..957917ecd 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java
@@ -456,46 +456,42 @@ public class UIUtils {
adapter.setProposalAcceptanceStyle(
ContentProposalAdapter.PROPOSAL_REPLACE);
- return new IPreviousValueProposalHandler() {
- @Override
- public void updateProposals() {
- String value = textField.getText();
- // don't store empty values
- if (value.length() > 0) {
- // we don't want to save too much in the preferences
- if (value.length() > 2000) {
- value = value.substring(0, 1999);
- }
- // now we need to mix the value into the list
- IDialogSettings settings = org.eclipse.egit.ui.Activator
- .getDefault().getDialogSettings();
- String[] existingValues = settings.getArray(preferenceKey);
- if (existingValues == null) {
- existingValues = new String[] { value };
- settings.put(preferenceKey, existingValues);
- } else {
-
- List<String> values = new ArrayList<>(
- existingValues.length + 1);
-
- for (String existingValue : existingValues)
- values.add(existingValue);
- // if it is already the first value, we don't need to do
- // anything
- if (values.indexOf(value) == 0)
- return;
-
- values.remove(value);
- // we insert at the top
- values.add(0, value);
- // make sure to not store more than the maximum number
- // of values
- while (values.size() > 10)
- values.remove(values.size() - 1);
-
- settings.put(preferenceKey, values
- .toArray(new String[0]));
- }
+ return () -> {
+ String value = textField.getText();
+ // don't store empty values
+ if (value.length() > 0) {
+ // we don't want to save too much in the preferences
+ if (value.length() > 2000) {
+ value = value.substring(0, 1999);
+ }
+ // now we need to mix the value into the list
+ IDialogSettings settings = org.eclipse.egit.ui.Activator
+ .getDefault().getDialogSettings();
+ String[] existingValues = settings.getArray(preferenceKey);
+ if (existingValues == null) {
+ existingValues = new String[] { value };
+ settings.put(preferenceKey, existingValues);
+ } else {
+
+ List<String> values = new ArrayList<>(
+ existingValues.length + 1);
+
+ for (String existingValue : existingValues)
+ values.add(existingValue);
+ // if it is already the first value, we don't need to do
+ // anything
+ if (values.indexOf(value) == 0)
+ return;
+
+ values.remove(value);
+ // we insert at the top
+ values.add(0, value);
+ // make sure to not store more than the maximum number
+ // of values
+ while (values.size() > 10)
+ values.remove(values.size() - 1);
+
+ settings.put(preferenceKey, values.toArray(new String[0]));
}
}
};
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CommonUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CommonUtils.java
index ffb677171..d11601b05 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CommonUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CommonUtils.java
@@ -93,7 +93,8 @@ public class CommonUtils {
int result;
- if (Character.isDigit(o1Part.charAt(0)) && Character.isDigit(o2Part.charAt(0))) {
+ if (Character.isDigit(o1Part.charAt(0))
+ && Character.isDigit(o2Part.charAt(0))) {
o1Part = stripLeadingZeros(o1Part);
o2Part = stripLeadingZeros(o2Part);
result = o1Part.length() - o2Part.length();
@@ -147,36 +148,26 @@ public class CommonUtils {
* Instance of comparator which sorts {@link Ref} names using
* {@link CommonUtils#STRING_ASCENDING_COMPARATOR}.
*/
- public static final Comparator<Ref> REF_ASCENDING_COMPARATOR = new Comparator<Ref>() {
- @Override
- public int compare(Ref o1, Ref o2) {
- return STRING_ASCENDING_COMPARATOR.compare(o1.getName(), o2.getName());
- }
- };
+ public static final Comparator<Ref> REF_ASCENDING_COMPARATOR = (Ref o1,
+ Ref o2) -> STRING_ASCENDING_COMPARATOR.compare(o1.getName(),
+ o2.getName());
/**
* Comparator for comparing {@link IResource} by the result of
* {@link IResource#getName()}.
*/
- public static final Comparator<IResource> RESOURCE_NAME_COMPARATOR = new Comparator<IResource>() {
- @Override
- public int compare(IResource r1, IResource r2) {
- return Policy.getComparator().compare(r1.getName(), r2.getName());
- }
- };
+ public static final Comparator<IResource> RESOURCE_NAME_COMPARATOR = (
+ IResource r1, IResource r2) -> Policy.getComparator()
+ .compare(r1.getName(), r2.getName());
/**
* Comparator for comparing (@link Path} by the result of
* {@link Path#toAbsolutePath()}
*/
- public static final Comparator<Path> PATH_STRING_COMPARATOR = new Comparator<Path>() {
- @Override
- public int compare(Path p1, Path p2) {
- return STRING_ASCENDING_COMPARATOR.compare(
+ public static final Comparator<Path> PATH_STRING_COMPARATOR = (Path p1,
+ Path p2) -> STRING_ASCENDING_COMPARATOR.compare(
p1.toAbsolutePath().toString(),
p2.toAbsolutePath().toString());
- }
- };
/**
* Programmatically run command based on its id and given selection
@@ -190,14 +181,14 @@ public class CommonUtils {
*/
public static boolean runCommand(String commandId,
IStructuredSelection selection) {
- ICommandService commandService = CommonUtils.getService(PlatformUI
- .getWorkbench(), ICommandService.class);
+ ICommandService commandService = CommonUtils
+ .getService(PlatformUI.getWorkbench(), ICommandService.class);
Command cmd = commandService.getCommand(commandId);
if (!cmd.isDefined())
return false;
- IHandlerService handlerService = CommonUtils.getService(PlatformUI
- .getWorkbench(), IHandlerService.class);
+ IHandlerService handlerService = CommonUtils
+ .getService(PlatformUI.getWorkbench(), IHandlerService.class);
EvaluationContext c = null;
if (selection != null) {
c = new EvaluationContext(
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java
index 14b18a3e7..4b43b42e9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java
@@ -13,7 +13,6 @@
package org.eclipse.egit.ui.internal.clone;
import java.io.File;
-import java.io.FilenameFilter;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -172,14 +171,10 @@ public class GitCreateGeneralProjectPage extends WizardPage {
return;
}
// make sure there is not already a .project file
- String[] dotProjectFiles = myDirectory.list(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- if (name.equals(".project")) //$NON-NLS-1$
- return true;
- return false;
- }
+ String[] dotProjectFiles = myDirectory.list((File dir, String name) -> {
+ if (name.equals(".project")) //$NON-NLS-1$
+ return true;
+ return false;
});
if (dotProjectFiles != null && dotProjectFiles.length > 0) {
setErrorMessage(NLS
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPage.java
index 64b93b035..d353d4e94 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPage.java
@@ -126,12 +126,7 @@ public class RefSpecPage extends WizardPage {
specsPanel = new RefSpecPanel(panel, pushPage);
specsPanel.getControl().setLayoutData(
new GridData(SWT.FILL, SWT.FILL, true, true));
- specsPanel.addRefSpecTableListener(new SelectionChangeListener() {
- @Override
- public void selectionChanged() {
- checkPage();
- }
- });
+ specsPanel.addRefSpecTableListener(this::checkPage);
if (!pushPage) {
final Group tagsGroup = new Group(panel, SWT.NULL);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
index ffb3b765d..4dbd10203 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
@@ -343,12 +343,7 @@ public class RefSpecPanel {
createPredefinedCreationPanel();
createTableGroup();
- addRefSpecTableListener(new SelectionChangeListener() {
- @Override
- public void selectionChanged() {
- validateSpecs();
- }
- });
+ addRefSpecTableListener(this::validateSpecs);
setEnable(false);
}
@@ -877,14 +872,11 @@ public class RefSpecPanel {
.setToolTipText(UIText.RefSpecPanel_predefinedTagsDescription);
updateAddPredefinedButton(addTagsButton, Transport.REFSPEC_TAGS);
- addRefSpecTableListener(new SelectionChangeListener() {
- @Override
- public void selectionChanged() {
- updateAddPredefinedButton(addConfiguredButton,
- predefinedConfigured);
- updateAddPredefinedButton(addBranchesButton, predefinedBranches);
- updateAddPredefinedButton(addTagsButton, Transport.REFSPEC_TAGS);
- }
+ addRefSpecTableListener(() -> {
+ updateAddPredefinedButton(addConfiguredButton,
+ predefinedConfigured);
+ updateAddPredefinedButton(addBranchesButton, predefinedBranches);
+ updateAddPredefinedButton(addTagsButton, Transport.REFSPEC_TAGS);
});
}
@@ -1359,12 +1351,9 @@ public class RefSpecPanel {
.setToolTipText(UIText.RefSpecPanel_removeAllDescription);
updateRemoveAllSpecButton();
- addRefSpecTableListener(new SelectionChangeListener() {
- @Override
- public void selectionChanged() {
- updateForceUpdateAllButton();
- updateRemoveAllSpecButton();
- }
+ addRefSpecTableListener(() -> {
+ updateForceUpdateAllButton();
+ updateRemoveAllSpecButton();
});
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java
index 41c4df241..ad72d6dae 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java
@@ -31,7 +31,6 @@ import org.eclipse.egit.ui.UIUtils.IPreviousValueProposalHandler;
import org.eclipse.egit.ui.internal.SecureStoreUtils;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.clone.GitUrlChecker;
-import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.IRemoteSelectionListener;
import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.SelectionType;
import org.eclipse.egit.ui.internal.provisional.wizards.GitRepositoryInfo;
import org.eclipse.egit.ui.internal.provisional.wizards.IRepositorySearchResult;
@@ -435,12 +434,9 @@ public class RepositorySelectionPage extends WizardPage implements IRepositorySe
SelectionType selectionType = sourceSelection ? SelectionType.FETCH : SelectionType.PUSH;
remoteCombo = new RemoteSelectionCombo(remotePanel, SWT.NULL, selectionType);
remoteConfig = remoteCombo.setItems(configuredRemotes);
- remoteCombo.addRemoteSelectionListener(new IRemoteSelectionListener() {
- @Override
- public void remoteSelected(RemoteConfig rc) {
- remoteConfig = rc;
- checkPage();
- }
+ remoteCombo.addRemoteSelectionListener((RemoteConfig rc) -> {
+ remoteConfig = rc;
+ checkPage();
});
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
index efc57e202..6d86d50f8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
@@ -479,14 +479,11 @@ public class CommitDialog extends TitleAreaDialog {
}
// initially, we sort by status plus path
- Collections.sort(items, new Comparator<CommitItem>() {
- @Override
- public int compare(CommitItem o1, CommitItem o2) {
- int diff = o1.status.ordinal() - o2.status.ordinal();
- if (diff != 0)
- return diff;
- return o1.path.compareToIgnoreCase(o2.path);
- }
+ Collections.sort(items, (CommitItem o1, CommitItem o2) -> {
+ int diff = o1.status.ordinal() - o2.status.ordinal();
+ if (diff != 0)
+ return diff;
+ return o1.path.compareToIgnoreCase(o2.path);
});
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
index 2747207e0..8aaac0ce9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
@@ -65,22 +65,18 @@ public class FileDiff {
* Comparator for sorting FileDiffs based on getPath(). Compares first the
* directory part, if those are equal, the filename part.
*/
- public static final Comparator<FileDiff> PATH_COMPARATOR = new Comparator<FileDiff>() {
-
- @Override
- public int compare(FileDiff left, FileDiff right) {
- String leftPath = left.getPath();
- String rightPath = right.getPath();
- int i = leftPath.lastIndexOf('/');
- int j = rightPath.lastIndexOf('/');
- int p = leftPath.substring(0, i + 1).replace('/', '\001').compareTo(
- rightPath.substring(0, j + 1).replace('/', '\001'));
- if (p != 0) {
- return p;
- }
- return leftPath.substring(i + 1)
- .compareTo(rightPath.substring(j + 1));
+ public static final Comparator<FileDiff> PATH_COMPARATOR = (FileDiff left, FileDiff right) -> {
+ String leftPath = left.getPath();
+ String rightPath = right.getPath();
+ int i = leftPath.lastIndexOf('/');
+ int j = rightPath.lastIndexOf('/');
+ int p = leftPath.substring(0, i + 1).replace('/', '\001').compareTo(
+ rightPath.substring(0, j + 1).replace('/', '\001'));
+ if (p != 0) {
+ return p;
}
+ return leftPath.substring(i + 1)
+ .compareTo(rightPath.substring(j + 1));
};
private final RevCommit commit;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 64a032b58..7b8a40067 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -1466,12 +1466,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
}
});
commentViewer
- .addCommitNavigationListener(new CommitNavigationListener() {
- @Override
- public void showCommit(final RevCommit c) {
- graph.selectCommit(c);
- }
- });
+ .addCommitNavigationListener(graph::selectCommit);
}
/**
@@ -1712,21 +1707,18 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
synchronized (this) {
if (refschangedRunnable == null) {
- refschangedRunnable = new Runnable() {
- @Override
- public void run() {
- if (!getControl().isDisposed()) {
- if (GitTraceLocation.HISTORYVIEW.isActive())
- GitTraceLocation
- .getTrace()
- .trace(
- GitTraceLocation.HISTORYVIEW
- .getLocation(),
- "Executing async repository changed event"); //$NON-NLS-1$
- refschangedRunnable = null;
- initAndStartRevWalk(
- !(e instanceof FetchHeadChangedEvent));
- }
+ refschangedRunnable = () -> {
+ if (!getControl().isDisposed()) {
+ if (GitTraceLocation.HISTORYVIEW.isActive())
+ GitTraceLocation
+ .getTrace()
+ .trace(
+ GitTraceLocation.HISTORYVIEW
+ .getLocation(),
+ "Executing async repository changed event"); //$NON-NLS-1$
+ refschangedRunnable = null;
+ initAndStartRevWalk(
+ !(e instanceof FetchHeadChangedEvent));
}
};
getControl().getDisplay().asyncExec(refschangedRunnable);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/ConfigurationEditorComponent.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/ConfigurationEditorComponent.java
index 9bc4abcd2..1319a1909 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/ConfigurationEditorComponent.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/ConfigurationEditorComponent.java
@@ -17,7 +17,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
@@ -550,13 +549,7 @@ public class ConfigurationEditorComponent {
Set<String> sectionNames = config.getSections();
for (String sectionName : sectionNames)
sections.add(new Section(this, sectionName));
- Collections.sort(sections, new Comparator<Section>() {
-
- @Override
- public int compare(Section o1, Section o2) {
- return o1.name.compareTo(o2.name);
- }
- });
+ Collections.sort(sections, (Section o1, Section o2) -> o1.name.compareTo(o2.name));
children = sections.toArray(new Section[0]);
} else
children = new Section[0];
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullWizardPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullWizardPage.java
index 86c1c6ae0..1d296d137 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullWizardPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullWizardPage.java
@@ -30,7 +30,6 @@ import org.eclipse.egit.ui.internal.components.AsynchronousBranchList;
import org.eclipse.egit.ui.internal.components.AsynchronousRefProposalProvider;
import org.eclipse.egit.ui.internal.components.BranchRebaseModeCombo;
import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo;
-import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.IRemoteSelectionListener;
import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.SelectionType;
import org.eclipse.egit.ui.internal.dialogs.CancelableFuture;
import org.eclipse.egit.ui.internal.push.AddRemoteWizard;
@@ -153,14 +152,11 @@ public class PullWizardPage extends WizardPage {
.applyTo(remoteSelectionCombo);
setRemoteConfigs();
remoteSelectionCombo
- .addRemoteSelectionListener(new IRemoteSelectionListener() {
- @Override
- public void remoteSelected(RemoteConfig rc) {
- remoteConfig = rc;
- setRefAssist(rc);
- checkPage();
- }
- });
+ .addRemoteSelectionListener((RemoteConfig rc) -> {
+ remoteConfig = rc;
+ setRefAssist(rc);
+ checkPage();
+ });
Button newRemoteButton = new Button(res, SWT.PUSH);
newRemoteButton.setText(UIText.PushBranchPage_NewRemoteButton);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java
index 157fba43f..8450f588b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java
@@ -34,10 +34,8 @@ import org.eclipse.egit.ui.internal.components.AsynchronousBranchList;
import org.eclipse.egit.ui.internal.components.AsynchronousRefProposalProvider;
import org.eclipse.egit.ui.internal.components.BranchNameNormalizer;
import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo;
-import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.IRemoteSelectionListener;
import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.SelectionType;
import org.eclipse.egit.ui.internal.components.UpstreamConfigComponent;
-import org.eclipse.egit.ui.internal.components.UpstreamConfigComponent.UpstreamConfigSelectionListener;
import org.eclipse.egit.ui.internal.dialogs.CancelableFuture;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.layout.GridDataFactory;
@@ -274,14 +272,11 @@ public class PushBranchPage extends WizardPage {
.applyTo(remoteSelectionCombo);
setRemoteConfigs();
remoteSelectionCombo
- .addRemoteSelectionListener(new IRemoteSelectionListener() {
- @Override
- public void remoteSelected(RemoteConfig rc) {
- remoteConfig = rc;
- setRefAssist(rc);
- checkPage();
- }
- });
+ .addRemoteSelectionListener((RemoteConfig rc) -> {
+ remoteConfig = rc;
+ setRefAssist(rc);
+ checkPage();
+ });
if (showNewRemoteButton) {
Button newRemoteButton = new Button(remoteGroup, SWT.PUSH);
@@ -333,14 +328,10 @@ public class PushBranchPage extends WizardPage {
GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
.indent(SWT.NONE, 20).create());
upstreamConfigComponent
- .addUpstreamConfigSelectionListener(new UpstreamConfigSelectionListener() {
- @Override
- public void upstreamConfigSelected(
- BranchRebaseMode newUpstreamConfig) {
- upstreamConfig = newUpstreamConfig;
- checkPage();
- }
- });
+ .addUpstreamConfigSelectionListener((BranchRebaseMode newUpstreamConfig) -> {
+ upstreamConfig = newUpstreamConfig;
+ checkPage();
+ });
setDefaultUpstreamConfig();
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushTagsPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushTagsPage.java
index 5f0fcbfbf..98f574e20 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushTagsPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushTagsPage.java
@@ -99,12 +99,9 @@ public class PushTagsPage extends WizardPage {
selectedRemoteConfig = remoteSelectionCombo
.setItems(getRemoteConfigs());
remoteSelectionCombo
- .addRemoteSelectionListener(new RemoteSelectionCombo.IRemoteSelectionListener() {
- @Override
- public void remoteSelected(RemoteConfig remoteConfig) {
- selectedRemoteConfig = remoteConfig;
- }
- });
+ .addRemoteSelectionListener((RemoteConfig remoteConfig) -> {
+ selectedRemoteConfig = remoteConfig;
+ });
tagsLabel = new Label(main, SWT.NONE);
tagsLabel.setText(UIText.PushTagsPage_TagsLabelNoneSelected);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java
index 584c8f4ca..466ee3aec 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java
@@ -14,7 +14,6 @@ package org.eclipse.egit.ui.internal.repository.tree.command;
import java.text.MessageFormat;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -46,8 +45,8 @@ import org.eclipse.ui.PlatformUI;
/**
* Command to drop one or all stashed commits
*/
-public class StashDropCommand extends
- RepositoriesViewCommandHandler<StashedCommitNode> {
+public class StashDropCommand
+ extends RepositoriesViewCommandHandler<StashedCommitNode> {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -102,14 +101,12 @@ public class StashDropCommand extends
// Sort by highest to lowest stash commit index.
// This avoids shifting problems that cause the indices of the
// selected nodes not match the indices in the repository
- Collections.sort(nodes, new Comparator<StashedCommitNode>() {
-
- @Override
- public int compare(StashedCommitNode n1,
- StashedCommitNode n2) {
- return n1.getIndex() < n2.getIndex() ? 1 : -1;
- }
- });
+ Collections
+ .sort(nodes,
+ (StashedCommitNode n1,
+ StashedCommitNode n2) -> n1
+ .getIndex() < n2.getIndex() ? 1
+ : -1);
for (StashedCommitNode node : nodes) {
final int index = node.getIndex();
@@ -137,33 +134,40 @@ public class StashDropCommand extends
}
private void tryToCloseEditor(final StashedCommitNode node) {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- IEditorReference[] editorReferences = activePage
- .getEditorReferences();
- for (IEditorReference editorReference : editorReferences) {
- IEditorInput editorInput = null;
- try {
- editorInput = editorReference.getEditorInput();
- } catch (PartInitException e) {
- Activator.handleError(e.getMessage(), e, true);
- }
- if (editorInput instanceof CommitEditorInput) {
- CommitEditorInput comEditorInput = (CommitEditorInput) editorInput;
- if (comEditorInput.getCommit().getRevCommit()
- .equals(node.getObject())) {
- activePage.closeEditor(
- editorReference.getEditor(false),
- false);
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI
+ .getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage();
+ IEditorReference[] editorReferences = activePage
+ .getEditorReferences();
+ for (IEditorReference editorReference : editorReferences) {
+ IEditorInput editorInput = null;
+ try {
+ editorInput = editorReference
+ .getEditorInput();
+ } catch (PartInitException e) {
+ Activator.handleError(e.getMessage(), e,
+ true);
+ }
+ if (editorInput instanceof CommitEditorInput) {
+ CommitEditorInput comEditorInput = (CommitEditorInput) editorInput;
+ if (comEditorInput.getCommit()
+ .getRevCommit()
+ .equals(node.getObject())) {
+ activePage.closeEditor(
+ editorReference.getEditor(
+ false),
+ false);
+ }
+ }
}
}
- }
- }
- });
+ });
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index b0e2491a0..63d92e5e9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -3015,15 +3015,12 @@ public class StagingView extends ViewPart
* elements
*/
public void refreshViewers() {
- syncExec(new Runnable() {
- @Override
- public void run() {
- setRedraw(false);
- try {
- refreshViewersInternal();
- } finally {
- setRedraw(true);
- }
+ syncExec(() -> {
+ setRedraw(false);
+ try {
+ refreshViewersInternal();
+ } finally {
+ setRedraw(true);
}
});
}
@@ -3037,19 +3034,16 @@ public class StagingView extends ViewPart
* Refresh the unstaged and staged viewers, preserving expanded elements
*/
public void refreshViewersPreservingExpandedElements() {
- syncExec(new Runnable() {
- @Override
- public void run() {
- Object[] unstagedExpanded = unstagedViewer.getVisibleExpandedElements();
- Object[] stagedExpanded = stagedViewer.getVisibleExpandedElements();
- setRedraw(false);
- try {
- refreshViewersInternal();
- unstagedViewer.setExpandedElements(unstagedExpanded);
- stagedViewer.setExpandedElements(stagedExpanded);
- } finally {
- setRedraw(true);
- }
+ syncExec(() -> {
+ Object[] unstagedExpanded = unstagedViewer.getVisibleExpandedElements();
+ Object[] stagedExpanded = stagedViewer.getVisibleExpandedElements();
+ setRedraw(false);
+ try {
+ refreshViewersInternal();
+ unstagedViewer.setExpandedElements(unstagedExpanded);
+ stagedViewer.setExpandedElements(stagedExpanded);
+ } finally {
+ setRedraw(true);
}
});
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
index 17fd6b8ed..8278e0a24 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
@@ -314,13 +314,8 @@ public class StagingViewContentProvider extends WorkbenchContentProvider {
repository = update.repository;
Set<StagingEntry> nodes = new TreeSet<>(
- new Comparator<StagingEntry>() {
- @Override
- public int compare(StagingEntry entry1, StagingEntry entry2) {
- return String.CASE_INSENSITIVE_ORDER
- .compare(entry1.getPath(), entry2.getPath());
- }
- });
+ (StagingEntry entry1, StagingEntry entry2) -> String.CASE_INSENSITIVE_ORDER
+ .compare(entry1.getPath(), entry2.getPath()));
if (update.changedResources != null
&& !update.changedResources.isEmpty()) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java
index 8e5fd85ae..61d06d35b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/model/GitModelCommit.java
@@ -17,7 +17,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change;
import org.eclipse.egit.core.synchronize.GitCommitsModelCache.Commit;
import org.eclipse.egit.ui.internal.synchronize.model.TreeBuilder.FileModelFactory;
-import org.eclipse.egit.ui.internal.synchronize.model.TreeBuilder.TreeModelFactory;
import org.eclipse.jgit.lib.Repository;
/**
@@ -98,15 +97,8 @@ public class GitModelCommit extends GitModelObjectContainer implements
return false;
}
};
- TreeModelFactory treeModelFactory = new TreeModelFactory() {
- @Override
- public GitModelTree createTreeModel(GitModelObjectContainer parent,
- IPath fullPath, int kind) {
- return new GitModelTree(parent, fullPath, kind);
- }
- };
return TreeBuilder.build(this, repo, commit.getChildren(),
- fileModelFactory, treeModelFactory);
+ fileModelFactory, GitModelTree::new);
}
/**

Back to the top