Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Theunissen2019-01-14 10:46:14 -0500
committerLars Vogel2019-01-14 11:24:28 -0500
commite0dddbcd150fcb3588ec4306ee78d580e0772246 (patch)
tree0195f54580498bcfe8c8f59d4b1dd88bfbd15c96
parent39201cf6c99c290e0daf1c98f4b4b3a5d168dc69 (diff)
downloadeclipse.platform.team-e0dddbcd150fcb3588ec4306ee78d580e0772246.tar.gz
eclipse.platform.team-e0dddbcd150fcb3588ec4306ee78d580e0772246.tar.xz
eclipse.platform.team-e0dddbcd150fcb3588ec4306ee78d580e0772246.zip
Bug 500061 - Compare editor does not link with Project ExplorerI20190114-1800
Add an ILinkHelper to link the EditorInput of a CompareEditor to the CommonNavigator. - The LinkHelper links the IFile of the active sub-editor to the CommonNavigator, when the CompareEditor part is activated. - The link is *not* refreshed when the active editor in the CompareEditor is changed, either due to user input, or the editor input becoming available. The ILinkHelper is only consulted on 'partActivated'. Change-Id: I2bbb4b9aac2826a8880e626782369a49228d88ad Signed-off-by: Rolf Theunissen <rolf.theunissen@altran.com>
-rw-r--r--bundles/org.eclipse.compare/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareLinkHelper.java48
-rw-r--r--bundles/org.eclipse.compare/plugin.xml23
-rw-r--r--bundles/org.eclipse.compare/pom.xml2
4 files changed, 75 insertions, 3 deletions
diff --git a/bundles/org.eclipse.compare/META-INF/MANIFEST.MF b/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
index 21c34b9ad..add50011c 100644
--- a/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.compare; singleton:=true
-Bundle-Version: 3.7.400.qualifier
+Bundle-Version: 3.7.500.qualifier
Bundle-Activator: org.eclipse.compare.internal.CompareUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.editors;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.compare.core;bundle-version="[3.5.0,4.0.0)";visibility:=reexport
+ org.eclipse.compare.core;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
+ org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional
Bundle-ActivationPolicy: lazy
Import-Package: com.ibm.icu.util,
com.ibm.icu.text
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareLinkHelper.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareLinkHelper.java
new file mode 100644
index 000000000..dc5fdc956
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareLinkHelper.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation 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:
+ * Rolf Theunissen - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.navigator.ILinkHelper;
+
+/**
+ * Links CompareEditorInput to IFiles in the CommonNavigator.
+ *
+ * @since 3.8
+ */
+public class CompareLinkHelper implements ILinkHelper {
+
+ @Override
+ public IStructuredSelection findSelection(IEditorInput anInput) {
+ IEditorInput eInput = anInput.getAdapter(IEditorInput.class);
+
+ IFile file = ResourceUtil.getFile(eInput);
+ if (file != null) {
+ return new StructuredSelection(file);
+ }
+
+ return StructuredSelection.EMPTY;
+ }
+
+ @Override
+ public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) {
+ // do nothing
+ }
+
+}
diff --git a/bundles/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugin.xml
index c1265cd38..71b7fde5b 100644
--- a/bundles/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugin.xml
@@ -367,4 +367,27 @@
</factory>
</extension>
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding
+ viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.compare.linkHelper">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.linkHelper">
+ <linkHelper
+ class="org.eclipse.compare.internal.CompareLinkHelper"
+ id="org.eclipse.compare.linkHelper">
+ <editorInputEnablement>
+ <instanceof value="org.eclipse.compare.CompareEditorInput"/>
+ </editorInputEnablement>
+ </linkHelper>
+ </extension>
+
</plugin>
diff --git a/bundles/org.eclipse.compare/pom.xml b/bundles/org.eclipse.compare/pom.xml
index 12f8dbf52..7f2cad82a 100644
--- a/bundles/org.eclipse.compare/pom.xml
+++ b/bundles/org.eclipse.compare/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.compare</groupId>
<artifactId>org.eclipse.compare</artifactId>
- <version>3.7.400-SNAPSHOT</version>
+ <version>3.7.500-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>

Back to the top