From f993d336e51b9f7898aeeff2e5ae6785066d1e5b Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 9 Oct 2008 16:23:52 +0000 Subject: demo integration beta1 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@94 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUI.java | 7 ++-- .../main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java | 3 +- .../main/java/at/gv/egiz/bku/gui/ImagePanel.java | 37 ++++++++++++++++++++ .../main/java/at/gv/egiz/bku/gui/SimpleGUI.java | 38 ++++++++++++++------- .../at/gv/egiz/bku/gui/Messages.properties | 2 +- BKUCommonGUI/src/main/resources/images/mocca.png | Bin 0 -> 1450 bytes .../src/main/resources/images/mocca_default.png | Bin 0 -> 1287 bytes .../src/main/resources/images/mocca_tiny.png | Bin 0 -> 1025 bytes 8 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java create mode 100644 BKUCommonGUI/src/main/resources/images/mocca.png create mode 100644 BKUCommonGUI/src/main/resources/images/mocca_default.png create mode 100644 BKUCommonGUI/src/main/resources/images/mocca_tiny.png (limited to 'BKUCommonGUI/src/main') diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java index 636a9fef..53ec1088 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java @@ -36,6 +36,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.text.MessageFormat; import java.util.List; import java.util.Locale; @@ -127,7 +128,7 @@ public class BKUGUI implements BKUGUIFacade { * @param localeString may be null */ @Override - public void init(final Container contentPane, String localeString) { + public void init(final Container contentPane, String localeString, final URL background) { if (localeString != null) { messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, new Locale(localeString)); @@ -149,7 +150,7 @@ public class BKUGUI implements BKUGUIFacade { log.debug("initializing gui"); // initIconPanel(); - initContentPanel(); + initContentPanel(background); GroupLayout layout = new GroupLayout(contentPane); contentPane.setLayout(layout); @@ -189,7 +190,7 @@ public class BKUGUI implements BKUGUIFacade { // .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); //); // } - protected void initContentPanel() { + protected void initContentPanel(URL background) { contentPanel = new JPanel(); diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java index 32eb4c3e..4925e7fa 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java @@ -20,6 +20,7 @@ import at.gv.egiz.stal.HashDataInput; import at.gv.egiz.smcc.PINSpec; import java.awt.Container; import java.awt.event.ActionListener; +import java.net.URL; import java.util.List; public interface BKUGUIFacade { @@ -32,7 +33,7 @@ public interface BKUGUIFacade { public static final String ERR_WRITE_HASHDATA = "error.write.hashdata"; public static final String ERR_INVALID_HASH = "error.invalid.hash"; - public void init(Container contentPane, String localeString); + public void init(Container contentPane, String localeString, URL background); public void showWelcomeDialog(); diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java new file mode 100644 index 00000000..e9c270ce --- /dev/null +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java @@ -0,0 +1,37 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package at.gv.egiz.bku.gui; + +import java.awt.Graphics; +import java.awt.Image; +import java.net.URL; +import javax.swing.ImageIcon; +import javax.swing.JPanel; + +/** + * + * @author clemens + */ +public class ImagePanel extends JPanel { + + protected Image backgroundImg; + + public ImagePanel(URL background) { + this(new ImageIcon(background).getImage()); + } + + public ImagePanel(Image img) { + this.backgroundImg = img; + this.setOpaque(false); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + g.drawImage(backgroundImg, 0, this.getHeight() - backgroundImg.getHeight(null), null); + } + +} diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java index b7d86d05..8e32d67e 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java @@ -36,6 +36,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.text.MessageFormat; import java.util.List; import java.util.Locale; @@ -53,6 +54,7 @@ import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.LayoutStyle; import javax.swing.SwingUtilities; +import javax.swing.border.TitledBorder; import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import org.apache.commons.logging.Log; @@ -66,7 +68,7 @@ public class SimpleGUI implements BKUGUIFacade { private static final Log log = LogFactory.getLog(SimpleGUI.class); public static final String MESSAGES_BUNDLE = "at/gv/egiz/bku/gui/Messages"; - public static final String LOGO_RESOURCE = "/images/logo.png"; + public static final String DEFAULT_BACKGROUND = "/images/mocca_default.png"; //logo.png"; public static final String HASHDATA_FONT = "Monospaced"; public static final Color ERROR_COLOR = Color.RED; public static final Color HYPERLINK_COLOR = Color.BLUE; @@ -121,13 +123,13 @@ public class SimpleGUI implements BKUGUIFacade { protected int buttonSize; private static final int CHECKBOX_WIDTH = new JCheckBox().getPreferredSize().width; - + /** * @param contentPane * @param localeString may be null */ @Override - public void init(final Container contentPane, String localeString) { + public void init(final Container contentPane, String localeString, final URL background) { if (localeString != null) { messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, new Locale(localeString)); @@ -149,7 +151,7 @@ public class SimpleGUI implements BKUGUIFacade { log.debug("initializing gui"); // initIconPanel(); - initContentPanel(); + initContentPanel(background); GroupLayout layout = new GroupLayout(contentPane); contentPane.setLayout(layout); @@ -189,13 +191,20 @@ public class SimpleGUI implements BKUGUIFacade { // .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); //); // } - protected void initContentPanel() { + protected void initContentPanel(URL background) { - contentPanel = new JPanel(); + if (background == null) { + background = this.getClass().getResource(DEFAULT_BACKGROUND); + } + contentPanel = new ImagePanel(background); +// contentPanel.setBorder(new TitledBorder("content")); + // headerPanel = new JPanel(); mainPanel = new JPanel(); - buttonPanel = new JPanel(); + mainPanel.setOpaque(false); + buttonPanel = new JPanel(); // new ImagePanel(LOGO_RESOURCE); //new JPanel(); + buttonPanel.setOpaque(false); // headerPanel.setBorder(new TitledBorder("header")); // mainPanel.setBorder(new TitledBorder("main")); @@ -487,13 +496,14 @@ public class SimpleGUI implements BKUGUIFacade { // cancelButton.addActionListener(cancelListener); JButton okButton = new JButton(); + okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); okButton.setText(messages.getString(BUTTON_OK)); okButton.setEnabled(false); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); JLabel cardPinLabel = new JLabel(); - cardPinLabel.setFont(cardPinLabel.getFont().deriveFont(cardPinLabel.getFont().getStyle() | java.awt.Font.BOLD)); + cardPinLabel.setFont(cardPinLabel.getFont().deriveFont(cardPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); String pinLabel = messages.getString(LABEL_PIN); cardPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); @@ -513,8 +523,8 @@ public class SimpleGUI implements BKUGUIFacade { }); JLabel infoLabel = new JLabel(); + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD, infoLabel.getFont().getSize()-2)); if (numRetries < 0) { - infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); String pinsizePattern = messages.getString(LABEL_PINSIZE); String pinSize = String.valueOf(pinSpec.getMinLength()); if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { @@ -658,13 +668,14 @@ public class SimpleGUI implements BKUGUIFacade { // cancelButton.addActionListener(cancelListener); JButton signButton = new JButton(); + signButton.setFont(signButton.getFont().deriveFont(signButton.getFont().getStyle() & ~java.awt.Font.BOLD)); signButton.setText(messages.getString(BUTTON_SIGN)); signButton.setEnabled(false); signButton.setActionCommand(signCommand); signButton.addActionListener(signListener); JLabel signPinLabel = new JLabel(); - signPinLabel.setFont(signPinLabel.getFont().deriveFont(signPinLabel.getFont().getStyle() | java.awt.Font.BOLD)); + signPinLabel.setFont(signPinLabel.getFont().deriveFont(signPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); String pinLabel = messages.getString(LABEL_PIN); signPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); @@ -684,7 +695,7 @@ public class SimpleGUI implements BKUGUIFacade { //pinsize or error label JLabel infoLabel = new JLabel(); - infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD, infoLabel.getFont().getSize()-2)); if (numRetries < 0) { String pinsizePattern = messages.getString(LABEL_PINSIZE); String pinSize = String.valueOf(pinSpec.getMinLength()); @@ -721,7 +732,7 @@ public class SimpleGUI implements BKUGUIFacade { .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) // .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(infoLabel)); mainPanelLayout.setVerticalGroup( @@ -847,6 +858,7 @@ public class SimpleGUI implements BKUGUIFacade { .addComponent(errorMsgLabel)); JButton okButton = new JButton(); + okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); okButton.setText(messages.getString(BUTTON_OK)); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); @@ -1062,6 +1074,7 @@ public class SimpleGUI implements BKUGUIFacade { // mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addComponent(refIdLabel).addGap(refIdLabel.getFont().getSize()).addComponent(hashDataScrollPane).addGap(refIdLabel.getFont().getSize()))); JButton backButton = new JButton(); + backButton.setFont(backButton.getFont().deriveFont(backButton.getFont().getStyle() & ~java.awt.Font.BOLD)); backButton.setText(messages.getString(BUTTON_BACK)); backButton.setActionCommand(cancelCommand); backButton.addActionListener(cancelListener); @@ -1215,6 +1228,7 @@ public class SimpleGUI implements BKUGUIFacade { JButton backButton = new JButton(); + backButton.setFont(backButton.getFont().deriveFont(backButton.getFont().getStyle() & ~java.awt.Font.BOLD)); backButton.setText(messages.getString(BUTTON_BACK)); backButton.setActionCommand(cancelCommand); backButton.addActionListener(cancelListener); diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties index a2b5e0df..abed420f 100644 --- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties +++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties @@ -34,7 +34,7 @@ message.hashdatalist={0} Signaturdatenobjekte: message.retries=Noch {0} Versuch(e) message.overwrite=M\u00F6chten Sie das existierende Dokument {0} \u00FCberschreiben? label.pin={0}: -label.pinsize=({0} stellig) +label.pinsize={0} stellig button.ok=OK button.cancel=Abbrechen button.back=Zur\u00FCck diff --git a/BKUCommonGUI/src/main/resources/images/mocca.png b/BKUCommonGUI/src/main/resources/images/mocca.png new file mode 100644 index 00000000..881a65c1 Binary files /dev/null and b/BKUCommonGUI/src/main/resources/images/mocca.png differ diff --git a/BKUCommonGUI/src/main/resources/images/mocca_default.png b/BKUCommonGUI/src/main/resources/images/mocca_default.png new file mode 100644 index 00000000..349d9ff0 Binary files /dev/null and b/BKUCommonGUI/src/main/resources/images/mocca_default.png differ diff --git a/BKUCommonGUI/src/main/resources/images/mocca_tiny.png b/BKUCommonGUI/src/main/resources/images/mocca_tiny.png new file mode 100644 index 00000000..1f125d9b Binary files /dev/null and b/BKUCommonGUI/src/main/resources/images/mocca_tiny.png differ -- cgit v1.2.3