From 84e214e4d708f13c8f09c68273541e535c560296 Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 10 Sep 2008 16:54:04 +0000 Subject: gui final 0.1b git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@30 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUI.java | 620 ++++++++++++++++----- .../at/gv/egiz/bku/gui/Messages.properties | 10 +- .../test/java/at/gv/egiz/bku/gui/BKUGUITest.java | 10 +- .../test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java | 90 ++- .../src/test/resources/commons-logging.properties | 1 + BKUCommonGUI/src/test/resources/log4j.properties | 19 + 6 files changed, 579 insertions(+), 171 deletions(-) create mode 100644 BKUCommonGUI/src/test/resources/commons-logging.properties create mode 100644 BKUCommonGUI/src/test/resources/log4j.properties 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 5175b45f..044e6927 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 @@ -23,43 +23,47 @@ package at.gv.egiz.bku.gui; import at.gv.egiz.smcc.PINSpec; import at.gv.egiz.stal.HashDataInput; import java.awt.Color; +import java.awt.Component; import java.awt.Container; import java.awt.Cursor; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.BufferedInputStream; import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; +import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.GroupLayout; import javax.swing.ImageIcon; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JScrollPane; +import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.LayoutStyle; import javax.swing.SwingUtilities; +import javax.swing.border.TitledBorder; import javax.swing.filechooser.FileFilter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; @@ -75,9 +79,9 @@ public class BKUGUI implements BKUGUIFacade { private static final Log log = LogFactory.getLog(BKUGUI.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 int MAIN_PANEL_WIDTH = 100; +// public static final int MAIN_PANEL_WIDTH = 100; // public static final int MAIN_PANEL_HEIGHT = 20; - public static final int PREF_SIZE_PINFIELD = 118; +// public static final int PREF_SIZE_PINFIELD = 118; public static final Color ERROR_COLOR = Color.RED; public static final Color HYPERLINK_COLOR = Color.BLUE; private static final String TITLE_WELCOME = "title.welcome"; @@ -95,18 +99,21 @@ public class BKUGUI implements BKUGUIFacade { private static final String MESSAGE_INSERTCARD = "message.insertcard"; private static final String MESSAGE_HASHDATALINK = "message.hashdatalink"; private static final String MESSAGE_HASHDATA = "message.hashdata"; + private static final String MESSAGE_HASHDATALIST = "message.hashdatalist"; private static final String MESSAGE_RETRIES = "message.retries"; private static final String MESSAGE_OVERWRITE = "message.overwrite"; private static final String LABEL_PIN = "label.pin"; private static final String LABEL_PINSIZE = "label.pinsize"; -// private static final String LABEL_CARDPINSIZE="label.cardpinsize"; -// private static final String LABEL_SIGNPIN="label.signpin"; -// private static final String LABEL_SIGNPINSIZE="label.signpinsize"; + private static final String ERROR_HASHDATA = "error.hashdata"; + private static final String BUTTON_OK = "button.ok"; private static final String BUTTON_CANCEL = "button.cancel"; + private static final String BUTTON_BACK = "button.back"; private static final String BUTTON_SIGN = "button.sign"; private static final String BUTTON_SAVE = "button.save"; private static final String MIMETYPE_DESC_XML = "mimetype.desc.xml"; + private static final String MIMETYPE_DESC_HTML = "mimetype.desc.html"; + private static final String MIMETYPE_DESC_XHTML = "mimetype.desc.xhtml"; private static final String MIMETYPE_DESC_TXT = "mimetype.desc.txt"; private static final String MIMETYPE_DESC_PDF = "mimetype.desc.pdf"; private static final String MIMETYPE_DESC_BIN = "mimetype.desc.bin"; @@ -125,6 +132,15 @@ public class BKUGUI implements BKUGUIFacade { /** remember the pinfield to return to worker */ protected JPasswordField pinField; + protected JButton okButton; + protected JButton cancelButton; + protected JButton signButton; + protected JButton saveButton; + protected JButton backButton; + protected int buttonSize; + + private static final int CHECKBOX_WIDTH = new JCheckBox().getPreferredSize().width; + /** * @param contentPane * @param localeString may be null @@ -168,9 +184,19 @@ public class BKUGUI implements BKUGUIFacade { GroupLayout iconPanelLayout = new GroupLayout(iconPanel); iconPanel.setLayout(iconPanelLayout); iconPanelLayout.setHorizontalGroup( - iconPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(iconPanelLayout.createSequentialGroup().addContainerGap().addComponent(iconLabel).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); + iconPanelLayout.createSequentialGroup() +// iconPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(iconPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, iconLabel.getPreferredSize().width, GroupLayout.PREFERRED_SIZE) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); //); iconPanelLayout.setVerticalGroup( - iconPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(iconPanelLayout.createSequentialGroup().addContainerGap().addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE).addContainerGap(41, Short.MAX_VALUE))); + iconPanelLayout.createSequentialGroup() +// iconPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(iconPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, iconLabel.getPreferredSize().height, GroupLayout.PREFERRED_SIZE) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); //); } protected void initContentPanel() { @@ -190,23 +216,60 @@ public class BKUGUI implements BKUGUIFacade { java.awt.Font.BOLD, titleLabel.getFont().getSize() + 2)); // titleLabel.setForeground(defaultForground); + okButton = new JButton(); + okButton.setText(messages.getString(BUTTON_OK)); + cancelButton = new JButton(); + cancelButton.setText(messages.getString(BUTTON_CANCEL)); + signButton = new JButton(); + signButton.setText(messages.getString(BUTTON_SIGN)); + backButton = new JButton(); + backButton.setText(messages.getString(BUTTON_BACK)); + saveButton = new JButton(); + saveButton.setText(messages.getString(BUTTON_SAVE)); +// contentPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); + + if (okButton.getPreferredSize().width > buttonSize) + buttonSize = okButton.getPreferredSize().width; + if (cancelButton.getPreferredSize().width > buttonSize) + buttonSize = cancelButton.getPreferredSize().width; + if (signButton.getPreferredSize().width > buttonSize) + buttonSize = signButton.getPreferredSize().width; + if (backButton.getPreferredSize().width > buttonSize) + buttonSize = backButton.getPreferredSize().width; + if (saveButton.getPreferredSize().width > buttonSize) + buttonSize = saveButton.getPreferredSize().width; + + GroupLayout headerPanelLayout = new GroupLayout(headerPanel); headerPanel.setLayout(headerPanelLayout); headerPanelLayout.setHorizontalGroup( - headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(titleLabel, GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)); + headerPanelLayout.createSequentialGroup() +// headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); headerPanelLayout.setVerticalGroup( - headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(titleLabel)); + headerPanelLayout.createSequentialGroup() +// headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); // mainPanel.setPreferredSize(new Dimension(MAIN_PANEL_WIDTH, MAIN_PANEL_HEIGHT)); GroupLayout contentPanelLayout = new GroupLayout(contentPanel); contentPanel.setLayout(contentPanelLayout); contentPanelLayout.setHorizontalGroup( - contentPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(contentPanelLayout.createSequentialGroup().addContainerGap().addGroup(contentPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(headerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(mainPanel, GroupLayout.DEFAULT_SIZE, MAIN_PANEL_WIDTH, Short.MAX_VALUE).addComponent(buttonPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))); + contentPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(headerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(mainPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); //)); contentPanelLayout.setVerticalGroup( - contentPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(contentPanelLayout.createSequentialGroup().addContainerGap().addComponent(headerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(mainPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) //79, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(buttonPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addContainerGap())); + contentPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(headerPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(mainPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) //, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap()); //); } @Override @@ -229,9 +292,13 @@ public class BKUGUI implements BKUGUIFacade { mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(waitMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); + mainPanelLayout.createSequentialGroup() +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(waitMsgLabel) + .addContainerGap()); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(waitMsgLabel)); + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(waitMsgLabel)); contentPanel.validate(); } @@ -257,9 +324,14 @@ public class BKUGUI implements BKUGUIFacade { mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(waitMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); + mainPanelLayout.createSequentialGroup() +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(waitMsgLabel) + .addContainerGap()); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(waitMsgLabel)); + mainPanelLayout.createSequentialGroup() +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(waitMsgLabel)); contentPanel.validate(); @@ -276,21 +348,25 @@ public class BKUGUI implements BKUGUIFacade { buttonPanel.removeAll(); titleLabel.setText(messages.getString(TITLE_INSERTCARD)); -// titleLabel.setForeground(defaultForground); - JButton cancelButton = new JButton(); - cancelButton.setFont(cancelButton.getFont()); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); cancelButton.addActionListener(cancelListener); cancelButton.setActionCommand(cancelCommand); GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); +// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(cancelButton).addContainerGap())); + buttonPanelLayout.createSequentialGroup() +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addContainerGap()); //); buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(cancelButton)); + buttonPanelLayout.createSequentialGroup() +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(cancelButton)); contentPanel.validate(); } @@ -308,12 +384,6 @@ public class BKUGUI implements BKUGUIFacade { titleLabel.setText(messages.getString(TITLE_CARD_NOT_SUPPORTED)); // titleLabel.setForeground(defaultForground); - JButton cancelButton = new JButton(); - cancelButton.setFont(cancelButton.getFont()); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); - cancelButton.addActionListener(cancelListener); - cancelButton.setActionCommand(cancelCommand); - JLabel errorMsgLabel = new JLabel(); errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); errorMsgLabel.setText(messages.getString(MESSAGE_INSERTCARD)); @@ -322,19 +392,33 @@ public class BKUGUI implements BKUGUIFacade { mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); + mainPanelLayout.createSequentialGroup() +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorMsgLabel)); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel)); + mainPanelLayout.createSequentialGroup() +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorMsgLabel)); + cancelButton.addActionListener(cancelListener); + cancelButton.setActionCommand(cancelCommand); GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); +// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(cancelButton).addContainerGap())); + buttonPanelLayout.createSequentialGroup() +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addContainerGap()); //); buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(cancelButton)); - + buttonPanelLayout.createSequentialGroup() +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(cancelButton)); + contentPanel.validate(); } }); @@ -355,16 +439,10 @@ public class BKUGUI implements BKUGUIFacade { titleLabel.setText(messages.getString(TITLE_RETRY)); } - JButton cancelButton = new JButton(); - cancelButton.setFont(cancelButton.getFont()); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); cancelButton.setActionCommand(cancelCommand); cancelButton.addActionListener(cancelListener); - JButton okButton = new JButton(); okButton.setEnabled(false); - okButton.setFont(okButton.getFont()); - okButton.setText(messages.getString(BUTTON_OK)); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); @@ -402,37 +480,77 @@ public class BKUGUI implements BKUGUIFacade { infoLabel.setForeground(ERROR_COLOR); } +// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); +// mainPanel.setLayout(mainPanelLayout); +// +// mainPanelLayout.setHorizontalGroup( +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(mainPanelLayout.createSequentialGroup() // .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// // .addComponent(hashDataLabel) +// // .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() +// .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) //RELATED) +// .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) //TRAILING) +// .addComponent(infoLabel) //, GroupLayout.DEFAULT_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE) +// .addComponent(pinField, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)) //)) +// .addContainerGap())); +// +// mainPanelLayout.setVerticalGroup( +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addContainerGap() // .addComponent(hashDataLabel).addGap(14, 14, 14) +// .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) //, false) +// .addComponent(cardPinLabel) //, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) +// .addComponent(pinField)) //, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) +// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(infoLabel).addGap(cardPinLabel.getFont().getSize()))); //10, 10, 10))); +// +// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); +// buttonPanel.setLayout(buttonPanelLayout); +// +// buttonPanelLayout.setHorizontalGroup( +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE).addComponent(okButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton).addContainerGap())); +// buttonPanelLayout.setVerticalGroup( +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(okButton).addComponent(cancelButton))); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); -// GroupLayout.ParallelGroup mainGroup = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); -// mainGroup.addComponent(pinSizeLabel) //, GroupLayout.DEFAULT_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE) -// .addComponent(pinField, GroupLayout.DEFAULT_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE); - mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup() // .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - // .addComponent(hashDataLabel) - // .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() - .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) //RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) //TRAILING) - .addComponent(infoLabel) //, GroupLayout.DEFAULT_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE) - .addComponent(pinField, GroupLayout.DEFAULT_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE)) //)) - .addContainerGap())); + mainPanelLayout.createSequentialGroup() +// .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addComponent(hashDataLabel) +// .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addComponent(cardPinLabel, 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(infoLabel)) + .addContainerGap()); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addContainerGap() // .addComponent(hashDataLabel).addGap(14, 14, 14) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) //, false) - .addComponent(cardPinLabel) //, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) - .addComponent(pinField)) //, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(infoLabel).addGap(cardPinLabel.getFont().getSize()))); //10, 10, 10))); + mainPanelLayout.createSequentialGroup() +// .addComponent(hashDataLabel) +// .addGap(hashDataLabel.getFont().getSize()) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(cardPinLabel) + .addComponent(pinField)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(infoLabel)); +// .addGap(signPinLabel.getFont().getSize())); GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); +// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE).addComponent(okButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton).addContainerGap())); + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addContainerGap());//); buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(okButton).addComponent(cancelButton))); + buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(okButton) + .addComponent(cancelButton)); pinField.requestFocusInWindow(); contentPanel.validate(); @@ -474,16 +592,10 @@ public class BKUGUI implements BKUGUIFacade { titleLabel.setText(messages.getString(TITLE_RETRY)); } - JButton cancelButton = new JButton(); - cancelButton.setFont(cancelButton.getFont()); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); cancelButton.setActionCommand(cancelCommand); cancelButton.addActionListener(cancelListener); - JButton signButton = new JButton(); signButton.setEnabled(false); - signButton.setFont(signButton.getFont()); - signButton.setText(messages.getString(BUTTON_SIGN)); signButton.setActionCommand(signCommand); signButton.addActionListener(signListener); @@ -539,22 +651,43 @@ public class BKUGUI implements BKUGUIFacade { mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(hashDataLabel).addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup().addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(infoLabel) //, GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE) - .addComponent(pinField, GroupLayout.DEFAULT_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE)))).addContainerGap())); + mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(hashDataLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .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(infoLabel)))) + .addContainerGap()); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addComponent(hashDataLabel).addGap(hashDataLabel.getFont().getSize()) //14, 14, 14) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE, false).addComponent(signPinLabel) //, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) - .addComponent(pinField)) //, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(infoLabel).addGap(signPinLabel.getFont().getSize()))); //10, 10, 10))); + mainPanelLayout.createSequentialGroup() + .addComponent(hashDataLabel) + .addGap(hashDataLabel.getFont().getSize()) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(signPinLabel) + .addComponent(pinField)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(infoLabel)); +// .addGap(signPinLabel.getFont().getSize())); GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); +// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE).addComponent(signButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton).addContainerGap())); + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addContainerGap());//); buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(signButton).addComponent(cancelButton))); + buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(signButton) + .addComponent(cancelButton)); pinField.requestFocusInWindow(); contentPanel.validate(); @@ -625,23 +758,30 @@ public class BKUGUI implements BKUGUIFacade { mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel)); + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorMsgLabel)); - JButton okButton = new JButton(); - okButton.setFont(okButton.getFont()); - okButton.setText(messages.getString(BUTTON_OK)); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); +// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(okButton).addContainerGap())); + buttonPanelLayout.createSequentialGroup() +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addContainerGap()); //); buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(okButton)); + buttonPanelLayout.createSequentialGroup() +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(okButton)); contentPanel.validate(); } @@ -668,9 +808,13 @@ public class BKUGUI implements BKUGUIFacade { mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); + mainPanelLayout.createSequentialGroup() +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorMsgLabel) + .addContainerGap()); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel)); + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorMsgLabel)); contentPanel.validate(); } @@ -725,41 +869,26 @@ public class BKUGUI implements BKUGUIFacade { showSaveHashDataInputDialog(signedRef, okListener, okCommand); } - } else { - mainPanel.removeAll(); - buttonPanel.removeAll(); - - titleLabel.setText(messages.getString(TITLE_ERROR)); - // titleLabel.setForeground(defaultForground); + } else if (signedReferences != null && signedReferences.size() > 1) { + final HashDataTableModel tableModel = new HashDataTableModel(signedReferences); - JLabel errorMsgLabel = new JLabel(); - errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - errorMsgLabel.setText("HashDataInputDialog not supported yet."); - errorMsgLabel.setForeground(ERROR_COLOR); + ActionListener al = new ActionListener() { - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); - mainPanel.setLayout(mainPanelLayout); - - mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); - mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(errorMsgLabel)); - - JButton okButton = new JButton(); - okButton.setFont(okButton.getFont()); - okButton.setText(messages.getString(BUTTON_OK)); - okButton.setActionCommand(okCommand); - okButton.addActionListener(okListener); - - GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); - buttonPanel.setLayout(buttonPanelLayout); - - buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(okButton).addContainerGap())); - buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(okButton)); - - contentPanel.validate(); + @Override + public void actionPerformed(ActionEvent e) { + List selection = tableModel.getSelectedReferenceIds(); + StringBuilder sb = new StringBuilder("Not implemented yet. \n"); + for (String string : selection) { + sb.append(string); + sb.append('\n'); + } + showErrorDialog(sb.toString(), okListener, okCommand); +// showSaveHashDataInputDialog(signedRef, okListener, okCommand); + } + }; + showMultipleHashDataInputDialog(tableModel, okListener, okCommand, al, "save"); + } else { + showErrorDialog(messages.getString(ERROR_HASHDATA), okListener, okCommand); } } }); @@ -774,54 +903,193 @@ public class BKUGUI implements BKUGUIFacade { JLabel refIdLabel = new JLabel(); refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); String refIdLabelPattern = messages.getString(MESSAGE_HASHDATA); - refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[] {refId} )); + refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{refId})); JScrollPane hashDataScrollPane = new JScrollPane(); JTextArea hashDataTextArea = new JTextArea(text); hashDataTextArea.setEditable(false); - hashDataTextArea.setColumns(20); - hashDataTextArea.setRows(3); + hashDataTextArea.setColumns(1); + hashDataTextArea.setRows(1); hashDataScrollPane.setViewportView(hashDataTextArea); + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(refIdLabel) + .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()); + + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createSequentialGroup() + .addComponent(refIdLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(hashDataScrollPane, 0, GroupLayout.PREFERRED_SIZE, hashDataTextArea.getPreferredSize().height+3)); + - JButton cancelButton = new JButton(); - cancelButton.setFont(cancelButton.getFont()); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); - cancelButton.setActionCommand(cancelCommand); - cancelButton.addActionListener(cancelListener); + +// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); +// mainPanel.setLayout(mainPanelLayout); +// +// mainPanelLayout.setHorizontalGroup( +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(refIdLabel).addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE)).addContainerGap())); +// +// mainPanelLayout.setVerticalGroup( +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addComponent(refIdLabel).addGap(refIdLabel.getFont().getSize()).addComponent(hashDataScrollPane).addGap(refIdLabel.getFont().getSize()))); + + backButton.setActionCommand(cancelCommand); + backButton.addActionListener(cancelListener); - JButton saveButton = new JButton(); - saveButton.setFont(saveButton.getFont()); - saveButton.setText(messages.getString(BUTTON_SAVE)); saveButton.setActionCommand(saveCommand); saveButton.addActionListener(saveListener); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + +// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); + buttonPanelLayout.setHorizontalGroup( + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(saveButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addContainerGap()); + buttonPanelLayout.setVerticalGroup( + buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(saveButton) + .addComponent(backButton)); + + +// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); +// buttonPanel.setLayout(buttonPanelLayout); +// +// buttonPanelLayout.setHorizontalGroup( +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE).addComponent(saveButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton).addContainerGap())); +// buttonPanelLayout.setVerticalGroup( +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(saveButton).addComponent(cancelButton))); + + contentPanel.validate(); + } + + private void showMultipleHashDataInputDialog(final TableModel signedReferences, final ActionListener cancelListener, final String cancelCommand, ActionListener saveListener, String saveCommand) { + mainPanel.removeAll(); + buttonPanel.removeAll(); + + titleLabel.setText(messages.getString(TITLE_HASHDATA)); + JLabel refIdLabel = new JLabel(); + refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST); + refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.getRowCount()})); + + JTable hashDataTable = new JTable(); + hashDataTable.setModel(signedReferences); + hashDataTable.setTableHeader(null); +// hashDataTable.setShowVerticalLines(false); +// hashDataTable.setRowSelectionAllowed(false); + TableColumn selectCol = hashDataTable.getColumnModel().getColumn(1); + selectCol.setMinWidth(CHECKBOX_WIDTH); + selectCol.setMaxWidth(CHECKBOX_WIDTH); + + + hashDataTable.setPreferredScrollableViewportSize(mainPanel.getPreferredSize()); + + JScrollPane hashDataScrollPane = new JScrollPane(hashDataTable); + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(mainPanelLayout.createSequentialGroup() - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(refIdLabel) - .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE)) - .addContainerGap())); - + mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(refIdLabel) + .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()); + mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(mainPanelLayout.createSequentialGroup() - .addComponent(refIdLabel) - .addGap(refIdLabel.getFont().getSize()) - .addComponent(hashDataScrollPane) - .addGap(refIdLabel.getFont().getSize()))); - + mainPanelLayout.createSequentialGroup() + .addComponent(refIdLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(hashDataScrollPane, 0, GroupLayout.PREFERRED_SIZE, hashDataTable.getPreferredSize().height+3)); +// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)); + + + +// +// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); +// mainPanel.setLayout(mainPanelLayout); +// +// mainPanelLayout.setHorizontalGroup( +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(mainPanelLayout.createSequentialGroup() +// .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addComponent(refIdLabel) +// .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE)) +// .addContainerGap())); +// +// mainPanelLayout.setVerticalGroup( +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(mainPanelLayout.createSequentialGroup() +// .addComponent(refIdLabel) +// .addGap(refIdLabel.getFont().getSize()) +// .addComponent(hashDataScrollPane) +// .addGap(refIdLabel.getFont().getSize()))); + + + + + + + + + + + + +// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); +// buttonPanel.setLayout(buttonPanelLayout); +// +// buttonPanelLayout.setHorizontalGroup( +// buttonPanelLayout.createSequentialGroup() +//// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +//// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup() +// .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) +// .addComponent(saveButton) +// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) +// .addComponent(cancelButton) +// .addContainerGap()); //); +// buttonPanelLayout.setVerticalGroup( +// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup() +// .addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) +// .addComponent(saveButton) +// .addComponent(cancelButton)) +// .addContainerGap())); + + + backButton.setActionCommand(cancelCommand); + backButton.addActionListener(cancelListener); + + saveButton.setActionCommand(saveCommand); + saveButton.addActionListener(saveListener); + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); +// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton); buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE).addComponent(saveButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton).addContainerGap())); + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(saveButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + .addContainerGap());//); buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(saveButton).addComponent(cancelButton))); + buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(saveButton) + .addComponent(backButton)); contentPanel.validate(); } @@ -901,9 +1169,13 @@ public class BKUGUI implements BKUGUIFacade { mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(waitMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); + mainPanelLayout.createSequentialGroup() +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(waitMsgLabel) + .addContainerGap()); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); mainPanelLayout.setVerticalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(waitMsgLabel)); + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(waitMsgLabel)); contentPanel.validate(); } @@ -975,13 +1247,17 @@ public class BKUGUI implements BKUGUIFacade { String ext = getExtension(f); if ("text/xml".equals(mimeType)) { - return "xml".equals(ext); + return "xml".equalsIgnoreCase(ext); + } else if ("text/html".equals(mimeType)) { + return "html".equalsIgnoreCase(ext) || "htm".equalsIgnoreCase(ext); + } else if ("application/xhtml+xml".equals(mimeType)) { + return "xhtml".equalsIgnoreCase(ext); } else if ("text/plain".equals(mimeType)) { - return "txt".equals(ext); + return "txt".equalsIgnoreCase(ext); } else if ("application/pdf".equals(mimeType)) { - return "pdf".equals(ext); + return "pdf".equalsIgnoreCase(ext); } else { - return "bin".equals(ext); + return true; } } @@ -1000,6 +1276,10 @@ public class BKUGUI implements BKUGUIFacade { public String getDescription() { if ("text/xml".equals(mimeType)) { return messages.getString(MIMETYPE_DESC_XML); + } else if ("text/html".equals(mimeType)) { + return messages.getString(MIMETYPE_DESC_HTML); + } else if ("application/xhtml+xml".equals(mimeType)) { + return messages.getString(MIMETYPE_DESC_XHTML); } else if ("text/plain".equals(mimeType)) { return messages.getString(MIMETYPE_DESC_TXT); } else if ("application/pdf".equals(mimeType)) { @@ -1012,6 +1292,10 @@ public class BKUGUI implements BKUGUIFacade { public String getExtension() { if ("text/xml".equals(mimeType)) { return ".xml"; + } else if ("text/html".equals(mimeType)) { + return ".html"; + } else if ("application/xhtml+xml".equals(mimeType)) { + return ".xhtml"; } else if ("text/plain".equals(mimeType)) { return ".txt"; } else if ("application/pdf".equals(mimeType)) { @@ -1021,4 +1305,34 @@ public class BKUGUI implements BKUGUIFacade { } } } + + class HashDataTableModel extends DefaultTableModel { + + Class[] types = new Class[]{ + java.lang.String.class, java.lang.Boolean.class + }; + + public HashDataTableModel(List signedReferences) { + super(0, 2); + for (HashDataInput hashDataInput : signedReferences) { + addRow(new Object[]{hashDataInput.getReferenceId(), new Boolean(true)}); + } + } + + @Override + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } + + public List getSelectedReferenceIds() { + ArrayList selection = new ArrayList(); + for (Object row : dataVector) { + if ((Boolean) ((Vector) row).elementAt(1)) { + selection.add((String) ((Vector) row).elementAt(0)); + } + } + return selection; + } + + } } 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 21a6bd1b..b651fa8d 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 @@ -25,18 +25,24 @@ title.hashdata=Signaturdaten windowtitle.save=Signaturdaten speichern windowtitle.overwrite=Datei \u00FCberschreiben? message.wait=Bitte warten... -message.insertcard=Bitte B\u00FCrgerkarte in den Kartenleser stecken. +message.insertcard=Bitte B\u00FCrgerkarte in den Kartenleser stecken message.hashdatalink=Signaturdaten anzeigen... -message.hashdata=Referenz Id: {0} +message.hashdata=Ein textuelles Signaturdatenobjekt: +#message.hashdata=Referenz Id: {0} +message.hashdatalist={0} Signaturdatenobjekte: message.retries=Noch {0} Versuche message.overwrite=M\u00F6chten Sie das existierende Dokument {0} \u00FCberschreiben? label.pin={0}: label.pinsize=({0} stellig) +error.hashdata=Keine Signaturdaten verf\u00FCgbar button.ok=OK button.cancel=Abbrechen +button.back=Zur\u00FCck button.sign=Signieren button.save=Speichern... mimetype.desc.xml=XML-Dateien (*.xml) +mimetype.desc.html=HTML-Dateien (*.html, *.htm) +mimetype.desc.xhtml=XHTML-Dateien (*.xhtml) mimetype.desc.txt=Textdateien (*.txt) mimetype.desc.pdf=Adobe PDF-Dateien (*.pdf) mimetype.desc.bin=Bin\u00E4rdateien (*.bin) diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java index 4dc1f8b3..a9c21a00 100644 --- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java +++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java @@ -21,6 +21,8 @@ package at.gv.egiz.bku.gui; +import java.awt.Container; +import java.awt.Dimension; import javax.swing.JFrame; import org.junit.Ignore; import org.junit.Test; @@ -36,7 +38,9 @@ public class BKUGUITest { public void testBKUGUI() { JFrame testFrame = new JFrame("BKUGUITest"); BKUGUI gui = new BKUGUI(); - gui.init(testFrame.getContentPane(), null); + Container contentPane = testFrame.getContentPane(); + contentPane.setPreferredSize(new Dimension(500, 200)); + gui.init(contentPane, null); BKUGUIWorker worker = new BKUGUIWorker(); worker.init(gui); testFrame.pack(); @@ -50,4 +54,8 @@ public class BKUGUITest { @Test public void dummyTest() { } + +// public static void main(String[] args) { +// new BKUGUITest().testBKUGUI(); +// } } diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java index e2f478c9..4367f642 100644 --- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java +++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java @@ -26,7 +26,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.Collections; +import java.util.ArrayList; +import java.util.List; /** * @@ -42,7 +43,7 @@ public class BKUGUIWorker implements Runnable { @Override public void run() { - try { +// try { final PINSpec signPinSpec = new PINSpec(6, 10, "[0-9]", "Signatur-PIN"); @@ -77,11 +78,11 @@ public class BKUGUIWorker implements Runnable { gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", null, "hashdata"); } }; - HashDataInput signedRef = new HashDataInput() { + HashDataInput signedRef1 = new HashDataInput() { @Override public InputStream getHashDataInput() { - return new ByteArrayInputStream("HashDataInput_002".getBytes()); + return new ByteArrayInputStream("HashDataInput_001\n12345\n\tHello, world!\n12345\n\n12345\n6789\nblabla".getBytes()); } @Override @@ -91,10 +92,69 @@ public class BKUGUIWorker implements Runnable { @Override public String getReferenceId() { - return "ref123"; + return "Reference-ref1-00000000000000000000001"; } }; - gui.showHashDataInputDialog(Collections.singletonList(signedRef), returnListener, "return"); + HashDataInput signedRef2 = new HashDataInput() { + + @Override + public InputStream getHashDataInput() { + return new ByteArrayInputStream("HashDataInput_002".getBytes()); + } + + @Override + public String getMimeType() { + return "text/xml"; + } + + @Override + public String getReferenceId() { + return "Reference-ref2-00000000000000000000002"; + } + }; + HashDataInput signedRef3 = new HashDataInput() { + + @Override + public InputStream getHashDataInput() { + return new ByteArrayInputStream("HashDataInput_003".getBytes()); + } + + @Override + public String getMimeType() { + return "text/xml"; + } + + @Override + public String getReferenceId() { + return "Reference-ref3-00000000000000000000003"; + } + }; + HashDataInput signedRef4 = new HashDataInput() { + + @Override + public InputStream getHashDataInput() { + return new ByteArrayInputStream("HashDataInput_004".getBytes()); + } + + @Override + public String getMimeType() { + return "text/xml"; + } + + @Override + public String getReferenceId() { + return "ref4"; + } + }; + + // + List signedRefs = new ArrayList(); + signedRefs.add(signedRef1); + signedRefs.add(signedRef2); + signedRefs.add(signedRef3); + signedRefs.add(signedRef4); +// signedRefs = Collections.singletonList(signedRef1); + gui.showHashDataInputDialog(signedRefs, returnListener, "return"); } }; @@ -105,7 +165,7 @@ public class BKUGUIWorker implements Runnable { // Thread.sleep(2000); // gui.showInsertCardDialog(cancelListener, "cancel"); -// + // Thread.sleep(2000); // // gui.showCardNotSupportedDialog(cancelListener, "cancel"); @@ -113,7 +173,7 @@ public class BKUGUIWorker implements Runnable { // Thread.sleep(2000); // PINSpec cardPinSpec = new PINSpec(4, 4, "[0-9]", "Karten-PIN"); -// +//// // gui.showCardPINDialog(cardPinSpec, okListener, "ok", cancelListener, "cancel"); // // Thread.sleep(2000); @@ -121,11 +181,11 @@ public class BKUGUIWorker implements Runnable { gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata"); - Thread.sleep(2000); +// Thread.sleep(2000); - gui.showSignaturePINRetryDialog(signPinSpec, 2, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata"); - - Thread.sleep(2000); +// gui.showSignaturePINRetryDialog(signPinSpec, 2, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata"); +// +// Thread.sleep(2000); //// // gui.showErrorDialog("Testfehler occured", null, null); // @@ -137,8 +197,8 @@ public class BKUGUIWorker implements Runnable { // gui.showTextPlainHashDataInput("hallo,\n welt!", "12345", null, "cancel", null, "save"); // Thread.sleep(2000); - } catch (InterruptedException ex) { - ex.printStackTrace(); - } +// } catch (InterruptedException ex) { +// ex.printStackTrace(); +// } } } diff --git a/BKUCommonGUI/src/test/resources/commons-logging.properties b/BKUCommonGUI/src/test/resources/commons-logging.properties new file mode 100644 index 00000000..29292562 --- /dev/null +++ b/BKUCommonGUI/src/test/resources/commons-logging.properties @@ -0,0 +1 @@ +org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger diff --git a/BKUCommonGUI/src/test/resources/log4j.properties b/BKUCommonGUI/src/test/resources/log4j.properties new file mode 100644 index 00000000..053eac17 --- /dev/null +++ b/BKUCommonGUI/src/test/resources/log4j.properties @@ -0,0 +1,19 @@ +# loglever DEBUG, appender STDOUT +log4j.rootLogger=TRACE, STDOUT +#log4j.logger.at.gv.egiz.slbinding.RedirectEventFilter=DEBUG, STDOUT + +# STDOUT appender +log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender +log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout +#log4j.appender.STDOUT.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n +#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n +log4j.appender.STDOUT.layout.ConversionPattern=%-5p |%d | %t | %c %x- %m%n + +### FILE appender +#log4j.appender.file=org.apache.log4j.RollingFileAppender +#log4j.appender.file.maxFileSize=100KB +#log4j.appender.file.maxBackupIndex=9 +#log4j.appender.file.File=egovbus_ca.log +#log4j.appender.file.threshold=info +#log4j.appender.file.layout=org.apache.log4j.PatternLayout +#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n \ No newline at end of file -- cgit v1.2.3