--- /dev/null
+/**
+* Copyright (C) 2007 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.webapp.view.datasource.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.di.UISynchronize;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.taxeditor.webapp.view.datasource.CdmMetaDataAwareDataSourceContainer;
+import eu.etaxonomy.taxeditor.webapp.view.datasource.e4.CdmDataSourceViewPartE4;
+
+/**
+ *
+ * @author pplitzner
+ * @date 22.08.2017
+ *
+ */
+public abstract class AbstractDataSourceHandlerE4 {
+
+ protected UISynchronize sync;
+
+ @Execute
+ public void execute(
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
+ @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ UISynchronize sync) {
+
+ this.sync = sync;
+
+ CdmDataSourceViewPartE4 view = (CdmDataSourceViewPartE4) thisPart.getObject();
+
+ boolean refresh = specificExecute(view,
+ (CdmMetaDataAwareDataSourceContainer) selection.getFirstElement(), shell);
+
+ if(refresh) {
+ view.refresh();
+ }
+ }
+
+ @CanExecute
+ public boolean canExecute(
+ @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
+ MHandledMenuItem menuItem) {
+ boolean canExecute = false;
+ canExecute = thisPart.getObject() instanceof CdmDataSourceViewPartE4
+ && selection!=null
+ && selection.size()==1
+ && selection.getFirstElement() instanceof CdmMetaDataAwareDataSourceContainer;
+ menuItem.setVisible(canExecute);
+ return canExecute;
+ }
+
+ public abstract boolean specificExecute(CdmDataSourceViewPartE4 dataSourceViewPart, CdmMetaDataAwareDataSourceContainer container, Shell shell);
+}