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 0b552ae623c68cca9f212557dab6b41fef9727c4 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Sep 13 13:39:28 2016 +0200 Rename AboutPanel → AboutUI (See #4024) --- .../org/nuiton/jaxx/widgets/about/AboutPanel.jaxx | 78 ------------------- .../jaxx/widgets/about/AboutPanelHandler.java | 91 ---------------------- .../org/nuiton/jaxx/widgets/about/AboutUI.jaxx | 73 +++++++++++++++++ ...{AboutPanelBuilder.java => AboutUIBuilder.java} | 87 +++++++++++---------- 4 files changed, 117 insertions(+), 212 deletions(-) diff --git a/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanel.jaxx b/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanel.jaxx deleted file mode 100644 index 596c526..0000000 --- a/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanel.jaxx +++ /dev/null @@ -1,78 +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' border='{BorderFactory.createLineBorder(Color.BLACK, 1)}'> - - <import> - java.awt.Color - javax.swing.BorderFactory - javax.swing.SwingConstants - - static org.nuiton.i18n.I18n.t; - </import> - - <String id='title' javaBean='null'/> - - <String id='iconPath' javaBean='null'/> - - <String id='bottomText' javaBean='null'/> - - <script><![CDATA[ - -public void display() { - handler.display(this); -} - -]]> - </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'/> - - <JToolBar constraints='BorderLayout.EAST' opaque="false" borderPainted="false" floatable="false"> - <JButton id='close' borderPainted="false" focusable="false" rolloverEnabled="false"/> - </JToolBar> - </JPanel> - </cell> - </row> - <row> - <cell weightx='1' fill='both'> - <JPanel id='topPanel'/> - </cell> - </row> - <row> - <cell weighty='1' fill='both'> - <JTabbedPane id='tabs'/> - </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}'/> - </JPanel> - </cell> - </row> - -</Table> diff --git a/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanelHandler.java b/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanelHandler.java deleted file mode 100644 index 7c3cca5..0000000 --- a/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanelHandler.java +++ /dev/null @@ -1,91 +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.widgets.about; - -import jaxx.runtime.JAXXUtil; -import jaxx.runtime.SwingUtil; -import jaxx.runtime.spi.UIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; -import java.awt.Frame; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -/** - * Handler of the ui {@link AboutPanel}. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.4 - */ -public class AboutPanelHandler implements UIHandler<AboutPanel> { - - private static final Log log = LogFactory.getLog(AboutPanelHandler.class); - - public static final String CLOSE_ACTION = "close"; - public static final String UNDECORATED = "undecorated"; - public static final String PARENT = "parent"; - - @Override - public void beforeInit(AboutPanel aboutPanel) { - } - - @Override - public void afterInit(final AboutPanel aboutPanel) { - } - - public void display(final AboutPanel ui) { - - boolean undecorated = (Boolean) ui.getClientProperty(UNDECORATED); - Frame parent = (Frame) ui.getClientProperty(PARENT); - - JDialog dialog = new JDialog(parent, true); - dialog.add(ui); - if (ui.getIconPath() != null) { - dialog.setIconImage(SwingUtil.createIcon(ui.getIconPath()).getImage()); - } - dialog.setResizable(true); - dialog.setSize(550, 450); - dialog.setUndecorated(undecorated); - dialog.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - if (log.isDebugEnabled()) { - log.debug("destroy ui " + ui); - } - JAXXUtil.destroy(ui); - } - }); - JRootPane rootPane = dialog.getRootPane(); - rootPane.setDefaultButton(ui.getClose()); - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), CLOSE_ACTION); - rootPane.getActionMap().put(CLOSE_ACTION, ui.getClose().getAction()); - - SwingUtil.center(parent, dialog); - dialog.setVisible(true); - - } -} diff --git a/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutUI.jaxx b/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutUI.jaxx new file mode 100644 index 0000000..904a402 --- /dev/null +++ b/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutUI.jaxx @@ -0,0 +1,73 @@ +<!-- + #%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% + --> +<JDialog resizable="true" undecorated="true" onWindowClosed="SwingUtil.destroy(this)" + iconImage="{SwingUtil.createIcon(getIconPath()).getImage()}"> + <import> + java.awt.Color + javax.swing.BorderFactory + javax.swing.SwingConstants + </import> + + <String id='iconPath' javaBean='"/icons/action-close.png"'/> + + <script><![CDATA[ +public void display() { + setSize((int)(getOwner().getWidth() * 0.7), (int)(getOwner().getHeight() * 0.7)); + SwingUtil.center(getOwner(), this); + setVisible(true); +} +]]> + </script> + + <Table insets='1' border='{BorderFactory.createLineBorder(Color.BLACK, 1)}'> + <row> + <cell weightx='1' fill='both'> + <JPanel background='{Color.WHITE}' layout='{new BorderLayout()}'> + <JLabel id="titleLabel" visible='{getTitle() != null}' font-size='12' constraints='BorderLayout.CENTER'/> + + <JToolBar constraints='BorderLayout.EAST' opaque="false" borderPainted="false" floatable="false"> + <JButton id='close' actionIcon="close" toolTipText="aboutframe.close" borderPainted="false" focusable="false"/> + </JToolBar> + </JPanel> + </cell> + </row> + <row> + <cell weightx='1' fill='both'> + <JPanel id='topPanel'/> + </cell> + </row> + <row> + <cell weighty='1' fill='both'> + <JTabbedPane id='tabs'/> + </cell> + </row> + <row> + <cell fill='both'> + <JPanel layout='{new BorderLayout()}'> + <JLabel id='bottomLabel' constraints='BorderLayout.CENTER' horizontalAlignment='{SwingConstants.CENTER}' + visible='{bottomLabel.getText() != null}'/> + </JPanel> + </cell> + </row> + + </Table> +</JDialog> \ No newline at end of file diff --git a/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanelBuilder.java b/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutUIBuilder.java similarity index 60% rename from jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanelBuilder.java rename to jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutUIBuilder.java index 314d418..ee50295 100644 --- a/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutPanelBuilder.java +++ b/jaxx-widgets-about/src/main/java/org/nuiton/jaxx/widgets/about/AboutUIBuilder.java @@ -9,10 +9,12 @@ import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JComponent; -import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JLabel; +import javax.swing.JRootPane; import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; @@ -22,126 +24,125 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import static org.nuiton.i18n.I18n.t; -import static org.nuiton.jaxx.widgets.about.AboutPanelHandler.CLOSE_ACTION; /** * Created on 12/09/16. * * @author Tony Chemit - chemit@codelutin.com */ -public class AboutPanelBuilder { +public class AboutUIBuilder { - protected final AboutPanel aboutPanel; + public static final String CLOSE_ACTION = "close"; - protected final Frame parent; + protected final AboutUI ui; - public AboutPanelBuilder(Frame parent) { + public AboutUIBuilder(Frame parent) { Preconditions.checkNotNull(parent); - this.parent = parent; - this.aboutPanel = new AboutPanel(); - this.aboutPanel.putClientProperty(AboutPanelHandler.PARENT, parent); + this.ui = new AboutUI(parent, true); Action closeAction = new AbstractAction(CLOSE_ACTION) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { - JDialog container = aboutPanel.getParentContainer(JDialog.class); - container.dispose(); + ui.dispose(); } }; closeAction.putValue(Action.NAME, null); - closeAction.putValue(Action.SMALL_ICON, SwingUtil.getUIManagerActionIcon(CLOSE_ACTION)); - closeAction.putValue(Action.SHORT_DESCRIPTION, t("aboutframe.close")); - aboutPanel.getClose().setAction(closeAction); + closeAction.putValue(Action.SMALL_ICON, ui.getClose().getIcon()); + closeAction.putValue(Action.SHORT_DESCRIPTION, ui.getClose().getToolTipText()); + ui.getClose().setAction(closeAction); + + JRootPane rootPane = ui.getRootPane(); + rootPane.setDefaultButton(ui.getClose()); + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), CLOSE_ACTION); + rootPane.getActionMap().put(CLOSE_ACTION, closeAction); + } - public static AboutPanelBuilder builder(Frame parent) { - return new AboutPanelBuilder(parent); + public static AboutUIBuilder builder(Frame parent) { + return new AboutUIBuilder(parent); } - public AboutPanelBuilder setTitle(String title) { - aboutPanel.setTitle(title); + public AboutUIBuilder setTitle(String title) { + ui.getTitleLabel().setText(title); return this; } - public AboutPanelBuilder setIconPath(String iconPath) { - aboutPanel.setIconPath(iconPath); + public AboutUIBuilder setIconPath(String iconPath) { + ui.setIconPath(iconPath); if (iconPath != null) { Icon logoIcon = Resource.getIcon(iconPath); - aboutPanel.getTopPanel().add(new JLabel(logoIcon)); + ui.getTopPanel().add(new JLabel(logoIcon)); } return this; } - public AboutPanelBuilder setBottomText(String bottomText) { - aboutPanel.setBottomText(bottomText); - return this; - } - - public AboutPanelBuilder undecorated() { - aboutPanel.putClientProperty(AboutPanelHandler.UNDECORATED, true); + public AboutUIBuilder setBottomText(String bottomText) { + ui.getBottomLabel().setText(bottomText); return this; } - public AboutPanelBuilder addAboutTab(String aboutText, boolean html) { + public AboutUIBuilder addAboutTab(String aboutText, boolean html) { return addTab0(t("aboutframe.about"), aboutText, html); } - public AboutPanelBuilder addDefaultLicenseTab(String projectName, boolean html) { + public AboutUIBuilder addDefaultLicenseTab(String projectName, boolean html) { return addLicenseTab("META-INF/" + projectName + "-LICENSE.txt", html); } - public AboutPanelBuilder addLicenseTab(String resourceName, boolean html) { + public AboutUIBuilder addLicenseTab(String resourceName, boolean html) { String tabContent = load(resourceName); addTab0(t("aboutframe.license"), tabContent, html); return this; } - public AboutPanelBuilder addDefaultThirdPartyTab(String projectName, boolean html) { + public AboutUIBuilder addDefaultThirdPartyTab(String projectName, boolean html) { return addThirdPartyTab("META-INF/" + projectName + "-THIRD-PARTY.txt", html); } - public AboutPanelBuilder addThirdPartyTab(String resourceName, boolean html) { + public AboutUIBuilder addThirdPartyTab(String resourceName, boolean html) { String tabContent = load(resourceName); return addTab0(t("aboutframe.thirdparty"), tabContent, html); } - public AboutPanelBuilder addDefaultChangelogTab(String projectName, boolean html) { + public AboutUIBuilder addDefaultChangelogTab(String projectName, boolean html) { return addChangelogTab("META-INF/" + projectName + "-CHANGELOG.txt", html); } - public AboutPanelBuilder addChangelogTab(String resourceName, boolean html) { + public AboutUIBuilder addChangelogTab(String resourceName, boolean html) { String tabContent = load(resourceName); return addTab0(t("aboutframe.changelog"), tabContent, html); } - public AboutPanelBuilder addTab(String tabTitle, String tabContent, boolean html) { + public AboutUIBuilder addTab(String tabTitle, String tabContent, boolean html) { return addTab0(tabTitle, tabContent, html); } - public AboutPanelBuilder addTabFromResource(String tabTitle, String resourceName, boolean html) { + public AboutUIBuilder addTabFromResource(String tabTitle, String resourceName, boolean html) { String tabContent = load(resourceName); return addTab0(tabTitle, tabContent, html); } - public AboutPanelBuilder addTab(String tabTitle, JComponent component) { + public AboutUIBuilder addTab(String tabTitle, JComponent component) { JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); - aboutPanel.tabs.addTab(tabTitle, component); + ui.tabs.addTab(tabTitle, component); return this; } - public AboutPanel build() { - return aboutPanel; + public AboutUI build() { + return ui; } - protected AboutPanelBuilder addTab0(String tabTitle, String tabContent, boolean html) { + protected AboutUIBuilder addTab0(String tabTitle, String tabContent, boolean html) { JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); - aboutPanel.tabs.addTab(tabTitle, scrollPane); + + JTabbedPane tabs = ui.getTabs(); + tabs.addTab(tabTitle, scrollPane); final JEditorPane jEditorPane = new JEditorPane(); jEditorPane.setBorder(null); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.