changeset 94:146a0704ba68

Include a schemaLocation attribute This will make eclipse automatically validate the thermostat-plugin.xml file whenever possible.
author Omair Majid <omajid@redhat.com>
date Thu, 06 Feb 2014 10:37:06 -0500
parents 13279d78dfe1
children 6fb474ebe666
files com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/PluginModelReaderWriter.java com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/SchemaConstants.java com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/package-info.java com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlCreationWizard.java
diffstat 4 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/PluginModelReaderWriter.java	Wed Jan 22 12:55:20 2014 -0500
+++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/PluginModelReaderWriter.java	Thu Feb 06 10:37:06 2014 -0500
@@ -70,6 +70,7 @@
             JAXBContext context = JAXBContext.newInstance(Plugin.class);
             Marshaller m = context.createMarshaller();
             m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, SchemaConstants.getSchemaLocation());
 
             m.marshal(plugin, out);
         } catch (JAXBException e) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/SchemaConstants.java	Thu Feb 06 10:37:06 2014 -0500
@@ -0,0 +1,11 @@
+package com.redhat.thermostat.tools.eclipse.plugin.model;
+
+public class SchemaConstants {
+
+    public static final String SCHEMA_NAMESPACE = "http://icedtea.classpath.org/thermostat/plugins/v1.0"; //$NON-NLS-1$
+    public static final String SCHEMA_URL = "http://icedtea.classpath.org/thermostat/docs/1.0/thermostat-plugin.xsd"; //$NON-NLS-1$
+
+    public static String getSchemaLocation() {
+        return SCHEMA_NAMESPACE + " " + SCHEMA_URL; // //$NON-NLS-1$
+    }
+}
--- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/package-info.java	Wed Jan 22 12:55:20 2014 -0500
+++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/package-info.java	Thu Feb 06 10:37:06 2014 -0500
@@ -3,6 +3,6 @@
  * {@code thermostat-plugin.xml} file.
  */
 @javax.xml.bind.annotation.XmlSchema(
-        namespace="http://icedtea.classpath.org/thermostat/plugins/v1.0",
+        namespace=SchemaConstants.SCHEMA_NAMESPACE,
         elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
 package com.redhat.thermostat.tools.eclipse.plugin.model;
--- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlCreationWizard.java	Wed Jan 22 12:55:20 2014 -0500
+++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/PluginXmlCreationWizard.java	Thu Feb 06 10:37:06 2014 -0500
@@ -22,6 +22,7 @@
 
 import com.redhat.thermostat.tools.eclipse.plugin.Activator;
 import com.redhat.thermostat.tools.eclipse.plugin.Messages;
+import com.redhat.thermostat.tools.eclipse.plugin.model.SchemaConstants;
 
 public class PluginXmlCreationWizard extends Wizard implements INewWizard {
 
@@ -112,9 +113,9 @@
 
     private InputStream getInitialContentStream() {
         String contents = "<?xml version=\"1.0\"?>\n" //$NON-NLS-1$
-                + "<plugin xmlns=\"http://icedtea.classpath.org/thermostat/plugins/v1.0\"\n" //$NON-NLS-1$
-                + "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" //$NON-NLS-1$
-                + "\txsi:schemaLocation=\"http://icedtea.classpath.org/thermostat/plugins/v1.0 thermostat-plugin.xsd\">\n" //$NON-NLS-1$
+                + "<plugin xmlns=\"" + SchemaConstants.SCHEMA_NAMESPACE + "\"\n" //$NON-NLS-1$ $NON-NLS-2$
+                + "        xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" //$NON-NLS-1$
+                + "        xsi:schemaLocation=\"" + SchemaConstants.getSchemaLocation() + "\">\n" //$NON-NLS-1$ $NON-NLS-2$
                 + "</plugin>"; //$NON-NLS-1$
 
         return new ByteArrayInputStream(contents.getBytes());