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.store.datasource.wizard;
|
12
|
|
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;
|
21
|
|
22
|
import eu.etaxonomy.cdm.database.CdmDataSource;
|
23
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
24
|
|
25
|
/**
|
26
|
* @author n.hoffmann
|
27
|
* @created 19.05.2009
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class CdmDataSourceMySQLWizardPage extends CdmDataSourceCredentialsWizardPage {
|
31
|
|
32
|
|
33
|
private static final Logger logger = Logger
|
34
|
.getLogger(CdmDataSourceMySQLWizardPage.class);
|
35
|
|
36
|
private Text portText;
|
37
|
private Text serverText;
|
38
|
|
39
|
/**
|
40
|
* @param pageName
|
41
|
*/
|
42
|
protected CdmDataSourceMySQLWizardPage(ICdmDataSource dataSource) {
|
43
|
super("MySQL");
|
44
|
setTitle("Enter credentials for MySQL database");
|
45
|
this.dataSource = dataSource;
|
46
|
}
|
47
|
|
48
|
/* (non-Javadoc)
|
49
|
* @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#createDatabaseForm()
|
50
|
*/
|
51
|
@Override
|
52
|
public void createDatabaseForm() {
|
53
|
logger.warn("Creating");
|
54
|
|
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);
|
62
|
|
63
|
// Create host label
|
64
|
Label serverLabel = new Label(locationGroup, SWT.NONE);
|
65
|
serverLabel.setText("Host:");
|
66
|
|
67
|
// Create host input
|
68
|
serverText = new Text(locationGroup, SWT.BORDER);
|
69
|
serverText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
70
|
serverText.addKeyListener(this);
|
71
|
|
72
|
// Create port label
|
73
|
Label portLabel = new Label(locationGroup, SWT.NONE);
|
74
|
portLabel.setText("Port:");
|
75
|
|
76
|
// Create port input
|
77
|
portText = new Text(locationGroup, SWT.BORDER);
|
78
|
portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
79
|
portText.addKeyListener(this);
|
80
|
}
|
81
|
|
82
|
/* (non-Javadoc)
|
83
|
* @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#testDbConfiguration()
|
84
|
*/
|
85
|
@Override
|
86
|
public void testDbConfiguration() {
|
87
|
ICdmDataSource dataSource = CdmDataSource.NewMySqlInstance(
|
88
|
getWizard().getServer(),
|
89
|
getWizard().getDatabase(),
|
90
|
getWizard().getPort(),
|
91
|
getWizard().getUsername(),
|
92
|
getWizard().getPassword()
|
93
|
);
|
94
|
if (dataSource.testConnection()) {
|
95
|
MessageDialog.openConfirm(parent.getShell(), "Test successful", "Test successful");
|
96
|
} else {
|
97
|
MessageDialog.openWarning(parent.getShell(), "Test unsuccessful", "Test unsuccessful");
|
98
|
}
|
99
|
}
|
100
|
|
101
|
/* (non-Javadoc)
|
102
|
* @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#updateLocation()
|
103
|
*/
|
104
|
@Override
|
105
|
public void updateLocation() {
|
106
|
getWizard().setServer(serverText.getText());
|
107
|
int port = new Integer(portText.getText());
|
108
|
getWizard().setPort(port);
|
109
|
}
|
110
|
}
|