*/
package eu.etaxonomy.taxeditor.view;
-import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
-
/**
* This class opens a popup dialog and provides the possibility to choose from a
* list of possible viewers which can be opened for a given input.
titleText, infoText);
}
- public static Map<Entry<Class<?>, String>, ICdmViewer> getNameViewerMap(Object input){
- Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = new HashMap<Entry<Class<?>, String>, ICdmViewer>();
-
- IExtensionRegistry reg = Platform.getExtensionRegistry();
- IConfigurationElement[] extensions = reg
- .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
- for (IConfigurationElement configElement : extensions) {
- try {
- Object object = configElement.createExecutableExtension("class");
- if(object instanceof ICdmViewer){
- ICdmViewer cdmViewer = (ICdmViewer)object;
- Map<Class<?>, String> viewerClasses = cdmViewer.getViewerClasses(input);
- for (Entry<Class<?>, String> entry : viewerClasses.entrySet()) {
- nameViewerMap.put(entry, cdmViewer);
- }
- }
- else{
- MessagingUtils.error(CdmViewerChooser.class, new Status(IStatus.ERROR, TaxeditorStorePlugin.PLUGIN_ID, "Could not load cdmViewer extension"));
- }
- } catch (CoreException e) {
- MessagingUtils.error(CdmViewerChooser.class, "Could not load cdmViewer extension", e);
- }
- }
- return nameViewerMap;
- }
-
/**
* Opens a popup dialog with all possible viewers for the given input.
* @param input the input for which the viewers are listed
*/
public void chooseViewer(Object input){
this.input = input;
- this.nameViewerMap = getNameViewerMap(input);
+ this.nameViewerMap = CdmViewerUtil.getNameViewerMap(input);
//if only one editor is available then open it
if(nameViewerMap.size()==1){
final ISelection selection = window.getActivePage().getSelection();
if(selection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = CdmViewerChooser.getNameViewerMap(firstElement);
+ Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = CdmViewerUtil.getNameViewerMap(firstElement);
for(Entry<Entry<Class<?>, String>, ICdmViewer> entry:nameViewerMap.entrySet()){
Entry<Class<?>, String> viewerClass = entry.getKey();
MenuItem menuItem = new MenuItem(addMenu, SWT.NONE);
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.view;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
+
+/**
+ * @author pplitzner
+ * @date Jul 7, 2015
+ *
+ */
+public class CdmViewerUtil {
+
+ public static Map<Entry<Class<?>, String>, ICdmViewer> getNameViewerMap(Object input){
+ Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = new HashMap<Entry<Class<?>, String>, ICdmViewer>();
+
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IConfigurationElement[] extensions = reg
+ .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
+ for (IConfigurationElement configElement : extensions) {
+ try {
+ Object object = configElement.createExecutableExtension("class");
+ if(object instanceof ICdmViewer){
+ ICdmViewer cdmViewer = (ICdmViewer)object;
+ Map<Class<?>, String> viewerClasses = cdmViewer.getViewerClasses(input);
+ for (Entry<Class<?>, String> entry : viewerClasses.entrySet()) {
+ nameViewerMap.put(entry, cdmViewer);
+ }
+ }
+ else{
+ MessagingUtils.error(CdmViewerChooser.class, new Status(IStatus.ERROR, TaxeditorStorePlugin.PLUGIN_ID, "Could not load cdmViewer extension"));
+ }
+ } catch (CoreException e) {
+ MessagingUtils.error(CdmViewerChooser.class, "Could not load cdmViewer extension", e);
+ }
+ }
+ return nameViewerMap;
+ }
+
+}