Author: tchemit Date: 2014-02-08 16:06:19 +0100 (Sat, 08 Feb 2014) New Revision: 1581 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1581 Log: fixes #4376 Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUIHandler.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java 2014-02-07 15:57:24 UTC (rev 1580) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java 2014-02-08 15:06:19 UTC (rev 1581) @@ -32,12 +32,11 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel; -import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog; +import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightUI; import jaxx.runtime.SwingUtil; import org.apache.commons.lang3.StringUtils; import javax.swing.JOptionPane; -import java.awt.Frame; import java.util.Map; import static org.nuiton.i18n.I18n.t; @@ -138,19 +137,8 @@ } protected Float openMelagWeightDialog() { - Frame frame = handler.getParentContainer(Frame.class); - - EnterMelagWeightDialog dialog = new EnterMelagWeightDialog( - frame, getConfig().getShortcutClosePopup()); - dialog.setWeightUnit(weightUnit); - SwingUtil.center(frame, dialog); - dialog.pack(); - dialog.setVisible(true); - - Float result = null; - if (dialog.getEditor().getModel() != null) { - result = dialog.getEditor().getModel().floatValue(); - } + EnterMelagWeightUI dialog = new EnterMelagWeightUI(getContext()); + Float result = dialog.openAndGetWeightValue(weightUnit); return result; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java 2014-02-07 15:57:24 UTC (rev 1580) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java 2014-02-08 15:06:19 UTC (rev 1581) @@ -32,12 +32,11 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; -import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog; +import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightUI; import jaxx.runtime.SwingUtil; import org.apache.commons.lang3.StringUtils; import javax.swing.JOptionPane; -import java.awt.Frame; import java.util.Map; import static org.nuiton.i18n.I18n.t; @@ -138,21 +137,8 @@ } protected Float openMelagWeightDialog() { - Frame frame = handler.getParentContainer(Frame.class); - - EnterMelagWeightDialog dialog = new EnterMelagWeightDialog( - frame, getConfig().getShortcutClosePopup()); - - dialog.setWeightUnit(weightUnit); - - SwingUtil.center(frame, dialog); - dialog.pack(); - dialog.setVisible(true); - - Float result = null; - if (dialog.getEditor().getModel() != null) { - result = dialog.getEditor().getModel().floatValue(); - } + EnterMelagWeightUI dialog = new EnterMelagWeightUI(getContext()); + Float result = dialog.openAndGetWeightValue(weightUnit); return result; } Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css 2014-02-07 15:57:24 UTC (rev 1580) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css 2014-02-08 15:06:19 UTC (rev 1581) @@ -1,53 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -#dialog { - title: {t("tutti.createSpeciesMelag.title", weightUnit.getShortLabel())}; -} - -#message { - text: {t("tutti.createSpeciesMelag.message", weightUnit.getShortLabel())}; - horizontalAlignment: {JLabel.CENTER}; -} - -#editor { - useFloat: true; - useSign: false; - autoPopup: true; - showPopupButton: true; - showReset: true; -} - -#cancelButton { - text: "tutti.createSpeciesMelag.action.cancel"; - toolTipText: "tutti.createSpeciesMelag.action.cancel.tip"; - i18nMnemonic: "tutti.createSpeciesMelag.action.cancel.mnemonic"; -} - -#validateButton { - text: "tutti.createSpeciesMelag.action.validate"; - toolTipText: "tutti.createSpeciesMelag.action.validate.tip"; - i18nMnemonic: "tutti.createSpeciesMelag.action.validate.mnemonic"; - enabled: { editor.getModel() != null }; -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx 2014-02-07 15:57:24 UTC (rev 1580) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx 2014-02-08 15:06:19 UTC (rev 1581) @@ -1,77 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 - 2013 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<JDialog id='dialog' layout='{new BorderLayout()}'> - <import> - fr.ifremer.tutti.type.WeightUnit; - - java.awt.Component; - java.awt.event.WindowAdapter; - java.awt.event.WindowEvent; - javax.swing.JComponent - javax.swing.JRootPane; - javax.swing.KeyStroke; - jaxx.runtime.swing.editor.NumberEditor - </import> - - <script><![CDATA[ - -public EnterMelagWeightDialog(Frame frame, KeyStroke shortcutClosePopup) { - super(frame, true); - - // add a auto-close action - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( - shortcutClosePopup, "close"); - - addWindowListener(new WindowAdapter() { - - @Override - public void windowClosed(WindowEvent e) { - Component ui = (Component) e.getSource(); - JAXXUtil.destroy(ui); - } - }); -} - - ]]></script> - - <WeightUnit id='weightUnit' javaBean='WeightUnit.KG'/> - - <Table id='table' fill='both' constraints='BorderLayout.CENTER'> - <row> - <cell insets='10, 10, 5, 10'> - <JLabel id='message'/> - </cell> - </row> - <row> - <cell insets='5, 10, 10, 10'> - <NumberEditor id='editor'/> - </cell> - </row> - </Table> - <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> - <JButton id='cancelButton' - onActionPerformed='editor.setModel(null); dispose();'/> - <JButton id='validateButton' onActionPerformed='dispose();'/> - </JPanel> -</JDialog> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.css (from rev 1572, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.css 2014-02-08 15:06:19 UTC (rev 1581) @@ -0,0 +1,57 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +#dialog { + title: {handler.getTile(getWeightUnit())}; +} + +#message { + text: {handler.getMessage(getWeightUnit())}; + horizontalAlignment: {JLabel.CENTER}; +} + +#editor { + modelType: {Float.class}; + useFloat: true; + useSign: false; + autoPopup: false; + showPopupButton: true; + showReset: true; + numberPattern: {getWeightUnit().getNumberEditorPattern()}; +} + +#cancelButton { + actionIcon: cancel; + text: "tutti.createSpeciesMelag.action.cancel"; + toolTipText: "tutti.createSpeciesMelag.action.cancel.tip"; + i18nMnemonic: "tutti.createSpeciesMelag.action.cancel.mnemonic"; +} + +#validateButton { + actionIcon: accept; + text: "tutti.createSpeciesMelag.action.validate"; + toolTipText: "tutti.createSpeciesMelag.action.validate.tip"; + i18nMnemonic: "tutti.createSpeciesMelag.action.validate.mnemonic"; + enabled: { editor.getModel() != null }; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.jaxx (from rev 1572, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUI.jaxx 2014-02-08 15:06:19 UTC (rev 1581) @@ -0,0 +1,68 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 - 2013 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='dialog' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<TuttiUIContext, EnterMelagWeightUIHandler>'> + <import> + fr.ifremer.tutti.type.WeightUnit; + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.util.TuttiUIUtil + + jaxx.runtime.swing.editor.NumberEditor + </import> + + <script><![CDATA[ + +public EnterMelagWeightUI(TuttiUIContext context) { + super(context.getMainUI()); + TuttiUIUtil.setApplicationContext(this, context); +} + +public Float openAndGetWeightValue(WeightUnit weightUnit) { + return handler.openAndGetWeightValue(weightUnit); +} + + ]]></script> + + <TuttiUIContext id='model' initializer='getContextValue(TuttiUIContext.class)'/> + + <WeightUnit id='weightUnit' javaBean='WeightUnit.KG'/> + + <Table id='table' fill='both' constraints='BorderLayout.CENTER'> + <row> + <cell insets='10, 10, 5, 10'> + <JLabel id='message'/> + </cell> + </row> + <row> + <cell insets='5, 10, 10, 10'> + <NumberEditor id='editor'/> + </cell> + </row> + </Table> + <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> + <JButton id='cancelButton' + onActionPerformed='editor.setModel(null); dispose();'/> + <JButton id='validateButton' onActionPerformed='dispose();'/> + </JPanel> +</JDialog> \ No newline at end of file Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUIHandler.java 2014-02-08 15:06:19 UTC (rev 1581) @@ -0,0 +1,98 @@ +package fr.ifremer.tutti.ui.swing.util.species; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.type.WeightUnit; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.validator.swing.SwingValidator; + +import javax.swing.JComponent; +import java.awt.Component; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created on 2/8/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.2 + */ +public class EnterMelagWeightUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, EnterMelagWeightUI> { + + @Override + public void onCloseUI() { + } + + @Override + public SwingValidator<TuttiUIContext> getValidator() { + return null; + } + + @Override + protected JComponent getComponentToFocus() { + return null; + } + + @Override + public void afterInit(EnterMelagWeightUI ui) { + + // add a auto-close action + ui.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( + getConfig().getShortcutClosePopup(), "close"); + + ui.addWindowListener(new WindowAdapter() { + + @Override + public void windowClosed(WindowEvent e) { + Component ui = (Component) e.getSource(); + JAXXUtil.destroy(ui); + } + }); + initUI(ui); + + + } + + protected Float openAndGetWeightValue(WeightUnit weightUnit) { + ui.setWeightUnit(weightUnit); + SwingUtil.center(getTopestUI(), ui); + ui.pack(); + ui.getEditor().requestFocusInWindow(); + ui.setVisible(true); + return ui.getEditor().getModel() == null ? null : ui.getEditor().getModel().floatValue(); + } + protected String getTile(WeightUnit weightUnit) { + return t("tutti.createSpeciesMelag.title", weightUnit.getShortLabel()); + } + + protected String getMessage(WeightUnit weightUnit) { + return t("tutti.createSpeciesMelag.message", weightUnit.getShortLabel()); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native