Revision 68c216b6
Added by Katja Luther about 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceTypeSelectionWizardPage.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
39 | 39 |
* @version 1.0 |
40 | 40 |
*/ |
41 | 41 |
public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements ModifyListener{ |
42 |
|
|
42 |
|
|
43 | 43 |
public static final DatabaseTypeEnum[] supportedDatabaseTypes = new DatabaseTypeEnum[]{ |
44 |
DatabaseTypeEnum.MySQL,
|
|
45 |
DatabaseTypeEnum.H2,
|
|
46 |
DatabaseTypeEnum.PostgreSQL
|
|
44 |
DatabaseTypeEnum.MySQL, |
|
45 |
DatabaseTypeEnum.H2, |
|
46 |
DatabaseTypeEnum.PostgreSQL |
|
47 | 47 |
/*DatabaseTypeEnum.SqlServer2005*/ |
48 | 48 |
}; |
49 |
|
|
50 |
|
|
49 |
|
|
50 |
|
|
51 | 51 |
private ArrayList<DatabaseTypeEnum> databaseTypes; |
52 |
|
|
52 |
|
|
53 | 53 |
private Text datasourceNameText; |
54 | 54 |
private String dataSourceName; |
55 | 55 |
private Combo databaseTypeCombo; |
56 |
|
|
56 |
|
|
57 | 57 |
private Composite composite; |
58 | 58 |
private Composite editDatasourceComposite; |
59 | 59 |
|
... | ... | |
61 | 61 |
|
62 | 62 |
private boolean dataBaseTypeSelected = false; |
63 | 63 |
private boolean dataSourceNameSet = false; |
64 |
|
|
64 |
|
|
65 | 65 |
private ICdmDataSource dataSource; |
66 | 66 |
|
67 | 67 |
private WizardPage nextPage; |
68 | 68 |
|
69 | 69 |
private CdmDataSourceCredentialsWizardPage credentialsWizardPage; |
70 |
|
|
70 |
|
|
71 | 71 |
/** |
72 | 72 |
* <p>Constructor for CdmDataSourceTypeSelectionWizardPage.</p> |
73 | 73 |
* |
... | ... | |
75 | 75 |
*/ |
76 | 76 |
public CdmDataSourceTypeSelectionWizardPage(ICdmDataSource dataSource) { |
77 | 77 |
super("DataSourceWizardPage"); |
78 |
|
|
78 |
|
|
79 | 79 |
this.dataSource = dataSource; |
80 |
|
|
80 |
|
|
81 | 81 |
String pageName = dataSource == null ? "Create New Datasource" : "Edit Existing Datasource"; |
82 |
|
|
82 |
|
|
83 | 83 |
setTitle(pageName); |
84 | 84 |
} |
85 | 85 |
|
... | ... | |
87 | 87 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
88 | 88 |
*/ |
89 | 89 |
/** {@inheritDoc} */ |
90 |
public void createControl(Composite parent) { |
|
90 |
@Override |
|
91 |
public void createControl(Composite parent) { |
|
91 | 92 |
|
92 | 93 |
setPageComplete(false); |
93 |
|
|
94 |
// Create top-level composite
|
|
94 |
|
|
95 |
// Create top-level composite |
|
95 | 96 |
composite = new Composite(parent, SWT.NONE); |
96 | 97 |
GridLayout gridLayout = new GridLayout(); |
97 | 98 |
gridLayout.numColumns = 1; |
... | ... | |
104 | 105 |
GridLayout datasourceLayout = new GridLayout(); |
105 | 106 |
datasourceLayout.numColumns = 2; |
106 | 107 |
editDatasourceComposite.setLayout(datasourceLayout); |
107 |
|
|
108 |
|
|
108 | 109 |
// Create label and input for dataSource name |
109 | 110 |
Label datasourceNameLabel = new Label(editDatasourceComposite, SWT.NONE); |
110 | 111 |
datasourceNameLabel.setText("Datasource Name:"); |
... | ... | |
112 | 113 |
datasourceNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
113 | 114 |
datasourceNameText.addModifyListener(this); |
114 | 115 |
|
115 |
// Create label and dropdown for database type
|
|
116 |
// Create label and dropdown for database type |
|
116 | 117 |
Label databaseTypeLabel = new Label(editDatasourceComposite, SWT.NONE); |
117 | 118 |
databaseTypeLabel.setText("Database Type:"); |
118 | 119 |
databaseTypeCombo = new Combo(editDatasourceComposite, SWT.BORDER | SWT.READ_ONLY); |
119 | 120 |
GridData comboLayout = new GridData(SWT.FILL, SWT.CENTER, false, false); |
120 | 121 |
databaseTypeCombo.setLayoutData(comboLayout); |
121 |
populateComboBoxItems();
|
|
122 |
|
|
122 |
populateComboBoxItems(); |
|
123 |
|
|
123 | 124 |
// Create listener to display database type-specific config options |
124 | 125 |
databaseTypeCombo.addSelectionListener(new SelectionAdapter() { |
125 |
public void widgetSelected(SelectionEvent e) { |
|
126 |
|
|
126 |
@Override |
|
127 |
public void widgetSelected(SelectionEvent e) { |
|
128 |
|
|
127 | 129 |
// Get database type at the selected index |
128 | 130 |
DatabaseTypeEnum type = databaseTypes.get(databaseTypeCombo.getSelectionIndex()); |
129 |
|
|
131 |
|
|
130 | 132 |
addDatabasePage(type); |
131 | 133 |
setDataBaseTypeSelected(true); |
132 | 134 |
checkPageComplete(); |
133 | 135 |
} |
134 | 136 |
}); |
135 |
|
|
137 |
|
|
136 | 138 |
// make the composite the wizard pages control |
137 | 139 |
setControl(composite); |
138 | 140 |
} |
139 |
|
|
141 |
|
|
140 | 142 |
private void populateComboBoxItems() { |
141 |
|
|
143 |
|
|
142 | 144 |
// Init DB types |
143 | 145 |
if (databaseTypes == null) { |
144 | 146 |
databaseTypes = new ArrayList<DatabaseTypeEnum>(); |
145 | 147 |
} |
146 |
|
|
148 |
|
|
147 | 149 |
// Add types to the type drop-down and to the types collection |
148 | 150 |
for (DatabaseTypeEnum type : supportedDatabaseTypes) { |
149 | 151 |
databaseTypeCombo.add(type.getName()); |
150 | 152 |
databaseTypes.add(type); |
151 | 153 |
} |
152 | 154 |
} |
153 |
|
|
155 |
|
|
154 | 156 |
/** |
155 | 157 |
* @param type |
156 | 158 |
*/ |
... | ... | |
158 | 160 |
// add credentials wizard page according to selection |
159 | 161 |
Wizard wizard = (Wizard) getWizard(); |
160 | 162 |
credentialsWizardPage = null; |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
163 | 165 |
if(type == DatabaseTypeEnum.H2){ |
164 | 166 |
credentialsWizardPage = new CdmDataSourceH2WizardPage(dataSource,CdmDataSourceWizard.Mode.CREATE); |
165 | 167 |
} |
... | ... | |
169 | 171 |
else if(type == DatabaseTypeEnum.PostgreSQL){ |
170 | 172 |
credentialsWizardPage = new CdmDataSourcePostgreSQLServerWizardPage(dataSource, CdmDataSourceWizard.Mode.CREATE); |
171 | 173 |
} |
172 |
|
|
174 |
|
|
173 | 175 |
// else if(type == DatabaseTypeEnum.SqlServer2005){ |
174 | 176 |
// credentialsWizardPage = new CdmDataSourceSQLServerWizardPage(dataSource); |
175 | 177 |
// } |
176 |
|
|
177 |
if(wizard.getPage(credentialsWizardPage.getName()) != null){ |
|
178 |
|
|
179 |
if(credentialsWizardPage != null && wizard.getPage(credentialsWizardPage.getName()) != null){
|
|
178 | 180 |
nextPage = (WizardPage) wizard.getPage(credentialsWizardPage.getName()); |
179 | 181 |
}else{ |
180 | 182 |
wizard.addPage(credentialsWizardPage); |
... | ... | |
198 | 200 |
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) |
199 | 201 |
*/ |
200 | 202 |
/** {@inheritDoc} */ |
201 |
public void modifyText(ModifyEvent e) { |
|
203 |
@Override |
|
204 |
public void modifyText(ModifyEvent e) { |
|
202 | 205 |
String name = datasourceNameText.getText(); |
203 |
|
|
206 |
|
|
204 | 207 |
if(name.length() == 0){ |
205 | 208 |
setDataSourceNameSet(false); |
206 | 209 |
setErrorMessage("DataSource name must not be empty."); |
... | ... | |
224 | 227 |
public void checkPageComplete() { |
225 | 228 |
boolean complete = isDataBaseTypeSelected(); |
226 | 229 |
complete &= isDataSourceNameSet(); |
227 |
|
|
230 |
|
|
228 | 231 |
setPageComplete(complete); |
229 | 232 |
} |
230 |
|
|
233 |
|
|
231 | 234 |
/** |
232 | 235 |
* <p>Getter for the field <code>dataSourceName</code>.</p> |
233 | 236 |
* |
... | ... | |
290 | 293 |
public NomenclaturalCode getNomenclaturalCode() { |
291 | 294 |
return nomenclaturalCode; |
292 | 295 |
} |
293 |
|
|
294 |
|
|
296 |
|
|
297 |
|
|
295 | 298 |
} |
Also available in: Unified diff
code cleaning