Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authortle2008-04-16 20:55:12 +0000
committertle2008-04-16 20:55:12 +0000
commit6bf5aa27952999cbf299fd9ab4a5ffc315826b28 (patch)
treedd69b4e3edd503384fc98846ab744acdb388b4bb /jpa
parent01d1b9693e920a9a38936d4a15930c52368bdc35 (diff)
downloadwebtools.dali-6bf5aa27952999cbf299fd9ab4a5ffc315826b28.tar.gz
webtools.dali-6bf5aa27952999cbf299fd9ab4a5ffc315826b28.tar.xz
webtools.dali-6bf5aa27952999cbf299fd9ab4a5ffc315826b28.zip
Initial check-in.
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsSizeComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/ConnectionPropertiesComposite.java119
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java88
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java113
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java107
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java60
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMinComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsSharedComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java57
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMinComposite.java168
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/NativeSqlComposite.java96
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java86
21 files changed, 2159 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java
new file mode 100644
index 0000000000..6b0152186e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/BatchWritingComposite.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.BatchWriting;
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * BatchWritingComposite
+ */
+public class BatchWritingComposite extends AbstractFormPane<Connection>
+{
+ /**
+ * Creates a new <code>BatchWritingComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public BatchWritingComposite(
+ AbstractFormPane<? extends Connection> parentComposite,
+ Composite parent) {
+
+ super( parentComposite, parent);
+ }
+
+ private EnumFormComboViewer<Connection, BatchWriting> buildBatchWritingCombo(Composite container) {
+ return new EnumFormComboViewer<Connection, BatchWriting>(this, container) {
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(Connection.BATCH_WRITING_PROPERTY);
+ }
+
+ @Override
+ protected BatchWriting[] choices() {
+ return BatchWriting.values();
+ }
+
+ @Override
+ protected BatchWriting defaultValue() {
+ return subject().getDefaultBatchWriting();
+ }
+
+ @Override
+ protected String displayString(BatchWriting value) {
+ return buildDisplayString(EclipseLinkUiMessages.class, BatchWritingComposite.this, value);
+ }
+
+ @Override
+ protected BatchWriting getValue() {
+ return subject().getBatchWriting();
+ }
+
+ @Override
+ protected void setValue(BatchWriting value) {
+ subject().setBatchWriting(value);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout( Composite container) {
+
+ this.buildLabeledComposite(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_batchWritingLabel,
+ this.buildBatchWritingCombo( container),
+ null // TODO IJpaHelpContextIds.
+ );
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsComposite.java
new file mode 100644
index 0000000000..1776940f72
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsComposite.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+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.widgets.Composite;
+
+/**
+ * CacheStatementsComposite
+ */
+public class CacheStatementsComposite extends AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>CacheStatementsComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public CacheStatementsComposite(
+ AbstractPane<? extends Connection> parentComposite,
+ Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ private WritablePropertyValueModel<Boolean> buildCacheStatementsHolder() {
+ return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.CACHE_STATEMENTS_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.getCacheStatements();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ subject.setCacheStatements(value);
+ }
+
+ @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 PropertyValueModel<String> buildCacheStatementsStringHolder() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildCacheStatementsHolder()) {
+ @Override
+ protected String transform(Boolean value) {
+ if ((subject() != null) && (value == null)) {
+ Boolean defaultValue = subject().getDefaultCacheStatements();
+ if (defaultValue != null) {
+ String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
+ return NLS.bind(EclipseLinkUiMessages.PersistenceXmlConnectionTab_cacheStatementsLabelDefault, defaultStringValue);
+ }
+ }
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_cacheStatementsLabel;
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ this.buildTriStateCheckBoxWithDefault(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_cacheStatementsLabel,
+ this.buildCacheStatementsHolder(),
+ this.buildCacheStatementsStringHolder(),
+ null
+// EclipseLinkHelpContextIds.
+ );
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java
new file mode 100644
index 0000000000..bd9e689b98
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsPropertiesComposite.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.swt.widgets.Composite;
+
+/** .
+ * CacheStatementsPropertiesComposite
+ */
+public class CacheStatementsPropertiesComposite extends AbstractPane<Connection>
+{
+ public CacheStatementsPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ new CacheStatementsComposite(this, container);
+
+ new CacheStatementsSizeComposite(this, container);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsSizeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsSizeComposite.java
new file mode 100644
index 0000000000..f71e70f33b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/CacheStatementsSizeComposite.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.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.AbstractPane;
+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;
+
+/**
+ * CacheStatementsSizeComposite
+ */
+@SuppressWarnings("nls")
+public class CacheStatementsSizeComposite extends AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>CacheStatementsSizeComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public CacheStatementsSizeComposite(AbstractPane<Connection> parentComposite,
+ Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ private WritablePropertyValueModel<Integer> buildCacheStatementsSizeHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.CACHE_STATEMENTS_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ Integer value = subject.getCacheStatementsSize();
+
+ if (value == null) {
+ value = -1;
+ }
+ return value;
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value == -1) {
+ value = null;
+ }
+ subject.setCacheStatementsSize(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Integer> buildDefaultCacheStatementsSizeHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+ @Override
+ protected Integer buildValue_() {
+ return subject.getDefaultCacheStatementsSize();
+ }
+
+ @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 buildDefaultCacheStatementsSizeLabel(Composite container) {
+
+ Label label = buildLabel(
+ container,
+ EclipseLinkUiMessages.DefaultWithoutValue
+ );
+
+ new LabeledControlUpdater(
+ new LabeledLabel(label),
+ buildDefaultCacheStatementsSizeLabelHolder()
+ );
+
+ return label;
+ }
+
+ private PropertyValueModel<String> buildDefaultCacheStatementsSizeLabelHolder() {
+
+ return new TransformationPropertyValueModel<Integer, String>(buildDefaultCacheStatementsSizeHolder()) {
+
+ @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.buildLabeledSpinner(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_cacheStatementsSizeLabel,
+ this.buildCacheStatementsSizeHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ this.buildDefaultCacheStatementsSizeLabel(container)
+ );
+
+ 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/connection/ConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/ConnectionPropertiesComposite.java
new file mode 100644
index 0000000000..74c52d41e0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/ConnectionPropertiesComposite.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.util.PaneEnabler;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.jpt.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * ConnectionPropertiesComposite
+ */
+public class ConnectionPropertiesComposite extends AbstractPane<Connection>
+{
+ public ConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ // group
+ Group dataGroup = this.buildTitledPane(container, "");
+
+ WritablePropertyValueModel<DataModel> dataHolder = this.buildDataHolder();
+ WritablePropertyValueModel<Boolean> dataSourceHolder = this.buildDataSourceHolder(dataHolder);
+ WritablePropertyValueModel<Boolean> jdbcHolder = this.buildJdbcHolder(dataHolder);
+
+ // DataSource radio button
+ this.buildRadioButton(
+ dataGroup,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_dataSourceLabel,
+ dataSourceHolder
+ );
+
+ DataSourcePropertiesComposite dataSourceComposite = new DataSourcePropertiesComposite(this, dataGroup);
+
+ // JDBC radio button
+ this.buildRadioButton(
+ dataGroup,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_jdbcLabel,
+ jdbcHolder
+ );
+
+ JdbcPropertiesComposite jdbcComposite = new JdbcPropertiesComposite(this, dataGroup);
+
+ new PaneEnabler(dataSourceHolder, dataSourceComposite);
+ new PaneEnabler(jdbcHolder, jdbcComposite);
+ }
+
+ private WritablePropertyValueModel<DataModel> buildDataHolder() {
+ return new SimplePropertyValueModel<DataModel>(new DataModel());
+ }
+
+ private WritablePropertyValueModel<Boolean> buildDataSourceHolder(PropertyValueModel<DataModel> subjectHolder) {
+ return new PropertyAspectAdapter<DataModel, Boolean>(subjectHolder, DataModel.DATA_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(subject.isDataSource());
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ subject.setDataSource(value.booleanValue());
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildJdbcHolder(PropertyValueModel<DataModel> subjectHolder) {
+ return new PropertyAspectAdapter<DataModel, Boolean>(subjectHolder, DataModel.DATA_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(subject.isJdbc());
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ subject.setDataSource(!value.booleanValue());
+ }
+ };
+ }
+
+ private class DataModel extends AbstractModel {
+ private Boolean isDataSource;
+ public static final String DATA_PROPERTY = "dataProperty";
+
+ public DataModel() {
+ this(false);
+ }
+ public DataModel(Boolean isDataSource) {
+ this.isDataSource = isDataSource;
+ }
+ public Boolean isDataSource() {
+ return this.isDataSource;
+ }
+ public Boolean isJdbc() {
+ return ! this.isDataSource;
+ }
+ public void setDataSource(Boolean isDataSource) {
+ Object old = this.isDataSource;
+ this.isDataSource = isDataSource;
+ this.firePropertyChanged(DATA_PROPERTY, old, isDataSource);
+ }
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java
new file mode 100644
index 0000000000..a60d266209
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/DataSourcePropertiesComposite.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @version 2.0
+ * @since 2.0
+ */
+public class DataSourcePropertiesComposite extends AbstractPane<Connection> {
+
+ /**
+ * Creates a new <code>EntityCachingPropertyComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public DataSourcePropertiesComposite(AbstractPane<Connection> parentComposite,
+ Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ // JTA Data Source
+ this.buildLabeledText(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_jtaDataSourceLabel,
+ buildJtaDataSourceHolder()
+ );
+
+ // Non-JTA Data Source
+ this.buildLabeledText(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_nonJtaDataSourceLabel,
+ buildNonJtaDataSourceHolder()
+ );
+ }
+
+ private WritablePropertyValueModel<String> buildJtaDataSourceHolder() {
+ return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.JTA_DATA_SOURCE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getJtaDataSource();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ subject.setJtaDataSource(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildNonJtaDataSourceHolder() {
+ return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.NON_JTA_DATA_SOURCE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getNonJtaDataSource();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ subject.setNonJtaDataSource(value);
+ }
+ };
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java
new file mode 100644
index 0000000000..bbfdac4a5c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/EclipseLinkConnectionComposite.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * EclipseLinkConnectionComposite
+ */
+public class EclipseLinkConnectionComposite
+ extends AbstractFormPane<Connection>
+{
+ public EclipseLinkConnectionComposite(
+ AbstractFormPane<Connection> subjectHolder,
+ Composite container) {
+ super(subjectHolder, container, false);
+ }
+
+ @Override
+ protected void initializeLayout(Composite parent) {
+ Section section = getWidgetFactory().createSection(parent, SWT.FLAT | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ section.setText(EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionTitle);
+ section.setDescription(EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionDescription);
+ Composite composite = getWidgetFactory().createComposite(section);
+ composite.setLayout(new GridLayout(1, false));
+ section.setClient(composite);
+ this.updateGridData(composite);
+ this.updateGridData(composite.getParent());
+
+ new TransactionTypeComposite(this, composite);
+
+ new BatchWritingComposite(this, composite);
+
+ new NativeSqlComposite(this, composite);
+
+ new CacheStatementsPropertiesComposite(this, composite);
+
+ new ConnectionPropertiesComposite(this, composite);
+
+ return;
+ }
+
+ private void updateGridData(Composite container) {
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ container.setLayoutData(gridData);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java
new file mode 100644
index 0000000000..a1f80707c7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcBindParametersComposite.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+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.widgets.Composite;
+
+/**
+ * JdbcBindParametersComposite
+ */
+public class JdbcBindParametersComposite extends AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>JdbcBindParametersComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public JdbcBindParametersComposite(
+ AbstractPane<? extends Connection> parentComposite,
+ Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ private WritablePropertyValueModel<Boolean> buildBindParametersHolder() {
+ return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.BIND_PARAMETERS_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.getBindParameters();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ subject.setBindParameters(value);
+ }
+
+ @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 PropertyValueModel<String> buildBindParametersStringHolder() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildBindParametersHolder()) {
+ @Override
+ protected String transform(Boolean value) {
+ if ((subject() != null) && (value == null)) {
+ Boolean defaultValue = subject().getDefaultBindParameters();
+ if (defaultValue != null) {
+ String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
+ return NLS.bind(EclipseLinkUiMessages.PersistenceXmlConnectionTab_bindParametersLabelDefault, defaultStringValue);
+ }
+ }
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_bindParametersLabel;
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ this.buildTriStateCheckBoxWithDefault(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_bindParametersLabel,
+ this.buildBindParametersHolder(),
+ this.buildBindParametersStringHolder(),
+ null
+// EclipseLinkHelpContextIds.
+ );
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java
new file mode 100644
index 0000000000..32a4ea4010
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcConnectionPropertiesComposite.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * JdbcConnectionPropertiesComposite
+ */
+public class JdbcConnectionPropertiesComposite extends AbstractPane<Connection>
+{
+ public JdbcConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ // Driver
+ new JdbcDriverComposite(this, container);
+
+ // Url
+ this.buildLabeledText(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_urlLabel,
+ buildUrlHolder()
+ );
+
+ // User
+ this.buildLabeledText(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_userLabel,
+ buildUserHolder()
+ );
+
+ // Password
+ this.buildLabeledText(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_passwordLabel,
+ buildPasswordHolder()
+ );
+
+ // Bind Parameters
+ new JdbcBindParametersComposite(this, container);
+
+
+ }
+
+ private WritablePropertyValueModel<String> buildUrlHolder() {
+ return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.URL_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getUrl();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ subject.setUrl(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildUserHolder() {
+ return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.USER_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getUser();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ subject.setUser(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildPasswordHolder() {
+ return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.PASSWORD_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getPassword();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ subject.setPassword(value);
+ }
+ };
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java
new file mode 100644
index 0000000000..cc897af3a7
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcDriverComposite.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * JdbcDriverComposite
+ */
+public class JdbcDriverComposite extends AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>EventListenerComposite</code>.
+ *
+ * @param parentPane The parent pane of this one
+ * @param parent The parent container
+ */
+ public JdbcDriverComposite(AbstractPane<? extends Connection> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent);
+ }
+
+ private ClassChooserPane<Connection> initializeClassChooser(Composite container) {
+
+ return new ClassChooserPane<Connection>(this, container) {
+
+ @Override
+ protected WritablePropertyValueModel<String> buildTextHolder() {
+ return new PropertyAspectAdapter<Connection, String>(getSubjectHolder(), Connection.DRIVER_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getDriver();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+
+ if (value.length() == 0) {
+ value = null;
+ }
+
+ subject.setDriver(value);
+ }
+ };
+ }
+
+ @Override
+ protected String className() {
+ return subject().getDriver();
+ }
+
+ @Override
+ protected String labelText() {
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_driverLabel;
+ }
+
+ @Override
+ protected IPackageFragmentRoot packageFragmentRoot() {
+ //TODO
+// IProject project = subject().getJpaProject().getProject();
+// IJavaProject root = JavaCore.create(project);
+//
+// try {
+// return root.getAllPackageFragmentRoots()[0];
+// }
+// catch (JavaModelException e) {
+// JptEclipseLinkUiPlugin.log(e);
+// }
+ return null;
+ }
+
+ @Override
+ protected void promptType() {
+ IType type = chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('.');
+ subject().setDriver(className);
+ }
+ }
+ };
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected void initializeLayout(Composite container) {
+ this.initializeClassChooser(container);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java
new file mode 100644
index 0000000000..a4cf3d2b1f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcPropertiesComposite.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * JdbcPropertiesComposite
+ */
+public class JdbcPropertiesComposite extends AbstractPane<Connection>
+{
+ public JdbcPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ new JdbcConnectionPropertiesComposite(this, container);
+
+ new JdbcReadConnectionPropertiesComposite(this, container);
+
+ new JdbcWriteConnectionPropertiesComposite(this, container);
+
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java
new file mode 100644
index 0000000000..c982c07a94
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionPropertiesComposite.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * JdbcReadConnectionPropertiesComposite
+ */
+public class JdbcReadConnectionPropertiesComposite extends AbstractPane<Connection>
+{
+ public JdbcReadConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ Section section = getWidgetFactory().createSection(container, SWT.FLAT | ExpandableComposite.TITLE_BAR);
+ section.setText(EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSectionTitle);
+ Composite composite = getWidgetFactory().createComposite(section);
+ composite.setLayout(new GridLayout(1, false));
+ section.setClient(composite);
+ this.updateGridData(composite);
+ this.updateGridData(composite.getParent());
+
+ // Read Connections Shared
+ new JdbcReadConnectionsSharedComposite(this, composite);
+
+ // Read Connections Minimum
+ new JdbcReadConnectionsMinComposite(this, composite);
+
+ // Read Connections Maximum
+ new JdbcReadConnectionsMaxComposite(this, composite);
+ }
+
+ private void updateGridData(Composite container) {
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ container.setLayoutData(gridData);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java
new file mode 100644
index 0000000000..e27a93fc75
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMaxComposite.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.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.AbstractPane;
+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 AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>JdbcReadConnectionsMaxComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public JdbcReadConnectionsMaxComposite(AbstractPane<Connection> parentComposite,
+ Composite parent) {
+
+ 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 setValue_(Integer value) {
+ if (value == -1) {
+ value = null;
+ }
+ subject.setReadConnectionsMax(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Integer> buildDefaultReadConnectionsMaxHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+ @Override
+ protected Integer buildValue_() {
+ return subject.getDefaultReadConnectionsMax();
+ }
+
+ @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 buildDefaultReadConnectionsMaxLabel(Composite container) {
+
+ Label label = buildLabel(
+ 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 "";
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ Spinner spinner = this.buildLabeledSpinner(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMaxLabel,
+ this.buildReadConnectionsMaxHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ this.buildDefaultReadConnectionsMaxLabel(container)
+ );
+
+ 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/connection/JdbcReadConnectionsMinComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMinComposite.java
new file mode 100644
index 0000000000..07c5f88113
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsMinComposite.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.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.AbstractPane;
+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 AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>JdbcReadConnectionsMinComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public JdbcReadConnectionsMinComposite(AbstractPane<Connection> parentComposite,
+ Composite parent) {
+
+ 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 setValue_(Integer value) {
+ if (value == -1) {
+ value = null;
+ }
+ subject.setReadConnectionsMin(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Integer> buildDefaultReadConnectionsMinHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+ @Override
+ protected Integer buildValue_() {
+ return subject.getDefaultReadConnectionsMin();
+ }
+
+ @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 buildDefaultReadConnectionsMinLabel(Composite container) {
+
+ Label label = buildLabel(
+ 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 "";
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ Spinner spinner = this.buildLabeledSpinner(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsMinLabel,
+ this.buildReadConnectionsMinHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ this.buildDefaultReadConnectionsMinLabel(container)
+ );
+
+ 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/connection/JdbcReadConnectionsSharedComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsSharedComposite.java
new file mode 100644
index 0000000000..547b654c24
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcReadConnectionsSharedComposite.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+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.widgets.Composite;
+
+/**
+ * ReadConnectionsSharedComposite
+ */
+public class JdbcReadConnectionsSharedComposite extends AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>ReadConnectionsSharedComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public JdbcReadConnectionsSharedComposite(
+ AbstractPane<? extends Connection> parentComposite,
+ Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ private WritablePropertyValueModel<Boolean> buildReadConnectionsSharedHolder() {
+ return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.READ_CONNECTIONS_SHARED_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.getReadConnectionsShared();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ subject.setReadConnectionsShared(value);
+ }
+
+ @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 PropertyValueModel<String> buildReadConnectionsSharedStringHolder() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildReadConnectionsSharedHolder()) {
+ @Override
+ protected String transform(Boolean value) {
+ if ((subject() != null) && (value == null)) {
+ Boolean defaultValue = subject().getDefaultReadConnectionsShared();
+ if (defaultValue != null) {
+ String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
+ return NLS.bind(EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSharedLabelDefault, defaultStringValue);
+ }
+ }
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSharedLabel;
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ this.buildTriStateCheckBoxWithDefault(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_readConnectionsSharedLabel,
+ this.buildReadConnectionsSharedHolder(),
+ this.buildReadConnectionsSharedStringHolder(),
+ null
+// EclipseLinkHelpContextIds.
+ );
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java
new file mode 100644
index 0000000000..175278bc7e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionPropertiesComposite.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * JdbcWriteConnectionPropertiesComposite
+ */
+public class JdbcWriteConnectionPropertiesComposite extends AbstractPane<Connection>
+{
+ public JdbcWriteConnectionPropertiesComposite(AbstractPane<Connection> parentComposite, Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ Section section = getWidgetFactory().createSection(container, SWT.FLAT | ExpandableComposite.TITLE_BAR);
+ section.setText(EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsSectionTitle);
+ Composite composite = getWidgetFactory().createComposite(section);
+ composite.setLayout(new GridLayout(1, false));
+ section.setClient(composite);
+ this.updateGridData(composite);
+ this.updateGridData(composite.getParent());
+
+ // Write Connections Minimum
+ new JdbcWriteConnectionsMinComposite(this, composite);
+
+ // Write Connections Maximum
+ new JdbcWriteConnectionsMaxComposite(this, composite);
+ }
+
+ private void updateGridData(Composite container) {
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ container.setLayoutData(gridData);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java
new file mode 100644
index 0000000000..d5336af9f0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMaxComposite.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.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.AbstractPane;
+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 AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>JdbcWriteConnectionsMaxComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public JdbcWriteConnectionsMaxComposite(AbstractPane<Connection> parentComposite,
+ Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ private WritablePropertyValueModel<Integer> buildWriteConnectionsMaxHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.WRITE_CONNECTIONS_MAX_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ Integer value = subject.getWriteConnectionsMax();
+
+ if (value == null) {
+ value = -1;
+ }
+ return value;
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value == -1) {
+ value = null;
+ }
+ subject.setWriteConnectionsMax(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Integer> buildDefaultWriteConnectionsMaxHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+ @Override
+ protected Integer buildValue_() {
+ return 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);
+ }
+ }
+ };
+ }
+
+ private Control buildDefaultWriteConnectionsMaxLabel(Composite container) {
+
+ Label label = buildLabel(
+ 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.buildLabeledSpinner(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMaxLabel,
+ this.buildWriteConnectionsMaxHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ this.buildDefaultWriteConnectionsMaxLabel(container)
+ );
+
+ 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/connection/JdbcWriteConnectionsMinComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMinComposite.java
new file mode 100644
index 0000000000..bc39035de9
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/JdbcWriteConnectionsMinComposite.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.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.AbstractPane;
+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 AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>JdbcWriteConnectionsMinComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public JdbcWriteConnectionsMinComposite(AbstractPane<Connection> parentComposite,
+ Composite parent) {
+
+ 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 setValue_(Integer value) {
+ if (value == -1) {
+ value = null;
+ }
+ subject.setWriteConnectionsMin(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Integer> buildDefaultWriteConnectionsMinHolder() {
+ return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), "") {
+ @Override
+ protected Integer buildValue_() {
+ return subject.getDefaultWriteConnectionsMin();
+ }
+
+ @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 buildDefaultWriteConnectionsMinLabel(Composite container) {
+
+ Label label = buildLabel(
+ 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 "";
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ Spinner spinner = this.buildLabeledSpinner(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_writeConnectionsMinLabel,
+ this.buildWriteConnectionsMinHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ this.buildDefaultWriteConnectionsMinLabel(container)
+ );
+
+ 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/connection/NativeSqlComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/NativeSqlComposite.java
new file mode 100644
index 0000000000..ea891c7860
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/NativeSqlComposite.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
+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.widgets.Composite;
+
+/**
+ * NativeSqlComposite
+ */
+public class NativeSqlComposite extends AbstractPane<Connection>
+{
+ /**
+ * Creates a new <code>NativeSqlComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public NativeSqlComposite(
+ AbstractPane<? extends Connection> parentComposite,
+ Composite parent) {
+
+ super(parentComposite, parent);
+ }
+
+ private WritablePropertyValueModel<Boolean> buildNativeSqlHolder() {
+ return new PropertyAspectAdapter<Connection, Boolean>(getSubjectHolder(), Connection.NATIVE_SQL_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return subject.getNativeSql();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ subject.setNativeSql(value);
+ }
+
+ @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 PropertyValueModel<String> buildNativeSqlStringHolder() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildNativeSqlHolder()) {
+ @Override
+ protected String transform(Boolean value) {
+ if ((subject() != null) && (value == null)) {
+ Boolean defaultValue = subject().getDefaultNativeSql();
+ if (defaultValue != null) {
+ String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
+ return NLS.bind(EclipseLinkUiMessages.PersistenceXmlConnectionTab_nativeSqlLabelDefault, defaultStringValue);
+ }
+ }
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_nativeSqlLabel;
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ this.buildTriStateCheckBoxWithDefault(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_nativeSqlLabel,
+ this.buildNativeSqlHolder(),
+ this.buildNativeSqlStringHolder(),
+ null
+// EclipseLinkHelpContextIds.
+ );
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java
new file mode 100644
index 0000000000..cce0f7586f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/PersistenceXmlConnectionTab.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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.eclipselink.ui.internal.connection;
+
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.WidgetFactory;
+import org.eclipse.jpt.ui.details.JpaPageComposite;
+import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * PersistenceXmlConnectionTab
+ */
+public class PersistenceXmlConnectionTab
+ extends AbstractFormPane<Connection>
+ implements JpaPageComposite<PersistenceUnit>
+{
+ // ********** constructors/initialization **********
+ public PersistenceXmlConnectionTab(
+ PropertyValueModel<Connection> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ new EclipseLinkConnectionComposite(this, container);
+ }
+
+ // ********** JpaPageComposite implementation **********
+ public String getHelpID() {
+ return null;
+ }
+
+ public Image getPageImage() {
+ return null;
+ }
+
+ public String getPageText() {
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_title;
+ }
+
+ // ********** Layout **********
+ @Override
+ protected Composite buildContainer(Composite parent) {
+ GridLayout layout = new GridLayout(1, true);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginTop = 0;
+ layout.marginLeft = 0;
+ layout.marginBottom = 0;
+ layout.marginRight = 0;
+ layout.verticalSpacing = 15;
+ Composite container = this.buildPane(parent, layout);
+ this.updateGridData(container);
+ return container;
+ }
+
+ private void updateGridData(Composite container) {
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ container.setLayoutData(gridData);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java
new file mode 100644
index 0000000000..666bd613f3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/connection/TransactionTypeComposite.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.eclipselink.ui.internal.connection;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
+import org.eclipse.jpt.eclipselink.core.internal.context.connection.Connection;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * TransactionTypeComposite
+ */
+public class TransactionTypeComposite extends AbstractFormPane<Connection>
+{
+ /**
+ * Creates a new <code>TransactionTypeComposite</code>.
+ *
+ * @param parentController
+ * The parent container of this one
+ * @param parent
+ * The parent container
+ */
+ public TransactionTypeComposite(
+ AbstractFormPane<? extends Connection> parentComposite,
+ Composite parent) {
+
+ super( parentComposite, parent);
+ }
+
+ private EnumFormComboViewer<Connection, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) {
+ return new EnumFormComboViewer<Connection, PersistenceUnitTransactionType>(this, container) {
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(Connection.TRANSACTION_TYPE_PROPERTY);
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType[] choices() {
+ return PersistenceUnitTransactionType.values();
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType defaultValue() {
+ return subject().getDefaultTransactionType();
+ }
+
+ @Override
+ protected String displayString(PersistenceUnitTransactionType value) {
+ return buildDisplayString(EclipseLinkUiMessages.class, TransactionTypeComposite.this, value);
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType getValue() {
+ return subject().getTransactionType();
+ }
+
+ @Override
+ protected void setValue(PersistenceUnitTransactionType value) {
+ subject().setTransactionType(value);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout( Composite container) {
+
+ this.buildLabeledComposite(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlConnectionTab_transactionTypeLabel,
+ this.buildTransactionTypeCombo( container),
+ null // TODO IJpaHelpContextIds.
+ );
+ }
+}

Back to the top