Author: dgeraskov
Date: 2008-10-23 06:27:41 -0400 (Thu, 23 Oct 2008)
New Revision: 11097
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/messages.properties
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/context/HibernatePersistenceUnit.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2976
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-23
09:24:48 UTC (rev 11096)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2008-10-23
10:27:41 UTC (rev 11097)
@@ -7,7 +7,8 @@
org.eclipse.core.runtime,
org.eclipse.jpt.core,
org.eclipse.wst.validation,
- org.eclipse.jpt.utility;bundle-version="1.2.0"
+ org.eclipse.jpt.utility;bundle-version="1.2.0",
+ org.eclipse.core.resources;bundle-version="3.4.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Hibernate Team
Export-Package: org.jboss.tools.hibernate.jpt.core.internal,
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-23
09:24:48 UTC (rev 11096)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2008-10-23
10:27:41 UTC (rev 11097)
@@ -10,16 +10,27 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context;
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jpt.core.context.persistence.Persistence;
+import org.eclipse.jpt.core.context.persistence.Property;
import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernatePersistenceUnit extends GenericPersistenceUnit {
+public class HibernatePersistenceUnit extends GenericPersistenceUnit
+ implements Messages{
private HibernateProperties hibernateProperties;
@@ -42,4 +53,53 @@
return this.hibernateProperties.getBasicHibernate();
}
+ // ********** Validation ***********************************************
+ @Override
+ public void addToMessages(List<IMessage> messages) {
+ super.addToMessages(messages);
+ addFileNotExistsMessages(messages);
+ }
+
+ protected void addFileNotExistsMessages(List<IMessage> messages) {
+ String configFile = getBasicProperties().getConfigurationFile();
+ if (configFile != null && configFile.length() > 0){
+ IPath path = new Path(configFile);
+
+ if (new File(path.toOSString()).exists()) return;
+
+
+ IResource res= ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (res != null) {
+ int resType= res.getType();
+ if (resType != IResource.FILE) {
+ Property prop = getProperty(BasicHibernateProperties.HIBERNATE_CONFIG_FILE);
+ IMessage message = new HibernateMessage(IMessage.HIGH_SEVERITY,
+ NOT_A_FILE, new String[]{configFile}, getResource());
+ message.setLineNo(prop.getValidationTextRange().getLineNumber());
+ messages.add(message);
+ }
+ } else {
+ Property prop = getProperty(BasicHibernateProperties.HIBERNATE_CONFIG_FILE);
+ IMessage message = new HibernateMessage(IMessage.HIGH_SEVERITY,
+ FILE_NOT_FOUND, new String[]{configFile}, getResource());
+ message.setLineNo(prop.getValidationTextRange().getLineNumber());
+ messages.add(message);
+ }
+ }
+ }
}
+
+/*Fixes the problem with class loader*/
+class HibernateMessage extends Message {
+
+ /**
+ * @param aSeverity
+ * @param anId
+ * @param aParams
+ * @param aTargetObject
+ */
+ public HibernateMessage(int aSeverity, String anId, String[] aParams, Object
aTargetObject) {
+ super(Messages.class.getName(), aSeverity, anId, aParams, aTargetObject);
+ }
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java 2008-10-23
10:27:41 UTC (rev 11097)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface Messages {
+
+ String NOT_A_FILE = "not_a_file";
+
+ String FILE_NOT_FOUND = "file_not_found";
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.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/messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/messages.properties
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/messages.properties 2008-10-23
10:27:41 UTC (rev 11097)
@@ -0,0 +1,2 @@
+not_a_file= Resource \"{0}\" is not a file.
+file_not_found = File \"{0}\" not found.
\ No newline at end of file
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native