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