Project

General

Profile

« Previous | Next » 

Revision 22fc4952

Added by Katja Luther over 6 years ago

add possibility to mark and delete more than one taxonNode

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingDeleteTaxonNodeHandlerE4.java
78 78
        }
79 79

  
80 80
        config = new TaxonDeletionConfigurator();
81

  
82
        if (treeNodes.size() == 1 ){
83
        	ITaxonTreeNode treeNode = treeNodes.iterator().next();
84
            ITaxonTreeNode taxonNode = treeNode;
85
            if (taxonNode instanceof TaxonNode && !((TaxonNode)taxonNode).hasTaxon()){
86
                taxonNode = CdmApplicationState.getCurrentAppConfig().getClassificationService().load(((TaxonNode)taxonNode).getClassification().getUuid());
81
        Iterator it = treeNodes.iterator();
82
        boolean containsNodeWithChildren = false;
83
        boolean containsClassification = false;
84
        boolean containsTaxonNodes = false;
85
        treeNodes = new HashSet<ITaxonTreeNode>();
86
        while (it.hasNext()){
87
        	ITaxonTreeNode treeNode = (ITaxonTreeNode) it.next();
88
           
89
            if (treeNode instanceof TaxonNode && !((TaxonNode)treeNode).hasTaxon()){
90
                treeNode = CdmApplicationState.getCurrentAppConfig().getClassificationService().load(((TaxonNode)treeNode).getClassification().getUuid());
87 91
            }else{
88
                taxonNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(taxonNode.getUuid());
92
                treeNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(treeNode.getUuid());
89 93
            }
90
            treeNodes = new HashSet<ITaxonTreeNode>();
91
            treeNodes.add(taxonNode);
92
            if (taxonNode == null){
94
            
95
            treeNodes.add(treeNode);
96
            if (treeNode == null){
93 97
            	MessagingUtils.informationDialog(Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED, Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE);
94 98
            	return Status.CANCEL_STATUS;
95 99

  
96 100
            }
101
            if (treeNode instanceof Classification){
102
            	containsClassification = true;
103
            	if (((Classification)treeNode).getRootNode() != null &&treeNode.hasChildNodes()) {
104
            		containsNodeWithChildren = true;
105
            	}
106
            }else if (treeNode instanceof TaxonNode){
107
            	containsTaxonNodes = true;
108
            	if (treeNode.hasChildNodes()){
109
            		containsNodeWithChildren = true;
110
            	}
111
            }
112
            
113
            
114
        }
97 115
            TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
98
			if (taxonNode instanceof Classification) {
116
			if (containsClassification && !containsTaxonNodes) {
99 117
				String message;
100
				if (((Classification)taxonNode).getRootNode() != null &&taxonNode.hasChildNodes()) {
118
				if (containsClassification && containsNodeWithChildren) {
101 119
					message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+DeleteHandlerE4.THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO;
102 120
				} else {
103 121
					message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION;
......
109 127
				}
110 128
			}
111 129
            else {
112

  
113
                if (taxonNode.hasChildNodes()){
114
                    DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
130
            	String confirmMessage= treeNodes.size() == 1?DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE:DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S;
131
                if (containsNodeWithChildren){
132
                	
133
                	DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
115 134
                            config,
116 135
                            shell,
117 136
                            DeleteHandlerE4.CONFIRM_DELETION,
118 137
                            null,
119
                            DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+DeleteHandlerE4.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
138
                            confirmMessage+DeleteHandlerE4.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
120 139
                            MessageDialog.WARNING, new String[] { DeleteHandlerE4.DELETE_ALL_CHILDREN,
121 140
                                    DeleteHandlerE4.MOVE_CHILDREN_TO_PARENT_NODE, DeleteHandlerE4.SKIP }, 0);
122 141
                    int result = dialog.open();
......
139 158
                            shell,
140 159
                            DeleteHandlerE4.CONFIRM_DELETION,
141 160
                            null,
142
                            DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S,
161
                            confirmMessage,
143 162
                            MessageDialog.WARNING,  new String[] { DeleteHandlerE4.DELETE, DeleteHandlerE4.SKIP }, 0);
144 163
                    int result = dialog.open();
145 164
                    if (result == 0){
......
155 174
//                    config.setTaxonNodeConfig(configNodes);
156 175
                }
157 176
            }
158
        }
177
//        }
159 178
        return Status.OK_STATUS;
160 179
    }
161 180

  

Also available in: Unified diff