use of org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent in project jbosstools-hibernate by jbosstools.
the class HibernatePropertiesComposite method initializeLayout.
@Override
protected void initializeLayout(Composite container) {
GridLayout gl = new GridLayout(3, false);
container.setLayout(gl);
this.helper = new DriverClassHelpers();
final SimpleListValueModel<String> lvmDialect = new SimpleListValueModel<String>(Arrays.asList(this.helper.getDialectNames()));
PropertyValueModel<BasicHibernateProperties> p = (PropertyValueModel<BasicHibernateProperties>) getSubjectHolder();
List<String> drivers = new ArrayList<String>();
BasicHibernateProperties props = p.getValue();
if (props != null) {
String dialectClass = this.helper.getDialectClass(props.getDialect());
String[] driverClasses = this.helper.getDriverClasses(dialectClass);
drivers.addAll(Arrays.asList(driverClasses));
}
final SimpleListValueModel<String> lvmDriver = new SimpleListValueModel<String>(drivers);
List<String> urls = new ArrayList<String>();
if (props != null) {
String driverClass = props.getDriver();
String[] connectionURLS = this.helper.getConnectionURLS(driverClass);
urls.addAll(Arrays.asList(connectionURLS));
}
final SimpleListValueModel<String> lvmUrl = new SimpleListValueModel<String>(urls);
ModifiablePropertyValueModel<String> dialectHolder = buildDialectHolder();
final ModifiablePropertyValueModel<String> driverHolder = buildDriverHolder();
final ModifiablePropertyValueModel<String> urlHolder = buildUrlHolder();
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
this.addLabel(container, HibernateConsoleMessages.ConsoleConfigurationPropertySource_config_file + ':');
this.cfgFile = this.addText(container, buildConfigFileHolder());
Button b = this.addButton(container, HibernateConsoleMessages.CodeGenerationSettingsTab_setup, createSetupAction());
cfgFile.setLayoutData(gd);
// Button b = addButton(section, HibernateConsoleMessages.CodeGenerationSettingsTab_setup, createSetupAction());
// this.cfgFile = addLabeledText(container,
// HibernateConsoleMessages.ConsoleConfigurationPropertySource_config_file + ':', buildConfigFileHolder(),
// b, null);
gd = new GridData(GridData.FILL_HORIZONTAL);
this.addLabel(container, HibernateConsoleMessages.NewConfigurationWizardPage_database_dialect);
Control c = this.addEditableCombo(container, lvmDialect, dialectHolder, TransformerTools.<String>objectToStringTransformer(), (String) null);
gd.horizontalSpan = 2;
c.setLayoutData(gd);
// addLabeledEditableCombo(
// section,
// HibernateConsoleMessages.NewConfigurationWizardPage_database_dialect,
// lvmDialect,
// dialectHolder,
// StringConverter.Default.<String>instance(),
// null);
this.addLabel(container, HibernateConsoleMessages.NewConfigurationWizardPage_driver_class);
c = this.addEditableCombo(container, lvmDriver, driverHolder, TransformerTools.<String>objectToStringTransformer(), (String) null);
c.setLayoutData(gd);
// addLabeledEditableCombo(
// section,
// HibernateConsoleMessages.NewConfigurationWizardPage_driver_class,
// lvmDriver,
// driverHolder,
// StringConverter.Default.<String>instance(),
// null);
this.addLabel(container, HibernateConsoleMessages.NewConfigurationWizardPage_connection_url);
c = this.addEditableCombo(container, lvmUrl, urlHolder, TransformerTools.<String>objectToStringTransformer(), (String) null);
c.setLayoutData(gd);
// addLabeledEditableCombo(
// section,
// HibernateConsoleMessages.NewConfigurationWizardPage_connection_url,
// lvmUrl,
// urlHolder,
// StringConverter.Default.<String>instance(),
// null);
dialectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, SWTListenerTools.wrap(new PropertyChangeListener() {
@Override
public void propertyChanged(PropertyChangeEvent event) {
String dialectClass = HibernatePropertiesComposite.this.helper.getDialectClass((String) event.getNewValue());
String[] driverClasses = HibernatePropertiesComposite.this.helper.getDriverClasses(dialectClass);
// save value
String driver = driverHolder.getValue();
lvmDriver.clear();
lvmDriver.addAll(Arrays.asList(driverClasses));
// restore value
driverHolder.setValue(driver);
}
}));
driverHolder.addPropertyChangeListener(PropertyValueModel.VALUE, SWTListenerTools.wrap(new PropertyChangeListener() {
@Override
public void propertyChanged(PropertyChangeEvent event) {
String driverClass = (String) event.getNewValue();
String[] connectionURLS = HibernatePropertiesComposite.this.helper.getConnectionURLS(driverClass);
// save value
String url = urlHolder.getValue();
lvmUrl.clear();
lvmUrl.addAll(Arrays.asList(connectionURLS));
// restore value
urlHolder.setValue(url);
}
}));
this.addLabel(container, HibernateConsoleMessages.NewConfigurationWizardPage_default_schema);
c = this.addText(container, buildSchemaDefaultHolder());
c.setLayoutData(gd);
// addLabeledText(
// section,
// HibernateConsoleMessages.NewConfigurationWizardPage_default_schema,
// buildSchemaDefaultHolder());
this.addLabel(container, HibernateConsoleMessages.NewConfigurationWizardPage_default_catalog);
c = this.addText(container, buildCatalogDefaultHolder());
c.setLayoutData(gd);
// addLabeledText(
// section,
// HibernateConsoleMessages.NewConfigurationWizardPage_default_catalog,
// buildCatalogDefaultHolder());
this.addLabel(container, HibernateConsoleMessages.NewConfigurationWizardPage_user_name);
c = this.addText(container, buildUsernameHolder());
c.setLayoutData(gd);
// addLabeledText(
// section,
// HibernateConsoleMessages.NewConfigurationWizardPage_user_name,
// buildUsernameHolder());
this.addLabel(container, HibernateConsoleMessages.NewConfigurationWizardPage_password);
c = this.addText(container, buildPasswordHolder());
c.setLayoutData(gd);
// addLabeledText(
// section,
// HibernateConsoleMessages.NewConfigurationWizardPage_password,
// buildPasswordHolder());
}
Aggregations