+++ /dev/null
-/**
- *
- */
-package eu.etaxonomy.taxeditor.local.datasource.wizard;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-import eu.etaxonomy.cdm.database.CdmDataSource;
-import eu.etaxonomy.cdm.database.ICdmDataSource;
-
-/**
- * @author n.hoffmann
- */
-public class CdmDataSourcePostgreSQLServerWizardPage extends
- CdmDataSourceCredentialsWizardPage {
-
- private Text text_port;
- private Text text_server;
-
- private String server;
-
- private int port;
-
- @Deprecated
- protected CdmDataSourcePostgreSQLServerWizardPage(ICdmDataSource dataSource) {
- super("PostgreSQL Server", dataSource);
- setTitle("PostgreSQL Server");
- setDescription("Enter credentials for PostgreSQL Server database");
-
- }
-
- /**
- * <p>Constructor for CdmDataSourcePostgreSQLServerWizardPage.</p>
- *
- * @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
- * @param mode a {@link eu.etaxonomy.taxeditor.webapp.datasource.common.wizard.CdmDataSourceWizard.Mode} enum type.
- */
- protected CdmDataSourcePostgreSQLServerWizardPage(ICdmDataSource dataSource, CdmDataSourceWizard.Mode mode) {
- super("PostgreSQL Server", dataSource, mode);
- setTitle("PostgreSQL Server");
- setDescription("Enter credentials for PostgreSQL Server database");
-
- }
-
- @Override
- public void createDatabaseForm() {
- // Create group composite for location data
- locationGroup = new Group(composite, SWT.NONE);
- locationGroup.setText("Location");
- locationGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
- GridLayout locationLayout = new GridLayout();
- locationLayout.numColumns = 2;
- locationGroup.setLayout(locationLayout);
-
- // Create host label
- Label serverLabel = new Label(locationGroup, SWT.NONE);
- serverLabel.setText("Host:");
-
- // Create host input
- text_server = new Text(locationGroup, SWT.BORDER);
- text_server.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
-
- // Create port label
- Label portLabel = new Label(locationGroup, SWT.NONE);
- portLabel.setText("Port:");
-
- // Create port input
- text_port = new Text(locationGroup, SWT.BORDER);
- text_port.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
-
- }
-
- @Override
- public void updateLocation() {
- server = text_server.getText();
- try{
- if(! text_port.getText().equals("")){
- port = new Integer(text_port.getText());
- setErrorMessage(null);
- }
- }catch(NumberFormatException e){
- setErrorMessage("Port number contains invalid characters");
- }
- }
-
- @Override
- public void updateDataSource() {
-
-
- ICdmDataSource dataSource = getDataSource();
-
- if(dataSource == null) {
- setDataSource(CdmDataSource.NewPostgreSQLInstance(server,
- database,
- port,
- username,
- password));
- } else {
- dataSource.setName(name);
- dataSource.setServer(server);
- dataSource.setDatabase(database);
- dataSource.setPort(port);
- dataSource.setUsername(username);
- dataSource.setPassword(password);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void init() {
- super.init();
- if(getDataSource() != null){
- removeListeners();
- text_server.setText(getDataSource().getServer());
- text_port.setText(String.valueOf(getDataSource().getPort()));
- // add listeners after setting text to avoid the modify event being called
- // for the initial value
- addListeners();
- }
-
- }
-
- private void addListeners() {
- text_server.addModifyListener(this);
- text_port.addModifyListener(this);
- }
-
- private void removeListeners() {
- text_server.removeModifyListener(this);
- text_port.removeModifyListener(this);
- }
-
-}