diff options
author | tle | 2010-04-21 21:21:25 +0000 |
---|---|---|
committer | tle | 2010-04-21 21:21:25 +0000 |
commit | 98aa244301a6f888712a79b153895e168b10781f (patch) | |
tree | d308291a85598dbea8b7d19d075bf0347b24625c | |
parent | 6d68098da6656d9e4e1f16539c7ebfc1819e2a7b (diff) | |
download | webtools.dali-98aa244301a6f888712a79b153895e168b10781f.tar.gz webtools.dali-98aa244301a6f888712a79b153895e168b10781f.tar.xz webtools.dali-98aa244301a6f888712a79b153895e168b10781f.zip |
306860 - EclipseLink Persistence.xml Logging missing Connection checkbox
7 files changed, 176 insertions, 17 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/persistence/logging/EclipseLinkLogging2_0.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/persistence/logging/EclipseLinkLogging2_0.java index 7326d49aba..6a9f3befc4 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/persistence/logging/EclipseLinkLogging2_0.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/context/persistence/logging/EclipseLinkLogging2_0.java @@ -32,6 +32,8 @@ public class EclipseLinkLogging2_0 extends EclipseLinkLogging * value = value */ private Map<String, LoggingLevel> categoryValues; + + private Boolean connection; private LoggingLevel categoriesDefaultValue; @@ -48,6 +50,9 @@ public class EclipseLinkLogging2_0 extends EclipseLinkLogging protected void initializeProperties() { super.initializeProperties(); + this.connection = + this.getBooleanValue(ECLIPSELINK_CONNECTION); + this.categoriesDefaultValue = this.getEnumValue(ECLIPSELINK_LEVEL, LoggingLevel.values()); this.initializeCategory(SQL_CATEGORY_LOGGING_PROPERTY); @@ -92,8 +97,11 @@ public class EclipseLinkLogging2_0 extends EclipseLinkLogging @Override public void propertyValueChanged(String propertyName, String newValue) { super.propertyValueChanged(propertyName, newValue); - - if (propertyName.equals(ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL)) { + + if (propertyName.equals(ECLIPSELINK_CONNECTION)) { + this.connectionChanged(newValue); + } + else if (propertyName.equals(ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL)) { this.categoryLoggingChanged_(ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL, newValue); } else if (propertyName.equals(ECLIPSELINK_TRANSACTION_CATEGORY_LOGGING_LEVEL)) { @@ -144,7 +152,10 @@ public class EclipseLinkLogging2_0 extends EclipseLinkLogging public void propertyRemoved(String propertyName) { super.propertyRemoved(propertyName); - if (propertyName.equals(ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL)) { + if (propertyName.equals(ECLIPSELINK_CONNECTION)) { + this.connectionChanged(null); + } + else if (propertyName.equals(ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL)) { this.categoryLoggingChanged_(ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL, null); } else if (propertyName.equals(ECLIPSELINK_TRANSACTION_CATEGORY_LOGGING_LEVEL)) { @@ -199,7 +210,10 @@ public class EclipseLinkLogging2_0 extends EclipseLinkLogging @Override protected void addPropertyNames(Map<String, String> propertyNames) { super.addPropertyNames(propertyNames); - + + propertyNames.put( + ECLIPSELINK_CONNECTION, + CONNECTION_PROPERTY); propertyNames.put( ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL, SQL_CATEGORY_LOGGING_PROPERTY); @@ -246,8 +260,31 @@ public class EclipseLinkLogging2_0 extends EclipseLinkLogging ECLIPSELINK_SERVER_CATEGORY_LOGGING_LEVEL, SERVER_CATEGORY_LOGGING_PROPERTY); } - + // ********** Connection ********** + public Boolean getConnection() { + return this.connection; + } + + public void setConnection(Boolean newConnection) { + Boolean old = this.connection; + this.connection = newConnection; + this.putProperty(CONNECTION_PROPERTY, newConnection); + this.firePropertyChanged(CONNECTION_PROPERTY, old, newConnection); + } + + private void connectionChanged(String stringValue) { + Boolean newValue = getBooleanValueOf(stringValue); + + Boolean old = this.connection; + this.connection = newValue; + this.firePropertyChanged(CONNECTION_PROPERTY, old, newValue); + } + + public Boolean getDefaultConnection() { + return DEFAULT_CONNECTION; + } + // ********** Category Levels ********** public LoggingLevel getLevel(String category) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/v2_0/context/persistence/logging/Logging2_0.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/v2_0/context/persistence/logging/Logging2_0.java index 1e60f5bf47..e18504a598 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/v2_0/context/persistence/logging/Logging2_0.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/v2_0/context/persistence/logging/Logging2_0.java @@ -18,6 +18,14 @@ public interface Logging2_0 extends Logging { public static final String CATEGORY_PREFIX_ = "eclipselink.logging.level."; //$NON-NLS-1$ + Boolean getDefaultConnection(); + Boolean getConnection(); + void setConnection(Boolean connection); + static final String CONNECTION_PROPERTY = "connection"; //$NON-NLS-1$ + // EclipseLink key string + static final String ECLIPSELINK_CONNECTION = "eclipselink.logging.connection"; //$NON-NLS-1$ + static final Boolean DEFAULT_CONNECTION = Boolean.TRUE; + LoggingLevel getCategoriesDefaultLevel(); LoggingLevel getLevel(String category); void setLevel(String category, LoggingLevel level); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties index 813737791c..b71d2951c5 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties @@ -308,6 +308,8 @@ PersistenceXmlLoggingTab_sessionLabel = Session PersistenceXmlLoggingTab_sessionLabelDefault = Session ({0}) PersistenceXmlLoggingTab_exceptionsLabel = Exceptions PersistenceXmlLoggingTab_exceptionsLabelDefault = Exceptions ({0}) +PersistenceXmlLoggingTab_connectionLabel = Connection +PersistenceXmlLoggingTab_connectionLabelDefault = Connection ({0}) PersistenceXmlLoggingTab_loggersLabel = Loggers: diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java index 4c252103bf..90a37382a8 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java @@ -315,6 +315,8 @@ public class EclipseLinkUiMessages { public static String PersistenceXmlLoggingTab_sessionLabelDefault; public static String PersistenceXmlLoggingTab_exceptionsLabel; public static String PersistenceXmlLoggingTab_exceptionsLabelDefault; + public static String PersistenceXmlLoggingTab_connectionLabel; + public static String PersistenceXmlLoggingTab_connectionLabelDefault; public static String PersistenceXmlLoggingTab_loggersLabel; public static String PersistenceXmlLoggingTab_loggingFileLabel; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/logging/EclipseLinkLoggingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/logging/EclipseLinkLoggingComposite.java index b3c0a58f56..e25109913e 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/logging/EclipseLinkLoggingComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/logging/EclipseLinkLoggingComposite.java @@ -45,17 +45,8 @@ public class EclipseLinkLoggingComposite<T extends Logging> // LoggingLevel: new LoggingLevelComposite(this, composite); - // Timestamp: - new TimestampComposite(this, composite); - - // Thread: - new ThreadComposite(this, composite); - - // Session: - new SessionComposite(this, composite); - - // Exceptions: - new ExceptionsComposite(this, composite); + // Boolean properties group + this.logPropertiesComposite(composite); // LoggingFile: new LoggingFileLocationComposite(this, composite); @@ -65,6 +56,21 @@ public class EclipseLinkLoggingComposite<T extends Logging> return; } + + protected void logPropertiesComposite(Composite parent) { + + // Timestamp: + new TimestampComposite(this, parent); + + // Thread: + new ThreadComposite(this, parent); + + // Session: + new SessionComposite(this, parent); + + // Exceptions: + new ExceptionsComposite(this, parent); + } private void updateGridData(Composite container) { GridData gridData = new GridData(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/persistence/logging/ConnectionComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/persistence/logging/ConnectionComposite.java new file mode 100644 index 0000000000..7466682715 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/persistence/logging/ConnectionComposite.java @@ -0,0 +1,97 @@ +/******************************************************************************* +* Copyright (c) 2010 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.v2_0.persistence.logging; + +import org.eclipse.jpt.eclipselink.core.v2_0.context.persistence.logging.Logging2_0; +import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages; +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.widgets.Composite; + +/** + * ConnectionComposite + */ +public class ConnectionComposite extends Pane<Logging2_0> +{ + /** + * Creates a new <code>ConnectionComposite</code>. + * + * @param parentController + * The parent container of this one + * @param parent + * The parent container + */ + public ConnectionComposite( + Pane<? extends Logging2_0> parentComposite, + Composite parent) { + + super(parentComposite, parent); + } + + @Override + protected void initializeLayout(Composite container) { + + this.addTriStateCheckBoxWithDefault( + container, + EclipseLinkUiMessages.PersistenceXmlLoggingTab_connectionLabel, + this.buildConnectionHolder(), + this.buildConnectionStringHolder(), + null +// EclipseLinkHelpContextIds.PERSISTENCE_LOGGING_CONNECTION // TODO + ); + } + + private WritablePropertyValueModel<Boolean> buildConnectionHolder() { + return new PropertyAspectAdapter<Logging2_0, Boolean>(getSubjectHolder(), Logging2_0.CONNECTION_PROPERTY) { + @Override + protected Boolean buildValue_() { + return this.subject.getConnection(); + } + + @Override + protected void setValue_(Boolean value) { + this.subject.setConnection(value); + } + }; + } + + private PropertyValueModel<String> buildConnectionStringHolder() { + return new TransformationPropertyValueModel<Boolean, String>(this.buildDefaultConnectionHolder()) { + @Override + protected String transform(Boolean value) { + if (value != null) { + String defaultStringValue = value.booleanValue() ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False; + return NLS.bind(EclipseLinkUiMessages.PersistenceXmlLoggingTab_connectionLabelDefault, defaultStringValue); + } + return EclipseLinkUiMessages.PersistenceXmlLoggingTab_connectionLabel; + } + }; + } + + private PropertyValueModel<Boolean> buildDefaultConnectionHolder() { + return new PropertyAspectAdapter<Logging2_0, Boolean>( + getSubjectHolder(), + Logging2_0.CONNECTION_PROPERTY) + { + @Override + protected Boolean buildValue_() { + if (this.subject.getConnection() != null) { + return null; + } + return this.subject.getDefaultConnection(); + } + }; + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/persistence/logging/EclipseLinkLogging2_0Composite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/persistence/logging/EclipseLinkLogging2_0Composite.java index 8f3292734e..19f21b0d16 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/persistence/logging/EclipseLinkLogging2_0Composite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/persistence/logging/EclipseLinkLogging2_0Composite.java @@ -44,5 +44,12 @@ public class EclipseLinkLogging2_0Composite extends EclipseLinkLoggingComposite< protected void addCategoryLoggingLevelComposite(Composite parent) { new EclipseLinkCategoryLoggingLevelComposite(this, parent); } - + + @Override + protected void logPropertiesComposite(Composite parent) { + super.logPropertiesComposite(parent); + + // Connection: + new ConnectionComposite(this, parent); + } } |