1 package eu
.etaxonomy
.taxeditor
.designproposal1
.view
;
3 import org
.eclipse
.jface
.action
.IToolBarManager
;
4 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
5 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
6 import org
.eclipse
.jface
.viewers
.LabelProvider
;
7 import org
.eclipse
.jface
.viewers
.TableViewer
;
8 import org
.eclipse
.jface
.viewers
.Viewer
;
9 import org
.eclipse
.swt
.SWT
;
10 import org
.eclipse
.swt
.events
.SelectionAdapter
;
11 import org
.eclipse
.swt
.events
.SelectionEvent
;
12 import org
.eclipse
.swt
.graphics
.Image
;
13 import org
.eclipse
.swt
.layout
.GridData
;
14 import org
.eclipse
.swt
.layout
.GridLayout
;
15 import org
.eclipse
.swt
.widgets
.Button
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.swt
.widgets
.Event
;
18 import org
.eclipse
.swt
.widgets
.Label
;
19 import org
.eclipse
.swt
.widgets
.Listener
;
20 import org
.eclipse
.swt
.widgets
.Text
;
21 import org
.eclipse
.ui
.ISharedImages
;
22 import org
.eclipse
.ui
.PlatformUI
;
23 import org
.eclipse
.ui
.part
.ViewPart
;
25 import eu
.etaxonomy
.taxeditor
.designproposal1
.controller
.CreateNameAction
;
27 public class CreateNameView
extends ViewPart
{
28 private Text txtSpEpithet
;
29 private Text txtGenus
;
30 public static final String ID
= "eu.etaxonomy.taxeditor.designproposal1.view.createnameview";
33 * This is a callback that will allow us to create the viewer and initialize
36 public void createPartControl(Composite parent
) {
37 final GridLayout gridLayout
= new GridLayout();
38 gridLayout
.numColumns
= 2;
39 parent
.setLayout(gridLayout
);
41 final Label genusLabel
= new Label(parent
, SWT
.NONE
);
42 genusLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
43 genusLabel
.setText("Genus:");
45 txtGenus
= new Text(parent
, SWT
.BORDER
);
46 final GridData gd_txtGenus
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
47 txtGenus
.setLayoutData(gd_txtGenus
);
49 final Label epithetLabel
= new Label(parent
, SWT
.NONE
);
50 epithetLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
51 epithetLabel
.setText("Epithet:");
53 txtSpEpithet
= new Text(parent
, SWT
.BORDER
);
54 final GridData gd_txtSpEpithet
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
55 txtSpEpithet
.setLayoutData(gd_txtSpEpithet
);
56 new Label(parent
, SWT
.NONE
);
58 final Button saveNameButton
= new Button(parent
, SWT
.NONE
);
60 saveNameButton
.addListener(SWT
.Selection
, new Listener() {
61 public void handleEvent(Event event
) {
62 new CreateNameAction(CreateNameView
.this.txtGenus
.getText(),
63 CreateNameView
.this.txtSpEpithet
.getText()).run();
67 final GridData gd_saveNameButton
= new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false);
68 saveNameButton
.setLayoutData(gd_saveNameButton
);
69 saveNameButton
.setText("Save Name");
74 * Passing the focus request to the viewer's control.
76 public void setFocus() {
78 private void initializeToolBar() {
79 IToolBarManager toolBarManager
= getViewSite().getActionBars().getToolBarManager();