Removed unnecessary ExecutionEvent
import java.util.Map;
import org.apache.log4j.Logger;
import java.util.Map;
import org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.ui.PartInitException;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import org.eclipse.ui.PartInitException;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
private final Logger logger = Logger.getLogger(EditorCdmViewer.class);
private final Logger logger = Logger.getLogger(EditorCdmViewer.class);
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.view.ICdmViewer#show(java.lang.Object)
- */
- public void show(Object input, Class<?> viewerClass, ExecutionEvent event) {
+ public void show(Object input, Class<?> viewerClass) {
try {
if(viewerClass.equals(MultiPageTaxonEditor.class)){
if(input instanceof TaxonBase){
try {
if(viewerClass.equals(MultiPageTaxonEditor.class)){
if(input instanceof TaxonBase){
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.view.ICdmViewer#getViewerClasses(java.lang.Object)
- */
@Override
public Map<Class<?>, String> getViewerClasses(Object input) {
Map<Class<?>, String> viewerNameMap = new HashMap<Class<?>, String>();
@Override
public Map<Class<?>, String> getViewerClasses(Object input) {
Map<Class<?>, String> viewerNameMap = new HashMap<Class<?>, String>();
import java.util.Map;
import org.apache.log4j.Logger;
import java.util.Map;
import org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.PlatformUI;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
@SuppressWarnings("unused")
private final Logger logger = Logger.getLogger(NavigationCdmViewer.class);
@SuppressWarnings("unused")
private final Logger logger = Logger.getLogger(NavigationCdmViewer.class);
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.view.ICdmViewer#show(java.lang.Object)
- */
- public void show(Object input, Class<?> viewerClass, ExecutionEvent event) {
+ public void show(Object input, Class<?> viewerClass) {
if(viewerClass.equals(NewClassificationWizard.class)){
if(input instanceof Classification){
Classification classification = (Classification)input;
NewClassificationWizard classificationWizard = new NewClassificationWizard();
classificationWizard.init(null, null);
classificationWizard.setEntity(classification);
if(viewerClass.equals(NewClassificationWizard.class)){
if(input instanceof Classification){
Classification classification = (Classification)input;
NewClassificationWizard classificationWizard = new NewClassificationWizard();
classificationWizard.init(null, null);
classificationWizard.setEntity(classification);
- WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), classificationWizard);
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), classificationWizard);
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.view.ICdmViewer#getViewerClasses(java.lang.Object)
- */
@Override
public Map<Class<?>, String> getViewerClasses(Object input) {
Map<Class<?>, String> viewerNameMap = new HashMap<Class<?>, String>();
@Override
public Map<Class<?>, String> getViewerClasses(Object input) {
Map<Class<?>, String> viewerNameMap = new HashMap<Class<?>, String>();
import eu.etaxonomy.taxeditor.view.CdmViewerChooser;
import eu.etaxonomy.taxeditor.view.CdmViewerChooser;
+/**
+ * Opens the (first) currently selected element in a viewer. Opens a list of
+ * possible viewers if more than one are registered for this element.
+ *
+ * @author pplitzner
+ * @date Jul 6, 2015
+ *
+ */
public class OpenHandler extends AbstractHandler {
@Override
public class OpenHandler extends AbstractHandler {
@Override
if(currentSelection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection) currentSelection).getFirstElement();
CdmViewerChooser viewerChooser = new CdmViewerChooser(HandlerUtil.getActiveShell(event));
if(currentSelection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection) currentSelection).getFirstElement();
CdmViewerChooser viewerChooser = new CdmViewerChooser(HandlerUtil.getActiveShell(event));
- viewerChooser.chooseViewer(firstElement, event);
+ viewerChooser.chooseViewer(firstElement);
import java.util.Map;
import java.util.Map.Entry;
import java.util.Map;
import java.util.Map.Entry;
-import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
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
*
* @author pplitzner
* @date Feb 23, 2015
private Object input;
private Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap;
private Object input;
private Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap;
- private ExecutionEvent executionEvent;
public CdmViewerChooser(Shell parentShell) {
this(parentShell, SWT.RESIZE | SWT.ON_TOP, true, false, false, false, false, "Open in ...",
public CdmViewerChooser(Shell parentShell) {
this(parentShell, SWT.RESIZE | SWT.ON_TOP, true, false, false, false, false, "Open in ...",
- /**
- * Opens a popup dialog with all possible viewers for the given input.
- * @param input the input for which the viewers are listed
- * @param event the {@link ExecutionEvent} if invoked via command/handler
- */
- public void chooseViewer(Object input, ExecutionEvent event){
- this.input = input;
- this.executionEvent = event;
- this.nameViewerMap = new HashMap<Entry<Class<?>, String>, ICdmViewer>();
+ 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
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] extensions = reg
MessagingUtils.error(CdmViewerChooser.class, "Could not load cdmViewer extension", 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);
+
//if only one editor is available then open it
if(nameViewerMap.size()==1){
Entry<Class<?>, String> next = nameViewerMap.keySet().iterator().next();
ICdmViewer cdmViewer = nameViewerMap.get(next);
//if only one editor is available then open it
if(nameViewerMap.size()==1){
Entry<Class<?>, String> next = nameViewerMap.keySet().iterator().next();
ICdmViewer cdmViewer = nameViewerMap.get(next);
- cdmViewer.show(input, next.getKey(), event);
+ cdmViewer.show(input, next.getKey());
}
else{
if(nameViewerMap.isEmpty()){
}
else{
if(nameViewerMap.isEmpty()){
- /* (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));
@Override
protected Control createDialogArea(Composite parent) {
TableViewer viewer = new TableViewer(new Table(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if(nameViewerMap.containsKey(firstElement)){
Entry<Class<?>, String> entry = (Entry<Class<?>, String>)firstElement;
ICdmViewer cdmViewer = nameViewerMap.get(entry);
if(nameViewerMap.containsKey(firstElement)){
Entry<Class<?>, String> entry = (Entry<Class<?>, String>)firstElement;
ICdmViewer cdmViewer = nameViewerMap.get(entry);
- cdmViewer.show(input, entry.getKey(), this.executionEvent);
+ cdmViewer.show(input, entry.getKey());
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
@Override
public String getText(Object element) {
String text = null;
@Override
public String getText(Object element) {
String text = null;
- /* (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
}
@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
}
@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;
}
@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
}
@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
@Override
public Image getImage(Object element) {
// TODO Auto-generated method stub
-import org.eclipse.core.commands.ExecutionEvent;
-
/**
* Implementors of this interface provide a mapping of input elements to views
/**
* Implementors of this interface provide a mapping of input elements to views
public interface ICdmViewer {
/**
public interface ICdmViewer {
/**
- * For the given input a map specifying the available viewers classes as
- * keys and their string representation as values is returned
+ * For the given input a map is returned specifying the available viewer
+ * classes as keys and their string representation as values
*
* @param input
* the input for which the viewer classes should be returned
*
* @param input
* the input for which the viewer classes should be returned
* Opens the viewer defined by the given viewerClass for the given input.
* @param input the input for which a viewer should be opened
* @param viewerClass the qualified class name of the viewer
* Opens the viewer defined by the given viewerClass for the given input.
* @param input the input for which a viewer should be opened
* @param viewerClass the qualified class name of the viewer
- * @param event the {@link ExecutionEvent} if invoked via command/handler
- public void show(Object input, Class<?> viewerClass, ExecutionEvent event);
+ public void show(Object input, Class<?> viewerClass);