1 package eu
.etaxonomy
.taxeditor
.prototype2
.view
;
3 import java
.beans
.PropertyChangeEvent
;
4 import java
.beans
.PropertyChangeListener
;
5 import java
.util
.ArrayList
;
8 import org
.eclipse
.core
.databinding
.DataBindingContext
;
9 import org
.eclipse
.core
.databinding
.beans
.BeansObservables
;
10 import org
.eclipse
.core
.databinding
.observable
.set
.ISetChangeListener
;
11 import org
.eclipse
.core
.databinding
.observable
.set
.SetChangeEvent
;
12 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
13 import org
.eclipse
.jface
.text
.source
.SourceViewer
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.dnd
.DND
;
16 import org
.eclipse
.swt
.dnd
.DropTarget
;
17 import org
.eclipse
.swt
.dnd
.DropTargetAdapter
;
18 import org
.eclipse
.swt
.dnd
.DropTargetEvent
;
19 import org
.eclipse
.swt
.dnd
.Transfer
;
20 import org
.eclipse
.swt
.events
.FocusEvent
;
21 import org
.eclipse
.swt
.events
.FocusListener
;
22 import org
.eclipse
.swt
.events
.MouseEvent
;
23 import org
.eclipse
.swt
.events
.MouseListener
;
24 import org
.eclipse
.swt
.events
.SelectionAdapter
;
25 import org
.eclipse
.swt
.events
.SelectionEvent
;
26 import org
.eclipse
.swt
.events
.SelectionListener
;
27 import org
.eclipse
.swt
.graphics
.Point
;
28 import org
.eclipse
.swt
.graphics
.Rectangle
;
29 import org
.eclipse
.swt
.layout
.FillLayout
;
30 import org
.eclipse
.swt
.layout
.GridData
;
31 import org
.eclipse
.swt
.layout
.GridLayout
;
32 import org
.eclipse
.swt
.widgets
.Composite
;
33 import org
.eclipse
.swt
.widgets
.CoolBar
;
34 import org
.eclipse
.swt
.widgets
.CoolItem
;
35 import org
.eclipse
.swt
.widgets
.Display
;
36 import org
.eclipse
.swt
.widgets
.Event
;
37 import org
.eclipse
.swt
.widgets
.Label
;
38 import org
.eclipse
.swt
.widgets
.Link
;
39 import org
.eclipse
.swt
.widgets
.Listener
;
40 import org
.eclipse
.swt
.widgets
.Menu
;
41 import org
.eclipse
.swt
.widgets
.MenuItem
;
42 import org
.eclipse
.swt
.widgets
.ToolBar
;
43 import org
.eclipse
.swt
.widgets
.ToolItem
;
44 import org
.eclipse
.ui
.IEditorInput
;
45 import org
.eclipse
.ui
.IEditorSite
;
46 import org
.eclipse
.ui
.PartInitException
;
47 import org
.eclipse
.ui
.part
.EditorPart
;
48 import org
.eclipse
.ui
.part
.WorkbenchPart
;
50 import com
.swtdesigner
.ResourceManager
;
51 import com
.swtdesigner
.SWTResourceManager
;
53 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
54 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
55 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
56 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
57 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
58 import eu
.etaxonomy
.taxeditor
.prototype2
.Activator
;
59 import eu
.etaxonomy
.taxeditor
.prototype2
.controller
.ActionDeleteTaxon
;
60 import eu
.etaxonomy
.taxeditor
.prototype2
.controller
.ActionOpenNameEditor
;
61 import eu
.etaxonomy
.taxeditor
.prototype2
.controller
.ActionOpenNewChildNameEditor
;
62 import eu
.etaxonomy
.taxeditor
.prototype2
.controller
.ActionSaveTaxon
;
63 import eu
.etaxonomy
.taxeditor
.prototype2
.controller
.TaxonTransfer
;
64 import eu
.etaxonomy
.taxeditor
.prototype2
.model
.PropertySheetNode
;
65 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.nameviewersupport
.GroupComposite
;
66 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.nameviewersupport
.NameComposite
;
67 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.nameviewersupport
.TesterooWritableSet
;
68 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.propertysheetsupport
.PropertySheetContentProvider
;
69 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.propertysheetsupport
.PropertySheetValueEditingSupport
;
70 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.propertysheetsupport
.PropertySheetValueLabelProvider
;
73 * TODO: user should always know what kind of name - BotanicalName,
74 * ZoologicalName, etc. - he will be editing when a new taxon
80 public class NameEditorView
extends EditorPart
{
82 * The taxon the editor is editing
86 * The higher taxon of the taxon the editor is editing
88 private Taxon higherTaxon
= null;
90 * Shared listener that sets dirty state to true
91 * when any registered property changes
93 private PropertyChangeListener taxonChangeListener
= new PropertyChangeListener() {
94 public void propertyChange(PropertyChangeEvent arg0
) {
96 firePropertyChange(PROP_DIRTY
);
100 * Arrays for the creation of synonyms - text and images
102 String
[] relTypes
= {"a synonym (type unknown)",
103 "a homotypic synonym",
104 "a heterotypic synoynm",
106 "a replaced synonym",
108 "an orthographic variant",
110 "a concept relation"};
111 String
[] relImgs
= {"unknown_no_bg.gif",
113 "heterosyn_no_bg.gif",
114 "basionym_no_bg.gif",
117 "orthovariant_no_bg.gif",
118 "misapplied_no_bg.gif",
119 "concept_no_bg.gif"};
120 String
[] conceptTypes
= {"congruent","included in","includes","overlaps","excludes","doubtful"};
122 * If true, show "save" prompt before closing editor
124 public boolean dirty
= false;
127 private Composite nameComposite
;
128 private Composite contentComposite
;
130 private PropertySheetViewer propertySheetViewer
;
131 private Composite parent
;
133 public static final String ID
= "eu.etaxonomy.taxeditor.prototype2.view.nameeditorview"; //$NON-NLS-1$
135 public NameEditorView() {
139 * Create contents of the editor part
143 public void createPartControl(Composite parent
) {
145 this.parent
= parent
;
146 parent
.setLayout(new GridLayout());
147 parent
.setRedraw(true);
153 final CoolBar coolBar
= new CoolBar(parent
, SWT
.NONE
);
154 new CoolItem(coolBar
, SWT
.PUSH
).setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/save_edit.gif"));
156 final ToolBar toolBar
= new ToolBar(parent
, SWT
.NONE
);
157 // toolBar.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
159 final ToolItem itemSave
= new ToolItem(toolBar
, SWT
.PUSH
);
160 itemSave
.setToolTipText("Save taxon");
161 itemSave
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/save_edit.gif"));
162 itemSave
.addSelectionListener(new SelectionListener() {
163 public void widgetDefaultSelected(SelectionEvent e
) {
165 new ActionSaveTaxon(taxon
).run();
167 public void widgetSelected(SelectionEvent e
) {
169 new ActionSaveTaxon(taxon
).run();
173 final ToolItem itemMove
= new ToolItem(toolBar
, SWT
.DROP_DOWN
);
174 itemMove
.setToolTipText("Move taxon");
176 final Menu menuMove
= new Menu(toolBar
);
177 addDropDown(itemMove
, menuMove
);
179 final MenuItem moveTaxonMenuItem
= new MenuItem(menuMove
, SWT
.NONE
);
180 moveTaxonMenuItem
.setText("Move taxon to another higher taxon");
181 moveTaxonMenuItem
.addSelectionListener(new SelectionAdapter() {
182 public void widgetSelected(final SelectionEvent e
) {
183 new MoveDialogView(getSite().getShell());
184 MoveDialogView dialog
= new MoveDialogView(getSite().getShell());
189 final MenuItem taxonToSynonymMenuItem
= new MenuItem(menuMove
, SWT
.NONE
);
190 taxonToSynonymMenuItem
.setSelection(true);
191 taxonToSynonymMenuItem
.setText("Turn taxon's accepted name into a synonym");
192 taxonToSynonymMenuItem
.addSelectionListener(new SelectionAdapter() {
193 public void widgetSelected(final SelectionEvent e
) {
194 new MoveDialogView(getSite().getShell());
195 MoveDialogView dialog
= new MoveDialogView(getSite().getShell());
200 itemMove
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/correction_change.gif"));
202 final ToolItem itemDelete
= new ToolItem(toolBar
, SWT
.NONE
);
203 itemDelete
.setToolTipText("Delete taxon");
204 itemDelete
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/delete_edit.gif"));
205 itemDelete
.addSelectionListener(new SelectionListener() {
207 public void widgetDefaultSelected(SelectionEvent e
) {
208 // TODO Auto-generated method stub
211 public void widgetSelected(SelectionEvent e
) {
212 new ActionDeleteTaxon(taxon
).run();
216 new ToolItem(toolBar
, SWT
.SEPARATOR
);
218 final ToolItem itemAddRelationship
= new ToolItem(toolBar
, SWT
.DROP_DOWN
);
219 itemAddRelationship
.setToolTipText("Add nom. or tax. relation to taxon");
220 itemAddRelationship
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/rel_no_bg.gif"));
223 * Create menu to add relations to the taxon
225 final Menu menuAddRel
= new Menu(toolBar
);
226 addDropDown(itemAddRelationship
, menuAddRel
);
228 for (int i
= 0; i
< relTypes
.length
; i
++) {
229 final MenuItem menuItem
;
230 if (relTypes
[i
].contains("concept")) {
231 menuItem
= new MenuItem(menuAddRel
, SWT
.CASCADE
);
233 final Menu conceptMenu
= new Menu(menuItem
);
234 menuItem
.setMenu(conceptMenu
);
236 for (int j
= 0; j
< conceptTypes
.length
; j
++) {
237 final MenuItem conceptMenuItem
= new MenuItem(conceptMenu
, SWT
.CHECK
);
238 conceptMenuItem
.setText(conceptTypes
[j
]);
241 menuItem
= new MenuItem(menuAddRel
, SWT
.NONE
);
244 menuItem
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/" + relImgs
[i
]));
245 menuItem
.setText("Add " + relTypes
[i
]);
248 new ToolItem(toolBar
, SWT
.SEPARATOR
);
250 final ToolItem itemAddTaxon
= new ToolItem(toolBar
, SWT
.DROP_DOWN
);
251 itemAddTaxon
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/add_edit.gif"));
252 itemAddTaxon
.setToolTipText("Add new taxon");
255 * drop-down to add new "included in" taxon
257 final Menu menuAdd
= new Menu(toolBar
);
258 addDropDown(itemAddTaxon
, menuAdd
);
260 if (higherTaxon
!= null) {
261 final MenuItem addToHigherTaxonItem
= new MenuItem(menuAdd
, SWT
.NONE
);
262 addToHigherTaxonItem
.setText("Add new taxon to \"" + higherTaxon
.getName().getTitleCache() + "\"");
263 addToHigherTaxonItem
.addSelectionListener(new SelectionListener() {
264 public void widgetDefaultSelected(SelectionEvent e
) {
265 // TODO Auto-generated method stub
268 public void widgetSelected(SelectionEvent e
) {
269 new ActionOpenNewChildNameEditor(higherTaxon
).run();
273 final MenuItem addTaxonItem
= new MenuItem(menuAdd
, SWT
.NONE
);
274 addTaxonItem
.setText("Add new taxon to this taxon");
275 addTaxonItem
.addSelectionListener(new SelectionListener() {
276 public void widgetDefaultSelected(SelectionEvent e
) {
277 // TODO Auto-generated method stub
280 public void widgetSelected(SelectionEvent e
) {
281 new ActionOpenNewChildNameEditor(taxon
).run();
285 contentComposite
= new Composite(parent
, SWT
.NONE
);
286 contentComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
287 contentComposite
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
288 final GridLayout gridLayout_2
= new GridLayout();
289 gridLayout_2
.marginHeight
= 0;
290 gridLayout_2
.marginWidth
= 0;
291 gridLayout_2
.numColumns
= 2;
292 contentComposite
.setLayout(gridLayout_2
);
293 contentComposite
.setRedraw(true);
296 nameComposite
= new Composite(contentComposite
, SWT
.NONE
);
297 nameComposite
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
298 nameComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, true));
299 GridLayout gridLayout
= new GridLayout();
300 gridLayout
.verticalSpacing
= 10;
301 nameComposite
.setLayout(gridLayout
);
302 nameComposite
.setRedraw(true);
305 // clickText = "Click here to start entering accepted name or enter its individual fields in the property sheet to the right";
306 // NameViewer_ acceptedNameViewer = new AcceptedNameViewer(taxon, bindingContext, nameComposite);
307 // acceptedNameViewer.setBindingContext(bindingContext);
308 // acceptedNameViewer.configure(new NameViewerConfig());
310 GroupComposite homoGroupComposite
= new GroupComposite(nameComposite
);
311 homoGroupComposite
.setTaxon(taxon
);
312 homoGroupComposite
.setNameEditorView(this);
314 new NameComposite(homoGroupComposite
, taxon
).setNameEditorView(this);
316 TesterooWritableSet
.getInstance().addSetChangeListener
317 (new ISetChangeListener() {
318 public void handleSetChange(SetChangeEvent event
) {
319 for ( Object addition
: event
.diff
.getAdditions()) {
320 if (addition
instanceof Synonym
)
321 createHeterotypicalGroup((Synonym
) addition
);
323 nameComposite
.layout();
324 contentComposite
.layout();
328 // Listen for names being dragged outside of existing homotypic groups -
329 // user wants to create a new group
330 // Drop functionality
331 Transfer
[] types
= new Transfer
[] {TaxonTransfer
.getInstance()};
332 int operations
= DND
.DROP_MOVE
| DND
.DROP_COPY
| DND
.DROP_DEFAULT
;
333 DropTarget target
= new DropTarget(nameComposite
, operations
);
334 target
.setTransfer(types
);
335 target
.addDropListener(dropTargetAdapter
);
338 * construct PropertySheetViewer, with bindings to model layer
340 propertySheetViewer
= new PropertySheetViewer(contentComposite
);
342 propertySheetViewer
.setContentProvider(
343 new PropertySheetContentProvider());
344 propertySheetViewer
.getPropertyValueColumn().setLabelProvider(
345 new PropertySheetValueLabelProvider(propertySheetViewer
));
346 propertySheetViewer
.getPropertyValueColumn().setEditingSupport(
347 new PropertySheetValueEditingSupport(propertySheetViewer
));
349 setPropertySheetNodes(taxon
.getName());
353 * Display hyperlinked higher taxon, if there is one
355 private void createHigherTaxon() {
356 Composite higherTaxonComposite
= new Composite(parent
, SWT
.NONE
);
357 higherTaxonComposite
.setLayout(new FillLayout());
358 (new Label(higherTaxonComposite
, SWT
.NONE
)).setText("Higher taxon: ");
359 if (higherTaxon
== null)
360 (new Label(higherTaxonComposite
, SWT
.NONE
)).setText("none");
362 Link higherTaxonLink
= new Link(higherTaxonComposite
, SWT
.NONE
);
363 higherTaxonLink
.setText("<a href=\"#\">" + higherTaxon
.getName().getTitleCache() + "</a>");
364 higherTaxonLink
.addMouseListener(new MouseListener() {
365 public void mouseDoubleClick(MouseEvent e
) {
366 new ActionOpenNameEditor(higherTaxon
).run();
368 public void mouseDown(MouseEvent e
) {
369 new ActionOpenNameEditor(higherTaxon
).run();
371 public void mouseUp(MouseEvent e
) {
376 public void setPropertySheetNodes(TaxonNameBase taxonname
) {
377 propertySheetViewer
.setInput(getPropertySheetNodes(taxonname
));
378 propertySheetViewer
.setExpandedState(fullTitleNode
, true);
381 private SourceViewer
createAcceptedName_() {
383 // Method[] methods = BotanicalName.class.getMethods();
384 // for (int i = 0; i < methods.length; i++) {
385 // System.out.println("Annotations:");
386 // for (int j = 0; i < methods[j].getAnnotations().length; j++)
387 // System.out.println("\t" + methods[i].getAnnotations()[j]);
388 // System.out.println("Type: " + methods[i].getReturnType().toString());
389 // System.out.println("Name:" + methods[i].getName());
390 // System.out.println();
392 // use annotations to find persistent methods
395 // PropertyDescriptor descriptor;
397 // descriptor = new PropertyDescriptor("genus", taxonname.getClass());
399 // System.out.println("Property desc. test in createAcceptedName: "
400 // + descriptor.getReadMethod().invoke(taxonname, null));
401 // } catch (IllegalArgumentException e) {
402 // // TODO Auto-generated catch block
403 // e.printStackTrace();
404 // } catch (IllegalAccessException e) {
405 // // TODO Auto-generated catch block
406 // e.printStackTrace();
407 // } catch (InvocationTargetException e) {
408 // // TODO Auto-generated catch block
409 // e.printStackTrace();
411 // } catch (IntrospectionException e) {
412 // // TODO Auto-generated catch block
413 // e.printStackTrace();
416 final SourceViewer sourceViewer
= new SourceViewer(nameComposite
, null, 0); // createSourceViewer(taxon.getName());
418 sourceViewer
.getTextWidget().setLayoutData(
419 new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
420 sourceViewer
.getTextWidget().setFont(
421 SWTResourceManager
.getFont("Georgia", 12, SWT
.NONE
));
424 * if this is a new name, show text prompt to start entering data
426 if (taxon
.getName().getNameCache() == null) {
427 clickText
= "Click here to start entering accepted name or enter individual fields in the property sheet to the right";
429 sourceViewer
.getTextWidget().setText(clickText
);
430 sourceViewer
.getTextWidget().setFont(SWTResourceManager
.getFont("Georgia", 12, SWT
.ITALIC
));
431 sourceViewer
.getTextWidget().setForeground(SWTResourceManager
.getColor(192, 192, 192));
432 sourceViewer
.getTextWidget().addFocusListener(new FocusListener() {
433 public void focusGained(FocusEvent e
) {
435 sourceViewer
.getTextWidget().setText("");
436 sourceViewer
.getTextWidget().setFont(SWTResourceManager
.getFont("Georgia", 12, SWT
.NONE
));
437 sourceViewer
.getTextWidget().setForeground(SWTResourceManager
.getColor(0, 0, 0));
439 // firePropertyChange(PROP_DIRTY);
442 public void focusLost(FocusEvent e
) {
443 if (sourceViewer
.getTextWidget().getText() == "") {
444 sourceViewer
.getTextWidget().setForeground(SWTResourceManager
.getColor(192, 192, 192));
445 sourceViewer
.getTextWidget().setText(clickText
);
446 sourceViewer
.getTextWidget().setFont(SWTResourceManager
.getFont("Georgia", 12, SWT
.ITALIC
));
461 * Creates the drop-down menu next to every synonym for changing relationship type
466 // private void createRelationMenu(Control control, BotanicalName name) {
467 private void createRelationMenu(final Label label
) {
469 final Menu menu
= new Menu(label
);
472 // context menu usually only shows up w/ right menu click -
473 // this listener lets the left click activate it as well
474 label
.addMouseListener(new MouseListener() {
475 public void mouseDown(MouseEvent e
) {
476 menu
.setVisible(true);
478 public void mouseDoubleClick(MouseEvent e
) { }
479 public void mouseUp(MouseEvent e
) { }
482 createRelationMenuItem(menu
, "delete_edit.gif", "Delete synonym from this taxon");
483 createRelationMenuItem(menu
, "correction_change.gif", "Move synonym to another taxon");
485 new MenuItem(menu
, SWT
.SEPARATOR
);
487 for (int i
= 0; i
< relTypes
.length
; i
++) {
488 final String relImg
= relImgs
[i
];
489 String relText
= "Turn this synonym into " + relTypes
[i
];
490 createRelationMenuItem(menu
, relImg
, relText
).addSelectionListener(new SelectionListener() {
491 public void widgetDefaultSelected(SelectionEvent e
) {
493 public void widgetSelected(SelectionEvent e
) {
494 label
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/" + relImg
));
500 private MenuItem
createRelationMenuItem(Menu menu
, String img
, String text
) {
501 final MenuItem menuItem
= new MenuItem(menu
, SWT
.NONE
);
502 menuItem
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/" + img
));
503 menuItem
.setText(text
);
508 public void setFocus() {
513 public void doSave(IProgressMonitor monitor
) {
514 // Do the Save operation
518 public void doSaveAs() {
519 // Do the Save As operation
523 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
525 if (!(input
instanceof IEditorInput
))
526 throw new PartInitException(
527 "Invalid Input: Must be IFileEditorInput");
529 if (input
.getAdapter(Taxon
.class) != null) {
530 taxon
= (Taxon
) input
.getAdapter(Taxon
.class);
537 if (taxon
.getTaxonomicParent() != null)
538 higherTaxon
= taxon
.getTaxonomicParent();
540 // Register listeners for any change in accepted name or set of relations
541 taxon
.getName().addPropertyChangeListener("titleCache", taxonChangeListener
);
542 taxon
.addPropertyChangeListener("synonyms", taxonChangeListener
);
549 PropertySheetNode fullTitleNode
;
554 private List
<PropertySheetNode
> getPropertySheetNodes(TaxonNameBase taxonName
) {
556 BotanicalName botName
= (BotanicalName
) taxonName
;
558 List
<PropertySheetNode
> propertySheetNodes
= new ArrayList
<PropertySheetNode
>();
559 fullTitleNode
= new PropertySheetNode("Full Title", BeansObservables
.observeValue(botName
, "titleCache"),
560 null, PropertySheetNode
.EDITABLE
);
561 propertySheetNodes
.add(fullTitleNode
);
563 // Note: only top-level nodes are "add"-ed - otherwise, they are
564 // instantiated with their parent node
565 if (botName
.getRank() == null) botName
.setRank(Rank
.GENUS());
566 new PropertySheetNode("Rank", botName
.getRank().getLabel(),
567 fullTitleNode
, PropertySheetNode
.NOT_EDITABLE
);
568 new PropertySheetNode("Genus", BeansObservables
.observeValue(botName
, "uninomial"),
569 fullTitleNode
, PropertySheetNode
.EDITABLE
);
570 new PropertySheetNode("Species Epithet", BeansObservables
.observeValue(botName
, "specificEpithet"),
571 fullTitleNode
, PropertySheetNode
.EDITABLE
);
574 botName
.getCombinationAuthorTeam() == null ?
"" :
575 botName
.getCombinationAuthorTeam().getTitleCache();
576 new PropertySheetNode("Author", author
,
577 fullTitleNode
, PropertySheetNode
.NOT_EDITABLE
);
579 return propertySheetNodes
;
583 public boolean isDirty() {
588 public boolean isSaveAsAllowed() {
592 private static void addDropDown(final ToolItem item
, final Menu menu
) {
593 item
.addListener(SWT
.Selection
, new Listener() {
594 public void handleEvent(Event event
) {
595 if (event
.detail
== SWT
.ARROW
) {
596 Rectangle rect
= item
.getBounds();
597 Point pt
= new Point(rect
.x
, rect
.y
+ rect
.height
);
598 pt
= item
.getParent().toDisplay(pt
);
599 menu
.setLocation(pt
.x
, pt
.y
);
600 menu
.setVisible(true);
606 private void createHeterotypicalGroup(Synonym heterosyn
) {
608 GroupComposite heteroGroupComposite
= new GroupComposite(nameComposite
);
609 heteroGroupComposite
.setTaxon(taxon
);
610 heteroGroupComposite
.setNameEditorView(this);
612 NameComposite nameComposite
= new NameComposite(heteroGroupComposite
, heterosyn
, taxon
);
613 nameComposite
.setNameEditorView(this);
614 nameComposite
.setFocus();
618 * Creates a new homotypic group when a name composite is dropped outside of all existing
621 DropTargetAdapter dropTargetAdapter
= new DropTargetAdapter() {
623 public void drop(DropTargetEvent event
) {
625 Synonym synonym
= (Synonym
) event
.data
;
627 GroupComposite homotypicGroupComposite
= new GroupComposite(nameComposite
);
628 homotypicGroupComposite
.setTaxon(taxon
);
629 homotypicGroupComposite
.setNameEditorView(NameEditorView
.this);
631 new NameComposite(homotypicGroupComposite
, synonym
, taxon
).setFocus();
633 NameEditorView
.this.contentComposite
.layout();