Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions java/xml.jaxb/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
<specification-version>1.40</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.core.multiview</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.75</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.libs.javacapi</code-name-base>
<build-prerequisite/>
Expand Down Expand Up @@ -231,36 +240,41 @@
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.ui</code-name-base>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.3</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<code-name-base>org.openide.util.lookup</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.ui</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.3</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<code-name-base>org.openide.windows</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.0</specification-version>
<specification-version>6.108</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<test-dependencies>
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>org.netbeans.api.progress</code-name-base>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.bootstrap</code-name-base>
</test-dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ Templates/XML=XML
Templates/XML/JavaXMLBinding=JAXB Binding
JAXBResolver=JAXB Binding
JAXB-ENDORSED=JAXB-ENDORSED
CTL_SourceTabCaption=&Source
16 changes: 16 additions & 0 deletions java/xml.jaxb/src/org/netbeans/modules/xml/jaxb/JAXBWizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,78 +47,79 @@
*/
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();
if (line != null){
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));
Source xslSource = new StreamSource(getFromClasspath(XSL_FILE));
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);
Expand All @@ -131,7 +132,7 @@ private void transformConfig2Build(String configFile, String buildFile){
fail("IOException");
}
}

/**
* Test the XSL style sheet.
**/
Expand Down Expand Up @@ -163,5 +164,5 @@ public void testXformConfig2BuildEmptyCatalog(){
transformConfig2Build(CONFIG_EMPTY_CAT, BUILD_EMPTY_CAT);
System.out.println("testXformConfig2BuildEmptyCatalog done.");
}

}
Loading