Revision 5ff3332c
Added by Patrick Plitzner over 9 years ago
- added property tester for context menu entries for media view (#3339)
eu.etaxonomy.taxeditor.bulkeditor/plugin.xml | ||
---|---|---|
145 | 145 |
commandId="eu.etaxonomy.taxeditor.bulkeditor.command.derivedunit.addDerivedUnitMedia" |
146 | 146 |
label="Add Derived Unit Media" |
147 | 147 |
style="push"> |
148 |
<visibleWhen> |
|
149 |
<not> |
|
150 |
<reference |
|
151 |
definitionId="isTaxonEditor"> |
|
152 |
</reference> |
|
153 |
</not> |
|
154 |
</visibleWhen> |
|
148 | 155 |
</command> |
149 | 156 |
<command |
150 | 157 |
commandId="eu.etaxonomy.taxeditor.bulkeditor.command.derivedunit.addFieldObjectMedia" |
151 | 158 |
label="Add Field Object Media" |
152 | 159 |
style="push"> |
160 |
<visibleWhen> |
|
161 |
<not> |
|
162 |
<reference |
|
163 |
definitionId="isTaxonEditor"> |
|
164 |
</reference> |
|
165 |
</not> |
|
166 |
</visibleWhen> |
|
153 | 167 |
</command> |
154 | 168 |
</menuContribution> |
155 | 169 |
<menuContribution |
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
1223 | 1223 |
</test> |
1224 | 1224 |
</with> |
1225 | 1225 |
</definition> |
1226 |
<definition |
|
1227 |
id="isTaxonEditor"> |
|
1228 |
<with |
|
1229 |
variable="selection"> |
|
1230 |
<test |
|
1231 |
property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isTaxonEditor"> |
|
1232 |
</test> |
|
1233 |
</with> |
|
1234 |
</definition> |
|
1226 | 1235 |
<definition |
1227 | 1236 |
id="isDescription"> |
1228 | 1237 |
<with |
... | ... | |
1291 | 1300 |
class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DescriptionsMenuPropertyTester" |
1292 | 1301 |
id="eu.etaxonomy.taxeditor.descriptions.PropertyTester" |
1293 | 1302 |
namespace="eu.etaxonomy.taxeditor.descriptions.propertyTester" |
1294 |
properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery" |
|
1303 |
properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor"
|
|
1295 | 1304 |
type="org.eclipse.jface.viewers.TreeSelection"> |
1296 | 1305 |
</propertyTester> |
1297 | 1306 |
<propertyTester |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DescriptionsMenuPropertyTester.java | ||
---|---|---|
9 | 9 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
10 | 10 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
11 | 11 |
import eu.etaxonomy.cdm.model.media.Media; |
12 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
|
13 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
12 | 14 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
13 | 15 |
|
14 | 16 |
/** |
... | ... | |
26 | 28 |
private static final String DESCRIPTION_ELEMENT = "isDescriptionElement"; |
27 | 29 |
private static final String DELETABLE = "isDeletable"; |
28 | 30 |
private static final String IMAGE_GALLERY = "isImageGallery"; |
31 |
private static final String TAXON_EDITOR = "isTaxonEditor"; |
|
29 | 32 |
|
30 | 33 |
/* (non-Javadoc) |
31 | 34 |
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) |
... | ... | |
35 | 38 |
public boolean test(Object receiver, String property, Object[] args, |
36 | 39 |
Object expectedValue) { |
37 | 40 |
|
38 |
Object[] selectedElements = ((IStructuredSelection) receiver).toArray(); |
|
41 |
if(TAXON_EDITOR.equals(property)){ |
|
42 |
return isTaxonEditor(); |
|
43 |
} |
|
39 | 44 |
|
40 |
if(selectedElements.length == 0){ |
|
45 |
Object[] selectedElements = ((IStructuredSelection) receiver).toArray(); |
|
46 |
|
|
47 |
if(selectedElements.length == 0){ |
|
41 | 48 |
// nothing selected so all tests should fail |
42 | 49 |
return false; |
43 | 50 |
} |
... | ... | |
127 | 134 |
} |
128 | 135 |
return true; |
129 | 136 |
} |
137 |
|
|
138 |
private boolean isTaxonEditor() { |
|
139 |
if(AbstractUtility.getActiveEditor() instanceof MultiPageTaxonEditor){ |
|
140 |
return true; |
|
141 |
} |
|
142 |
return false; |
|
143 |
} |
|
130 | 144 |
} |
Also available in: Unified diff