Project

General

Profile

« Previous | Next » 

Revision 45e12d2b

Added by Patrick Plitzner about 9 years ago

  • added Open in Taxon Editor command to Taxon Bulk Editor (#4536)

View differences:

.gitattributes
82 82
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorViewerConfiguration.java -text
83 83
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/IBulkEditorConstants.java -text
84 84
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/IBulkEditorSortProvider.java -text
85
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/PropertyTester.java -text
86 85
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorPropertyTester.java -text
87 86
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DeleteObjectContributionItem.java -text
88 87
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicMarkerTypeEditingMenu.java -text
eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
82 82
      </menuContribution>
83 83
      <menuContribution
84 84
            locationURI="popup:#BulkEditorContext">
85
         <command
86
               commandId="eu.etaxonomy.taxeditor.navigation.command.update.editSelection"
87
               label="Edit"
88
               style="push">
89
            <visibleWhen>
90
               <reference
91
                     definitionId="isTaxonBulkEditorInput">
92
               </reference>
93
            </visibleWhen>
94
         </command>
95
         <separator
96
               name="taxeditor-bulkeditor.separator1"
97
               visible="true">
98
         </separator>
85 99
         <menu
86 100
               label="%menu.label.1">
87 101
            <dynamic
......
102 116
            </visibleWhen>
103 117
         </menu>
104 118
         <separator
105
               name="taxeditor-bulkeditor.separator1"
106
               visible="true">
119
               name="eu.etaxonomy.taxeditor.bulkeditor.separator1">
107 120
         </separator>
108 121
         <command
109 122
               commandId="bulkeditor.commands.setmergetarget"
......
306 319
            </test>
307 320
         </with>
308 321
      </definition>
322
      <definition
323
            id="isTaxonBulkEditorInput">
324
         <with
325
               variable="activeEditor">
326
            <test
327
                  property="taxeditor-bulkeditor.propertyTester.isTaxonEditor">
328
            </test>
329
         </with>
330
      </definition>
309 331
   </extension>
310 332
   <extension
311 333
         point="org.eclipse.core.expressions.propertyTesters">
......
313 335
            class="eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorPropertyTester"
314 336
            id="taxeditor-bulkeditor.PropertyTester"
315 337
            namespace="taxeditor-bulkeditor.propertyTester"
316
            properties="isMergingEnabled"
317
            type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor">
318
      </propertyTester>
319
      <propertyTester
320
            class="eu.etaxonomy.taxeditor.bulkeditor.PropertyTester"
321
            id="eu.etaxonomy.taxeditor.bulkeditor.propertyTester"
322
            namespace="eu.etaxonomy.taxeditor.bulkeditor.propertyTester"
323
            properties="isDerivedUnitEditor"
338
            properties="isMergingEnabled, isDerivedUnitEditor, isTaxonEditor, isGroupEditor"
324 339
            type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor">
325 340
      </propertyTester>
326 341
   </extension>
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/PropertyTester.java
1

  
2
package eu.etaxonomy.taxeditor.bulkeditor;
3

  
4
import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
5

  
6
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
7

  
8
	public static final String IS_DERIVED_UNIT_EDITOR = "isDerivedUnitEditor";
9
	
10
	@Override
11
	public boolean test(Object receiver, String property, Object[] args,
12
			Object expectedValue) {
13
		
14
		BulkEditor editor = (BulkEditor) receiver;
15
		
16
		if(IS_DERIVED_UNIT_EDITOR.equals(property)){
17
			return editor.getEditorInput() instanceof OccurrenceEditorInput;
18
		}
19
		
20
		return false;
21
	}
22

  
23
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorPropertyTester.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
12 12

  
13 13
import org.apache.log4j.Logger;
14 14
import org.eclipse.core.expressions.PropertyTester;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16 15
import org.eclipse.ui.IEditorInput;
17 16

  
18
import eu.etaxonomy.cdm.model.common.Group;
19
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
20 17
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
21 18
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
22 19
import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
23 20
import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
24
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
21
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
25 22

  
26 23
/**
27 24
 * <p>BulkEditorPropertyTester class.</p>
......
31 28
 * @version 1.0
32 29
 */
33 30
public class BulkEditorPropertyTester extends PropertyTester {
34
	private static final Logger logger = Logger
31

  
32
    @SuppressWarnings("unused")
33
    private static final Logger logger = Logger
35 34
			.getLogger(BulkEditorPropertyTester.class);
36 35

  
37
	private static final String GROUP = "isGroup";
38
	private static final String DERIVEDUNIT = "isDerivedUnit";
36
	private static final String IS_MERGING_ENABLED = "isMergingEnabled";
37

  
38
	private static final String IS_GROUP_EDITOR = "isGroupEditor";
39
    public static final String IS_DERIVED_UNIT_EDITOR = "isDerivedUnitEditor";
40
    public static final String IS_TAXON_EDITOR = "isTaxonEditor";
41

  
39 42
	/* (non-Javadoc)
40 43
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
41 44
	 */
42 45
	/** {@inheritDoc} */
43
	public boolean test(Object receiver, String property, Object[] args,
46
	@Override
47
    public boolean test(Object receiver, String property, Object[] args,
44 48
			Object expectedValue) {
45 49
		BulkEditor bulkEditor = (BulkEditor) receiver;
46
			
47
		if ("isMergingEnabled".equals(property)) {			
50

  
51
		if (IS_MERGING_ENABLED.equals(property)) {
48 52
			IEditorInput input = bulkEditor.getEditorInput();
49 53
			if (input instanceof AbstractBulkEditorInput) {
50
				return ((AbstractBulkEditorInput) input).isMergingEnabled();
51
			}			
54
				return ((AbstractBulkEditorInput<?>) input).isMergingEnabled();
55
			}
52 56
		}
53
		if(GROUP.equals(property)){
54
			return isGroup(bulkEditor);
57
		else if(IS_GROUP_EDITOR.equals(property)){
58
			return bulkEditor.getEditorInput() instanceof GroupEditorInput;
55 59
		}
56
		
57
		if (DERIVEDUNIT.equals(property)){
58
			
59
			return isDerivedUnit(bulkEditor);
60
		else if (IS_DERIVED_UNIT_EDITOR.equals(property)){
61
            return bulkEditor.getEditorInput() instanceof OccurrenceEditorInput;
60 62
		}
63
        else if(IS_TAXON_EDITOR.equals(property)){
64
            return bulkEditor.getEditorInput() instanceof TaxonEditorInput;
65
        }
61 66
//		if (("isPublishFlagEditingEnabled").equals(property)) {
62 67
//			IEditorInput input = bulkEditor.getEditorInput();
63 68
//			if (input instanceof NameEditorInput) {
......
66 71
//		}
67 72
		return false;
68 73
	}
69
	
70
	private boolean isDerivedUnit(BulkEditor bulkEditor) {
71
		IEditorInput input = bulkEditor.getEditorInput();
72
		return (input instanceof OccurrenceEditorInput) ? true : false;
73
	}
74

  
75
	private boolean isGroup(BulkEditor bulkEditor) {
76
		IEditorInput input = bulkEditor.getEditorInput();
77
		return (input instanceof GroupEditorInput) ? true : false;
78
	}
79 74
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java
19 19
import org.eclipse.core.runtime.Status;
20 20
import org.eclipse.core.runtime.jobs.Job;
21 21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23 23
import org.eclipse.jface.wizard.WizardDialog;
24 24
import org.eclipse.swt.widgets.Display;
25 25
import org.eclipse.ui.handlers.HandlerUtil;
......
46 46

  
47 47
		ISelection selection = HandlerUtil.getCurrentSelection(event);
48 48

  
49
		if(selection instanceof StructuredSelection){
50
			final StructuredSelection structuredSelection = (StructuredSelection) selection;
49
		if(selection instanceof IStructuredSelection){
50
			final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
51 51

  
52 52
			if(structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof Classification){
53 53
				Classification classification = (Classification) structuredSelection.getFirstElement();

Also available in: Unified diff