/hg/icedtea-web: AppTrustWarningPanel buttons made more flexible

aazores at icedtea.classpath.org aazores at icedtea.classpath.org
Tue Mar 4 08:11:03 PST 2014


changeset d8407ab3635c in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=d8407ab3635c
author: Andrew Azores <aazores at redhat.com>
date: Tue Mar 04 11:10:51 2014 -0500

	AppTrustWarningPanel buttons made more flexible

	* netx/net/sourceforge/jnlp/resources/Messages.properties:
	(SAppletTitle) new message
	* netx/net/sourceforge/jnlp/security/AppTrustWarningPanel.java:
	(buttons) new list of UI buttons. (getAllowButton, getRejectButton,
	addComponents) made final.
	(createButtonPanel) uses list of buttons rather than hardcoded.
	(helpButton) action made configurable.


diffstat:

 ChangeLog                                                    |  10 +
 netx/net/sourceforge/jnlp/resources/Messages.properties      |   1 +
 netx/net/sourceforge/jnlp/security/AppTrustWarningPanel.java |  82 +++++++----
 3 files changed, 60 insertions(+), 33 deletions(-)

diffs (181 lines):

diff -r 07d7757eda0c -r d8407ab3635c ChangeLog
--- a/ChangeLog	Tue Mar 04 10:35:17 2014 -0500
+++ b/ChangeLog	Tue Mar 04 11:10:51 2014 -0500
@@ -1,3 +1,13 @@
+2014-03-04  Andrew Azores  <aazores at redhat.com>
+
+	* netx/net/sourceforge/jnlp/resources/Messages.properties:
+	(SAppletTitle) new message
+	* netx/net/sourceforge/jnlp/security/AppTrustWarningPanel.java:
+	(buttons) new list of UI buttons. (getAllowButton, getRejectButton,
+	addComponents) made final.
+	(createButtonPanel) uses list of buttons rather than hardcoded.
+	(helpButton) action made configurable.
+
 2014-03-03  Omair Majid  <omajid at redhat.com>
 
 	PR857
diff -r 07d7757eda0c -r d8407ab3635c netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties	Tue Mar 04 10:35:17 2014 -0500
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties	Tue Mar 04 11:10:51 2014 -0500
@@ -264,6 +264,7 @@
 SNotAllSignedQuestion=Do you wish to proceed and run this application anyway?
 SAuthenticationPrompt=The {0} server at {1} is requesting authentication. It says "{2}"
 SJNLPFileIsNotSigned=This application contains a digital signature in which the launching JNLP file is not signed.
+SAppletTitle=Applet title: {0}
 
 # Security - used for the More Information dialog
 SBadKeyUsage=Resources contain entries whose signer certificate's KeyUsage extension doesn't allow code signing.
diff -r 07d7757eda0c -r d8407ab3635c netx/net/sourceforge/jnlp/security/AppTrustWarningPanel.java
--- a/netx/net/sourceforge/jnlp/security/AppTrustWarningPanel.java	Tue Mar 04 10:35:17 2014 -0500
+++ b/netx/net/sourceforge/jnlp/security/AppTrustWarningPanel.java	Tue Mar 04 11:10:51 2014 -0500
@@ -46,6 +46,8 @@
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.swing.BorderFactory;
 import javax.swing.BoxLayout;
@@ -60,7 +62,6 @@
 import javax.swing.SwingConstants;
 
 import net.sourceforge.jnlp.JNLPFile;
-import net.sourceforge.jnlp.PluginBridge;
 import net.sourceforge.jnlp.security.appletextendedsecurity.ExecuteAppletAction;
 import net.sourceforge.jnlp.security.appletextendedsecurity.ExtendedAppletSecurityHelp;
 import net.sourceforge.jnlp.util.ScreenFinder;
@@ -111,16 +112,17 @@
     protected int INFO_PANEL_HINT_HEIGHT = 25;
     protected int QUESTION_PANEL_HEIGHT = 35;
 
-    private JButton allowButton;
-    private JButton rejectButton;
-    private JButton helpButton;
-    private JCheckBox permanencyCheckBox;
-    private JRadioButton applyToAppletButton;
-    private JRadioButton applyToCodeBaseButton;
+    protected List<JButton> buttons;
+    protected JButton allowButton;
+    protected JButton rejectButton;
+    protected JButton helpButton;
+    protected JCheckBox permanencyCheckBox;
+    protected JRadioButton applyToAppletButton;
+    protected JRadioButton applyToCodeBaseButton;
 
     protected JNLPFile file;
 
-    private ActionChoiceListener actionChoiceListener;
+    protected ActionChoiceListener actionChoiceListener;
 
     /*
      * Subclasses should call addComponents() IMMEDIATELY after calling the super() constructor!
@@ -128,6 +130,20 @@
     public AppTrustWarningPanel(JNLPFile file, ActionChoiceListener actionChoiceListener) {
         this.file = file;
         this.actionChoiceListener = actionChoiceListener;
+        this.buttons = new ArrayList<JButton>();
+
+        allowButton = new JButton(R("ButProceed"));
+        rejectButton = new JButton(R("ButCancel"));
+        helpButton = new JButton(R("APPEXTSECguiPanelHelpButton"));
+
+        allowButton.addActionListener(chosenActionSetter(true));
+        rejectButton.addActionListener(chosenActionSetter(false));
+
+        helpButton.addActionListener(getHelpButtonAction());
+
+        buttons.add(allowButton);
+        buttons.add(rejectButton);
+        buttons.add(helpButton);
     }
 
     /*
@@ -151,15 +167,26 @@
      */
     protected abstract String getQuestionPanelText();
 
-    public JButton getAllowButton() {
+    public final JButton getAllowButton() {
         return allowButton;
     }
 
-    public JButton getRejectButton() {
+    public final JButton getRejectButton() {
         return rejectButton;
     }
 
-    protected static String htmlWrap(String text) {
+    protected ActionListener getHelpButtonAction() {
+        return new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                JDialog d = new ExtendedAppletSecurityHelp(null, false, "dialogue");
+                ScreenFinder.centerWindowsToCurrentScreen(d);
+                d.setVisible(true);
+            }
+        };
+    }
+
+    protected static final String htmlWrap(String text) {
         return "<html>" + text + "</html>";
     }
 
@@ -180,11 +207,16 @@
     }
 
     private void setupInfoPanel() {
+        String titleText = R("SAppletTitle", file.getTitle());
+        JLabel titleLabel = new JLabel(titleText);
+        titleLabel.setFont(new Font(titleLabel.getFont().getName(), Font.BOLD, 18));
+
         String infoLabelText = getInfoPanelText();
-        int panelHeight = INFO_PANEL_HEIGHT + INFO_PANEL_HINT_HEIGHT;
+        JLabel infoLabel = new JLabel(infoLabelText);
 
-        JLabel infoLabel = new JLabel(infoLabelText);
+        int panelHeight = titleLabel.getHeight() + INFO_PANEL_HEIGHT + INFO_PANEL_HINT_HEIGHT;
         JPanel infoPanel = new JPanel(new BorderLayout());
+        infoPanel.add(titleLabel, BorderLayout.PAGE_START);
         infoPanel.add(infoLabel, BorderLayout.CENTER);
         infoPanel.setPreferredSize(new Dimension(PANE_WIDTH, panelHeight));
         infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
@@ -237,25 +269,9 @@
     private JPanel createButtonPanel() {
         JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
 
-        allowButton = new JButton(R("ButProceed"));
-        rejectButton = new JButton(R("ButCancel"));
-        helpButton = new JButton(R("APPEXTSECguiPanelHelpButton"));
-
-        allowButton.addActionListener(chosenActionSetter(true));
-        rejectButton.addActionListener(chosenActionSetter(false));
-
-        helpButton.addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-                JDialog d = new ExtendedAppletSecurityHelp(null, false, "dialogue");
-                ScreenFinder.centerWindowsToCurrentScreen(d);
-                d.setVisible(true);
-            }
-        });
-
-        buttonPanel.add(allowButton);
-        buttonPanel.add(rejectButton);
-        buttonPanel.add(helpButton);
+        for (final JButton button : buttons) {
+            buttonPanel.add(button);
+        }
 
         buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
 
@@ -280,7 +296,7 @@
      * Creates the actual GUI components, and adds it to this panel. This should be called by all subclasses
      * IMMEDIATELY after calling the super() constructor!
      */
-    protected void addComponents() {
+    protected final void addComponents() {
         setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
 
         setupTopPanel();


More information about the distro-pkg-dev mailing list