Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorkmoore2009-04-17 18:30:06 +0000
committerkmoore2009-04-17 18:30:06 +0000
commite4ccfd158f0908c0edb71310f67c7b00c335d234 (patch)
tree20b9625a607bd9f79c23c3dbe2aa19ed542f4671 /jpa
parent92f0e5c8bc89722961261c3c17237173769859f2 (diff)
downloadwebtools.dali-e4ccfd158f0908c0edb71310f67c7b00c335d234.tar.gz
webtools.dali-e4ccfd158f0908c0edb71310f67c7b00c335d234.tar.xz
webtools.dali-e4ccfd158f0908c0edb71310f67c7b00c335d234.zip
230396 - changing spinners to combos with a default option that only accept integers
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java160
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/DefaultCacheSizeComposite.java153
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMaxComposite.java154
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMinComposite.java155
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMaxComposite.java157
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMinComposite.java155
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java413
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java147
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java330
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmGeneratorComposite.java272
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmSequenceGeneratorComposite.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmTableGeneratorComposite.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/IntegerCombo.java182
15 files changed, 714 insertions, 1649 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java
index 501c5c17f9..68a0528a1d 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/CacheSizeComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2009 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,24 +11,17 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.caching;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* CacheSizeComposite
*/
-@SuppressWarnings("nls")
public class CacheSizeComposite extends Pane<EntityCacheProperties>
{
/**
@@ -45,125 +38,62 @@ public class CacheSizeComposite extends Pane<EntityCacheProperties>
super(parentComposite, parent);
}
- private WritablePropertyValueModel<Integer> buildCacheSizeHolder() {
- return new PropertyAspectAdapter<EntityCacheProperties, Integer>(getSubjectHolder(), EntityCacheProperties.CACHE_SIZE_PROPERTY) {
+ @Override
+ protected void initializeLayout(Composite container) {
+ addCacheSizeCombo(container);
+ }
+
+ private void addCacheSizeCombo(Composite container) {
+ new IntegerCombo<EntityCacheProperties>(this, container) {
+
@Override
- protected Integer buildValue_() {
- Integer value = subject.getCacheSize();
- if (value == null) {
- value = -1;
- }
- return value;
+ protected String getLabelText() {
+ return EclipseLinkUiMessages.CacheSizeComposite_cacheSize;
}
-
+
@Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setCacheSize(value);
+ protected String getHelpId() {
+ return null;
}
- };
- }
-
- private PropertyValueModel<Caching> buildCachingHolder() {
- return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) {
+
@Override
- protected Caching transform_(EntityCacheProperties value) {
- return value.getCaching();
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Caching, Integer>(buildCachingHolder(), Caching.CACHE_SIZE_DEFAULT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ Integer value = this.subject.getCacheSizeDefault();
+ if (value == null) {
+ value = this.subject.getDefaultCacheSizeDefault();
+ }
+ return value;
+ }
+ };
}
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultCacheSizeHolder() {
- return new PropertyAspectAdapter<Caching, Integer>(buildCachingHolder(), Caching.CACHE_SIZE_DEFAULT_PROPERTY) {
+
@Override
- protected Integer buildValue_() {
- Integer value = subject.getCacheSizeDefault();
- if (value == null) {
- value = subject.getDefaultCacheSizeDefault();
- }
- return value;
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<EntityCacheProperties, Integer>(getSubjectHolder(), EntityCacheProperties.CACHE_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getCacheSize();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setCacheSize(value);
+ }
+ };
}
};
}
-
- private Control addDefaultCacheSizeLabel(Composite container) {
-
- Label label = addLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultCacheSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultCacheSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultCacheSizeHolder()) {
-
+
+ private PropertyValueModel<Caching> buildCachingHolder() {
+ return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) {
@Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
+ protected Caching transform_(EntityCacheProperties value) {
+ return value.getCaching();
}
};
}
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.addLabeledSpinner(
- container,
- EclipseLinkUiMessages.CacheSizeComposite_cacheSize,
- this.buildCacheSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.addDefaultCacheSizeLabel(container),
- null
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/DefaultCacheSizeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/DefaultCacheSizeComposite.java
index 69b62b3378..8c95e467e9 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/DefaultCacheSizeComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/DefaultCacheSizeComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2009 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,24 +11,16 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.caching;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.Caching;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* CacheSizeComposite
*/
-@SuppressWarnings("nls")
public class DefaultCacheSizeComposite extends Pane<Caching>
{
/**
@@ -45,125 +37,50 @@ public class DefaultCacheSizeComposite extends Pane<Caching>
super(parentComposite, parent);
}
- private WritablePropertyValueModel<Integer> buildCacheSizeHolder() {
- return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder(), Caching.CACHE_SIZE_DEFAULT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getCacheSizeDefault();
- if (value == null) {
- value = -1;
- }
- return value;
- }
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setCacheSizeDefault(value);
- }
- };
+ @Override
+ protected void initializeLayout(Composite container) {
+ addDefaultCacheSizeCombo(container);
}
-
- private PropertyValueModel<Integer> buildDefaultCacheSizeHolder() {
- return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder(), "") {
+
+ private void addDefaultCacheSizeCombo(Composite container) {
+ new IntegerCombo<Caching>(this, container) {
+
@Override
- protected Integer buildValue_() {
- return subject.getDefaultCacheSizeDefault();
+ protected String getLabelText() {
+ return EclipseLinkUiMessages.DefaultCacheSizeComposite_defaultCacheSize;
}
-
+
@Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
+ protected String getHelpId() {
+ return null;
}
- };
- }
-
- private Control addDefaultCacheSizeLabel(Composite container) {
-
- Label label = addLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultCacheSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultCacheSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultCacheSizeHolder()) {
@Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultCacheSizeDefault();
+ }
+ };
}
+
+ @Override
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Caching, Integer>(getSubjectHolder(), Caching.CACHE_SIZE_DEFAULT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getCacheSizeDefault();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setCacheSizeDefault(value);
+ }
+ }; }
};
}
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.addLabeledSpinner(
- container,
- EclipseLinkUiMessages.DefaultCacheSizeComposite_defaultCacheSize,
- this.buildCacheSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.addDefaultCacheSizeLabel(container),
- null
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMaxComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMaxComposite.java
index fcb1449a2b..35a1b3c934 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMaxComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMaxComposite.java
@@ -11,24 +11,16 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.connection;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.connection.Connection;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* JdbcReadConnectionsMaxComposite
*/
-@SuppressWarnings("nls")
public class JdbcReadConnectionsMaxComposite extends Pane<Connection>
{
/**
@@ -45,125 +37,49 @@ public class JdbcReadConnectionsMaxComposite extends Pane<Connection>
super(parentComposite, parent);
}
- private WritablePropertyValueModel<Integer> buildReadConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.READ_CONNECTIONS_MAX_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getReadConnectionsMax();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
+ @Override
+ protected void initializeLayout(Composite container) {
+ addReadConnectionsMaxCombo(container);
+ }
+
+ private void addReadConnectionsMaxCombo(Composite container) {
+ new IntegerCombo<Connection>(this, container) {
+
@Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setReadConnectionsMax(value);
+ protected String getLabelText() {
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMaxLabel;
}
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultReadConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+
@Override
- protected Integer buildValue_() {
- return subject.getDefaultReadConnectionsMax();
+ protected String getHelpId() {
+ return null;
}
-
+
@Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultReadConnectionsMax();
+ }
+ };
}
- };
- }
-
- private Control addDefaultReadConnectionsMaxLabel(Composite container) {
-
- Label label = addLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultReadConnectionsMaxLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultReadConnectionsMaxLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultReadConnectionsMaxHolder()) {
-
+
@Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.READ_CONNECTIONS_MAX_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getReadConnectionsMax();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setReadConnectionsMax(value);
+ }
+ };
}
};
}
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.addLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMaxLabel,
- this.buildReadConnectionsMaxHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.addDefaultReadConnectionsMaxLabel(container),
- null
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMinComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMinComposite.java
index c11485f8b5..03fef1d4f5 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMinComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcReadConnectionsMinComposite.java
@@ -11,24 +11,16 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.connection;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.connection.Connection;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* JdbcReadConnectionsMinComposite
*/
-@SuppressWarnings("nls")
public class JdbcReadConnectionsMinComposite extends Pane<Connection>
{
/**
@@ -45,125 +37,48 @@ public class JdbcReadConnectionsMinComposite extends Pane<Connection>
super(parentComposite, parent);
}
- private WritablePropertyValueModel<Integer> buildReadConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.READ_CONNECTIONS_MIN_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getReadConnectionsMin();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
+ @Override
+ protected void initializeLayout(Composite container) {
+ addReadConnectionsMinCombo(container);
+ }
+
+ private void addReadConnectionsMinCombo(Composite container) {
+ new IntegerCombo<Connection>(this, container) {
+
@Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setReadConnectionsMin(value);
+ protected String getLabelText() {
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMinLabel;
}
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultReadConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+
@Override
- protected Integer buildValue_() {
- return subject.getDefaultReadConnectionsMin();
+ protected String getHelpId() {
+ return null;
}
-
+
@Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultReadConnectionsMin();
+ }
+ };
}
- };
- }
-
- private Control addDefaultReadConnectionsMinLabel(Composite container) {
-
- Label label = addLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultReadConnectionsMinLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultReadConnectionsMinLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultReadConnectionsMinHolder()) {
-
+
@Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.READ_CONNECTIONS_MIN_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getReadConnectionsMin();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setReadConnectionsMin(value);
+ }
+ };
}
};
}
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.addLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMinLabel,
- this.buildReadConnectionsMinHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.addDefaultReadConnectionsMinLabel(container),
- null
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMaxComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMaxComposite.java
index f92224528b..48504665c2 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMaxComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMaxComposite.java
@@ -11,24 +11,16 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.connection;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.connection.Connection;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* JdbcWriteConnectionsMaxComposite
*/
-@SuppressWarnings("nls")
public class JdbcWriteConnectionsMaxComposite extends Pane<Connection>
{
/**
@@ -44,126 +36,49 @@ public class JdbcWriteConnectionsMaxComposite extends Pane<Connection>
super(parentComposite, parent);
}
-
- private WritablePropertyValueModel<Integer> buildWriteConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.WRITE_CONNECTIONS_MAX_PROPERTY) {
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ addWriteConnectionsMaxCombo(container);
+ }
+
+ private void addWriteConnectionsMaxCombo(Composite container) {
+ new IntegerCombo<Connection>(this, container) {
+
@Override
- protected Integer buildValue_() {
- Integer value = subject.getWriteConnectionsMax();
-
- if (value == null) {
- value = -1;
- }
- return value;
+ protected String getLabelText() {
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMaxLabel;
}
-
+
@Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setWriteConnectionsMax(value);
+ protected String getHelpId() {
+ return null;
}
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultWriteConnectionsMaxHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+
@Override
- protected Integer buildValue_() {
- return subject.getDefaultWriteConnectionsMax();
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultWriteConnectionsMax();
+ }
+ };
}
-
+
@Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.WRITE_CONNECTIONS_MAX_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getWriteConnectionsMax();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setWriteConnectionsMax(value);
+ }
+ };
}
};
}
-
- private Control addDefaultWriteConnectionsMaxLabel(Composite container) {
-
- Label label = addLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultWriteConnectionsMaxLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultWriteConnectionsMaxLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultWriteConnectionsMaxHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.addLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMaxLabel,
- this.buildWriteConnectionsMaxHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.addDefaultWriteConnectionsMaxLabel(container),
- null
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMinComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMinComposite.java
index 4f4d7e4076..b7bcd44b5c 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMinComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/connection/JdbcWriteConnectionsMinComposite.java
@@ -11,24 +11,16 @@ package org.eclipse.jpt.eclipselink.ui.internal.persistence.connection;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.connection.Connection;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* JdbcWriteConnectionsMinComposite
*/
-@SuppressWarnings("nls")
public class JdbcWriteConnectionsMinComposite extends Pane<Connection>
{
/**
@@ -45,125 +37,48 @@ public class JdbcWriteConnectionsMinComposite extends Pane<Connection>
super(parentComposite, parent);
}
- private WritablePropertyValueModel<Integer> buildWriteConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.WRITE_CONNECTIONS_MIN_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getWriteConnectionsMin();
-
- if (value == null) {
- value = -1;
- }
- return value;
- }
-
+ @Override
+ protected void initializeLayout(Composite container) {
+ addWriteConnectionsMinCombo(container);
+ }
+
+ private void addWriteConnectionsMinCombo(Composite container) {
+ new IntegerCombo<Connection>(this, container) {
+
@Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setWriteConnectionsMin(value);
+ protected String getLabelText() {
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMinLabel;
}
- };
- }
-
- private PropertyValueModel<Integer> buildDefaultWriteConnectionsMinHolder() {
- return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+
@Override
- protected Integer buildValue_() {
- return subject.getDefaultWriteConnectionsMin();
+ protected String getHelpId() {
+ return null;
}
-
+
@Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultWriteConnectionsMin();
+ }
+ };
}
- };
- }
-
- private Control addDefaultWriteConnectionsMinLabel(Composite container) {
-
- Label label = addLabel(
- container,
- EclipseLinkUiMessages.DefaultWithoutValue
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultWriteConnectionsMinLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultWriteConnectionsMinLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultWriteConnectionsMinHolder()) {
-
+
@Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(EclipseLinkUiMessages.DefaultWithValue, value);
- }
-
- return "";
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.WRITE_CONNECTIONS_MIN_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getWriteConnectionsMin();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setWriteConnectionsMin(value);
+ }
+ };
}
};
}
-
- @Override
- protected void initializeLayout(Composite container) {
-
- Spinner spinner = this.addLabeledSpinner(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMinLabel,
- this.buildWriteConnectionsMinHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- this.addDefaultWriteConnectionsMinLabel(container),
- null
- );
-
- updateGridData(container, spinner);
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
index 5fd6358941..76215f2ffb 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2009 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -11,6 +11,7 @@ package org.eclipse.jpt.ui.internal.mappings.details;
import java.util.Collection;
import java.util.Iterator;
+
import org.eclipse.jpt.core.context.BaseColumn;
import org.eclipse.jpt.core.context.Column;
import org.eclipse.jpt.core.context.NamedColumn;
@@ -19,9 +20,9 @@ import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.mappings.db.ColumnCombo;
import org.eclipse.jpt.ui.internal.mappings.db.DatabaseObjectCombo;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.mappings.db.TableCombo;
import org.eclipse.jpt.ui.internal.widgets.FormPane;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
@@ -29,11 +30,7 @@ import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueM
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* Here the layout of this pane:
@@ -203,169 +200,7 @@ public class ColumnComposite extends FormPane<Column> {
}
};
}
-
- private WritablePropertyValueModel<Integer> buildDefaultLengthHolder() {
- return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.DEFAULT_LENGTH_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return Integer.valueOf(this.subject.getDefaultLength());
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control addDefaultLengthLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultLengthLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultLengthLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultLengthHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- int defaultValue = (getSubject() != null) ? getSubject().getDefaultLength() :
- Column.DEFAULT_LENGTH;
-
- return NLS.bind(
- JptUiMappingsMessages.DefaultWithOneParam,
- Integer.valueOf(defaultValue)
- );
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildDefaultPrecisionHolder() {
- return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.DEFAULT_PRECISION_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return Integer.valueOf(this.subject.getDefaultPrecision());
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control addDefaultPrecisionLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultPrecisionLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultPrecisionLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultPrecisionHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- int defaultValue = (getSubject() != null) ? getSubject().getDefaultPrecision() :
- Column.DEFAULT_PRECISION;
-
- return NLS.bind(
- JptUiMappingsMessages.DefaultWithOneParam,
- Integer.valueOf(defaultValue)
- );
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildDefaultScaleHolder() {
- return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.DEFAULT_SCALE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return Integer.valueOf(this.subject.getDefaultScale());
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private Control addDefaultScaleLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultScaleLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultScaleLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultScaleHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- int defaultValue = (getSubject() != null) ? getSubject().getDefaultScale() :
- Column.DEFAULT_SCALE;
-
- return NLS.bind(
- JptUiMappingsMessages.DefaultWithOneParam,
- Integer.valueOf(defaultValue)
- );
- }
- };
- }
-
+
private WritablePropertyValueModel<Boolean> buildInsertableHolder() {
return new PropertyAspectAdapter<Column, Boolean>(getSubjectHolder(), BaseColumn.SPECIFIED_INSERTABLE_PROPERTY) {
@Override
@@ -404,22 +239,6 @@ public class ColumnComposite extends FormPane<Column> {
};
}
- private WritablePropertyValueModel<Integer> buildLengthHolder() {
- return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_LENGTH_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedLength();
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedLength(value);
- }
- };
- }
private WritablePropertyValueModel<Boolean> buildNullableHolder() {
return new PropertyAspectAdapter<Column, Boolean>(
@@ -473,40 +292,6 @@ public class ColumnComposite extends FormPane<Column> {
};
}
- private WritablePropertyValueModel<Integer> buildPrecisionHolder() {
- return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_PRECISION_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedPrecision();
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedPrecision(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildScaleHolder() {
- return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_SCALE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedScale();
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedScale(value);
- }
- };
- }
-
private Pane<Column> addTableCombo(Composite container) {
return new DatabaseObjectCombo<Column>(this, container) {
@@ -688,6 +473,7 @@ public class ColumnComposite extends FormPane<Column> {
}
protected class DetailsComposite extends FormPane<Column> {
+
public DetailsComposite(FormPane<?> parentPane,
PropertyValueModel<? extends Column> subjectHolder,
Composite parent) {
@@ -734,47 +520,9 @@ public class ColumnComposite extends FormPane<Column> {
JpaHelpContextIds.MAPPING_COLUMN_NULLABLE
);
- // Length widgets
- Spinner lengthSpinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.ColumnComposite_length,
- buildLengthHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultLengthLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_LENGTH
- );
-
- updateGridData(container, lengthSpinner);
-
- // Precision widgets
- Spinner precisionSpinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.ColumnComposite_precision,
- buildPrecisionHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultPrecisionLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_PRECISION
- );
-
- updateGridData(container, precisionSpinner);
-
- // Scale widgets
- Spinner scaleSpinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.ColumnComposite_scale,
- buildScaleHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultScaleLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_SCALE
- );
-
- updateGridData(container, scaleSpinner);
+ addLengthCombo(container);
+ addPrecisionCombo(container);
+ addScaleCombo(container);
// Column Definition widgets
addLabeledText(
@@ -783,36 +531,125 @@ public class ColumnComposite extends FormPane<Column> {
buildColumnDefinitionHolder()
);
}
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
- Control[] controls = paneContainer.getChildren();
+ private void addLengthCombo(Composite container) {
+ new IntegerCombo<Column>(this, container) {
+
+ @Override
+ protected String getLabelText() {
+ return JptUiMappingsMessages.ColumnComposite_length;
+ }
+
+ @Override
+ protected String getHelpId() {
+ return JpaHelpContextIds.MAPPING_COLUMN_LENGTH;
+ }
+
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.DEFAULT_LENGTH_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultLength());
+ }
+ };
+ }
+
+ @Override
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_LENGTH_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedLength();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setSpecifiedLength(value);
+ }
+ };
+ }
+ };
+ }
+
+ private void addPrecisionCombo(Composite container) {
+ new IntegerCombo<Column>(this, container) {
+
+ @Override
+ protected String getLabelText() {
+ return JptUiMappingsMessages.ColumnComposite_precision;
+ }
+
+ @Override
+ protected String getHelpId() {
+ return JpaHelpContextIds.MAPPING_COLUMN_PRECISION;
+ }
+
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.DEFAULT_PRECISION_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultPrecision());
+ }
+ };
+ }
+
+ @Override
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_PRECISION_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedPrecision();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setSpecifiedPrecision(value);
+ }
+ };
+ }
+ };
+ }
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
+ private void addScaleCombo(Composite container) {
+ new IntegerCombo<Column>(this, container) {
+
+ @Override
+ protected String getLabelText() {
+ return JptUiMappingsMessages.ColumnComposite_scale;
+ }
+
+ @Override
+ protected String getHelpId() {
+ return JpaHelpContextIds.MAPPING_COLUMN_SCALE;
+ }
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.DEFAULT_SCALE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultScale());
+ }
+ };
+ }
+
+ @Override
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Column, Integer>(getSubjectHolder(), Column.SPECIFIED_SCALE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedScale();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setSpecifiedScale(value);
+ }
+ };
+ }
+ };
}
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java
index 629c39f509..0da085e50b 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/DiscriminatorColumnComposite.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.ui.internal.mappings.details;
import java.util.Collection;
+
import org.eclipse.jpt.core.context.DiscriminatorColumn;
import org.eclipse.jpt.core.context.DiscriminatorType;
import org.eclipse.jpt.core.context.Entity;
@@ -18,22 +19,15 @@ import org.eclipse.jpt.db.Table;
import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.mappings.db.ColumnCombo;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
import org.eclipse.jpt.ui.internal.util.PaneEnabler;
import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
import org.eclipse.jpt.ui.internal.widgets.FormPane;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* Here the layout of this pane:
@@ -253,18 +247,7 @@ public class DiscriminatorColumnComposite<T extends Entity> extends FormPane<T>
@Override
protected void initializeLayout(Composite container) {
// Length widgets
- Spinner lengthSpinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.ColumnComposite_length,
- buildLengthHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultLengthLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_LENGTH
- );
-
- updateGridData(container, lengthSpinner);
+ addLengthCombo(container);
// Column Definition widgets
addLabeledText(
@@ -273,79 +256,47 @@ public class DiscriminatorColumnComposite<T extends Entity> extends FormPane<T>
buildColumnDefinitionHolder(getSubjectHolder())
);
}
-
- private WritablePropertyValueModel<Integer> buildLengthHolder() {
-
- return new PropertyAspectAdapter<DiscriminatorColumn, Integer>(getSubjectHolder(), DiscriminatorColumn.SPECIFIED_LENGTH_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedLength();
- }
-
+
+ private void addLengthCombo(Composite container) {
+ new IntegerCombo<DiscriminatorColumn>(this, container) {
+
@Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedLength(value);
+ protected String getLabelText() {
+ return JptUiMappingsMessages.ColumnComposite_length;
}
- };
- }
-
- private Control addDefaultLengthLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultLengthLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultLengthLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultLengthHolder()) {
-
+
@Override
- protected String transform(Integer value) {
-
- int defaultValue = (getSubject() != null) ? getSubject().getDefaultLength() :
- DiscriminatorColumn.DEFAULT_LENGTH;
-
- return NLS.bind(
- JptUiMappingsMessages.DefaultWithOneParam,
- Integer.valueOf(defaultValue)
- );
+ protected String getHelpId() {
+ return JpaHelpContextIds.MAPPING_COLUMN_LENGTH;
}
- };
- }
- private WritablePropertyValueModel<Integer> buildDefaultLengthHolder() {
- return new PropertyAspectAdapter<DiscriminatorColumn, Integer>(getSubjectHolder(), DiscriminatorColumn.DEFAULT_LENGTH_PROPERTY) {
@Override
- protected Integer buildValue_() {
- return Integer.valueOf(this.subject.getDefaultLength());
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<DiscriminatorColumn, Integer>(getSubjectHolder(), DiscriminatorColumn.DEFAULT_LENGTH_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultLength());
+ }
+ };
}
-
+
@Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.valueOf(Integer.MIN_VALUE), newValue);
- }
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<DiscriminatorColumn, Integer>(getSubjectHolder(), DiscriminatorColumn.SPECIFIED_LENGTH_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedLength();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setSpecifiedLength(value);
+ }
+ };
}
};
}
-
+
private WritablePropertyValueModel<String> buildColumnDefinitionHolder(PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder) {
return new PropertyAspectAdapter<DiscriminatorColumn, String>(discriminatorColumnHolder, NamedColumn.COLUMN_DEFINITION_PROPERTY) {
@@ -363,37 +314,5 @@ public class DiscriminatorColumnComposite<T extends Entity> extends FormPane<T>
}
};
}
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
-
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
index d67774b8e1..21d670e1d0 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
@@ -13,19 +13,12 @@ import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.context.Generator;
import org.eclipse.jpt.core.context.GeneratorHolder;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
* This is the generic pane for a generator.
@@ -38,7 +31,6 @@ import org.eclipse.swt.widgets.Spinner;
* @version 2.0
* @since 1.0
*/
-@SuppressWarnings("nls")
public abstract class GeneratorComposite<T extends Generator> extends Pane<GeneratorHolder>
{
private PropertyValueModel<Generator> generatorHolder;
@@ -78,142 +70,6 @@ public abstract class GeneratorComposite<T extends Generator> extends Pane<Gener
*/
protected abstract T getGenerator(GeneratorHolder subject);
- private WritablePropertyValueModel<Integer> buildAllocationSizeHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(this.generatorHolder, Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getSpecifiedAllocationSize();
- if (value == null) {
- return -1;
- }
- return value;
- }
-
- @Override
- public void setValue(Integer value) {
- if (subject != null) {
- setValue_(value);
- return;
- }
- if (value == -1) {
- return;
- }
- retrieveGenerator(getSubject()).setSpecifiedAllocationSize(value);
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setSpecifiedAllocationSize(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildDefaultAllocationSizeHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(this.generatorHolder, Generator.DEFAULT_ALLOCATION_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultAllocationSize();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control addDefaultAllocationSizeLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultAllocationSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultAllocationSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultAllocationSizeHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(JptUiMappingsMessages.DefaultWithOneParam, value);
- }
-
- return "";
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildDefaultInitialValueHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(this.generatorHolder, Generator.DEFAULT_INITIAL_VALUE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return subject.getDefaultInitialValue();
- }
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control addDefaultInitialValueLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultInitialValueLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultInitialValueLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultInitialValueHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(JptUiMappingsMessages.DefaultWithOneParam, value);
- }
-
- return "";
- }
- };
- }
/**
* Creates the new <code>IGenerator</code>.
@@ -227,12 +83,12 @@ public abstract class GeneratorComposite<T extends Generator> extends Pane<Gener
return new PropertyAspectAdapter<Generator, String>(this.generatorHolder, Generator.NAME_PROPERTY) {
@Override
protected String buildValue_() {
- return subject.getName();
+ return this.subject.getName();
}
@Override
public void setValue(String value) {
- if (subject != null) {
+ if (this.subject != null) {
setValue_(value);
return;
}
@@ -247,42 +103,7 @@ public abstract class GeneratorComposite<T extends Generator> extends Pane<Gener
if (value.length() == 0) {
value = null;
}
- subject.setName(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildInitialValueHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(this.generatorHolder, Generator.SPECIFIED_INITIAL_VALUE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- Integer value = subject.getSpecifiedInitialValue();
-
- if (value == null) {
- return -1;
- }
-
- return value;
- }
-
- @Override
- public void setValue(Integer value) {
- if (subject != null) {
- setValue_(value);
- return;
- }
- if (value == -1) {
- return;
- }
- retrieveGenerator(getSubject()).setSpecifiedInitialValue(value);
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setSpecifiedInitialValue(value);
+ this.subject.setName(value);
}
};
}
@@ -297,51 +118,84 @@ public abstract class GeneratorComposite<T extends Generator> extends Pane<Gener
return (this.getSubject() == null) ? null : this.getGenerator(this.getSubject());
}
- /**
- * Creates the labeled spinner responsible to edit the allocation size. The
- * default value will be shown after the spinner. A value of -1 means the
- * default value and the model has <code>null</code>.
- *
- * @param container The parent container
- */
- protected void initializeAllocationSizeWidgets(Composite container) {
+ protected void addAllocationSizeCombo(Composite container) {
+ new IntegerCombo<Generator>(this, this.generatorHolder, container) {
+
+ @Override
+ protected String getLabelText() {
+ return JptUiMappingsMessages.GeneratorComposite_allocationSize;
+ }
+
+ @Override
+ protected String getHelpId() {
+ return null;//JpaHelpContextIds.MAPPING_COLUMN_LENGTH;
+ }
- Spinner spinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.GeneratorComposite_allocationSize,
- buildAllocationSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultAllocationSizeLabel(container),
- null
- );
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_ALLOCATION_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultAllocationSize());
+ }
+ };
+ }
+
+ @Override
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedAllocationSize();
+ }
- updateGridData(container, spinner);
+ @Override
+ public void setValue(Integer value) {
+ retrieveGenerator(GeneratorComposite.this.getSubject()).setSpecifiedAllocationSize(value);
+ }
+ };
+ }
+ };
}
+
+ protected void addInitialValueCombo(Composite container) {
+ new IntegerCombo<Generator>(this, this.generatorHolder, container) {
+
+ @Override
+ protected String getLabelText() {
+ return JptUiMappingsMessages.GeneratorComposite_initialValue;
+ }
+
+ @Override
+ protected String getHelpId() {
+ return null;//JpaHelpContextIds.MAPPING_COLUMN_LENGTH;
+ }
- /**
- * Creates the labeled spinner responsible to edit the initial value. The
- * default value will be shown after the spinner. A value of -1 means the
- * default value and the model has <code>null</code>.
- *
- * @param container The parent container
- */
- protected void initializeInitialValueWidgets(Composite container) {
-
- Spinner spinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.GeneratorComposite_initialValue,
- buildInitialValueHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultInitialValueLabel(container),
- null
- );
-
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_INITIAL_VALUE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultInitialValue());
+ }
+ };
+ }
+
+ @Override
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_INITIAL_VALUE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedInitialValue();
+ }
- updateGridData(container, spinner);
+ @Override
+ public void setValue(Integer value) {
+ retrieveGenerator(GeneratorComposite.this.getSubject()).setSpecifiedInitialValue(value);
+ }
+ };
+ }
+ };
}
/**
@@ -378,34 +232,4 @@ public abstract class GeneratorComposite<T extends Generator> extends Pane<Gener
return generator;
}
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
index 6d62623328..20bd049acd 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
@@ -67,15 +67,11 @@ public class SequenceGeneratorComposite extends GeneratorComposite<SequenceGener
return subject.addSequenceGenerator();
}
- protected SequenceGenerator buildGenerator() {
- return this.buildGenerator(this.getSubject());
- }
-
private PropertyValueModel<SequenceGenerator> buildSequenceGeneratorHolder() {
return new PropertyAspectAdapter<GeneratorHolder, SequenceGenerator>(getSubjectHolder(), GeneratorHolder.SEQUENCE_GENERATOR_PROPERTY) {
@Override
protected SequenceGenerator buildValue_() {
- return subject.getSequenceGenerator();
+ return this.subject.getSequenceGenerator();
}
};
}
@@ -98,11 +94,7 @@ public class SequenceGeneratorComposite extends GeneratorComposite<SequenceGener
@Override
protected void setValue(String value) {
- SequenceGenerator sg = this.getSubject();
- if (sg == null) {
- sg = SequenceGeneratorComposite.this.buildGenerator();
- }
- sg.setSpecifiedSequenceName(value);
+ retrieveGenerator(SequenceGeneratorComposite.this.getSubject()).setSpecifiedSequenceName(value);
}
@Override
@@ -156,11 +148,8 @@ public class SequenceGeneratorComposite extends GeneratorComposite<SequenceGener
JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_SEQUENCE
);
- // Allocation Size widgets
- initializeAllocationSizeWidgets(container);
-
- // Initial Value widgets
- initializeInitialValueWidgets(container);
+ addAllocationSizeCombo(container);
+ addInitialValueCombo(container);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java
index fb922f1a74..d37a34a431 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java
@@ -117,11 +117,7 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
@Override
protected void setValue(String value) {
- TableGenerator tg = this.getSubject();
- if (tg == null) {
- tg = TableGeneratorComposite.this.buildGenerator();
- }
- tg.setSpecifiedCatalog(value);
+ retrieveGenerator(TableGeneratorComposite.this.getSubject()).setSpecifiedCatalog(value);
}
@Override
@@ -136,10 +132,6 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
return subject.addTableGenerator();
}
- protected TableGenerator buildGenerator() {
- return this.buildGenerator(this.getSubject());
- }
-
private ColumnCombo<TableGenerator> addPkColumnNameCombo(Composite parent) {
return new ColumnCombo<TableGenerator>(this, buildTableGeneratorHolder(), parent) {
@@ -171,11 +163,7 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
@Override
protected void setValue(String value) {
- TableGenerator tg = this.getSubject();
- if (tg == null) {
- tg = TableGeneratorComposite.this.buildGenerator();
- }
- tg.setSpecifiedPkColumnName(value);
+ retrieveGenerator(TableGeneratorComposite.this.getSubject()).setSpecifiedPkColumnName(value);
}
@Override
@@ -221,11 +209,7 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
@Override
protected void setValue(String value) {
- TableGenerator tg = this.getSubject();
- if (tg == null) {
- tg = TableGeneratorComposite.this.buildGenerator();
- }
- tg.setSpecifiedPkColumnValue(value);
+ retrieveGenerator(TableGeneratorComposite.this.getSubject()).setSpecifiedPkColumnValue(value);
}
@Override
@@ -271,11 +255,7 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
@Override
protected void setValue(String value) {
- TableGenerator tg = this.getSubject();
- if (tg == null) {
- tg = TableGeneratorComposite.this.buildGenerator();
- }
- tg.setSpecifiedSchema(value);
+ retrieveGenerator(TableGeneratorComposite.this.getSubject()).setSpecifiedSchema(value);
}
@Override
@@ -295,7 +275,7 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
return new PropertyAspectAdapter<GeneratorHolder, TableGenerator>(getSubjectHolder(), GeneratorHolder.TABLE_GENERATOR_PROPERTY) {
@Override
protected TableGenerator buildValue_() {
- return subject.getTableGenerator();
+ return this.subject.getTableGenerator();
}
};
}
@@ -346,11 +326,7 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
@Override
protected void setValue(String value) {
- TableGenerator tg = this.getSubject();
- if (tg == null) {
- tg = TableGeneratorComposite.this.buildGenerator();
- }
- tg.setSpecifiedTable(value);
+ retrieveGenerator(TableGeneratorComposite.this.getSubject()).setSpecifiedTable(value);
}
@Override
@@ -407,11 +383,7 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
@Override
protected void setValue(String value) {
- TableGenerator tg = this.getSubject();
- if (tg == null) {
- tg = TableGeneratorComposite.this.buildGenerator();
- }
- tg.setSpecifiedValueColumnName(value);
+ retrieveGenerator(TableGeneratorComposite.this.getSubject()).setSpecifiedValueColumnName(value);
}
@Override
@@ -496,16 +468,10 @@ public class TableGeneratorComposite extends GeneratorComposite<TableGenerator>
JpaHelpContextIds.MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN_VALUE
);
- // Allocation Size widgets
- initializeAllocationSizeWidgets(container);
-
- // Initial Value widgets
- initializeInitialValueWidgets(container);
+ addAllocationSizeCombo(container);
+ addInitialValueCombo(container);
}
- /*
- * (non-Javadoc)
- */
@Override
protected String getPropertyName() {
return GeneratorHolder.TABLE_GENERATOR_PROPERTY;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmGeneratorComposite.java
index eebec9afd3..64c34b6593 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmGeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmGeneratorComposite.java
@@ -12,19 +12,12 @@ package org.eclipse.jpt.ui.internal.orm.details;
import org.eclipse.jpt.core.context.Generator;
import org.eclipse.jpt.core.context.orm.OrmGenerator;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.IntegerCombo;
import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
/**
@@ -64,230 +57,83 @@ public abstract class OrmGeneratorComposite<T extends OrmGenerator> extends Pane
};
}
-
-
- /**
- * Creates the labeled spinner responsible to edit the allocation size. The
- * default value will be shown after the spinner. A value of -1 means the
- * default value and the model has <code>null</code>.
- *
- * @param container The parent container
- */
- protected void initializeAllocationSizeWidgets(Composite container) {
-
- Spinner spinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.GeneratorComposite_allocationSize,
- buildAllocationSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultAllocationSizeLabel(container),
- null
- );
-
- updateGridData(container, spinner);
- }
-
- private WritablePropertyValueModel<Integer> buildAllocationSizeHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY) {
+ protected void addAllocationSizeCombo(Composite container) {
+ new IntegerCombo<Generator>(this, container) {
+
@Override
- protected Integer buildValue_() {
- Integer value = subject.getSpecifiedAllocationSize();
- if (value == null) {
- return -1;
- }
- return value;
+ protected String getLabelText() {
+ return JptUiMappingsMessages.GeneratorComposite_allocationSize;
}
-
- @Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setSpecifiedAllocationSize(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildDefaultAllocationSizeHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_ALLOCATION_SIZE_PROPERTY) {
+
@Override
- protected Integer buildValue_() {
- return subject.getDefaultAllocationSize();
+ protected String getHelpId() {
+ return null;//JpaHelpContextIds.MAPPING_COLUMN_LENGTH;
}
@Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_ALLOCATION_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultAllocationSize());
+ }
+ };
}
- };
- }
-
- private Control addDefaultAllocationSizeLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultAllocationSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultAllocationSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultAllocationSizeHolder()) {
-
+
@Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(JptUiMappingsMessages.DefaultWithOneParam, value);
- }
-
- return "";
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedAllocationSize();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setSpecifiedAllocationSize(value);
+ }
+ };
}
- };
- }
- /**
- * Creates the labeled spinner responsible to edit the initial value. The
- * default value will be shown after the spinner. A value of -1 means the
- * default value and the model has <code>null</code>.
- *
- * @param container The parent container
- */
- protected void initializeInitialValueWidgets(Composite container) {
-
- Spinner spinner = addLabeledSpinner(
- container,
- JptUiMappingsMessages.GeneratorComposite_initialValue,
- buildInitialValueHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultInitialValueLabel(container),
- null
- );
-
-
- updateGridData(container, spinner);
+ };
}
- private WritablePropertyValueModel<Integer> buildInitialValueHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_INITIAL_VALUE_PROPERTY) {
+ protected void addInitialValueCombo(Composite container) {
+ new IntegerCombo<Generator>(this, container) {
+
@Override
- protected Integer buildValue_() {
- Integer value = subject.getSpecifiedInitialValue();
-
- if (value == null) {
- return -1;
- }
-
- return value;
+ protected String getLabelText() {
+ return JptUiMappingsMessages.GeneratorComposite_initialValue;
}
-
+
@Override
- protected void setValue_(Integer value) {
- if (value == -1) {
- value = null;
- }
- subject.setSpecifiedInitialValue(value);
+ protected String getHelpId() {
+ return null;//JpaHelpContextIds.MAPPING_COLUMN_LENGTH;
}
- };
- }
- private WritablePropertyValueModel<Integer> buildDefaultInitialValueHolder() {
- return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_INITIAL_VALUE_PROPERTY) {
@Override
- protected Integer buildValue_() {
- return subject.getDefaultInitialValue();
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.DEFAULT_INITIAL_VALUE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultInitialValue());
+ }
+ };
}
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- private Control addDefaultInitialValueLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultInitialValueLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultInitialValueLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultInitialValueHolder()) {
-
+
@Override
- protected String transform(Integer value) {
-
- if (value != null) {
- return NLS.bind(JptUiMappingsMessages.DefaultWithOneParam, value);
- }
-
- return "";
+ protected WritablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Generator, Integer>(getSubjectHolder(), Generator.SPECIFIED_INITIAL_VALUE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedInitialValue();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setSpecifiedInitialValue(value);
+ }
+ };
}
- };
- }
-
- /**
- * Changes the layout of the given container by changing which widget will
- * grab the excess of horizontal space. By default, the center control grabs
- * the excess space, we change it to be the right control.
- *
- * @param container The container containing the controls needing their
- * <code>GridData</code> to be modified from the default values
- * @param spinner The spinner that got created
- */
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
+ };
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmSequenceGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmSequenceGeneratorComposite.java
index 22ed3e5211..00eab10b52 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmSequenceGeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmSequenceGeneratorComposite.java
@@ -76,11 +76,8 @@ public class OrmSequenceGeneratorComposite extends OrmGeneratorComposite<OrmSequ
JpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_SEQUENCE
);
- // Allocation Size widgets
- initializeAllocationSizeWidgets(container);
-
- // Initial Value widgets
- initializeInitialValueWidgets(container);
+ addAllocationSizeCombo(container);
+ addInitialValueCombo(container);
}
private SequenceCombo<OrmSequenceGenerator> addSequenceNameCombo(Composite parent) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmTableGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmTableGeneratorComposite.java
index 28e756bc57..098bb4669f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmTableGeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/orm/details/OrmTableGeneratorComposite.java
@@ -140,11 +140,8 @@ public class OrmTableGeneratorComposite extends OrmGeneratorComposite<OrmTableGe
JpaHelpContextIds.MAPPING_TABLE_GENERATOR_PRIMARY_KEY_COLUMN_VALUE
);
- // Allocation Size widgets
- initializeAllocationSizeWidgets(container);
-
- // Initial Value widgets
- initializeInitialValueWidgets(container);
+ addAllocationSizeCombo(container);
+ addInitialValueCombo(container);
}
private ColumnCombo<OrmTableGenerator> addPkColumnNameCombo(Composite parent) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/IntegerCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/IntegerCombo.java
new file mode 100644
index 0000000000..c717a3fa3b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/IntegerCombo.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.widgets;
+
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.TransformationWritablePropertyValueModel;
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This is a replacement for a Spinner. It is a combo that only accepts integers.
+ * It also includes a Default option in the combo.
+ */
+public abstract class IntegerCombo<T extends Model>
+ extends Pane<T>
+{
+
+ /**
+ * The main (only) widget of this pane.
+ */
+ private CCombo comboBox;
+
+
+ private PropertyValueModel<String> defaultValueHolder;
+
+ // ********** constructors **********
+
+ protected IntegerCombo(
+ Pane<? extends T> parentPane,
+ Composite parent
+ ) {
+ super(parentPane, parent);
+ }
+
+ protected IntegerCombo(
+ Pane<?> parentPane,
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent
+ ) {
+ super(parentPane, subjectHolder, parent);
+ }
+
+
+ // ********** initialization **********
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ this.defaultValueHolder = buildDefaultStringHolder();
+ this.comboBox = this.addLabeledEditableCCombo(
+ container,
+ getLabelText(),
+ buildDefaultListHolder(),
+ buildSelectedItemStringHolder(),
+ getHelpId()
+ );
+
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
+ gridData.grabExcessHorizontalSpace = false;
+ this.comboBox.setLayoutData(gridData);
+
+ this.comboBox.addVerifyListener(this.buildVerifyListener());
+ SWTUtil.attachDefaultValueHandler(this.comboBox);
+ }
+
+ protected VerifyListener buildVerifyListener() {
+ return new VerifyListener() {
+ public void verifyText(VerifyEvent e) {
+ IntegerCombo.this.verifyComboBox(e);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildDefaultListHolder() {
+ return new PropertyListValueModelAdapter<String>(this.defaultValueHolder);
+ }
+
+ private PropertyValueModel<String> buildDefaultStringHolder() {
+ return new TransformationPropertyValueModel<Integer, String>(buildDefaultHolder()) {
+ @Override
+ protected String transform_(Integer value) {
+ return getDefaultValueString(value);
+ }
+ };
+ }
+
+ private String getDefaultValueString(Integer defaultValue) {
+ return NLS.bind(
+ JptUiMappingsMessages.DefaultWithOneParam,
+ defaultValue
+ );
+ }
+
+ private String getDefaultValueString() {
+ return this.defaultValueHolder.getValue();
+ }
+
+ private WritablePropertyValueModel<String> buildSelectedItemStringHolder() {
+ return new TransformationWritablePropertyValueModel<Integer, String>(buildSelectedItemHolder()) {
+ @Override
+ protected String transform(Integer value) {
+ return value == null ?
+ getDefaultValueString()
+ :
+ value.toString();
+ }
+
+ @Override
+ protected Integer reverseTransform_(String value) {
+ int intLength;
+ try {
+ intLength = Integer.parseInt(value);
+ }
+ catch (NumberFormatException e) {
+ //if the default is selected from the combo, set length to null
+ return null;
+ }
+ return Integer.valueOf(intLength);
+ }
+ };
+ }
+
+ // ********** abstract methods **********
+
+ protected abstract String getLabelText();
+
+ protected abstract String getHelpId();
+
+ protected abstract PropertyValueModel<Integer> buildDefaultHolder();
+
+ protected abstract WritablePropertyValueModel<Integer> buildSelectedItemHolder();
+
+
+ // ********** overrides **********
+
+ @Override
+ public void enableWidgets(boolean enabled) {
+ super.enableWidgets(enabled);
+
+ if ( ! this.comboBox.isDisposed()) {
+ this.comboBox.setEnabled(enabled);
+ }
+ }
+
+ // ********** combo-box verify listener callback **********
+
+ protected void verifyComboBox(VerifyEvent e) {
+ if (e.character == '\b') {
+ //ignore backspace
+ return;
+ }
+ if (e.text.equals("") //DefaultValueHandler sets the text to "" //$NON-NLS-1$
+ || e.text.equals(this.defaultValueHolder.getValue())) {
+ return;
+ }
+ try {
+ Integer.parseInt(e.text);
+ }
+ catch (NumberFormatException exception) {
+ e.doit = false;
+ }
+ }
+
+}

Back to the top