Bug 539446 - Show path in CTRL+E
Now Ctrl+E shows the path for filtered editor resources
Change-Id: I6a7119d5e0cb55236c485ef48d6b1fdeb62e824c
Signed-off-by: Patrik Suzzi <psuzzi@itemis.com>
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java
index a420747..99abf11 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbookEditorsHandler.java
@@ -20,6 +20,8 @@
import java.util.List;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.runtime.Adapters;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
@@ -35,7 +37,10 @@
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.themes.ITheme;
@@ -164,6 +169,29 @@
ColumnViewerToolTipSupport.enableFor(tableViewerColumn.getViewer());
}
+ /** Extends generated label adding the resource path for duplicates */
+ @Override
+ protected String getWorkbenchPartReferenceText(WorkbenchPartReference ref) {
+ StringBuilder str = new StringBuilder(super.getWorkbenchPartReferenceText(ref));
+ if (ref instanceof EditorReference) {
+ str.append(" - "); //$NON-NLS-1$
+ str.append(getEditorInputPath((EditorReference) ref));
+ }
+ return str.toString();
+ }
+
+ /** Return the editor input path relative to the workspace root */
+ private String getEditorInputPath(EditorReference editorReference) {
+ try {
+ IEditorInput input = editorReference.getEditorInput();
+ return Adapters.adapt(input, IPathEditorInput.class).getPath().makeRelativeTo(Platform.getLocation())
+ .toOSString();
+ } catch (PartInitException e) {
+ WorkbenchPlugin.log(getClass(), "getWorkbenchPartReferenceText", e); //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+ }
+
/** True if the given model represents the active editor */
protected boolean isActiveEditor(MPart model) {
if (model == null || model.getTags() == null) {