Project

General

Profile

« Previous | Next » 

Revision f853dd5b

Added by Patrick Plitzner almost 6 years ago

ref #7010 Adapt taxon navigator handlers for multiple selection

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CloneClassificationHandlerE4.java
70 70
    @CanExecute
71 71
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
72 72
        boolean canExecute = false;
73
        canExecute = selection.getFirstElement() instanceof TaxonNode
73
        canExecute = selection.size()==1
74
                && selection.getFirstElement() instanceof TaxonNode
74 75
                && ((TaxonNode) selection.getFirstElement()).getTaxon()==null
75 76
                && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
76 77
        menuItem.setVisible(canExecute);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CopyHandlerE4.java
19 19
import org.eclipse.e4.ui.services.IServiceConstants;
20 20
import org.eclipse.jface.viewers.TreeSelection;
21 21

  
22
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
23 22
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
24 23
import eu.etaxonomy.taxeditor.model.AbstractUtility;
25 24
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
......
56 55
    @CanExecute
57 56
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
58 57
        boolean canExecute = false;
59
        canExecute = selection.getFirstElement() instanceof ITaxonTreeNode;
58
        canExecute = selection.size()==1
59
                && selection.getFirstElement() instanceof TaxonNodeDto;
60 60
        menuItem.setVisible(canExecute);
61 61
        return canExecute;
62 62
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CreateClassificationHierarchyHandlerE4.java
53 53
    @CanExecute
54 54
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
55 55
        boolean canExecute = false;
56
        canExecute = selection.getFirstElement() instanceof TaxonNode
56
        canExecute = selection.size()==1
57
                && selection.getFirstElement() instanceof TaxonNode
57 58
                && ((TaxonNode) selection.getFirstElement()).getTaxon()==null
58 59
                && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
59 60
        menuItem.setVisible(canExecute);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/DeleteHandlerE4.java
186 186
    @CanExecute
187 187
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
188 188
        boolean canExecute = false;
189
        canExecute = !selection.isEmpty() && !(selection.getFirstElement() instanceof Synonym);
189
        canExecute = !selection.isEmpty();
190
        Object[] array = selection.toArray();
191
        for (Object object : array) {
192
            canExecute &= !(object instanceof Synonym);
193
        }
190 194
        menuItem.setVisible(canExecute);
191 195
        return canExecute;
192 196
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/NewTaxonNodeHandlerE4.java
15 15
import org.eclipse.e4.core.di.annotations.CanExecute;
16 16
import org.eclipse.e4.core.di.annotations.Execute;
17 17
import org.eclipse.e4.ui.model.application.MApplication;
18
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
18 19
import org.eclipse.e4.ui.services.IServiceConstants;
19 20
import org.eclipse.e4.ui.workbench.modeling.EModelService;
20 21
import org.eclipse.e4.ui.workbench.modeling.EPartService;
......
65 66
	}
66 67

  
67 68
    @CanExecute
68
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection){
69
        return selection!=null && !selection.isEmpty();
69
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
70
            MHandledMenuItem menuItem){
71
        boolean canExecute = false;
72
        canExecute = selection!=null && selection.size()==1;
73
        menuItem.setVisible(canExecute);
74
        return canExecute;
70 75
    }
71 76
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RefreshTreeHandlerE4.java
18 18
import org.eclipse.e4.ui.services.IServiceConstants;
19 19
import org.eclipse.jface.viewers.TreeSelection;
20 20

  
21
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
22 21
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
23 22

  
24 23
/**
......
40 39
    @CanExecute
41 40
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
42 41
        boolean canExecute = false;
43
        canExecute = selection.getFirstElement() instanceof TaxonNodeDto;
42
        canExecute = !selection.isEmpty();
44 43
        menuItem.setVisible(canExecute);
45 44
        return canExecute;
46 45
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingChangeAcceptedTaxonToSynonymHandlerE4.java
143 143
    @CanExecute
144 144
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
145 145
        boolean canExecute = false;
146
        canExecute = (selection.getFirstElement() instanceof TaxonNodeDto) && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null ;
146
        canExecute = selection.size()==1
147
                && selection.getFirstElement() instanceof TaxonNodeDto
148
                && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null ;
147 149
        menuItem.setVisible(canExecute);
148 150
        return canExecute;
149 151
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingDeleteTaxonNodeHandlerE4.java
196 196
    @CanExecute
197 197
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
198 198
        boolean canExecute = false;
199
        Object selectionElement =  selection.getFirstElement();
200

  
201
        canExecute = (selectionElement instanceof TaxonNodeDto) ||
202
                (selectionElement instanceof TaxonNode && ((TaxonNode)selectionElement).getTaxon() == null);
199
        canExecute = selection.size()==1
200
                && (selection.getFirstElement() instanceof TaxonNodeDto)
201
                ||
202
                (selection.getFirstElement() instanceof TaxonNode
203
                        && ((TaxonNode)selection.getFirstElement()).getTaxon() == null);
203 204
        menuItem.setVisible(canExecute);
204 205
        return canExecute;
205 206
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveFactualDataHandlerE4.java
123 123
    @CanExecute
124 124
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
125 125
        boolean canExecute = false;
126
        canExecute = (selection.getFirstElement() instanceof TaxonNodeDto) && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid()  != null;
126
        canExecute = selection.size()==1
127
                && selection.getFirstElement() instanceof TaxonNodeDto
128
                && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid()  != null;
127 129
        menuItem.setVisible(canExecute);
128 130
        return canExecute;
129 131
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveTaxonNodeHandlerE4.java
145 145
    @CanExecute
146 146
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
147 147
        boolean canExecute = false;
148
        canExecute = (selection.getFirstElement() instanceof TaxonNodeDto) && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid()  != null;
148
        canExecute = selection.size()==1
149
                && selection.getFirstElement() instanceof TaxonNodeDto
150
                && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null;
149 151
        menuItem.setVisible(canExecute);
150 152
        return canExecute;
151 153
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetPublishFlagForSubtreeHandlerE4.java
92 92
    @CanExecute
93 93
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
94 94
        boolean canExecute = false;
95
        canExecute = selection.getFirstElement() instanceof TaxonNodeDto;
95
        canExecute = selection.size()==1
96
                && selection.getFirstElement() instanceof TaxonNodeDto;
96 97
        menuItem.setVisible(canExecute);
97 98
        return canExecute;
98 99
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetSecReferenceForSubtreeHandlerE4.java
90 90
    @CanExecute
91 91
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
92 92
        boolean canExecute = false;
93
        canExecute = selection.getFirstElement() instanceof TaxonNodeDto;
93
        canExecute = selection.size()==1
94
                && selection.getFirstElement() instanceof TaxonNodeDto;
94 95
        menuItem.setVisible(canExecute);
95 96
        return canExecute;
96 97
    }

Also available in: Unified diff