Revision 6dc31045
Added by Cherian Mathew almost 11 years ago
.gitattributes | ||
---|---|---|
374 | 374 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java -text |
375 | 375 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListItem.java -text |
376 | 376 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListLabelProvider.java -text |
377 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateNodeHandler.java -text |
|
377 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateChildNodeHandler.java -text |
|
378 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateSiblingNodeHandler.java -text |
|
378 | 379 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/DeleteNodeHandler.java -text |
380 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/RefreshNodeNumberingHandler.java -text |
|
379 | 381 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/CreateNodeOperation.java -text |
380 | 382 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/DeleteNodeOperation.java -text |
381 | 383 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java -text |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateChildNodeHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package eu.etaxonomy.taxeditor.editor.key.polytomous.handler; |
|
5 |
|
|
6 |
import org.eclipse.core.commands.AbstractHandler; |
|
7 |
import org.eclipse.core.commands.ExecutionEvent; |
|
8 |
import org.eclipse.core.commands.ExecutionException; |
|
9 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
10 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
11 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
12 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
13 |
import org.eclipse.ui.IEditorPart; |
|
14 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
17 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
|
18 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
19 |
import eu.etaxonomy.taxeditor.editor.key.KeyEditor; |
|
20 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage; |
|
21 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListEditor; |
|
22 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.CreateNodeOperation; |
|
23 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author n.hoffmann |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class CreateChildNodeHandler extends AbstractHandler { |
|
30 |
|
|
31 |
/* |
|
32 |
* (non-Javadoc) |
|
33 |
* |
|
34 |
* @see |
|
35 |
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. |
|
36 |
* ExecutionEvent) |
|
37 |
*/ |
|
38 |
@Override |
|
39 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
40 |
|
|
41 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
42 |
|
|
43 |
if (editor instanceof KeyEditor) { |
|
44 |
IPolytomousKeyEditorPage editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor) |
|
45 |
.getActiveEditor(); |
|
46 |
|
|
47 |
if (editorPage instanceof PolytomousKeyListEditor) { |
|
48 |
PolytomousKeyListEditor klEditor = (PolytomousKeyListEditor) editorPage; |
|
49 |
if(klEditor.getTableItemCount() == 0) { |
|
50 |
PolytomousKey pk = (PolytomousKey)klEditor.getViewerInputKey(); |
|
51 |
try { |
|
52 |
String label = event.getCommand().getName(); |
|
53 |
IUndoContext undoContext = EditorUtil.getUndoContext(); |
|
54 |
|
|
55 |
|
|
56 |
AbstractPostOperation operation = new CreateNodeOperation( |
|
57 |
label, undoContext, pk.getRoot(), editorPage); |
|
58 |
EditorUtil.executeOperation(operation); |
|
59 |
} catch (NotDefinedException e) { |
|
60 |
EditorUtil.warn(getClass(), "Command name not set."); |
|
61 |
} |
|
62 |
} else { |
|
63 |
|
|
64 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
65 |
.getCurrentSelection(event); |
|
66 |
|
|
67 |
if (selection.getFirstElement() instanceof PolytomousKeyNode) { |
|
68 |
try { |
|
69 |
String label = event.getCommand().getName(); |
|
70 |
IUndoContext undoContext = EditorUtil.getUndoContext(); |
|
71 |
|
|
72 |
PolytomousKeyNode keyNode = (PolytomousKeyNode) selection |
|
73 |
.getFirstElement(); |
|
74 |
|
|
75 |
AbstractPostOperation operation = new CreateNodeOperation( |
|
76 |
label, undoContext, keyNode, editorPage); |
|
77 |
EditorUtil.executeOperation(operation); |
|
78 |
} catch (NotDefinedException e) { |
|
79 |
EditorUtil.warn(getClass(), "Command name not set."); |
|
80 |
} |
|
81 |
} else { |
|
82 |
MessageDialog.openInformation( |
|
83 |
EditorUtil.getShell(), |
|
84 |
"No Key Node Selected", |
|
85 |
"Please right-click on a specific key node to create a new child key node."); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
return null; |
|
92 |
} |
|
93 |
|
|
94 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateNodeHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package eu.etaxonomy.taxeditor.editor.key.polytomous.handler; |
|
5 |
|
|
6 |
import org.eclipse.core.commands.AbstractHandler; |
|
7 |
import org.eclipse.core.commands.ExecutionEvent; |
|
8 |
import org.eclipse.core.commands.ExecutionException; |
|
9 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
10 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
11 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
12 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
13 |
import org.eclipse.ui.IEditorPart; |
|
14 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
17 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
|
18 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
19 |
import eu.etaxonomy.taxeditor.editor.key.KeyEditor; |
|
20 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage; |
|
21 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListEditor; |
|
22 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.CreateNodeOperation; |
|
23 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author n.hoffmann |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class CreateNodeHandler extends AbstractHandler { |
|
30 |
|
|
31 |
/* |
|
32 |
* (non-Javadoc) |
|
33 |
* |
|
34 |
* @see |
|
35 |
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. |
|
36 |
* ExecutionEvent) |
|
37 |
*/ |
|
38 |
@Override |
|
39 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
40 |
|
|
41 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
42 |
|
|
43 |
if (editor instanceof KeyEditor) { |
|
44 |
IPolytomousKeyEditorPage editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor) |
|
45 |
.getActiveEditor(); |
|
46 |
|
|
47 |
if (editorPage instanceof PolytomousKeyListEditor) { |
|
48 |
PolytomousKeyListEditor klEditor = (PolytomousKeyListEditor) editorPage; |
|
49 |
if(klEditor.getTableItemCount() == 0) { |
|
50 |
PolytomousKey pk = (PolytomousKey)klEditor.getViewerInputKey(); |
|
51 |
try { |
|
52 |
String label = event.getCommand().getName(); |
|
53 |
IUndoContext undoContext = EditorUtil.getUndoContext(); |
|
54 |
|
|
55 |
|
|
56 |
AbstractPostOperation operation = new CreateNodeOperation( |
|
57 |
label, undoContext, pk.getRoot(), editorPage); |
|
58 |
EditorUtil.executeOperation(operation); |
|
59 |
} catch (NotDefinedException e) { |
|
60 |
EditorUtil.warn(getClass(), "Command name not set."); |
|
61 |
} |
|
62 |
} else { |
|
63 |
|
|
64 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
65 |
.getCurrentSelection(event); |
|
66 |
|
|
67 |
if (selection.getFirstElement() instanceof PolytomousKeyNode) { |
|
68 |
try { |
|
69 |
String label = event.getCommand().getName(); |
|
70 |
IUndoContext undoContext = EditorUtil.getUndoContext(); |
|
71 |
|
|
72 |
PolytomousKeyNode keyNode = (PolytomousKeyNode) selection |
|
73 |
.getFirstElement(); |
|
74 |
|
|
75 |
AbstractPostOperation operation = new CreateNodeOperation( |
|
76 |
label, undoContext, keyNode, editorPage); |
|
77 |
EditorUtil.executeOperation(operation); |
|
78 |
} catch (NotDefinedException e) { |
|
79 |
EditorUtil.warn(getClass(), "Command name not set."); |
|
80 |
} |
|
81 |
} else { |
|
82 |
MessageDialog.openInformation( |
|
83 |
EditorUtil.getShell(), |
|
84 |
"No Key Node Selected", |
|
85 |
"Please right-click on a specific key node to create a new child key node."); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
return null; |
|
92 |
} |
|
93 |
|
|
94 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateSiblingNodeHandler.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.key.polytomous.handler; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.AbstractHandler; |
|
4 |
import org.eclipse.core.commands.ExecutionEvent; |
|
5 |
import org.eclipse.core.commands.ExecutionException; |
|
6 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
7 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
8 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
9 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
10 |
import org.eclipse.ui.IEditorPart; |
|
11 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
14 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
|
15 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
16 |
import eu.etaxonomy.taxeditor.editor.key.KeyEditor; |
|
17 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage; |
|
18 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListEditor; |
|
19 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.CreateNodeOperation; |
|
20 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
21 |
|
|
22 |
/** |
|
23 |
* Handler responsible for creating sibling nodes of Polytomous Key Nodes |
|
24 |
* @author c.mathew |
|
25 |
* |
|
26 |
*/ |
|
27 |
|
|
28 |
public class CreateSiblingNodeHandler extends AbstractHandler { |
|
29 |
|
|
30 |
/* |
|
31 |
* (non-Javadoc) |
|
32 |
* |
|
33 |
* @see |
|
34 |
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. |
|
35 |
* ExecutionEvent) |
|
36 |
*/ |
|
37 |
@Override |
|
38 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
39 |
|
|
40 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
41 |
|
|
42 |
if (editor instanceof KeyEditor) { |
|
43 |
IPolytomousKeyEditorPage editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor) |
|
44 |
.getActiveEditor(); |
|
45 |
|
|
46 |
if (editorPage instanceof PolytomousKeyListEditor) { |
|
47 |
|
|
48 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
49 |
.getCurrentSelection(event); |
|
50 |
|
|
51 |
if (selection.getFirstElement() instanceof PolytomousKeyNode) { |
|
52 |
try { |
|
53 |
String label = event.getCommand().getName(); |
|
54 |
IUndoContext undoContext = EditorUtil.getUndoContext(); |
|
55 |
|
|
56 |
PolytomousKeyNode keyNode = (PolytomousKeyNode) selection |
|
57 |
.getFirstElement(); |
|
58 |
|
|
59 |
AbstractPostOperation operation = new CreateNodeOperation( |
|
60 |
label, undoContext, keyNode.getParent(), editorPage); |
|
61 |
EditorUtil.executeOperation(operation); |
|
62 |
} catch (NotDefinedException e) { |
|
63 |
EditorUtil.warn(getClass(), "Command name not set."); |
|
64 |
} |
|
65 |
} else { |
|
66 |
MessageDialog.openInformation( |
|
67 |
EditorUtil.getShell(), |
|
68 |
"No Key Node Selected", |
|
69 |
"Please right-click on a specific key node to create a new sibling key node."); |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
return null; |
|
75 |
} |
|
76 |
|
|
77 |
} |
|
78 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/RefreshNodeNumberingHandler.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.key.polytomous.handler; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.AbstractHandler; |
|
4 |
import org.eclipse.core.commands.ExecutionEvent; |
|
5 |
import org.eclipse.core.commands.ExecutionException; |
|
6 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
7 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
8 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
9 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
10 |
import org.eclipse.ui.IEditorPart; |
|
11 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
|
14 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
15 |
import eu.etaxonomy.taxeditor.editor.key.KeyEditor; |
|
16 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage; |
|
17 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListEditor; |
|
18 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.CreateNodeOperation; |
|
19 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.RefreshNodeNumberingOperation; |
|
20 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
21 |
|
|
22 |
public class RefreshNodeNumberingHandler extends AbstractHandler { |
|
23 |
|
|
24 |
@Override |
|
25 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
26 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
27 |
|
|
28 |
if (editor instanceof KeyEditor) { |
|
29 |
IPolytomousKeyEditorPage editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor) |
|
30 |
.getActiveEditor(); |
|
31 |
|
|
32 |
if (editorPage instanceof PolytomousKeyListEditor) { |
|
33 |
|
|
34 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
35 |
.getCurrentSelection(event); |
|
36 |
|
|
37 |
if (selection.getFirstElement() instanceof PolytomousKeyNode) { |
|
38 |
try { |
|
39 |
String label = event.getCommand().getName(); |
|
40 |
IUndoContext undoContext = EditorUtil.getUndoContext(); |
|
41 |
|
|
42 |
PolytomousKeyNode keyNode = (PolytomousKeyNode) selection |
|
43 |
.getFirstElement(); |
|
44 |
|
|
45 |
AbstractPostOperation operation = new RefreshNodeNumberingOperation( |
|
46 |
label, undoContext, keyNode, editorPage); |
|
47 |
EditorUtil.executeOperation(operation); |
|
48 |
} catch (NotDefinedException e) { |
|
49 |
EditorUtil.warn(getClass(), "Command name not set."); |
|
50 |
} |
|
51 |
} |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
return null; |
|
56 |
} |
|
57 |
|
|
58 |
} |
Also available in: Unified diff
CreateNodeHandler.java : replaced by CreateChildNodeHandler.java
RefreshNodeNumberingHandler.java : handler for refreshing polytomous key node numbers
CreateSiblingNodeHandler.java : handler for creating siblings