Revision abada6da
Added by Cherian Mathew about 11 years ago
- Renamed EditHandler to EditPolytomousKeyNodesHandler
- Added handler to create new Polytomous Key
.gitattributes | ||
---|---|---|
823 | 823 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPart.java -text |
824 | 824 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPartDataChangeBehavior.java -text |
825 | 825 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/DeleteHandler.java -text |
826 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/EditHandler.java -text |
|
826 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/EditPolytomousKeyNodesHandler.java -text |
|
827 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/NewPolytomousKeyHandler.java -text |
|
827 | 828 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/operation/DeleteOperation.java -text |
828 | 829 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/ClassificationContentProvider.java -text |
829 | 830 |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/ClassificationLabelProvider.java -text |
eu.etaxonomy.taxeditor.navigation/plugin.xml | ||
---|---|---|
215 | 215 |
<menuContribution |
216 | 216 |
locationURI="popup:eu.etaxonomy.taxeditor.navigation.key.polytomous.polytomousKeyViewPart"> |
217 | 217 |
<command |
218 |
commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.edit" |
|
218 |
commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.newKey" |
|
219 |
label="New" |
|
220 |
style="push"> |
|
221 |
</command> |
|
222 |
<command |
|
223 |
commandId="eu.etaxonomy.taxeditor.navigation.key.polytomous.editNodes" |
|
219 | 224 |
label="Edit" |
220 | 225 |
style="push"> |
221 | 226 |
</command> |
222 | 227 |
<separator |
223 |
name="eu.etaxonomy.eu.polytomousKeyView.separator" |
|
228 |
name="eu.etaxonomy.eu.polytomousKeyView.separator2"
|
|
224 | 229 |
visible="true"> |
225 | 230 |
</separator> |
226 | 231 |
<command |
... | ... | |
269 | 274 |
<extension |
270 | 275 |
point="org.eclipse.ui.commands"> |
271 | 276 |
<command |
272 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.EditHandler" |
|
273 |
id="eu.etaxonomy.taxeditor.navigation.key.polytomous.edit" |
|
274 |
name="Edit Polytomous Key"> |
|
277 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.NewPolytomousKeyHandler" |
|
278 |
id="eu.etaxonomy.taxeditor.navigation.key.polytomous.newKey" |
|
279 |
name="New Polytomous Key"> |
|
280 |
</command> |
|
281 |
<command |
|
282 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.EditPolytomousKeyNodesHandler" |
|
283 |
id="eu.etaxonomy.taxeditor.navigation.key.polytomous.editNodes" |
|
284 |
name="Edit Polytomous Key Nodes"> |
|
275 | 285 |
</command> |
276 | 286 |
</extension> |
277 | 287 |
<extension |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPart.java | ||
---|---|---|
12 | 12 |
import org.eclipse.jface.action.MenuManager; |
13 | 13 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
14 | 14 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
15 |
import org.eclipse.jface.viewers.ISelection; |
|
15 | 16 |
import org.eclipse.jface.viewers.ListViewer; |
17 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
|
16 | 18 |
import org.eclipse.jface.viewers.Viewer; |
17 | 19 |
import org.eclipse.jface.viewers.ViewerFilter; |
18 | 20 |
import org.eclipse.swt.SWT; |
... | ... | |
23 | 25 |
import org.eclipse.swt.widgets.Composite; |
24 | 26 |
import org.eclipse.swt.widgets.Control; |
25 | 27 |
import org.eclipse.swt.widgets.Display; |
28 |
import org.eclipse.swt.widgets.Event; |
|
26 | 29 |
import org.eclipse.swt.widgets.Menu; |
27 | 30 |
import org.eclipse.swt.widgets.Text; |
28 | 31 |
import org.eclipse.ui.IMemento; |
... | ... | |
80 | 83 |
|
81 | 84 |
public static final String ID = "eu.etaxonomy.taxeditor.navigation.key.polytomous.polytomousKeyViewPart"; |
82 | 85 |
|
83 |
public static final String OPEN_COMMAND_ID = "eu.etaxonomy.taxeditor.navigation.key.polytomous.edit"; |
|
86 |
public static final String OPEN_COMMAND_ID = "eu.etaxonomy.taxeditor.navigation.key.polytomous.editNodes";
|
|
84 | 87 |
|
85 | 88 |
private class ContextListener extends ContextListenerAdapter{ |
86 | 89 |
/* (non-Javadoc) |
... | ... | |
139 | 142 |
viewer.addDoubleClickListener(new IDoubleClickListener() { |
140 | 143 |
|
141 | 144 |
@Override |
142 |
public void doubleClick(DoubleClickEvent event) { |
|
143 |
|
|
144 |
ICommandService commandService = (ICommandService)getSite().getService(ICommandService.class); |
|
145 |
|
|
146 |
Command command = commandService.getCommand(OPEN_COMMAND_ID); |
|
147 |
if(command.isEnabled()) { |
|
148 |
IHandlerService handlerService = (IHandlerService)getSite().getService(IHandlerService.class); |
|
149 |
try { |
|
150 |
handlerService.executeCommand(OPEN_COMMAND_ID, null); |
|
151 |
} catch (NotDefinedException e) { |
|
152 |
throw new RuntimeException("Could not find open command: " + OPEN_COMMAND_ID); |
|
153 |
} catch (Exception e) { |
|
154 |
NavigationUtil.error(getClass(), "An exception occured while trying to open a selection", e); |
|
155 |
} |
|
156 |
} |
|
145 |
public void doubleClick(DoubleClickEvent event) { |
|
146 |
openSelectedKeyNodes(); |
|
157 | 147 |
} |
158 | 148 |
}); |
159 | 149 |
|
150 |
|
|
160 | 151 |
getSite().setSelectionProvider(viewer); |
161 | 152 |
|
162 | 153 |
createMenu(); |
... | ... | |
166 | 157 |
} |
167 | 158 |
} |
168 | 159 |
|
160 |
public void openSelectedKeyNodes() { |
|
161 |
ICommandService commandService = (ICommandService)getSite().getService(ICommandService.class); |
|
162 |
|
|
163 |
Command command = commandService.getCommand(OPEN_COMMAND_ID); |
|
164 |
if(command.isEnabled()) { |
|
165 |
IHandlerService handlerService = (IHandlerService)getSite().getService(IHandlerService.class); |
|
166 |
try { |
|
167 |
handlerService.executeCommand(OPEN_COMMAND_ID, null); |
|
168 |
} catch (NotDefinedException e) { |
|
169 |
throw new RuntimeException("Could not find open command: " + OPEN_COMMAND_ID); |
|
170 |
} catch (Exception e) { |
|
171 |
NavigationUtil.error(getClass(), "An exception occured while trying to open a selection", e); |
|
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
public void setViewerSelection(ISelection selection, boolean reveal) { |
|
177 |
getSite().setSelectionProvider(viewer); |
|
178 |
viewer.setSelection(selection,reveal); |
|
179 |
viewer.getList().notifyListeners(SWT.Selection,new Event()); |
|
180 |
} |
|
181 |
|
|
169 | 182 |
private void createMenu(){ |
170 | 183 |
MenuManager menuManager = new MenuManager(); |
171 | 184 |
menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/EditHandler.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler; |
|
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.runtime.IProgressMonitor; |
|
17 |
import org.eclipse.core.runtime.IStatus; |
|
18 |
import org.eclipse.core.runtime.Status; |
|
19 |
import org.eclipse.core.runtime.jobs.Job; |
|
20 |
import org.eclipse.jface.viewers.ISelection; |
|
21 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
22 |
import org.eclipse.swt.widgets.Display; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
25 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
|
26 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart; |
|
27 |
|
|
28 |
/** |
|
29 |
* @author n.hoffmann |
|
30 |
* @created Dec 3, 2010 |
|
31 |
* @version 1.0 |
|
32 |
*/ |
|
33 |
public class EditHandler extends AbstractHandler { |
|
34 |
|
|
35 |
/* (non-Javadoc) |
|
36 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
37 |
*/ |
|
38 |
@Override |
|
39 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
40 |
PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false); |
|
41 |
|
|
42 |
ISelection selection = view.getSite().getSelectionProvider().getSelection(); |
|
43 |
if(selection instanceof StructuredSelection){ |
|
44 |
final StructuredSelection structuredSelection = (StructuredSelection) selection; |
|
45 |
|
|
46 |
Job job = new Job("Opening Polytomous Keys"){ |
|
47 |
|
|
48 |
@Override |
|
49 |
protected IStatus run(IProgressMonitor monitor) { |
|
50 |
monitor.beginTask("Opening Polytomous Keys", structuredSelection.size()); |
|
51 |
|
|
52 |
for(final Object selectedObject : structuredSelection.toArray()){ |
|
53 |
if(selectedObject instanceof PolytomousKey){ |
|
54 |
|
|
55 |
Display.getDefault().asyncExec(new Runnable(){ |
|
56 |
|
|
57 |
@Override |
|
58 |
public void run() { |
|
59 |
NavigationUtil.openEditor((PolytomousKey) selectedObject); |
|
60 |
} |
|
61 |
|
|
62 |
}); |
|
63 |
monitor.worked(1); |
|
64 |
} |
|
65 |
} |
|
66 |
monitor.done(); |
|
67 |
return Status.OK_STATUS; |
|
68 |
} |
|
69 |
|
|
70 |
}; |
|
71 |
|
|
72 |
job.setPriority(Job.SHORT); |
|
73 |
job.schedule(); |
|
74 |
|
|
75 |
} |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/EditPolytomousKeyNodesHandler.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler; |
|
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.runtime.IProgressMonitor; |
|
17 |
import org.eclipse.core.runtime.IStatus; |
|
18 |
import org.eclipse.core.runtime.Status; |
|
19 |
import org.eclipse.core.runtime.jobs.Job; |
|
20 |
import org.eclipse.jface.viewers.ISelection; |
|
21 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
22 |
import org.eclipse.swt.widgets.Display; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
25 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
|
26 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart; |
|
27 |
|
|
28 |
/** |
|
29 |
* @author n.hoffmann |
|
30 |
* @created Dec 3, 2010 |
|
31 |
* @version 1.0 |
|
32 |
*/ |
|
33 |
public class EditPolytomousKeyNodesHandler extends AbstractHandler { |
|
34 |
|
|
35 |
/* (non-Javadoc) |
|
36 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
37 |
*/ |
|
38 |
@Override |
|
39 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
40 |
PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false); |
|
41 |
|
|
42 |
ISelection selection = view.getSite().getSelectionProvider().getSelection(); |
|
43 |
if(selection instanceof StructuredSelection){ |
|
44 |
|
|
45 |
final StructuredSelection structuredSelection = (StructuredSelection) selection; |
|
46 |
|
|
47 |
Job job = new Job("Opening Polytomous Keys"){ |
|
48 |
|
|
49 |
@Override |
|
50 |
protected IStatus run(IProgressMonitor monitor) { |
|
51 |
monitor.beginTask("Opening Polytomous Keys", structuredSelection.size()); |
|
52 |
|
|
53 |
for(final Object selectedObject : structuredSelection.toArray()){ |
|
54 |
if(selectedObject instanceof PolytomousKey){ |
|
55 |
|
|
56 |
Display.getDefault().asyncExec(new Runnable(){ |
|
57 |
|
|
58 |
@Override |
|
59 |
public void run() { |
|
60 |
NavigationUtil.openEditor((PolytomousKey) selectedObject); |
|
61 |
} |
|
62 |
|
|
63 |
}); |
|
64 |
monitor.worked(1); |
|
65 |
} |
|
66 |
} |
|
67 |
monitor.done(); |
|
68 |
return Status.OK_STATUS; |
|
69 |
} |
|
70 |
|
|
71 |
}; |
|
72 |
|
|
73 |
job.setPriority(Job.SHORT); |
|
74 |
job.schedule(); |
|
75 |
|
|
76 |
} |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/NewPolytomousKeyHandler.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler; |
|
12 |
|
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import org.eclipse.core.commands.AbstractHandler; |
|
16 |
import org.eclipse.core.commands.ExecutionEvent; |
|
17 |
import org.eclipse.core.commands.ExecutionException; |
|
18 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
19 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
20 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
21 |
import org.eclipse.ui.commands.ICommandService; |
|
22 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
23 |
import org.eclipse.ui.handlers.IHandlerService; |
|
24 |
|
|
25 |
import eu.etaxonomy.cdm.strategy.generate.PolytomousKeyGenerator; |
|
26 |
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService; |
|
27 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
28 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
|
29 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart; |
|
30 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.DeleteOperation; |
|
31 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
32 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
33 |
|
|
34 |
import org.eclipse.core.commands.AbstractHandler; |
|
35 |
import org.eclipse.core.commands.Command; |
|
36 |
import org.eclipse.core.commands.ExecutionEvent; |
|
37 |
import org.eclipse.core.commands.ExecutionException; |
|
38 |
import org.eclipse.core.commands.IHandler; |
|
39 |
import org.eclipse.core.runtime.IStatus; |
|
40 |
import org.eclipse.core.runtime.Status; |
|
41 |
import org.eclipse.jface.wizard.WizardDialog; |
|
42 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
43 |
|
|
44 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
|
45 |
import eu.etaxonomy.taxeditor.newWizard.NewPolytomousKeyWizard; |
|
46 |
import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard; |
|
47 |
|
|
48 |
/** |
|
49 |
* <p>NewTaxonNodeHandler class.</p> |
|
50 |
* |
|
51 |
* @author n.hoffmann |
|
52 |
* @created Sep 15, 2009 |
|
53 |
* @version 1.0 |
|
54 |
*/ |
|
55 |
public class NewPolytomousKeyHandler extends AbstractHandler implements IHandler { |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
59 |
*/ |
|
60 |
/** {@inheritDoc} */ |
|
61 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
62 |
NewPolytomousKeyWizard wizard = new NewPolytomousKeyWizard(); |
|
63 |
wizard.init(null,null); |
|
64 |
WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard); |
|
65 |
int status = dialog.open(); |
|
66 |
if(status == Status.OK) { |
|
67 |
PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false); |
|
68 |
List<PolytomousKey> pklist = CdmStore.getService(IPolytomousKeyService.class).list(PolytomousKey.class, null, null, null, null); |
|
69 |
view.refresh(); |
|
70 |
view.setViewerSelection(new StructuredSelection(wizard.getEntity()),true); |
|
71 |
view.openSelectedKeyNodes(); |
|
72 |
} |
|
73 |
return null; |
|
74 |
} |
|
75 |
} |
Also available in: Unified diff