Project

General

Profile

« Previous | Next » 

Revision f6a8dc56

Added by Patrick Plitzner over 10 years ago

merged model adaptions to cdmlib 3.2.4 from campanula branch

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
26 26
import org.eclipse.ui.PartInitException;
27 27
import org.eclipse.ui.handlers.HandlerUtil;
28 28

  
29
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
30 29
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditor;
30
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
31 31
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
32 32
import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
33 33
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorDataChangeBehaviour.java
17 17
import eu.etaxonomy.cdm.model.taxon.Synonym;
18 18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19 19
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent;
20
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
21 20
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
21
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
22 22
import eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour;
23 23
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
24 24

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
25 25
import eu.etaxonomy.cdm.api.service.ITaxonService;
26 26
import eu.etaxonomy.cdm.model.common.CdmBase;
27 27
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
28
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
28
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
29 29
import eu.etaxonomy.cdm.model.taxon.Synonym;
30 30
import eu.etaxonomy.cdm.model.taxon.Taxon;
31 31
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
......
37 37
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
38 38
import eu.etaxonomy.taxeditor.store.CdmStore;
39 39

  
40

  
40 41
/**
41 42
 * <p>TaxonEditorInput class.</p>
42 43
 *
......
47 48
public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPersistableElement {
48 49

  
49 50
	private ConversationHolder conversation;
50
	
51

  
51 52
	private TaxonNode taxonNode;
52 53

  
53 54
	private TaxonEditorInputDataChangeBehaviour dataChangeBehavior;
54
	
55

  
55 56
	private TaxonBase initiallySelectedTaxonBase;
56
	
57

  
57 58
	private TaxonEditorInput(TaxonNode taxonNode, ConversationHolder conversation){
58 59
		this.conversation = conversation;
59 60
		this.taxonNode = taxonNode;
60 61
	}
61
	
62 62

  
63
	
63

  
64

  
64 65
	/**
65 66
	 * <p>NewInstance</p>
66 67
	 *
......
76 77
			throw e;
77 78
		}
78 79
	}
79
	
80

  
80 81
    /**
81
     * 
82
     *
82 83
     * @param taxonNodeUuid
83 84
     * @param conversation
84 85
     * @return
85 86
     */
86 87
    private static TaxonEditorInput NewInstance(UUID taxonNodeUuid, ConversationHolder conversation){
87
    	
88
    	
88

  
89

  
89 90
    	TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeUuid, null);
90
		
91

  
91 92
		if(taxonNode == null){
92 93
			EditorUtil.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not type TaxonBase.");
93 94
			return null;
94
		}	
95
		
95
		}
96

  
96 97
    	return new TaxonEditorInput(taxonNode, conversation);
97 98
    }
98
    
99

  
99 100
    /**
100 101
     * <p>NewInstanceFromTaxonBase</p>
101 102
     *
......
104 105
     */
105 106
    public static TaxonEditorInput NewInstanceFromTaxonBase(UUID taxonBaseUuid){
106 107
    	ConversationHolder conversation = CdmStore.createConversation();
107
    	
108

  
108 109
    	TaxonEditorInput input = null;
109
    	
110

  
110 111
    	TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid);
111 112
    	if(taxonBase.isOrphaned()) {
112 113
    		EditorUtil.warningDialog("Orphaned Taxon", TaxonEditorInput.class, "This is an orphaned taxon i.e. a taxon that is not connected to a classification and not having any taxonomic relationships. Editing of orphaned taxon is currently not supported.");
113 114
    	}
114 115
    	else if(taxonBase.isInstanceOf(Taxon.class)){
115 116
    		Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
116
    		
117

  
117 118
    		if (taxon.isMisapplication()){
118 119
    			// TODO get accepted taxon
119 120
    			EditorUtil.info("trying to open Mispplied Name ");
120
    			
121

  
121 122
    			Set<Taxon> acceptedTaxa = new HashSet<Taxon>();
122 123
    			Set<TaxonRelationship> relations = taxon.getRelationsFromThisTaxon();
123 124
    			for(TaxonRelationship relation : relations){
......
126 127
    				}
127 128
    			}
128 129
    			input =  getInputForMultipleTaxa(conversation, acceptedTaxa);
129
    			
130

  
130 131
    		}else{
131 132
    			input = getInputForMultipleNodes(conversation, taxon.getTaxonNodes());
132 133
    		}
133 134
    	}else if(taxonBase instanceof Synonym){
134 135
    		Synonym synonym = (Synonym) taxonBase;
135
    		
136

  
136 137
    		Set<Taxon> taxa = synonym.getAcceptedTaxa();
137 138
    		input = getInputForMultipleTaxa(conversation, taxa);
138 139
    	}
139
    	
140

  
140 141
    	input.setInitiallySelectedTaxonBase(taxonBase);
141
    	
142

  
142 143
    	return input;
143 144
    }
144
    
145

  
145 146
	private static TaxonEditorInput getInputForMultipleNodes(ConversationHolder conversation, Set<TaxonNode> taxonNodes){
146 147
    	if(taxonNodes.size() == 1){
147 148
    		TaxonNode taxonNode = taxonNodes.iterator().next();
......
149 150
    	}else if(taxonNodes.size() > 1){
150 151
			TaxonNode taxonNode = ChooseFromMultipleTaxonNodesDialog.choose(taxonNodes);
151 152
			if(taxonNode != null){
152
				return NewInstance(taxonNode.getUuid(), conversation);			
153
				return NewInstance(taxonNode.getUuid(), conversation);
153 154
			}
154 155
		}else if(taxonNodes.size() == 0){
155 156
			// this is an undesired state
......
157 158
		}
158 159
    	return null;
159 160
    }
160
    
161

  
161 162
    private static TaxonEditorInput getInputForMultipleTaxa(ConversationHolder conversation, Set<Taxon> taxa){
162 163
    	if(taxa.size() == 1){
163 164
    		Taxon taxon = taxa.iterator().next();
......
176 177
		}
177 178
    	return null;
178 179
    }
179
    
180

  
180 181
    /**
181 182
     * <p>NewEmptyInstance</p>
182 183
     *
......
185 186
     */
186 187
    public static TaxonEditorInput NewEmptyInstance(UUID parentNodeUuid){
187 188
    	ConversationHolder conversation = CdmStore.createConversation();
188
		
189

  
189 190
		TaxonNameBase<?, ?> name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
190
		ITreeNode parentNode = CdmStore.getService(IClassificationService.class).getTreeNodeByUuid(parentNodeUuid);
191
		
191
		ITaxonTreeNode parentNode = CdmStore.getService(IClassificationService.class).getTreeNodeByUuid(parentNodeUuid);
192

  
192 193
		Taxon newTaxon = Taxon.NewInstance(name, parentNode.getReference());
193 194
		TaxonNode newTaxonNode = parentNode.addChildTaxon(newTaxon, parentNode.getReference(), parentNode.getMicroReference());
194
		
195

  
195 196
		// add the new taxon to the editors persistence context
196 197
		UUID newTaxonNodeUuid = CdmStore.getService(ITaxonNodeService.class).save(newTaxonNode);
197
		
198

  
198 199
		return new TaxonEditorInput(newTaxonNode, conversation);
199 200
    }
200
	
201

  
201 202
	/* (non-Javadoc)
202 203
	 * @see org.eclipse.ui.IEditorInput#exists()
203 204
	 */
......
206 207
	 *
207 208
	 * @return a boolean.
208 209
	 */
209
	public boolean exists() {
210
	@Override
211
    public boolean exists() {
210 212
		return taxonNode != null;
211 213
	}
212 214

  
......
218 220
	 *
219 221
	 * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object.
220 222
	 */
221
	public ImageDescriptor getImageDescriptor() {
223
	@Override
224
    public ImageDescriptor getImageDescriptor() {
222 225
		return null;
223 226
	}
224 227

  
......
230 233
	 *
231 234
	 * @return a {@link java.lang.String} object.
232 235
	 */
233
	public String getName() {
236
	@Override
237
    public String getName() {
234 238
		if(getTaxon() == null){
235 239
			return null;
236 240
		}
......
239 243
			return "New taxon";
240 244
		} else {
241 245
			return name.getTitleCache();
242
		}	
246
		}
243 247
	}
244 248

  
245 249
	/* (non-Javadoc)
......
250 254
	 *
251 255
	 * @return a {@link org.eclipse.ui.IPersistableElement} object.
252 256
	 */
253
	public IPersistableElement getPersistable() {
257
	@Override
258
    public IPersistableElement getPersistable() {
254 259
//		if(CdmStore.isActive()){
255 260
//			TaxonNode test = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid());
256 261
//			boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
......
269 274
	 *
270 275
	 * @return a {@link java.lang.String} object.
271 276
	 */
272
	public String getToolTipText() {
277
	@Override
278
    public String getToolTipText() {
273 279
		return getName();
274 280
	}
275 281

  
......
277 283
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
278 284
	 */
279 285
	/** {@inheritDoc} */
280
	public Object getAdapter(Class adapter) {
286
	@Override
287
    public Object getAdapter(Class adapter) {
281 288

  
282 289
		if (adapter == Taxon.class) {
283 290
			return taxonNode.getTaxon();
284 291
		}
285
		
292

  
286 293
		if (adapter == TaxonNode.class) {
287 294
			return taxonNode;
288 295
		}
289
		
296

  
290 297
		return null;
291 298
	}
292
	
299

  
293 300
	/**
294 301
	 * {@inheritDoc}
295 302
	 *
296 303
	 * Overrides equals to ensure that a taxon can only be edited by
297 304
	 * one editor at a time.
298 305
	 */
299
	public boolean equals(Object obj) {
300
		if (TaxonEditorInput.class.equals(obj.getClass()) 
306
	@Override
307
    public boolean equals(Object obj) {
308
		if (TaxonEditorInput.class.equals(obj.getClass())
301 309
				&& getTaxon() != null
302 310
				&& getTaxon().equals(((TaxonEditorInput) obj).getTaxon())){
303 311
			if(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase() != null){
......
316 324
	public Taxon getTaxon(){
317 325
		return taxonNode.getTaxon();
318 326
	}
319
	
327

  
320 328
	/**
321 329
	 * <p>Getter for the field <code>taxonNode</code>.</p>
322 330
	 *
......
325 333
	public TaxonNode getTaxonNode() {
326 334
		return taxonNode;
327 335
	}
328
	
336

  
329 337
	/*
330 338
	 * (non-Javadoc)
331 339
	 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
......
335 343
	 *
336 344
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
337 345
	 */
338
	public ConversationHolder getConversationHolder() {
346
	@Override
347
    public ConversationHolder getConversationHolder() {
339 348
		return conversation;
340 349
	}
341 350

  
......
344 353
	 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
345 354
	 */
346 355
	/** {@inheritDoc} */
347
	public void update(CdmDataChangeMap events) {
356
	@Override
357
    public void update(CdmDataChangeMap events) {
348 358
		if(dataChangeBehavior == null){
349 359
			dataChangeBehavior = new TaxonEditorInputDataChangeBehaviour(this);
350 360
		}
351
		
361

  
352 362
		DataChangeBridge.handleDataChange(events, dataChangeBehavior);
353 363
	}
354 364

  
......
360 370
	 *
361 371
	 * @return a {@link java.lang.String} object.
362 372
	 */
363
	public String getFactoryId() {
373
	@Override
374
    public String getFactoryId() {
364 375
		return TaxonEditorInputFactory.getFactoryId();
365 376
	}
366 377

  
......
368 379
	 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
369 380
	 */
370 381
	/** {@inheritDoc} */
371
	public void saveState(IMemento memento) {
382
	@Override
383
    public void saveState(IMemento memento) {
372 384
		TaxonEditorInputFactory.saveState(memento, this);
373 385
	}
374 386

  
375
    
387

  
376 388
    /**
377 389
     * <p>Setter for the field <code>initiallySelectedTaxonBase</code>.</p>
378 390
     *
......
390 402
	public TaxonBase getInitiallySelectedTaxonBase() {
391 403
		return initiallySelectedTaxonBase;
392 404
	}
393
	
405

  
394 406
	@Override
395 407
	public String toString() {
396 408
		return String.format("%s[%s]", this.getClass().getSimpleName(), getTaxon());
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/UseObjectManager.java
25 25
import eu.etaxonomy.cdm.model.description.FeatureNode;
26 26
import eu.etaxonomy.cdm.model.description.FeatureTree;
27 27
import eu.etaxonomy.cdm.model.description.State;
28
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
29 28
import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
30 29
import eu.etaxonomy.taxeditor.store.CdmStore;
31 30
import eu.etaxonomy.taxeditor.store.StoreUtil;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java
23 23
import org.eclipse.jface.viewers.ISelection;
24 24
import org.eclipse.jface.viewers.ISelectionProvider;
25 25
import org.eclipse.jface.viewers.StructuredSelection;
26
import org.eclipse.swt.SWT;
27 26
import org.eclipse.swt.dnd.DND;
28 27
import org.eclipse.swt.dnd.DropTarget;
29 28
import org.eclipse.swt.dnd.Transfer;
30 29
import org.eclipse.swt.graphics.Color;
31 30
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Display;
33 31
import org.eclipse.swt.widgets.Menu;
34 32
import org.eclipse.ui.IEditorInput;
35 33
import org.eclipse.ui.IEditorSite;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SwapSynonymAndAcceptedHandler.java
18 18
import org.eclipse.core.commands.common.NotDefinedException;
19 19
import org.eclipse.swt.widgets.Display;
20 20
import org.eclipse.swt.widgets.Shell;
21
import org.eclipse.ui.PartInitException;
22
import org.eclipse.ui.forms.editor.FormEditor;
23 21
import org.eclipse.ui.handlers.HandlerUtil;
24 22

  
25 23
import eu.etaxonomy.cdm.model.common.CdmBase;
26 24
import eu.etaxonomy.cdm.model.taxon.Synonym;
27 25
import eu.etaxonomy.cdm.model.taxon.Taxon;
28
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
29 26
import eu.etaxonomy.taxeditor.editor.EditorUtil;
30 27
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
31 28
import eu.etaxonomy.taxeditor.editor.name.operation.SwapSynonymAndAcceptedOperation;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
18 18
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
19 19
import eu.etaxonomy.cdm.api.service.ITaxonService;
20 20
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
21
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
21
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
22 22
import eu.etaxonomy.cdm.model.taxon.Synonym;
23 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24 24
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
......
36 36
 * @version 1.0
37 37
 */
38 38
public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPostOperation {
39
	
39

  
40 40
	private Taxon newTaxon;
41 41
	private Synonym synonym;
42
	private ITreeNode parentNode;
42
	private ITaxonTreeNode parentNode;
43 43

  
44 44
	private TaxonNode newNode;
45 45

  
46 46
	private Synonym[] synonymsInHomotypicalGroup;
47
	
47

  
48 48
	/**
49 49
	 * <p>Constructor for ChangeSynonymToAcceptedTaxonOperation.</p>
50 50
	 *
51 51
	 * @param label a {@link java.lang.String} object.
52 52
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
53 53
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
54
	 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
54
	 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
55 55
	 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
56 56
	 * @param synonymsInHomotypicalGroup an array of {@link eu.etaxonomy.cdm.model.taxon.Synonym} objects.
57 57
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
58 58
	 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
59 59
	 */
60 60
	public ChangeSynonymToAcceptedTaxonOperation(String label, IUndoContext undoContext,
61
			Taxon taxon, ITreeNode parentNode, Synonym synonym, Synonym[] synonymsInHomotypicalGroup, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
61
			Taxon taxon, ITaxonTreeNode parentNode, Synonym synonym, Synonym[] synonymsInHomotypicalGroup, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
62 62
		super(label, undoContext, postOperationEnabled, conversationEnabled);
63 63

  
64 64
		this.taxon = taxon;
65 65
		this.parentNode = parentNode;
66
		this.synonym = synonym; 
66
		this.synonym = synonym;
67 67
		this.synonymsInHomotypicalGroup = synonymsInHomotypicalGroup;
68 68
	}
69
	
69

  
70 70
	/* (non-Javadoc)
71 71
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
72 72
	 */
......
74 74
	@Override
75 75
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
76 76
			throws ExecutionException {
77
		
77

  
78 78
		try {
79 79
			newTaxon = CdmStore.getService(ITaxonService.class).changeSynonymToAcceptedTaxon(synonym, taxon, true, true, null, null);
80 80
		} catch (HomotypicalGroupChangeException e) {
......
82 82
			return postExecute(null);
83 83
		}
84 84
		monitor.worked(20);
85
		
85

  
86 86
		synonym.setSec(null);
87 87
		newNode = parentNode.addChildTaxon(newTaxon, null, null);
88
		
88

  
89 89
		if(synonymsInHomotypicalGroup != null){
90 90
			Taxon taxon = newNode.getTaxon();
91 91
			for (Synonym synonym : synonymsInHomotypicalGroup){
92 92
				taxon.addHomotypicSynonym(synonym, null, null);
93 93
			}
94 94
		}
95
		
95

  
96 96
		monitor.worked(40);
97 97

  
98 98
		return postExecute(newNode);
......
115 115
	@Override
116 116
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
117 117
			throws ExecutionException {
118
		
118

  
119 119
		// TODO implement - biggest problem is that any window open for new taxon must be closed first
120 120
		StoreUtil.warn(this.getClass(), "Not yet implemented");
121
		
121

  
122 122
		return postExecute(taxon);
123 123
	}
124 124

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DynamicFeatureMenu.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
 */
......
31 31
import eu.etaxonomy.cdm.model.description.FeatureTree;
32 32
import eu.etaxonomy.cdm.model.description.TaxonDescription;
33 33
import eu.etaxonomy.taxeditor.editor.EditorUtil;
34
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
35 34
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
36 35
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
37 36
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
......
42 41
 * <p>
43 42
 * DynamicFeatureMenu class.
44 43
 * </p>
45
 * 
44
 *
46 45
 * @author n.hoffmann
47 46
 * @created 17.04.2009
48 47
 * @version 1.0
......
56 55

  
57 56
	/*
58 57
	 * (non-Javadoc)
59
	 * 
58
	 *
60 59
	 * @see
61 60
	 * org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
62 61
	 */
......
65 64
	protected IContributionItem[] getContributionItems() {
66 65

  
67 66
		return new IContributionItem[] { new ContributionItem() {
68
			public void fill(Menu menu, int index) {
67
			@Override
68
            public void fill(Menu menu, int index) {
69 69

  
70 70
				ISelection selection = selectionService
71 71
						.getSelection(DescriptiveViewPart.ID);
......
90 90
						createMenuItem(menu, featureNode.getFeature());
91 91

  
92 92
						// add possible children to the menu
93
						for (FeatureNode childNode : featureNode.getChildren()) {
93
						for (FeatureNode childNode : featureNode.getChildNodes()) {
94 94
							createMenuItem(menu, childNode.getFeature());
95 95
						}
96 96
					} else if (selectedElement instanceof DescriptionElementBase) {
......
111 111
		menuItem.setText(deproxiedFeature.getLabel());
112 112
		menuItem.addSelectionListener(new SelectionListener() {
113 113

  
114
			public void widgetDefaultSelected(SelectionEvent e) {
114
			@Override
115
            public void widgetDefaultSelected(SelectionEvent e) {
115 116
			}
116 117

  
117
			public void widgetSelected(SelectionEvent ev) {
118
			@Override
119
            public void widgetSelected(SelectionEvent ev) {
118 120
				Event event = new Event();
119 121
				event.data = deproxiedFeature;
120 122
				try {
......
130 132

  
131 133
	/**
132 134
	 * Retrieves the feature tree associated with the given description
133
	 * 
135
	 *
134 136
	 * TODO as of now this is always the same thing because feature trees may
135 137
	 * not be associated to descriptions yet.
136
	 * 
138
	 *
137 139
	 * @param description
138 140
	 * @return
139 141
	 */
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/ClassificationLabelProvider.java
18 18
import org.eclipse.swt.graphics.Image;
19 19
import org.eclipse.ui.navigator.IDescriptionProvider;
20 20

  
21
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
22
import eu.etaxonomy.cdm.model.common.LanguageString;
23 21
import eu.etaxonomy.cdm.model.taxon.Classification;
24 22

  
25 23
/**
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/SynonymLabelProvider.java
12 12

  
13 13
import org.apache.log4j.Logger;
14 14
import org.eclipse.jface.viewers.ColumnLabelProvider;
15
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
15 16
import org.eclipse.jface.viewers.ILabelProvider;
16 17
import org.eclipse.jface.viewers.StyledString;
17
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
18 18
import org.eclipse.swt.graphics.Image;
19 19
import org.eclipse.ui.navigator.IDescriptionProvider;
20 20

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

  
22 22
import eu.etaxonomy.cdm.model.common.CdmBase;
23 23
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
24
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
24
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
25 25
import eu.etaxonomy.cdm.model.taxon.Taxon;
26 26
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent;
27 27
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
......
38 38
 * @created 01.04.2009
39 39
 * @version 1.0
40 40
 */
41
public class TaxonNavigatorDataChangeBehavior extends AbstractDataChangeBehaviour implements 
41
public class TaxonNavigatorDataChangeBehavior extends AbstractDataChangeBehaviour implements
42 42
		IDataChangeBehavior {
43 43

  
44 44
	private TaxonNavigator source;
45 45

  
46 46
	private Set<CdmBase> staleObjects;
47
	
47

  
48 48
	/**
49 49
	 * <p>Constructor for TaxonNavigatorDataChangeBehavior.</p>
50 50
	 *
......
53 53
	public TaxonNavigatorDataChangeBehavior(TaxonNavigator taxonNavigator) {
54 54
		source = taxonNavigator;
55 55
	}
56
	
56

  
57 57
	/* (non-Javadoc)
58 58
	 * @see eu.etaxonomy.taxeditor.store.model.IDataChangeBehavior#isRelevant(java.lang.Object, eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
59 59
	 */
......
64 64
	 * @return a boolean.
65 65
	 */
66 66
	public boolean isRelevant(CdmDataChangeMap events) {
67
		
67

  
68 68
		// TODO react only on insert/update/delete of taxon and synonym objects
69 69
		// and on update of name objects
70 70
		boolean relevant = false;
71 71
		staleObjects = new HashSet<CdmBase>();
72
		
72

  
73 73
		for(CdmDataChangeEvent event : events.getAllEvents()){
74 74
			EventType eventType = event.getEventType();
75 75
			CdmBase eventEntity = event.getEntity();
76
			
76

  
77 77
			// all tree node changes are relevant
78
			if((eventType == EventType.INSERT || eventType == EventType.DELETE || eventType == EventType.UPDATE) 
79
					&& event.getEntity() instanceof ITreeNode){
78
			if((eventType == EventType.INSERT || eventType == EventType.DELETE || eventType == EventType.UPDATE)
79
					&& event.getEntity() instanceof ITaxonTreeNode){
80 80
				return true;
81 81
			}
82
			
82

  
83 83
			// name updates of the accepted taxon of open editors are relevant
84 84
			if(eventType == EventType.UPDATE){
85 85
				TaxonNameBase name = null;
......
90 90
				}else{
91 91
					continue;
92 92
				}
93
				
93

  
94 94
				Set<IEditorPart> openEditors = NavigationUtil.getOpenEditors();
95 95
				for(IEditorPart editor : openEditors){
96
					
96

  
97 97
					if(name.equals(((TaxonEditorInput) editor.getEditorInput()).getTaxon().getName())){
98 98
						return true;
99 99
					}
100 100
				}
101 101
			}
102
			
103
			
102

  
103

  
104 104
//			if(eventType == EventType.UPDATE){
105 105
//				relevant = true;
106 106
//				CdmBase entity = event.getEntity();
......
111 111
//				}
112 112
//			}
113 113
		}
114
		
114

  
115 115
		return false;
116
		
116

  
117 117
		// @deprecated
118 118
		// react on everything except load
119 119
//		if(events.sizeByEventType(EventType.INSERT) > 0){
......
131 131
	 * @see eu.etaxonomy.taxeditor.store.model.IDataChangeBehavior#reactOnDataChange(java.lang.Object, eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
132 132
	 */
133 133
	/** {@inheritDoc} */
134
	public void reactOnDataChange(CdmDataChangeMap events) {
134
	@Override
135
    public void reactOnDataChange(CdmDataChangeMap events) {
135 136
		if(isRelevant(events)){
136 137

  
137 138
			final Display display = Display.getCurrent();
138 139
			Job job = new Job("Updating Taxon Navigator") {
139
				
140

  
140 141
				@Override
141 142
				protected IStatus run(IProgressMonitor monitor) {
142 143
					monitor.beginTask("Updating Taxon Navigator", 3);
143 144
					monitor.worked(1);
144
					
145

  
145 146
					// clear the session completely
146 147
					monitor.subTask("Clearing Taxon Navigators session");
147 148
					display.asyncExec(new Runnable() {
148
						 public void run() {
149
						 @Override
150
                        public void run() {
149 151
							 source.getConversationHolder().clear();
150 152
						 }
151
					});					
152
					// FIXME completely clearing the session is a brute force approach. 
153
					});
154
					// FIXME completely clearing the session is a brute force approach.
153 155
					// It would be much more elegant to clear only those elements that have been changed.
154 156
					// I could not get that to work but we should consider workin on this because we might
155 157
					// run into serious performance issues, especially when it comes to large trees
......
157 159
					// at least, we moved this to a job so it can run in a background thred
158 160
					// seems to improve the situation but not sure if final solution
159 161
					monitor.worked(1);
160
					
162

  
161 163
					monitor.subTask("Refreshing viewer");
162
					
164

  
163 165
					display.asyncExec(new Runnable() {
164
					    public void run() {
166
					    @Override
167
                        public void run() {
165 168
					    	source.refresh();
166 169
					    }
167 170
					});
168
					
169
					
170
					
171

  
172

  
173

  
171 174
					monitor.worked(1);
172 175
					monitor.done();
173 176
					return Status.OK_STATUS;
174 177
				}
175 178
			};
176
			
179

  
177 180
			job.setPriority(Job.SHORT);
178 181
			job.schedule();
179
			
182

  
180 183
		}
181 184
	}
182 185
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeContentProvider.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
*/
......
15 15
import org.eclipse.jface.viewers.Viewer;
16 16

  
17 17
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
18
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
18
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
19 19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 20

  
21 21
/**
......
30 30
			.getLogger(TaxonNodeContentProvider.class);
31 31

  
32 32
	private static final Object[] NO_CHILDREN = new Object[0];
33
	
33

  
34 34
	/** {@inheritDoc} */
35
	public Object[] getChildren(Object parentElement) {
36
		Object[] children = null;		
37
		
38
		if(parentElement instanceof ITreeNode){
39
			ITreeNode treeNode = (ITreeNode) HibernateProxyHelper.deproxy(parentElement);
35
	@Override
36
    public Object[] getChildren(Object parentElement) {
37
		Object[] children = null;
38

  
39
		if(parentElement instanceof ITaxonTreeNode){
40
		    ITaxonTreeNode treeNode = (ITaxonTreeNode) HibernateProxyHelper.deproxy(parentElement);
40 41
			children = treeNode.getChildNodes().toArray();
41 42
		}
42
		
43

  
43 44
		return children != null ? children : NO_CHILDREN;
44 45
	}
45 46

  
46 47
	/** {@inheritDoc} */
47
	public Object getParent(Object element) {
48
	@Override
49
    public Object getParent(Object element) {
48 50
		if(element instanceof TaxonNode){
49 51
			return ((TaxonNode) element).getParent();
50
		}		
52
		}
51 53
		return null;
52 54
	}
53 55

  
54 56
	/** {@inheritDoc} */
55
	public boolean hasChildren(Object element) {
57
	@Override
58
    public boolean hasChildren(Object element) {
56 59
		if(element instanceof TaxonNode){
57 60
			return ((TaxonNode) element).getCountChildren() > 0;
58 61
		}
......
60 63
	}
61 64

  
62 65
	/** {@inheritDoc} */
63
	public Object[] getElements(Object inputElement) {
66
	@Override
67
    public Object[] getElements(Object inputElement) {
64 68
		return this.getChildren(inputElement);
65 69
	}
66 70

  
67 71
	/**
68 72
	 * <p>dispose</p>
69 73
	 */
70
	public void dispose() {
74
	@Override
75
    public void dispose() {
71 76
	}
72 77

  
73 78
	/** {@inheritDoc} */
74
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
79
	@Override
80
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
75 81
	}
76 82
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.navigation.navigator;
12 12

  
13
import org.apache.log4j.Logger;
14 13
import org.eclipse.jface.viewers.ColumnLabelProvider;
14
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
15 15
import org.eclipse.jface.viewers.ILabelProvider;
16 16
import org.eclipse.jface.viewers.StyledString;
17
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
18 17
import org.eclipse.jface.viewers.StyledString.Styler;
19
import org.eclipse.swt.SWT;
20 18
import org.eclipse.swt.graphics.Image;
21 19
import org.eclipse.swt.graphics.TextStyle;
22 20
import org.eclipse.ui.navigator.IDescriptionProvider;
......
27 25
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
28 26
import eu.etaxonomy.cdm.model.taxon.Taxon;
29 27
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
30
import eu.etaxonomy.cdm.persistence.hibernate.permission.Operation;
31 28
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
32 29
import eu.etaxonomy.taxeditor.preference.Resources;
33 30
import eu.etaxonomy.taxeditor.security.RequiredPermissions;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapterAssistant.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
*/
......
28 28
import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
29 29

  
30 30
import eu.etaxonomy.cdm.model.common.CdmBase;
31
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
31
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
32 32
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
33 33
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
34 34
import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation;
......
48 48

  
49 49
	/** Constant <code>ID="eu.etaxonomy.taxeditor.navigation.navig"{trunked}</code> */
50 50
	public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator.dropassistant"; //$NON-NLS-1$
51
	
51

  
52 52
	/* (non-Javadoc)
53 53
	 * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
54 54
	 */
......
56 56
	@Override
57 57
	public IStatus handleDrop(CommonDropAdapter dropAdapter,
58 58
			DropTargetEvent dropTargetEvent, Object target) {
59
			
60
		if (target instanceof ITreeNode) {
59

  
60
		if (target instanceof ITaxonTreeNode) {
61 61
			Set<TaxonNode> taxonNodes = getSelectedTaxa();
62
			ITreeNode targetTreeNode = (ITreeNode) target;
63
			if(taxonNodes != null)
64
				return moveTaxon(taxonNodes, targetTreeNode);
62
			ITaxonTreeNode targetTreeNode = (ITaxonTreeNode) target;
63
			if(taxonNodes != null) {
64
                return moveTaxon(taxonNodes, targetTreeNode);
65
            }
65 66
		}
66
							
67

  
67 68
		return Status.CANCEL_STATUS;
68 69
	}
69
	
70

  
70 71
	private Set<TaxonNode> getSelectedTaxa(){
71
		HashSet<TaxonNode> taxonNodes = new HashSet<TaxonNode>();		
72
		
72
		HashSet<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
73

  
73 74
		ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
74 75
		if (selection instanceof TreeSelection) {
75
		
76

  
76 77
			Iterator selectionIterator = ((TreeSelection) selection).iterator();
77
				
78

  
78 79
			while (selectionIterator.hasNext()){
79 80
				Object object = selectionIterator.next();
80 81
				if(object instanceof TaxonNode){
......
92 93
	/** {@inheritDoc} */
93 94
	@Override
94 95
	public IStatus validateDrop(Object target, int operation,
95
			TransferData transferType) {	
96
		if (target instanceof ITreeNode) {
96
			TransferData transferType) {
97
		if (target instanceof ITaxonTreeNode) {
97 98
			// do not allow to drop onto itself
98 99
			for(TaxonNode taxonNode : getSelectedTaxa()){
99 100
				if (taxonNode.equals(target)) {
......
101 102
				}
102 103
			}
103 104
			return Status.OK_STATUS;
104
		}		
105
		}
105 106
		return Status.CANCEL_STATUS;
106 107
	}
107
	
108

  
108 109

  
109 110
	/**
110 111
	 * @param childTaxonNode
111 112
	 * @param parentTaxon
112 113
	 * @return
113 114
	 */
114
	private IStatus moveTaxon(Set<TaxonNode> taxonNodes, ITreeNode targetITreeNode) {
115
		
115
	private IStatus moveTaxon(Set<TaxonNode> taxonNodes, ITaxonTreeNode targetITaxonTreeNode) {
116

  
116 117
		TaxonNavigator taxonNavigator;
117 118
		taxonNavigator = (TaxonNavigator) NavigationUtil.showView(TaxonNavigator.ID);
118
		
119
		if(targetITreeNode instanceof TaxonNode){
120
		
121
			TaxonNode targetTaxonNode = (TaxonNode) targetITreeNode;
122
			
119

  
120
		if(targetITaxonTreeNode instanceof TaxonNode){
121

  
122
			TaxonNode targetTaxonNode = (TaxonNode) targetITaxonTreeNode;
123

  
123 124
//			for(TaxonNode taxonNode : taxonNodes){
124 125
//				if (taxonNode.equals(targetTaxonNode)) {
125 126
//					return Status.CANCEL_STATUS;
126 127
//				}
127 128
//			}
128
			
129

  
129 130
			// Make sure parent taxon does not have unsaved changes
130 131
			if (NavigationUtil.isDirty(targetTaxonNode)){
131 132
				MessageDialog.openWarning(NavigationUtil.getShell(), "Unsaved Parent Taxon", "There are unsaved " +
132 133
				"changes in the parent taxon. Pleas save first.");
133 134
				return Status.CANCEL_STATUS;
134 135
			}
135
			
136
			
136

  
137

  
137 138
			// Make sure parentTaxon is not the drop target
138 139
//			if (!childTaxonNode.isTopmostNode() && childTaxonNode.getParent().equals(targetTaxonNode)){
139 140
//				return Status.CANCEL_STATUS;
140 141
//			}
141
			
142

  
142 143
			// Make sure taxon is not being dropped onto itself
143 144
//			if (childTaxonNode.equals(targetTaxonNode)) {
144 145
//				return Status.CANCEL_STATUS;
145 146
//			}
146
			
147
			
148 147

  
149
		}	
150
		
148

  
149

  
150
		}
151

  
151 152
		IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
152 153
		if (workspaceUndoContext == null) {
153 154
			logger.error("Workspace undo context is null. DND operation cancelled");
......
155 156
		}
156 157

  
157 158
		AbstractPostOperation operation = new MoveTaxonOperation
158
				("Move Taxon", workspaceUndoContext, taxonNodes, targetITreeNode, this, taxonNavigator);
159
		NavigationUtil.executeOperation(operation);	
160
		
161
		logger.info("Moved taxa to new parent " + targetITreeNode);
159
				("Move Taxon", workspaceUndoContext, taxonNodes, targetITaxonTreeNode, this, taxonNavigator);
160
		NavigationUtil.executeOperation(operation);
161

  
162
		logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
162 163
		return Status.OK_STATUS;
163 164
	}
164 165

  
......
166 167
	 * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
167 168
	 */
168 169
	/** {@inheritDoc} */
169
	public boolean postOperation(CdmBase objectAffectedByOperation) {
170
	@Override
171
    public boolean postOperation(CdmBase objectAffectedByOperation) {
170 172
		return true;
171 173
	}
172 174

  
......
175 177
	 *
176 178
	 * @return a boolean.
177 179
	 */
178
	public boolean onComplete() {
180
	@Override
181
    public boolean onComplete() {
179 182
		// TODO Auto-generated method stub
180 183
		return false;
181 184
	}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CopyHandler.java
9 9
*/
10 10
package eu.etaxonomy.taxeditor.navigation.navigator.handler;
11 11

  
12
import java.util.Iterator;
13

  
14 12
import org.eclipse.core.commands.AbstractHandler;
15 13
import org.eclipse.core.commands.ExecutionEvent;
16 14
import org.eclipse.core.commands.ExecutionException;
......
20 18
import org.eclipse.jface.viewers.IStructuredSelection;
21 19
import org.eclipse.ui.handlers.HandlerUtil;
22 20

  
23
import eu.etaxonomy.cdm.model.common.TermBase;
24
import eu.etaxonomy.cdm.model.taxon.Taxon;
25
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
26 21
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
27
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
28 22
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
29 23
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
30 24
import eu.etaxonomy.taxeditor.navigation.navigator.operation.CopyOperation;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.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
*/
......
29 29
import org.eclipse.ui.PartInitException;
30 30
import org.eclipse.ui.handlers.HandlerUtil;
31 31

  
32
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
32
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
33 33
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
34 34
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
35 35
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
......
50 50
	private TaxonNavigator taxonNavigator;
51 51

  
52 52
	/** {@inheritDoc} */
53
	public Object execute(ExecutionEvent event) throws ExecutionException {
54
		
53
	@Override
54
    public Object execute(ExecutionEvent event) throws ExecutionException {
55

  
55 56
		activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
56
		
57

  
57 58
		taxonNavigator = NavigationUtil.showNavigator();
58
				
59

  
59 60
		TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
60
		
61

  
61 62
		String plural = selection.size() > 1 ? "s" : "";
62 63
		// Prompt user for confirmation
63 64
		if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Are you sure you want to delete the selected node" + plural +"?")){
64 65
			return null;
65 66
		}
66
		
67

  
67 68
		Iterator selectionIterator = selection.iterator();
68
		Set<ITreeNode> treeNodes = new HashSet<ITreeNode>();
69
		
69
		Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
70

  
70 71
		while (selectionIterator.hasNext()){
71 72
			Object object = selectionIterator.next();
72
			if(object instanceof ITreeNode)
73
				treeNodes.add((ITreeNode) object);
73
			if(object instanceof ITaxonTreeNode) {
74
                treeNodes.add((ITaxonTreeNode) object);
75
            }
74 76
		}
75
			
77

  
76 78
		AbstractPostOperation operation = null;
77 79
		try {
78 80
			operation = new DeleteOperation(
79
					event.getCommand().getName(), NavigationUtil.getUndoContext(), 
81
					event.getCommand().getName(), NavigationUtil.getUndoContext(),
80 82
					treeNodes, taxonNavigator, taxonNavigator);
81
			
83

  
82 84
			IStatus status = NavigationUtil.executeOperation(operation);
83
			
84
			
85

  
86

  
85 87
			// FIXME is there a better place for this code?
86 88
			if (status == Status.OK_STATUS){
87
				for (ITreeNode treeNode : treeNodes){
89
				for (ITaxonTreeNode treeNode : treeNodes){
88 90
					if(treeNode instanceof TaxonNode) {
89 91
						closeObsoleteEditor((TaxonNode) treeNode);
90 92
					}
91 93
				}
92 94
			}
93
		
95

  
94 96
		} catch (NotDefinedException e) {
95 97
			NavigationUtil.warn(getClass(), "Command name not set");
96 98
		}
97 99
		return null;
98 100
	}
99
	
101

  
100 102
	private void closeObsoleteEditor(TaxonNode taxonNode){
101 103
		for (IEditorReference ref : activePage.getEditorReferences()) {
102 104
			try {
103
				IEditorInput input = ref.getEditorInput(); 
105
				IEditorInput input = ref.getEditorInput();
104 106
				if (input instanceof TaxonEditorInput) {
105 107
					TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
106 108
					if (taxonNode.equals(node)) {
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/CopyOperation.java
11 11

  
12 12
import org.eclipse.core.commands.ExecutionException;
13 13
import org.eclipse.core.commands.operations.IUndoContext;
14

  
15
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
16
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
17
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
18

  
19 14
import org.eclipse.core.runtime.IAdaptable;
20 15
import org.eclipse.core.runtime.IProgressMonitor;
21 16
import org.eclipse.core.runtime.IStatus;
......
23 18
import org.eclipse.swt.dnd.TextTransfer;
24 19
import org.eclipse.swt.dnd.Transfer;
25 20

  
21
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
22
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
23
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
24

  
26 25

  
27 26
/**
28 27
 * @author l.morris
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.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
*/
......
21 21
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
22 22
import eu.etaxonomy.cdm.api.service.IClassificationService;
23 23
import eu.etaxonomy.cdm.model.taxon.Classification;
24
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
24
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
25 25
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
26 26
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
27 27
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
......
36 36
 * @version 1.0
37 37
 */
38 38
public class DeleteOperation extends AbstractPersistentPostOperation{
39
	
40
	private Set<ITreeNode> treeNodes;
41 39

  
42
	
40
	private Set<ITaxonTreeNode> treeNodes;
41

  
42

  
43 43
	/**
44 44
	 * <p>Constructor for DeleteTreeNodeOperation.</p>
45 45
	 *
......
50 50
	 * @param treeNodes a {@link java.util.Set} object.
51 51
	 */
52 52
	public DeleteOperation(String label, IUndoContext undoContext,
53
			Set<ITreeNode> treeNodes,
53
			Set<ITaxonTreeNode> treeNodes,
54 54
			IPostOperationEnabled postOperationEnabled,
55 55
			IConversationEnabled conversationEnabled) {
56 56
		super(label, undoContext, postOperationEnabled, conversationEnabled);
57 57
		this.treeNodes = treeNodes;
58 58
	}
59 59

  
60
	
60

  
61 61
	/* (non-Javadoc)
62 62
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
63 63
	 */
......
68 68

  
69 69
		bind();
70 70
		monitor.worked(20);
71
        for (ITreeNode treeNode : treeNodes){
71
        for (ITaxonTreeNode treeNode : treeNodes){
72 72
			if(treeNode instanceof TaxonNode){
73 73
				((TaxonNode) treeNode).delete();
74 74
			}else if(treeNode instanceof Classification){
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/MoveTaxonOperation.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
21 21
import org.eclipse.core.runtime.Status;
22 22

  
23 23
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
24
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
24
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
25 25
import eu.etaxonomy.cdm.model.taxon.IllegalAncestryException;
26 26
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
27 27
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
......
36 36
 * @version 1.0
37 37
 */
38 38
public class MoveTaxonOperation extends AbstractPersistentPostOperation {
39
	
39

  
40 40
	/**
41 41
	 * A reference to the new taxonomical parent.
42 42
	 */
43
	private ITreeNode newParentTreeNode;
43
	private ITaxonTreeNode newParentTreeNode;
44 44
	/**
45 45
	 * A reference to the former taxonomical parents
46 46
	 */
47
	private Map<TaxonNode, ITreeNode> oldParentTreeNodes;
48
	
47
	private Map<TaxonNode, ITaxonTreeNode> oldParentTreeNodes;
48

  
49 49
	private Set<TaxonNode> taxonNodes;
50 50

  
51 51
	/**
......
54 54
	 * @param label a {@link java.lang.String} object.
55 55
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
56 56
	 * @param taxonNodes a {@link java.util.Set} object.
57
	 * @param newParentTreeNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
57
	 * @param newParentTreeNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
58 58
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
59 59
	 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
60 60
	 */
61 61
	public MoveTaxonOperation(String label, IUndoContext undoContext,
62
			Set<TaxonNode> taxonNodes, ITreeNode newParentTreeNode, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
62
			Set<TaxonNode> taxonNodes, ITaxonTreeNode newParentTreeNode, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
63 63
		super(label, undoContext, postOperationEnabled, conversationEnabled);
64 64

  
65 65
		this.taxonNodes = taxonNodes;
66
		
66

  
67 67
		this.newParentTreeNode = newParentTreeNode;
68
		
69
		// Save old parent ITreeNodes for undo
70
		oldParentTreeNodes = new HashMap<TaxonNode, ITreeNode>();
68

  
69
		// Save old parent ITaxonTreeNodes for undo
70
		oldParentTreeNodes = new HashMap<TaxonNode, ITaxonTreeNode>();
71 71
		for(TaxonNode taxonNode : taxonNodes){
72 72
			this.oldParentTreeNodes.put(taxonNode, taxonNode.getParent());
73 73
		}
74 74
	}
75
	
75

  
76 76
	/* (non-Javadoc)
77 77
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78 78
	 */
......
82 82
			throws ExecutionException {
83 83
		bind();
84 84
		monitor.worked(20);
85
		
85

  
86 86
		try {
87 87
			for (TaxonNode taxonNode : taxonNodes){
88
				TaxonNode newTaxonNode = newParentTreeNode.addChildNode(taxonNode, 
88
				TaxonNode newTaxonNode = newParentTreeNode.addChildNode(taxonNode,
89 89
						newParentTreeNode.getReference(), newParentTreeNode.getMicroReference());
90 90
				taxonNodes.add(newTaxonNode);
91 91
				monitor.worked(2);
......
94 94
			StoreUtil.warningDialog("Illegal ancestry", this, e.getMessage());
95 95
		}
96 96
		monitor.worked(40);
97
		
97

  
98 98
		return postExecute(null);
99 99
	}
100 100

  
......
116 116
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
117 117
			throws ExecutionException {
118 118
		StoreUtil.warn(this.getClass(), "Not implemented yet.");
119
		
120
		// iterate over oldParentTreeNodes, delete each TaxonNode from its actual parent and add to its former parent		
121
		
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff