Author: dgeraskov
Date: 2008-10-06 06:03:45 -0400 (Mon, 06 Oct 2008)
New Revision: 10681
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2818
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2008-10-06
10:02:22 UTC (rev 10680)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2008-10-06
10:03:45 UTC (rev 10681)
@@ -7,11 +7,11 @@
org.eclipse.core.runtime,
org.eclipse.jpt.core,
org.eclipse.wst.validation,
- org.eclipse.jpt.eclipselink.core;bundle-version="1.0.0",
org.eclipse.jpt.utility;bundle-version="1.2.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Hibernate Team
Export-Package: org.jboss.tools.hibernate.jpt.core.internal,
- org.jboss.tools.hibernate.jpt.core.internal.context
+ org.jboss.tools.hibernate.jpt.core.internal.context,
+ org.jboss.tools.hibernate.jpt.core.internal.context.basic
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java 2008-10-06
10:02:22 UTC (rev 10680)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernatePlatform.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -27,9 +27,8 @@
return ID;
}
- /* use GenericJpaPlatform's methods while under progress
@Override
protected JpaFactory buildJpaFactory() {
return new HibernateFactory();
- }*/
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java 2008-10-06
10:02:22 UTC (rev 10680)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateJpaProperties.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -10,11 +10,20 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context;
+import java.util.ListIterator;
+
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.core.context.persistence.Property;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernateBasic;
/**
* @author Dmitry Geraskov
@@ -25,48 +34,75 @@
private PersistenceUnit persistenceUnit;
+ private BasicHibernateProperties basicHibernateProperties;
+
+ private ListValueModel<Property> propertiesAdapter;
+ private ListValueModel<Property> propertyListAdapter;
+
public HibernateJpaProperties(PersistenceUnit parent) {
super();
this.initialize(parent);
}
+
+ protected void initialize(PersistenceUnit parent) {
+ this.persistenceUnit = parent;
+ PropertyValueModel<PersistenceUnit> persistenceUnitHolder =
+ new SimplePropertyValueModel<PersistenceUnit>(this.persistenceUnit);
+
+ this.propertiesAdapter = this.buildPropertiesAdapter(persistenceUnitHolder);
+ this.propertyListAdapter = this.buildPropertyListAdapter(this.propertiesAdapter);
+
+ this.basicHibernateProperties = this.buildBasicProperties();
+ }
+
+ private ListValueModel<Property>
buildPropertyListAdapter(ListValueModel<Property> propertiesAdapter) {
+ return new ItemPropertyListValueModelAdapter<Property>(propertiesAdapter,
Property.VALUE_PROPERTY);
+ }
+
+ private ListValueModel<Property>
buildPropertiesAdapter(PropertyValueModel<PersistenceUnit> subjectHolder) {
+ return new ListAspectAdapter<PersistenceUnit, Property>(subjectHolder,
PersistenceUnit.PROPERTIES_LIST) {
+ @Override
+ protected ListIterator<Property> listIterator_() {
+ return this.subject.properties();
+ }
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties#getJpaProject()
- */
- public JpaProject getJpaProject() {
- return this.persistenceUnit.getJpaProject();
+ @Override
+ protected int size_() {
+ return this.subject.propertiesSize();
+ }
+ };
}
+
+ // ******** Behavior *********
+ public BasicHibernateProperties getBasicHibernate() {
+ return this.basicHibernateProperties;
+ }
+
+ private BasicHibernateProperties buildBasicProperties() {
+ return new HibernateBasic(this.persistenceUnit(), this.propertyListAdapter());
+ }
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties#itemIsProperty(org.eclipse.jpt.core.context.persistence.Property)
- */
- public boolean itemIsProperty(Property item) {
- throw new UnsupportedOperationException();
+ public ListValueModel<Property> propertyListAdapter() {
+ return this.propertyListAdapter;
}
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties#persistenceUnit()
- */
public PersistenceUnit persistenceUnit() {
return this.persistenceUnit;
}
+
+ public JpaProject getJpaProject() {
+ return this.persistenceUnit.getJpaProject();
+ }
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties#propertyIdFor(org.eclipse.jpt.core.context.persistence.Property)
- */
- public String propertyIdFor(Property property) {
+ public boolean itemIsProperty(Property item) {
throw new UnsupportedOperationException();
}
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.utility.model.listener.PropertyChangeListener#propertyChanged(org.eclipse.jpt.utility.model.event.PropertyChangeEvent)
- */
public void propertyChanged(PropertyChangeEvent event) {
throw new UnsupportedOperationException();
}
-
- protected void initialize(PersistenceUnit parent) {
- this.persistenceUnit = parent;
+
+ public String propertyIdFor(Property property) {
+ throw new UnsupportedOperationException();
}
-
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2008-10-06
10:02:22 UTC (rev 10680)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -13,6 +13,7 @@
import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
/**
* @author Dmitry Geraskov
@@ -36,9 +37,9 @@
this.hibernateProperties = new HibernateJpaProperties(this);
}
- /*
- * put getters for specific properties here
- *
- */
+ // ******** Behavior *********
+ public BasicHibernateProperties getBasicProperties() {
+ return this.hibernateProperties.getBasicHibernate();
+ }
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.Property;
+import org.eclipse.jpt.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public abstract class HibernatePersistenceUnitProperties extends AbstractModel
implements PersistenceUnitProperties {
+
+ private PersistenceUnit persistenceUnit;
+
+ private PersistenceUnitPropertyListListener propertyListListener;
+
+ private Map<String, String> propertyNames;
+
+ protected HibernatePersistenceUnitProperties(
+ PersistenceUnit parent,
+ ListValueModel<Property> propertyListAdapter) {
+ super();
+ this.initialize(parent, propertyListAdapter);
+ }
+
+ protected void initialize(
+ PersistenceUnit parent,
+ ListValueModel<Property> propertyListAdapter) {
+ this.persistenceUnit = parent;
+
+ this.propertyListListener = new PersistenceUnitPropertyListListener(this);
+ propertyListAdapter.addListChangeListener(ListValueModel.LIST_VALUES,
this.propertyListListener);
+
+ this.initializePropertyNames();
+ this.initializeProperties();
+ }
+
+ protected void initializePropertyNames() {
+ this.propertyNames = new HashMap<String, String>();
+ this.addPropertyNames(this.propertyNames);
+ }
+
+ /**
+ * Initializes properties with values from the persistence unit.
+ */
+ protected abstract void initializeProperties();
+
+ // ********** behavior **********
+ public PersistenceUnit persistenceUnit() {
+ return this.persistenceUnit;
+ }
+
+ public JpaProject getJpaProject() {
+ return this.persistenceUnit.getJpaProject();
+ }
+
+ public PersistenceUnitPropertyListListener propertyListListener() {
+ return this.propertyListListener;
+ }
+
+ private Map<String, String> propertyNames() {
+ return this.propertyNames;
+ }
+
+ /**
+ * Adds property names key/value pairs, used by the methods: itemIsProperty
+ * and propertyIdFor.
+ *
+ * key = EclipseLink property key; value = property id
+ */
+ protected abstract void addPropertyNames(Map<String, String> propertyNames);
+
+ /**
+ * Method used for identifying the given property.
+ */
+ public boolean itemIsProperty(Property item) {
+ if (item == null) {
+ throw new IllegalArgumentException("Property is null");
+ }
+ return this.propertyNames().keySet().contains(item.getName());
+ }
+
+ /**
+ * Returns the property name used for change notification of the given
+ * property.
+ */
+ public String propertyIdFor(Property property) {
+ String propertyId = this.propertyNames().get(property.getName());
+ if (propertyId == null) {
+ throw new IllegalArgumentException("Illegal property: " +
property.toString());
+ }
+ return propertyId;
+ }
+
+ protected String hibernateKeyFor(String propertyId) {
+ for (String hibernateKey : this.propertyNames().keySet()) {
+ if (this.propertyNames().get(hibernateKey).equals(propertyId)) {
+ return hibernateKey;
+ }
+ }
+ throw new IllegalArgumentException("Illegal property: " + propertyId);
+ }
+
+ // ****** get/set String convenience methods *******
+ /**
+ * Returns the String value of the given Property from the PersistenceXml.
+ */
+ protected String getStringValue(String key) {
+ return this.getStringValue(key, null);
+ }
+
+ protected String getStringValue(String key, String keySuffix) {
+ String elKey = (keySuffix == null) ? key : key + keySuffix;
+ if (this.persistenceUnit().containsProperty(elKey)) {
+ // TOREVIEW - handle incorrect String in persistence.xml
+ return this.persistenceUnit().getProperty(elKey).getValue();
+ }
+ return null;
+ }
+
+ /**
+ * Put the given String value into the PersistenceXml.
+ * @param key
+ * EclipseLink Key
+ * @param keySuffix
+ * e.g. entity name
+ * @param newValue
+ * value to be associated with the key
+ * @param allowDuplicate
+ */
+ protected void putStringValue(String key, String keySuffix, String newValue, boolean
allowDuplicate) {
+ String elKey = (keySuffix == null) ? key : key + keySuffix;
+ if (newValue == null) {
+ this.persistenceUnit().removeProperty(elKey);
+ }
+ else {
+ this.persistenceUnit().putProperty(elKey, newValue, allowDuplicate);
+ }
+ }
+
+ // ******** Convenience methods ********
+ /**
+ * Put into persistenceUnit properties.
+ *
+ * @param key -
+ * property name
+ * @param value -
+ * property value
+ */
+ @SuppressWarnings("unchecked")
+ protected void putProperty(String key, Object value) {
+ String elKey = this.hibernateKeyFor(key);
+ if (value == null)
+ this.removeProperty(elKey);
+ else
+ this.putProperty_(elKey, value);
+ }
+
+ private void putProperty_(String key, Object value) {
+ this.persistenceUnit().putProperty(key, value.toString(), false);
+ }
+
+ /**
+ * Removes a property with the given key.
+ */
+ protected void removeProperty(String key) {
+ this.persistenceUnit().removeProperty(key);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java 2008-10-06
10:02:22 UTC (rev 10680)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernateProperties.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context;
-import org.eclipse.jpt.eclipselink.core.internal.context.PersistenceUnitProperties;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
/**
* @author Dmitry Geraskov
@@ -18,6 +18,6 @@
*/
public interface HibernateProperties extends PersistenceUnitProperties {
- // put getters for specific properties here
+ BasicHibernateProperties getBasicHibernate();
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context;
+
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.Property;
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface PersistenceUnitProperties extends Model, PropertyChangeListener {
+
+ /**
+ * Method used for identifying the given property.
+ */
+ boolean itemIsProperty(Property item);
+
+ /**
+ * Returns the property name used for change notification of the given property.
+ */
+ String propertyIdFor(Property property);
+
+ /**
+ * Return the PersistenceUnit of this Properties.
+ */
+ PersistenceUnit persistenceUnit();
+
+ /**
+ * Return the JPA project the PersistenceUnit belongs to.
+ */
+ JpaProject getJpaProject();
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitProperties.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context;
+
+import java.util.Iterator;
+
+import org.eclipse.jpt.core.context.persistence.Property;
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.event.ListChangeEvent;
+import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.utility.model.listener.ListChangeListener;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class PersistenceUnitPropertyListListener implements ListChangeListener
+{
+ private PersistenceUnitProperties parent;
+
+ // ********** constructors / initialization **********
+ public PersistenceUnitPropertyListListener(PersistenceUnitProperties parent) {
+ this.parent = parent;
+ }
+
+ // ********** Behavior **********
+ protected boolean add(Property newItem, Model source) {
+ if (this.model().itemIsProperty(newItem)) {
+ String propertyName = this.model().propertyIdFor(newItem);
+ this.model().propertyChanged(
+ new PropertyChangeEvent(source, propertyName, null, newItem));
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean remove(Property item, Model source) {
+ if (this.model().itemIsProperty(item)) {
+ String propertyName = this.model().propertyIdFor(item);
+ this.model().propertyChanged(
+ new PropertyChangeEvent(source, propertyName, item, null)); // oldItem is the removed
property
+ return true;
+ }
+ return false;
+ }
+
+ // replace
+ protected Property set(Property newItem, Model source) {
+ if (this.model().itemIsProperty(newItem)) {
+ String propertyName = this.model().propertyIdFor(newItem);
+ this.model().propertyChanged(
+ new PropertyChangeEvent(source, propertyName, null, newItem)); // oldItem unknown
+ return newItem;
+ }
+ return null;
+ }
+
+ // ********** ListChangeListener implementation **********
+ public void itemsAdded(ListChangeEvent e) {
+ for (Iterator<Property> stream = this.items(e); stream.hasNext();) {
+ this.add(stream.next(), e.getSource());
+ }
+ }
+
+ public void itemsRemoved(ListChangeEvent e) {
+ for (Iterator<Property> stream = this.items(e); stream.hasNext();) {
+ this.remove(stream.next(), e.getSource());
+ }
+ }
+
+ public void itemsReplaced(ListChangeEvent e) {
+ // ItemAspectListValueModelAdapter(270) does not provide old value
+ for (Iterator<Property> newStream = this.items(e); newStream.hasNext();) {
+ this.set(newStream.next(), e.getSource());
+ }
+ }
+
+ public void itemsMoved(ListChangeEvent e) {
+ throw new UnsupportedOperationException("source: " + e.getSource() + " -
aspect: " + e.getAspectName());
+ }
+
+ public void listCleared(ListChangeEvent e) {
+ throw new UnsupportedOperationException("source: " + e.getSource() + " -
aspect: " + e.getAspectName());
+ }
+
+ public void listChanged(ListChangeEvent e) {
+ throw new UnsupportedOperationException("source: " + e.getSource() + " -
aspect: " + e.getAspectName());
+ }
+
+ // ********** internal methods **********
+ private PersistenceUnitProperties model() {
+ return this.parent;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Iterator<Property> items(ListChangeEvent event) {
+ return (Iterator<Property>) event.items();
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/PersistenceUnitPropertyListListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.basic;
+
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface BasicHibernateProperties extends Model, PropertyChangeListener {
+
+ String getDefaultConfigurationFile();
+ String getConfigurationFile();
+ void setConfigurationFile(String newConfigFile);
+ static final String CONFIG_FILE_PROPERTY = "confFileProperty";
+ // Hibernate key string
+ static final String HIBERNATE_CONFIG_FILE = "hibernate.ejb.cfgfile";
+ static final String DEFAULT_CONFIG_FILE = "";
+
+ String getDefaultDialect();
+ String getDialect();
+ void setDialect(String newDialect);
+ static final String DIALECT_PROPERTY = "dialectProperty";
+ // Hibernate key string
+ static final String HIBERNATE_DIALECT = "hibernate.dialect";
+ static final String DEFAULT_DIALECT = "";
+
+ String getDefaultDriver();
+ String getDriver();
+ void setDriver(String newDriver);
+ static final String DRIVER_PROPERTY = "driverProperty";
+ // Hibernate key string
+ static final String HIBERNATE_DRIVER = "hibernate.connection.driver_class";
+ static final String DEFAULT_DRIVER = "";
+
+ String getDefaultUrl();
+ String getUrl();
+ void setUrl(String newUrl);
+ static final String URL_PROPERTY = "urlProperty";
+ // Hibernate key string
+ static final String HIBERNATE_URL = "hibernate.connection.url";
+ static final String DEFAULT_URL = "";
+
+ String getDefaultSchemaDefault();
+ String getSchemaDefault();
+ void setSchemaDefault(String newSchemaDefault);
+ static final String SCHEMA_DEFAULT_PROPERTY = "schemaDefaultProperty";
+ // Hibernate key string
+ static final String HIBERNATE_SCHEMA_DEFAULT = "hibernate.default_schema";
+ static final String DEFAULT_SCHEMA_DEFAULT = "";
+
+ String getDefaultCatalogDefault();
+ String getCatalogDefault();
+ void setCatalogDefault(String newCatalogDefault);
+ static final String CATALOG_DEFAULT_PROPERTY = "catalogDefaultProperty";
+ // Hibernate key string
+ static final String HIBERNATE_CATALOG = "hibernate.default_catalog";
+ static final String DEFAULT_CATALOG_DEFAULT = "";
+
+ String getDefaultUsername();
+ String getUsername();
+ void setUsername(String newUsername);
+ static final String USERNAME_PROPERTY = "usernameProperty";
+ // Hibernate key string
+ static final String HIBERNATE_USERNAME = "hibernate.connection.username";
+ static final String DEFAULT_USERNAME = "";
+
+ String getDefaultPassword();
+ String getPassword();
+ void setPassword(String newPassword);
+ static final String PASSWORD_PROPERTY = "passwordProperty";
+ // Hibernate key string
+ static final String HIBERNATE_PASSWORD = "hibernate.connection.password";
+ static final String DEFAULT_PASSWORD = "";
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/BasicHibernateProperties.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java 2008-10-06
10:03:45 UTC (rev 10681)
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.basic;
+
+import java.util.Map;
+
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.Property;
+import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnitProperties;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateBasic extends HibernatePersistenceUnitProperties
+ implements BasicHibernateProperties {
+
+ // ********** Hibernate properties **********
+ private String configFile;
+ private String dialect;
+ private String driver;
+ private String url;
+ private String schemaDefault;
+ private String catalogDefault;
+ private String username;
+ private String password;
+
+ // ********** constructors **********
+ public HibernateBasic(PersistenceUnit parent, ListValueModel<Property>
propertyListAdapter) {
+ super(parent, propertyListAdapter);
+ }
+
+ // ********** initialization **********
+ /**
+ * Initializes properties with values from the persistence unit.
+ */
+ @Override
+ protected void initializeProperties() {
+ this.configFile =
+ this.getStringValue(HIBERNATE_CONFIG_FILE);
+ this.dialect =
+ this.getStringValue(HIBERNATE_DIALECT);
+ this.driver =
+ this.getStringValue(HIBERNATE_DRIVER);
+ this.url =
+ this.getStringValue(HIBERNATE_URL);
+ this.schemaDefault =
+ this.getStringValue(HIBERNATE_SCHEMA_DEFAULT);
+ this.catalogDefault =
+ this.getStringValue(HIBERNATE_CATALOG);
+ this.username =
+ this.getStringValue(HIBERNATE_USERNAME);
+ this.password =
+ this.getStringValue(HIBERNATE_PASSWORD);
+ }
+
+
+ // ********** behavior **********
+ @Override
+ protected void addPropertyNames(Map<String, String> propertyNames) {
+ propertyNames.put(
+ HIBERNATE_CONFIG_FILE,
+ CONFIG_FILE_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_DIALECT,
+ DIALECT_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_DRIVER,
+ DRIVER_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_URL,
+ URL_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_SCHEMA_DEFAULT,
+ SCHEMA_DEFAULT_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_CATALOG,
+ CATALOG_DEFAULT_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_USERNAME,
+ USERNAME_PROPERTY);
+ propertyNames.put(
+ HIBERNATE_PASSWORD,
+ PASSWORD_PROPERTY);
+ }
+
+ public void propertyChanged(PropertyChangeEvent event) {
+ String aspectName = event.getAspectName();
+ if (aspectName.equals(CONFIG_FILE_PROPERTY)) {
+ this.configurationFileChanged(event);
+ } else if (aspectName.equals(DIALECT_PROPERTY)) {
+ this.dialectChanged(event);
+ } else if (aspectName.equals(DRIVER_PROPERTY)) {
+ this.driverChanged(event);
+ } else if (aspectName.equals(URL_PROPERTY)) {
+ this.urlChanged(event);
+ } else if (aspectName.equals(SCHEMA_DEFAULT_PROPERTY)) {
+ this.schemaDefaultChanged(event);
+ } else if (aspectName.equals(CATALOG_DEFAULT_PROPERTY)) {
+ this.catalogDefaultChanged(event);
+ } else if (aspectName.equals(USERNAME_PROPERTY)) {
+ this.usernameChanged(event);
+ } else if (aspectName.equals(PASSWORD_PROPERTY)) {
+ this.passwordChanged(event);
+ }
+ }
+
+ // ********** Configuration File **********
+ public String getDefaultConfigurationFile() {
+ return DEFAULT_CONFIG_FILE;
+ }
+
+ public String getConfigurationFile() {
+ return this.configFile;
+ }
+
+ public void setConfigurationFile(String newConfigFile) {
+ String old = this.configFile;
+ this.configFile = newConfigFile;
+ this.putProperty(CONFIG_FILE_PROPERTY, newConfigFile);
+ this.firePropertyChanged(CONFIG_FILE_PROPERTY, old, newConfigFile);
+ }
+
+ private void configurationFileChanged(PropertyChangeEvent event) {
+ String newFile = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.configFile;
+ this.configFile = newFile;
+ this.firePropertyChanged(event.getAspectName(), old, newFile);
+ }
+
+ // ********** Dialect **********
+ public String getDefaultDialect() {
+ return DEFAULT_DIALECT;
+ }
+
+ public String getDialect() {
+ return this.dialect;
+ }
+
+ public void setDialect(String newDialect) {
+ String old = this.dialect;
+ this.dialect = newDialect;
+ this.putProperty(DIALECT_PROPERTY, newDialect);
+ this.firePropertyChanged(DIALECT_PROPERTY, old, newDialect);
+ }
+
+ private void dialectChanged(PropertyChangeEvent event) {
+ String newDialect = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.dialect;
+ this.dialect = newDialect;
+ this.firePropertyChanged(event.getAspectName(), old, newDialect);
+ }
+
+ // ********** Driver **********
+ public String getDefaultDriver() {
+ return DEFAULT_DRIVER;
+ }
+
+ public String getDriver() {
+ return this.driver;
+ }
+
+ public void setDriver(String newDriver) {
+ String old = this.driver;
+ this.driver = newDriver;
+ this.putProperty(DRIVER_PROPERTY, newDriver);
+ this.firePropertyChanged(DRIVER_PROPERTY, old, newDriver);
+ }
+
+ private void driverChanged(PropertyChangeEvent event) {
+ String newDriver = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.driver;
+ this.driver = newDriver;
+ this.firePropertyChanged(event.getAspectName(), old, newDriver);
+ }
+
+ // ********** Url **********
+ public String getDefaultUrl() {
+ return DEFAULT_URL;
+ }
+
+ public String getUrl() {
+ return this.url;
+ }
+
+ public void setUrl(String newUrl) {
+ String old = this.url;
+ this.url = newUrl;
+ this.putProperty(URL_PROPERTY, newUrl);
+ this.firePropertyChanged(URL_PROPERTY, old, newUrl);
+ }
+
+ private void urlChanged(PropertyChangeEvent event) {
+ String newUrl = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.url;
+ this.url = newUrl;
+ this.firePropertyChanged(event.getAspectName(), old, newUrl);
+ }
+
+ // ********** Default schema **********
+ public String getDefaultSchemaDefault() {
+ return DEFAULT_SCHEMA_DEFAULT;
+ }
+
+ public String getSchemaDefault() {
+ return schemaDefault;
+ }
+
+ public void setSchemaDefault(String newSchemaDefault) {
+ String old = this.schemaDefault;
+ this.schemaDefault = newSchemaDefault;
+ this.putProperty(SCHEMA_DEFAULT_PROPERTY, newSchemaDefault);
+ this.firePropertyChanged(SCHEMA_DEFAULT_PROPERTY, old, newSchemaDefault);
+ }
+
+ private void schemaDefaultChanged(PropertyChangeEvent event) {
+ String newSchemaDefault = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.schemaDefault;
+ this.schemaDefault = newSchemaDefault;
+ this.firePropertyChanged(event.getAspectName(), old, newSchemaDefault);
+ }
+
+ // ********** Default catalog **********
+ public String getDefaultCatalogDefault() {
+ return DEFAULT_CATALOG_DEFAULT;
+ }
+
+ public String getCatalogDefault() {
+ return catalogDefault;
+ }
+
+ public void setCatalogDefault(String newCatalogDefault) {
+ String old = this.catalogDefault;
+ this.catalogDefault = newCatalogDefault;
+ this.putProperty(CATALOG_DEFAULT_PROPERTY, newCatalogDefault);
+ this.firePropertyChanged(CATALOG_DEFAULT_PROPERTY, old, newCatalogDefault);
+ }
+
+ private void catalogDefaultChanged(PropertyChangeEvent event) {
+ String newCatalogDefault = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.catalogDefault;
+ this.catalogDefault = newCatalogDefault;
+ this.firePropertyChanged(event.getAspectName(), old, newCatalogDefault);
+ }
+
+ // ********** Username **********
+ public String getDefaultUsername() {
+ return DEFAULT_USERNAME;
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String newUsername) {
+ String old = this.username;
+ this.username = newUsername;
+ this.putProperty(USERNAME_PROPERTY, newUsername);
+ this.firePropertyChanged(USERNAME_PROPERTY, old, newUsername);
+ }
+
+ private void usernameChanged(PropertyChangeEvent event) {
+ String newUsername = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.username;
+ this.username = newUsername;
+ this.firePropertyChanged(event.getAspectName(), old, newUsername);
+ }
+
+ // ********** Password **********
+ public String getDefaultPassword() {
+ return DEFAULT_PASSWORD;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String newPassword) {
+ String old = this.password;
+ this.password = newPassword;
+ this.putProperty(PASSWORD_PROPERTY, newPassword);
+ this.firePropertyChanged(PASSWORD_PROPERTY, old, newPassword);
+ }
+
+ private void passwordChanged(PropertyChangeEvent event) {
+ String newPassword = (event.getNewValue() == null) ? null : ((Property)
event.getNewValue()).getValue();
+ String old = this.password;
+ this.password = newPassword;
+ this.firePropertyChanged(event.getAspectName(), old, newPassword);
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/HibernateBasic.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native