r712 - in trunk/jrst/src/main/java/org/nuiton/jrst: . jaxxUI
Author: jpages Date: 2012-06-11 17:57:48 +0200 (Mon, 11 Jun 2012) New Revision: 712 Url: http://nuiton.org/repositories/revision/jrst/712 Log: Suite du passage ?\195?\160 Jaxx pour l'interface graphique. Modified: trunk/jrst/src/main/java/org/nuiton/jrst/JRST.java 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/src/main/java/org/nuiton/jrst/JRST.java =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-06-08 16:18:59 UTC (rev 711) +++ trunk/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-06-11 15:57:48 UTC (rev 712) @@ -24,8 +24,7 @@ */ package org.nuiton.jrst; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; +import java.awt.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -38,9 +37,11 @@ import java.io.Reader; import java.net.URL; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import javax.swing.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.TransformerException; @@ -55,6 +56,7 @@ import org.nuiton.i18n.init.ClassPathI18nInitializer; import org.nuiton.jrst.convertisor.DocUtils2RST; import org.nuiton.jrst.convertisor.DocUtilsVisitor; +import org.nuiton.jrst.jaxxUI.JRSTView; import org.nuiton.jrst.legacy.JRSTReader; import org.nuiton.util.ApplicationConfig; import org.nuiton.util.Resource; @@ -262,9 +264,15 @@ protected static String[] askOptionGraph() throws SecurityException, NoSuchMethodException { + /* JRSTInterface graph = new JRSTInterface(PATTERN_TYPE); + return graph.getCmd(); + */ + JRSTView jrstView = new JRSTView(); + jrstView.setVisible(true); - return graph.getCmd(); + jrstView.pack(); + return jrstView.getHandler().getCmd(); } /** Modified: trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTView.jaxx =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTView.jaxx 2012-06-08 16:18:59 UTC (rev 711) +++ trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTView.jaxx 2012-06-11 15:57:48 UTC (rev 712) @@ -1,60 +1,114 @@ -<Application title='JRST' resizable='false' visible='true'> +<JDialog title='JRST' resizable='true' modal='true' visible='false' layout='{new BorderLayout()}'> <import> - javax.swing.JFrame + javax.swing.BoxLayout java.awt.BorderLayout java.awt.FlowLayout java.awt.Dimension org.nuiton.jrst.JRST + org.nuiton.util.Resource </import> <script><![CDATA[ protected void $afterCompleteSetup() { - handler.init(JRST.PATTERN_TYPE); + handler.init(); } ]]></script> <JRSTViewHandler id='handler' constructorParams='this'/> + <DefaultComboBoxModel id='comboBoxModel' constructorParams='handler.setFormats(JRST.PATTERN_TYPE)'/> - <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> + <Table> + <row> + <cell columns='3'> + <JLabel id='errorLbl' text=''/> + </cell> + </row> + <row> + <cell> + <JLabel text='Open'/> + </cell> + <cell> + <JTextField id='openText' columns='31'/> + </cell> + <cell> + <JButton id ='boutonOpenLocation' + onActionPerformed='handler.openOpenLocation()' + preferredSize='{new Dimension(30,30)}' + constructorParams='Resource.getIcon("icone/open.png")'/> + </cell> + </row> + <row> + <cell> + <JLabel text='saveAs'/> + </cell> + <cell> + <JTextField id='saveText' columns='31'/> + </cell> + <cell> + <JButton id ='boutonSaveLocation' + onActionPerformed='handler.openSaveLocation()' + preferredSize='{new Dimension(30,30)}' + constructorParams='Resource.getIcon("icone/open.png")'/> + </cell> + </row> -</Application> \ No newline at end of file + <row> + <cell> + <JRadioButton id='format' + text='Format : ' + selected='true' + onActionPerformed='handler.formatEnable()'/> + </cell> + <cell columns='2'> + <JComboBox id='formatList' constructorParams='comboBoxModel'/> + </cell> + </row> + + <row> + <cell columns='3'> + <JPanel id='xslPanel' layout='{new BoxLayout(xslPanel, BoxLayout.Y_AXIS)}'> + <JPanel id='externalXSLPanel'> + <JRadioButton id='xslRadio' text='externalXSL'/> + <JTextField id='xslText' columns='30' enabled='false'/> + <JButton id='boutonXslLocation' + preferredSize='{new Dimension(30, 30)}' + constructorParams='Resource.getIcon("icone/open.png")' + onActionPerformed='handler.openXslLocation((JButton)event.getSource())' + enabled='false'/> + </JPanel> + <JPanel id='addXslPanel'> + <JButton id='addXslButton' + constructorParams='Resource.getIcon("icone/more.gif")' + preferredSize='{new Dimension(20, 20)}' + onActionPerformed='handler.addXslLocation((JButton)event.getSource())'/> + </JPanel> + </JPanel> + </cell> + </row> + + + + <row> + <cell columns='3'> + <JCheckBox id='simpleModeChechBox' text='Simple mode' + onActionPerformed='handler.setMode()'/> + </cell> + </row> + + <row> + <cell/> + <cell> + <JButton id='boutonAnnuler' text='Cancel' onActionPerformed='handler.annuler()'/> + </cell> + <cell> + <JButton id='boutonConvertir' text='Convert' onActionPerformed='handler.convert()'/> + </cell> + </row> + + + </Table> + +</JDialog> \ No newline at end of file Modified: trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTViewHandler.java =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTViewHandler.java 2012-06-08 16:18:59 UTC (rev 711) +++ trunk/jrst/src/main/java/org/nuiton/jrst/jaxxUI/JRSTViewHandler.java 2012-06-11 15:57:48 UTC (rev 712) @@ -1,11 +1,11 @@ package org.nuiton.jrst.jaxxUI; -import org.nuiton.jrst.JRST; +import org.nuiton.util.Resource; import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; import java.util.LinkedList; @@ -18,37 +18,36 @@ */ 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 LinkedList<JTextField> textFieldList; + protected LinkedList<JButton>ListXslBoutonLocation; + 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>(); + public void init() { + ButtonGroup group = new ButtonGroup(); + group.add(getXslRadio()); } + private JRadioButton getXslRadio() { + JRadioButton xslRadio = jrstView.getXslRadio(); + if (xslRadio == null) { + xslRadio = new JRadioButton(_("externalXSL")); + } + return xslRadio; + } + protected void openOpenLocation() { JFileChooser fc = new JFileChooser(System.getProperty("user.home")); fc.showOpenDialog(jrstView); @@ -56,13 +55,14 @@ if (file != null) { getOpenText().setText(file.getAbsolutePath()); } - } private JTextField getOpenText() { JTextField openText = jrstView.getOpenText(); - openText = new JTextField(); - openText.setColumns(31); + if (openText == null) { + openText = new JTextField(); + openText.setColumns(31); + } return openText; } @@ -81,61 +81,102 @@ } else getSaveText().setText(file.getAbsolutePath()); } + } + protected void formatEnable() { + jrstView.getFormatList().setEnabled(jrstView.getFormat().isEnabled()); + jrstView.getXslText().setEnabled(!jrstView.getXslText().isEnabled()); + jrstView.getBoutonXslLocation().setEnabled(!jrstView.getBoutonXslLocation().isEnabled()); } public int askEcraser() { - int choix = JOptionPane.showConfirmDialog(jrstView, _("overwriteGraph?")); - - return choix; + return JOptionPane.showConfirmDialog(jrstView, _("overwriteGraph?")); } private JTextField getSaveText() { JTextField saveText = jrstView.getSaveText(); - saveText = new JTextField(); - saveText.setColumns(31); + if (saveText == null) { + saveText = new JTextField(); + saveText.setColumns(31); + } return saveText; } - protected void formatEnable() { - getFormatList().setEnabled(getFormat().isSelected()); - for (Container c : composantsXSL) - c.setEnabled(!getFormat().isSelected()); + protected JComboBox getFormatList() { + return jrstView.formatList; } - private JRadioButton getFormat() { - JRadioButton format = jrstView.getFormat(); - format = new JRadioButton("Format : "); - format.setSelected(true); - format.addChangeListener(new ChangeListener() { + public String[] setFormats(String formats) { + listFormats = formats.split("\\|"); + return listFormats; + } - public void stateChanged(ChangeEvent e) { - formatEnable(); + protected void setMode() { + simpleMode = !simpleMode; + } + protected void annuler() { + System.exit(0); + } + + public String[] getCmd() { + return commande; + } + + public void addXslLocation(JButton button) { + JPanel panel = (JPanel)button.getParent(); + panel = new JPanel(new BoxLayout(panel, BoxLayout.Y_AXIS)); + + JTextField xslText = new JTextField(); + xslText.setColumns(30); + xslText.setEnabled(false); + JButton boutonXslLocation = new JButton(Resource.getIcon("icone/open.png")); + boutonXslLocation.setPreferredSize(new Dimension(30, 30)); + boutonXslLocation.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //openXslLocation((JButton) e.getSource()); } + }); + boutonXslLocation.setEnabled(false); + panel.add(xslText); + panel.add(boutonXslLocation); + + JPanel panel2 = new JPanel(new BoxLayout(panel, BoxLayout.Y_AXIS)); + JButton addXslButton = new JButton(Resource.getIcon("icone/more.gif")); + addXslButton.setPreferredSize(new Dimension(20, 20)); + addXslButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + addXslLocation((JButton) event.getSource()); + } }); - return format; + panel2.add(addXslButton); } - protected JComboBox getFormatList() { - JComboBox formatList = jrstView.getFormatList(); - formatList = new JComboBox(setFormats(JRST.PATTERN_TYPE)); - return formatList; + private JLabel getErrorLabel() { + JLabel errorLbl = jrstView.getErrorLbl(); + if (errorLbl == null) { + errorLbl = new JLabel(""); + } + return errorLbl; } - public String[] setFormats(String formats) { - return listFormats = formats.split("\\|"); - } + protected void openXslLocation(JButton b) { + JFileChooser fc = new JFileChooser(System.getProperty("user.home")); + fc.showOpenDialog(jrstView); + File file = fc.getSelectedFile(); + if (file != null) { + int i = 0; + for (JButton btmp : ListXslBoutonLocation) { + if (btmp == b) { + textFieldList.get(i).setText(file.getAbsolutePath()); + } - protected void setMode() { - simpleMode = !simpleMode; + i++; + } + } } - protected void annuler() { - System.exit(0); - } - protected void convert() { boolean exit = false; if (getOpenText().getText().equals("")) { @@ -160,11 +201,11 @@ if (simpleMode) { cmd += "--simple "; } - if (getFormat().isSelected()) + if (jrstView.getFormat().isSelected()) cmd += "-t " + getFormatList().getSelectedItem(); else { cmd += "-x "; - for (JTextField t : ListXslText) { + for (JTextField t : textFieldList) { if (!t.getText().equals("")) cmd += t.getText() + ","; } @@ -179,11 +220,4 @@ } } - - private JLabel getErrorLabel() { - JLabel errorLbl = jrstView.getErrorLbl(); - errorLbl = new JLabel(""); - return errorLbl; - } - }
participants (1)
-
jpages@users.nuiton.org