From 2b5d27f65957c6e0957c3571edc808ff76f2ddd7 Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Wed, 15 May 2019 09:42:46 +0200 Subject: Fix formatting after lambda change Commit f7252ca introduced a number of places where the formatting did not match the Eclipse formatter settings. Reformat the changed lines. Omit redundant lambda parameter types, just use "a" and "b" for comparator parameter names, and in a few cases do other minor clean-up on the affected lines. Change-Id: Iaf459a8f2366a8176f1ca3e257e5e1900b7f8c66 Signed-off-by: Thomas Wolf --- .../src/org/eclipse/egit/core/NetUtil.java | 37 +++++++------ .../core/internal/indexdiff/IndexDiffCache.java | 8 +-- .../egit/core/op/DisconnectProviderOperation.java | 4 +- .../synchronize/GitSubscriberMergeContext.java | 3 +- .../egit/ui/common/LocalRepositoryTestCase.java | 2 +- .../org/eclipse/egit/ui/internal/CommonUtils.java | 19 +++---- .../org/eclipse/egit/ui/internal/SaveFilter.java | 8 +-- .../clone/GitCreateGeneralProjectPage.java | 20 +++---- .../components/RepositorySelectionPage.java | 2 +- .../egit/ui/internal/dialogs/CommitDialog.java | 9 +-- .../eclipse/egit/ui/internal/history/FileDiff.java | 28 +++++----- .../egit/ui/internal/history/GitHistoryPage.java | 10 ++-- .../preferences/ConfigurationEditorComponent.java | 3 +- .../egit/ui/internal/pull/PullWizardPage.java | 3 +- .../egit/ui/internal/push/PushBranchPage.java | 8 +-- .../egit/ui/internal/push/PushTagsPage.java | 5 +- .../repository/tree/command/StashDropCommand.java | 64 ++++++++-------------- .../staging/StagingViewContentProvider.java | 4 +- 18 files changed, 108 insertions(+), 129 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 4187d817f2..16622a28c4 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 @@ -32,24 +32,27 @@ import org.eclipse.jgit.transport.URIish; */ public class NetUtil { - private static TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { - @Override - public X509Certificate[] getAcceptedIssuers() { - return null; - } + private static final TrustManager[] TRUST_ALL_CERTS = new TrustManager[] { + new X509TrustManager() { + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } - @Override - public void checkClientTrusted(X509Certificate[] certs, String authType) { - // no check - } + @Override + public void checkClientTrusted(X509Certificate[] certs, + String authType) { + // no check + } - @Override - public void checkServerTrusted(X509Certificate[] certs, String authType) { - // no check - } - } }; + @Override + public void checkServerTrusted(X509Certificate[] certs, + String authType) { + // no check + } + } }; - private static HostnameVerifier trustAllHostNames = (hostname, + private static final HostnameVerifier TRUST_ALL_HOST_NAMES = (hostname, session) -> true; // always accept /** @@ -74,9 +77,9 @@ public class NetUtil { new URIish(conn.getURL().toString())); if (!http.isSslVerify()) { SSLContext ctx = SSLContext.getInstance("TLS"); //$NON-NLS-1$ - ctx.init(null, trustAllCerts, null); + ctx.init(null, TRUST_ALL_CERTS, null); httpsConn.setSSLSocketFactory(ctx.getSocketFactory()); - httpsConn.setHostnameVerifier(trustAllHostNames); + httpsConn.setHostnameVerifier(TRUST_ALL_HOST_NAMES); } } catch (KeyManagementException | NoSuchAlgorithmException | URISyntaxException e) { 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 1e54bb4fd3..249c331db9 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 @@ -52,7 +52,7 @@ public class IndexDiffCache { private CopyOnWriteArrayList listeners = new CopyOnWriteArrayList<>(); - private IndexDiffChangedListener globalListener; + private final IndexDiffChangedListener globalListener; private ExternalFileBufferListener bufferListener; @@ -207,7 +207,7 @@ public class IndexDiffCache { * constructor */ public IndexDiffCache() { - createGlobalListener(); + globalListener = this::notifyListeners; registerBufferListener(); } @@ -261,10 +261,6 @@ public class IndexDiffCache { listeners.remove(listener); } - private void createGlobalListener() { - globalListener = this::notifyListeners; - } - private void notifyListeners(Repository repository, IndexDiffData indexDiffData) { for (IndexDiffChangedListener listener : listeners) { diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java index 354b5842ad..c5d298bdd5 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DisconnectProviderOperation.java @@ -81,7 +81,9 @@ public class DisconnectProviderOperation implements IEGitOperation { if (container.isTeamPrivateMember()) { // TODO is this the right location? if (GitTraceLocation.CORE.isActive()) { - GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), "notTeamPrivate " + container); //$NON-NLS-1$ + GitTraceLocation.getTrace().trace( + GitTraceLocation.CORE.getLocation(), + "notTeamPrivate " + container); //$NON-NLS-1$ } container.setTeamPrivateMember(false); } 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 ba8f2122da..943b0da6b9 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 @@ -62,7 +62,8 @@ public class GitSubscriberMergeContext extends SubscriberMergeContext { this.gsds = gsds; - indexChangeListener = (repository, indexDiffData) -> handleRepositoryChange(repository); + indexChangeListener = (repository, + indexDiffData) -> handleRepositoryChange(repository); resourceChangeListener = event -> { IResourceDelta delta = event.getDelta(); if (delta != null) { 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 b88faf4a27..e3a6abfe61 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,7 +599,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase { protected void shareProjects(File repositoryDir) throws Exception { Repository myRepository = lookupRepository(repositoryDir); - FilenameFilter projectFilter = (File dir, String name) -> name.equals(".project"); + FilenameFilter projectFilter = (dir, 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/internal/CommonUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CommonUtils.java index d11601b059..524e6c414a 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 @@ -148,26 +148,25 @@ public class CommonUtils { * Instance of comparator which sorts {@link Ref} names using * {@link CommonUtils#STRING_ASCENDING_COMPARATOR}. */ - public static final Comparator REF_ASCENDING_COMPARATOR = (Ref o1, - Ref o2) -> STRING_ASCENDING_COMPARATOR.compare(o1.getName(), - o2.getName()); + public static final Comparator REF_ASCENDING_COMPARATOR = // + (a, b) -> STRING_ASCENDING_COMPARATOR.compare(a.getName(), + b.getName()); /** * Comparator for comparing {@link IResource} by the result of * {@link IResource#getName()}. */ - public static final Comparator RESOURCE_NAME_COMPARATOR = ( - IResource r1, IResource r2) -> Policy.getComparator() - .compare(r1.getName(), r2.getName()); + public static final Comparator RESOURCE_NAME_COMPARATOR = // + (a, b) -> Policy.getComparator().compare(a.getName(), b.getName()); /** * Comparator for comparing (@link Path} by the result of * {@link Path#toAbsolutePath()} */ - public static final Comparator PATH_STRING_COMPARATOR = (Path p1, - Path p2) -> STRING_ASCENDING_COMPARATOR.compare( - p1.toAbsolutePath().toString(), - p2.toAbsolutePath().toString()); + public static final Comparator PATH_STRING_COMPARATOR = // + (a, b) -> STRING_ASCENDING_COMPARATOR.compare( + a.toAbsolutePath().toString(), + b.toAbsolutePath().toString()); /** * Programmatically run command based on its id and given selection diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/SaveFilter.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/SaveFilter.java index 1c69899fc1..d5769e4733 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/SaveFilter.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/SaveFilter.java @@ -92,11 +92,9 @@ class SaveFilter implements ISaveableFilter { } } } catch (CoreException e) { - Activator - .logError( - NLS - .bind( - "An internal error occurred while determining the resources for {0}", saveable.getName()), e); //$NON-NLS-1$ + Activator.logError(NLS.bind( + "An internal error occurred while determining the resources for {0}", //$NON-NLS-1$ + saveable.getName()), e); } } else { // If there is no mapping, try to adapt to a resource or file directly 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 dbf956a74d..6d0be4c7f9 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 @@ -15,6 +15,7 @@ package org.eclipse.egit.ui.internal.clone; import java.io.File; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; @@ -171,20 +172,17 @@ public class GitCreateGeneralProjectPage extends WizardPage { return; } // make sure there is not already a .project file - 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 - .bind( - UIText.GitCreateGeneralProjectPage_FileExistsInDirMessage, - ".project", myDirectory.getPath())); //$NON-NLS-1$ + File projectFile = new File(myDirectory, + IProjectDescription.DESCRIPTION_FILE_NAME); + if (projectFile.exists()) { + setErrorMessage(NLS.bind( + UIText.GitCreateGeneralProjectPage_FileExistsInDirMessage, + IProjectDescription.DESCRIPTION_FILE_NAME, + myDirectory.getPath())); return; } // project name empty - if (projectName.length() == 0) { + if (projectName.isEmpty()) { setErrorMessage(UIText.GitCreateGeneralProjectPage_EnterProjectNameMessage); return; } 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 ad72d6daee..9842ea2e9d 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 @@ -434,7 +434,7 @@ 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((RemoteConfig rc) -> { + remoteCombo.addRemoteSelectionListener(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 6d86d50f87..439819eb1f 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,11 +479,12 @@ public class CommitDialog extends TitleAreaDialog { } // initially, we sort by status plus path - Collections.sort(items, (CommitItem o1, CommitItem o2) -> { - int diff = o1.status.ordinal() - o2.status.ordinal(); - if (diff != 0) + Collections.sort(items, (a, b) -> { + int diff = a.status.ordinal() - b.status.ordinal(); + if (diff != 0) { return diff; - return o1.path.compareToIgnoreCase(o2.path); + } + return a.path.compareToIgnoreCase(b.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 8aaac0ce9c..3bbd68d54e 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,19 +65,21 @@ 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 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)); - }; + public static final Comparator PATH_COMPARATOR = // + (left, 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 7b8a400679..ee1deea7d2 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 @@ -1709,13 +1709,11 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, if (refschangedRunnable == null) { refschangedRunnable = () -> { if (!getControl().isDisposed()) { - if (GitTraceLocation.HISTORYVIEW.isActive()) - GitTraceLocation - .getTrace() - .trace( - GitTraceLocation.HISTORYVIEW - .getLocation(), + if (GitTraceLocation.HISTORYVIEW.isActive()) { + GitTraceLocation.getTrace().trace( + GitTraceLocation.HISTORYVIEW.getLocation(), "Executing async repository changed event"); //$NON-NLS-1$ + } refschangedRunnable = null; initAndStartRevWalk( !(e instanceof FetchHeadChangedEvent)); 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 0b1bb4eacb..838d18cf57 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 @@ -549,7 +549,8 @@ public class ConfigurationEditorComponent { Set sectionNames = config.getSections(); for (String sectionName : sectionNames) sections.add(new Section(this, sectionName)); - Collections.sort(sections, (Section o1, Section o2) -> o1.name.compareTo(o2.name)); + Collections.sort(sections, + (a, b) -> a.name.compareTo(b.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 1d296d137f..7f343c0eab 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 @@ -151,8 +151,7 @@ public class PullWizardPage extends WizardPage { GridDataFactory.fillDefaults().grab(true, false) .applyTo(remoteSelectionCombo); setRemoteConfigs(); - remoteSelectionCombo - .addRemoteSelectionListener((RemoteConfig rc) -> { + remoteSelectionCombo.addRemoteSelectionListener(rc -> { remoteConfig = rc; setRefAssist(rc); checkPage(); 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 8450f588b5..06734b7d3a 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 @@ -271,8 +271,7 @@ public class PushBranchPage extends WizardPage { GridDataFactory.fillDefaults().grab(true, false).span(remoteSelectionSpan, 1) .applyTo(remoteSelectionCombo); setRemoteConfigs(); - remoteSelectionCombo - .addRemoteSelectionListener((RemoteConfig rc) -> { + remoteSelectionCombo.addRemoteSelectionListener(rc -> { remoteConfig = rc; setRefAssist(rc); checkPage(); @@ -327,9 +326,8 @@ public class PushBranchPage extends WizardPage { upstreamConfigComponent.getContainer().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).span(3, 1) .indent(SWT.NONE, 20).create()); - upstreamConfigComponent - .addUpstreamConfigSelectionListener((BranchRebaseMode newUpstreamConfig) -> { - upstreamConfig = newUpstreamConfig; + upstreamConfigComponent.addUpstreamConfigSelectionListener(cfg -> { + upstreamConfig = cfg; 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 98f574e209..7269f001d3 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 @@ -98,9 +98,8 @@ public class PushTagsPage extends WizardPage { .grab(true, false).create()); selectedRemoteConfig = remoteSelectionCombo .setItems(getRemoteConfigs()); - remoteSelectionCombo - .addRemoteSelectionListener((RemoteConfig remoteConfig) -> { - selectedRemoteConfig = remoteConfig; + remoteSelectionCombo.addRemoteSelectionListener(rc -> { + selectedRemoteConfig = rc; }); tagsLabel = new Label(main, SWT.NONE); 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 466ee3aec8..f1456a3922 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 @@ -101,12 +101,8 @@ public class StashDropCommand // 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, - (StashedCommitNode n1, - StashedCommitNode n2) -> n1 - .getIndex() < n2.getIndex() ? 1 - : -1); + Collections.sort(nodes, + (a, b) -> a.getIndex() < b.getIndex() ? 1 : -1); for (StashedCommitNode node : nodes) { final int index = node.getIndex(); @@ -134,41 +130,29 @@ public class StashDropCommand } 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(() -> { + 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); } - }); - + } + } + }); } @Override 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 8278e0a24f..a0f58339fa 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,8 +314,8 @@ public class StagingViewContentProvider extends WorkbenchContentProvider { repository = update.repository; Set nodes = new TreeSet<>( - (StagingEntry entry1, StagingEntry entry2) -> String.CASE_INSENSITIVE_ORDER - .compare(entry1.getPath(), entry2.getPath())); + (a, b) -> String.CASE_INSENSITIVE_ORDER.compare(a.getPath(), + b.getPath())); if (update.changedResources != null && !update.changedResources.isEmpty()) { -- cgit v1.2.3