Project

General

Profile

Revision 09831abe

ID09831abe3e24ea758d08d6699a3fd8cffb659ef9
Parent 017f41a2
Child 4b61c8bc

Added by Patrick Plitzner over 3 years ago

ref #7010 Adapt uses view handlers for multiple selection

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionElementHandlerE4.java
79 79
    }
80 80

  
81 81
    @CanExecute
82
    public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection,
83
            MHandledMenuItem menuItem){
82
    public boolean canExecute(MHandledMenuItem menuItem,
83
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection){
84 84
        boolean canExecute = false;
85
        canExecute = selection!=null
86
                && selection.size()==1;
85
        canExecute = selection.size()==1
86
                &&
87
                (selection.getFirstElement() instanceof DescriptionBase
88
                || selection.getFirstElement() instanceof DescriptionElementBase
89
                || selection.getFirstElement() instanceof FeatureNodeContainer);
87 90
        menuItem.setVisible(canExecute);
88 91
        return canExecute;
92

  
89 93
    }
90 94

  
91 95
    /**
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/e4/handler/CreateUseRecordHandlerE4.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.editor.view.uses.e4.handler;
11 11

  
12
import javax.inject.Named;
13

  
14
import org.eclipse.e4.core.di.annotations.CanExecute;
15
import org.eclipse.e4.ui.services.IServiceConstants;
16

  
17 12
import eu.etaxonomy.cdm.model.description.DescriptionBase;
18
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
19 13
import eu.etaxonomy.cdm.model.description.Feature;
20 14
import eu.etaxonomy.taxeditor.editor.EditorUtil;
21 15
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.CreateDescriptionElementHandlerE4;
22 16
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateUseRecordOperation;
23
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
24 17
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
25 18
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26 19
import eu.etaxonomy.taxeditor.store.UseObjectStore;
......
32 25
 *
33 26
 */
34 27
public class CreateUseRecordHandlerE4 extends CreateDescriptionElementHandlerE4 {
35
	/** {@inheritDoc} */
36
	@Override
28

  
29
    @Override
37 30
	protected AbstractPostOperation operationCreationInstance(String label, Feature feature, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
38 31
		//Use Record Feature retrieval below
39 32
		Feature useRecordFeature = UseObjectStore.getUseRecordFeature();
......
43 36
					description, useRecordFeature, postOperationEnabled);
44 37
	}
45 38

  
46

  
47
    @CanExecute
48
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection){
49
        return selection instanceof DescriptionBase
50
                || selection instanceof DescriptionElementBase
51
                || selection instanceof FeatureNodeContainer;
52
    }
53

  
54 39
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/e4/handler/CreateUseSummaryHandlerE4.java
9 9
package eu.etaxonomy.taxeditor.editor.view.uses.e4.handler;
10 10

  
11 11

  
12
import javax.inject.Named;
13

  
14
import org.eclipse.e4.core.di.annotations.CanExecute;
15
import org.eclipse.e4.ui.services.IServiceConstants;
16

  
17 12
import eu.etaxonomy.cdm.model.description.DescriptionBase;
18
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
19 13
import eu.etaxonomy.cdm.model.description.Feature;
20 14
import eu.etaxonomy.taxeditor.editor.EditorUtil;
21 15
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.CreateDescriptionElementHandlerE4;
22 16
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateUseSummaryOperation;
23
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
24 17
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
25 18
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26 19
import eu.etaxonomy.taxeditor.store.UseObjectStore;
......
43 36
		return new CreateUseSummaryOperation(label,	EditorUtil.getUndoContext(), description, useSummarFeature, postOperationEnabled);
44 37
	}
45 38

  
46
	@CanExecute
47
	public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection){
48
	    return selection instanceof DescriptionBase
49
	            || selection instanceof DescriptionElementBase
50
	            || selection instanceof FeatureNodeContainer;
51
	}
52

  
53 39
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)