*/
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 provides the possibility to choose from a list of possible viewers
- * which can be opened for a given input in a popup dialog.
+ * 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.
*
* @author pplitzner
* @date Feb 23, 2015
*/
public void chooseViewer(Object input){
this.input = input;
- this.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);
- }
- }
+ this.nameViewerMap = CdmViewerUtil.getNameViewerMap(input);
+
//if only one editor is available then open it
if(nameViewerMap.size()==1){
Entry<Class<?>, String> next = nameViewerMap.keySet().iterator().next();
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
@Override
protected Control createDialogArea(Composite parent) {
TableViewer viewer = new TableViewer(new Table(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
return parent;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
@Override
public String getText(Object element) {
String text = null;
return text;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
@Override
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
@Override
public void dispose() {
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
- */
@Override
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
@Override
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
@Override
public Image getImage(Object element) {
// TODO Auto-generated method stub