Project

General

Profile

Revision a61cb7d4

IDa61cb7d4b3ce0c682bef9fac5761572a973e0830
Parent 41e7e87f
Child 7d5cb398

Added by Patrick Plitzner over 2 years ago

ref #6913 Remove open handler

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java
1
package eu.etaxonomy.taxeditor.editor.handler;
2

  
3
import org.eclipse.core.commands.AbstractHandler;
4
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
7
import org.eclipse.e4.ui.workbench.modeling.EPartService;
8
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
9

  
10
import eu.etaxonomy.taxeditor.editor.AppModelId;
11
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
12
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
13
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
14

  
15
public class OpenDerivateViewHandler extends AbstractHandler {
16

  
17
    @Override
18
    public Object execute(ExecutionEvent event) throws ExecutionException {
19
        EPartService partService = TaxeditorStorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
20
        MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW);
21
        part = partService.showPart(part, PartState.ACTIVATE);
22
        DerivateView derivateView = (DerivateView) part.getObject();
23
        derivateView.init(new DerivateViewEditorInput());
24
        return null;
25
    }
26

  
27
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/DefaultOpenHandlerBase.java
1
package eu.etaxonomy.taxeditor.handler.defaultHandler;
2

  
3
import java.util.UUID;
4

  
5
import org.eclipse.core.commands.AbstractHandler;
6
import org.eclipse.core.commands.ExecutionEvent;
7
import org.eclipse.core.commands.ExecutionException;
8
import org.eclipse.core.commands.ParameterType;
9
import org.eclipse.core.commands.common.NotDefinedException;
10

  
11
import eu.etaxonomy.taxeditor.model.MessagingUtils;
12
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
13

  
14
public abstract class DefaultOpenHandlerBase <T> extends AbstractHandler {
15

  
16
    @Override
17
    public Object execute(ExecutionEvent event) throws ExecutionException {
18
        String commandId = event.getCommand().getId();
19
        String uuidParameterId = commandId+".uuid";
20
        //check if uuid parameter is set
21
        if(event.getParameter(uuidParameterId)!=null){
22
            Object object = event.getObjectParameterForExecution(uuidParameterId);
23
            ParameterType parameterType;
24
            try {
25
                parameterType = event.getCommand().getParameterType(uuidParameterId);
26
                if(parameterType.isCompatible(object)){
27
                    T entity = getEntity((UUID) object);
28
                    open(event, entity);
29
                }
30
            } catch (NotDefinedException e) {
31
                MessagingUtils.error(DefaultOpenHandlerBase.class, "Error while opening entity!", e);
32
            }
33
        }
34
        //if not try current selection
35
        else{
36
            MessagingUtils.errorDialog("Default Handler", this, "Migrate handler!!!", TaxeditorStorePlugin.PLUGIN_ID, null, false);
37
//            ISelection selection = HandlerUtil.getCurrentSelection(event);
38
//            if(selection instanceof IStructuredSelection){
39
//                open(event, (T) ((IStructuredSelection) selection).getFirstElement());
40
//            }
41
        }
42
        return null;
43
    }
44

  
45

  
46
    protected abstract T getEntity(UUID uuid);
47

  
48
    protected abstract void open(ExecutionEvent event, T entity);
49

  
50
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)