3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.datasource
.wizard
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.layout
.GridData
;
15 import org
.eclipse
.swt
.layout
.GridLayout
;
16 import org
.eclipse
.swt
.widgets
.Group
;
17 import org
.eclipse
.swt
.widgets
.Label
;
18 import org
.eclipse
.swt
.widgets
.Text
;
20 import eu
.etaxonomy
.cdm
.database
.CdmDataSource
;
21 import eu
.etaxonomy
.cdm
.database
.DatabaseTypeEnum
;
22 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
25 * <p>CdmDataSourceMySQLWizardPage class.</p>
31 public class CdmDataSourceMySQLWizardPage
extends CdmDataSourceCredentialsWizardPage
{
33 private Text text_port
;
34 private Text text_server
;
36 private String server
;
41 * <p>Constructor for CdmDataSourceMySQLWizardPage.</p>
43 * @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
45 protected CdmDataSourceMySQLWizardPage(ICdmDataSource dataSource
) {
47 setTitle("MySQL Server");
48 setDescription("Enter credentials for MySQL database");
49 this.setDataSource(dataSource
);
53 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#createDatabaseForm()
57 public void createDatabaseForm() {
58 // Create group composite for location data
59 locationGroup
= new Group(composite
, SWT
.NONE
);
60 locationGroup
.setText("Location");
61 locationGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
62 GridLayout locationLayout
= new GridLayout();
63 locationLayout
.numColumns
= 2;
64 locationGroup
.setLayout(locationLayout
);
67 Label serverLabel
= new Label(locationGroup
, SWT
.NONE
);
68 serverLabel
.setText("Host:");
71 text_server
= new Text(locationGroup
, SWT
.BORDER
);
72 text_server
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
73 text_server
.addModifyListener(this);
76 Label portLabel
= new Label(locationGroup
, SWT
.NONE
);
77 portLabel
.setText("Port:");
80 text_port
= new Text(locationGroup
, SWT
.BORDER
);
81 text_port
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
82 text_port
.addModifyListener(this);
87 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#updateLocation()
91 public void updateLocation() {
92 server
= text_server
.getText();
94 if(! text_port
.getText().equals("")){
95 port
= new Integer(text_port
.getText());
96 setErrorMessage(null);
98 }catch(NumberFormatException e
){
99 setErrorMessage("Port number contains invalid characters");
104 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#updateDataSource()
108 public void updateDataSource() {
109 setDataSource(CdmDataSource
.NewMySqlInstance(server
,
118 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#checkPageComplete()
122 public void checkPageComplete() {
123 // check if widgets of this component are complete
124 boolean complete
= server
.trim().length() != 0;
128 port
= DatabaseTypeEnum
.MySQL
.getDefaultPort();
131 setPageComplete(complete
);
133 // check if widgets of the extended class are complete
134 super.checkPageComplete();
138 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#init()
143 if(getDataSource() != null){
144 modifyTextWithoutTriggeringListeners(text_server
, this, getDataSource().getServer());
145 modifyTextWithoutTriggeringListeners(text_port
, this, getDataSource().getPort()+"");