4 package eu
.etaxonomy
.taxeditor
.local
.datasource
.wizard
;
6 import org
.eclipse
.swt
.SWT
;
7 import org
.eclipse
.swt
.layout
.GridData
;
8 import org
.eclipse
.swt
.layout
.GridLayout
;
9 import org
.eclipse
.swt
.widgets
.Group
;
10 import org
.eclipse
.swt
.widgets
.Label
;
11 import org
.eclipse
.swt
.widgets
.Text
;
13 import eu
.etaxonomy
.cdm
.database
.CdmDataSource
;
14 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
19 public class CdmDataSourcePostgreSQLServerWizardPage
extends
20 CdmDataSourceCredentialsWizardPage
{
22 private Text text_port
;
23 private Text text_server
;
25 private String server
;
30 protected CdmDataSourcePostgreSQLServerWizardPage(ICdmDataSource dataSource
) {
31 super("PostgreSQL Server", dataSource
);
32 setTitle("PostgreSQL Server");
33 setDescription("Enter credentials for PostgreSQL Server database");
38 * <p>Constructor for CdmDataSourcePostgreSQLServerWizardPage.</p>
40 * @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
41 * @param mode a {@link eu.etaxonomy.taxeditor.webapp.datasource.common.wizard.CdmDataSourceWizard.Mode} enum type.
43 protected CdmDataSourcePostgreSQLServerWizardPage(ICdmDataSource dataSource
, CdmDataSourceWizard
.Mode mode
) {
44 super("PostgreSQL Server", dataSource
, mode
);
45 setTitle("PostgreSQL Server");
46 setDescription("Enter credentials for PostgreSQL Server database");
51 public void createDatabaseForm() {
52 // Create group composite for location data
53 locationGroup
= new Group(composite
, SWT
.NONE
);
54 locationGroup
.setText("Location");
55 locationGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
56 GridLayout locationLayout
= new GridLayout();
57 locationLayout
.numColumns
= 2;
58 locationGroup
.setLayout(locationLayout
);
61 Label serverLabel
= new Label(locationGroup
, SWT
.NONE
);
62 serverLabel
.setText("Host:");
65 text_server
= new Text(locationGroup
, SWT
.BORDER
);
66 text_server
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
70 Label portLabel
= new Label(locationGroup
, SWT
.NONE
);
71 portLabel
.setText("Port:");
74 text_port
= new Text(locationGroup
, SWT
.BORDER
);
75 text_port
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
81 public void updateLocation() {
82 server
= text_server
.getText();
84 if(! text_port
.getText().equals("")){
85 port
= new Integer(text_port
.getText());
86 setErrorMessage(null);
88 }catch(NumberFormatException e
){
89 setErrorMessage("Port number contains invalid characters");
94 public void updateDataSource() {
97 ICdmDataSource dataSource
= getDataSource();
99 if(dataSource
== null) {
100 setDataSource(CdmDataSource
.NewPostgreSQLInstance(server
,
106 dataSource
.setName(name
);
107 dataSource
.setServer(server
);
108 dataSource
.setDatabase(database
);
109 dataSource
.setPort(port
);
110 dataSource
.setUsername(username
);
111 dataSource
.setPassword(password
);
119 if(getDataSource() != null){
121 text_server
.setText(getDataSource().getServer());
122 text_port
.setText(String
.valueOf(getDataSource().getPort()));
123 // add listeners after setting text to avoid the modify event being called
124 // for the initial value
130 private void addListeners() {
131 text_server
.addModifyListener(this);
132 text_port
.addModifyListener(this);
135 private void removeListeners() {
136 text_server
.removeModifyListener(this);
137 text_port
.removeModifyListener(this);