4 package eu
.etaxonomy
.taxeditor
.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
;
20 public class CdmDataSourcePostgreSQLServerWizardPage
extends
21 CdmDataSourceCredentialsWizardPage
{
23 private Text text_port
;
24 private Text text_server
;
26 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 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#createDatabaseForm()
41 public void createDatabaseForm() {
42 // Create group composite for location data
43 locationGroup
= new Group(composite
, SWT
.NONE
);
44 locationGroup
.setText("Location");
45 locationGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
46 GridLayout locationLayout
= new GridLayout();
47 locationLayout
.numColumns
= 2;
48 locationGroup
.setLayout(locationLayout
);
51 Label serverLabel
= new Label(locationGroup
, SWT
.NONE
);
52 serverLabel
.setText("Host:");
55 text_server
= new Text(locationGroup
, SWT
.BORDER
);
56 text_server
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
60 Label portLabel
= new Label(locationGroup
, SWT
.NONE
);
61 portLabel
.setText("Port:");
64 text_port
= new Text(locationGroup
, SWT
.BORDER
);
65 text_port
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
71 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#updateLocation()
74 public void updateLocation() {
75 server
= text_server
.getText();
77 if(! text_port
.getText().equals("")){
78 port
= new Integer(text_port
.getText());
79 setErrorMessage(null);
81 }catch(NumberFormatException e
){
82 setErrorMessage("Port number contains invalid characters");
87 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#updateDataSource()
90 public void updateDataSource() {
93 ICdmDataSource dataSource
= getDataSource();
95 if(dataSource
== null) {
96 setDataSource(CdmDataSource
.NewPostgreSQLInstance(server
,
103 dataSource
.setName(name
);
104 dataSource
.setServer(server
);
105 dataSource
.setDatabase(database
);
106 dataSource
.setPort(port
);
107 dataSource
.setUsername(username
);
108 dataSource
.setPassword(password
);
109 dataSource
.setNomenclaturalCode(nomenclaturalCode
);
114 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#init()
120 if(getDataSource() != null){
122 text_server
.setText(getDataSource().getServer());
123 text_port
.setText(String
.valueOf(getDataSource().getPort()));
124 // add listeners after setting text to avoid the modify event being called
125 // for the initial value
131 private void addListeners() {
132 text_server
.addModifyListener(this);
133 text_port
.addModifyListener(this);
136 private void removeListeners() {
137 text_server
.removeModifyListener(this);
138 text_port
.removeModifyListener(this);