Author: jpages Date: 2012-06-08 18:18:59 +0200 (Fri, 08 Jun 2012) New Revision: 711 Url: http://nuiton.org/repositories/revision/jrst/711 Log: Cr?\195?\169ation de l'UI avec Jaxx (non termin?\195?\169e) Added: trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/ trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTView.jaxx trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTViewHandler.java Modified: trunk/jrst/pom.xml trunk/pom.xml Modified: trunk/jrst/pom.xml =================================================================== --- trunk/jrst/pom.xml 2012-06-08 07:54:09 UTC (rev 710) +++ trunk/jrst/pom.xml 2012-06-08 16:18:59 UTC (rev 711) @@ -41,6 +41,34 @@ <groupId>org.nuiton.jrst</groupId> <artifactId>jrst</artifactId> + <properties> + + <!-- jaxx configuration --> + <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath> + <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> + <jaxx.defaultErrorUIFQN> + jaxx.runtime.validator.swing.ui.ImageValidationUI + </jaxx.defaultErrorUIFQN> + <!--<jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon>--> + <jaxx.generateHelp>true</jaxx.generateHelp> + <jaxx.generateSearch>false</jaxx.generateSearch> + <jaxx.autoImportCss>true</jaxx.autoImportCss> + <jaxx.autoRecurseInCss>false</jaxx.autoRecurseInCss> + <!--<jaxx.helpBrokerFQN>fr.ird.observe.ui.ObserveHelpBroker</jaxx.helpBrokerFQN>--> + + <!-- jaxx help configuration --> + <jaxx.helpsetName>sammoa</jaxx.helpsetName> + <jaxx.locales>fr,en</jaxx.locales> + <!--<jaxx.helpTarget>src/main/help</jaxx.helpTarget>--> + + <i18n.bundleOutputName>sammoa-ui-swing</i18n.bundleOutputName> + + <doAccessImport>false</doAccessImport> + + <maven.jar.main.class>org.nuiton.jrst.JRST</maven.jar.main.class> + + </properties> + <dependencies> <dependency> <groupId>${project.groupId}</groupId> @@ -48,7 +76,30 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + + <!-- jaxx dependencies --> <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-runtime</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-validator</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-widgets</artifactId> + </dependency> + + <!-- swing widgets --> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-widgets</artifactId> + </dependency> + + <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> </dependency> @@ -153,15 +204,6 @@ <!-- ************************************************************* --> <packaging>jar</packaging> - <properties> - - <maven.jar.main.class>org.nuiton.jrst.JRST</maven.jar.main.class> - - <!-- extra files to include in release --> - <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles> - - </properties> - <build> <resources> @@ -174,6 +216,17 @@ </resources> <plugins> + <plugin> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> <!-- plugin i18n --> <plugin> Added: trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTView.jaxx =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTView.jaxx (rev 0) +++ trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTView.jaxx 2012-06-08 16:18:59 UTC (rev 711) @@ -0,0 +1,60 @@ +<Application title='JRST' resizable='false' visible='true'> + + <import> + javax.swing.JFrame + java.awt.BorderLayout + java.awt.FlowLayout + java.awt.Dimension + org.nuiton.jrst.JRST + </import> + + <script><![CDATA[ + + protected void $afterCompleteSetup() { + handler.init(JRST.PATTERN_TYPE); + } + + ]]></script> + + <JRSTViewHandler id='handler' constructorParams='this'/> + + <JLabel id='errorLbl' text=''/> + <JPanel id='openPanel'> + <JLabel text='Open'/> + <JTextField id='openText' columns='31'/> + <JButton id ='boutonOpenLocation' + onActionPerformed='handler.openOpenLocation()' + preferredSize='{new Dimension(30,30)}'/> + </JPanel> + <JPanel> + <JLabel text='saveAs'/> + <JTextField id='saveText' columns='31'/> + <JButton id ='boutonSaveLocation' + onActionPerformed='handler.openSaveLocation()' + preferredSize='{new Dimension(30,30)}'/> + </JPanel> + <JPanel id='formatPanel'> + <ButtonGroup id='group'> + <JRadioButton id='format' + text='Format : ' + selected='true' + onActionPerformed='handler.formatEnable()'/> + <JRadioButton text='externalXSL'/> + <JComboBox id='formatList'/> + </ButtonGroup> + </JPanel> + <JPanel id='xslLigne' layout='{new FlowLayout(FlowLayout.TRAILING)}'> + <JRadioButton id='externalXSL'/> + <JTextField id='xslText' columns='30' enabled='false'/> + <JButton id='boutonXslLocation' preferredSize='{new Dimension(30, 30)}' enabled='false'/> + </JPanel> + <JPanel id='' layout='{new FlowLayout(FlowLayout.LEFT)}'> + <JCheckBox id='simpleModeChechBox' text='Simple mode' + onActionPerformed='handler.setMode()'/> + </JPanel> + <JPanel id='boutonPanel' layout='{new FlowLayout()}'> + <JButton id='boutonAnnuler' onActionPerformed='handler.annuler()'/> + <JButton id='boutonConvertir' onActionPerformed='handler.convert()'/> + </JPanel> + +</Application> \ No newline at end of file Added: trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTViewHandler.java =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTViewHandler.java (rev 0) +++ trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTViewHandler.java 2012-06-08 16:18:59 UTC (rev 711) @@ -0,0 +1,189 @@ +package org.nuiton.jrst.jaxxUI; + +import org.nuiton.jrst.JRST; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.io.File; +import java.util.LinkedList; + +import static org.nuiton.i18n.I18n._; + +/** + * Created: 03/05/12 + * + * @author jpages <j.pages@codelutin.com> + */ +public class JRSTViewHandler { + + private LinkedList<JPanel> ListAddXslPanel; + + private LinkedList<JTextField> ListXslText; + + private LinkedList<JButton> ListXslBouton; + + private LinkedList<JButton> ListXslBoutonLocation; + + private LinkedList<Container> composantsXSL; + + private String[] listFormats; + + private boolean ecrase; + private boolean simpleMode; + private String[] commande; + + protected JRSTView jrstView; + + protected JRSTViewHandler(JRSTView jrstView) { + this.jrstView = jrstView; + } + + public void init(String formats) { + setFormats(formats); + composantsXSL = new LinkedList<Container>(); + ListAddXslPanel = new LinkedList<JPanel>(); + ListXslBouton = new LinkedList<JButton>(); + ListXslText = new LinkedList<JTextField>(); + ListXslBoutonLocation = new LinkedList<JButton>(); + } + + protected void openOpenLocation() { + JFileChooser fc = new JFileChooser(System.getProperty("user.home")); + fc.showOpenDialog(jrstView); + File file = fc.getSelectedFile(); + if (file != null) { + getOpenText().setText(file.getAbsolutePath()); + } + + } + + private JTextField getOpenText() { + JTextField openText = jrstView.getOpenText(); + openText = new JTextField(); + openText.setColumns(31); + return openText; + } + + protected void openSaveLocation() { + JFileChooser fc = new JFileChooser(System.getProperty("user.home")); + fc.showSaveDialog(jrstView); + File file = fc.getSelectedFile(); + if (file != null) { + if (file.exists()) { + int choix = askEcraser(); + if (choix == JOptionPane.YES_OPTION) { + ecrase = true; + getSaveText().setText(file.getAbsolutePath()); + } else if (choix == JOptionPane.NO_OPTION) + openSaveLocation(); + } else + getSaveText().setText(file.getAbsolutePath()); + } + + } + + public int askEcraser() { + int choix = JOptionPane.showConfirmDialog(jrstView, _("overwriteGraph?")); + + return choix; + } + + private JTextField getSaveText() { + JTextField saveText = jrstView.getSaveText(); + saveText = new JTextField(); + saveText.setColumns(31); + return saveText; + } + + protected void formatEnable() { + getFormatList().setEnabled(getFormat().isSelected()); + for (Container c : composantsXSL) + c.setEnabled(!getFormat().isSelected()); + } + + private JRadioButton getFormat() { + JRadioButton format = jrstView.getFormat(); + format = new JRadioButton("Format : "); + format.setSelected(true); + format.addChangeListener(new ChangeListener() { + + public void stateChanged(ChangeEvent e) { + formatEnable(); + + } + + }); + return format; + } + + protected JComboBox getFormatList() { + JComboBox formatList = jrstView.getFormatList(); + formatList = new JComboBox(setFormats(JRST.PATTERN_TYPE)); + return formatList; + } + + public String[] setFormats(String formats) { + return listFormats = formats.split("\\|"); + } + + protected void setMode() { + simpleMode = !simpleMode; + } + + protected void annuler() { + System.exit(0); + } + + protected void convert() { + boolean exit = false; + if (getOpenText().getText().equals("")) { + getErrorLabel().setText(_("openEmpty?")); + getErrorLabel().setForeground(Color.RED); + jrstView.pack(); + } else { + if (!ecrase) { + File file = new File(getSaveText().getText()); + if (file.exists()) { + int choix = askEcraser(); + if (choix == JOptionPane.YES_OPTION) + ecrase = true; + else if (choix == JOptionPane.NO_OPTION) + exit = true; + } + } + if (!exit) { + String cmd = ""; + if (ecrase) + cmd += "--force "; + if (simpleMode) { + cmd += "--simple "; + } + if (getFormat().isSelected()) + cmd += "-t " + getFormatList().getSelectedItem(); + else { + cmd += "-x "; + for (JTextField t : ListXslText) { + if (!t.getText().equals("")) + cmd += t.getText() + ","; + } + cmd = cmd.substring(0, cmd.length() - 1); + } + if (getSaveText().getText().length() > 0) + cmd += " -o " + getSaveText().getText(); + cmd += " " + getOpenText().getText() + " "; + commande = cmd.trim().split(" "); + jrstView.dispose(); + } + + } + } + + private JLabel getErrorLabel() { + JLabel errorLbl = jrstView.getErrorLbl(); + errorLbl = new JLabel(""); + return errorLbl; + } + +} Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-06-08 07:54:09 UTC (rev 710) +++ trunk/pom.xml 2012-06-08 16:18:59 UTC (rev 711) @@ -281,6 +281,33 @@ </dependency> + <!-- jaxx dependencies --> + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-runtime</artifactId> + <version>${jaxxVersion}</version> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-validator</artifactId> + <version>${jaxxVersion}</version> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-widgets</artifactId> + <version>${jaxxVersion}</version> + </dependency> + + <!-- swing widgets --> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-widgets</artifactId> + <version>1.1.1</version> + </dependency> + + </dependencies> </dependencyManagement> @@ -355,6 +382,7 @@ <nuitonUtilsVersion>2.4.8</nuitonUtilsVersion> <nuitonI18nVersion>2.4.1</nuitonI18nVersion> <xalanVersion>2.7.1</xalanVersion> + <jaxxVersion>2.4.2</jaxxVersion> </properties> @@ -369,6 +397,12 @@ <version>${nuitonI18nVersion}</version> </plugin> + <plugin> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <version>${jaxxVersion}</version> + </plugin> + </plugins> </pluginManagement>