Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.core.junit/src/org/eclipse/egit/core/test/TestUtils.java3
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/SshPreferencesMirrorTest.java65
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java17
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java38
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/SshPreferencesMirror.java18
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/Utils.java33
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java42
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java4
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java2
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/menu/DynamicHistoryMenu.java3
-rw-r--r--org.eclipse.egit.target/egit-4.10.target20
-rw-r--r--org.eclipse.egit.target/egit-4.10.tpd2
-rw-r--r--org.eclipse.egit.target/egit-4.11.target20
-rw-r--r--org.eclipse.egit.target/egit-4.11.tpd2
-rw-r--r--org.eclipse.egit.target/egit-4.12-staging.target20
-rw-r--r--org.eclipse.egit.target/egit-4.12-staging.tpd2
-rw-r--r--org.eclipse.egit.target/egit-4.6.target20
-rw-r--r--org.eclipse.egit.target/egit-4.6.tpd2
-rw-r--r--org.eclipse.egit.target/egit-4.7.target20
-rw-r--r--org.eclipse.egit.target/egit-4.7.tpd2
-rw-r--r--org.eclipse.egit.target/egit-4.8.target20
-rw-r--r--org.eclipse.egit.target/egit-4.8.tpd2
-rw-r--r--org.eclipse.egit.target/egit-4.9.target20
-rw-r--r--org.eclipse.egit.target/egit-4.9.tpd2
-rw-r--r--org.eclipse.egit.target/orbit/R20190602212107-2019-06.tpd (renamed from org.eclipse.egit.target/orbit/S20190521195709.tpd)20
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecoratorTest.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/selection/SelectionForViewsTest.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/operations/GitScopeUtilTest.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java9
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/TestCommitMessageProviderExtensionFactory.java5
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ActionUtils.java109
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitLabelProvider.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/RepositorySaveableFilter.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadActionHandler.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/TagActionHandler.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/MultiPageEditorContentOutlinePage.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/NotesEditorPage.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/CachedCheckboxTreeViewer.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/ProblemLabelDecorator.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/HyperlinkTokenScanner.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/ShowWhitespaceAction.java149
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageArea.java338
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/TextEditorPropertyAction.java147
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/expressions/GitPropertyTester.java19
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/handler/SelectionHandler.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java12
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java41
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractRebaseHistoryCommandHandler.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GlobalConfigurationPreferencePage.java27
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseInteractiveView.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertyPage.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionPropertyTester.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionUtils.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitChangeSetModelProvider.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronizeParticipant.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/OpenWorkingFileAction.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitChangeSetContentProvider.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitTemplateVariableResolver.java4
85 files changed, 879 insertions, 702 deletions
diff --git a/org.eclipse.egit.core.junit/src/org/eclipse/egit/core/test/TestUtils.java b/org.eclipse.egit.core.junit/src/org/eclipse/egit/core/test/TestUtils.java
index 569bf4e5e..a18cd8935 100644
--- a/org.eclipse.egit.core.junit/src/org/eclipse/egit/core/test/TestUtils.java
+++ b/org.eclipse.egit.core.junit/src/org/eclipse/egit/core/test/TestUtils.java
@@ -242,8 +242,7 @@ public class TestUtils {
public void assertRepositoryContainsFiles(Repository repository,
String[] paths) throws Exception {
Set<String> expectedfiles = new HashSet<>();
- for (String path : paths)
- expectedfiles.add(path);
+ expectedfiles.addAll(Arrays.asList(paths));
try (TreeWalk treeWalk = new TreeWalk(repository)) {
treeWalk.addTree(repository.resolve("HEAD^{tree}"));
treeWalk.setRecursive(true);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/SshPreferencesMirrorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/SshPreferencesMirrorTest.java
new file mode 100644
index 000000000..7fed0e928
--- /dev/null
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/SshPreferencesMirrorTest.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (C) 2019 Thomas Wolf <thomas.wolf@paranor.ch>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.egit.core.internal;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+public class SshPreferencesMirrorTest {
+
+ @Rule
+ public TemporaryFolder tmp = new TemporaryFolder();
+
+ @Before
+ public void prepareMirror() throws Exception {
+ SshPreferencesMirror.INSTANCE.start();
+ }
+
+ @After
+ public void resetPreferences() throws Exception {
+ set("PRIVATEKEY", null);
+ }
+
+ private void set(String key, String value) throws Exception {
+ IEclipsePreferences preferences = InstanceScope.INSTANCE
+ .getNode("org.eclipse.jsch.core");
+ if (value == null) {
+ preferences.remove(key);
+ } else {
+ preferences.put(key, value);
+ }
+ preferences.flush();
+ }
+
+ @Test
+ public void testAbsoluteKeyPath() throws Exception {
+ File fakeSshHome = tmp.newFolder("faks_ssh_home");
+ File otherDirectory = tmp.newFolder("other");
+ File fakeDefaultKey = File.createTempFile("id_", "key", fakeSshHome);
+ File fakeOtherKey = File.createTempFile("other", "key", otherDirectory);
+ set("PRIVATEKEY", fakeDefaultKey.getName() + ','
+ + fakeOtherKey.getAbsolutePath());
+ assertEquals(
+ '[' + fakeDefaultKey.getAbsolutePath() + ", "
+ + fakeOtherKey.getAbsolutePath() + ']',
+ SshPreferencesMirror.INSTANCE.getDefaultIdentities(fakeSshHome)
+ .toString());
+ }
+}
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
index fcf0d5559..8812edb71 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
@@ -26,13 +26,12 @@ import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.egit.core.AdapterUtils;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.op.MergeOperation;
import org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber;
import org.eclipse.egit.core.synchronize.GitSubscriberMergeContext;
@@ -111,7 +110,7 @@ public abstract class ModelTestCase extends GitTestCase {
.getModelProviderDescriptor(
SampleModelProvider.SAMPLE_PROVIDER_ID)
.getModelProvider();
- return Utils.getAdapter(provider, IResourceMappingMerger.class);
+ return Adapters.adapt(provider, IResourceMappingMerger.class);
}
protected IMergeContext prepareContext(Repository repository,
@@ -123,7 +122,7 @@ public abstract class ModelTestCase extends GitTestCase {
gsds);
subscriber.init(new NullProgressMonitor());
- ResourceMapping mapping = AdapterUtils.adapt(workspaceFile,
+ ResourceMapping mapping = Adapters.adapt(workspaceFile,
ResourceMapping.class);
SubscriberScopeManager manager = new SubscriberScopeManager(
subscriber.getName(), new ResourceMapping[] { mapping, },
@@ -139,16 +138,16 @@ public abstract class ModelTestCase extends GitTestCase {
protected IMergeContext prepareModelContext(Repository repository,
IFile workspaceFile, String srcRev, String dstRev) throws Exception {
- Set<IResource> includedResources = new HashSet<IResource>(
+ Set<IResource> includedResources = new HashSet<>(
Arrays.asList(workspaceFile));
- Set<IResource> newResources = new HashSet<IResource>(includedResources);
- Set<ResourceMapping> allMappings = new HashSet<ResourceMapping>();
+ Set<IResource> newResources = new HashSet<>(includedResources);
+ Set<ResourceMapping> allMappings = new HashSet<>();
ResourceMappingContext mappingContext = ResourceMappingContext.LOCAL_CONTEXT;
ModelProvider provider = ModelProvider.getModelProviderDescriptor(
SampleModelProvider.SAMPLE_PROVIDER_ID).getModelProvider();
do {
Set<IResource> copy = newResources;
- newResources = new HashSet<IResource>();
+ newResources = new HashSet<>();
for (IResource resource : copy) {
ResourceMapping[] mappings = provider.getMappings(resource,
mappingContext, new NullProgressMonitor());
@@ -183,7 +182,7 @@ public abstract class ModelTestCase extends GitTestCase {
private static Set<IResource> collectResources(ResourceMapping[] mappings,
ResourceMappingContext mappingContext) throws Exception {
- final Set<IResource> resources = new HashSet<IResource>();
+ final Set<IResource> resources = new HashSet<>();
for (ResourceMapping mapping : mappings) {
ResourceTraversal[] traversals = mapping.getTraversals(
mappingContext, new NullProgressMonitor());
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java
index d79d66cad..d9cf678ac 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java
@@ -16,10 +16,8 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.jgit.annotations.Nullable;
/**
@@ -32,32 +30,6 @@ public class AdapterUtils {
}
/**
- * Adapt object to given target class type
- *
- * @param object
- * @param target
- * @param <V> type of target
- * @return adapted
- */
- @Nullable
- public static <V> V adapt(Object object, Class<V> target) {
- if (object == null) {
- return null;
- }
- if (target.isInstance(object)) {
- return target.cast(object);
- }
- if (object instanceof IAdaptable) {
- V adapter = Utils.getAdapter(((IAdaptable) object), target);
- if (adapter != null || object instanceof PlatformObject) {
- return adapter;
- }
- }
- Object adapted = Platform.getAdapterManager().getAdapter(object, target);
- return target.cast(adapted);
- }
-
- /**
* Adapt object to one interface from list: {@link IResource},
* {@link IContainer}, {@link IFile} or {@link IProject}.
*
@@ -69,19 +41,19 @@ public class AdapterUtils {
if (object == null) {
return null;
}
- IResource resource = adapt(object, IResource.class);
+ IResource resource = Adapters.adapt(object, IResource.class);
if (resource != null) {
return resource;
}
- resource = adapt(object, IFile.class);
+ resource = Adapters.adapt(object, IFile.class);
if (resource != null) {
return resource;
}
- resource = adapt(object, IProject.class);
+ resource = Adapters.adapt(object, IProject.class);
if (resource != null) {
return resource;
}
- resource = adapt(object, IContainer.class);
+ resource = Adapters.adapt(object, IContainer.class);
if (resource != null) {
return resource;
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java
index 34246c7a7..ca62bc839 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java
@@ -502,9 +502,6 @@ public class CoreText extends NLS {
public static String SubmoduleUpdateOperation_cloning;
/** */
- public static String Utils_InvalidAdapterError;
-
- /** */
public static String ValidationUtils_CanNotResolveRefMessage;
/** */
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/SshPreferencesMirror.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/SshPreferencesMirror.java
index dcfafbca3..8c73aab60 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/SshPreferencesMirror.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/SshPreferencesMirror.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2018, Thomas Wolf <thomas.wolf@paranor.ch>
+ * Copyright (C) 2018, 2019 Thomas Wolf <thomas.wolf@paranor.ch>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -58,12 +58,18 @@ public class SshPreferencesMirror {
private String defaultMechanisms;
+ private boolean started;
+
private SshPreferencesMirror() {
// This is a singleton.
}
/** Starts mirroring the ssh preferences. */
public void start() {
+ if (started) {
+ return;
+ }
+ started = true;
preferences = InstanceScope.INSTANCE.getNode(PREFERENCES_NODE);
if (preferences != null) {
preferences.addPreferenceChangeListener(listener);
@@ -73,6 +79,7 @@ public class SshPreferencesMirror {
/** Stops mirroring the ssh preferences. */
public void stop() {
+ started = false;
if (preferences != null) {
preferences.removePreferenceChangeListener(listener);
}
@@ -168,8 +175,13 @@ public class SshPreferencesMirror {
return null;
}
return defaultIdentities.stream()
- .map(s -> new File(sshDir, s).toPath())
- .filter(Files::exists).collect(Collectors.toList());
+ .map(s -> {
+ File f = new File(s);
+ if (!f.isAbsolute()) {
+ f = new File(sshDir, s);
+ }
+ return f.toPath();
+ }).filter(Files::exists).collect(Collectors.toList());
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/Utils.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/Utils.java
index 82abd31c2..afbfab3dc 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/Utils.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/Utils.java
@@ -17,7 +17,6 @@ import java.io.IOException;
import java.text.MessageFormat;
import java.util.Collection;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.egit.core.Activator;
import org.eclipse.jgit.annotations.NonNull;
@@ -96,38 +95,6 @@ public class Utils {
}
/**
- * Returns the adapter corresponding to the given adapter class.
- * <p>
- * Workaround for "Unnecessary cast" errors, see bug 460685. Can be removed
- * when EGit depends on Eclipse 4.5 or higher.
- *
- * @param adaptable
- * the adaptable
- * @param adapterClass
- * the adapter class to look up
- * @return a object of the given class, or <code>null</code> if this object
- * does not have an adapter for the given class
- */
- public static <T> T getAdapter(IAdaptable adaptable, Class<T> adapterClass) {
- Object adapter = adaptable.getAdapter(adapterClass);
- if (adapter == null) {
- return null;
- }
- // Guard against misbehaving IAdaptables...
- if (adapterClass.isInstance(adapter)) {
- return adapterClass.cast(adapter);
- } else {
- Activator.logError(
- MessageFormat.format(CoreText.Utils_InvalidAdapterError,
- adaptable.getClass().getName(),
- adapterClass.getName(),
- adapter.getClass().getName()),
- new IllegalStateException());
- return null;
- }
- }
-
- /**
* Validates a given ref name, including testing whether a ref with that
* name already exists, or if the name conflicts with an already existing
* ref.
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties
index 432624ae0..6a8251df4 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties
@@ -204,8 +204,6 @@ MergeStrategy_ReservedName=The strategy name {0} is reserved by JGit for class {
SubmoduleUpdateOperation_updating=Updating submodules in {0}
SubmoduleUpdateOperation_cloning=Updating submodules in {0}: cloning submodule {1}
-Utils_InvalidAdapterError={0}.getAdapter({1}.class) returned an object of type {2}, which is not of the requested type. Please ask the provider of {0} to fix this bug in their code.
-
ValidationUtils_CanNotResolveRefMessage=Cannot resolve {0}
ValidationUtils_InvalidRefNameMessage={0} is not a valid name for a ref
ValidationUtils_InvalidRevision=Invalid revision {0}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
index a076b542b..842a2f3ca 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
@@ -18,11 +18,11 @@ import java.util.Collections;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.internal.CoreText;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.synchronize.GitRemoteResource;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
@@ -211,33 +211,35 @@ class GitFileHistory extends FileHistory implements IAdaptable {
}
private String getGitPath(IFileRevision revision) {
- if (revision instanceof CommitFileRevision)
+ if (revision instanceof CommitFileRevision) {
return ((CommitFileRevision) revision).getGitPath();
- else if (revision instanceof IAdaptable) {
- final IResourceVariant variant = Utils.getAdapter(((IAdaptable) revision), IResourceVariant.class);
-
- if (variant instanceof GitRemoteResource)
- return ((GitRemoteResource) variant).getPath();
}
+ IResourceVariant variant = Adapters.adapt(revision,
+ IResourceVariant.class);
+ if (variant instanceof GitRemoteResource) {
+ return ((GitRemoteResource) variant).getPath();
+ }
return null;
}
private RevCommit getRevCommit(IFileRevision revision) {
- if (revision instanceof CommitFileRevision)
+ if (revision instanceof CommitFileRevision) {
return ((CommitFileRevision) revision).getRevCommit();
- else if (revision instanceof IAdaptable) {
- final IResourceVariant variant = Utils.getAdapter(((IAdaptable) revision), IResourceVariant.class);
- if (variant instanceof GitRemoteResource) {
- final RevCommit commit = ((GitRemoteResource) variant)
- .getCommitId();
- try {
- return walk.parseCommit(commit);
- } catch (IOException e) {
- Activator.logError(NLS.bind(
- CoreText.GitFileHistory_invalidCommit,
- commit.getName(), resource.getName()), e);
- }
+ }
+ IResourceVariant variant = Adapters.adapt(revision,
+ IResourceVariant.class);
+ if (variant instanceof GitRemoteResource) {
+ final RevCommit commit = ((GitRemoteResource) variant)
+ .getCommitId();
+ try {
+ return walk.parseCommit(commit);
+ } catch (IOException e) {
+ Activator
+ .logError(
+ NLS.bind(CoreText.GitFileHistory_invalidCommit,
+ commit.getName(), resource.getName()),
+ e);
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java
index 317269326..e2a62e6fc 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ResourceUtil.java
@@ -648,8 +648,7 @@ public class ResourceUtil {
}
final ResourceMapping[] modelMappings = model.getMappings(
resource, context, new NullProgressMonitor());
- for (ResourceMapping mapping : modelMappings)
- mappings.add(mapping);
+ mappings.addAll(Arrays.asList(modelMappings));
}
} catch (CoreException e) {
Activator.logError(e.getMessage(), e);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
index 56f7f8096..425ab6985 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
@@ -38,6 +38,7 @@ import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -52,7 +53,6 @@ import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.GitCorePreferences;
import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.core.internal.CoreText;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.jgit.annotations.NonNull;
@@ -667,7 +667,7 @@ public class GitProjectData {
if (r instanceof IContainer) {
c = (IContainer) r;
} else if (r != null) {
- c = Utils.getAdapter(r, IContainer.class);
+ c = Adapters.adapt(r, IContainer.class);
}
if (c == null) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java
index 38995c217..9c50d4693 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/securestorage/EGitSecureStore.java
@@ -120,7 +120,7 @@ public class EGitSecureStore {
return;
ISecurePreferences node = preferences.node(pathName);
node.removeNode();
- node.flush();
+ preferences.flush();
}
}
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/menu/DynamicHistoryMenu.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/menu/DynamicHistoryMenu.java
index 4709140fa..1037f7f2b 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/menu/DynamicHistoryMenu.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/menu/DynamicHistoryMenu.java
@@ -14,6 +14,7 @@ import static org.eclipse.egit.gitflow.ui.Activator.error;
import java.io.IOException;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.gitflow.Activator;
import org.eclipse.egit.gitflow.GitFlowRepository;
@@ -96,7 +97,7 @@ public class DynamicHistoryMenu extends ContributionItem {
private GitFlowRepository getRepository() {
IWorkbenchPart activePart = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActivePart();
- Repository repository = Utils.getAdapter(activePart, Repository.class);
+ Repository repository = Adapters.adapt(activePart, Repository.class);
if (repository == null) {
return null;
}
diff --git a/org.eclipse.egit.target/egit-4.10.target b/org.eclipse.egit.target/egit-4.10.target
index e90802a7d..5a3b96c29 100644
--- a/org.eclipse.egit.target/egit-4.10.target
+++ b/org.eclipse.egit.target/egit-4.10.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="egit-4.10" sequenceNumber="1558550707">
+<target name="egit-4.10" sequenceNumber="1559548233">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -40,8 +40,8 @@
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="javax.xml.bind" version="2.2.0.v201105210648"/>
<unit id="javax.xml.stream" version="1.0.1.v201004272200"/>
- <unit id="org.apache.ant" version="1.10.6.v20190516-0412"/>
- <unit id="org.apache.ant.source" version="1.10.6.v20190516-0412"/>
+ <unit id="org.apache.ant" version="1.10.5.v20190526-1402"/>
+ <unit id="org.apache.ant.source" version="1.10.5.v20190526-1402"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.compress" version="1.18.0.v20181121-2221"/>
@@ -54,12 +54,12 @@
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.61.0.v20190602-1335"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -97,7 +97,7 @@
<unit id="org.apache.sshd.osgi.source" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp.source" version="2.2.0.v20190425-2127"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository"/>
+ <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.10.tpd b/org.eclipse.egit.target/egit-4.10.tpd
index db7502deb..fa395b3a5 100644
--- a/org.eclipse.egit.target/egit-4.10.tpd
+++ b/org.eclipse.egit.target/egit-4.10.tpd
@@ -2,5 +2,5 @@ target "egit-4.10" with source configurePhase
include "projects/jetty-9.4.14.tpd"
include "projects/swtbot-snapshot.tpd"
-include "orbit/S20190521195709.tpd"
+include "orbit/R20190602212107-2019-06.tpd"
include "releasetrain/4.10-2018-12.tpd"
diff --git a/org.eclipse.egit.target/egit-4.11.target b/org.eclipse.egit.target/egit-4.11.target
index 093dcf71c..efc4c9088 100644
--- a/org.eclipse.egit.target/egit-4.11.target
+++ b/org.eclipse.egit.target/egit-4.11.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="egit-4.11" sequenceNumber="1558550750">
+<target name="egit-4.11" sequenceNumber="1559548257">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -40,8 +40,8 @@
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="javax.xml.bind" version="2.2.0.v201105210648"/>
<unit id="javax.xml.stream" version="1.0.1.v201004272200"/>
- <unit id="org.apache.ant" version="1.10.6.v20190516-0412"/>
- <unit id="org.apache.ant.source" version="1.10.6.v20190516-0412"/>
+ <unit id="org.apache.ant" version="1.10.5.v20190526-1402"/>
+ <unit id="org.apache.ant.source" version="1.10.5.v20190526-1402"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.compress" version="1.18.0.v20181121-2221"/>
@@ -54,12 +54,12 @@
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.61.0.v20190602-1335"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -97,7 +97,7 @@
<unit id="org.apache.sshd.osgi.source" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp.source" version="2.2.0.v20190425-2127"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository"/>
+ <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.11.tpd b/org.eclipse.egit.target/egit-4.11.tpd
index 737c4e0c1..99c21b1f3 100644
--- a/org.eclipse.egit.target/egit-4.11.tpd
+++ b/org.eclipse.egit.target/egit-4.11.tpd
@@ -2,5 +2,5 @@ target "egit-4.11" with source configurePhase
include "projects/jetty-9.4.14.tpd"
include "projects/swtbot-snapshot.tpd"
-include "orbit/S20190521195709.tpd"
+include "orbit/R20190602212107-2019-06.tpd"
include "releasetrain/4.11-2019-03.tpd"
diff --git a/org.eclipse.egit.target/egit-4.12-staging.target b/org.eclipse.egit.target/egit-4.12-staging.target
index cf086aed4..02942dda5 100644
--- a/org.eclipse.egit.target/egit-4.12-staging.target
+++ b/org.eclipse.egit.target/egit-4.12-staging.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="egit-4.12-staging" sequenceNumber="1558550752">
+<target name="egit-4.12-staging" sequenceNumber="1559548260">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -40,8 +40,8 @@
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="javax.xml.bind" version="2.2.0.v201105210648"/>
<unit id="javax.xml.stream" version="1.0.1.v201004272200"/>
- <unit id="org.apache.ant" version="1.10.6.v20190516-0412"/>
- <unit id="org.apache.ant.source" version="1.10.6.v20190516-0412"/>
+ <unit id="org.apache.ant" version="1.10.5.v20190526-1402"/>
+ <unit id="org.apache.ant.source" version="1.10.5.v20190526-1402"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.compress" version="1.18.0.v20181121-2221"/>
@@ -54,12 +54,12 @@
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.61.0.v20190602-1335"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -97,7 +97,7 @@
<unit id="org.apache.sshd.osgi.source" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp.source" version="2.2.0.v20190425-2127"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository"/>
+ <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.12-staging.tpd b/org.eclipse.egit.target/egit-4.12-staging.tpd
index 1744dca8f..013e8a5fe 100644
--- a/org.eclipse.egit.target/egit-4.12-staging.tpd
+++ b/org.eclipse.egit.target/egit-4.12-staging.tpd
@@ -2,5 +2,5 @@ target "egit-4.12-staging" with source configurePhase
include "projects/jetty-9.4.14.tpd"
include "projects/swtbot-snapshot.tpd"
-include "orbit/S20190521195709.tpd"
+include "orbit/R20190602212107-2019-06.tpd"
include "releasetrain/staging.tpd"
diff --git a/org.eclipse.egit.target/egit-4.6.target b/org.eclipse.egit.target/egit-4.6.target
index a0f5b0b29..5dbeaa2a0 100644
--- a/org.eclipse.egit.target/egit-4.6.target
+++ b/org.eclipse.egit.target/egit-4.6.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="egit-4.6" sequenceNumber="1558550774">
+<target name="egit-4.6" sequenceNumber="1559548284">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -40,8 +40,8 @@
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="javax.xml.bind" version="2.2.0.v201105210648"/>
<unit id="javax.xml.stream" version="1.0.1.v201004272200"/>
- <unit id="org.apache.ant" version="1.10.6.v20190516-0412"/>
- <unit id="org.apache.ant.source" version="1.10.6.v20190516-0412"/>
+ <unit id="org.apache.ant" version="1.10.5.v20190526-1402"/>
+ <unit id="org.apache.ant.source" version="1.10.5.v20190526-1402"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.compress" version="1.18.0.v20181121-2221"/>
@@ -54,12 +54,12 @@
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.61.0.v20190602-1335"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -97,7 +97,7 @@
<unit id="org.apache.sshd.osgi.source" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp.source" version="2.2.0.v20190425-2127"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository"/>
+ <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.6.tpd b/org.eclipse.egit.target/egit-4.6.tpd
index 1865086cb..6cdaddbe9 100644
--- a/org.eclipse.egit.target/egit-4.6.tpd
+++ b/org.eclipse.egit.target/egit-4.6.tpd
@@ -2,5 +2,5 @@ target "egit-4.6" with source configurePhase
include "projects/jetty-9.4.14.tpd"
include "projects/swtbot-snapshot.tpd"
-include "orbit/S20190521195709.tpd"
+include "orbit/R20190602212107-2019-06.tpd"
include "releasetrain/4.6-neon.tpd"
diff --git a/org.eclipse.egit.target/egit-4.7.target b/org.eclipse.egit.target/egit-4.7.target
index 619ec049a..42d8515a4 100644
--- a/org.eclipse.egit.target/egit-4.7.target
+++ b/org.eclipse.egit.target/egit-4.7.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="egit-4.7" sequenceNumber="1558550768">
+<target name="egit-4.7" sequenceNumber="1559548276">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -40,8 +40,8 @@
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="javax.xml.bind" version="2.2.0.v201105210648"/>
<unit id="javax.xml.stream" version="1.0.1.v201004272200"/>
- <unit id="org.apache.ant" version="1.10.6.v20190516-0412"/>
- <unit id="org.apache.ant.source" version="1.10.6.v20190516-0412"/>
+ <unit id="org.apache.ant" version="1.10.5.v20190526-1402"/>
+ <unit id="org.apache.ant.source" version="1.10.5.v20190526-1402"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.compress" version="1.18.0.v20181121-2221"/>
@@ -54,12 +54,12 @@
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.61.0.v20190602-1335"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -97,7 +97,7 @@
<unit id="org.apache.sshd.osgi.source" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp.source" version="2.2.0.v20190425-2127"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository"/>
+ <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.7.tpd b/org.eclipse.egit.target/egit-4.7.tpd
index 4d53162cd..a21f155b1 100644
--- a/org.eclipse.egit.target/egit-4.7.tpd
+++ b/org.eclipse.egit.target/egit-4.7.tpd
@@ -2,5 +2,5 @@ target "egit-4.7" with source configurePhase
include "projects/jetty-9.4.14.tpd"
include "projects/swtbot-snapshot.tpd"
-include "orbit/S20190521195709.tpd"
+include "orbit/R20190602212107-2019-06.tpd"
include "releasetrain/4.7-oxygen.tpd"
diff --git a/org.eclipse.egit.target/egit-4.8.target b/org.eclipse.egit.target/egit-4.8.target
index 6d9afd7cc..b996b6836 100644
--- a/org.eclipse.egit.target/egit-4.8.target
+++ b/org.eclipse.egit.target/egit-4.8.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="egit-4.8" sequenceNumber="1558550767">
+<target name="egit-4.8" sequenceNumber="1559548274">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -40,8 +40,8 @@
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="javax.xml.bind" version="2.2.0.v201105210648"/>
<unit id="javax.xml.stream" version="1.0.1.v201004272200"/>
- <unit id="org.apache.ant" version="1.10.6.v20190516-0412"/>
- <unit id="org.apache.ant.source" version="1.10.6.v20190516-0412"/>
+ <unit id="org.apache.ant" version="1.10.5.v20190526-1402"/>
+ <unit id="org.apache.ant.source" version="1.10.5.v20190526-1402"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.compress" version="1.18.0.v20181121-2221"/>
@@ -54,12 +54,12 @@
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.61.0.v20190602-1335"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -97,7 +97,7 @@
<unit id="org.apache.sshd.osgi.source" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp.source" version="2.2.0.v20190425-2127"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository"/>
+ <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.8.tpd b/org.eclipse.egit.target/egit-4.8.tpd
index b333b5ce4..459e329ff 100644
--- a/org.eclipse.egit.target/egit-4.8.tpd
+++ b/org.eclipse.egit.target/egit-4.8.tpd
@@ -2,5 +2,5 @@ target "egit-4.8" with source configurePhase
include "projects/jetty-9.4.14.tpd"
include "projects/swtbot-snapshot.tpd"
-include "orbit/S20190521195709.tpd"
+include "orbit/R20190602212107-2019-06.tpd"
include "releasetrain/4.8-photon.tpd"
diff --git a/org.eclipse.egit.target/egit-4.9.target b/org.eclipse.egit.target/egit-4.9.target
index eaa047eb2..03921faab 100644
--- a/org.eclipse.egit.target/egit-4.9.target
+++ b/org.eclipse.egit.target/egit-4.9.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="egit-4.9" sequenceNumber="1558550772">
+<target name="egit-4.9" sequenceNumber="1559548279">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -40,8 +40,8 @@
<unit id="javax.servlet.source" version="3.1.0.v201410161800"/>
<unit id="javax.xml.bind" version="2.2.0.v201105210648"/>
<unit id="javax.xml.stream" version="1.0.1.v201004272200"/>
- <unit id="org.apache.ant" version="1.10.6.v20190516-0412"/>
- <unit id="org.apache.ant.source" version="1.10.6.v20190516-0412"/>
+ <unit id="org.apache.ant" version="1.10.5.v20190526-1402"/>
+ <unit id="org.apache.ant.source" version="1.10.5.v20190526-1402"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/>
<unit id="org.apache.commons.compress" version="1.18.0.v20181121-2221"/>
@@ -54,12 +54,12 @@
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov" version="1.61.0.v20190602-1335"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.61.0.v20190602-1335"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -97,7 +97,7 @@
<unit id="org.apache.sshd.osgi.source" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp" version="2.2.0.v20190425-2127"/>
<unit id="org.apache.sshd.sftp.source" version="2.2.0.v20190425-2127"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository"/>
+ <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
diff --git a/org.eclipse.egit.target/egit-4.9.tpd b/org.eclipse.egit.target/egit-4.9.tpd
index 1a5a3e64f..9772bc0b4 100644
--- a/org.eclipse.egit.target/egit-4.9.tpd
+++ b/org.eclipse.egit.target/egit-4.9.tpd
@@ -2,5 +2,5 @@ target "egit-4.9" with source configurePhase
include "projects/jetty-9.4.14.tpd"
include "projects/swtbot-snapshot.tpd"
-include "orbit/S20190521195709.tpd"
+include "orbit/R20190602212107-2019-06.tpd"
include "releasetrain/4.9-2018-09.tpd"
diff --git a/org.eclipse.egit.target/orbit/S20190521195709.tpd b/org.eclipse.egit.target/orbit/R20190602212107-2019-06.tpd
index 97347b649..f25d7e41e 100644
--- a/org.eclipse.egit.target/orbit/S20190521195709.tpd
+++ b/org.eclipse.egit.target/orbit/R20190602212107-2019-06.tpd
@@ -1,7 +1,7 @@
-target "S20190521195709" with source configurePhase
+target "R20190602212107-2019-06" with source configurePhase
// see http://download.eclipse.org/tools/orbit/downloads/
-location "http://download.eclipse.org/tools/orbit/downloads/drops/S20190521195709/repository" {
+location "https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository" {
com.google.gson [2.8.2.v20180104-1110,2.8.2.v20180104-1110]
com.google.gson.source [2.8.2.v20180104-1110,2.8.2.v20180104-1110]
com.jcraft.jsch [0.1.55.v20190404-1902,0.1.55.v20190404-1902]
@@ -13,8 +13,8 @@ location "http://download.eclipse.org/tools/orbit/downloads/drops/S2019052119570
javax.servlet.source [3.1.0.v201410161800,3.1.0.v201410161800]
javax.xml.bind [2.2.0.v201105210648,2.2.0.v201105210648]
javax.xml.stream [1.0.1.v201004272200,1.0.1.v201004272200]
- org.apache.ant [1.10.6.v20190516-0412,1.10.6.v20190516-0412]
- org.apache.ant.source [1.10.6.v20190516-0412,1.10.6.v20190516-0412]
+ org.apache.ant [1.10.5.v20190526-1402,1.10.5.v20190526-1402]
+ org.apache.ant.source [1.10.5.v20190526-1402,1.10.5.v20190526-1402]
org.apache.commons.codec [1.10.0.v20180409-1845,1.10.0.v20180409-1845]
org.apache.commons.codec.source [1.10.0.v20180409-1845,1.10.0.v20180409-1845]
org.apache.commons.compress [1.18.0.v20181121-2221,1.18.0.v20181121-2221]
@@ -27,12 +27,12 @@ location "http://download.eclipse.org/tools/orbit/downloads/drops/S2019052119570
org.apache.httpcomponents.httpcore.source [4.4.10.v20190123-2214,4.4.10.v20190123-2214]
org.apache.log4j [1.2.15.v201012070815,1.2.15.v201012070815]
org.apache.log4j.source [1.2.15.v201012070815,1.2.15.v201012070815]
- org.bouncycastle.bcpg [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
- org.bouncycastle.bcpg.source [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
- org.bouncycastle.bcpkix [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
- org.bouncycastle.bcpkix.source [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
- org.bouncycastle.bcprov [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
- org.bouncycastle.bcprov.source [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
+ org.bouncycastle.bcpg [1.61.0.v20190602-1335,1.61.0.v20190602-1335]
+ org.bouncycastle.bcpg.source [1.61.0.v20190602-1335,1.61.0.v20190602-1335]
+ org.bouncycastle.bcpkix [1.61.0.v20190602-1335,1.61.0.v20190602-1335]
+ org.bouncycastle.bcpkix.source [1.61.0.v20190602-1335,1.61.0.v20190602-1335]
+ org.bouncycastle.bcprov [1.61.0.v20190602-1335,1.61.0.v20190602-1335]
+ org.bouncycastle.bcprov.source [1.61.0.v20190602-1335,1.61.0.v20190602-1335]
org.kohsuke.args4j [2.33.0.v20160323-2218,2.33.0.v20160323-2218]
org.kohsuke.args4j.source [2.33.0.v20160323-2218,2.33.0.v20160323-2218]
org.hamcrest [1.1.0.v20090501071000,1.1.0.v20090501071000]
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecoratorTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecoratorTest.java
index d95d9c76c..2f41bf256 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecoratorTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecoratorTest.java
@@ -25,8 +25,8 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffData;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
@@ -226,7 +226,7 @@ public abstract class GitLightweightDecoratorTest
protected static IFile findFile(IContainer container, String name) {
IResource resource = findResource(container, name);
- return AdapterUtils.adapt(resource, IFile.class);
+ return Adapters.adapt(resource, IFile.class);
}
protected static RevCommit gitCommit(Git git) throws Exception {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/selection/SelectionForViewsTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/selection/SelectionForViewsTest.java
index 16db98b62..28e605dd7 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/selection/SelectionForViewsTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/selection/SelectionForViewsTest.java
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.RepositoryUtil;
import org.eclipse.egit.core.op.CloneOperation;
import org.eclipse.egit.ui.Activator;
@@ -152,7 +152,7 @@ public class SelectionForViewsTest extends GitRepositoriesViewTestBase {
Object firstElement = ((IStructuredSelection) selection)
.getFirstElement();
assertNotNull("Null in selection " + viewId, firstElement);
- Repository repo = AdapterUtils.adapt(firstElement, Repository.class);
+ Repository repo = Adapters.adapt(firstElement, Repository.class);
assertNotNull("Expected a repository " + viewId + ", but "
+ firstElement.getClass().getName()
+ " doesn't adapt to Repository", repo);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/operations/GitScopeUtilTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/operations/GitScopeUtilTest.java
index 8c7126022..b4ddb4227 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/operations/GitScopeUtilTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/operations/GitScopeUtilTest.java
@@ -29,12 +29,12 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.JobFamilies;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.operations.GitScopeOperation;
import org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory;
@@ -235,7 +235,7 @@ public class GitScopeUtilTest extends LocalRepositoryTestCase {
}
private ResourceMapping getMappingAdapter(IResource resource) {
- return Utils.getAdapter(resource, ResourceMapping.class);
+ return Adapters.adapt(resource, ResourceMapping.class);
}
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
index d65c7d503..2551d908e 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
@@ -160,7 +160,7 @@ public class TestUtil {
BundleContext context = bundle.getBundleContext();
ServiceTracker<BundleLocalization, BundleLocalization> localizationTracker =
- new ServiceTracker<BundleLocalization, BundleLocalization>(
+ new ServiceTracker<>(
context, BundleLocalization.class, null);
localizationTracker.open();
@@ -469,8 +469,7 @@ public class TestUtil {
public static void assertRepositoryContainsFiles(Repository repository,
String[] paths) throws Exception {
Set<String> expectedfiles = new HashSet<>();
- for (String path : paths)
- expectedfiles.add(path);
+ expectedfiles.addAll(Arrays.asList(paths));
try (TreeWalk treeWalk = new TreeWalk(repository)) {
treeWalk.addTree(repository.resolve("HEAD^{tree}"));
treeWalk.setRecursive(true);
@@ -555,7 +554,7 @@ public class TestUtil {
*/
public SWTBotTreeItem[] getProjectItems(SWTBotTree projectExplorerTree,
String... projects) {
- List<SWTBotTreeItem> items = new ArrayList<SWTBotTreeItem>();
+ List<SWTBotTreeItem> items = new ArrayList<>();
for (SWTBotTreeItem item : projectExplorerTree.getAllItems()) {
String itemText = item.getText();
StringTokenizer tok = new StringTokenizer(itemText, " ");
@@ -691,7 +690,7 @@ public class TestUtil {
*/
public static SWTBotTreeItem getNode(SWTBotTreeItem[] nodes, String searchText) {
List<String> texts = new ArrayList<>();
- List<SWTBotTreeItem> matchingItems = new ArrayList<SWTBotTreeItem>();
+ List<SWTBotTreeItem> matchingItems = new ArrayList<>();
for (SWTBotTreeItem item : nodes) {
String text = item.getText();
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java
index a7b7fe3cd..d8a128a9e 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java
@@ -20,8 +20,8 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.concurrent.atomic.AtomicReference;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.Activator;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
@@ -81,7 +81,7 @@ public class CommitEditorTest extends LocalRepositoryTestCase {
assertNotNull(editorRef.get());
IEditorPart editor = editorRef.get();
assertTrue(editor instanceof CommitEditor);
- RepositoryCommit adaptedCommit = Utils.getAdapter(editor,
+ RepositoryCommit adaptedCommit = Adapters.adapt(editor,
RepositoryCommit.class);
assertNotNull(adaptedCommit);
assertEquals(commit, adaptedCommit.getRevCommit());
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/TestCommitMessageProviderExtensionFactory.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/TestCommitMessageProviderExtensionFactory.java
index 24737b531..18393f875 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/TestCommitMessageProviderExtensionFactory.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/TestCommitMessageProviderExtensionFactory.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.egit.ui.test.stagview;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
@@ -60,9 +61,7 @@ public class TestCommitMessageProviderExtensionFactory
public void setCommitMessageProviders(
ICommitMessageProvider... newProviders) {
providers.clear();
- for (ICommitMessageProvider p : newProviders) {
- providers.add(p);
- }
+ providers.addAll(Arrays.asList(newProviders));
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
index bee72f3e0..94c0bd1b7 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
@@ -31,8 +31,8 @@ import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
@@ -471,7 +471,7 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
IAdaptable[] elements = workingSet.getElements();
assertEquals("Wrong number of projects in working set", 1,
elements.length);
- IProject project = Utils.getAdapter(elements[0], IProject.class);
+ IProject project = Adapters.adapt(elements[0], IProject.class);
assertEquals("Wrong project in working set", projectName,
project.getName());
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java
index 2fe4a283a..33befcaa2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java
@@ -124,6 +124,11 @@ public class JobFamilies {
public final static Object FORMAT_COMMIT_INFO = new JobFamily();
/**
+ * Commit editor job
+ */
+ public final static Object COMMIT_EDITOR = new JobFamily();
+
+ /**
* Fill tag list
*/
public final static Object FILL_TAG_LIST = new JobFamily(UIIcons.TAGS);
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 957917ecd..89922c017 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
@@ -14,6 +14,7 @@ package org.eclipse.egit.ui;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@@ -27,8 +28,8 @@ import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.Path;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.ui.internal.CommonUtils;
import org.eclipse.egit.ui.internal.RepositorySaveableFilter;
import org.eclipse.egit.ui.internal.UIIcons;
@@ -476,8 +477,7 @@ public class UIUtils {
List<String> values = new ArrayList<>(
existingValues.length + 1);
- for (String existingValue : existingValues)
- values.add(existingValue);
+ values.addAll(Arrays.asList(existingValues));
// if it is already the first value, we don't need to do
// anything
if (values.indexOf(value) == 0)
@@ -917,7 +917,7 @@ public class UIUtils {
}
private static String getShowInMenuLabel() {
- IBindingService bindingService = AdapterUtils.adapt(PlatformUI
+ IBindingService bindingService = Adapters.adapt(PlatformUI
.getWorkbench(), IBindingService.class);
if (bindingService != null) {
String keyBinding = bindingService
@@ -942,7 +942,7 @@ public class UIUtils {
*/
@Nullable
public static KeyStroke getKeystrokeOfBestActiveBindingFor(String commandId) {
- IBindingService bindingService = AdapterUtils
+ IBindingService bindingService = Adapters
.adapt(PlatformUI.getWorkbench(), IBindingService.class);
if (bindingService == null) {
return null;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ActionUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ActionUtils.java
index f4616f5ab..2add80da5 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ActionUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ActionUtils.java
@@ -17,7 +17,10 @@ import java.util.function.BooleanSupplier;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Control;
@@ -109,6 +112,95 @@ public final class ActionUtils {
}
/**
+ * Creates a new text action using a given {@link ActionFactory} to use as a
+ * template to set the label, image, and action definition id.
+ *
+ * @param target
+ * for the action
+ * @param factory
+ * to configure the action
+ * @param operationCode
+ * for the action
+ * @return the configured {@link UpdateableAction}
+ */
+ public static UpdateableAction createTextAction(
+ ITextOperationTarget target, ActionFactory factory,
+ int operationCode) {
+ if (operationCode == ITextOperationTarget.REDO) {
+ // XXX: workaround for
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=206111
+ return createGlobalAction(factory,
+ () -> target.doOperation(operationCode), () -> true);
+ }
+ return createGlobalAction(factory,
+ () -> target.doOperation(operationCode),
+ () -> target.canDoOperation(operationCode));
+ }
+
+ private static UpdateableAction[] createStandardTextActions(
+ ITextOperationTarget target, boolean editable) {
+ UpdateableAction[] actions = new UpdateableAction[ITextOperationTarget.SELECT_ALL
+ + 1];
+ if (editable) {
+ actions[ITextOperationTarget.UNDO] = createTextAction(target,
+ ActionFactory.UNDO, ITextOperationTarget.UNDO);
+ actions[ITextOperationTarget.REDO] = createTextAction(target,
+ ActionFactory.REDO, ITextOperationTarget.REDO);
+ actions[ITextOperationTarget.CUT] = createTextAction(target,
+ ActionFactory.CUT, ITextOperationTarget.CUT);
+ actions[ITextOperationTarget.PASTE] = createTextAction(
+ target, ActionFactory.PASTE, ITextOperationTarget.PASTE);
+ actions[ITextOperationTarget.DELETE] = createTextAction(
+ target, ActionFactory.DELETE, ITextOperationTarget.DELETE);
+ }
+ actions[ITextOperationTarget.COPY] = createTextAction(target,
+ ActionFactory.COPY, ITextOperationTarget.COPY);
+ actions[ITextOperationTarget.SELECT_ALL] = createTextAction(
+ target, ActionFactory.SELECT_ALL,
+ ITextOperationTarget.SELECT_ALL);
+ return actions;
+ }
+
+ /**
+ * Create the standard text actions, fill them into a {@MenuManager} and
+ * return them as an array indexed by the {@link ITextOperationTarget}
+ * operation codes. For an editable target, creates undo, redo | cut, copy,
+ * paste | delete, select all; otherwise just copy, select all.
+ *
+ * @param target
+ * for the actions to operate on
+ * @param editable
+ * whether the target is editable
+ * @param manager
+ * to fill in; may be {@code null} if the actions shall not be
+ * added to a {@link MenuManager}
+ * @return the actions; may contain {@code null} values (index 0 will always
+ * be {@code null})
+ */
+ public static UpdateableAction[] fillStandardTextActions(
+ ITextOperationTarget target, boolean editable,
+ MenuManager manager) {
+ UpdateableAction[] actions = createStandardTextActions(target,
+ editable);
+ if (manager != null) {
+ if (editable) {
+ manager.add(actions[ITextOperationTarget.UNDO]);
+ manager.add(actions[ITextOperationTarget.REDO]);
+ manager.add(new Separator());
+ manager.add(actions[ITextOperationTarget.CUT]);
+ }
+ manager.add(actions[ITextOperationTarget.COPY]);
+ if (editable) {
+ manager.add(actions[ITextOperationTarget.PASTE]);
+ manager.add(new Separator());
+ manager.add(actions[ITextOperationTarget.DELETE]);
+ }
+ manager.add(actions[ITextOperationTarget.SELECT_ALL]);
+ }
+ return actions;
+ }
+
+ /**
* Hooks up the {@link Control} such that the given {@link IAction}s are
* registered with the given {@link IHandlerService} while the control has
* the focus. Ensures that actions are properly de-registered when the
@@ -117,7 +209,8 @@ public final class ActionUtils {
* @param control
* to hook up
* @param actions
- * to be registered while the control has the focus
+ * to be registered while the control has the focus; {@code null}
+ * items are skipped.
* @param service
* to register the actions with
*/
@@ -148,12 +241,14 @@ public final class ActionUtils {
// Looks like sometimes we get two focusGained events.
return;
}
- for (final IAction action : actions) {
- handlerActivations.add(service.activateHandler(
- action.getActionDefinitionId(),
- new ActionHandler(action), expression, false));
- if (action instanceof IUpdate) {
- ((IUpdate) action).update();
+ for (IAction action : actions) {
+ if (action != null) {
+ handlerActivations.add(service.activateHandler(
+ action.getActionDefinitionId(),
+ new ActionHandler(action), expression, false));
+ if (action instanceof IUpdate) {
+ ((IUpdate) action).update();
+ }
}
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitLabelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitLabelProvider.java
index 7d042eaf7..c38d75288 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitLabelProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitLabelProvider.java
@@ -13,7 +13,7 @@
package org.eclipse.egit.ui.internal;
import org.eclipse.core.resources.IResource;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.ui.internal.clone.ProjectRecord;
import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
import org.eclipse.egit.ui.internal.repository.tree.RefNode;
@@ -70,7 +70,7 @@ public class GitLabelProvider extends LabelProvider implements
}
if (element instanceof GitModelBlob || element instanceof GitModelTree) {
- Object adapter = AdapterUtils.adapt(element, IResource.class);
+ Object adapter = Adapters.adapt(element, IResource.class);
return getWorkbenchLabelProvider().getImage(adapter);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/RepositorySaveableFilter.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/RepositorySaveableFilter.java
index 1635fd529..a1a7045ad 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/RepositorySaveableFilter.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/RepositorySaveableFilter.java
@@ -15,9 +15,9 @@ import java.util.List;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.util.ProjectUtil;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jgit.lib.Repository;
@@ -54,7 +54,7 @@ public class RepositorySaveableFilter extends SaveFilter {
}
private boolean isTextFileBufferInWorkDir(Saveable saveable) {
- IDocument document = AdapterUtils.adapt(saveable, IDocument.class);
+ IDocument document = Adapters.adapt(saveable, IDocument.class);
if (document == null)
return true; // be conservative and assume this needs to be saved
ITextFileBuffer textFileBuffer = FileBuffers.getTextFileBufferManager()
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadActionHandler.java
index 1af16244e..57ba92dcd 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadActionHandler.java
@@ -18,8 +18,8 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.storage.GitFileRevision;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.CompareUtils;
@@ -111,13 +111,13 @@ public class CompareIndexWithHeadActionHandler extends RepositoryActionHandler {
}
Object selected = selection.getFirstElement();
- IResource resource = AdapterUtils.adapt(selected, IResource.class);
+ IResource resource = Adapters.adapt(selected, IResource.class);
if (resource instanceof IFile) {
// action is only working on files. Avoid calculation
// of unnecessary expensive IndexDiff on a folder
return ResourceStateFactory.getInstance().get(resource).isStaged();
} else if (resource == null) {
- IPath location = AdapterUtils.adapt(selected, IPath.class);
+ IPath location = Adapters.adapt(selected, IPath.class);
if (location != null) {
return ResourceStateFactory.getInstance().get(location.toFile())
.isStaged();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java
index 28f84db8c..2e2edc690 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowBlameActionHandler.java
@@ -19,7 +19,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.internal.job.JobUtil;
import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.core.project.RepositoryMapping;
@@ -44,7 +44,7 @@ public class ShowBlameActionHandler extends RepositoryActionHandler {
return null;
}
Object element = selection.getFirstElement();
- IResource resource = AdapterUtils.adapt(element, IResource.class);
+ IResource resource = Adapters.adapt(element, IResource.class);
if (resource instanceof IFile) {
RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
if (mapping != null) {
@@ -76,7 +76,7 @@ public class ShowBlameActionHandler extends RepositoryActionHandler {
return false;
}
Object element = selection.getFirstElement();
- IResource resource = AdapterUtils.adapt(element, IResource.class);
+ IResource resource = Adapters.adapt(element, IResource.class);
if (resource instanceof IStorage) {
return RepositoryMapping.getMapping(resource) != null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/TagActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/TagActionHandler.java
index 3710acf37..e218685ee 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/TagActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/TagActionHandler.java
@@ -15,6 +15,7 @@ import java.text.MessageFormat;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -22,7 +23,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.IRepositoryCommit;
import org.eclipse.egit.core.op.TagOperation;
import org.eclipse.egit.ui.Activator;
@@ -163,7 +163,7 @@ public class TagActionHandler extends RepositoryActionHandler {
private IRepositoryCommit getCommit(IStructuredSelection selection) {
if (selection != null && selection.size() == 1) {
Object obj = selection.getFirstElement();
- return AdapterUtils.adapt(obj, IRepositoryCommit.class);
+ return Adapters.adapt(obj, IRepositoryCommit.class);
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
index 84ad8d15b..22a1f5260 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/blame/BlameOperation.java
@@ -21,13 +21,13 @@ import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.core.op.IEGitOperation;
import org.eclipse.egit.ui.Activator;
@@ -356,7 +356,7 @@ public class BlameOperation implements IEGitOperation {
AbstractDecoratedTextEditor editor = (AbstractDecoratedTextEditor) editorPart;
// IRevisionRulerColumn would also be possible but using
// IVerticalRulerInfo seems to work in more situations.
- IVerticalRulerInfo rulerInfo = AdapterUtils.adapt(editor,
+ IVerticalRulerInfo rulerInfo = Adapters.adapt(editor,
IVerticalRulerInfo.class);
BlameInformationControlCreator creator = new BlameInformationControlCreator(
@@ -380,7 +380,7 @@ public class BlameOperation implements IEGitOperation {
}
}
- IRevisionRulerColumn revisionRuler = AdapterUtils.adapt(editor,
+ IRevisionRulerColumn revisionRuler = Adapters.adapt(editor,
IRevisionRulerColumn.class);
if (revisionRuler instanceof IRevisionRulerColumnExtension)
((IRevisionRulerColumnExtension) revisionRuler)
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java
index b502bcb9d..08269fbe1 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditor.java
@@ -16,10 +16,10 @@ package org.eclipse.egit.ui.internal.commit;
import java.text.MessageFormat;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.CommonUtils;
import org.eclipse.egit.ui.internal.UIIcons;
@@ -461,7 +461,7 @@ public class CommitEditor extends SharedHeaderFormEditor implements
@Override
public <T> T getAdapter(Class<T> adapter) {
if (RepositoryCommit.class == adapter) {
- return AdapterUtils.adapt(getEditorInput(), adapter);
+ return Adapters.adapt(getEditorInput(), adapter);
} else if (IContentOutlinePage.class == adapter) {
return adapter.cast(getOutlinePage());
}
@@ -475,7 +475,7 @@ public class CommitEditor extends SharedHeaderFormEditor implements
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
- if (AdapterUtils.adapt(input, RepositoryCommit.class) == null)
+ if (Adapters.adapt(input, RepositoryCommit.class) == null)
throw new PartInitException(
"Input could not be adapted to commit object"); //$NON-NLS-1$
super.init(site, input);
@@ -543,7 +543,7 @@ public class CommitEditor extends SharedHeaderFormEditor implements
@Override
public ShowInContext getShowInContext() {
IFormPage currentPage = getActivePageInstance();
- IShowInSource showInSource = AdapterUtils.adapt(currentPage,
+ IShowInSource showInSource = Adapters.adapt(currentPage,
IShowInSource.class);
if (showInSource != null) {
return showInSource.getShowInContext();
@@ -554,7 +554,7 @@ public class CommitEditor extends SharedHeaderFormEditor implements
@Override
public String[] getShowInTargetIds() {
IFormPage currentPage = getActivePageInstance();
- IShowInTargetList targetList = AdapterUtils.adapt(currentPage,
+ IShowInTargetList targetList = Adapters.adapt(currentPage,
IShowInTargetList.class);
if (targetList != null) {
return targetList.getShowInTargetIds();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
index 7497d3c6d..13c2b4115 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java
@@ -20,17 +20,21 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.egit.core.EclipseGitProgressTransformer;
import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIUtils;
import org.eclipse.egit.ui.internal.ClipboardUtils;
@@ -548,7 +552,7 @@ public class CommitEditorPage extends FormPage
}
RepositoryCommit getCommit() {
- return AdapterUtils.adapt(getEditor(), RepositoryCommit.class);
+ return Adapters.adapt(getEditor(), RepositoryCommit.class);
}
@Override
@@ -634,13 +638,14 @@ public class CommitEditorPage extends FormPage
return Collections.emptyList();
}
if (refs.size() < BRANCH_LIMIT_FOR_SYNC_LOAD) {
- return findBranchesReachableFromCommit(commit, refs);
+ return findBranchesReachableFromCommit(commit, refs,
+ new NullProgressMonitor());
} else {
Job branchRefreshJob = new CommitEditorPageJob(commit) {
@Override
protected IStatus run(IProgressMonitor monitor) {
List<Ref> branches = findBranchesReachableFromCommit(commit,
- refs);
+ refs, monitor);
updateUI(monitor, () -> fillBranches(branches));
return Status.OK_STATUS;
}
@@ -651,10 +656,12 @@ public class CommitEditorPage extends FormPage
}
private List<Ref> findBranchesReachableFromCommit(RepositoryCommit commit,
- List<Ref> refs) {
+ List<Ref> refs, IProgressMonitor monitor) {
+ EclipseGitProgressTransformer progress = new EclipseGitProgressTransformer(
+ SubMonitor.convert(monitor, refs.size()));
try (RevWalk revWalk = new RevWalk(commit.getRepository())) {
return RevWalkUtils.findBranchesReachableFrom(commit.getRevCommit(),
- revWalk, refs);
+ revWalk, refs, progress);
} catch (IOException e) {
Activator.handleError(e.getMessage(), e, false);
return Collections.emptyList();
@@ -713,7 +720,8 @@ public class CommitEditorPage extends FormPage
@Override
public boolean belongsTo(Object family) {
- return CommitEditorPage.this == family;
+ return CommitEditorPage.this == family
+ || JobFamilies.COMMIT_EDITOR == family;
}
protected final void updateUI(IProgressMonitor monitor, Runnable task) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java
index 88269be58..739014716 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorPage.java
@@ -26,13 +26,13 @@ import java.util.Map;
import java.util.Objects;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.Adapters;
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.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIUtils;
import org.eclipse.egit.ui.internal.UIText;
@@ -429,7 +429,7 @@ public class DiffEditorPage extends TextEditor
@Override
public ShowInContext getShowInContext() {
- RepositoryCommit commit = AdapterUtils.adapt(getEditorInput(),
+ RepositoryCommit commit = Adapters.adapt(getEditorInput(),
RepositoryCommit.class);
if (commit != null) {
return new ShowInContext(getEditorInput(),
@@ -563,7 +563,7 @@ public class DiffEditorPage extends TextEditor
* cause this document to be shown.
*/
private void formatDiff() {
- RepositoryCommit commit = AdapterUtils.adapt(getEditor(),
+ RepositoryCommit commit = Adapters.adapt(getEditor(),
RepositoryCommit.class);
if (commit == null) {
return;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/MultiPageEditorContentOutlinePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/MultiPageEditorContentOutlinePage.java
index f78875e71..26c1ec4f3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/MultiPageEditorContentOutlinePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/MultiPageEditorContentOutlinePage.java
@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.jface.dialogs.IPageChangedListener;
import org.eclipse.jface.util.SafeRunnable;
@@ -223,7 +223,7 @@ public class MultiPageEditorContentOutlinePage extends ContentOutlinePage {
}
private IPage createOutlinePage(IEditorPart editor) {
- IContentOutlinePage outlinePage = AdapterUtils.adapt(editor,
+ IContentOutlinePage outlinePage = Adapters.adapt(editor,
IContentOutlinePage.class);
if (outlinePage == null) {
pages.put(editor, emptyPage);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/NotesEditorPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/NotesEditorPage.java
index 3bee1fa0f..57679879c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/NotesEditorPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/NotesEditorPage.java
@@ -12,7 +12,7 @@
*****************************************************************************/
package org.eclipse.egit.ui.internal.commit;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.widgets.Composite;
@@ -47,7 +47,7 @@ public class NotesEditorPage extends FormPage {
* @return commit
*/
protected RepositoryCommit getCommit() {
- return AdapterUtils.adapt(getEditor(), RepositoryCommit.class);
+ return Adapters.adapt(getEditor(), RepositoryCommit.class);
}
@Override
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/CachedCheckboxTreeViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/CachedCheckboxTreeViewer.java
index 7b55ea278..fef6977f6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/CachedCheckboxTreeViewer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/CachedCheckboxTreeViewer.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.components;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -198,9 +199,7 @@ public class CachedCheckboxTreeViewer extends ContainerCheckedTreeViewer {
}
if (contentProvider == null) {
- for (Object element : visible) {
- checkState.add(element);
- }
+ checkState.addAll(Arrays.asList(visible));
} else {
Set<Object> toCheck = new HashSet<>();
for (Object element : visible) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
index a4dcd2ff8..9cf415bf4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
@@ -33,10 +33,10 @@ import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffData;
import org.eclipse.egit.core.internal.util.ExceptionCollector;
import org.eclipse.egit.core.project.GitProjectData;
@@ -710,9 +710,10 @@ public class GitLightweightDecorator extends GitDecorator
resource = (IResource) element;
} else if (element instanceof IAdaptable) {
final IAdaptable adaptable = (IAdaptable) element;
- resource = AdapterUtils.adapt(adaptable, IResource.class);
+ resource = Adapters.adapt(adaptable, IResource.class);
if (resource == null) {
- final IContributorResourceAdapter adapter = AdapterUtils.adapt(adaptable, IContributorResourceAdapter.class);
+ final IContributorResourceAdapter adapter = Adapters
+ .adapt(adaptable, IContributorResourceAdapter.class);
if (adapter != null)
resource = adapter.getAdaptedResource(adaptable);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/ProblemLabelDecorator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/ProblemLabelDecorator.java
index a5a3ec302..f1b803905 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/ProblemLabelDecorator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/ProblemLabelDecorator.java
@@ -23,9 +23,9 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
@@ -174,10 +174,9 @@ public class ProblemLabelDecorator extends BaseLabelProvider implements
private void getAffectedElements(Set<IPath> paths, Object[] elements,
IStructuredContentProvider contentProvider, List<Object> result) {
for (Object element : elements) {
- IPath path = AdapterUtils.adapt(element, IPath.class);
+ IPath path = Adapters.adapt(element, IPath.class);
if (path == null) {
- IResource resource = AdapterUtils.adapt(element,
- IResource.class);
+ IResource resource = Adapters.adapt(element, IResource.class);
if (resource != null) {
path = resource.getLocation();
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/HyperlinkTokenScanner.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/HyperlinkTokenScanner.java
index 2a07f4f4b..f187138ad 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/HyperlinkTokenScanner.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/HyperlinkTokenScanner.java
@@ -11,6 +11,7 @@
package org.eclipse.egit.ui.internal.dialogs;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -304,9 +305,7 @@ public class HyperlinkTokenScanner implements ITokenScanner {
IHyperlinkDetector[] configuredDetectors = configuration
.getHyperlinkDetectors(viewer);
if (configuredDetectors != null && configuredDetectors.length > 0) {
- for (IHyperlinkDetector detector : configuredDetectors) {
- allDetectors.add(detector);
- }
+ allDetectors.addAll(Arrays.asList(configuredDetectors));
if (preferenceStore.getBoolean(URL_HYPERLINK_DETECTOR_KEY)
|| !preferenceStore.getBoolean(
AbstractTextEditor.PREFERENCE_HYPERLINKS_ENABLED)) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/ShowWhitespaceAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/ShowWhitespaceAction.java
new file mode 100644
index 000000000..6ce0acdfc
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/ShowWhitespaceAction.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2019 Tomasz Zarna (IBM), Robin Stocker, and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Factored out of SpellcheckableMessageArea.
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.dialogs;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IPainter;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.WhitespaceCharacterPainter;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+/**
+ * An action to toggle showing whitespace in a an {@link ITextViewer}.
+ */
+public class ShowWhitespaceAction extends TextEditorPropertyAction {
+
+ /**
+ * Creates a new {@link ShowWhitespaceAction}.
+ *
+ * @param viewer
+ * to operate on
+ */
+ public ShowWhitespaceAction(ITextViewer viewer) {
+ this(viewer, false);
+ }
+
+ /**
+ * Creates a new {@link ShowWhitespaceAction}.
+ *
+ * @param viewer
+ * to operate on
+ * @param initiallyOff
+ * whether to show whitespace initially
+ */
+ public ShowWhitespaceAction(ITextViewer viewer, boolean initiallyOff) {
+ super(UIText.SpellcheckableMessageArea_showWhitespace, viewer,
+ AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS,
+ initiallyOff);
+ }
+
+ private IPainter whitespaceCharPainter;
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ if (property == null) {
+ return;
+ }
+ switch (property) {
+ case AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS:
+ case AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES:
+ case AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES:
+ case AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES:
+ case AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES:
+ case AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES:
+ case AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES:
+ case AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS:
+ case AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS:
+ case AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS:
+ case AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN:
+ case AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED:
+ case AbstractTextEditor.PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE:
+ synchronizeWithPreference();
+ break;
+ default:
+ break;
+ }
+ }
+
+ @Override
+ protected final String getPreferenceKey() {
+ return AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS;
+ }
+
+ @Override
+ protected void toggleState(boolean checked) {
+ if (checked) {
+ installPainter();
+ } else {
+ uninstallPainter();
+ }
+ }
+
+ /**
+ * Installs the painter on the viewer.
+ */
+ private void installPainter() {
+ Assert.isTrue(whitespaceCharPainter == null);
+ ITextViewer v = getTextViewer();
+ if (v instanceof ITextViewerExtension2) {
+ IPreferenceStore store = getStore();
+ whitespaceCharPainter = new WhitespaceCharacterPainter(v,
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN),
+ store.getBoolean(
+ AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED),
+ store.getInt(
+ AbstractTextEditor.PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE));
+ ((ITextViewerExtension2) v).addPainter(whitespaceCharPainter);
+ }
+ }
+
+ /**
+ * Remove the painter from the viewer.
+ */
+ private void uninstallPainter() {
+ if (whitespaceCharPainter == null) {
+ return;
+ }
+ ITextViewer v = getTextViewer();
+ if (v instanceof ITextViewerExtension2) {
+ ((ITextViewerExtension2) v).removePainter(whitespaceCharPainter);
+ }
+ whitespaceCharPainter.deactivate(true);
+ whitespaceCharPainter = null;
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageArea.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageArea.java
index 8d7810e86..d490c4cbc 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageArea.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageArea.java
@@ -24,15 +24,14 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIUtils;
import org.eclipse.egit.ui.internal.ActionUtils;
+import org.eclipse.egit.ui.internal.ActionUtils.UpdateableAction;
import org.eclipse.egit.ui.internal.CommonUtils;
-import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
@@ -40,20 +39,13 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.SubMenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPainter;
-import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension2;
import org.eclipse.jface.text.MarginPainter;
import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.WhitespaceCharacterPainter;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
@@ -71,8 +63,6 @@ import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jgit.util.IntList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BidiSegmentEvent;
@@ -90,16 +80,12 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
import org.eclipse.ui.themes.IThemeManager;
@@ -116,119 +102,6 @@ public class SpellcheckableMessageArea extends Composite {
private static final Pattern TRAILING_NEWLINES = Pattern.compile("\\v+$"); //$NON-NLS-1$
- private static class TextViewerAction extends Action implements IUpdate {
-
- private int fOperationCode= -1;
- private ITextOperationTarget fOperationTarget;
-
- /**
- * Creates a new action.
- *
- * @param target
- * to operate on
- * @param operationCode
- * the opcode
- */
- public TextViewerAction(ITextOperationTarget target,
- int operationCode) {
- fOperationCode= operationCode;
- fOperationTarget = target;
- update();
- }
-
- /**
- * Updates the enabled state of the action.
- */
- @Override
- public void update() {
- // XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=206111
- if (fOperationCode == ITextOperationTarget.REDO) {
- return;
- }
- setEnabled(fOperationTarget != null
- && fOperationTarget.canDoOperation(fOperationCode));
- }
-
- /**
- * @see Action#run()
- */
- @Override
- public void run() {
- if (fOperationCode != -1 && fOperationTarget != null)
- fOperationTarget.doOperation(fOperationCode);
- }
- }
-
- private static abstract class TextEditorPropertyAction extends Action implements IPropertyChangeListener {
-
- private SourceViewer viewer;
- private String preferenceKey;
- private IPreferenceStore store;
-
- public TextEditorPropertyAction(String label, SourceViewer viewer, String preferenceKey) {
- super(label, IAction.AS_CHECK_BOX);
- this.viewer = viewer;
- this.preferenceKey = preferenceKey;
- this.store = EditorsUI.getPreferenceStore();
- if (store != null)
- store.addPropertyChangeListener(this);
- synchronizeWithPreference();
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(getPreferenceKey()))
- synchronizeWithPreference();
- }
-
- protected void synchronizeWithPreference() {
- // start read-only components without visible whitespace
- if (!viewer.getTextWidget().getEditable()) {
- return;
- }
- boolean checked = false;
- if (store != null)
- checked = store.getBoolean(getPreferenceKey());
- if (checked != isChecked()) {
- setChecked(checked);
- toggleState(checked);
- } else if (checked) {
- toggleState(false);
- toggleState(true);
- }
- }
-
- protected String getPreferenceKey() {
- return preferenceKey;
- }
-
- @Override
- public void run() {
- toggleState(isChecked());
- if (store != null)
- store.setValue(getPreferenceKey(), isChecked());
- }
-
- public void dispose() {
- if (store != null)
- store.removePropertyChangeListener(this);
- }
-
- /**
- * @param checked
- * new state
- */
- abstract protected void toggleState(boolean checked);
-
- protected ITextViewer getTextViewer() {
- return viewer;
- }
-
- protected IPreferenceStore getStore() {
- return store;
- }
- }
-
private final HyperlinkSourceViewer sourceViewer;
private TextSourceViewerConfiguration configuration;
@@ -497,153 +370,18 @@ public class SpellcheckableMessageArea extends Composite {
}
}
- private TextViewerAction createFromActionFactory(ActionFactory factory,
- int operationCode) {
- IWorkbenchAction template = factory
- .create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- TextViewerAction action = new TextViewerAction(sourceViewer,
- operationCode);
- action.setText(template.getText());
- action.setImageDescriptor(template.getImageDescriptor());
- action.setDisabledImageDescriptor(
- template.getDisabledImageDescriptor());
- action.setActionDefinitionId(template.getActionDefinitionId());
- template.dispose();
- return action;
- }
-
private void configureContextMenu() {
final boolean editable = isEditable(sourceViewer);
- TextViewerAction cutAction;
- TextViewerAction undoAction;
- TextViewerAction redoAction;
- TextViewerAction pasteAction;
- IAction quickFixAction;
+ IAction quickFixAction = null;
if (editable) {
- cutAction = createFromActionFactory(ActionFactory.CUT,
- ITextOperationTarget.CUT);
- undoAction = createFromActionFactory(ActionFactory.UNDO,
- ITextOperationTarget.UNDO);
- redoAction = createFromActionFactory(ActionFactory.REDO,
- ITextOperationTarget.REDO);
- pasteAction = createFromActionFactory(ActionFactory.PASTE,
- ITextOperationTarget.PASTE);
quickFixAction = new QuickfixAction(sourceViewer);
- } else {
- cutAction = null;
- undoAction = null;
- redoAction = null;
- pasteAction = null;
- quickFixAction = null;
}
- TextViewerAction copyAction = createFromActionFactory(
- ActionFactory.COPY, ITextOperationTarget.COPY);
- TextViewerAction selectAllAction = createFromActionFactory(
- ActionFactory.SELECT_ALL, ITextOperationTarget.SELECT_ALL);
-
- final TextEditorPropertyAction showWhitespaceAction = new TextEditorPropertyAction(
- UIText.SpellcheckableMessageArea_showWhitespace,
- sourceViewer,
- AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS) {
-
- private IPainter whitespaceCharPainter;
-
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- if (property.equals(getPreferenceKey())
- || AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN
- .equals(property)
- || AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED
- .equals(property)
- || AbstractTextEditor.PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE
- .equals(property)) {
- synchronizeWithPreference();
- }
- }
-
- @Override
- protected void toggleState(boolean checked) {
- if (checked)
- installPainter();
- else
- uninstallPainter();
- }
-
- /**
- * Installs the painter on the viewer.
- */
- private void installPainter() {
- Assert.isTrue(whitespaceCharPainter == null);
- ITextViewer v = getTextViewer();
- if (v instanceof ITextViewerExtension2) {
- IPreferenceStore store = getStore();
- whitespaceCharPainter = new WhitespaceCharacterPainter(
- v,
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN),
- store.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED),
- store.getInt(AbstractTextEditor.PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE));
- ((ITextViewerExtension2) v).addPainter(whitespaceCharPainter);
- }
- }
-
- /**
- * Remove the painter from the viewer.
- */
- private void uninstallPainter() {
- if (whitespaceCharPainter == null)
- return;
- ITextViewer v = getTextViewer();
- if (v instanceof ITextViewerExtension2)
- ((ITextViewerExtension2) v)
- .removePainter(whitespaceCharPainter);
- whitespaceCharPainter.deactivate(true);
- whitespaceCharPainter = null;
- }
- };
+ final ShowWhitespaceAction showWhitespaceAction = new ShowWhitespaceAction(
+ sourceViewer, !editable);
MenuManager contextMenu = new MenuManager();
- if (cutAction != null) {
- contextMenu.add(cutAction);
- }
- contextMenu.add(copyAction);
- if (pasteAction != null) {
- contextMenu.add(pasteAction);
- }
- contextMenu.add(selectAllAction);
- if (undoAction != null) {
- contextMenu.add(undoAction);
- }
- if (redoAction != null) {
- contextMenu.add(redoAction);
- }
+ UpdateableAction[] standardActions = ActionUtils
+ .fillStandardTextActions(sourceViewer, editable, contextMenu);
contextMenu.add(new Separator());
contextMenu.add(showWhitespaceAction);
contextMenu.add(new Separator());
@@ -662,15 +400,10 @@ public class SpellcheckableMessageArea extends Composite {
final StyledText textWidget = getTextWidget();
List<IAction> globalActions = new ArrayList<>();
- if (editable) {
- globalActions.add(cutAction);
- globalActions.add(pasteAction);
- globalActions.add(undoAction);
- globalActions.add(redoAction);
+ globalActions.addAll(Arrays.asList(standardActions));
+ if (quickFixAction != null) {
globalActions.add(quickFixAction);
}
- globalActions.add(copyAction);
- globalActions.add(selectAllAction);
if (contentAssistAction != null) {
globalActions.add(contentAssistAction);
}
@@ -679,35 +412,25 @@ public class SpellcheckableMessageArea extends Composite {
textWidget.setMenu(contextMenu.createContextMenu(textWidget));
- sourceViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- if (cutAction != null)
- cutAction.update();
- copyAction.update();
- }
-
- });
+ sourceViewer.addSelectionChangedListener(event -> {
+ if (standardActions[ITextOperationTarget.CUT] != null) {
+ standardActions[ITextOperationTarget.CUT].update();
+ }
+ standardActions[ITextOperationTarget.COPY].update();
+ });
if (editable) {
- sourceViewer.addTextListener(new ITextListener() {
- @Override
- public void textChanged(TextEvent event) {
- if (undoAction != null)
- undoAction.update();
- if (redoAction != null)
- redoAction.update();
+ sourceViewer.addTextListener(event -> {
+ if (standardActions[ITextOperationTarget.UNDO] != null) {
+ standardActions[ITextOperationTarget.UNDO].update();
+ }
+ if (standardActions[ITextOperationTarget.REDO] != null) {
+ standardActions[ITextOperationTarget.REDO].update();
}
});
}
- textWidget.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent disposeEvent) {
- showWhitespaceAction.dispose();
- }
- });
+ textWidget.addDisposeListener(e -> showWhitespaceAction.dispose());
}
private void addProposals(final SubMenuManager quickFixMenu) {
@@ -781,11 +504,10 @@ public class SpellcheckableMessageArea extends Composite {
final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(
sourceViewer, null, annotationAccess, textColors);
- List annotationPreferences = new MarkerAnnotationPreferences()
- .getAnnotationPreferences();
- Iterator e = annotationPreferences.iterator();
- while (e.hasNext())
- support.setAnnotationPreference((AnnotationPreference) e.next());
+ List<AnnotationPreference> annotationPreferences = new MarkerAnnotationPreferences()
+ .getAnnotationPreferences();
+ annotationPreferences.iterator()
+ .forEachRemaining(p -> support.setAnnotationPreference(p));
support.install(EditorsUI.getPreferenceStore());
return support;
@@ -849,8 +571,14 @@ public class SpellcheckableMessageArea extends Composite {
private IAction createContentAssistAction(
final SourceViewer viewer) {
- Action proposalAction = new TextViewerAction(viewer,
- ISourceViewer.CONTENTASSIST_PROPOSALS);
+ Action proposalAction = new Action() {
+
+ @Override
+ public void run() {
+ viewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+ }
+
+ };
proposalAction
.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
return proposalAction;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/TextEditorPropertyAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/TextEditorPropertyAction.java
new file mode 100644
index 000000000..9df5386a1
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/TextEditorPropertyAction.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2019 Tomasz Zarna (IBM) and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Thomas Wolf <thomas.wolf@paranor.ch> - Factored out of SpellcheckableMessageArea.
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.dialogs;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.editors.text.EditorsUI;
+
+/**
+ * An {@link Action} that operates on an {@link ITextViewer} that represents a
+ * boolean preference in the text editor preferences. When toggled, it toggles
+ * the persisted state and invokes {@link #toggleState(boolean)}, which is to be
+ * implemented by sub-classes to update the text viewer in response to the
+ * preference change.
+ */
+public abstract class TextEditorPropertyAction extends Action
+ implements IPropertyChangeListener, IWorkbenchAction {
+
+ // Possibly originally copied from
+ // org.eclipse.compare.internal.TextEditorPropertyAction and adapted?
+
+ private ITextViewer viewer;
+
+ private String preferenceKey;
+
+ private IPreferenceStore store;
+
+ /**
+ * Creates a new {@link TextEditorPropertyAction}.
+ *
+ * @param label
+ * for the action
+ * @param viewer
+ * to operate on
+ * @param preferenceKey
+ * in the {@link EditorsUI#getPreferenceStore()} for this action
+ * @param initiallyOff
+ * if {@code true}, the action initially is not checked and does
+ * not reflect the preference state
+ */
+ public TextEditorPropertyAction(String label, ITextViewer viewer,
+ String preferenceKey, boolean initiallyOff) {
+ super(label, IAction.AS_CHECK_BOX);
+ this.viewer = viewer;
+ this.preferenceKey = preferenceKey;
+ this.store = EditorsUI.getPreferenceStore();
+ if (store != null) {
+ store.addPropertyChangeListener(this);
+ }
+ if (!initiallyOff) {
+ synchronizeWithPreference();
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(getPreferenceKey())) {
+ synchronizeWithPreference();
+ }
+ }
+
+ /**
+ * Reads the preference and calls {@link #toggleState(boolean)} as
+ * appropriate.
+ */
+ protected void synchronizeWithPreference() {
+ boolean checked = false;
+ if (store != null) {
+ checked = store.getBoolean(getPreferenceKey());
+ }
+ if (checked != isChecked()) {
+ setChecked(checked);
+ toggleState(checked);
+ } else if (checked) {
+ toggleState(false);
+ toggleState(true);
+ }
+ }
+
+ /**
+ * Retrieves the preference key of this action.
+ *
+ * @return the preference key.
+ */
+ protected String getPreferenceKey() {
+ return preferenceKey;
+ }
+
+ @Override
+ public void run() {
+ toggleState(isChecked());
+ if (store != null) {
+ store.setValue(getPreferenceKey(), isChecked());
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if (store != null) {
+ store.removePropertyChangeListener(this);
+ }
+ }
+
+ /**
+ * Updates the {@link ITextViewer} of this action as appropriate.
+ *
+ * @param checked
+ * new state
+ */
+ abstract protected void toggleState(boolean checked);
+
+ /**
+ * Retrieves the {@link ITextViewer} this action operates on.
+ *
+ * @return the {@link ITextViewer}
+ */
+ protected ITextViewer getTextViewer() {
+ return viewer;
+ }
+
+ /**
+ * Retrieves the {@link IPreferenceStore} this action operates on.
+ *
+ * @return the {@link IPreferenceStore}, or {@code null} if there is no
+ * preference store for text editors
+ */
+ protected IPreferenceStore getStore() {
+ return store;
+ }
+}
+
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/expressions/GitPropertyTester.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/expressions/GitPropertyTester.java
index 1bd4f2282..d27b12143 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/expressions/GitPropertyTester.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/expressions/GitPropertyTester.java
@@ -16,7 +16,7 @@ import java.util.Collection;
import java.util.List;
import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.internal.IRepositoryCommit;
import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
import org.eclipse.jgit.lib.Constants;
@@ -71,7 +71,7 @@ public class GitPropertyTester extends AbstractPropertyTester {
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
if ("parentCount".equals(property)) { //$NON-NLS-1$
- RevCommit commit = AdapterUtils.adapt(receiver, RevCommit.class);
+ RevCommit commit = Adapters.adapt(receiver, RevCommit.class);
if (commit == null) {
return false;
}
@@ -83,41 +83,38 @@ public class GitPropertyTester extends AbstractPropertyTester {
commit.getParentCount() > 0);
}
} else if ("isBare".equals(property)) { //$NON-NLS-1$
- Repository repository = AdapterUtils.adapt(receiver,
- Repository.class);
+ Repository repository = Adapters.adapt(receiver, Repository.class);
if (repository != null) {
return computeResult(expectedValue, repository.isBare());
}
} else if ("isSafe".equals(property)) { //$NON-NLS-1$
- Repository repository = AdapterUtils.adapt(receiver,
- Repository.class);
+ Repository repository = Adapters.adapt(receiver, Repository.class);
if (repository != null) {
return computeResult(expectedValue, repository
.getRepositoryState().equals(RepositoryState.SAFE));
}
} else if ("canCommit".equals(property)) { //$NON-NLS-1$
- Repository repository = AdapterUtils.adapt(receiver,
- Repository.class);
+ Repository repository = Adapters.adapt(receiver, Repository.class);
if (repository != null) {
return computeResult(expectedValue,
repository.getRepositoryState().canCommit());
}
} else if ("hasMultipleRefs".equals(property)) { //$NON-NLS-1$
- IRepositoryCommit commit = AdapterUtils.adapt(receiver,
+ IRepositoryCommit commit = Adapters.adapt(receiver,
IRepositoryCommit.class);
if (commit != null) {
return computeResult(expectedValue,
hasMultipleRefs(commit, toRefNames(args)));
}
} else if ("hasRef".equals(property)) { //$NON-NLS-1$
- IRepositoryCommit commit = AdapterUtils.adapt(receiver,
+ IRepositoryCommit commit = Adapters.adapt(receiver,
IRepositoryCommit.class);
if (commit != null) {
return computeResult(expectedValue,
hasRef(commit, toRefNames(args)));
}
} else if ("isStash".equals(property)) { //$NON-NLS-1$
- RepositoryCommit commit = AdapterUtils.adapt(receiver,
+ RepositoryCommit commit = Adapters.adapt(receiver,
RepositoryCommit.class);
return computeResult(expectedValue,
commit != null && commit.isStash());
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
index 58094c341..2181690b8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java
@@ -27,13 +27,13 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.Activator;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.util.ProjectUtil;
import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.egit.core.project.RepositoryMapping;
@@ -144,7 +144,7 @@ public class GitAdapterFactory implements IAdapterFactory {
}
if (adapterType == Repository.class) {
- ResourceMapping m = AdapterUtils.adapt(adaptableObject,
+ ResourceMapping m = Adapters.adapt(adaptableObject,
ResourceMapping.class);
if (m != null) {
return adapterType.cast(SelectionUtils
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/handler/SelectionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/handler/SelectionHandler.java
index de2bfc0c7..81211b618 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/handler/SelectionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/handler/SelectionHandler.java
@@ -18,7 +18,7 @@ import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -56,7 +56,7 @@ public abstract class SelectionHandler extends AbstractHandler {
protected <V> V getSelectedItem(final Class<V> itemClass,
final ExecutionEvent event) {
final Object selected = getSelection(event).getFirstElement();
- return AdapterUtils.adapt(selected, itemClass);
+ return Adapters.adapt(selected, itemClass);
}
/**
@@ -71,7 +71,7 @@ public abstract class SelectionHandler extends AbstractHandler {
ExecutionEvent event) {
final List<V> items = new LinkedList<>();
for (Object selected : getSelection(event).toArray()) {
- V adapted = AdapterUtils.adapt(selected, itemClass);
+ V adapted = Adapters.adapt(selected, itemClass);
if (adapted != null)
items.add(adapted);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java
index 56a6c9b06..bae488156 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java
@@ -25,6 +25,8 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.egit.core.EclipseGitProgressTransformer;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.CommonUtils;
@@ -120,7 +122,7 @@ public class CommitInfoBuilder {
if(Activator.getDefault().getPreferenceStore().getBoolean(
UIPreferences.HISTORY_SHOW_BRANCH_SEQUENCE)) {
try (RevWalk rw = new RevWalk(db)) {
- List<Ref> branches = getBranches(commit, allRefs, db);
+ List<Ref> branches = getBranches(commit, allRefs, db, monitor);
Collections.sort(branches,
CommonUtils.REF_ASCENDING_COMPARATOR);
if (!branches.isEmpty()) {
@@ -255,18 +257,22 @@ public class CommitInfoBuilder {
* @param commit
* @param allRefs
* @param db
+ * @param monitor
* @return List of heads from those current commit is reachable
* @throws MissingObjectException
* @throws IncorrectObjectTypeException
* @throws IOException
*/
private static List<Ref> getBranches(RevCommit commit,
- Collection<Ref> allRefs, Repository db)
+ Collection<Ref> allRefs, Repository db, IProgressMonitor monitor)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
+ EclipseGitProgressTransformer progress = new EclipseGitProgressTransformer(
+ SubMonitor.convert(monitor, allRefs.size()));
try (RevWalk revWalk = new RevWalk(db)) {
revWalk.setRetainBody(false);
- return RevWalkUtils.findBranchesReachableFrom(commit, revWalk, allRefs);
+ return RevWalkUtils.findBranchesReachableFrom(commit, revWalk,
+ allRefs, progress);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java
index bf1ab666a..7851ea17f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java
@@ -21,11 +21,11 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIUtils;
@@ -339,7 +339,8 @@ class CommitMessageViewer extends HyperlinkSourceViewer {
}
private void scheduleFormatJob() {
- IWorkbenchSiteProgressService siteService = AdapterUtils.adapt(partSite, IWorkbenchSiteProgressService.class);
+ IWorkbenchSiteProgressService siteService = Adapters.adapt(partSite,
+ IWorkbenchSiteProgressService.class);
if (siteService == null) {
return;
}
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 ee1deea7d..589d849b8 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
@@ -31,6 +31,7 @@ import java.util.regex.Pattern;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -45,6 +46,7 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIUtils;
+import org.eclipse.egit.ui.internal.ActionUtils;
import org.eclipse.egit.ui.internal.CompareUtils;
import org.eclipse.egit.ui.internal.UIIcons;
import org.eclipse.egit.ui.internal.UIText;
@@ -55,6 +57,7 @@ import org.eclipse.egit.ui.internal.commit.FocusTracker;
import org.eclipse.egit.ui.internal.components.RepositoryMenuUtil.RepositoryToolbarAction;
import org.eclipse.egit.ui.internal.dialogs.HyperlinkSourceViewer;
import org.eclipse.egit.ui.internal.dialogs.HyperlinkTokenScanner;
+import org.eclipse.egit.ui.internal.dialogs.ShowWhitespaceAction;
import org.eclipse.egit.ui.internal.fetch.FetchHeadChangedEvent;
import org.eclipse.egit.ui.internal.history.FindToolbar.StatusListener;
import org.eclipse.egit.ui.internal.repository.tree.AdditionalRefNode;
@@ -90,6 +93,7 @@ import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
@@ -888,7 +892,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
if (resource != null && typeOk(resource))
return true;
- return AdapterUtils.adapt(object, Repository.class) != null;
+ return Adapters.adapt(object, Repository.class) != null;
}
private static boolean typeOk(final IResource object) {
@@ -1290,6 +1294,33 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
diffViewer.getControl().setLayoutData(
GridDataFactory.fillDefaults().grab(true, false).create());
+ ActionUtils.UpdateableAction selectAll = ActionUtils.createGlobalAction(
+ ActionFactory.SELECT_ALL,
+ () -> diffViewer.doOperation(ITextOperationTarget.SELECT_ALL),
+ () -> diffViewer
+ .canDoOperation(ITextOperationTarget.SELECT_ALL));
+ ActionUtils.UpdateableAction copy = ActionUtils.createGlobalAction(
+ ActionFactory.COPY,
+ () -> diffViewer.doOperation(ITextOperationTarget.COPY),
+ () -> diffViewer.canDoOperation(ITextOperationTarget.COPY));
+ ActionUtils.setGlobalActions(diffViewer.getControl(), copy, selectAll);
+ ShowWhitespaceAction showWhitespaceAction = new ShowWhitespaceAction(
+ diffViewer);
+ diffViewer.addSelectionChangedListener(e -> copy.update());
+ MenuManager contextMenu = new MenuManager();
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(manager -> {
+ if (diffViewer.getDocument().getLength() > 0) {
+ manager.add(copy);
+ manager.add(selectAll);
+ manager.add(new Separator());
+ manager.add(showWhitespaceAction);
+ }
+ });
+ StyledText diffWidget = diffViewer.getTextWidget();
+ diffWidget.setMenu(contextMenu.createContextMenu(diffWidget));
+ diffWidget.addDisposeListener(e -> showWhitespaceAction.dispose());
+
setWrap(store
.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP));
@@ -1893,9 +1924,9 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
}
}
if (repo == null) {
- repo = AdapterUtils.adapt(o, Repository.class);
+ repo = Adapters.adapt(o, Repository.class);
if (repo != null) {
- File file = AdapterUtils.adapt(o, File.class);
+ File file = Adapters.adapt(o, File.class);
if (file == null) {
input = new HistoryPageInput(repo);
} else {
@@ -1903,7 +1934,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
}
}
}
- selection = AdapterUtils.adapt(o, RevCommit.class);
+ selection = Adapters.adapt(o, RevCommit.class);
if (input == null || repo == null) {
this.name = ""; //$NON-NLS-1$
@@ -2758,7 +2789,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
IWorkbenchPartSite site = getPartSite();
if (site != null) {
final IWorkbenchSiteProgressService p;
- p = AdapterUtils.adapt(site, IWorkbenchSiteProgressService.class);
+ p = Adapters.adapt(site, IWorkbenchSiteProgressService.class);
if (p != null) {
p.schedule(j, 0, true /* use half-busy cursor */);
return;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
index 5fe593a48..dc4a3abf2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
@@ -24,6 +24,7 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.AdapterUtils;
@@ -74,8 +75,8 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
throws ExecutionException {
IStructuredSelection selection = getSelection(event);
if (!selection.isEmpty()) {
- IRepositoryCommit commit = AdapterUtils
- .adapt(selection.getFirstElement(), IRepositoryCommit.class);
+ IRepositoryCommit commit = Adapters.adapt(
+ selection.getFirstElement(), IRepositoryCommit.class);
if (commit != null) {
return commit.getRepository();
}
@@ -90,7 +91,7 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
if (input instanceof RepositoryTreeNode) {
return ((RepositoryTreeNode) input).getRepository();
}
- Repository repo = AdapterUtils.adapt(input, Repository.class);
+ Repository repo = Adapters.adapt(input, Repository.class);
if (repo != null) {
return repo;
}
@@ -194,7 +195,7 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
throw new ExecutionException(
UIText.AbstractHistoryCommandHandler_ActionRequiresOneSelectedCommitMessage);
}
- RevCommit commit = AdapterUtils.adapt(selection.getFirstElement(),
+ RevCommit commit = Adapters.adapt(selection.getFirstElement(),
RevCommit.class);
if (commit == null) {
throw new ExecutionException(
@@ -240,7 +241,7 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
List<RevCommit> commits = new ArrayList<>();
try (RevWalk walk = new RevWalk(repository)) {
for (Object element : selection.toList()) {
- RevCommit commit = AdapterUtils.adapt(element, RevCommit.class);
+ RevCommit commit = Adapters.adapt(element, RevCommit.class);
if (commit != null) {
// Re-parse commit to clear effects of TreeFilter
RevCommit reparsed = walk.parseCommit(commit.getId());
@@ -307,7 +308,7 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
if (selection.isEmpty()) {
return branchesOfCommit;
}
- RevCommit revCommit = AdapterUtils.adapt(selection.getFirstElement(),
+ RevCommit revCommit = Adapters.adapt(selection.getFirstElement(),
RevCommit.class);
if (!(revCommit instanceof PlotCommit)) {
return branchesOfCommit;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractRebaseHistoryCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractRebaseHistoryCommandHandler.java
index b927bb246..3e317ad9e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractRebaseHistoryCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractRebaseHistoryCommandHandler.java
@@ -20,7 +20,7 @@ import java.io.IOException;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.op.RebaseOperation;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.commands.shared.AbstractRebaseCommandHandler;
@@ -51,7 +51,7 @@ public abstract class AbstractRebaseHistoryCommandHandler extends
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- RevCommit revCommit = AdapterUtils
+ RevCommit revCommit = Adapters
.adapt(getSelection(event).getFirstElement(), RevCommit.class);
if (!(revCommit instanceof PlotCommit)) {
return null;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java
index 5bce2c081..d72302598 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java
@@ -21,10 +21,10 @@ import java.util.List;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.egit.ui.Activator;
@@ -110,17 +110,15 @@ public class GitScopeUtil {
@Nullable
private static ResourceMapping getResourceMapping(Object o) {
- ResourceMapping mapping = AdapterUtils.adapt(o, ResourceMapping.class);
+ ResourceMapping mapping = Adapters.adapt(o, ResourceMapping.class);
if (mapping != null) {
return mapping;
}
- if (o instanceof IAdaptable) {
- IContributorResourceAdapter adapted = AdapterUtils.adapt(o,
- IContributorResourceAdapter.class);
- if (adapted instanceof IContributorResourceAdapter2) {
- IContributorResourceAdapter2 cra = (IContributorResourceAdapter2) adapted;
- return cra.getAdaptedResourceMapping((IAdaptable) o);
- }
+ IContributorResourceAdapter adapted = Adapters.adapt(o,
+ IContributorResourceAdapter.class);
+ if (adapted instanceof IContributorResourceAdapter2) {
+ IContributorResourceAdapter2 cra = (IContributorResourceAdapter2) adapted;
+ return cra.getAdaptedResourceMapping((IAdaptable) o);
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
index 4b32dcdea..2ca03deb8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
@@ -17,8 +17,7 @@ import java.io.IOException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIUtils;
@@ -83,14 +82,9 @@ public class GitProjectPropertyPage extends PropertyPage {
// Get the project that is the source of this property page
IProject project = null;
- final IAdaptable element = getElement();
- if (element instanceof IResource) {
- project = ((IResource) element).getProject();
- } else {
- IResource adapter = AdapterUtils.adapt(element, IResource.class);
- if (adapter != null) {
- project = adapter.getProject();
- }
+ IResource resource = Adapters.adapt(getElement(), IResource.class);
+ if (resource != null) {
+ project = resource.getProject();
}
RepositoryMapping mapping = RepositoryMapping.getMapping(project);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GlobalConfigurationPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GlobalConfigurationPreferencePage.java
index 221f04151..ac89554d9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GlobalConfigurationPreferencePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GlobalConfigurationPreferencePage.java
@@ -117,17 +117,6 @@ public class GlobalConfigurationPreferencePage extends PreferencePage implements
updateApplyButton();
}
};
- Control result = userConfigEditor.createContents();
- Dialog.applyDialogFont(result);
- TabItem userTabItem = new TabItem(tabFolder, SWT.FILL);
- userTabItem.setControl(result);
- userTabItem.setText(UIText.GlobalConfigurationPreferencePage_userSettingTabTitle);
-
- result = sysConfigEditor.createContents();
- Dialog.applyDialogFont(result);
- TabItem sysTabItem = new TabItem(tabFolder, SWT.FILL);
- sysTabItem.setControl(result);
- sysTabItem.setText(UIText.GlobalConfigurationPreferencePage_systemSettingTabTitle);
Composite repoTab = new Composite(tabFolder, SWT.NONE);
GridLayoutFactory.swtDefaults().margins(0, 0).applyTo(repoTab);
@@ -168,6 +157,22 @@ public class GlobalConfigurationPreferencePage extends PreferencePage implements
repoCombo.setEnabled(false);
}
+ Control result = userConfigEditor.createContents();
+ Dialog.applyDialogFont(result);
+ TabItem userTabItem = new TabItem(tabFolder, SWT.FILL);
+ userTabItem.setControl(result);
+ userTabItem.setText(
+ UIText.GlobalConfigurationPreferencePage_userSettingTabTitle);
+
+ result = sysConfigEditor.createContents();
+ Dialog.applyDialogFont(result);
+ TabItem sysTabItem = new TabItem(tabFolder, SWT.FILL);
+ sysTabItem.setControl(result);
+ sysTabItem.setText(
+ UIText.GlobalConfigurationPreferencePage_systemSettingTabTitle);
+
+ tabFolder.setSelection(userTabItem);
+
return composite;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseInteractiveView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseInteractiveView.java
index 5963ee989..2c7ae5da6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseInteractiveView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseInteractiveView.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -227,7 +228,7 @@ public class RebaseInteractiveView extends ViewPart implements
}
}
if (repo == null) {
- repo = AdapterUtils.adapt(o, Repository.class);
+ repo = Adapters.adapt(o, Repository.class);
}
if (repo == null && !force) {
return;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
index 219cdf72f..2abf2fb62 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
@@ -19,6 +19,7 @@ package org.eclipse.egit.ui.internal.reflog;
import java.io.IOException;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.project.RepositoryMapping;
@@ -369,7 +370,7 @@ public class ReflogView extends ViewPart implements RefsChangedListener, IShowIn
}
if (part instanceof IEditorPart) {
IEditorInput input = ((IEditorPart) part).getEditorInput();
- Repository repository = AdapterUtils.adapt(input,
+ Repository repository = Adapters.adapt(input,
Repository.class);
if (repository != null) {
reactOnSelection(new StructuredSelection(repository));
@@ -461,7 +462,7 @@ public class ReflogView extends ViewPart implements RefsChangedListener, IShowIn
}
}
if (selectedRepo == null) {
- selectedRepo = AdapterUtils.adapt(first, Repository.class);
+ selectedRepo = Adapters.adapt(first, Repository.class);
}
if (selectedRepo == null) {
return;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
index eeecf20b8..908ea7564 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
@@ -33,6 +33,7 @@ import java.util.Set;
import org.eclipse.core.commands.Command;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -873,7 +874,7 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
showResource(input.getFile());
return true;
}
- Repository repository = AdapterUtils.adapt(context.getInput(),
+ Repository repository = Adapters.adapt(context.getInput(),
Repository.class);
if (repository != null) {
showRepository(repository);
@@ -985,13 +986,13 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
showResource(adapted);
return;
}
- File file = AdapterUtils.adapt(ssel.getFirstElement(), File.class);
+ File file = Adapters.adapt(ssel.getFirstElement(), File.class);
if (file != null) {
IPath path = new Path(file.getAbsolutePath());
showPaths(Arrays.asList(path));
return;
}
- Repository repository = AdapterUtils.adapt(ssel.getFirstElement(),
+ Repository repository = Adapters.adapt(ssel.getFirstElement(),
Repository.class);
if (repository != null) {
showRepository(repository);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertyPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertyPage.java
index 63960db89..f248a0c39 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertyPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertyPage.java
@@ -15,7 +15,7 @@ package org.eclipse.egit.ui.internal.repository;
import java.io.File;
import java.io.IOException;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.preferences.ConfigurationEditorComponent;
import org.eclipse.jface.layout.GridDataFactory;
@@ -43,7 +43,7 @@ public class RepositoryPropertyPage extends PropertyPage {
GridLayoutFactory.fillDefaults().applyTo(displayArea);
GridDataFactory.fillDefaults().applyTo(displayArea);
- final Repository repo = AdapterUtils.adapt(getElement(), Repository.class);
+ final Repository repo = Adapters.adapt(getElement(), Repository.class);
if (repo == null)
return displayArea;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java
index fdc47f94e..89852a2af 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.repository;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType;
import org.eclipse.jface.action.IToolBarManager;
@@ -134,7 +134,7 @@ public class RepositoryPropertySourceProvider implements
Ref ref = (Ref) node.getObject();
if (ref.getName().startsWith(Constants.R_HEADS) || ref.getName().startsWith(Constants.R_REMOTES)){
checkChangeType(SourceType.BRANCH);
- Repository repository = AdapterUtils.adapt(node, Repository.class);
+ Repository repository = Adapters.adapt(node, Repository.class);
lastRepositorySource = new BranchPropertySource(repository, ref.getName(), myPage);
return lastRepositorySource;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java
index d0ae76b3a..ab2e038ef 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryStatisticsPage.java
@@ -15,7 +15,7 @@ package org.eclipse.egit.ui.internal.repository;
import java.text.NumberFormat;
import java.util.Properties;
-import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.jgit.api.GarbageCollectCommand;
@@ -65,7 +65,7 @@ public class RepositoryStatisticsPage extends PropertyPage {
column.setText(title);
}
- Repository repo = AdapterUtils.adapt(getElement(), Repository.class);
+ Repository repo = Adapters.adapt(getElement(), Repository.class);
if (repo == null) {
return table;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
index 8fe617d27..6c92b7f45 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionEditorInput.java
@@ -25,13 +25,13 @@ import java.util.Date;
import org.eclipse.core.resources.IEncodedStorage;
import org.eclipse.core.resources.IFileState;
import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.storage.CommitFileRevision;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter;
@@ -80,7 +80,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
return new IFileState() {
@Override
public <T> T getAdapter(Class<T> adapter) {
- return AdapterUtils.adapt(storage, adapter);
+ return Adapters.adapt(storage, adapter);
}
@Override
@@ -123,7 +123,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
return new IEncodedStorage() {
@Override
public <T> T getAdapter(Class<T> adapter) {
- return AdapterUtils.adapt(storage, adapter);
+ return Adapters.adapt(storage, adapter);
}
@Override
@@ -201,7 +201,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
@Override
public String getName() {
- IFileRevision rev = AdapterUtils.adapt(this, IFileRevision.class);
+ IFileRevision rev = Adapters.adapt(this, IFileRevision.class);
if (rev != null) {
String identifier;
if (rev instanceof CommitFileRevision) {
@@ -214,7 +214,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
UIText.FileRevisionEditorInput_NameAndRevisionTitle,
rev.getName(), identifier);
}
- IFileState state = AdapterUtils.adapt(this, IFileState.class);
+ IFileState state = Adapters.adapt(this, IFileState.class);
if (state != null) {
return state.getName() + ' ' + PreferenceBasedDateFormatter.create()
.formatDate(new Date(state.getModificationTime()));
@@ -245,7 +245,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
if (object != null) {
return adapter.cast(object);
}
- return AdapterUtils.adapt(fileRevision, adapter);
+ return Adapters.adapt(fileRevision, adapter);
}
@Override
@@ -260,7 +260,7 @@ public class FileRevisionEditorInput extends PlatformObject implements
@Override
public String getLabel(Object o) {
- IFileRevision rev = AdapterUtils.adapt(this, IFileRevision.class);
+ IFileRevision rev = Adapters.adapt(this, IFileRevision.class);
if (rev != null)
return rev.getName();
return storage.getName();
@@ -348,11 +348,11 @@ public class FileRevisionEditorInput extends PlatformObject implements
}
private String getRevisionPrefix() {
- IFileRevision rev = AdapterUtils.adapt(this, IFileRevision.class);
+ IFileRevision rev = Adapters.adapt(this, IFileRevision.class);
if (rev != null) {
return abbreviate(rev.getContentIdentifier()) + '_';
}
- IFileState state = AdapterUtils.adapt(this, IFileState.class);
+ IFileState state = Adapters.adapt(this, IFileState.class);
if (state != null) {
return DATE_FORMAT.format(new Date(state.getModificationTime()))
+ '_';
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java
index ee7f29740..685fd1635 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/FileRevisionTypedElement.java
@@ -18,10 +18,10 @@ import java.util.Date;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.team.core.history.IFileRevision;
@@ -63,7 +63,7 @@ public class FileRevisionTypedElement extends StorageTypedElement {
return adapter.cast(result);
}
if (adapter == Repository.class) {
- return AdapterUtils.adapt(fileRevision, adapter);
+ return Adapters.adapt(fileRevision, adapter);
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java
index 1929f9a26..8de917451 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/revision/GitCompareFileRevisionEditorInput.java
@@ -30,11 +30,11 @@ import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.Activator;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.storage.IndexFileRevision;
import org.eclipse.egit.core.internal.storage.OpenWorkspaceVersionEnabled;
import org.eclipse.egit.ui.internal.CommonUtils;
@@ -369,7 +369,7 @@ public class GitCompareFileRevisionEditorInput extends SaveableCompareEditorInpu
}
return getResource();
} else if (adapter == Repository.class && left != null) {
- return AdapterUtils.adapt(left, Repository.class);
+ return Adapters.adapt(left, Repository.class);
}
return super.getAdapter(adapter);
}
@@ -623,7 +623,7 @@ public class GitCompareFileRevisionEditorInput extends SaveableCompareEditorInpu
private ISaveablesLifecycleListener getSaveablesLifecycleListener(
IWorkbenchPart part) {
- ISaveablesLifecycleListener listener = AdapterUtils.adapt(part,
+ ISaveablesLifecycleListener listener = Adapters.adapt(part,
ISaveablesLifecycleListener.class);
if (listener == null)
listener = CommonUtils.getService(part.getSite(), ISaveablesLifecycleListener.class);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionPropertyTester.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionPropertyTester.java
index 7d3a293bb..9f2071376 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionPropertyTester.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionPropertyTester.java
@@ -27,6 +27,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.project.RepositoryMapping;
@@ -194,13 +195,12 @@ public class SelectionPropertyTester extends AbstractPropertyTester {
boolean single) {
Repository repo = null;
for (Object element : collection) {
- IContainer container = AdapterUtils.adapt(element,
- IProject.class);
+ IContainer container = Adapters.adapt(element, IProject.class);
RepositoryMapping mapping = null;
if (container != null) {
mapping = RepositoryMapping.getMapping(container);
} else {
- container = AdapterUtils.adapt(element, IContainer.class);
+ container = Adapters.adapt(element, IContainer.class);
if (container != null) {
mapping = RepositoryMapping.getMapping(container);
}
@@ -214,7 +214,7 @@ public class SelectionPropertyTester extends AbstractPropertyTester {
repo = r;
}
} else {
- IWorkingSet workingSet = AdapterUtils.adapt(element,
+ IWorkingSet workingSet = Adapters.adapt(element,
IWorkingSet.class);
if (workingSet != null) {
for (IAdaptable adaptable : workingSet.getElements()) {
@@ -270,7 +270,7 @@ public class SelectionPropertyTester extends AbstractPropertyTester {
}
private static Repository getRepositoryOfProject(Object object) {
- IProject project = AdapterUtils.adapt(object, IProject.class);
+ IProject project = Adapters.adapt(object, IProject.class);
if (project != null)
return getRepositoryOfMapping(project);
return null;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionUtils.java
index 9729f0b73..338ccc273 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/SelectionUtils.java
@@ -26,6 +26,7 @@ import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.util.ResourceUtil;
@@ -102,7 +103,7 @@ public class SelectionUtils {
Set<Repository> repos = new LinkedHashSet<>();
for (Object o : selection.toArray()) {
- Repository repo = AdapterUtils.adapt(o, Repository.class);
+ Repository repo = Adapters.adapt(o, Repository.class);
if (repo != null) {
repos.add(repo);
} else {
@@ -200,7 +201,7 @@ public class SelectionUtils {
if (location != null)
result.add(location);
} else {
- IPath location = AdapterUtils.adapt(o, IPath.class);
+ IPath location = Adapters.adapt(o, IPath.class);
if (location != null)
result.add(location);
else
@@ -248,7 +249,7 @@ public class SelectionUtils {
}
private static List<IResource> extractResourcesFromMapping(Object o) {
- ResourceMapping mapping = AdapterUtils.adapt(o, ResourceMapping.class);
+ ResourceMapping mapping = Adapters.adapt(o, ResourceMapping.class);
return ResourceUtil.extractResourcesFromMapping(mapping);
}
@@ -316,7 +317,7 @@ public class SelectionUtils {
@NonNull IStructuredSelection selection) {
Set<Object> result = new HashSet<>();
for (Object o : selection.toList()) {
- Repository r = AdapterUtils.adapt(o, Repository.class);
+ Repository r = Adapters.adapt(o, Repository.class);
if (r != null) {
result.add(r);
continue;
@@ -326,12 +327,11 @@ public class SelectionUtils {
result.add(resource);
continue;
}
- ResourceMapping mapping = AdapterUtils.adapt(o,
- ResourceMapping.class);
+ ResourceMapping mapping = Adapters.adapt(o, ResourceMapping.class);
if (mapping != null) {
result.addAll(extractResourcesFromMapping(mapping));
} else {
- IPath location = AdapterUtils.adapt(o, IPath.class);
+ IPath location = Adapters.adapt(o, IPath.class);
if (location != null) {
result.add(location);
}
@@ -394,7 +394,7 @@ public class SelectionUtils {
if (result == null) {
for (Object o : selection.toArray()) {
- Repository nextRepo = AdapterUtils.adapt(o, Repository.class);
+ Repository nextRepo = Adapters.adapt(o, Repository.class);
if (nextRepo != null && result != null && result != nextRepo) {
if (warn)
MessageDialog
@@ -533,7 +533,7 @@ public class SelectionUtils {
result = new ArrayList<>();
Iterator elements = ((IStructuredSelection) selection).iterator();
while (elements.hasNext()) {
- T adapter = AdapterUtils.adapt(elements.next(), c);
+ T adapter = Adapters.adapt(elements.next(), c);
if (adapter != null) {
result.add(adapter);
}
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 0b991000d..b9cc24904 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
@@ -45,6 +45,7 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -1204,7 +1205,7 @@ public class StagingView extends ViewPart
}
if (part instanceof IEditorPart) {
IEditorInput input = ((IEditorPart) part).getEditorInput();
- Repository repository = AdapterUtils.adapt(input,
+ Repository repository = Adapters.adapt(input,
Repository.class);
if (repository != null) {
reactOnSelection(new StructuredSelection(repository));
@@ -1476,7 +1477,7 @@ public class StagingView extends ViewPart
if (resource != null) {
sel = new StructuredSelection(resource);
} else {
- Repository repository = AdapterUtils.adapt(
+ Repository repository = Adapters.adapt(
((IEditorPart) part).getEditorInput(),
Repository.class);
if (repository != null) {
@@ -2004,7 +2005,8 @@ public class StagingView extends ViewPart
// For the normal resource undo/redo actions to be active, so that files
// deleted via the "Delete" action in the staging view can be restored.
- IUndoContext workspaceContext = AdapterUtils.adapt(ResourcesPlugin.getWorkspace(), IUndoContext.class);
+ IUndoContext workspaceContext = Adapters
+ .adapt(ResourcesPlugin.getWorkspace(), IUndoContext.class);
undoRedoActionGroup = new UndoRedoActionGroup(getViewSite(), workspaceContext, true);
undoRedoActionGroup.fillActionBars(actionBars);
@@ -3320,8 +3322,7 @@ public class StagingView extends ViewPart
reload(repo);
}
} else {
- Repository repo = AdapterUtils.adapt(firstElement,
- Repository.class);
+ Repository repo = Adapters.adapt(firstElement, Repository.class);
if (repo != null) {
if (currentRepository != repo) {
reload(repo);
@@ -3609,7 +3610,7 @@ public class StagingView extends ViewPart
.getStagingEntriesFiltered((StagingFolderEntry) o);
collectPaths(entries, result);
} else if (o instanceof StagingEntry) {
- result.add(AdapterUtils.adapt(o, IPath.class));
+ result.add(Adapters.adapt(o, IPath.class));
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitChangeSetModelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitChangeSetModelProvider.java
index b314b35cc..fcdbb4082 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitChangeSetModelProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitChangeSetModelProvider.java
@@ -16,10 +16,10 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.Activator;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext;
import org.eclipse.egit.core.synchronize.IgnoreInGitSynchronizations;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
@@ -76,7 +76,8 @@ public class GitChangeSetModelProvider extends ModelProvider
}
if (object != null) {
- ResourceMapping rm = AdapterUtils.adapt(object, ResourceMapping.class);
+ ResourceMapping rm = Adapters.adapt(object,
+ ResourceMapping.class);
return new ResourceMapping[] { rm };
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java
index c5ad55861..fbed0bc95 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java
@@ -20,13 +20,13 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber;
import org.eclipse.egit.core.synchronize.GitSubscriberMergeContext;
@@ -98,7 +98,7 @@ public class GitModelSynchronize {
List<ResourceMapping> gitMappings = new ArrayList<>();
for (IResource element : elements) {
- ResourceMapping mapping = AdapterUtils.adapt(element,
+ ResourceMapping mapping = Adapters.adapt(element,
ResourceMapping.class);
if (mapping != null && isMappedToGitProvider(mapping))
gitMappings.add(mapping);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronizeParticipant.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronizeParticipant.java
index c1e82daab..7439a3c86 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronizeParticipant.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronizeParticipant.java
@@ -31,6 +31,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -38,7 +39,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.storage.WorkspaceFileRevision;
import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.egit.core.project.GitProjectData;
@@ -221,7 +221,7 @@ public class GitModelSynchronizeParticipant extends ModelSynchronizeParticipant
// in Java Workspace model Java source files are passed as type
// CompilationUnit which can be adapted to IResource
- IResource res = AdapterUtils.adapt(object, IResource.class);
+ IResource res = Adapters.adapt(object, IResource.class);
if (res != null && res.getType() == IResource.FILE)
return true;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/OpenWorkingFileAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/OpenWorkingFileAction.java
index 884305ab2..42bbd36e8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/OpenWorkingFileAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/OpenWorkingFileAction.java
@@ -14,8 +14,8 @@ import java.io.File;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.synchronize.model.GitModelObject;
import org.eclipse.jface.dialogs.ErrorDialog;
@@ -133,7 +133,7 @@ public class OpenWorkingFileAction extends SelectionListenerAction {
@Nullable
private IResource getExistingResource(IStructuredSelection selection) {
Object element = selection.getFirstElement();
- IResource resource = AdapterUtils.adapt(element, IResource.class);
+ IResource resource = Adapters.adapt(element, IResource.class);
if (resource != null && resource.exists()) {
return resource;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitChangeSetContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitChangeSetContentProvider.java
index 50b8e3219..6fc737780 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitChangeSetContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/mapping/GitChangeSetContentProvider.java
@@ -17,11 +17,11 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.Activator;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber;
import org.eclipse.egit.core.synchronize.GitSubscriberMergeContext;
import org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext;
@@ -114,7 +114,7 @@ public class GitChangeSetContentProvider extends SynchronizationContentProvider
@Nullable
private ResourceMapping getResourceMapping(Object object) {
- return AdapterUtils.adapt(object, ResourceMapping.class);
+ return Adapters.adapt(object, ResourceMapping.class);
}
@Override
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitTemplateVariableResolver.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitTemplateVariableResolver.java
index 5b8dbe97b..41cdfe335 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitTemplateVariableResolver.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/variables/GitTemplateVariableResolver.java
@@ -15,8 +15,8 @@ import java.lang.reflect.Method;
import java.util.List;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.jdt.core.IJavaProject;
@@ -147,7 +147,7 @@ public class GitTemplateVariableResolver extends TemplateVariableResolver {
// We can't use instanceof here because of the compiler error on 4.10
// platform saying that TemplateContext is always IAdaptable
if (IAdaptable.class.isInstance(context)) {
- return AdapterUtils.adapt(context, IProject.class);
+ return Adapters.adapt(context, IProject.class);
}
// Note: block below can be removed after EGit minimum target platform
// will be 4.10, see bug 539095 for details

Back to the top