(no commit message)
[taxeditor.git] / taxeditor-navigation / src / main / java / eu / etaxonomy / taxeditor / newWizards / NewClassificationWizardPage.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.newWizards;
12
13
14 import java.util.UUID;
15
16 import org.apache.log4j.Logger;
17 import org.eclipse.jface.wizard.WizardPage;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.custom.CLabel;
20 import org.eclipse.swt.events.ModifyEvent;
21 import org.eclipse.swt.events.ModifyListener;
22 import org.eclipse.swt.events.SelectionAdapter;
23 import org.eclipse.swt.events.SelectionEvent;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Button;
27 import org.eclipse.swt.widgets.Composite;
28 import org.eclipse.swt.widgets.Text;
29
30 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
31 import eu.etaxonomy.taxeditor.dialogs.filteredSelection.FilteredReferenceSelectionDialog;
32 import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
33
34 /**
35 * @author n.hoffmann
36 * @created 23.06.2009
37 * @version 1.0
38 */
39 public class NewClassificationWizardPage extends WizardPage implements ModifyListener {
40 private static final Logger logger = Logger
41 .getLogger(NewClassificationWizardPage.class);
42
43 private Text text_treeLabel;
44
45 private Text text_reference;
46
47 private Button button_browseReference;
48
49 private UUID referenceUuid;
50
51 private Text text_microReference;
52
53 /**
54 * @param pageName
55 */
56 protected NewClassificationWizardPage(String pageName) {
57 super(pageName);
58 this.setTitle("Classification");
59
60 this.setDescription("Create a new Classification.");
61 }
62
63 /* (non-Javadoc)
64 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
65 */
66 public void createControl(Composite parent) {
67
68 setPageComplete(false);
69
70 Composite composite = new Composite(parent, SWT.NONE);
71 GridLayout gridLayout = new GridLayout();
72 gridLayout.numColumns = 3;
73 composite.setLayout(gridLayout);
74
75 CLabel label_treeLabel = new CLabel(composite, SWT.NULL);
76 label_treeLabel.setText("Label:");
77
78 text_treeLabel = new Text(composite, SWT.BORDER);
79 text_treeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
80 text_treeLabel.addModifyListener(this);
81
82 // FIXME this is a rudimentary implementation. Add missing fields.
83
84 CLabel label_reference = new CLabel(composite, SWT.NULL);
85 label_reference.setText("Reference:");
86
87 text_reference = new Text(composite, SWT.BORDER);
88 text_reference.setEnabled(false);
89 text_reference.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
90
91 button_browseReference = new Button(composite, SWT.PUSH);
92 button_browseReference.setText("Browse...");
93 button_browseReference.addSelectionListener(new SelectionAdapter(){
94 /* (non-Javadoc)
95 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
96 */
97 @Override
98 public void widgetSelected(SelectionEvent e) {
99 logger.warn("Open reference search dialog");
100
101 ReferenceBase reference = FilteredReferenceSelectionDialog.selectReference(NavigationUtil.getShell(), null);
102
103 if (reference == null) {
104 return;
105 }
106
107 referenceUuid = reference.getUuid();
108
109 text_reference.setText(reference.getTitleCache());
110 }
111 });
112
113 CLabel label_microReference = new CLabel(composite, SWT.NULL);
114 label_microReference.setText("Reference Detail");
115
116 text_microReference = new Text(composite, SWT.BORDER);
117 text_microReference.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
118
119 setControl(composite);
120 }
121
122 /**
123 * @return the text_treeLabel
124 */
125 public String getTreeLabel() {
126 return text_treeLabel.getText();
127 }
128
129 /**
130 * @return
131 */
132 public String getMicroReference() {
133 return text_microReference.getText();
134 }
135
136 /* (non-Javadoc)
137 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
138 */
139 public void modifyText(ModifyEvent e) {
140 if(getTreeLabel().trim().length() > 0){
141 setPageComplete(true);
142 }
143 }
144
145 /**
146 * @return
147 */
148 public UUID getReferenceUuid() {
149 return referenceUuid;
150 }
151 }