This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 483a599dca6f42ae16d0d533d4bf87ffd5fd86c3 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sat Dec 31 11:29:11 2016 +0100 Remove some deprecated api (See #4103) --- jaxx-application-swing/pom.xml | 5 + .../swing/AbstractApplicationUIHandler.java | 8 +- .../feature/databinding/BindingExtremeDemo.jaxx | 8 +- .../org/nuiton/jaxx/runtime/FileChooserUtil.java | 358 --------------------- .../java/org/nuiton/jaxx/runtime/JAXXUtil.java | 66 ---- .../org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx | 139 -------- .../jaxx/runtime/swing/AboutPanelHandler.java | 177 ---------- .../nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java | 9 +- .../swing/editor/cell/NumberCellEditor.java | 127 -------- 9 files changed, 15 insertions(+), 882 deletions(-) diff --git a/jaxx-application-swing/pom.xml b/jaxx-application-swing/pom.xml index 7cfb529..19d4f10 100644 --- a/jaxx-application-swing/pom.xml +++ b/jaxx-application-swing/pom.xml @@ -79,6 +79,11 @@ <artifactId>jaxx-widgets</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jaxx-widgets-number</artifactId> + <version>${project.version}</version> + </dependency> <!-- Commons --> <dependency> diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java index 3302a6e..bbf4083 100644 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java +++ b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/AbstractApplicationUIHandler.java @@ -36,7 +36,7 @@ import org.nuiton.jaxx.runtime.swing.editor.bean.BeanComboBox; import org.nuiton.jaxx.runtime.swing.editor.bean.BeanDoubleList; import org.nuiton.jaxx.runtime.swing.editor.bean.BeanFilterableComboBox; import org.nuiton.jaxx.runtime.swing.editor.bean.BeanUIUtil; -import org.nuiton.jaxx.runtime.swing.editor.cell.NumberCellEditor; +import org.nuiton.jaxx.widgets.number.NumberCellEditor; import org.nuiton.jaxx.runtime.swing.editor.gis.DmdCoordinateEditor; import org.nuiton.jaxx.runtime.swing.editor.gis.DmsCoordinateEditor; import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer; @@ -1128,8 +1128,7 @@ public abstract class AbstractApplicationUIHandler<M, UI extends ApplicationUI<M boolean sign, JTable table) { - NumberCellEditor<Float> editor = - JAXXWidgetUtil.newNumberTableCellEditor(Float.class, sign); + NumberCellEditor<Float> editor = new NumberCellEditor<>(Float.class, sign); editor.getNumberEditor().setSelectAllTextOnError(true); editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); editor.getNumberEditor().setNumberPattern(numberPattern); @@ -1154,8 +1153,7 @@ public abstract class AbstractApplicationUIHandler<M, UI extends ApplicationUI<M boolean sign, JTable table) { - NumberCellEditor<Integer> editor = - JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, sign); + NumberCellEditor<Integer> editor = new NumberCellEditor<>(Integer.class, sign); editor.getNumberEditor().setSelectAllTextOnError(true); editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2)); editor.getNumberEditor().setNumberPattern(numberPattern); diff --git a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx index c74b404..05f3e29 100644 --- a/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx +++ b/jaxx-demo/src/main/java/org/nuiton/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx @@ -26,7 +26,7 @@ <import> org.nuiton.jaxx.runtime.JAXXBinding - org.nuiton.jaxx.runtime.FileChooserUtil + org.nuiton.jaxx.runtime.JaxxFileChooser java.awt.Color javax.swing.border.TitledBorder javax.swing.DefaultListModel @@ -146,7 +146,7 @@ protected String[] getSources() { </cell> <cell> <JButton text="file..." - onActionPerformed='setFile(FileChooserUtil.getFile(this, new String[0]))'/> + onActionPerformed='setFile(JaxxFileChooser.forLoadingFile().choose())'/> </cell> </row> @@ -205,7 +205,7 @@ protected String[] getSources() { </cell> <cell> <JButton text="model0.file..." - onActionPerformed='model0.setFile(FileChooserUtil.getFile(this,new String[0]))'/> + onActionPerformed='model0.setFile(JaxxFileChooser.forLoadingFile().choose())'/> </cell> </row> @@ -267,7 +267,7 @@ protected String[] getSources() { </cell> <cell> <JButton text="model1.file..." - onActionPerformed='model1.setFile(FileChooserUtil.getFile(this,new String[0]))'/> + onActionPerformed='model1.setFile(JaxxFileChooser.forLoadingFile().choose())'/> </cell> </row> diff --git a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/FileChooserUtil.java b/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/FileChooserUtil.java deleted file mode 100644 index 1466f14..0000000 --- a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/FileChooserUtil.java +++ /dev/null @@ -1,358 +0,0 @@ -package org.nuiton.jaxx.runtime; - -/* - * #%L - * JAXX :: Runtime - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.FileUtil; - -import javax.swing.JFileChooser; -import java.awt.Component; -import java.io.File; - -/** - * To help choosing a file / directory. - * - * Was previously in {@code org.nuiton.util.FileUtil} from - * {@code nuiton-utils} project. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.5.16 - * @deprecated since 2.15, prefer use {@link JaxxFileChooser}. - */ -public class FileChooserUtil { - - /** Logger. */ - private static final Log log = LogFactory.getLog(FileChooserUtil.class); - - public static final File DEFAULT_CURRENT_DIRECTORY_FILE = new File("."); - - protected static File currentDirectory = DEFAULT_CURRENT_DIRECTORY_FILE; - - public static void setCurrentDirectory(File dir) { - JaxxFileChooser.setCurrentDirectory(currentDirectory ); - } - - public static File getCurrentDirectory() { - return JaxxFileChooser.getCurrentDirectory(); - } - - public static boolean isCurrentDirectoryDefault() { - return JaxxFileChooser.isCurrentDirectoryDefault(); - } - - protected FileChooserUtil() { - // no instance please - } - - - public static class PatternChooserFilter extends javax.swing.filechooser.FileFilter { - protected final String pattern; - - protected final String description; - - public PatternChooserFilter(String pattern, String description) { - this.pattern = pattern; - this.description = description; - } - - @Override - public boolean accept(File f) { - return f.isDirectory() || f.getAbsolutePath().matches(pattern); - } - - @Override - public String getDescription() { - return description; - } - - } - - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - * @see #getFile(javax.swing.filechooser.FileFilter...) - */ - public static File getFile(String... patternOrDescriptionFilters) { - File result; - result = getFile(null, patternOrDescriptionFilters); - return result; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File getFile(javax.swing.filechooser.FileFilter... filters) { - return getFile(null, filters); - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param parent le component parent du dialog - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - * @see #getFile(javax.swing.filechooser.FileFilter...) - */ - public static File getFile(Component parent, - String... patternOrDescriptionFilters) { - File result; - result = getFile("Ok", "Ok", parent, patternOrDescriptionFilters); - return result; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - * @see #getFile(javax.swing.filechooser.FileFilter...) - */ - public static File getFile(String title, - String approvalText, - Component parent, - String... patternOrDescriptionFilters) { - - if (patternOrDescriptionFilters.length % 2 != 0) { - throw new IllegalArgumentException( - "Arguments must be (pattern, description) couple"); - } - javax.swing.filechooser.FileFilter[] filters = - new javax.swing.filechooser.FileFilter[ - patternOrDescriptionFilters.length / 2]; - for (int i = 0; i < filters.length; i++) { - String pattern = patternOrDescriptionFilters[i * 2]; - String description = patternOrDescriptionFilters[i * 2 + 1]; - filters[i] = new PatternChooserFilter(pattern, description); - } - File result; - result = getFile(title, approvalText, parent, filters); - return result; - } - - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param parent le component parent du dialog - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File getFile(Component parent, - javax.swing.filechooser.FileFilter... filters) { - return getFile("Ok", "Ok", parent, filters); - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est choisi ou l'utilisateur a annulé - */ - public static File getFile(String title, - String approvalText, - Component parent, - javax.swing.filechooser.FileFilter... filters) { - try { - JFileChooser chooser = new JFileChooser(currentDirectory); - - chooser.setDialogType(JFileChooser.CUSTOM_DIALOG); - if (filters.length > 0) { - if (filters.length == 1) { - chooser.setFileFilter(filters[0]); - } else { - for (javax.swing.filechooser.FileFilter filter : filters) { - chooser.addChoosableFileFilter(filter); - } - } - } - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setDialogTitle(title); - int returnVal = chooser.showDialog(parent, approvalText); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File theFile = chooser.getSelectedFile(); - if (theFile != null) { - currentDirectory = theFile; - return theFile.getAbsoluteFile(); - } - } - } catch (Exception eee) { - log.warn("Erreur:", eee); - } - return null; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données - * par deux, le pattern du filtre + la description du filtre - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File saveFile(String filename, - String title, - String approvalText, - Component parent, - String... patternOrDescriptionFilters) { - - if (patternOrDescriptionFilters.length % 2 != 0) { - throw new IllegalArgumentException( - "Arguments must be (pattern, description) couple"); - } - javax.swing.filechooser.FileFilter[] filters = - new javax.swing.filechooser.FileFilter[ - patternOrDescriptionFilters.length / 2]; - for (int i = 0; i < filters.length; i++) { - String pattern = patternOrDescriptionFilters[i * 2]; - String description = patternOrDescriptionFilters[i * 2 + 1]; - filters[i] = new FileUtil.PatternChooserFilter(pattern, description); - } - File result; - result = saveFile(filename, title, approvalText, parent, filters); - return result; - } - - /** - * Retourne le nom du fichier entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null. - * - * @param title le titre de la boite de dialogue - * @param approvalText le label du boutton d'acceptation - * @param parent le component parent du dialog - * @param filters les filtres a ajouter - * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé - */ - public static File saveFile(String filename, - String title, - String approvalText, - Component parent, - javax.swing.filechooser.FileFilter... filters) { - File selectedFile = new File(getCurrentDirectory(), filename); - JFileChooser chooser = new JFileChooser(selectedFile); - - chooser.setDialogType(JFileChooser.SAVE_DIALOG); - chooser.setSelectedFile(selectedFile); - if (filters.length > 0) { - if (filters.length == 1) { - chooser.setFileFilter(filters[0]); - } else { - for (javax.swing.filechooser.FileFilter filter : filters) { - chooser.addChoosableFileFilter(filter); - } - } - } - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setDialogTitle(title); - - File result = null; - - int returnVal = chooser.showDialog(parent, approvalText); - if (returnVal == JFileChooser.APPROVE_OPTION) { - result = chooser.getSelectedFile(); - if (result != null) { - setCurrentDirectory(result); - result = result.getAbsoluteFile(); - } - } - return result; - } - - /** - * @return le nom du repertoire entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne - * null. - */ - public static String getDirectory() { - return getDirectory(null, "Ok", "Ok"); - } - - /** - * @param title le nom de la boite de dialogue - * @param approvalText le texte de l'action d'acceptation du répertoire dans le file chooser - * @return le nom du repertoire entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne - * null. - */ - public static String getDirectory(String title, String approvalText) { - return getDirectory(null, title, approvalText); - } - - /** - * @param parent le component parent du dialog - * @param title le nom de la boite de dialogue - * @param approvalText le texte de l'action d'acceptation du répertoire dans le file chooser - * @return le nom du repertoire entre dans la boite de dialogue. - * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne - * null. - */ - public static String getDirectory(Component parent, - String title, - String approvalText) { - try { - JFileChooser chooser = new JFileChooser(currentDirectory); - chooser.setDialogType(JFileChooser.CUSTOM_DIALOG); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setDialogTitle(title); - int returnVal = chooser.showDialog(parent, approvalText); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File theFile = chooser.getSelectedFile(); - if (theFile != null) { - currentDirectory = theFile; - if (theFile.isDirectory()) { - return theFile.getAbsolutePath(); - } - } - } else { - return null; - } - } catch (Exception eee) { - log.warn("Erreur:", eee); - } - return null; - } -} diff --git a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java b/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java index c38ce8b..d061a10 100644 --- a/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java +++ b/jaxx-runtime/src/main/java/org/nuiton/jaxx/runtime/JAXXUtil.java @@ -341,72 +341,6 @@ public class JAXXUtil { } } - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static boolean assignment(boolean value, - String name, - JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - - public static byte assignment(byte value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static short assignment(short value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static int assignment(int value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static long assignment(long value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static float assignment(float value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static double assignment(double value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static char assignment(char value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - - /** @deprecated since 2.4.2, never use, will not be replaced */ - @Deprecated - public static Object assignment(Object value, String name, JAXXObject src) { - src.firePropertyChange(name.trim(), null, "dummy value"); - return value; - } - /** * Compute the string representation of an object. * diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx deleted file mode 100644 index 9dc8c63..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanel.jaxx +++ /dev/null @@ -1,139 +0,0 @@ -<!-- - #%L - JAXX :: Widgets - %% - Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser 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 Lesser Public License for more details. - - You should have received a copy of the GNU General Lesser Public - License along with this program. If not, see - <http://www.gnu.org/licenses/lgpl-3.0.html>. - #L% - --> - -<Table insets='1' - background='{getBackgroundColor()}' - border='{BorderFactory.createLineBorder(Color.BLACK, 1)}'> - - <import> - java.awt.Color - java.awt.Frame - javax.swing.BorderFactory - javax.swing.SwingConstants - </import> - - <AboutPanelHandler id='handler' constructorParams='this'/> - - <String id='title' javaBean='null'/> - - <String id='iconPath' javaBean='null'/> - - <String id='aboutText' javaBean='null'/> - - <String id='bottomText' javaBean='null'/> - - <String id='licenseText' javaBean='null'/> - - <String id='thirdpartyText' javaBean='null'/> - - <Color id='backgroundColor' javaBean='null'/> - - <script><![CDATA[ -public void setLicenseFile(String filename) { - handler.setLicenseFile(filename); -} - -public void setThirdpartyFile(String filename) { - handler.setThirdpartyFile(filename); -} - -public void buildTopPanel() { - handler.buildTopPanel(); -} - -public void init() { - handler.init(); -} - -public void showInDialog(Frame ui, boolean undecorated) { - handler.showInDialog(ui, undecorated); -} - -void $afterCompleteSetup() { - handler.$afterCompleteSetup(); -} - -]]> - </script> - <row> - <cell weightx='1' fill='both'> - <JPanel background='{Color.WHITE}' layout='{new BorderLayout()}'> - <JLabel text='{SwingUtil.getStringValue(getTitle())}' - visible='{getTitle() != null}' - font-size='12' - constraints='BorderLayout.CENTER'/> - </JPanel> - </cell> - </row> - <row> - <cell weightx='1' fill='both'> - <JPanel id='topPanel'/> - </cell> - </row> - <row> - <cell weighty='1' fill='both'> - <JTabbedPane id='tabs'> - <tab title="aboutframe.about"> - <JScrollPane id='aboutContent' border='{null}'> - <JEditorPane contentType='text/html' - editable='false' - border='{null}' - text='{SwingUtil.getStringValue(getAboutText())}' - onHyperlinkUpdate='SwingUtil.openLink(event)'/> - </JScrollPane> - </tab> - <tab title="aboutframe.license"> - <JScrollPane id='licenseContent' border='{null}'> - <JTextArea id='licenseTextArea' - editable='false' - font-size='11' - border='{null}' - text='{SwingUtil.getStringValue(getLicenseText())}'/> - </JScrollPane> - </tab> - <tab title="aboutframe.thirdparty"> - <JScrollPane id='thirdpartyContent' border='{null}'> - <JTextArea id='thirdpartyTextArea' - editable='false' - font-size='11' - border='{null}' - text='{SwingUtil.getStringValue(getThirdpartyText())}'/> - </JScrollPane> - </tab> - </JTabbedPane> - </cell> - </row> - <row> - <cell fill='both'> - <JPanel layout='{new BorderLayout()}'> - <JLabel id='bottomLabel' - constraints='BorderLayout.CENTER' - horizontalAlignment='{SwingConstants.CENTER}' - text='{SwingUtil.getStringValue(getBottomText())}' - visible='{getBottomText() != null}'/> - <JButton id='close' action='{handler.closeAction}' - constraints='BorderLayout.EAST'/> - </JPanel> - </cell> - </row> - -</Table> diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanelHandler.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanelHandler.java deleted file mode 100644 index b514fe3..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/AboutPanelHandler.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jaxx.runtime.swing; - -import org.nuiton.jaxx.runtime.JAXXUtil; -import org.nuiton.jaxx.runtime.SwingUtil; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.Resource; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import java.awt.Component; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.IOException; -import java.io.InputStream; - -import static org.nuiton.i18n.I18n.t; - -/** - * Handler of the ui {@link AboutPanel}. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 2.4 - * @deprecated please use now jaxx-widgets-about module instead. - */ -@Deprecated -public class AboutPanelHandler { - - private static final Log log = LogFactory.getLog(AboutPanelHandler.class); - - protected final AboutPanel ui; - - public AboutPanelHandler(AboutPanel ui) { - this.ui = ui; - } - - final protected Action closeAction = new AbstractAction("close") { - private static final long serialVersionUID = 1L; - - @Override - public void actionPerformed(ActionEvent e) { - JDialog container = ui.getParentContainer(JDialog.class); - if (container != null) { - container.dispose(); - } else { - ui.setVisible(false); - } - } - }; - - public void setLicenseFile(String filename) { - String load = load(filename); - ui.setLicenseText(load); - } - - public void setThirdpartyFile(String filename) { - String load = load(filename); - ui.setThirdpartyText(load); - } - - public void buildTopPanel() { - // image - JLabel labelIcon; - if (ui.iconPath != null) { - Icon logoIcon = Resource.getIcon(ui.iconPath); - labelIcon = new JLabel(logoIcon); - } else { - labelIcon = new JLabel(); - } - ui.topPanel.add(labelIcon); - } - - public void init() { - if (ui.getAboutText() == null) { - ui.tabs.remove(ui.aboutContent); - } - if (ui.getLicenseText() == null) { - ui.tabs.remove(ui.licenseContent); - } else { - SwingUtilities.invokeLater(() -> ui.licenseTextArea.setCaretPosition(0)); - - } - if (ui.getThirdpartyText() == null) { - ui.tabs.remove(ui.thirdpartyContent); - } else { - SwingUtilities.invokeLater(() -> ui.thirdpartyTextArea.setCaretPosition(0)); - } - } - - public void showInDialog(Frame ui, boolean undecorated) { - JDialog f = new JDialog(ui, true); - f.add(this.ui); - if (this.ui.iconPath != null) { - f.setIconImage(SwingUtil.createIcon(this.ui.iconPath).getImage()); - } - f.setResizable(false); - f.setSize(550, 450); - f.setUndecorated(undecorated); - JRootPane rootPane = f.getRootPane(); - rootPane.setDefaultButton(this.ui.close); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); - rootPane.getActionMap().put("close", closeAction); - f.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - Component ui = (Component) e.getSource(); - if (log.isInfoEnabled()) { - log.info("destroy ui " + ui); - } - JAXXUtil.destroy(ui); - JAXXUtil.destroy(AboutPanelHandler.this.ui); - } - }); - SwingUtil.center(ui, f); - f.setVisible(true); - } - - protected String load(String filename) { - InputStream licenseStream = getClass().getResourceAsStream("/" + filename); - String result = null; - try { - if (licenseStream != null) { - result = IOUtils.toString(licenseStream); - } - } catch (IOException ex) { - // ignore it - } finally { - if (licenseStream != null) { - try { - licenseStream.close(); - } catch (IOException ex) { - log.error("could not close file " + filename); - } - } - } - if (result == null) { - result = "resource " + filename + " not found"; - } - return result; - } - - void $afterCompleteSetup() { - buildTopPanel(); - ui.close.setText(t("aboutframe.ok")); - } -} diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java index 1d08f7b..cff617d 100644 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java +++ b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/JAXXWidgetUtil.java @@ -21,15 +21,15 @@ */ package org.nuiton.jaxx.runtime.swing; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; import org.nuiton.jaxx.runtime.SwingUtil; import org.nuiton.jaxx.runtime.swing.editor.cell.DateCellEditor; import org.nuiton.jaxx.runtime.swing.editor.cell.FileCellEditor; import org.nuiton.jaxx.runtime.swing.editor.cell.KeyStrokeCellEditor; -import org.nuiton.jaxx.runtime.swing.editor.cell.NumberCellEditor; import org.nuiton.jaxx.runtime.swing.renderer.DateCellRenderer; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + /** * @author Sylvain Lletellier */ @@ -55,7 +55,4 @@ public class JAXXWidgetUtil extends SwingUtil { return new KeyStrokeCellEditor(); } - public static <E extends Number> NumberCellEditor<E> newNumberTableCellEditor(Class<E> type, boolean useSign) { - return new NumberCellEditor<>(type, useSign); - } } diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/NumberCellEditor.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/NumberCellEditor.java deleted file mode 100644 index 138e00a..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/runtime/swing/editor/cell/NumberCellEditor.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jaxx.runtime.swing.editor.cell; - -import java.awt.Component; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; -import javax.swing.table.TableCellEditor; -import org.nuiton.jaxx.runtime.JAXXUtil; -import org.nuiton.jaxx.runtime.swing.editor.NumberEditor; - -/** - * @author Sylvain Lletellier - * @deprecated since 2.17, prefer use {@code org.nuiton.jaxx.widgets.editor.cell.NumberCellEditor}. - */ -@Deprecated -public class NumberCellEditor<E extends Number> extends AbstractCellEditor - implements TableCellEditor, FocusListener, AncestorListener { - - private static final long serialVersionUID = 1L; - - protected final NumberEditor numberEditor; - - /** constructor */ - public NumberCellEditor(Class<E> type, boolean useSign) { - numberEditor = new NumberEditor(); - numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT); - numberEditor.getTextField().setBorder(null); - numberEditor.getTextField().addFocusListener(this); - numberEditor.getTextField().addAncestorListener(this); - - numberEditor.setModelType(type); - - numberEditor.setUseSign(useSign); - numberEditor.init(); - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, int row, int column) { - - E number = (E) value; - numberEditor.setModel(number); - numberEditor.setModelText(JAXXUtil.getStringValue(number)); - return numberEditor; - } - - public NumberEditor getNumberEditor() { - return numberEditor; - } - - @Override - public E getCellEditorValue() { - return (E)numberEditor.getModel(); - } - - @Override - public void focusGained(FocusEvent e) { - SwingUtilities.invokeLater(() -> { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - }); - } - - @Override - public void focusLost(FocusEvent e) { - // commenting the next line fixes http://www.nuiton.org/issues/3517 and http://www.nuiton.org/issues/3518 -// cancelCellEditing(); - } - - @Override - public void ancestorAdded(AncestorEvent event) { - SwingUtilities.invokeLater(() -> { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - }); - } - - @Override - public void ancestorRemoved(AncestorEvent event) { - } - - @Override - public void ancestorMoved(AncestorEvent event) { - } - - @Override - public boolean stopCellEditing() { - boolean result = super.stopCellEditing(); - // Reset previous data to avoid keeping it on other cell edition - if (result) { - numberEditor.setModel(null); - // Use empty string, otherwise there is a NPE in NumberEditorHandler - numberEditor.setModelText(""); - // force binding, I do not know why the textfield text is not emptied - // if we do not force it - numberEditor.applyDataBinding(NumberEditor.BINDING_TEXT_FIELD_TEXT); - } - return result; - } - -} -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.