Project

General

Profile

Revision 4aa3c52a

ID4aa3c52a4e3b60a495ddebf031bef3de40ffcb7d
Parent 22fc4952
Child 14a9bc04

Added by Katja Luther about 3 years ago

improve name editor update for navigator operations

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
323 323
            if(object instanceof TaxonNameEditorE4){
324 324
                TaxonNameEditorE4 taxonEditor = (TaxonNameEditorE4)object;
325 325
                TaxonNode node = taxonEditor.getEditorInput().getTaxonNode();
326
                if(node.treeIndex().startsWith(treeIndex)){
327
                    partService.hidePart(part, true);
326
                if (node.treeIndex()!= null){
327
	                if(node.treeIndex().startsWith(treeIndex)){
328
	                    partService.hidePart(part, true);
329
	                }
330
                }else{
331
                	logger.debug("The taxonnode of taxon " + node.getTaxon().getTitleCache() + " uuid: " + node.getUuid() + " has no treeindex");;
328 332
                }
329 333
            }
330 334
        }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/Messages.java
41 41
    public static String DeleteHandler_DELETE_ALL;
42 42
    public static String DeleteHandler_DELETE_CLASSIFICATION;
43 43
    public static String DeleteHandler_DELETE_NODE;
44
    public static String DeleteHandler_DELETE_NODES;
44 45
    public static String DeleteHandler_MOVE_TO_PARENT;
45 46
    public static String DeleteHandler_SKIP;
46 47
    public static String DeleteHandler_DELETE;
......
181 182
    public static String TaxonNavigatorLabels_SET_PUBLISH_FOR_CHILDREN;
182 183
	public static String TaxonNavigatorLabels_ACCEPTED_TAXA_NEED_TO_BE_FROM_SAME_CLASSIFICATION;
183 184
	
185
	
184 186

  
185 187

  
186 188
    static {
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/messages.properties
21 21
DeleteHandler_CONFIRM_MESSAGE=Do you want to delete the selected key(s)?
22 22
DeleteHandler_DELETE_ALL=Delete all children
23 23
DeleteHandler_DELETE_CLASSIFICATION=Do you really want to delete the classification?
24
DeleteHandler_DELETE_NODE=Do you really want to delete the selected node(s)?
24
DeleteHandler_DELETE_NODE=Do you really want to delete the selected node?
25
DeleteHandler_DELETE_NODES=Do you really want to delete the selected nodes?
25 26
DeleteHandler_MOVE_TO_PARENT=Move children to parent node
26 27
DeleteHandler_SKIP=Cancel
27 28
DeleteHandler_DELETE=Delete
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/messages_de.properties
21 21
DeleteHandler_CONFIRM_MESSAGE=Wollen wie Sie die ausgew?hlten Schl?ssen l?schen?
22 22
DeleteHandler_DELETE_ALL=Alle Kinder l?schen
23 23
DeleteHandler_DELETE_CLASSIFICATION=Wollen Sie die Klassifikation wirklich l?schen?
24
DeleteHandler_DELETE_NODE=Wollen Sie die ausgew?hlten Knoten wirklich l?schen?
24
DeleteHandler_DELETE_NODE=Wollen Sie den ausgew?hlten Knoten wirklich l?schen?
25
DeleteHandler_DELETE_NODES=Wollen Sie die ausgew?hlten Knoten wirklich l?schen?
25 26
DeleteHandler_MOVE_TO_PARENT=Verschiebe Kinder zu Elternknoten
26 27
DeleteHandler_SKIP=Abbrechen
27 28
DeleteHandler_DELETE=L?schen
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/DeleteHandlerE4.java
53 53
    protected static final String DELETE_ALL_CHILDREN = Messages.DeleteHandler_DELETE_ALL;
54 54
    protected static final String THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDNODES;
55 55
    protected static final String THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDREN;
56
    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S = Messages.DeleteHandler_DELETE_NODE;
56
    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S = Messages.DeleteHandler_DELETE_NODES;
57
    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE = Messages.DeleteHandler_DELETE_NODE;
57 58
    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION = Messages.DeleteHandler_DELETE_CLASSIFICATION;
58 59
    protected static final String CONFIRM_DELETION = Messages.DeleteHandler_CONFIRM_DELETE;
59 60
    protected static final String DELETE = Messages.DeleteHandler_DELETE;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingChangeAcceptedTaxonToSynonymHandlerE4.java
23 23
import org.eclipse.jface.viewers.TreeSelection;
24 24
import org.eclipse.swt.widgets.Shell;
25 25

  
26
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
26 27
import eu.etaxonomy.cdm.model.taxon.Classification;
27 28
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
28 29
import eu.etaxonomy.taxeditor.editor.EditorUtil;
......
69 70

  
70 71
        // check that selected object is a taxon node
71 72
        Iterator it = selection.iterator();
73
        Classification nextClassification;
74
        oldTaxonNodes = new HashSet<>();
72 75
        while(it.hasNext()){
73 76
        	Object obj = it.next();
74
	        if(obj instanceof TaxonNode && ((TaxonNode)obj).hasTaxon()) {
77
        	if(obj instanceof TaxonNode && ((TaxonNode)obj).hasTaxon()) {
75 78
	            oldTaxonNodes.add((TaxonNode)obj);
79
	            nextClassification = HibernateProxyHelper.deproxy(((TaxonNode)obj).getClassification(), Classification.class);
76 80
	            if (classification == null){
77
	            	classification = ((TaxonNode)obj).getClassification();
78
	            }else if (classification != ((TaxonNode)obj).getClassification()){
81
	            	classification = nextClassification;
82
	            }else if (!classification.equals(nextClassification)){
79 83
	            	return new Status(IStatus.ERROR,
80 84
	                        "unknown", //$NON-NLS-1$
81 85
	                        TaxonNavigatorLabels.ACCEPTED_TAXA_NEED_TO_BE_FROM_SAME_CLASSIFICATION);
......
131 135
                new RemotingChangeAcceptedTaxonToSynonymOperation(getTrigger(),
132 136
                        false,
133 137
                        nodeUuids,
134
                        newAcceptedTaxonNode.getUuid());
138
                        newAcceptedTaxonNode.getUuid(), partService, activePart, application);
135 139

  
136 140
        return rcattso;
137 141
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/RemotingChangeAcceptedTaxonToSynonymOperation.java
14 14

  
15 15
import org.eclipse.core.runtime.IAdaptable;
16 16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.e4.ui.model.application.MApplication;
18
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
19
import org.eclipse.e4.ui.workbench.modeling.EPartService;
20
import org.eclipse.swt.widgets.Display;
17 21

  
18 22
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
19 23
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
20 24
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
21 25
import eu.etaxonomy.cdm.api.service.UpdateResult;
26
import eu.etaxonomy.cdm.model.common.CdmBase;
27
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
28
import eu.etaxonomy.taxeditor.editor.EditorUtil;
29
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
22 30
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
23 31
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
24 32

  
......
42 50
    public RemotingChangeAcceptedTaxonToSynonymOperation(Object source,
43 51
            boolean async,
44 52
            Set<UUID> oldTaxonNodeUuids,
45
            UUID newAcceptedTaxonNodeUuid) {
46
        super(LABEL, Action.Update, source, async);
53
            UUID newAcceptedTaxonNodeUuid,
54
            EPartService partService,
55
            MPart activePart,
56
            MApplication application) {
57
        super(LABEL, Action.Update, source, async, partService, activePart, application);
47 58
        this.oldTaxonNodeUuids.addAll(oldTaxonNodeUuids);
48 59
        this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid;
60
        
61
    }
62
    
63
    /**
64
     * @param label
65
     */
66
    public RemotingChangeAcceptedTaxonToSynonymOperation(Object source,
67
            boolean async,
68
            UUID oldTaxonNodeUuid,
69
            UUID newAcceptedTaxonNodeUuid,
70
            EPartService partService,
71
    		MPart activePart,
72
    		MApplication application) {
73
        super(LABEL, Action.Update, source, async, partService, activePart, application);
74
        this.oldTaxonNodeUuids.add(oldTaxonNodeUuid);
75
        this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid;
49 76
    }
50 77
    
51 78
    /**
......
65 92
     */
66 93
    @Override
67 94
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
95
    	
68 96
    	if (this.oldTaxonNodeUuids.size() == 1){
69
    		return CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNodeUuids.iterator().next(),
97
    		updateResult = CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNodeUuids.iterator().next(),
70 98
                    newAcceptedTaxonNodeUuid,
71 99
                    null,
72 100
                    null,
73 101
                    null);
74 102
    	}else{
75
    		return CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeSynonymsOfAnotherTaxonNode(oldTaxonNodeUuids,
103
    		updateResult = CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeSynonymsOfAnotherTaxonNode(oldTaxonNodeUuids,
76 104
                    newAcceptedTaxonNodeUuid,
77 105
                    null,
78 106
                    null,
79 107
                    null);
80 108
    	}
109
    	updateNameEditor();
110
    	return updateResult;
81 111
        
82 112
    }
83

  
113
    
114
    private void updateNameEditor(){
115
    	if (partService != null){
116
	    Display.getDefault().asyncExec(new Runnable() {
117
		    public void run() {
118
		    	for (MPart part : partService.getParts()){
119
					Object object = part.getObject();
120
					if (object instanceof TaxonNameEditorE4){
121
						Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes();
122
						for (TaxonNode node: nodes){
123
							if (node.getTaxon().getUuid().equals(newAcceptedTaxonNodeUuid)){
124
								EditorUtil.updateEditor(node, partService, application);										   
125
							}
126
								
127
						}
128
					}
129
				} 
130
		    }
131
		});
132
    	}
133
    }
84 134
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java
32 32
	ForSubtreeConfiguratorBase config;
33 33
	
34 34
	UUID parentUuid;
35
	 EPartService partService;
36
	 MPart activePart;
37
	 MApplication application;
35
	
38 36
	 TaxonNode subtreeNode; 
39 37
	 ITaxonNodeService taxonNodeService;
40 38
	 
......
46 44
	            MApplication application,
47 45
	            ForSubtreeConfiguratorBase config,
48 46
	            String label) {
49
	        super(label, Action.Update, source, async);
47
	        super(label, Action.Update, source, async, partService, activePart, application);
50 48
	        parentUuid = taxonNodeUuid;
51 49
	        this.config = config;
52 50
	        this.updateResult = new UpdateResult();
53
	        this.partService= partService;
54
	        this.activePart = activePart;
55
	        this.application = application;
51
	       
56 52
	        try {
57 53
				taxonNodeService = CdmApplicationState.getService(ITaxonNodeService.class);
58 54
			} catch (CdmApplicationException e) {
......
61 57
			}
62 58
	        subtreeNode = taxonNodeService.load(config.getSubtreeUuid());
63 59
	    }
64
	 
65
	 public void updateNameEditors(){
66
		 for (CdmBase object: updateResult.getUpdatedObjects()){
67
				Taxon taxon = null;
68
				TaxonNode node = null;
69
				if (object instanceof Taxon){
70
					taxon = HibernateProxyHelper.deproxy(object, Taxon.class);
71
					node = taxon.getTaxonNode(subtreeNode.getClassification());
60
	  public void updateNameEditors(){
61
			 for (CdmBase object: updateResult.getUpdatedObjects()){
62
					Taxon taxon = null;
63
					TaxonNode node = null;
64
					if (object instanceof Taxon){
65
						taxon = HibernateProxyHelper.deproxy(object, Taxon.class);
66
						node = taxon.getTaxonNode(subtreeNode.getClassification());
67
						
68
					}else if (object instanceof Synonym){
69
						Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class);
70
						taxon = syn.getAcceptedTaxon();
71
						node = taxon.getTaxonNode(subtreeNode.getClassification());
72
					}
72 73
					
73
				}else if (object instanceof Synonym){
74
					Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class);
75
					taxon = syn.getAcceptedTaxon();
76
					node = taxon.getTaxonNode(subtreeNode.getClassification());
77
				}
78
				
79
				Display.getDefault().asyncExec(new Runnable() {
80
				    public void run() {
81
				    	for (MPart part : partService.getParts()){
82
							Object object = part.getObject();
83
							if (object instanceof TaxonNameEditorE4){
84
								Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes();
85
								for (TaxonNode node: nodes){
86
									if (node.treeIndex().startsWith(subtreeNode.treeIndex())){
87
										EditorUtil.updateEditor(node, partService, application);										   
74
					Display.getDefault().asyncExec(new Runnable() {
75
					    public void run() {
76
					    	for (MPart part : partService.getParts()){
77
								Object object = part.getObject();
78
								if (object instanceof TaxonNameEditorE4){
79
									Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes();
80
									for (TaxonNode node: nodes){
81
										if (node.treeIndex().startsWith(subtreeNode.treeIndex())){
82
											EditorUtil.updateEditor(node, partService, application);										   
83
										}
84
											
88 85
									}
89
										
90 86
								}
91
							}
92
						} 
93
				    }
94
				});
87
							} 
88
					    }
89
					});
90
			 }
95 91
		 }
96
	 }
92
	 
97 93
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/RemotingCdmUpdateOperation.java
17 17
import org.eclipse.core.runtime.IStatus;
18 18
import org.eclipse.core.runtime.MultiStatus;
19 19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.e4.ui.model.application.MApplication;
21
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
22
import org.eclipse.e4.ui.workbench.modeling.EPartService;
23
import org.eclipse.swt.widgets.Display;
20 24

  
21 25
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
22 26
import eu.etaxonomy.cdm.api.service.UpdateResult;
27
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
28
import eu.etaxonomy.cdm.model.common.CdmBase;
29
import eu.etaxonomy.cdm.model.taxon.Synonym;
30
import eu.etaxonomy.cdm.model.taxon.Taxon;
31
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
32

  
23 33

  
24 34
/**
25 35
 * @author cmathew
......
30 40

  
31 41
    protected UpdateResult updateResult;
32 42
    public static boolean throwExceptions = false;
43
    protected EPartService partService = null;
44
    protected MPart activePart = null;
45
    protected MApplication application = null;
33 46

  
34 47
    /**
35 48
     * @param label
36 49
     */
37
    public RemotingCdmUpdateOperation(String label, Action action, Object source, boolean async) {
50
    public RemotingCdmUpdateOperation(String label, Action action, Object source, boolean async, 
51
    		EPartService partService,
52
    		MPart activePart,
53
    		MApplication application) {
54
        super(label, action, source, async);
55
        this.partService= partService;
56
        this.activePart = activePart;
57
        this.application = application;
58
    }
59
    
60
    public RemotingCdmUpdateOperation(String label, Action action, Object source, boolean async){
38 61
        super(label, action, source, async);
62
       
39 63
    }
40 64

  
41 65
    /* (non-Javadoc)
......
119 143
        }
120 144
        return null;
121 145
    }
146
    
147
  
122 148
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)