Re-upload

This commit is contained in:
Daniel Cortes
2017-07-31 13:24:41 -04:00
commit 8ba3d1b4fb
6 changed files with 252 additions and 0 deletions

38
pom.xml Normal file
View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ryuuji</groupId>
<artifactId>xslsimpletransform</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.ryuuji.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.ryuuji.App

View File

@@ -0,0 +1,17 @@
package com.ryuuji;
import javax.swing.*;
/**
* Created by ryuuji on 29-04-17.
*/
public class App {
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | UnsupportedLookAndFeelException | InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
new Screen();
}
}

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ryuuji.Screen">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="527" height="195"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="fed1c" class="javax.swing.JButton" binding="xmlButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="XML"/>
</properties>
</component>
<component id="40619" class="javax.swing.JTextField" binding="pathXml">
<constraints>
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="300" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="fc519" class="javax.swing.JButton" binding="xslButton">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="XSL"/>
</properties>
</component>
<component id="bf2b2" class="javax.swing.JTextField" binding="pathXsl">
<constraints>
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="300" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="f1bb6" class="javax.swing.JButton" binding="endFileButton">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="End File"/>
</properties>
</component>
<component id="50e2e" class="javax.swing.JTextField" binding="pathOut">
<constraints>
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="300" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="eca88" class="javax.swing.JButton" binding="generateButton" default-binding="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Generate"/>
</properties>
</component>
<component id="cc3bf" class="javax.swing.JButton" binding="openButton" default-binding="true">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Open"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,96 @@
package com.ryuuji;
import javax.swing.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.awt.*;
import java.io.File;
import java.io.IOException;
/**
* Created by ryuuji on 29-04-17.
*/
public class Screen extends JFrame{
private JButton xmlButton;
private JTextField pathXml;
private JButton xslButton;
private JTextField pathXsl;
private JButton endFileButton;
private JTextField pathOut;
private JButton generateButton;
private JPanel mainPanel;
private JButton openButton;
public Screen(){
setContentPane(mainPanel);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
setVisible(true);
setListeners();
}
private void setListeners() {
xmlButton.addActionListener(a->{
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Selecciona el XML");
chooser.setCurrentDirectory(
new File("/home/ryuuji/IdeaProjects/ProyectoEscuelaBasica/files/reportes/"));
if(chooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION){
pathXml.setText(chooser.getSelectedFile().getAbsolutePath());
}
});
xslButton.addActionListener(a->{
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Selecciona el XSL");
chooser.setCurrentDirectory(
new File("/home/ryuuji/IdeaProjects/ProyectoEscuelaBasica/files/xslt/"));
if(chooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION){
pathXsl.setText(chooser.getSelectedFile().getAbsolutePath());
}
});
endFileButton.addActionListener(a->{
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Selecciona el Archivo final");
chooser.setCurrentDirectory(
new File("/home/ryuuji/IdeaProjects/ProyectoEscuelaBasica/files/reportes/"));
if(chooser.showSaveDialog(null)==JFileChooser.APPROVE_OPTION){
pathOut.setText(chooser.getSelectedFile().getAbsolutePath());
}
});
generateButton.addActionListener(a->{
try {
transform(pathXml.getText(),pathXsl.getText(),pathOut.getText());
JOptionPane.showMessageDialog(null,
"Se a generado el archivo");
} catch (TransformerException e) {
JOptionPane.showMessageDialog(null,
"No se a podido generar el archivo\n" +
""+e.getLocalizedMessage(),null,JOptionPane.ERROR_MESSAGE);
}
});
openButton.addActionListener(a->{
Desktop desktop = Desktop.getDesktop();
try {
desktop.open(new File(pathOut.getText()));
} catch (IOException e) {
JOptionPane.showMessageDialog(null,
"El archivo seleccionado no existe",null,JOptionPane.ERROR_MESSAGE);
}
});
}
public void transform(String xml, String xsl, String out) throws TransformerException {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource(new File(xsl));
Transformer transformer = null;
transformer = factory.newTransformer(xslt);
Source text = new StreamSource(new File(xml));
transformer.transform(text, new StreamResult(new File(out)));
}
}

15
xslsimpletransform.iml Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>