Project

General

Profile

« Previous | Next » 

Revision cd614957

Added by Niels Hoffmann about 15 years ago

started to refactor action delegation

View differences:

eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/SynonymComposite.java
25 25
import eu.etaxonomy.cdm.model.taxon.Taxon;
26 26
import eu.etaxonomy.taxeditor.ITaxEditorConstants;
27 27
import eu.etaxonomy.taxeditor.TaxEditorPlugin;
28
import eu.etaxonomy.taxeditor.actions.cdm.SwapSynonymAndTaxonAction;
29
import eu.etaxonomy.taxeditor.actions.name.ChangeSynonymToConceptRelationAction;
30
import eu.etaxonomy.taxeditor.actions.name.ChangeSynonymToMisapplicationAction;
31
import eu.etaxonomy.taxeditor.actions.name.CreateSynonymInGroupAction;
32
import eu.etaxonomy.taxeditor.actions.name.CreateNewTaxonFromSynonymAction;
33
import eu.etaxonomy.taxeditor.actions.name.MakeBasionymAction;
34
import eu.etaxonomy.taxeditor.actions.name.Messages;
35
import eu.etaxonomy.taxeditor.actions.name.RemoveSynonymAction;
36
import eu.etaxonomy.taxeditor.actions.name.UnmakeBasionymAction;
28 37
import eu.etaxonomy.taxeditor.controller.EditorController;
29 38
import eu.etaxonomy.taxeditor.controller.GlobalController;
30 39
import eu.etaxonomy.taxeditor.editor.ContextMenu;
31 40
import eu.etaxonomy.taxeditor.model.CdmUtil;
32 41
import eu.etaxonomy.taxeditor.operations.name.ChangeHomotypicGroupOperation;
33
import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToConceptOperation;
34 42
import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToMisappliedNameOperation;
35
import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToTaxonOperation;
36
import eu.etaxonomy.taxeditor.operations.name.MakeSynonymAcceptedOperation;
37
import eu.etaxonomy.taxeditor.operations.name.MakeSynonymGroupBasionymOperation;
38
import eu.etaxonomy.taxeditor.operations.name.RemoveSynonymOperation;
39 43
import eu.etaxonomy.taxeditor.operations.name.UnmakeSynonymGroupBasionymOperation;
40 44
import eu.etaxonomy.taxeditor.propertysheet.name.TaxonBasePropertySource;
41 45

  
......
136 140

  
137 141
		ContextMenu contextMenu = createContextMenu();
138 142

  
139
		// Change composite to a misapplied name
140
		String text = "Change synonym to misapplied name"; //$NON-NLS-1$
141
		ImageDescriptor image = TaxEditorPlugin.getDefault()
142
				.getImageDescriptor(ITaxEditorConstants.MISAPPLIED_NAME_ICON);
143
		contextMenu.addAction(new Action(text, image){
144
						
145
			public void run() {
146
				IUndoableOperation operation = new ChangeSynonymToMisappliedNameOperation
147
						(this.getText(), undoContext, taxon, synonym);
148
				
149
				GlobalController.executeOperation(operation);
150
			}
151
		});
152
		
153
		// Change synonym to conccept relation
154
		text = "Change synonym to concept relation"; //$NON-NLS-1$
155
		image = TaxEditorPlugin.getDefault()
156
					.getImageDescriptor(ITaxEditorConstants.CONCEPT_ICON);
157

  
158
		contextMenu.addAction(new Action(text, image){
159
			
160
			public void run() {
161
				IUndoableOperation operation = new ChangeSynonymToConceptOperation
162
						(this.getText(), undoContext, taxon, synonym);
163
				
164
				GlobalController.executeOperation(operation);			
165
			}
166
		});
167
		
168
		// Remove composite
169
		text = "Remove synonym from taxon"; //$NON-NLS-1$
170
		image = TaxEditorPlugin.getDefault()
171
				.getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON);
172
		contextMenu.addAction(new Action(text, image){
173
			
174
			public void run() {
175
				IUndoableOperation operation = new RemoveSynonymOperation
176
						(this.getText(), undoContext, taxon, synonym);
177
				
178
				GlobalController.executeOperation(operation);				
179
			}
180
		});
181
		
182
		// Separator
183
		contextMenu.addSeparator();
184
				
185
		// Make the synonym the basionym of the homotypic group
186
		text = Messages.getString
187
				("AddBasionymCompositeAction.0", synonym.getName());  //$NON-NLS-1$
188
		image = TaxEditorPlugin.getDefault()
189
					.getImageDescriptor(ITaxEditorConstants.BASIONYM_ICON);
190
		Action makeBasionymAction = new Action(text, image){
191
			
192
			public void run() {
193
				IUndoableOperation operation = new MakeSynonymGroupBasionymOperation
194
						(this.getText(), undoContext, taxon, synonym);
195
				
196
				GlobalController.executeOperation(operation);		
197
			}
198
		};
199
		contextMenu.addAction(makeBasionymAction);	
200
	
201
		// Action to remove the composite as basionym of the homotypic group
202
		text = Messages.getString
203
				("RemoveBasionymCompositeAction.0", synonym.getName());  //$NON-NLS-1$
204
		image = TaxEditorPlugin.getDefault()
205
					.getImageDescriptor(ITaxEditorConstants.BASIONYM_ICON);
206
		Action unmakeBasionymAction = new Action(text, image){
207
			
208
			public void run() {
209
				IUndoableOperation operation = new UnmakeSynonymGroupBasionymOperation
210
						(this.getText(), undoContext, taxon, synonym);
211
				
212
				GlobalController.executeOperation(operation);				
213
			}
214
		};
215
		contextMenu.addAction(unmakeBasionymAction);
216
		
143
		contextMenu.addAction(new RemoveSynonymAction(taxon, synonym));
217 144
		if (CdmUtil.isNameGroupBasionym(synonym.getName())) {
218
			
219
			// Gray out action for "make synonym group basionym"
220
			makeBasionymAction.setEnabled(false);
145
			contextMenu.addAction(new UnmakeBasionymAction(taxon, synonym));
221 146
		} else {
222
			
223
			// Gray out action for "unmake synonym group basionym"
224
			unmakeBasionymAction.setEnabled(false);
147
			contextMenu.addAction(new MakeBasionymAction(taxon, synonym));	
225 148
		}
226
		
227
		// Separator
149
		 // Add synonym to this synonyms homotypical group
150
		// FIXME not working with the new menu action 
151
//		contextMenu.addAction(new CreateSynonymInGroupAction(synonym.getHomotypicGroup()));
228 152
		contextMenu.addSeparator();
229

  
153
		contextMenu.addAction(new ChangeSynonymToMisapplicationAction(taxon, synonym));
154
		contextMenu.addAction(new ChangeSynonymToConceptRelationAction(taxon, synonym));
155
		contextMenu.addSeparator();				
230 156
		// Change this synonym to the taxon's accepted name
231
		text = "Make synonym this taxon's accepted taxon"; //$NON-NLS-1$
232
		image = TaxEditorPlugin.getDefault()
233
					.getImageDescriptor(ITaxEditorConstants.SWAP_SYNONYM_AND_TAXON_ICON);
234
		Action swapAction = new Action(text, image){
235
			
236
			public void run() {
237
				IUndoableOperation operation = new MakeSynonymAcceptedOperation
238
						(this.getText(), undoContext, taxon, synonym);
239
				
240
				GlobalController.executeOperation(operation);				
241
			}
242
		};
157
		Action swapAction = new SwapSynonymAndTaxonAction(taxon, synonym);
243 158
		contextMenu.addAction(swapAction);
244 159
		// TODO fix operation
245 160
		swapAction.setEnabled(false);
246 161
		
247 162
		// Make a new taxon with this synonym as the accepted name
248
		text = "Use synonym name to make a new taxon"; //$NON-NLS-1$
249
		image = TaxEditorPlugin.getDefault()
250
					.getImageDescriptor(ITaxEditorConstants.SYNONYM_TO_TAXON_ICON);
251

  
252
		contextMenu.addAction(new Action(text, image){
253
			
254
			public void run() {
255
				IUndoableOperation operation = new ChangeSynonymToTaxonOperation
256
						(this.getText(), undoContext, taxon, synonym);
257
				
258
				GlobalController.executeOperation(operation);			
259
			}
260
		});
163
		contextMenu.addAction(new CreateNewTaxonFromSynonymAction(taxon, synonym));
261 164
	}
262 165

  
263 166

  

Also available in: Unified diff