private int port;
+
+
/**
* <p>Constructor for CdmDataSourceMySQLWizardPage.</p>
*
* @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
*/
protected CdmDataSourceMySQLWizardPage(ICdmDataSource dataSource) {
- super("MySQL");
+ super("MySQL", dataSource, CdmDataSourceWizard.Mode.CREATE);
setTitle("MySQL Server");
setDescription("Enter credentials for MySQL database");
- this.setDataSource(dataSource);
+
+ }
+
+ /**
+ * <p>Constructor for CdmDataSourceMySQLWizardPage.</p>
+ *
+ * @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
+ */
+ protected CdmDataSourceMySQLWizardPage(ICdmDataSource dataSource, CdmDataSourceWizard.Mode mode) {
+ super("MySQL", dataSource, mode);
+ setTitle("MySQL Server");
+ setDescription("Enter credentials for MySQL database");
+
}
/* (non-Javadoc)
// 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));
+ locationGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 2));
GridLayout locationLayout = new GridLayout();
locationLayout.numColumns = 2;
locationGroup.setLayout(locationLayout);
// Create host input
text_server = new Text(locationGroup, SWT.BORDER);
text_server.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text_server.addModifyListener(this);
+
// Create port label
Label portLabel = new Label(locationGroup, SWT.NONE);
// Create port input
text_port = new Text(locationGroup, SWT.BORDER);
text_port.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text_port.addModifyListener(this);
+
}
*/
/** {@inheritDoc} */
@Override
- public void updateDataSource() {
- setDataSource(CdmDataSource.NewMySqlInstance(server,
- database,
- port,
- username,
- password,
- nomenclaturalCode));
+ public void updateDataSource() {
+ ICdmDataSource dataSource = getDataSource();
+
+ if(dataSource == null) {
+ setDataSource(CdmDataSource.NewMySqlInstance(server,
+ database,
+ port,
+ username,
+ password,
+ nomenclaturalCode));
+ } else {
+ dataSource.setName(name);
+ dataSource.setServer(server);
+ dataSource.setDatabase(database);
+ dataSource.setPort(port);
+ dataSource.setUsername(username);
+ dataSource.setPassword(password);
+ dataSource.setNomenclaturalCode(nomenclaturalCode);
+ }
}
/* (non-Javadoc)
/** {@inheritDoc} */
@Override
public void init() {
+ super.init();
if(getDataSource() != null){
- modifyTextWithoutTriggeringListeners(text_server, this, getDataSource().getServer());
- modifyTextWithoutTriggeringListeners(text_port, this, getDataSource().getPort()+"");
- super.init();
+ 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);
}
}