Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Theunissen2019-01-14 15:46:14 +0000
committerLars Vogel2019-01-14 16:24:28 +0000
commite0dddbcd150fcb3588ec4306ee78d580e0772246 (patch)
tree0195f54580498bcfe8c8f59d4b1dd88bfbd15c96 /bundles/org.eclipse.compare/compare/org/eclipse/compare
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>
Diffstat (limited to 'bundles/org.eclipse.compare/compare/org/eclipse/compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareLinkHelper.java48
1 files changed, 48 insertions, 0 deletions
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
+ }
+
+}

Back to the top