Project

General

Profile

« Previous | Next » 

Revision eb7bdd58

Added by Patrick Plitzner over 8 years ago

Remove "edit" commands which are replaced by generic cdmViewer framework

View differences:

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="%command.label"
88
               style="push">
89
            <visibleWhen>
90
               <reference
91
                     definitionId="isTaxonBulkEditorInput">
92
               </reference>
93
            </visibleWhen>
94
         </command>
85
         <dynamic
86
               class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu"
87
               id="eu.etaxonomy.taxeditor.bulkeditor.cdmViewerContextMenu">
88
         </dynamic>
95 89
         <separator
96 90
               name="taxeditor-bulkeditor.separator1"
97 91
               visible="true">
......
225 219
               </reference>
226 220
            </visibleWhen>
227 221
         </command>
228
         <dynamic
229
               class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu"
230
               id="eu.etaxonomy.taxeditor.bulkeditor.cdmViewerContextMenu">
231
         </dynamic>
232 222
      </menuContribution>
233 223
   </extension>
234 224
   <extension
eu.etaxonomy.taxeditor.navigation/plugin.xml
174 174
               name="taxeditor-navigation.separator1"
175 175
               visible="true">
176 176
         </separator>
177
         <command
178
               commandId="eu.etaxonomy.taxeditor.navigation.command.update.editSelection"
179
               label="%command.label.5"
180
               style="push">       
181
            <visibleWhen
182
                  checkEnabled="true">
183
               <or>
184
                  <reference
185
                        definitionId="isTaxonNode">
186
                  </reference>
187
                  <reference
188
                        definitionId="isTaxonomicTree">
189
                  </reference>
190
               </or>
191
            </visibleWhen>
192
         </command>
193 177
         <dynamic
194 178
               class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu"
195 179
               id="eu.etaxonomy.taxeditor.navigation.cdmViewerContextMenu">
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java
35 35
import eu.etaxonomy.cdm.model.taxon.Taxon;
36 36
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
37 37
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
38
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
39 38
import eu.etaxonomy.taxeditor.editor.EditorUtil;
40 39
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
41 40
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
......
108 107
		}
109 108
	}
110 109

  
111
	public static void openEditor(Object selectedObject){
112
		if (selectedObject instanceof UuidAndTitleCache){
113
			Class type = ((UuidAndTitleCache) selectedObject).getType();
114
			if(type == Taxon.class || type == Synonym.class){
115
				try {
116
					EditorUtil.openTaxonBase(((UuidAndTitleCache) selectedObject).getUuid());
117
				} catch (PartInitException e) {
118
					MessagingUtils.error(NavigationUtil.class, "Error opening the editor", e);
119
				}
120
			}
121
		}else if(selectedObject instanceof ICdmBase){
122
			openEditor((ICdmBase) selectedObject);
123
		}else{
124
			MessagingUtils.error(NavigationUtil.class, new IllegalArgumentException("Selected object is not supported: " + selectedObject));
125
		}
126
	}
127

  
128 110
	/**
129 111
	 * <p>openEmpty</p>
130 112
	 *
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java
1
package eu.etaxonomy.taxeditor.navigation.navigator.handler;
2
// $Id$
3
/**
4
* Copyright (C) 2007 EDIT
5
* European Distributed Institute of Taxonomy
6
* http://www.e-taxonomy.eu
7
*
8
* The contents of this file are subject to the Mozilla Public License Version 1.1
9
* See LICENSE.TXT at the top of this package for the full license terms.
10
*/
11

  
12

  
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.IHandler;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.jobs.Job;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.wizard.WizardDialog;
24
import org.eclipse.swt.widgets.Display;
25
import org.eclipse.ui.handlers.HandlerUtil;
26

  
27
import eu.etaxonomy.cdm.model.taxon.Classification;
28
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
29
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
30

  
31
/**
32
 * <p>EditHandler class.</p>
33
 *
34
 * @author n.hoffmann
35
 * @created May 12, 2010
36
 * @version 1.0
37
 */
38
public class EditHandler extends AbstractHandler implements IHandler{
39

  
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
42
	 */
43
	/** {@inheritDoc} */
44
	@Override
45
    public Object execute(ExecutionEvent event) throws ExecutionException {
46

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

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

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

  
55
				NewClassificationWizard classificationWizard = new NewClassificationWizard();
56
				classificationWizard.init(null, null);
57
				classificationWizard.setEntity(classification);
58
				WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), classificationWizard);
59
				dialog.open();
60

  
61
			}
62
			else{
63

  
64
				Job job = new Job("Opening editor") {
65

  
66
					@Override
67
					protected IStatus run(IProgressMonitor monitor) {
68
						for(final Object selectedObject : structuredSelection.toArray()){
69

  
70
							Display.getDefault().asyncExec(new Runnable(){
71

  
72
								@Override
73
                                public void run() {
74
									NavigationUtil.openEditor(selectedObject);
75
								}
76

  
77
							});
78
						}
79
						return Status.OK_STATUS;
80
					}
81
				};
82

  
83
				job.schedule();
84
			}
85
		}
86

  
87
		return null;
88
	}
89
}

Also available in: Unified diff