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
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.layout
.GridData
;
17 import org
.eclipse
.swt
.layout
.GridLayout
;
18 import org
.eclipse
.swt
.widgets
.Group
;
19 import org
.eclipse
.swt
.widgets
.Label
;
20 import org
.eclipse
.swt
.widgets
.Text
;
22 import eu
.etaxonomy
.cdm
.database
.CdmDataSource
;
23 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
30 public class CdmDataSourceMySQLWizardPage
extends CdmDataSourceCredentialsWizardPage
{
33 private static final Logger logger
= Logger
34 .getLogger(CdmDataSourceMySQLWizardPage
.class);
36 private Text portText
;
37 private Text serverText
;
42 protected CdmDataSourceMySQLWizardPage(ICdmDataSource dataSource
) {
44 setTitle("Enter credentials for MySQL database");
45 this.dataSource
= dataSource
;
49 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#createDatabaseForm()
52 public void createDatabaseForm() {
53 logger
.warn("Creating");
55 // Create group composite for location data
56 locationGroup
= new Group(composite
, SWT
.NONE
);
57 locationGroup
.setText("Location");
58 locationGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
59 GridLayout locationLayout
= new GridLayout();
60 locationLayout
.numColumns
= 2;
61 locationGroup
.setLayout(locationLayout
);
64 Label serverLabel
= new Label(locationGroup
, SWT
.NONE
);
65 serverLabel
.setText("Host:");
68 serverText
= new Text(locationGroup
, SWT
.BORDER
);
69 serverText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
70 serverText
.addKeyListener(this);
73 Label portLabel
= new Label(locationGroup
, SWT
.NONE
);
74 portLabel
.setText("Port:");
77 portText
= new Text(locationGroup
, SWT
.BORDER
);
78 portText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
79 portText
.addKeyListener(this);
83 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#testDbConfiguration()
86 public void testDbConfiguration() {
87 ICdmDataSource dataSource
= CdmDataSource
.NewMySqlInstance(
88 getWizard().getServer(),
89 getWizard().getDatabase(),
90 getWizard().getPort(),
91 getWizard().getUsername(),
92 getWizard().getPassword()
95 dataSource
.testConnection();
96 MessageDialog
.openConfirm(parent
.getShell(), "Test successful", "Test successful");
98 MessageDialog
.openWarning(parent
.getShell(), "Test unsuccessful", "Test unsuccessful \n\n" + e
.getCause());
103 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#updateLocation()
106 public void updateLocation() {
107 getWizard().setServer(serverText
.getText());
108 int port
= new Integer(portText
.getText());
109 getWizard().setPort(port
);