diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-11-13 18:24:57 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-11-13 18:24:57 +0000 |
commit | 9662ac90b6aa84bc54543d3c8670ba6c8e42bbac (patch) | |
tree | 4b47426d3cf67ff9deee1e741fa9740b54b988fc /BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui | |
parent | 35356a68fcecb6492a90f7cd01ff846f2393fdaa (diff) | |
download | mocca-9662ac90b6aa84bc54543d3c8670ba6c8e42bbac.tar.gz mocca-9662ac90b6aa84bc54543d3c8670ba6c8e42bbac.tar.bz2 mocca-9662ac90b6aa84bc54543d3c8670ba6c8e42bbac.zip |
FRAME HashDataDisplay
FRAME Help
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@165 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui')
8 files changed, 626 insertions, 400 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java index a249a376..f46f5227 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package at.gv.egiz.bku.gui; import java.awt.event.ActionEvent; @@ -22,19 +21,24 @@ import java.awt.event.ActionListener; import java.net.MalformedURLException; import java.net.URL; import java.util.Locale; +import java.util.ResourceBundle; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * + * Implement the showDocument(URL) method to provide an actual HelpListener. + * This class does not keep a GUI reference and subclasses should not interfere with the GUI. + * Therefore, any errors occurring in showDocument() should be handled/displayed within + * showDocument() and exceptions thrown from showDocument() are logged, not displayed in the GUI. + * * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> */ public abstract class AbstractHelpListener implements ActionListener { protected final static Log log = LogFactory.getLog(AbstractHelpListener.class); -// protected String helpURLBase; protected URL baseURL; protected Locale locale; + protected ResourceBundle messages; public AbstractHelpListener(URL baseURL, Locale locale) { if (baseURL == null || "".equals(baseURL)) { @@ -42,6 +46,11 @@ public abstract class AbstractHelpListener implements ActionListener { } this.baseURL = baseURL; this.locale = locale; + if (locale != null) { + messages = ResourceBundle.getBundle(BKUGUIFacade.MESSAGES_BUNDLE, locale); + } else { + messages = ResourceBundle.getBundle(BKUGUIFacade.MESSAGES_BUNDLE); + } } @Override @@ -49,30 +58,36 @@ public abstract class AbstractHelpListener implements ActionListener { log.debug("received help action: " + e.getActionCommand()); URL helpURL = constructHelpURL(baseURL, e.getActionCommand()); try { - showDocument(helpURL); + showDocument(helpURL, e.getActionCommand()); } catch (Exception ex) { log.error("could not display help document " + helpURL + ": " + ex.getMessage()); } } - - private URL constructHelpURL(URL baseURL, String helpItem) { + + private URL constructHelpURL(URL baseURL, String helpTopic) { URL helpURL = baseURL; log.trace("constructing help URL: " + helpURL); try { if (locale != null) { helpURL = new URL(helpURL, locale.toString() + "/"); log.trace("constructing help URL: " + helpURL); - } - if (helpItem != null && !"".equals(helpItem)) { - helpURL = new URL(helpURL, helpItem + ".html"); + } + if (helpTopic != null && !"".equals(helpTopic)) { + helpURL = new URL(helpURL, helpTopic + ".html"); log.trace("constructing help URL: " + helpURL); } } catch (MalformedURLException ex) { - log.error("Failed to construct help URL for help item " + helpItem + ": " + ex.getMessage()); + log.error("Failed to construct help URL for help item " + helpTopic + ": " + ex.getMessage()); } return helpURL; } - - public abstract void showDocument(URL helpDocument) throws Exception; - + + /** + * Errors from HelpListeners should not (are not) displayed in the applet, + * but should rather be in the HelpListener specific way. + * Therefore, implementations SHOULD NOT throw exceptions (these are only logged). + * @param helpDocument + * @throws java.lang.Exception + */ + public abstract void showDocument(URL helpDocument, String helpTopic) throws Exception; } 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 38638b5d..2daf3300 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 @@ -1,20 +1,19 @@ /* -* Copyright 2008 Federal Chancellery Austria and -* Graz University of Technology -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package at.gv.egiz.bku.gui; import at.gv.egiz.stal.HashDataInput; @@ -27,7 +26,7 @@ import java.util.List; import java.util.Locale; public interface BKUGUIFacade { - + public static final String ERR_UNKNOWN = "error.unknown"; public static final String ERR_SERVICE_UNREACHABLE = "error.ws.unreachable"; public static final String ERR_NO_PCSC = "error.pcsc"; @@ -38,92 +37,108 @@ public interface BKUGUIFacade { public static final String ERR_INVALID_HASH = "error.invalid.hash"; public static final String ERR_CARD_LOCKED = "error.card.locked"; public static final String ERR_CARD_NOTACTIVATED = "error.card.notactivated"; + public static final String ERR_VIEWER = "error.viewer"; - public static final String MESSAGES_BUNDLE = "at/gv/egiz/bku/gui/Messages"; - public static final String DEFAULT_BACKGROUND = "/images/BackgroundChipperling.png"; - public static final String HELP_IMG = "/images/help.png"; - public static final String HASHDATA_FONT = "Monospaced"; - public static final Color ERROR_COLOR = Color.RED; - public static final Color HYPERLINK_COLOR = Color.BLUE; - public static final String TITLE_WELCOME = "title.welcome"; - public static final String TITLE_INSERTCARD = "title.insertcard"; - public static final String TITLE_CARD_NOT_SUPPORTED = "title.cardnotsupported"; - public static final String TITLE_CARDPIN = "title.cardpin"; - public static final String TITLE_SIGN = "title.sign"; - public static final String TITLE_ERROR = "title.error"; - public static final String TITLE_RETRY = "title.retry"; - public static final String TITLE_WAIT = "title.wait"; - public static final String TITLE_HASHDATA = "title.hashdata"; - public static final String WINDOWTITLE_SAVE = "windowtitle.save"; - public static final String WINDOWTITLE_SAVEDIR = "windowtitle.savedir"; - public static final String WINDOWTITLE_OVERWRITE = "windowtitle.overwrite"; - public static final String WINDOWTITLE_VIEWER = "windowtitle.viewer"; - public static final String MESSAGE_WAIT = "message.wait"; - public static final String MESSAGE_INSERTCARD = "message.insertcard"; - public static final String MESSAGE_ENTERPIN = "message.enterpin"; - public static final String MESSAGE_HASHDATALINK = "message.hashdatalink"; - public static final String MESSAGE_HASHDATA = "message.hashdata"; - public static final String MESSAGE_HASHDATALIST = "message.hashdatalist"; - public static final String MESSAGE_RETRIES = "message.retries"; - public static final String MESSAGE_OVERWRITE = "message.overwrite"; - public static final String LABEL_PIN = "label.pin"; - public static final String LABEL_PINSIZE = "label.pinsize"; + public static final String MESSAGES_BUNDLE = "at/gv/egiz/bku/gui/Messages"; + public static final String DEFAULT_BACKGROUND = "/images/BackgroundChipperling.png"; + public static final String HELP_IMG = "/images/help.png"; + public static final String HASHDATA_FONT = "Monospaced"; + public static final Color ERROR_COLOR = Color.RED; + public static final Color HYPERLINK_COLOR = Color.BLUE; + public static final String TITLE_WELCOME = "title.welcome"; + public static final String TITLE_INSERTCARD = "title.insertcard"; + public static final String TITLE_CARD_NOT_SUPPORTED = "title.cardnotsupported"; + public static final String TITLE_CARDPIN = "title.cardpin"; + public static final String TITLE_SIGN = "title.sign"; + public static final String TITLE_ERROR = "title.error"; + public static final String TITLE_RETRY = "title.retry"; + public static final String TITLE_WAIT = "title.wait"; + public static final String TITLE_HASHDATA = "title.hashdata"; + public static final String WINDOWTITLE_SAVE = "windowtitle.save"; + public static final String WINDOWTITLE_SAVEDIR = "windowtitle.savedir"; + public static final String WINDOWTITLE_OVERWRITE = "windowtitle.overwrite"; + public static final String WINDOWTITLE_VIEWER = "windowtitle.viewer"; + public static final String WINDOWTITLE_HELP = "windowtitle.help"; + public static final String MESSAGE_WAIT = "message.wait"; + public static final String MESSAGE_INSERTCARD = "message.insertcard"; + public static final String MESSAGE_ENTERPIN = "message.enterpin"; + public static final String MESSAGE_HASHDATALINK = "message.hashdatalink"; + public static final String MESSAGE_HASHDATA = "message.hashdata"; + public static final String MESSAGE_HASHDATALIST = "message.hashdatalist"; + public static final String MESSAGE_RETRIES = "message.retries"; + public static final String MESSAGE_OVERWRITE = "message.overwrite"; + public static final String MESSAGE_HELP = "message.help"; + public static final String LABEL_PIN = "label.pin"; + public static final String LABEL_PINSIZE = "label.pinsize"; // public static final String ERROR_NO_HASHDATA = "error.no.hashdata"; - public static final String HELP_WELCOME = "help.welcome"; - public static final String HELP_WAIT = "help.wait"; - public static final String HELP_CARDNOTSUPPORTED = "help.cardnotsupported"; - public static final String HELP_INSERTCARD = "help.insertcard"; - public static final String HELP_CARDPIN = "help.cardpin"; - public static final String HELP_SIGNPIN = "help.signpin"; - public static final String HELP_RETRY = "help.retry"; - public static final String HELP_HASHDATA = "help.hashdata"; - public static final String HELP_HASHDATALIST = "help.hashdatalist"; - public static final String HELP_HASHDATAVIEWER = "help.hashdataviewer"; - - public static final String BUTTON_OK = "button.ok"; - public static final String BUTTON_CANCEL = "button.cancel"; - public static final String BUTTON_BACK = "button.back"; - public static final String BUTTON_SIGN = "button.sign"; - public static final String BUTTON_SAVE = "button.save"; - public static final String BUTTON_CLOSE = "button.close"; - public static final String SAVE_HASHDATAINPUT_PREFIX = "save.hashdatainput.prefix"; - - - public void init(Container contentPane, Locale locale, URL background, ActionListener helpListener); - - /** - * - * @return the locale of the message bundle (what if no message bundle could be loaded for the requested locale?) - */ - public Locale getLocale(); - - public void showWelcomeDialog(); - - /** - * - * @param waitMessage if null, a simple 'wait' text is displayed - */ - public void showWaitDialog(String waitMessage); - - public void showInsertCardDialog(ActionListener cancelListener, String actionCommand); - - public void showCardNotSupportedDialog(ActionListener cancelListener, String actionCommand); - - public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand); - - public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand); - - public void showSignaturePINDialog(PINSpec pinSpec, ActionListener signListener, String signCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand); - - public void showSignaturePINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand); - - public char[] getPin(); - - public void showHashDataInputDialog(List<HashDataInput> signedReferences, boolean standalone, ActionListener okListener, String actionCommand); - + public static final String HELP_WELCOME = "help.welcome"; + public static final String HELP_WAIT = "help.wait"; + public static final String HELP_CARDNOTSUPPORTED = "help.cardnotsupported"; + public static final String HELP_INSERTCARD = "help.insertcard"; + public static final String HELP_CARDPIN = "help.cardpin"; + public static final String HELP_SIGNPIN = "help.signpin"; + public static final String HELP_RETRY = "help.retry"; + public static final String HELP_HASHDATA = "help.hashdata"; + public static final String HELP_HASHDATALIST = "help.hashdatalist"; + public static final String HELP_HASHDATAVIEWER = "help.hashdataviewer"; + public static final String BUTTON_OK = "button.ok"; + public static final String BUTTON_CANCEL = "button.cancel"; + public static final String BUTTON_BACK = "button.back"; + public static final String BUTTON_SIGN = "button.sign"; + public static final String BUTTON_SAVE = "button.save"; + public static final String BUTTON_CLOSE = "button.close"; + public static final String SAVE_HASHDATAINPUT_PREFIX = "save.hashdatainput.prefix"; + + public void init(Container contentPane, Locale locale, URL background, ActionListener helpListener); + + /** + * + * @return the locale of the message bundle (what if no message bundle could be loaded for the requested locale?) + */ + public Locale getLocale(); + + public void showWelcomeDialog(); + + /** + * + * @param waitMessage if null, a simple 'wait' text is displayed + */ + public void showWaitDialog(String waitMessage); + + public void showInsertCardDialog(ActionListener cancelListener, String actionCommand); + + public void showCardNotSupportedDialog(ActionListener cancelListener, String actionCommand); + + public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand); + + public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand); + + public void showSignaturePINDialog(PINSpec pinSpec, ActionListener signListener, String signCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand); + + public void showSignaturePINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand); + + public char[] getPin(); + + /** + * TODO move to HashDataDisplay implementations + * @param signedReferences + * @param externalDisplay + * @param okListener + * @param okCommand + */ + public void showHashDataInputDialog(List<HashDataInput> signedReferences, boolean externalDisplay, ActionListener okListener, String okCommand); + + /** + * TODO pull out from BKUGUIFacade. (or make this strictly an applet internal version) + * Problem: if standalone flag is provided, we also need the actionlistener.. + * @param helpDocument + * @param mimeType + * @param encoding + */ +// public void showHelpDialog(InputStream helpDocument, String mimeType, String encoding); //, boolean standalone); //, ActionListener okListener, String okCommand); + // public void showPlainTextHashDataInputDialog(String text, ActionListener saveListener, String saveCommand, ActionListener cancelListener, String cancelCommand); - - public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams, ActionListener okListener, String actionCommand); - - public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams); + public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams, ActionListener okListener, String actionCommand); + + public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams); } diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java index aea85523..e8566fa6 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java @@ -64,13 +64,5 @@ class HashDataTableModel extends DefaultTableModel { } } return selection; - }// public List<String> getSelectedReferenceIds() { -// ArrayList<String> selection = new ArrayList<String>(); -// for (Object row : dataVector) { -// if ((Boolean) ((Vector) row).elementAt(1)) { -// selection.add((String) ((Vector) row).elementAt(0)); -// } -// } -// return selection; -// } + } }
\ No newline at end of file diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java deleted file mode 100644 index 3db06e19..00000000 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright 2008 Federal Chancellery Austria and - * Graz University of Technology - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package at.gv.egiz.bku.gui; - -import at.gv.egiz.stal.HashDataInput; -import java.awt.Component; -import java.awt.Container; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.io.InputStreamReader; -import java.io.Reader; -import java.text.MessageFormat; -import java.util.List; -import java.util.ResourceBundle; -import javax.swing.GroupLayout; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.LayoutStyle; -import javax.swing.text.Document; -import javax.swing.text.EditorKit; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * - * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> - */ -public class HashDataViewer extends JDialog - implements ActionListener, WindowListener { - - public static final String PLAINTEXT_FONT = "Monospaced"; - - protected static final Log log = LogFactory.getLog(HashDataViewer.class); - private static HashDataViewer dialog; - - public static void showDialog(Component frameComp, List<HashDataInput> signedReferences, ResourceBundle messages, ActionListener saveListener, String saveCommand, HelpMouseListener helpListener) { - - log.info("******************* SHOW HASHDATA DIALOG"); - - Frame frame = JOptionPane.getFrameForComponent(frameComp); - - dialog = new HashDataViewer(frame, signedReferences.get(0), messages, saveListener, saveCommand, helpListener); - dialog.addWindowListener(dialog); - dialog.setVisible(true); - - } - - private HashDataViewer(Frame frame, HashDataInput hashData, ResourceBundle messages, ActionListener saveListener, String saveCommand, HelpMouseListener helpListener) { - super(frame, messages.getString(BKUGUIFacade.WINDOWTITLE_VIEWER), true); - - JPanel viewerPanel = createViewerPanel(messages, hashData, helpListener); - JPanel buttonPanel = createButtonPanel(messages, saveListener, saveCommand); - - - Container contentPane = getContentPane(); - contentPane.setPreferredSize(new Dimension(400, 300)); - - GroupLayout mainLayout = new GroupLayout(contentPane); - contentPane.setLayout(mainLayout); - - mainLayout.setHorizontalGroup( - mainLayout.createSequentialGroup() - .addContainerGap() - .addGroup( - mainLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(viewerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()); - mainLayout.setVerticalGroup( - mainLayout.createSequentialGroup() - .addContainerGap() - .addComponent(viewerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addContainerGap()); - - pack(); - setLocationRelativeTo(frame); - } - - private JPanel createViewerPanel(ResourceBundle messages, HashDataInput hashData, HelpMouseListener helpListener) { - String mimeType = hashData.getMimeType(); - String encoding = hashData.getEncoding(); - - log.debug("display hashdata: " + mimeType + ";" + encoding); - - if (mimeType == null) { - mimeType = "text/plain"; - } - if (encoding == null) { - encoding = "UTF-8"; - } - - JEditorPane viewer = new JEditorPane(); - viewer.setEditable(false); - viewer.setContentType(mimeType); - if ("text/plain".equals(mimeType)) { - viewer.setFont(new Font(PLAINTEXT_FONT, viewer.getFont().getStyle(), viewer.getFont().getSize())); - } - - EditorKit editorKit = viewer.getEditorKit(); - Document document = editorKit.createDefaultDocument(); - - Reader reader; - try { - reader = new InputStreamReader(hashData.getHashDataInput(), encoding); - viewer.read(reader, document); - } catch (Exception ex) { - String p = messages.getString(BKUGUIFacade.ERR_DISPLAY_HASHDATA); - viewer.setText(MessageFormat.format(p, ex.getMessage())); - } - - JScrollPane scrollPane = new JScrollPane(viewer); -// scrollPane.setPreferredSize(new Dimension(400, 300)); - scrollPane.setPreferredSize(viewer.getPreferredSize()); - scrollPane.setAlignmentX(LEFT_ALIGNMENT); - - JLabel viewerTitle = new JLabel(); - viewerTitle.setText(messages.getString(BKUGUIFacade.TITLE_HASHDATA)); - viewerTitle.setFont(viewerTitle.getFont().deriveFont(viewerTitle.getFont().getStyle() | java.awt.Font.BOLD)); - viewerTitle.setLabelFor(viewer); - - JLabel helpLabel = new JLabel(); - helpListener.setHelpTopic(BKUGUIFacade.HELP_HASHDATAVIEWER); - helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG))); - helpLabel.addMouseListener(helpListener); - helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - - JPanel viewerPanel = new JPanel(); - GroupLayout viewerPanelLayout = new GroupLayout(viewerPanel); - viewerPanel.setLayout(viewerPanelLayout); - - viewerPanelLayout.setHorizontalGroup( - viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(viewerPanelLayout.createSequentialGroup() - .addComponent(viewerTitle) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel)) - .addComponent(scrollPane)); //, 0, 0, Short.MAX_VALUE)); - - viewerPanelLayout.setVerticalGroup( - viewerPanelLayout.createSequentialGroup() - .addGroup(viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(viewerTitle) - .addComponent(helpLabel)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(scrollPane)); //, 0, 0, Short.MAX_VALUE)); - -// viewerPanel.setLayout(new BoxLayout(viewerPanel, BoxLayout.PAGE_AXIS)); -// JLabel title = new JLabel(messages.getString(BKUGUIFacade.TITLE_HASHDATA)); -// title.setLabelFor(viewer); -// viewerPanel.add(title); -// viewerPanel.add(Box.createRigidArea(new Dimension(0, 5))); -// viewerPanel.add(scrollPane); -// viewerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - return viewerPanel; - } - - private JPanel createButtonPanel(ResourceBundle messages, ActionListener saveListener, String saveCommand) { - JButton closeButton = new JButton(); - closeButton.setText(messages.getString(BKUGUIFacade.BUTTON_CLOSE)); - closeButton.addActionListener(this); - - JButton saveButton = new JButton(); - saveButton.setText(messages.getString(BKUGUIFacade.BUTTON_SAVE)); - saveButton.setActionCommand(saveCommand); - saveButton.addActionListener(saveListener); - - int buttonSize = closeButton.getPreferredSize().width; - if (saveButton.getPreferredSize().width > buttonSize) { - buttonSize = saveButton.getPreferredSize().width; - } - - JPanel buttonPanel = new JPanel(); - GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); - buttonPanel.setLayout(buttonPanelLayout); - - 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(closeButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); - buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(saveButton).addComponent(closeButton)); - - return buttonPanel; - } - - @Override - public void actionPerformed(ActionEvent e) { -// if ("close".equals(e.getActionCommand())) { - HashDataViewer.dialog.setVisible(false); -// HashDataViewer.dialog.dispose(); - } - - @Override - public void windowOpened(WindowEvent e) { - log.debug("WINDOW OPENED"); - } - - @Override - public void windowClosing(WindowEvent e) { - log.debug("WINDOW CLOSING"); - } - - @Override - public void windowClosed(WindowEvent e) { - log.debug("WINDOW CLOSED"); - } - - @Override - public void windowIconified(WindowEvent e) { - log.debug("WINDOW ICONIFIED"); - } - - @Override - public void windowDeiconified(WindowEvent e) { - } - - @Override - public void windowActivated(WindowEvent e) { - log.debug("WINDOW ACTIVATED"); - } - - @Override - public void windowDeactivated(WindowEvent e) { - log.debug("WINDOW DEACTIVATED"); - } - - - - - - - -} diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperLinkRenderer.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperLinkRenderer.java new file mode 100644 index 00000000..d9606177 --- /dev/null +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperLinkRenderer.java @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package at.gv.egiz.bku.gui; + +import at.gv.egiz.stal.HashDataInput; +import java.awt.Color; +import java.awt.Component; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; + +/** + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> + */ +public class HyperLinkRenderer extends JLabel implements TableCellRenderer { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + HashDataInput hdi = (HashDataInput) value; + setText(hdi.getReferenceId() + " (" + hdi.getMimeType() + ")"); + setBackground(Color.CYAN); + return this; + } + +// extends DefaultTableCellRenderer { +// +// @Override +// public void setValue(Object value) { +// HashDataInput hdi = (HashDataInput) value; +// setText(hdi.getReferenceId() + " (" + hdi.getMimeType() + ")"); +// } +} 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 583dae0f..6250dd0e 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 @@ -83,7 +83,7 @@ public class SimpleGUI implements BKUGUIFacade { protected int buttonSize; - private static final int CHECKBOX_WIDTH = new JCheckBox().getPreferredSize().width; +// private static final int CHECKBOX_WIDTH = new JCheckBox().getPreferredSize().width; /** * @param contentPane @@ -924,16 +924,17 @@ public class SimpleGUI implements BKUGUIFacade { } } else { - final HashDataTableModel tableModel = new HashDataTableModel(signedReferences); - - ActionListener saveHashDataListener = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - showSaveHashDataInputDialog(tableModel.getSelectedHashData(), okListener, okCommand); - } - }; - showMultipleHashDataInputDialog(tableModel, okListener, okCommand, saveHashDataListener, "save"); + SimpleHashDataTableModel tableModel = new SimpleHashDataTableModel(signedReferences); +// final HashDataTableModel tableModel = new HashDataTableModel(signedReferences); +// +// ActionListener saveHashDataListener = new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// showSaveHashDataInputDialog(tableModel.getSelectedHashData(), okListener, okCommand); +// } +// }; + showMultipleHashDataInputDialog(tableModel, okListener, okCommand); } } @@ -953,7 +954,7 @@ public class SimpleGUI implements BKUGUIFacade { log.debug("show plaintext hashdatainput dialog"); - HashDataViewer.showDialog(contentPane, signedReferences, messages, saveListener, saveCommand, helpListener); + ViewerDialog.showHashDataInput(contentPane, signedReferences, messages, saveListener, saveCommand, helpListener); } }); } @@ -1052,7 +1053,8 @@ public class SimpleGUI implements BKUGUIFacade { }); } - private void showMultipleHashDataInputDialog(final TableModel signedReferences, final ActionListener cancelListener, final String cancelCommand, final ActionListener saveListener, final String saveCommand) { + private void showMultipleHashDataInputDialog(final TableModel signedReferences, final ActionListener cancelListener, final String cancelCommand) { +// , final ActionListener saveListener, final String saveCommand log.debug("scheduling multiple hashdatainput dialog"); @@ -1076,13 +1078,14 @@ public class SimpleGUI implements BKUGUIFacade { refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.getRowCount()})); JTable hashDataTable = new JTable(); + hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperLinkRenderer()); 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); +// TableColumn selectCol = hashDataTable.getColumnModel().getColumn(1); +// selectCol.setMinWidth(CHECKBOX_WIDTH); +// selectCol.setMaxWidth(CHECKBOX_WIDTH); // hashDataTable.setPreferredScrollableViewportSize(mainPanel.getPreferredSize()); diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleHashDataTableModel.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleHashDataTableModel.java new file mode 100644 index 00000000..463dbe81 --- /dev/null +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleHashDataTableModel.java @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package at.gv.egiz.bku.gui; + +import at.gv.egiz.stal.HashDataInput; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; +import javax.swing.table.DefaultTableModel; + +/** + * + * @author clemens + */ +class SimpleHashDataTableModel extends DefaultTableModel { + + protected List<HashDataInput> signedReferences; + + protected Class[] types = new Class[]{ + java.lang.String.class + }; + + public SimpleHashDataTableModel(List<HashDataInput> signedReferences) { + super(0, 1); + this.signedReferences = signedReferences; + for (HashDataInput hashDataInput : signedReferences) { + +// String desc = hashDataInput.getReferenceId() + " (" + hashDataInput.getMimeType() + ")"; + addRow(new Object[]{hashDataInput}); + } + } + + @Override + public Class getColumnClass(int columnIndex) { + return types[columnIndex]; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + if (columnIndex == 1) + return true; + return false; + } +}
\ No newline at end of file diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerDialog.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerDialog.java new file mode 100644 index 00000000..cd04ad98 --- /dev/null +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerDialog.java @@ -0,0 +1,354 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package at.gv.egiz.bku.gui; + +import at.gv.egiz.stal.HashDataInput; +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.text.MessageFormat; +import java.util.List; +import java.util.ResourceBundle; +import javax.swing.GroupLayout; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.LayoutStyle; +import javax.swing.text.Document; +import javax.swing.text.EditorKit; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLEditorKit; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> + */ +public class ViewerDialog extends JDialog + implements ActionListener { + + public static final String PLAINTEXT_FONT = "Monospaced"; + protected static final Log log = LogFactory.getLog(ViewerDialog.class); +// private ViewerDialog dialog; + + protected ResourceBundle messages; + + /** + * + * @param frameComp + * @param signedReferences currently, only one hashdata input (the first in the list) is displayed + * @param messages + * @param saveListener + * @param saveCommand + * @param helpListener + */ + public static void showHashDataInput(Component frameComp, + List<HashDataInput> hashDataInputs, + ResourceBundle messages, + ActionListener saveListener, + String saveCommand, + HelpMouseListener helpListener) { + + Frame frame = null; + if (frameComp != null) { + JOptionPane.getFrameForComponent(frameComp); + } + ViewerDialog viewer = new ViewerDialog(frame, + messages, + hashDataInputs, + saveListener, + saveCommand, + helpListener); + viewer.setVisible(true); + } + + public static void showHelp(Component frameComp, + String helpTopic, +// Reader helpDocument, + InputStream helpDocument, + String mimeType, + ResourceBundle messages) { + + Frame frame = null; + if (frameComp != null) { + JOptionPane.getFrameForComponent(frameComp); + } + ViewerDialog viewer = new ViewerDialog(frame, messages, helpTopic, helpDocument, mimeType); + viewer.setVisible(true); + } + + /** + * TODO make encoding aware! + * @param frame + * @param title + * @param messages + * @param hashDataInputs + * @param saveListener + * @param saveCommand + * @param helpListener + */ + private ViewerDialog(Frame frame, + ResourceBundle messages, + List<HashDataInput> hashDataInputs, + ActionListener saveListener, + String saveCommand, + HelpMouseListener helpListener) { + super(frame, messages.getString(BKUGUIFacade.WINDOWTITLE_VIEWER), true); + this.messages = messages; + + HashDataInput hashData = hashDataInputs.get(0); + +// Charset cs; +// if (hashData.getEncoding() == null) { +// cs = Charset.forName("UTF-8"); +// } else { +// try { +// cs = Charset.forName(hashData.getEncoding()); +// } catch (Exception ex) { +// log.debug("charset " + hashData.getEncoding() + " not supported, assuming UTF-8: " + ex.getMessage()); +// cs = Charset.forName("UTF-8"); +// } +// } + +// InputStreamReader isr = new InputStreamReader(hashData.getHashDataInput(), cs); +// Reader content = new BufferedReader(isr); + InputStream content = hashData.getHashDataInput(); + String mimeType = hashData.getMimeType(); + String encoding = hashData.getEncoding(); + + JPanel hashDataPanel = createViewerPanel(messages.getString(BKUGUIFacade.MESSAGE_HASHDATA), content, mimeType, encoding, helpListener); + JPanel buttonPanel = createButtonPanel(saveListener, saveCommand); + initContentPane(new Dimension(600, 400), hashDataPanel, buttonPanel); + + pack(); + if (frame != null) { + setLocationRelativeTo(frame); + } else { + setLocationByPlatform(true); + } + } + + private ViewerDialog(Frame frame, + ResourceBundle messages, + String helpTopic, +// Reader helpDocument, + InputStream helpDocument, + String mimeType) { + super(frame, messages.getString(BKUGUIFacade.WINDOWTITLE_HELP), true); + this.messages = messages; + + String p = messages.getString(BKUGUIFacade.MESSAGE_HELP); + String helpItem = messages.getString(helpTopic); + String viewerLabel = MessageFormat.format(p, new Object[] {helpItem}); + + JPanel helpPanel = createViewerPanel(viewerLabel, helpDocument, mimeType, null, null); + JPanel buttonPanel = createButtonPanel(); + + initContentPane(new Dimension(600, 400), helpPanel, buttonPanel); + pack(); + if (frame != null) { + setLocationRelativeTo(frame); + } else { + setLocationByPlatform(true); + } + } + + private void initContentPane(Dimension preferredSize, JPanel viewerPanel, JPanel buttonPanel) { + Container contentPane = getContentPane(); + contentPane.setPreferredSize(preferredSize); + + GroupLayout mainLayout = new GroupLayout(contentPane); + contentPane.setLayout(mainLayout); + + mainLayout.setHorizontalGroup( + mainLayout.createSequentialGroup().addContainerGap().addGroup( + mainLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(viewerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()); + mainLayout.setVerticalGroup( + mainLayout.createSequentialGroup() + .addContainerGap() + .addComponent(viewerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(buttonPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap()); + } + + /** + * + * @param messages + * @param content + * @param mimeType defaults to text/plain if null + * @param encoding must be null if document contains charset declaration (e.g. HTML page), otherwise the parser crashes + * @param helpListener may be null + * @return + */ + private JPanel createViewerPanel(String viewerLabelText, InputStream content, String mimeType, String encoding, HelpMouseListener helpListener) { + log.debug("viewer dialog: " + mimeType); + + if (mimeType == null) { + mimeType = "text/plain"; + } else if ("application/xhtml+xml".equals(mimeType)) { + mimeType = "text/html"; + } + + JEditorPane viewer = new JEditorPane(); + viewer.setEditable(false); + viewer.setContentType(mimeType); + if ("text/plain".equals(mimeType)) { + viewer.setFont(new Font(PLAINTEXT_FONT, viewer.getFont().getStyle(), viewer.getFont().getSize())); + } + + EditorKit editorKit = viewer.getEditorKit(); + Document document = editorKit.createDefaultDocument(); +// document.putProperty("IgnoreCharsetDirective", new Boolean(true)); + + try { + if (encoding != null) { + BufferedReader contentReader = new BufferedReader(new InputStreamReader(content, encoding)); + viewer.read(contentReader, document); + contentReader.close(); + } else { + // charset declaration in content + viewer.read(content, document); + content.close(); + } + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + String p = messages.getString(BKUGUIFacade.ERR_VIEWER); + viewer.setText(MessageFormat.format(p, ex.getMessage())); + } + + JScrollPane scrollPane = new JScrollPane(viewer); + scrollPane.setPreferredSize(viewer.getPreferredSize()); + scrollPane.setAlignmentX(LEFT_ALIGNMENT); + viewer.setCaretPosition(0); + + JLabel viewerLabel = new JLabel(); + viewerLabel.setText(viewerLabelText); + viewerLabel.setFont(viewerLabel.getFont().deriveFont(viewerLabel.getFont().getStyle() | java.awt.Font.BOLD)); + viewerLabel.setLabelFor(viewer); + + JPanel viewerPanel = new JPanel(); + GroupLayout viewerPanelLayout = new GroupLayout(viewerPanel); + viewerPanel.setLayout(viewerPanelLayout); + + if (helpListener != null) { + JLabel helpLabel = new JLabel(); + helpListener.setHelpTopic(BKUGUIFacade.HELP_HASHDATAVIEWER); + helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG))); + helpLabel.addMouseListener(helpListener); + helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + viewerPanelLayout.setHorizontalGroup( + viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(viewerPanelLayout.createSequentialGroup().addComponent(viewerLabel).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE).addComponent(helpLabel)).addComponent(scrollPane)); //, 0, 0, Short.MAX_VALUE)); + viewerPanelLayout.setVerticalGroup( + viewerPanelLayout.createSequentialGroup() + .addGroup(viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(viewerLabel) + .addComponent(helpLabel)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scrollPane)); + } else { + viewerPanelLayout.setHorizontalGroup( + viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(viewerLabel) + .addComponent(scrollPane)); + viewerPanelLayout.setVerticalGroup( + viewerPanelLayout.createSequentialGroup() + .addComponent(viewerLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scrollPane)); + + } + + return viewerPanel; + } + + private JPanel createButtonPanel() { + JButton closeButton = new JButton(); + closeButton.setText(messages.getString(BKUGUIFacade.BUTTON_CLOSE)); + closeButton.addActionListener(this); + + JPanel buttonPanel = new JPanel(); + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + buttonPanelLayout.setHorizontalGroup( + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(closeButton)); + buttonPanelLayout.setVerticalGroup( + buttonPanelLayout.createSequentialGroup() + .addComponent(closeButton)); + return buttonPanel; + } + + private JPanel createButtonPanel(ActionListener saveListener, String saveCommand) { + JButton closeButton = new JButton(); + closeButton.setText(messages.getString(BKUGUIFacade.BUTTON_CLOSE)); + closeButton.addActionListener(this); + + JButton saveButton = new JButton(); + saveButton.setText(messages.getString(BKUGUIFacade.BUTTON_SAVE)); + saveButton.setActionCommand(saveCommand); + saveButton.addActionListener(saveListener); + + int buttonSize = closeButton.getPreferredSize().width; + if (saveButton.getPreferredSize().width > buttonSize) { + buttonSize = saveButton.getPreferredSize().width; + } + + JPanel buttonPanel = new JPanel(); + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + 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(closeButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); + buttonPanelLayout.setVerticalGroup( + buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(saveButton).addComponent(closeButton)); + + return buttonPanel; + } + + @Override + public void actionPerformed(ActionEvent e) { +// if ("close".equals(e.getActionCommand())) { +// ViewerDialog.dialog.setVisible(false); +// HashDataViewer.dialog.dispose(); + this.setVisible(false); + } +} |