Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-10-25 19:58:23 +0000
committerMartin Fluegge2011-10-25 19:58:23 +0000
commite7f88afda636abe81ddb00f5b26b124a1931c84d (patch)
treef6548de80a1a76973cb743fbf1dbc92c3a6c77d3 /plugins/org.eclipse.emf.cdo.dawn.ui
parent5fe470950fe93c3b9608fed817f40b94ed11f4bc (diff)
downloadcdo-e7f88afda636abe81ddb00f5b26b124a1931c84d.tar.gz
cdo-e7f88afda636abe81ddb00f5b26b124a1931c84d.tar.xz
cdo-e7f88afda636abe81ddb00f5b26b124a1931c84d.zip
[361743] [Dawn] Extended EMF editor does not show Dawn specific context
menus https://bugs.eclipse.org/bugs/show_bug.cgi?id=361743
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java177
1 files changed, 95 insertions, 82 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java
index 967333d8dc..5739a257f2 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java
@@ -1,82 +1,95 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- */
-package org.eclipse.emf.cdo.dawn.ui.helper;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Martin Fluegge
- */
-public class EditorDescriptionHelper
-{
- public static String getEditorIdForDawnEditor(String resourceName)
- {
- IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName);
- if (editorDescriptor != null)
- {
- return editorDescriptor.getId();
- }
- return null;
- }
-
- public static IEditorDescriptor getEditorDescriptorForDawnEditor(String resourceName)
- {
- IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName);
-
- for (IEditorDescriptor editorDescriptor : editors)
- {
- // TODO make this more stable by getting the class name more reliably
- if (editorDescriptor.getId().contains(".Dawn") || editorDescriptor.getId().contains(".dawn"))
- {
- return editorDescriptor;
- }
- }
-
- return null;
- }
-
- public static IEditorDescriptor getEditorDescriptorFromFirstEditor(String resourceName)
- {
- IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName);
- if (editors.length > 0)
- {
- return editors[0];
- }
-
- return null;
- }
-
- public static IEditorDescriptor getEditorDescriptorForDawnEditor(Resource resource)
- {
- return getEditorDescriptorForDawnEditor(resource.getURI().lastSegment());
- }
-
- public static Image getImageForEditor(String resourceName)
- {
- IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName);
-
- if (editorDescriptor == null)
- {
- editorDescriptor = getEditorDescriptorFromFirstEditor(resourceName);
- }
-
- if (editorDescriptor != null)
- {
- return editorDescriptor.getImageDescriptor().createImage();
- }
-
- return null;
- }
-}
+/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.ui.helper;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Martin Fluegge
+ */
+public class EditorDescriptionHelper
+{
+ public static String getEditorIdForDawnEditor(String resourceName)
+ {
+ IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName);
+ if (editorDescriptor != null)
+ {
+ return editorDescriptor.getId();
+ }
+ return null;
+ }
+
+ public static IEditorDescriptor getEditorDescriptorForDawnEditor(String resourceName)
+ {
+ IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName);
+
+ for (IEditorDescriptor editorDescriptor : editors)
+ {
+ // TODO make this more stable by getting the class name more reliably
+ String id = editorDescriptor.getId();
+ int lastIndexOf = id.lastIndexOf('.');
+ String lastSegment = id.substring(lastIndexOf + 1, id.length());
+
+ if (lastSegment.toLowerCase().startsWith("dawn"))
+ {
+ return editorDescriptor;
+ }
+ }
+ // if this fails we try to get one that contains .dawn
+ for (IEditorDescriptor editorDescriptor : editors)
+ {
+ // TODO make this more stable by getting the class name more reliably
+ String id = editorDescriptor.getId();
+ if (id.toLowerCase().contains(".dawn"))
+ {
+ return editorDescriptor;
+ }
+ }
+ return null;
+ }
+
+ public static IEditorDescriptor getEditorDescriptorFromFirstEditor(String resourceName)
+ {
+ IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName);
+ if (editors.length > 0)
+ {
+ return editors[0];
+ }
+
+ return null;
+ }
+
+ public static IEditorDescriptor getEditorDescriptorForDawnEditor(Resource resource)
+ {
+ return getEditorDescriptorForDawnEditor(resource.getURI().lastSegment());
+ }
+
+ public static Image getImageForEditor(String resourceName)
+ {
+ IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName);
+
+ if (editorDescriptor == null)
+ {
+ editorDescriptor = getEditorDescriptorFromFirstEditor(resourceName);
+ }
+
+ if (editorDescriptor != null)
+ {
+ return editorDescriptor.getImageDescriptor().createImage();
+ }
+
+ return null;
+ }
+}

Back to the top