diff --git a/java/xml.jaxb/nbproject/project.xml b/java/xml.jaxb/nbproject/project.xml index c5561fb6b50b..b31a0f1f92a0 100644 --- a/java/xml.jaxb/nbproject/project.xml +++ b/java/xml.jaxb/nbproject/project.xml @@ -61,6 +61,15 @@ 1.40 + + org.netbeans.core.multiview + + + + 1 + 1.75 + + org.netbeans.libs.javacapi @@ -231,7 +240,7 @@ - org.openide.util.ui + org.openide.util @@ -239,7 +248,15 @@ - org.openide.util + org.openide.util.lookup + + + + 8.0 + + + + org.openide.util.ui @@ -247,20 +264,17 @@ - org.openide.util.lookup + org.openide.windows - 8.0 + 6.108 unit - - org.netbeans.api.progress - org.netbeans.bootstrap diff --git a/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/Bundle.properties b/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/Bundle.properties index e5a2a3f7f59e..9f4f6d068b31 100644 --- a/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/Bundle.properties +++ b/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/Bundle.properties @@ -35,3 +35,4 @@ Templates/XML=XML Templates/XML/JavaXMLBinding=JAXB Binding JAXBResolver=JAXB Binding JAXB-ENDORSED=JAXB-ENDORSED +CTL_SourceTabCaption=&Source \ No newline at end of file diff --git a/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/JAXBWizard.java b/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/JAXBWizard.java index f2d41fc701ef..5106186e5185 100644 --- a/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/JAXBWizard.java +++ b/java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/JAXBWizard.java @@ -19,7 +19,11 @@ package org.netbeans.modules.xml.jaxb; +import org.netbeans.core.spi.multiview.MultiViewElement; +import org.netbeans.core.spi.multiview.text.MultiViewEditorElement; import org.openide.filesystems.MIMEResolver; +import org.openide.util.Lookup; +import org.openide.windows.TopComponent; /** * A place holder class @@ -33,6 +37,18 @@ ) public class JAXBWizard { + @MultiViewElement.Registration( + displayName="org.netbeans.modules.xml.jaxb.Bundle#CTL_SourceTabCaption", + iconBase="org/netbeans/modules/xml/jaxb/resources/XML_file.png", + persistenceType=TopComponent.PERSISTENCE_ONLY_OPENED, + preferredID="xml.text", + mimeType="text/x-jaxb-binding+xml", + position=1 + ) + public static MultiViewEditorElement createMultiViewEditor(Lookup context) { + return new MultiViewEditorElement(context); + } + /** Creates a new instance of JAXBWizard */ public JAXBWizard() { } diff --git a/java/xml.jaxb/test/unit/src/org/netbeans/modules/xml/jaxb/util/XSLTest.java b/java/xml.jaxb/test/unit/src/org/netbeans/modules/xml/jaxb/util/XSLTest.java index 068535c04b47..f84850cdfcf2 100644 --- a/java/xml.jaxb/test/unit/src/org/netbeans/modules/xml/jaxb/util/XSLTest.java +++ b/java/xml.jaxb/test/unit/src/org/netbeans/modules/xml/jaxb/util/XSLTest.java @@ -47,40 +47,42 @@ */ public class XSLTest extends NbTestCase { private static final String CONFIG_FILE1 = "ConfigFile1.xml"; //NOI18N - private static final String CONFIG_FILE2 = "ConfigFile2.xml"; //NOI18N - private static final String CONFIG_FILE3 = "ConfigFile3.xml"; //NOI18N - private static final String CONFIG_EMPTY_CAT = "ConfigFileEmptyCatalog.xml"; //NOI18N + private static final String CONFIG_FILE2 = "ConfigFile2.xml"; //NOI18N + private static final String CONFIG_FILE3 = "ConfigFile3.xml"; //NOI18N + private static final String CONFIG_EMPTY_CAT = "ConfigFileEmptyCatalog.xml"; //NOI18N private static final String BUILD_FILE1 = "BuildFile1.xml"; //NOI18N - private static final String BUILD_FILE2 = "BuildFile2.xml"; //NOI18N - private static final String BUILD_FILE3 = "BuildFile3.xml"; //NOI18N - private static final String BUILD_EMPTY_CAT = "BuildFileEmptyCatalog.xml"; //NOI18N - - private static final String XSL_FILE = + private static final String BUILD_FILE2 = "BuildFile2.xml"; //NOI18N + private static final String BUILD_FILE3 = "BuildFile3.xml"; //NOI18N + private static final String BUILD_EMPTY_CAT = "BuildFileEmptyCatalog.xml"; //NOI18N + + private static final String XSL_FILE = "/org/netbeans/modules/xml/jaxb/resources/JAXBBuild.xsl"; //NOI18N private static final String TEMP_BUILD_FILE = "jaxb_build" ; //NOI18N - + public XSLTest(String testName) { super(testName); } - + + @Override public void setUp() throws Exception { } - + + @Override public void tearDown() throws Exception { } - + private InputStream getFromClasspath(String filePath){ return this.getClass().getResourceAsStream(filePath); } - + private InputStream getDatafile(String filename) throws FileNotFoundException{ String dataFilename = "/org/netbeans/modules/xml/jaxb/util/" + filename; return new FileInputStream(new File(getDataDir(), dataFilename)); } - + private String getString(InputStream stream) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(stream)); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String line = ""; while (line != null){ line = br.readLine(); @@ -88,20 +90,19 @@ private String getString(InputStream stream) throws IOException{ sb.append(line); } } - + return sb.toString(); } - + private void compareStream(InputStream file1, InputStream file2) throws IOException{ - boolean ret = false; String str1 = getString(file1); //System.out.println("Str1:" + str1 + ":Str1"); String str2 = getString(file2); - //System.out.println("Str2:" + str2 + ":Str2"); - //System.out.println("Length:" + str1.length() + ":" + str2.length()); + //System.out.println("Str2:" + str2 + ":Str2"); + //System.out.println("Length:" + str1.length() + ":" + str2.length()); assertEquals(str1, str2); } - + private void transformConfig2Build(String configFile, String buildFile){ try { Source xmlSource = new StreamSource(getDatafile(configFile)); @@ -109,16 +110,16 @@ private void transformConfig2Build(String configFile, String buildFile){ File tmpFile = java.io.File.createTempFile(TEMP_BUILD_FILE, ".xml"); //System.out.println("tmpFile:" + tmpFile.getAbsolutePath()); tmpFile.deleteOnExit(); - FileOutputStream fos = new FileOutputStream(tmpFile); - Result result = new StreamResult(fos); - TransformerFactory fact = TransformerFactory.newInstance(); - fact.setAttribute("indent-number", 4); //NOI18N - Transformer xformer = fact.newTransformer(xslSource); - xformer.setOutputProperty(OutputKeys.INDENT, "yes"); //NOI18N - xformer.setOutputProperty(OutputKeys.METHOD, "xml"); //NOI18N - xformer.transform(xmlSource, result); + try (FileOutputStream fos = new FileOutputStream(tmpFile)) { + Result result = new StreamResult(fos); + TransformerFactory fact = TransformerFactory.newInstance(); + fact.setAttribute("indent-number", 4); //NOI18N + Transformer xformer = fact.newTransformer(xslSource); + xformer.setOutputProperty(OutputKeys.INDENT, "yes"); //NOI18N + xformer.setOutputProperty(OutputKeys.METHOD, "xml"); //NOI18N + xformer.transform(xmlSource, result); + } // Compare. - fos.close(); compareStream(getDatafile(buildFile), new FileInputStream(tmpFile)); } catch (TransformerConfigurationException ex) { Logger.getLogger("global").log(Level.SEVERE, null, ex); @@ -131,7 +132,7 @@ private void transformConfig2Build(String configFile, String buildFile){ fail("IOException"); } } - + /** * Test the XSL style sheet. **/ @@ -163,5 +164,5 @@ public void testXformConfig2BuildEmptyCatalog(){ transformConfig2Build(CONFIG_EMPTY_CAT, BUILD_EMPTY_CAT); System.out.println("testXformConfig2BuildEmptyCatalog done."); } - + }