Author: tchemit Date: 2008-02-15 15:44:42 +0000 (Fri, 15 Feb 2008) New Revision: 1002 Added: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx Log: implements import action Added: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/ImportDialog.jaxx 2008-02-15 15:44:42 UTC (rev 1002) @@ -0,0 +1,76 @@ +<JDialog> + <script> +AbstractAction cancelAction = new AbstractAction(_("simexplorer.common.cancel")){ + private static final long serialVersionUID = -4585698788717305452L; + + public void actionPerformed(ActionEvent e) { + filePath.setText(null); + dispose(); + } +}; + +public java.io.File getFile() { + setVisible(true); + if (filePath.getText().equals("")) { + return null; + } + java.io.File f= new java.io.File(filePath.getText()); + filePath.setText(null); + return f; +} + +protected void chooseDir() { + File dir= org.codelutin.util.FileUtil.getFile(new String[0]); + if (dir!=null) { + filePath.setText(dir.toString()); + } +} +public ImportDialog(JFrame frame) { + super(frame,true); + JRootPane rootPane = getRootPane(); + rootPane.setDefaultButton(ok); + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),"cancel"); + rootPane.getActionMap().put("cancel", cancelAction); +} +protected void check() { + String t = filePath.getText(); + java.io.File f = new File(t); + ok.setEnabled(!t.equals("") && f.exists() && f.isFile()); +} + </script> + <Table> + <row fill='vertical'> + <cell anchor='west' fill='horizontal' weightx="2"> + <JLabel text='simexplorer.choose.import.label'/> + </cell> + <cell anchor='west'> + <VBox> + <JRadioButton id='selected' text='simexplorer.entities.applicationExploration' value='ApplicationExploration' buttonGroup='typeImport' onActionPerformed='filePath.setText(null)'/> + <JRadioButton text='simexplorer.entities.library' value='Library' buttonGroup='typeImport' onActionPerformed='filePath.setText(null)'/> + </VBox> + </cell> + </row> + <row> + <cell columns='2' weightx='1' fill='horizontal'> + <Table> + <row fill="both"> + <cell weightx='1' fill='both' insets='0,0,0,0'> + <JTextField id='filePath' onCaretUpdate='check()' margin='0,0,0,0'/> + </cell> + <cell anchor='east' insets='0,2,0,0'> + <JButton id='chooseDirectory' icon='{createImageIcon("fileChooser.png")}' onActionPerformed='chooseDir()' margin='0,0,0,0'/> + </cell> + </row> + </Table> + </cell> + </row> + <row fill='horizontal'> + <cell columns='2'> + <JPanel layout='{new GridLayout(1, 0, 2, 2)}'> + <JButton id='ok' text='simexplorer.action.import' enabled='false' onActionPerformed='dispose();'/> + <JButton id='cancel' text='simexplorer.common.cancel' action='{cancelAction}'/> + </JPanel> + </cell> + </row> + </Table> +</JDialog>
participants (1)
-
tchemit@users.labs.libre-entreprise.org