Author: vyemialyanchyk
Date: 2008-06-06 12:52:05 -0400 (Fri, 06 Jun 2008)
New Revision: 8617
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.properties
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/Messages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/Messages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/messages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/messages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/Messages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/messages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/Messages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/messages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/Messages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/messages.properties
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/NodeFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/AbstractConsoleConfigurationPreferences.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/StandAloneConsoleConfigurationPreferences.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginFileAppender.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginLogAppender.java
Log:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-500
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -69,42 +69,42 @@
public class ConsoleConfiguration implements ExecutionContextHolder {
private ExecutionContext executionContext;
-
+
private Map fakeDrivers = new HashMap();
-
- /* TODO: move this out to the actual users of the configuraiton/sf ? */
+
+ /* TODO: move this out to the actual users of the configuraiton/sf ? */
private Configuration configuration;
private SessionFactory sessionFactory;
-
+
/** Unique name for this configuration */
public String getName() {
return prefs.getName();
}
-
+
public ConsoleConfiguration(ConsoleConfigurationPreferences config) {
prefs = config;
}
-
+
public Object execute(Command c) {
return executionContext.execute(c);
}
-
-
+
+
public ConsoleConfigurationPreferences prefs = null;
-
-
+
+
/**
* Reset so a new configuration or sessionfactory is needed.
*
*/
public void reset() {
- // reseting state
+ // reseting state
configuration = null;
closeSessionFactory();
}
-
+
public void build() {
- configuration = buildWith(null, true);
+ configuration = buildWith(null, true);
}
private Configuration buildJPAConfiguration(String persistenceUnit, Properties
properties, String entityResolver, boolean includeMappings) {
@@ -123,42 +123,42 @@
if(!includeMappings) {
overrides.put( "hibernate.archive.autodetection", "none" );
//$NON-NLS-1$//$NON-NLS-2$
}
-
+
Class clazz =
ReflectHelper.classForName("org.hibernate.ejb.Ejb3Configuration",
ConsoleConfiguration.class); //$NON-NLS-1$
Object ejb3cfg = clazz.newInstance();
-
+
if(StringHelper.isNotEmpty(entityResolver)) {
Class resolver = ReflectHelper.classForName(entityResolver, this.getClass());
Object object = resolver.newInstance();
Method method = clazz.getMethod("setEntityResolver", new Class[] {
EntityResolver.class });//$NON-NLS-1$
method.invoke(ejb3cfg, new Object[] { object } );
}
-
+
Method method = clazz.getMethod("configure", new Class[] { String.class,
Map.class }); //$NON-NLS-1$
if ( method.invoke(ejb3cfg, new Object[] { persistenceUnit, overrides } ) == null ) {
- String out = NLS.bind(Messages.CONSOLECONFIGURATION_PERSISTENCE_UNIT_NOT_FOUND,
persistenceUnit);
+ String out =
NLS.bind(ConsoleMessages.ConsoleConfiguration_persistence_unit_not_found,
persistenceUnit);
throw new HibernateConsoleRuntimeException(out);
}
-
+
method = clazz.getMethod("getHibernateConfiguration", new
Class[0]);//$NON-NLS-1$
Configuration invoke = (Configuration) method.invoke(ejb3cfg, (Object[])null);
return invoke;
}
catch (Exception e) {
- throw new
HibernateConsoleRuntimeException(Messages.CONSOLECONFIGURATION_COULD_NOT_CREATE_JPA_BASED_CONFIGURATION,e);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_create_jpa_based_configuration,e);
}
}
-
+
private Configuration buildAnnotationConfiguration() throws ClassNotFoundException,
InstantiationException, IllegalAccessException {
Class clazz = ReflectHelper
.classForName( "org.hibernate.cfg.AnnotationConfiguration" );
//$NON-NLS-1$
Configuration newInstance = (Configuration) clazz.newInstance();
return newInstance;
}
-
+
/**
* @return
- *
+ *
*/
public Configuration buildWith(final Configuration cfg, final boolean includeMappings)
{
URL[] customClassPathURLS = prefs.getCustomClassPathURLS();
@@ -170,7 +170,7 @@
throw cnfe;
}
}
-
+
protected synchronized Class loadClass(String name, boolean resolve) throws
ClassNotFoundException {
try {
return super.loadClass( name, resolve );
@@ -178,7 +178,7 @@
throw cnfe;
}
}
-
+
public Class loadClass(String name) throws ClassNotFoundException {
try {
return super.loadClass( name );
@@ -186,15 +186,15 @@
throw cnfe;
}
}
- });
-
+ });
+
Configuration result = (Configuration) executionContext.execute(new
ExecutionContext.Command() {
-
+
public Object execute() {
Configuration localCfg = cfg;
Properties properties = prefs.getProperties();
-
+
if(properties!=null) {
// in case the transaction manager is empty then we need to inject a faketm since
hibernate will still try and instantiate it.
String str = properties.getProperty(
"hibernate.transaction.manager_lookup_class" ); //$NON-NLS-1$
@@ -203,8 +203,8 @@
//properties.setProperty( "hibernate.transaction.factory_class",
"");
}
}
-
-
+
+
if(localCfg==null) {
localCfg = buildConfiguration( properties, includeMappings );
} else {
@@ -212,16 +212,16 @@
//origProperties.putAll(properties);
//cfg.setProperties(origProperties);
// TODO: this is actually only for jdbc reveng...
- //localCfg = configureStandardConfiguration( includeMappings, localCfg, properties
);
+ //localCfg = configureStandardConfiguration( includeMappings, localCfg, properties
);
}
- // here both setProperties and configxml have had their chance to tell which
databasedriver is needed.
+ // here both setProperties and configxml have had their chance to tell which
databasedriver is needed.
registerFakeDriver(localCfg.getProperty(Environment.DRIVER) );
-
+
// TODO: jpa configuration ?
if(includeMappings) {
File[] mappingFiles = prefs.getMappingFiles();
-
+
for (int i = 0; i < mappingFiles.length; i++) {
File hbm = mappingFiles[i];
localCfg = localCfg.addFile(hbm);
@@ -230,13 +230,13 @@
// TODO: HBX-
localCfg.setProperty( "hibernate.temp.use_jdbc_metadata_defaults",
"false" ); //$NON-NLS-1$//$NON-NLS-2$
localCfg.setProperty( Environment.HBM2DDL_AUTO, "false" ); //$NON-NLS-1$
-
+
return localCfg;
}
-
+
});
-
-
+
+
return result;
}
@@ -244,7 +244,7 @@
File configXMLFile = prefs.getConfigXMLFile();
if(!includeMappings) {
org.dom4j.Document doc;
- XMLHelper xmlHelper = new XMLHelper();
+ XMLHelper xmlHelper = new XMLHelper();
InputStream stream;
String resourceName = "<unknown>"; //$NON-NLS-1$
try {
@@ -257,37 +257,37 @@
}
}
catch (FileNotFoundException e1) {
- throw new
HibernateConsoleRuntimeException(Messages.CONSOLECONFIGURATION_COULD_NOT_ACCESS +
configXMLFile, e1);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_access +
configXMLFile, e1);
}
-
+
try {
List errors = new ArrayList();
-
+
doc = xmlHelper.createSAXReader( resourceName, errors, entityResolver )
.read( new InputSource( stream ) );
if ( errors.size() != 0 ) {
throw new MappingException(
- Messages.CONSOLECONFIGURATION_INVALID_CONFIGURATION,
+ ConsoleMessages.ConsoleConfiguration_invalid_configuration,
(Throwable) errors.get( 0 )
);
}
-
-
+
+
List list =
doc.getRootElement().element("session-factory").elements("mapping");
//$NON-NLS-1$ //$NON-NLS-2$
Iterator iterator = list.iterator();
while ( iterator.hasNext() ) {
Node element = (Node) iterator.next();
- element.getParent().remove(element);
+ element.getParent().remove(element);
}
-
+
DOMWriter dw = new DOMWriter();
Document document = dw.write(doc);
return localCfg.configure( document );
-
+
}
catch (DocumentException e) {
throw new HibernateException(
- Messages.CONSOLECONFIGURATION_COULD_NOT_PARSE_CONFIGURATION + resourceName, e
+ ConsoleMessages.ConsoleConfiguration_could_not_parse_configuration + resourceName,
e
);
}
finally {
@@ -306,14 +306,14 @@
}
}
}
-
+
/**
* DriverManager checks what classloader a class is loaded from thus
- * we register a FakeDriver that we know is loaded "properly" which delegates
all it class
+ * we register a FakeDriver that we know is loaded "properly" which delegates
all it class
* to the real driver.
- *
+ *
* By doing so we can convince DriverManager that we can use any dynamically loaded
driver.
- *
+ *
* @param driverClassName
*/
private void registerFakeDriver(String driverClassName) {
@@ -326,22 +326,22 @@
DriverManager.registerDriver(fakeDelegatingDriver);
fakeDrivers.put(driverClassName,fakeDelegatingDriver);
}
- }
+ }
catch (ClassNotFoundException e) {
- String out =
NLS.bind(Messages.CONSOLECONFIGURATION_PROBLEMS_WHILE_LOADING_DATABASE_DRIVERCLASS,
driverClassName);
- throw new HibernateConsoleRuntimeException(out, e);
- }
+ String out =
NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass,
driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ }
catch (InstantiationException e) {
- String out =
NLS.bind(Messages.CONSOLECONFIGURATION_PROBLEMS_WHILE_LOADING_DATABASE_DRIVERCLASS,
driverClassName);
+ String out =
NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass,
driverClassName);
throw new HibernateConsoleRuntimeException(out, e);
- }
+ }
catch (IllegalAccessException e) {
- String out =
NLS.bind(Messages.CONSOLECONFIGURATION_PROBLEMS_WHILE_LOADING_DATABASE_DRIVERCLASS,
driverClassName);
+ String out =
NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass,
driverClassName);
throw new HibernateConsoleRuntimeException(out, e);
- }
+ }
catch (SQLException e) {
- String out =
NLS.bind(Messages.CONSOLECONFIGURATION_PROBLEMS_WHILE_LOADING_DATABASE_DRIVERCLASS,
driverClassName);
- throw new HibernateConsoleRuntimeException(out, e);
+ String out =
NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass,
driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
}
}
}
@@ -362,7 +362,7 @@
execute(new ExecutionContext.Command() {
public Object execute() {
if(sessionFactory!=null) {
- throw new
HibernateConsoleRuntimeException(Messages.CONSOLECONFIGURATION_FACTORY_NOT_CLOSED_BEFORE_BUILD_NEW_FACTORY);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_factory_not_closed_before_build_new_factory);
}
sessionFactory = getConfiguration().buildSessionFactory();
fireFactoryBuilt();
@@ -370,63 +370,63 @@
}
});
}
-
+
public SessionFactory getSessionFactory() {
return sessionFactory;
}
-
-
+
+
int execcount;
List queryListeners = new ArrayList();
List consoleCfgListeners = new ArrayList();
-
+
public QueryPage executeHQLQuery(final String hql) {
return executeHQLQuery(hql, new QueryInputModel());
}
-
+
public QueryPage executeHQLQuery(final String hql, final QueryInputModel
queryParameters) {
-
+
return (QueryPage) executionContext.execute(new ExecutionContext.Command() {
-
+
public Object execute() {
Session session = getSessionFactory().openSession();
QueryPage qp = new HQLQueryPage(ConsoleConfiguration.this,hql,queryParameters);
qp.setSession(session);
-
- qp.setId(++execcount);
- fireQueryPageCreated(qp);
+
+ qp.setId(++execcount);
+ fireQueryPageCreated(qp);
return qp;
}
-
- });
+
+ });
}
-
+
public QueryPage executeBSHQuery(final String queryString, final QueryInputModel model)
{
return (QueryPage) executionContext.execute(new ExecutionContext.Command() {
-
+
public Object execute() {
Session session = getSessionFactory().openSession();
QueryPage qp = new JavaPage(ConsoleConfiguration.this,queryString,model);
qp.setSession(session);
-
- qp.setId(++execcount);
- fireQueryPageCreated(qp);
+
+ qp.setId(++execcount);
+ fireQueryPageCreated(qp);
return qp;
}
-
- });
+
+ });
}
-
+
private void fireQueryPageCreated(QueryPage qp) {
- Iterator i = consoleCfgListeners.iterator();
+ Iterator i = consoleCfgListeners.iterator();
while (i.hasNext() ) {
ConsoleConfigurationListener view = (ConsoleConfigurationListener) i.next();
view.queryPageCreated(qp);
- }
+ }
}
-
+
private void fireFactoryBuilt() {
Iterator i = consoleCfgListeners.iterator();
while (i.hasNext() ) {
@@ -444,26 +444,26 @@
}
public void addConsoleConfigurationListener(ConsoleConfigurationListener v) {
- consoleCfgListeners.add(v);
+ consoleCfgListeners.add(v);
}
-
+
public void removeConsoleConfigurationListener(ConsoleConfigurationListener sfListener)
{
- consoleCfgListeners.remove(sfListener);
+ consoleCfgListeners.remove(sfListener);
}
-
+
public ConsoleConfigurationListener[] getConsoleConfigurationListeners() {
return (ConsoleConfigurationListener[]) consoleCfgListeners.toArray(new
ConsoleConfigurationListener[consoleCfgListeners.size()]);
}
-
+
public boolean isSessionFactoryCreated() {
return sessionFactory!=null;
}
public ConsoleConfigurationPreferences getPreferences() {
return prefs;
- }
-
+ }
+
public String toString() {
return getClass().getName() + ":" + getName(); //$NON-NLS-1$
}
@@ -475,43 +475,43 @@
public void closeSessionFactory() {
if(sessionFactory!=null) {
fireFactoryClosing(sessionFactory);
- sessionFactory.close();
+ sessionFactory.close();
sessionFactory = null;
- }
+ }
}
public Settings getSettings(final Configuration cfg) {
return (Settings) execute(new Command() {
-
+
public Object execute() {
return cfg.buildSettings();
}
-
- });
+
+ });
}
// TODO: delegate to some extension point
private Configuration buildConfiguration(Properties properties, boolean includeMappings)
{
- Configuration localCfg = null;
+ Configuration localCfg = null;
if(prefs.getConfigurationMode().equals( ConfigurationMode.ANNOTATIONS )) {
try {
localCfg = buildAnnotationConfiguration();
localCfg = configureStandardConfiguration( includeMappings, localCfg, properties );
}
catch (Exception e) {
- throw new
HibernateConsoleRuntimeException(Messages.CONSOLECONFIGURATION_COULD_NOT_LOAD_ANNOTATIONCONFIGURATION,e);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_load_annotationconfiguration,e);
}
} else if(prefs.getConfigurationMode().equals( ConfigurationMode.JPA )) {
try {
localCfg = buildJPAConfiguration( getPreferences().getPersistenceUnitName(),
properties, prefs.getEntityResolverName(), includeMappings );
}
catch (Exception e) {
- throw new
HibernateConsoleRuntimeException(Messages.CONSOLECONFIGURATION_COULD_NOT_LOAD_JPA_CONFIGURATION,e);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_load_jpa_configuration,e);
}
} else {
- localCfg = new Configuration();
+ localCfg = new Configuration();
localCfg = configureStandardConfiguration( includeMappings, localCfg, properties );
- }
+ }
return localCfg;
}
@@ -524,25 +524,25 @@
try {
entityResolver = (EntityResolver)
ReflectHelper.classForName(prefs.getEntityResolverName()).newInstance();
} catch (Exception c) {
- throw new
HibernateConsoleRuntimeException(Messages.CONSOLECONFIGURATION_COULD_NOT_CONFIGURE_ENTITY_RESOLVER
+ prefs.getEntityResolverName(), c);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_configure_entity_resolver
+ prefs.getEntityResolverName(), c);
}
}
localCfg.setEntityResolver(entityResolver);
- if(StringHelper.isNotEmpty( prefs.getNamingStrategy())) {
+ if(StringHelper.isNotEmpty( prefs.getNamingStrategy())) {
try {
NamingStrategy ns = (NamingStrategy)
ReflectHelper.classForName(prefs.getNamingStrategy()).newInstance();
localCfg.setNamingStrategy( ns );
} catch (Exception c) {
- throw new
HibernateConsoleRuntimeException(Messages.CONSOLECONFIGURATION_COULD_NOT_CONFIGURE_NAMING_STRATEGY
+ prefs.getNamingStrategy(), c);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_configure_naming_strategy
+ prefs.getNamingStrategy(), c);
}
}
-
+
localCfg = loadConfigurationXML( localCfg, includeMappings, entityResolver );
-
+
return localCfg;
}
-
+
}
\ No newline at end of file
Copied:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.java
(from rev 8549,
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/Messages.java)
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -0,0 +1,42 @@
+package org.hibernate.console;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ConsoleMessages extends NLS {
+ private static final String BUNDLE_NAME =
"org.hibernate.console.ConsoleMessages"; //$NON-NLS-1$
+ public static String ConsoleConfiguration_could_not_access;
+ public static String ConsoleConfiguration_could_not_configure_entity_resolver;
+ public static String ConsoleConfiguration_could_not_configure_naming_strategy;
+ public static String ConsoleConfiguration_could_not_create_jpa_based_configuration;
+ public static String ConsoleConfiguration_could_not_load_annotationconfiguration;
+ public static String ConsoleConfiguration_could_not_load_jpa_configuration;
+ public static String ConsoleConfiguration_could_not_parse_configuration;
+ public static String ConsoleConfiguration_factory_not_closed_before_build_new_factory;
+ public static String ConsoleConfiguration_invalid_configuration;
+ public static String ConsoleConfiguration_persistence_unit_not_found;
+ public static String ConsoleConfiguration_problems_while_loading_database_driverclass;
+ public static String JavaPage_no_info;
+ public static String JavaPage_not_allowed;
+ public static String KnownConfigurations_could_not_write_state;
+ public static String KnownConfigurations_hibernate_log;
+ public static String KnownConfigurations_unknown;
+ public static String DefaultExecutionContext_existing_classloader;
+ public static String ClassNode_uninitialized_proxy;
+ public static String ConfigurationNode_mapped_entities;
+ public static String NodeFactory_unknown;
+ public static String PersistentCollectionNode_could_not_access_property_value;
+ public static String AbstractConsoleConfigurationPreferences_could_not_load_prop_file;
+ public static String AbstractConsoleConfigurationPreferences_name_not_null_or_empty;
+ public static String AbstractConsoleConfigurationPreferences_unknown;
+ public static String
StandAloneConsoleConfigurationPreferences_could_not_resolve_classpaths;
+ public static String StandAloneConsoleConfigurationPreferences_errors_while_parsing;
+ public static String PluginFileAppender_missing_plugin_state_location;
+ public static String PluginLogAppender_missing_layout_for_appender;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class);
+ }
+
+ private ConsoleMessages() {
+ }
+}
Copied:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.properties
(from rev 8549,
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/messages.properties)
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.properties
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleMessages.properties 2008-06-06
16:52:05 UTC (rev 8617)
@@ -0,0 +1,28 @@
+ConsoleConfiguration_could_not_access=Could not access
+ConsoleConfiguration_could_not_configure_entity_resolver=Could not configure entity
resolver
+ConsoleConfiguration_could_not_configure_naming_strategy=Could not configure naming
strategy
+ConsoleConfiguration_could_not_create_jpa_based_configuration=Could not create JPA based
Configuration
+ConsoleConfiguration_could_not_load_annotationconfiguration=Could not load
AnnotationConfiguration
+ConsoleConfiguration_could_not_load_jpa_configuration=Could not load JPA Configuration
+ConsoleConfiguration_could_not_parse_configuration=Could not parse configuration:
+ConsoleConfiguration_factory_not_closed_before_build_new_factory=Factory were not closed
before attempting to built a new factory.
+ConsoleConfiguration_invalid_configuration=invalid configuration
+ConsoleConfiguration_persistence_unit_not_found=Persistence unit not found:
'{0}'.
+ConsoleConfiguration_problems_while_loading_database_driverclass=Problems while loading
database driverclass ({0})
+JavaPage_no_info=<no info>
+JavaPage_not_allowed=System.exit not allowed\!
+KnownConfigurations_could_not_write_state=Could not write state
+KnownConfigurations_hibernate_log=Hibernate Log -
+KnownConfigurations_unknown=<unknown>
+DefaultExecutionContext_existing_classloader=Existing classloader is not equal to the
previously installed classloader\! Existing={0} Previous={1}
+ClassNode_uninitialized_proxy=(uninitialized proxy)
+ConfigurationNode_mapped_entities=Mapped entities
+NodeFactory_unknown=Unknown ->
+PersistentCollectionNode_could_not_access_property_value=Could not access property value
+AbstractConsoleConfigurationPreferences_could_not_load_prop_file=Could not load property
file
+AbstractConsoleConfigurationPreferences_name_not_null_or_empty=Name cannot be null or
empty
+AbstractConsoleConfigurationPreferences_unknown=<unknown>
+StandAloneConsoleConfigurationPreferences_could_not_resolve_classpaths=Could not resolve
classpaths
+StandAloneConsoleConfigurationPreferences_errors_while_parsing=Errors while parsing
+PluginFileAppender_missing_plugin_state_location=Missing Plugin State Location.
+PluginLogAppender_missing_layout_for_appender=Missing layout for appender
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/JavaPage.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -38,11 +38,11 @@
/**
* @author MAX
*
- *
+ *
*/
public class JavaPage extends AbstractQueryPage {
- private String criteriaCode;
+ private String criteriaCode;
Criteria criteria = null;
@@ -51,7 +51,7 @@
private QueryInputModel model;
/**
- * @param model
+ * @param model
* @param session2
*/
public JavaPage(ConsoleConfiguration cfg, String criteriaCode, QueryInputModel model)
{
@@ -65,7 +65,7 @@
try {
if(criteriaCode.indexOf( "System.exit" )>=0) { // TODO: externalize
run so we don't need this bogus check! //$NON-NLS-1$
list = Collections.EMPTY_LIST;
- addException( new IllegalArgumentException(Messages.JAVAPAGE_NOT_ALLOWED) );
+ addException( new
IllegalArgumentException(ConsoleMessages.JavaPage_not_allowed) );
return;
}
ip = setupInterpreter(getSession() );
@@ -83,26 +83,26 @@
}
} else {
list = new ArrayList();
- list.add(o);
- }
- }
+ list.add(o);
+ }
+ }
catch (EvalError e) {
- addException(e);
- }
+ addException(e);
+ }
catch (HibernateException e) {
- addException(e);
- }
+ addException(e);
+ }
}
-
+
private Interpreter setupInterpreter(Session session) throws EvalError,
HibernateException {
Interpreter interpreter = new Interpreter();
-
+
interpreter.set("session", session); //$NON-NLS-1$
interpreter.setClassLoader( Thread.currentThread().getContextClassLoader() );
SessionImplementor si = (SessionImplementor)session;
-
+
Map map = si.getFactory().getAllClassMetadata();
-
+
Iterator iterator = map.keySet().iterator();
//TODO: filter non classes.
String imports = new String();
@@ -110,12 +110,12 @@
String element = (String) iterator.next();
imports += "import " + element + ";\n"; //$NON-NLS-1$
//$NON-NLS-2$
}
-
+
imports += "import org.hibernate.criterion.*;\n"; //$NON-NLS-1$
imports += "import org.hibernate.*;\n"; //$NON-NLS-1$
// TODO: expose the parameters as values to be used in the code.
interpreter.eval(imports);
-
+
return interpreter;
}
@@ -123,24 +123,24 @@
if(list!=null) return list;
try {
if(criteria!=null) {
- long startTime = System.currentTimeMillis();
+ long startTime = System.currentTimeMillis();
list = criteria.list();
queryTime = System.currentTimeMillis() - startTime;
- }
+ }
else {
return Collections.EMPTY_LIST;
}
- }
+ }
catch (HibernateException e) {
list = Collections.EMPTY_LIST;
addException(e);
- }
+ }
return list;
}
public List getPathNames() {
List l = new ArrayList();
- l.add(Messages.JAVAPAGE_NO_INFO);
+ l.add(ConsoleMessages.JavaPage_no_info);
return l;
}
@@ -149,7 +149,7 @@
}
public void release() {
-
+
super.release();
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -64,12 +64,12 @@
*/
public class KnownConfigurations {
- // TODO: is the best way for the querypage model ?
- private QueryPageModel queryPages = new QueryPageModel();
+ // TODO: is the best way for the querypage model ?
+ private QueryPageModel queryPages = new QueryPageModel();
private List configurationListeners = new ArrayList();
private Map configurations;
private ConsoleConfigurationListener sfListener = new ConsoleConfigurationListener() {
-
+
public void sessionFactoryClosing(final ConsoleConfiguration configuration, final
SessionFactory closingFactory) {
fireNotification(new Notification() {
public void notify(KnownConfigurationsListener listener) {
@@ -77,34 +77,34 @@
}
});
}
-
+
public void sessionFactoryBuilt(final ConsoleConfiguration ccfg, final SessionFactory
builtSessionFactory) {
fireNotification(new Notification() {
public void notify(KnownConfigurationsListener listener) {
- listener.sessionFactoryBuilt(ccfg, builtSessionFactory);
+ listener.sessionFactoryBuilt(ccfg, builtSessionFactory);
}
});
}
public void queryPageCreated(QueryPage qp) {
- queryPages.add(qp);
+ queryPages.add(qp);
}
-
+
};
private static KnownConfigurations instance;
-
+
public static synchronized KnownConfigurations getInstance() {
if (instance == null) {
instance = new KnownConfigurations();
}
return instance;
}
-
-
-
+
+
+
private abstract class Notification {
-
+
public void run(KnownConfigurationsListener listener) {
notify(listener);
}
@@ -115,16 +115,16 @@
*/
protected abstract void notify(KnownConfigurationsListener listener);
}
-
+
/**
* Register to receive notification of repository creation and disposal
*/
public void addConsoleConfigurationListener(KnownConfigurationsListener listener) {
synchronized(configurationListeners) {
- configurationListeners.add(listener);
+ configurationListeners.add(listener);
}
}
-
+
/**
* De-register a listener
*/
@@ -136,7 +136,7 @@
/**
* Add the repository to the receiver's list of known configurations. Doing this
will enable
- *
+ *
*/
public ConsoleConfiguration addConfiguration(final ConsoleConfiguration configuration,
boolean broadcast) {
// Check the cache for an equivalent instance and if there is one, just update the
cache
@@ -145,11 +145,11 @@
// Store the location
// Cache the location instance for later retrieval
getRepositoriesMap().put(configuration.getName(), configuration);
- configuration.addConsoleConfigurationListener(sfListener);
+ configuration.addConsoleConfigurationListener(sfListener);
existingConfiguration = configuration;
}
-
+
if (broadcast) {
fireNotification(new Notification() {
public void notify(KnownConfigurationsListener listener) {
@@ -159,19 +159,19 @@
}
return existingConfiguration;
}
-
+
public void removeAllConfigurations() {
ConsoleConfiguration[] cfgs = getConfigurations();
for (int i = 0; i < cfgs.length; i++) {
ConsoleConfiguration configuration = cfgs[i];
removeConfiguration(configuration, false);
}
-
+
}
-
+
// added forUpdate as a workaround for letting listeners know it is done to update the
configuration so they don't cause removal issues.
public void removeConfiguration(final ConsoleConfiguration configuration, final boolean
forUpdate) {
-
+
ConsoleConfiguration oldConfig = (ConsoleConfiguration)
getRepositoriesMap().remove(configuration.getName() );
if (oldConfig != null) {
oldConfig.removeConsoleConfigurationListener(sfListener);
@@ -182,13 +182,13 @@
});
oldConfig.reset();
removeLoggingStream( oldConfig );
-
+
}
-
-
+
+
}
-
+
/**
* Answer whether the provided configuration name is known by the provider or not.
* The name string corresponds to the Strin returned by ConsoleConfiguration#getName()
@@ -197,13 +197,13 @@
return internalGetRepository(name) != null;
}
- /**
+ /**
* Return a list of the know repository locations
*/
public ConsoleConfiguration[] getConfigurations() {
return (ConsoleConfiguration[])getRepositoriesMap().values().toArray(new
ConsoleConfiguration[getRepositoriesMap().size()]);
}
-
+
public ConsoleConfiguration[] getConfigurationsSortedByName() {
return getConfigurations(new Comparator() {
public boolean equals(Object obj) {
@@ -217,31 +217,31 @@
}
});
}
-
+
public ConsoleConfiguration[] getConfigurations(Comparator c) {
ConsoleConfiguration[] configurations = getConfigurations();
Arrays.sort(configurations, c);
return configurations;
}
-
+
private ConsoleConfiguration internalGetRepository(String location) {
return (ConsoleConfiguration) getRepositoriesMap().get(location);
}
-
-
+
+
private Map getRepositoriesMap() {
if (configurations == null) {
configurations = new TreeMap();
}
return configurations;
}
-
+
private KnownConfigurationsListener[] getListeners() {
synchronized(configurationListeners) {
return (KnownConfigurationsListener[]) configurationListeners.toArray(new
KnownConfigurationsListener[configurationListeners.size()]);
}
}
-
+
private void fireNotification(Notification notification) {
// Get a snapshot of the listeners so the list doesn't change while we're
firing
KnownConfigurationsListener[] listeners = getListeners();
@@ -253,27 +253,27 @@
}
BaseNode rootNode = new ConfigurationListNode(this);
-
+
public BaseNode getRootNode() {
- return rootNode;
+ return rootNode;
}
// TODO: decouple this logging from Eclipse platform!
private Map loggingStreams = new HashMap();
public MessageConsoleStream findLoggingStream(String name) {
- Object[] console = (Object[]) loggingStreams.get(name);
+ Object[] console = (Object[]) loggingStreams.get(name);
if(console==null) {
console = new Object[2];
- String secondaryId = Messages.KNOWNCONFIGURATIONS_HIBERNATE_LOG +
(name==null?Messages.KNOWNCONFIGURATIONS_UNKNOWN:name);
+ String secondaryId = ConsoleMessages.KnownConfigurations_hibernate_log +
(name==null?ConsoleMessages.KnownConfigurations_unknown:name);
console[0] = new MessageConsole(secondaryId, null);
IConsoleManager consoleManager =
ConsolePlugin.getDefault().getConsoleManager();
consoleManager.addConsoles(new IConsole[] { (IConsole) console[0] });
console[1] = ((MessageConsole)console[0]).newMessageStream();
loggingStreams.put(name, console);
- }
+ }
return (MessageConsoleStream) console[1];
}
-
+
private void removeLoggingStream(ConsoleConfiguration oldConfig) {
Object[] object = (Object[]) loggingStreams.remove( oldConfig.getName() );
if(object!=null) {
@@ -281,17 +281,17 @@
MessageConsoleStream stream = (MessageConsoleStream)object[1];
try { stream.close(); } catch(IOException ie) { /* ignore */ };
IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
- consoleManager.removeConsoles( new IConsole[] { mc } );
+ consoleManager.removeConsoles( new IConsole[] { mc } );
}
}
-
+
public ConsoleConfiguration find(String lastUsedName) {
if(configurations==null) return null;
if(lastUsedName==null) return null;
return (ConsoleConfiguration) configurations.get(lastUsedName);
}
-
+
public QueryPageModel getQueryPageModel() {
return queryPages;
}
@@ -301,36 +301,36 @@
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
-
+
Element element = document.createElement("hibernate-console");
//$NON-NLS-1$
Node node = document.appendChild(element);
-
+
ConsoleConfiguration[] configs = getConfigurations();
for (int i = 0; i < configs.length; i++) {
ConsoleConfiguration cfg = configs[i];
cfg.getPreferences().writeStateTo(element);
}
-
+
writeXml(document, f);
- }
+ }
catch (TransformerConfigurationException e) {
- throw new
HibernateConsoleRuntimeException(Messages.KNOWNCONFIGURATIONS_COULD_NOT_WRITE_STATE,e);
- }
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.KnownConfigurations_could_not_write_state,e);
+ }
catch (TransformerException e) {
- throw new
HibernateConsoleRuntimeException(Messages.KNOWNCONFIGURATIONS_COULD_NOT_WRITE_STATE,e);
- }
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.KnownConfigurations_could_not_write_state,e);
+ }
catch (ParserConfigurationException e) {
- throw new
HibernateConsoleRuntimeException(Messages.KNOWNCONFIGURATIONS_COULD_NOT_WRITE_STATE,e);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.KnownConfigurations_could_not_write_state,e);
}
}
private void writeXml(Document document, File f) throws
TransformerConfigurationException, TransformerFactoryConfigurationError,
TransformerException {
// Prepare the DOM document for writing
Source source = new DOMSource(document);
-
+
// Prepare the output file
Result result = new StreamResult(f);
-
+
// Write the DOM document to the file
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.setOutputProperty(OutputKeys.INDENT, "true"); //$NON-NLS-1$
@@ -338,14 +338,14 @@
}
List queryParameters = new ArrayList();
-
+
public ConsoleQueryParameter[] getQueryParameters() {
return (ConsoleQueryParameter[]) queryParameters.toArray(new
ConsoleQueryParameter[queryParameters.size()]);
}
-
+
public List getQueryParameterList() {
return queryParameters;
- }
-
-
+ }
+
+
}
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/Messages.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/Messages.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,30 +0,0 @@
-package org.hibernate.console;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.hibernate.console.messages";
//$NON-NLS-1$
- public static String CONSOLECONFIGURATION_COULD_NOT_ACCESS;
- public static String CONSOLECONFIGURATION_COULD_NOT_CONFIGURE_ENTITY_RESOLVER;
- public static String CONSOLECONFIGURATION_COULD_NOT_CONFIGURE_NAMING_STRATEGY;
- public static String CONSOLECONFIGURATION_COULD_NOT_CREATE_JPA_BASED_CONFIGURATION;
- public static String CONSOLECONFIGURATION_COULD_NOT_LOAD_ANNOTATIONCONFIGURATION;
- public static String CONSOLECONFIGURATION_COULD_NOT_LOAD_JPA_CONFIGURATION;
- public static String CONSOLECONFIGURATION_COULD_NOT_PARSE_CONFIGURATION;
- public static String CONSOLECONFIGURATION_FACTORY_NOT_CLOSED_BEFORE_BUILD_NEW_FACTORY;
- public static String CONSOLECONFIGURATION_INVALID_CONFIGURATION;
- public static String CONSOLECONFIGURATION_PERSISTENCE_UNIT_NOT_FOUND;
- public static String CONSOLECONFIGURATION_PROBLEMS_WHILE_LOADING_DATABASE_DRIVERCLASS;
- public static String JAVAPAGE_NO_INFO;
- public static String JAVAPAGE_NOT_ALLOWED;
- public static String KNOWNCONFIGURATIONS_COULD_NOT_WRITE_STATE;
- public static String KNOWNCONFIGURATIONS_HIBERNATE_LOG;
- public static String KNOWNCONFIGURATIONS_UNKNOWN;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -26,16 +26,17 @@
import java.util.WeakHashMap;
import org.eclipse.osgi.util.NLS;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.eclipse.logging.CurrentContext;
public class DefaultExecutionContext implements ExecutionContext {
- final private URLClassLoader configurationClassLoader;
+ final private URLClassLoader configurationClassLoader;
private volatile int installs;
private Map previousLoaders = new WeakHashMap();
final String key;
-
+
public DefaultExecutionContext(String key, URLClassLoader loader) {
configurationClassLoader = loader;
this.key = key;
@@ -49,10 +50,10 @@
if(configurationClassLoader!=null &&
Thread.currentThread().getContextClassLoader() != configurationClassLoader) {
previousLoaders.put(Thread.currentThread(),
Thread.currentThread().getContextClassLoader() );
Thread.currentThread().setContextClassLoader(configurationClassLoader);
- }
-
+ }
+
}
-
+
/* (non-Javadoc)
* @see
org.hibernate.console.IExecutionContext#execute(org.hibernate.console.ExecutionContext.Command)
*/
@@ -61,31 +62,31 @@
CurrentContext.push( key );
installLoader();
return c.execute();
- }
+ }
finally {
uninstallLoader();
CurrentContext.pop();
}
}
-
+
/* (non-Javadoc)
* @see org.hibernate.console.IExecutionContext#uninstallLoader()
*/
public void uninstallLoader() {
installs--; // TODO: make more safe (synchronized) bookkeeping of the classloader
installation.
-
+
if(installs==0) {
ClassLoader cl = (ClassLoader) previousLoaders.get(Thread.currentThread() );
if(configurationClassLoader!=null &&
Thread.currentThread().getContextClassLoader() != configurationClassLoader) {
- String out = NLS.bind(Messages.DEFAULTEXECUTIONCONTEXT_EXISTING_CLASSLOADER,
Thread.currentThread().getContextClassLoader(), configurationClassLoader);
+ String out = NLS.bind(ConsoleMessages.DefaultExecutionContext_existing_classloader,
Thread.currentThread().getContextClassLoader(), configurationClassLoader);
throw new IllegalStateException(out);
}
-
+
if(cl!=null) {
previousLoaders.remove(Thread.currentThread() );
Thread.currentThread().setContextClassLoader(cl);
- }
- }
+ }
+ }
}
-
+
}
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/Messages.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/Messages.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,15 +0,0 @@
-package org.hibernate.console.execution;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME =
"org.hibernate.console.execution.messages"; //$NON-NLS-1$
- public static String DEFAULTEXECUTIONCONTEXT_EXISTING_CLASSLOADER;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/messages.properties 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/messages.properties 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1 +0,0 @@
-DEFAULTEXECUTIONCONTEXT_EXISTING_CLASSLOADER=Existing classloader is not equal to the
previously installed classloader\! Existing={0} Previous={1}
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/messages.properties 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/messages.properties 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,16 +0,0 @@
-CONSOLECONFIGURATION_COULD_NOT_ACCESS=Could not access
-CONSOLECONFIGURATION_COULD_NOT_CONFIGURE_ENTITY_RESOLVER=Could not configure entity
resolver
-CONSOLECONFIGURATION_COULD_NOT_CONFIGURE_NAMING_STRATEGY=Could not configure naming
strategy
-CONSOLECONFIGURATION_COULD_NOT_CREATE_JPA_BASED_CONFIGURATION=Could not create JPA based
Configuration
-CONSOLECONFIGURATION_COULD_NOT_LOAD_ANNOTATIONCONFIGURATION=Could not load
AnnotationConfiguration
-CONSOLECONFIGURATION_COULD_NOT_LOAD_JPA_CONFIGURATION=Could not load JPA Configuration
-CONSOLECONFIGURATION_COULD_NOT_PARSE_CONFIGURATION=Could not parse configuration:
-CONSOLECONFIGURATION_FACTORY_NOT_CLOSED_BEFORE_BUILD_NEW_FACTORY=Factory were not closed
before attempting to built a new factory.
-CONSOLECONFIGURATION_INVALID_CONFIGURATION=invalid configuration
-CONSOLECONFIGURATION_PERSISTENCE_UNIT_NOT_FOUND=Persistence unit not found:
'{0}'.
-CONSOLECONFIGURATION_PROBLEMS_WHILE_LOADING_DATABASE_DRIVERCLASS=Problems while loading
database driverclass ({0})
-JAVAPAGE_NO_INFO=<no info>
-JAVAPAGE_NOT_ALLOWED=System.exit not allowed\!
-KNOWNCONFIGURATIONS_COULD_NOT_WRITE_STATE=Could not write state
-KNOWNCONFIGURATIONS_HIBERNATE_LOG=Hibernate Log -
-KNOWNCONFIGURATIONS_UNKNOWN=<unknown>
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ClassNode.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -26,6 +26,7 @@
import org.hibernate.EntityMode;
import org.hibernate.Hibernate;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.console.ImageConstants;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.type.CollectionType;
@@ -40,22 +41,22 @@
ClassMetadata md;
boolean objectGraph;
-
+
Object baseObject;
boolean childrenCreated = false;
- public ClassNode(NodeFactory factory, BaseNode parent, String name, ClassMetadata
metadata, Object baseObject, boolean objectGraph) {
-
+ public ClassNode(NodeFactory factory, BaseNode parent, String name, ClassMetadata
metadata, Object baseObject, boolean objectGraph) {
+
super(factory, parent);
this.name = name;
this.baseObject = baseObject;
this.objectGraph = objectGraph;
-
+
md = metadata;
if (md != null) { // Don't have any hibernate related info about this one...
iconName = ImageConstants.MAPPEDCLASS;
} else {
- iconName = ImageConstants.UNMAPPEDCLASS;
- }
+ iconName = ImageConstants.UNMAPPEDCLASS;
+ }
}
protected void checkChildren() {
@@ -64,51 +65,51 @@
childrenCreated = true;
}
}
-
+
protected void createChildren() {
//System.out.println("Creating children for: " + this);
-
+
if(objectGraph && getValue()==null || md == null) {
return;
- }
-
-
+ }
+
+
// Identifier
if(md.getIdentifierPropertyName()!=null) {
- children.add(0, factory.createIdentifierNode(this, md) );
+ children.add(0, factory.createIdentifierNode(this, md) );
}
-
+
String[] names = md.getPropertyNames();
for (int i = 0; i < names.length; i++) {
Type type = md.getPropertyTypes()[i];
-
+
if(type.isCollectionType() ) {
PersistentCollectionNode tn =
factory.createPersistentCollectionNode(this, names[i], md, (CollectionType)type,
getValue(), objectGraph);
- children.add(tn);
+ children.add(tn);
} else {
children.add(factory.createPropertyNode(this, i, md, getValue(),
objectGraph) );
- }
- }
- }
+ }
+ }
+ }
public String getHQL() {
List parents = new ArrayList();
-
+
BaseNode currentParent;
currentParent = this;
while (currentParent != null && !(currentParent instanceof
ConfigurationEntitiesNode) ) {
parents.add(currentParent);
currentParent = currentParent.parent;
}
-
+
if(currentParent instanceof ConfigurationEntitiesNode) {
currentParent = (BaseNode) parents.get(parents.size()-1);
}
-
+
// currentParent is the root
String cname = (
(ClassNode)currentParent).md.getMappedClass(EntityMode.POJO).getName();
-
+
if (cname.lastIndexOf(".") != -1) { //$NON-NLS-1$
cname = cname.substring(cname.lastIndexOf(".") + 1); //$NON-NLS-1$
}
@@ -121,7 +122,7 @@
return "select " + alias + path + " from " + cname + " as
" + alias; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
+
public ClassMetadata getClassMetadata() {
return md;
}
@@ -132,14 +133,14 @@
if(Hibernate.isInitialized(o) ) {
return super.renderLabel(fullyQualifiedNames) + " = " + o; //$NON-NLS-1$
} else {
- return super.renderLabel(fullyQualifiedNames) + " = " +
Messages.CLASSNODE_UNINITIALIZED_PROXY; //$NON-NLS-1$
+ return super.renderLabel(fullyQualifiedNames) + " = " +
ConsoleMessages.ClassNode_uninitialized_proxy; //$NON-NLS-1$
}
-
+
} else {
return super.renderLabel(fullyQualifiedNames);
}
}
-
+
public Object getValue() {
if(objectGraph) {
return baseObject;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/ConfigurationNode.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -24,6 +24,7 @@
import org.hibernate.SessionFactory;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.ConsoleConfigurationListener;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.console.ImageConstants;
import org.hibernate.console.QueryPage;
@@ -31,26 +32,26 @@
* @author max
*
*/
-public class ConfigurationNode extends BaseNode {
-
+public class ConfigurationNode extends BaseNode {
+
private final ConsoleConfiguration configuration;
private boolean childrenCreated;
public ConfigurationNode(BaseNode parent, ConsoleConfiguration configuration) {
super(null,parent);
- this.configuration = configuration;
+ this.configuration = configuration;
configuration.addConsoleConfigurationListener(new ConsoleConfigurationListener() {
public void sessionFactoryBuilt(ConsoleConfiguration ccfg, SessionFactory
builtSessionFactory) {
clear();
}
-
+
public void sessionFactoryClosing(ConsoleConfiguration configuration, SessionFactory
closedSessionFactory) {
clear();
}
public void queryPageCreated(QueryPage qp) { }
});
-
+
name = configuration.getName();
iconName = ImageConstants.CONFIGURATION;
}
@@ -58,27 +59,27 @@
public ConsoleConfiguration getConsoleConfiguration() {
return configuration;
}
-
+
protected void checkChildren() {
if(!childrenCreated) {
if(configuration.isSessionFactoryCreated() ) {
NodeFactory fac = new NodeFactory(configuration);
- children.add(fac.createConfigurationEntitiesNode(Messages.CONFIGURATIONNODE_MAPPED_ENTITIES)
);
+ children.add(fac.createConfigurationEntitiesNode(ConsoleMessages.ConfigurationNode_mapped_entities)
);
childrenCreated=true;
-
+
/*Configuration cfg = configuration.getConfiguration();
Iterator iter = cfg.getTableMappings();
while (iter.hasNext() ) {// todo: move to nodefactory.
Table table = (Table) iter.next();
TableNode node = NodeFactory.createTableNode(this,table);
children.add(node);
- } */
+ } */
}else {
children.clear();
}
- }
+ }
}
-
+
public String getHQL() {
// TODO Auto-generated method stub
return null;
@@ -90,5 +91,5 @@
public void clear() {
super.clear();
childrenCreated = false;
- }
+ }
}
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/Messages.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/Messages.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,18 +0,0 @@
-package org.hibernate.console.node;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME =
"org.hibernate.console.node.messages"; //$NON-NLS-1$
- public static String CLASSNODE_UNINITIALIZED_PROXY;
- public static String CONFIGURATIONNODE_MAPPED_ENTITIES;
- public static String NODEFACTORY_UNKNOWN;
- public static String PERSISTENTCOLLECTIONNODE_COULD_NOT_ACCESS_PROPERTY_VALUE;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/NodeFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/NodeFactory.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/NodeFactory.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -32,6 +32,7 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.console.ImageConstants;
import org.hibernate.mapping.Table;
import org.hibernate.metadata.ClassMetadata;
@@ -50,15 +51,15 @@
private Map collectionMetaData;
private ConsoleConfiguration consoleConfiguration;
-
-
-
-
+
+
+
+
/**
* @param c
*/
public NodeFactory(ConsoleConfiguration c) throws HibernateException {
- setConsoleConfiguration(c);
+ setConsoleConfiguration(c);
}
private void setConsoleConfiguration(ConsoleConfiguration c) {
@@ -73,11 +74,11 @@
public ConfigurationEntitiesNode createConfigurationEntitiesNode(String name) {
Enhancer e = ProxyFactory.createEnhancer(ConfigurationEntitiesNode.class);
-
- return (ConfigurationEntitiesNode) e.create(new Class[] { String.class,
NodeFactory.class, List.class },
+
+ return (ConfigurationEntitiesNode) e.create(new Class[] { String.class,
NodeFactory.class, List.class },
new Object[] { name, this, classes });
-
- //return new RootNode(this, classes);
+
+ //return new RootNode(this, classes);
}
public BaseNode createObjectNode(Session session, Object o) throws HibernateException
{
@@ -92,10 +93,10 @@
}
private ClassNode internalCreateClassNode(BaseNode node, String clazz,ClassMetadata md,
Object o, boolean objectGraph) {
-
+
Enhancer e = ProxyFactory.createEnhancer(ClassNode.class);
-
- return (ClassNode) e.create(new Class[] { NodeFactory.class, BaseNode.class,
String.class, ClassMetadata.class, Object.class, boolean.class},
+
+ return (ClassNode) e.create(new Class[] { NodeFactory.class, BaseNode.class,
String.class, ClassMetadata.class, Object.class, boolean.class},
new Object[] { this, node, clazz, md,o, Boolean.valueOf(objectGraph) } );
}
@@ -109,17 +110,17 @@
}
public CollectionMetadata getCollectionMetaData(String role) {
- return (CollectionMetadata) collectionMetaData.get(role);
+ return (CollectionMetadata) collectionMetaData.get(role);
}
-
+
public BaseNode createPropertyNode(BaseNode parent, int idx, ClassMetadata metadata) {
return createPropertyNode(parent, idx, metadata, null,false);
}
-
+
public BaseNode createPropertyNode(BaseNode node, int i, ClassMetadata md, Object
baseObject, boolean objectGraph) {
Enhancer e = ProxyFactory.createEnhancer(PropertyNode.class);
-
- return (BaseNode) e.create(new Class[] { NodeFactory.class, BaseNode.class,
int.class, ClassMetadata.class, Object.class, boolean.class},
+
+ return (BaseNode) e.create(new Class[] { NodeFactory.class, BaseNode.class,
int.class, ClassMetadata.class, Object.class, boolean.class},
new Object[] { this, node, new
Integer(i),md,baseObject,Boolean.valueOf(objectGraph) } );
}
@@ -131,8 +132,8 @@
*/
public IdentifierNode createIdentifierNode(BaseNode parent, ClassMetadata md) {
Enhancer e = ProxyFactory.createEnhancer(IdentifierNode.class);
-
- return (IdentifierNode) e.create(new Class[] { NodeFactory.class, BaseNode.class,
ClassMetadata.class},
+
+ return (IdentifierNode) e.create(new Class[] { NodeFactory.class, BaseNode.class,
ClassMetadata.class},
new Object[] { this, parent, md } );
//return new IdentifierNode(this, parent, md);
}
@@ -140,29 +141,29 @@
public BaseNode createNode(BaseNode parent, final Class clazz) {
ClassMetadata metadata = getMetaData(clazz);
if(metadata!=null) {
- return createClassNode(parent, clazz.getName() );
+ return createClassNode(parent, clazz.getName() );
}
-
+
return new BaseNode(this, parent) {
public String getHQL() {
return null;
}
-
+
public String getName() {
- return Messages.NODEFACTORY_UNKNOWN + clazz;
+ return ConsoleMessages.NodeFactory_unknown + clazz;
}
-
+
protected void checkChildren() {
// TODO Auto-generated method stub
}
};
- }
-
+ }
+
public PersistentCollectionNode createPersistentCollectionNode(ClassNode node, String
name, ClassMetadata md, CollectionType type, Object baseObject, boolean objectGraph) {
Enhancer e = ProxyFactory.createEnhancer(PersistentCollectionNode.class);
-
+
return (PersistentCollectionNode) e.create(
- new Class[] { NodeFactory.class, BaseNode.class, String.class,
CollectionType.class, ClassMetadata.class, CollectionMetadata.class, Object.class,
boolean.class},
+ new Class[] { NodeFactory.class, BaseNode.class, String.class,
CollectionType.class, ClassMetadata.class, CollectionMetadata.class, Object.class,
boolean.class},
new Object[] { this, node, name, type, md,
getCollectionMetaData(type.getRole() ), baseObject, Boolean.valueOf(objectGraph) } );
//return new PersistentCollectionNode(this, node, name, type, md,
getCollectionMetaData(type.getRole() ), baseObject, objectGraph);
}
@@ -172,7 +173,7 @@
if(type.isEntityType() ) {
EntityType et = (EntityType) type;
if(!et.isOneToOne() ) {
- result = ImageConstants.MANYTOONE;
+ result = ImageConstants.MANYTOONE;
} else {
result = ImageConstants.ONETOONE;
}
@@ -186,11 +187,11 @@
} else {
result = ImageConstants.PROPERTY;
}
-
+
return result;
}
-
-
+
+
public ConsoleConfiguration getConsoleConfiguration() {
return consoleConfiguration;
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/PersistentCollectionNode.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -28,6 +28,7 @@
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.type.CollectionType;
@@ -45,7 +46,7 @@
private boolean objectGraph;
private Object baseObject;
private Object collectionObject;
-
+
boolean childrenCreated = false;
private ClassMetadata md;
public PersistentCollectionNode(NodeFactory factory, BaseNode parent, String name,
CollectionType type, ClassMetadata md, CollectionMetadata metadata, Object baseObject,
boolean objectGraph) {
@@ -55,9 +56,9 @@
this.name = name;
this.baseObject = baseObject;
this.objectGraph = objectGraph;
-
-
-
+
+
+
iconName = factory.getIconNameForType(type);
this.elementType = metadata.getElementType();
if(objectGraph) {
@@ -66,13 +67,13 @@
virtualNode = factory.createNode(null, elementType.getReturnedClass() );
}
}
-
+
Object initCollectionObject() {
if(collectionObject!=null) return collectionObject;
try {
collectionObject = md.getPropertyValue(baseObject, name, EntityMode.POJO);
} catch (HibernateException e) {
- IllegalArgumentException iae = new
IllegalArgumentException(Messages.PERSISTENTCOLLECTIONNODE_COULD_NOT_ACCESS_PROPERTY_VALUE);
+ IllegalArgumentException iae = new
IllegalArgumentException(ConsoleMessages.PersistentCollectionNode_could_not_access_property_value);
iae.initCause(e);
throw iae;
}
@@ -82,7 +83,7 @@
public String getHQL() {
return ""; //$NON-NLS-1$
}
-
+
public TreeNode getChildAt(int childIndex) {
checkChildren();
if(objectGraph) {
@@ -125,24 +126,24 @@
int idx = 0;
if(!type.isArrayType() ) {
Iterator i = ( (Collection)collectionObject).iterator();
-
+
while (i.hasNext() ) {
Object element = i.next();
-
+
children.add(createNode(idx++,element, elementType) );
}
} else {
Object[] os = (Object[]) collectionObject;
for (int i = 0; i < os.length; i++) {
Object element = os[i];
- children.add(createNode(idx++, element, elementType) );
+ children.add(createNode(idx++, element, elementType) );
}
-
+
}
-
+
childrenCreated = true;
}
-
+
}
private Object createNode(int idx, Object element, Type type) { // TODO: use a common
way to create these darn nodes!
@@ -152,8 +153,8 @@
public String renderLabel(boolean b) {
return getLabel(getName(),b) + " : " +
getLabel(type.getReturnedClass().getName(),b) + "<" +
getLabel(elementType.getReturnedClass().getName(),b) + ">";
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
-
- public Type getType() {
+
+ public Type getType() {
return type;
}
}
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/messages.properties 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/node/messages.properties 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,4 +0,0 @@
-CLASSNODE_UNINITIALIZED_PROXY=(uninitialized proxy)
-CONFIGURATIONNODE_MAPPED_ENTITIES=Mapped entities
-NODEFACTORY_UNKNOWN=Unknown ->
-PERSISTENTCOLLECTIONNODE_COULD_NOT_ACCESS_PROPERTY_VALUE=Could not access property value
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/AbstractConsoleConfigurationPreferences.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/AbstractConsoleConfigurationPreferences.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/AbstractConsoleConfigurationPreferences.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -26,6 +26,7 @@
import java.io.IOException;
import java.util.Properties;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.console.HibernateConsoleRuntimeException;
import org.hibernate.util.StringHelper;
import org.w3c.dom.Document;
@@ -42,17 +43,17 @@
static final String PROJECT_ATTRIB = "project"; //$NON-NLS-1$
static final String USE_PROJECT_CLASSPATH_ATTRIB = "use-project-classpath";
//$NON-NLS-1$
-
-
+
+
private String projectName;
- private String name = Messages.ACCP_UNKNOWN;
+ private String name = ConsoleMessages.AbstractConsoleConfigurationPreferences_unknown;
protected String entityResolverName = null;
private boolean useProjectClasspath;
private ConfigurationMode configurationMode;
private String persistenceUnitName;
private String namingStrategy;
-
+
public AbstractConsoleConfigurationPreferences(String name, ConfigurationMode
configurationMode, String projectName, boolean useProjectclassPath, String entityResolver,
String persistenceUnitName, String namingStrategy) {
setName(name);
this.persistenceUnitName = persistenceUnitName;
@@ -62,28 +63,28 @@
this.projectName = projectName;
this.useProjectClasspath = useProjectclassPath;
}
-
+
protected AbstractConsoleConfigurationPreferences() {
}
-
+
public ConfigurationMode getConfigurationMode() {
return configurationMode;
}
-
+
public String getPersistenceUnitName() {
return persistenceUnitName;
}
-
+
public String getNamingStrategy() {
return namingStrategy;
}
-
+
public void setName(String name) {
if(name==null || name.trim().length()==0) {
- throw new IllegalArgumentException(Messages.ACCP_NAME_NOT_NULL_OR_EMPTY);
+ throw new
IllegalArgumentException(ConsoleMessages.AbstractConsoleConfigurationPreferences_name_not_null_or_empty);
}
-
+
this.name = name;
}
@@ -97,14 +98,14 @@
try {
Properties p = new Properties();
p.load(new FileInputStream(propFile) );
- return p;
- }
+ return p;
+ }
catch(IOException io) {
- throw new HibernateConsoleRuntimeException(Messages.ACCP_COULD_NOT_LOAD_PROP_FILE +
propFile, io);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.AbstractConsoleConfigurationPreferences_could_not_load_prop_file
+ propFile, io);
}
}
- /** generic xml dumper that just dumps the toString representation of the paramters
+ /** generic xml dumper that just dumps the toString representation of the paramters
* @param useAnnotations */
protected static void writeStateTo(Node node, String name, String entityResolver,
ConfigurationMode configurationMode, String projectName, boolean useProjectClasspath,
Object cfgFile, Object propertyFilename, Object[] mappings, Object[] customClasspath) {
Document doc = node.getOwnerDocument();
@@ -113,80 +114,80 @@
n.setAttribute(ANNOTATIONS_ATTRIB, "true");
}*/
n.setAttribute(CONFIGURATION_MODE_ATTRIB, configurationMode.toString());
-
+
if(StringHelper.isNotEmpty(entityResolver)) {
n.setAttribute(ENTITYRESOLVER_ATTRIB, entityResolver);
}
-
+
if(useProjectClasspath) {
n.setAttribute( USE_PROJECT_CLASSPATH_ATTRIB, "true" ); //$NON-NLS-1$
}
-
+
if(StringHelper.isNotEmpty(projectName)) {
n.setAttribute(PROJECT_ATTRIB, projectName);
}
-
+
node.appendChild(n);
-
+
if(cfgFile!=null) {
n.appendChild(createElementWithAttribute(doc, HIBERNATE_CONFIG_XML_TAG,
LOCATION_ATTRIB, cfgFile.toString() ) );
}
-
+
if(propertyFilename!=null) {
n.appendChild(createElementWithAttribute(doc, HIBERNATE_PROPERTIES_TAG,
LOCATION_ATTRIB, propertyFilename.toString() ) );
}
-
+
if(mappings.length>0) {
Element cc = createElementWithAttribute(doc, MAPPINGS_TAG, null, null);
n.appendChild(cc);
-
+
for (int i = 0; i < mappings.length; i++) {
Object path = mappings[i];
cc.appendChild(createElementWithAttribute(doc, MAPPING_TAG, LOCATION_ATTRIB,
path.toString() ) );
}
}
-
+
if(customClasspath.length>0) {
Element cc = createElementWithAttribute(doc, CLASSPATH_TAG, null, null);
n.appendChild(cc);
-
+
for (int i = 0; i < customClasspath.length; i++) {
Object path = customClasspath[i];
cc.appendChild(createElementWithAttribute(doc, PATH_TAG, LOCATION_ATTRIB,
path.toString() ) );
}
}
}
-
+
public boolean useProjectClasspath() {
return useProjectClasspath;
}
-
+
protected void setUseProjectClasspath(boolean useProjectClasspath) {
this.useProjectClasspath = useProjectClasspath;
}
-
-
-
+
+
+
public void setProjectName(String projectName) {
this.projectName = projectName;
}
-
+
public String getProjectName() {
return projectName;
}
-
+
public void readStateFrom(Element node) {
-
+
String entityResolver = null;
String cfgName = null;
String cfgFile = null;
String propFile = null;
String[] mappings = new String[0];
String[] classpath = new String[0];
-
+
cfgName = node.getAttribute(NAME_ATTRIB);
-
-
+
+
String attribute = node.getAttribute(ANNOTATIONS_ATTRIB);
if(StringHelper.isNotEmpty( attribute )) {
boolean oldAnnotationFlag = ((attribute != null) &&
attribute.equalsIgnoreCase("true")); //$NON-NLS-1$
@@ -199,46 +200,46 @@
attribute = node.getAttribute(CONFIGURATION_MODE_ATTRIB);
configurationMode = ConfigurationMode.parse( attribute );
}
-
-
+
+
attribute = node.getAttribute( PROJECT_ATTRIB );
setProjectName( attribute );
-
+
attribute = node.getAttribute( USE_PROJECT_CLASSPATH_ATTRIB );
setUseProjectClasspath((attribute != null) &&
attribute.equalsIgnoreCase("true")); //$NON-NLS-1$
-
+
attribute = node.getAttribute(ENTITYRESOLVER_ATTRIB);
if(attribute!=null && attribute.trim().length()>0) {
entityResolver = attribute;
}
-
+
NodeList elements = node.getElementsByTagName(HIBERNATE_CONFIG_XML_TAG);
if(elements.getLength()==1) {
cfgFile = ( (Element)elements.item(0) ).getAttribute(LOCATION_ATTRIB);
}
-
+
elements = node.getElementsByTagName(HIBERNATE_PROPERTIES_TAG);
if(elements.getLength()==1) {
propFile = ( (Element)elements.item(0) ).getAttribute(LOCATION_ATTRIB);
}
-
-
- mappings = parseListOfLocations(node, MAPPINGS_TAG, MAPPING_TAG);
+
+
+ mappings = parseListOfLocations(node, MAPPINGS_TAG, MAPPING_TAG);
classpath = parseListOfLocations(node, CLASSPATH_TAG, PATH_TAG);
-
-
+
+
setName(cfgName);
setEntityResolverName(entityResolver);
setConfigFile(cfgFile);
setPropertyFile(propFile);
setMappings(mappings);
setCustomClassPath(classpath);
-
+
}
private void setEntityResolverName(String entityResolver) {
this.entityResolverName = entityResolver;
-
+
}
private String[] parseListOfLocations(Element node, String parenttag, String elementag)
{
@@ -256,19 +257,19 @@
return result;
}
- /**
+ /**
* generic XML handling. Ugly like hell - but done to reduce jar requirements and code
duplication.
- * TODO: make better ;)
+ * TODO: make better ;)
**/
-
+
public String getEntityResolverName() { return entityResolverName; };
-
+
protected abstract void setConfigFile(String cfgFile);
protected abstract void setPropertyFile(String cfgFile);
protected abstract void setMappings(String[] mappings);
protected abstract void setCustomClassPath(String[] mappings);
-
-
+
+
protected static Element createElementWithAttribute(Document doc, String tagName, String
attribName, String attributValue) {
Element n;
n = doc.createElement(tagName);
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/Messages.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/Messages.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,19 +0,0 @@
-package org.hibernate.console.preferences;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME =
"org.hibernate.console.preferences.messages"; //$NON-NLS-1$
- public static String ACCP_COULD_NOT_LOAD_PROP_FILE;
- public static String ACCP_NAME_NOT_NULL_OR_EMPTY;
- public static String ACCP_UNKNOWN;
- public static String
STANDALONECONSOLECONFIGURATIONPREFERENCES_COULD_NOT_RESOLVE_CLASSPATHS;
- public static String STANDALONECONSOLECONFIGURATIONPREFERENCES_ERRORS_WHILE_PARSING;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/StandAloneConsoleConfigurationPreferences.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/StandAloneConsoleConfigurationPreferences.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/StandAloneConsoleConfigurationPreferences.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -30,6 +30,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.console.HibernateConsoleRuntimeException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -42,58 +43,58 @@
private File cfgFile;
private File propertyFilename;
private File[] mappings;
- private File[] customClasspath;
+ private File[] customClasspath;
public StandAloneConsoleConfigurationPreferences(String name, File xmlconfig, File
propertiesFile, File[] mappingFiles, File[] customClasspath) {
super(name, ConfigurationMode.CORE, null, false, null, null, null);
this.cfgFile = xmlconfig;
this.propertyFilename = propertiesFile;
this.mappings = mappingFiles;
- this.customClasspath = customClasspath;
+ this.customClasspath = customClasspath;
}
protected StandAloneConsoleConfigurationPreferences() {
// hidden for others
}
-
+
protected StandAloneConsoleConfigurationPreferences(String name) {
this(name,null,null,new File[0],new File[0]);
}
-
+
/**
* @return return non-null array of URLs for a customclasspath
*/
public URL[] getCustomClassPathURLS() {
URL[] result = new URL[customClasspath.length];
-
+
for (int i = 0; i < customClasspath.length; i++) {
File file = customClasspath[i];
try {
result[i] = file.toURL();
- }
+ }
catch (MalformedURLException mue) {
- throw new
HibernateConsoleRuntimeException(Messages.STANDALONECONSOLECONFIGURATIONPREFERENCES_COULD_NOT_RESOLVE_CLASSPATHS,
mue);
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.StandAloneConsoleConfigurationPreferences_could_not_resolve_classpaths,
mue);
}
}
return result;
}
-
+
/**
* @return return non-null array of URLs for mapping files
*/
public File[] getMappingFiles() {
return mappings;
}
-
+
public File getConfigXMLFile() {
return cfgFile;
}
public void writeStateTo(Element node) {
- writeStateTo(node, getName(), getEntityResolverName(), getConfigurationMode(), null,
false, cfgFile, propertyFilename, mappings, customClasspath);
+ writeStateTo(node, getName(), getEntityResolverName(), getConfigurationMode(), null,
false, cfgFile, propertyFilename, mappings, customClasspath);
}
-
+
public File getPropertyFile() {
return propertyFilename;
}
@@ -111,7 +112,7 @@
this.mappings = new File[mappings.length];
for (int i = 0; i < mappings.length; i++) {
String str = mappings[i];
- this.mappings[i] = new File(str);
+ this.mappings[i] = new File(str);
}
}
@@ -119,37 +120,37 @@
this.customClasspath = new File[mappings.length];
for (int i = 0; i < mappings.length; i++) {
String str = mappings[i];
- this.customClasspath[i] = new File(str);
+ this.customClasspath[i] = new File(str);
}
- }
+ }
public static StandAloneConsoleConfigurationPreferences[] readStateFrom(File f) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser;
try {
parser = factory.newDocumentBuilder();
-
+
Document doc = parser.parse(f);
-
+
Element root = doc.getDocumentElement();
-
+
NodeList elementsByTagName = root.getElementsByTagName(CONFIGURATION_TAG);
StandAloneConsoleConfigurationPreferences[] result = new
StandAloneConsoleConfigurationPreferences[elementsByTagName.getLength()];
-
+
for(int i = 0; i < elementsByTagName.getLength(); i++) {
result[i] = new StandAloneConsoleConfigurationPreferences();
result[i].readStateFrom( (Element)elementsByTagName.item(i) );
}
return result;
- }
+ }
catch(SAXException sa) {
- throw new
HibernateConsoleRuntimeException(Messages.STANDALONECONSOLECONFIGURATIONPREFERENCES_ERRORS_WHILE_PARSING
+ f,sa);
- }
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.StandAloneConsoleConfigurationPreferences_errors_while_parsing
+ f,sa);
+ }
catch (ParserConfigurationException e) {
- throw new
HibernateConsoleRuntimeException(Messages.STANDALONECONSOLECONFIGURATIONPREFERENCES_ERRORS_WHILE_PARSING
+ f,e);
- }
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.StandAloneConsoleConfigurationPreferences_errors_while_parsing
+ f,e);
+ }
catch (IOException e) {
- throw new
HibernateConsoleRuntimeException(Messages.STANDALONECONSOLECONFIGURATIONPREFERENCES_ERRORS_WHILE_PARSING
+ f,e);
- }
+ throw new
HibernateConsoleRuntimeException(ConsoleMessages.StandAloneConsoleConfigurationPreferences_errors_while_parsing
+ f,e);
+ }
}
}
\ No newline at end of file
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/messages.properties 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/messages.properties 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,5 +0,0 @@
-ACCP_COULD_NOT_LOAD_PROP_FILE=Could not load property file
-ACCP_NAME_NOT_NULL_OR_EMPTY=Name cannot be null or empty
-ACCP_UNKNOWN=<unknown>
-STANDALONECONSOLECONFIGURATIONPREFERENCES_COULD_NOT_RESOLVE_CLASSPATHS=Could not resolve
classpaths
-STANDALONECONSOLECONFIGURATIONPREFERENCES_ERRORS_WHILE_PARSING=Errors while parsing
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/Messages.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/Messages.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,16 +0,0 @@
-package org.hibernate.eclipse.logging;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME =
"org.hibernate.eclipse.logging.messages"; //$NON-NLS-1$
- public static String PLUGINFILEAPPENDER_MISSING_PLUGIN_STATE_LOCATION;
- public static String PLUGINLOGAPPENDER_MISSING_LAYOUT_FOR_APPENDER;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginFileAppender.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginFileAppender.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginFileAppender.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -27,44 +27,45 @@
import org.apache.log4j.RollingFileAppender;
import org.apache.log4j.spi.LoggingEvent;
import org.eclipse.core.runtime.IPath;
+import org.hibernate.console.ConsoleMessages;
/**
* PluginFileAppender
- * This class is a custom Log4J appender that sends Log4J events to
+ * This class is a custom Log4J appender that sends Log4J events to
* the Eclipse plug-in state location. It extends the RollingFileAppender class.
* @author Manoel Marques
*/
public class PluginFileAppender extends RollingFileAppender {
private IPath stateLocation;
- private boolean activateOptionsPending;
+ private boolean activateOptionsPending;
private boolean translatePath = true;
-
+
/**
* Creates a new PluginFileAppender.
*/
public PluginFileAppender() {
super();
}
-
+
/**
* Creates a new PluginFileAppender.
* @param layout layout instance.
- * @param stateLocation IPath containing the plug-in state location
- */
+ * @param stateLocation IPath containing the plug-in state location
+ */
public PluginFileAppender(Layout layout,IPath stateLocation) {
super();
setLayout(layout);
- setStateLocation(stateLocation);
+ setStateLocation(stateLocation);
}
-
+
/**
* Creates a new PluginFileAppender.
* @param layout layout instance.
- * @param stateLocation IPath containing the plug-in state location
+ * @param stateLocation IPath containing the plug-in state location
* @param file file name
* @param append true if file is to be appended
- */
+ */
public PluginFileAppender(Layout layout,IPath stateLocation, String file, boolean
append)
throws IOException {
super();
@@ -78,9 +79,9 @@
/**
* Creates a new PluginFileAppender.
* @param layout layout instance.
- * @param stateLocation IPath containing the plug-in state location
+ * @param stateLocation IPath containing the plug-in state location
* @param file file name
- */
+ */
public PluginFileAppender(Layout layout,IPath stateLocation, String file) throws
IOException {
super();
setLayout(layout);
@@ -88,88 +89,88 @@
setFile(file);
activateOptions();
}
-
+
/**
* Sets the state location. If activateOptions call is pending, translate the file name
- * and call activateOptions
- * @param stateLocation IPath containing the plug-in state location
- */
+ * and call activateOptions
+ * @param stateLocation IPath containing the plug-in state location
+ */
void setStateLocation(IPath stateLocation) {
- this.stateLocation = stateLocation;
+ this.stateLocation = stateLocation;
if (this.stateLocation != null && this.activateOptionsPending) {
this.activateOptionsPending = false;
setFile(getFile());
activateOptions();
}
}
-
+
/**
- * Sets the file name.Translate it before setting.
+ * Sets the file name.Translate it before setting.
* @param file file name
- */
+ */
public void setFile(String file) {
super.setFile(getTranslatedFileName(file));
}
-
+
/**
* Set file options and opens it, leaving ready to write.
* @param file file name
* @param append true if file is to be appended
* @param bufferedIO true if file is to buffered
* @param bufferSize buffer size
- * @throws IOException - IO Error happend or the state location was not set
- */
+ * @throws IOException - IO Error happend or the state location was not set
+ */
public void setFile(String fileName,boolean append,boolean bufferedIO,int bufferSize)
throws IOException {
- if (this.stateLocation == null)
- throw new IOException(Messages.PLUGINFILEAPPENDER_MISSING_PLUGIN_STATE_LOCATION);
-
- fileName = (this.translatePath) ? getTranslatedFileName(fileName) : fileName;
+ if (this.stateLocation == null)
+ throw new
IOException(ConsoleMessages.PluginFileAppender_missing_plugin_state_location);
+
+ fileName = (this.translatePath) ? getTranslatedFileName(fileName) : fileName;
super.setFile(fileName,append,bufferedIO,bufferSize);
}
-
+
/**
- * Finishes instance initialization. If state location was not set, set activate as
+ * Finishes instance initialization. If state location was not set, set activate as
* pending and does nothing.
- */
+ */
public void activateOptions() {
- if (this.stateLocation == null) {
+ if (this.stateLocation == null) {
this.activateOptionsPending = true;
return;
- }
-
+ }
+
// base class will call setFile, don't translate the name
// because it was already translated
this.translatePath = false;
- super.activateOptions();
+ super.activateOptions();
this.translatePath = true;
}
-
+
/**
* Any path part of a file is removed and the state location is added to the name
* to form a new path. If there is not state location, returns the name unmodified.
* @param file file name
- * @return translated file name
+ * @return translated file name
*/
private String getTranslatedFileName(String file) {
-
+
if (this.stateLocation == null || file == null)
return file;
-
+
file = file.trim();
if (file.length() == 0)
return file;
-
+
int index = file.lastIndexOf('/');
if (index == -1)
index = file.lastIndexOf('\\');
-
- if (index != -1)
+
+ if (index != -1)
file = file.substring(index + 1);
-
- IPath newPath = this.stateLocation.append(file);
+
+ IPath newPath = this.stateLocation.append(file);
return newPath.toString();
}
-
+
public void append(LoggingEvent event) {
super.append( event );
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginLogAppender.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginLogAppender.java 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/PluginLogAppender.java 2008-06-06
16:52:05 UTC (rev 8617)
@@ -32,28 +32,29 @@
import org.apache.log4j.spi.ThrowableInformation;
import org.eclipse.core.runtime.ILog;
import org.eclipse.ui.console.MessageConsoleStream;
+import org.hibernate.console.ConsoleMessages;
import org.hibernate.console.KnownConfigurations;
/**
* PluginLogAppender
- * This class is a custom Log4J appender that sends Log4J events to
+ * This class is a custom Log4J appender that sends Log4J events to
* the Eclipse plug-in log.
* @author Manoel Marques
*/
public class PluginLogAppender extends AppenderSkeleton {
-
+
private ILog pluginLog;
private Map streams = new HashMap();
-
-
+
+
/**
* Sets the Eclipse log instance
* @param log plug-in log
- */
+ */
void setLog(ILog pluginLog) {
this.pluginLog = pluginLog;
}
-
+
/**
* Log event happened.
* Translates level to status instance codes:
@@ -62,37 +63,37 @@
* level > Level.DEBUG - Status.INFO
* default - Status.OK
* @param event LoggingEvent instance
- */
+ */
public void append(LoggingEvent event) {
-
+
if (this.layout == null) {
- this.errorHandler.error(Messages.PLUGINLOGAPPENDER_MISSING_LAYOUT_FOR_APPENDER +
- this.name,null,ErrorCode.MISSING_LAYOUT);
+ this.errorHandler.error(ConsoleMessages.PluginLogAppender_missing_layout_for_appender
+
+ this.name,null,ErrorCode.MISSING_LAYOUT);
return;
}
-
+
String text = this.layout.format(event);
-
+
Throwable thrown = null;
if (this.layout.ignoresThrowable()) {
ThrowableInformation info = event.getThrowableInformation();
if (info != null)
- thrown = info.getThrowable();
+ thrown = info.getThrowable();
}
- /*
+ /*
Level level = event.getLevel();
int severity = IStatus.OK;
-
- if (level.toInt() >= Priority.ERROR_INT)
+
+ if (level.toInt() >= Priority.ERROR_INT)
severity = IStatus.ERROR;
else
if (level.toInt() >= Priority.WARN_INT)
severity = IStatus.WARNING;
else
- if (level.toInt() >= Priority.DEBUG_INT)
+ if (level.toInt() >= Priority.DEBUG_INT)
severity = IStatus.INFO;
-
-
+
+
this.pluginLog.log(new Status(severity,
this.pluginLog.getBundle().getSymbolicName(),
level.toInt(),text,thrown));*/
@@ -107,22 +108,22 @@
stream.println(stringWriter.getBuffer().toString());
}
}
-
+
}
-
-
-
+
+
+
/**
* Closes this appender
- */
+ */
public void close() {
- this.closed = true;
+ this.closed = true;
}
-
+
/**
* Checks if this appender requires layout
* @return true if layout is required.
- */
+ */
public boolean requiresLayout() {
return true;
}
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/messages.properties 2008-06-06
16:51:51 UTC (rev 8616)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/eclipse/logging/messages.properties 2008-06-06
16:52:05 UTC (rev 8617)
@@ -1,2 +0,0 @@
-PLUGINFILEAPPENDER_MISSING_PLUGIN_STATE_LOCATION=Missing Plugin State Location.
-PLUGINLOGAPPENDER_MISSING_LAYOUT_FOR_APPENDER=Missing layout for appender