summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main/java/at
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-19 16:14:57 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-19 16:14:57 +0000
commitd8901c075f9deb663e0edd640672ed620ffb4610 (patch)
treeecb1b87d6499a4719a5940dc7f8ad6cf47a32491 /BKUCommonGUI/src/main/java/at
parentbc81c317e254fa617fc24c8129b743ac74aad470 (diff)
downloadmocca-d8901c075f9deb663e0edd640672ed620ffb4610.tar.gz
mocca-d8901c075f9deb663e0edd640672ed620ffb4610.tar.bz2
mocca-d8901c075f9deb663e0edd640672ed620ffb4610.zip
GUI bugfixes and cleanup
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@181 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI/src/main/java/at')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java26
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java103
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java4
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java47
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java1
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java38
6 files changed, 89 insertions, 130 deletions
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 2dbba730..7d912f11 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
@@ -19,9 +19,7 @@ package at.gv.egiz.bku.gui;
import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.smcc.PINSpec;
import java.awt.Color;
-import java.awt.Container;
import java.awt.event.ActionListener;
-import java.net.URL;
import java.util.List;
import java.util.Locale;
@@ -71,7 +69,6 @@ public interface BKUGUIFacade {
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";
@@ -95,17 +92,13 @@ public interface BKUGUIFacade {
// public void init(Container contentPane, Locale locale, Style guiStyle, 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
+ * @param waitMessage if null, a simple 'please wait' text is displayed
*/
public void showWaitDialog(String waitMessage);
@@ -123,25 +116,8 @@ public interface BKUGUIFacade {
public char[] getPin();
- /**
- * TODO move to HashDataDisplay implementations
- * @param signedReferences
- * @param externalDisplay
- * @param okListener
- * @param okCommand
- */
public void showHashDataInputDialog(List<HashDataInput> signedReferences, 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);
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
index 38247174..a190b9c0 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
@@ -26,6 +26,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionAdapter;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -554,44 +556,37 @@ public class BKUGUIImpl implements BKUGUIFacade {
GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
- GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
- GroupLayout.SequentialGroup pinHorizontal = 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(pinsizeLabel));
-
- GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup();
+ GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup()
+ .addComponent(infoLabel);
+ GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(infoLabel);
if (!renderHeaderPanel) {
- GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup()
- .addComponent(infoLabel) //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
+ infoHorizontal
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
- .addComponent(helpLabel); //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- mainHorizontal
- .addGroup(infoHorizontal)
- .addGroup(pinHorizontal);
- GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(infoLabel)
.addComponent(helpLabel);
- mainVertical
- .addGroup(infoVertical)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
- } else {
- mainHorizontal
- .addGroup(pinHorizontal);
- }
-
- mainVertical
- .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(cardPinLabel)
- .addComponent(pinField))
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(pinsizeLabel);
+ infoVertical
+ .addComponent(helpLabel);
+ }
- mainPanelLayout.setHorizontalGroup(mainHorizontal);
- mainPanelLayout.setVerticalGroup(mainVertical);
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(infoHorizontal)
+ .addGroup(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(pinsizeLabel))));
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(infoVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(cardPinLabel)
+ .addComponent(pinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinsizeLabel));
GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
@@ -1049,31 +1044,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
}
/**
- * Opens HashDataViewer on mouse clicked event
- */
-// public class HashDataMouseListener extends MouseAdapter {
-//
-// private HashDataInput hashData;
-//
-// public void setHashData(HashDataInput hashData) {
-// this.hashData = hashData;
-// }
-//
-// @Override
-// public void mouseClicked(MouseEvent e) {
-// ActionListener saveListener = new ActionListener() {
-//
-// @Override
-// public void actionPerformed(ActionEvent e) {
-// showSaveHashDataInputDialog(Collections.singletonList(hashData), null, null);
-// }
-// };
-// showHashDataViewer(hashData, saveListener, "save");
-// super.mouseClicked(e);
-// }
-// }
-
- /**
* has to be called from event dispatcher thread
* @param hashDataText
* @param saveListener
@@ -1113,10 +1083,23 @@ public class BKUGUIImpl implements BKUGUIFacade {
refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.size()}));
HashDataTableModel tableModel = new HashDataTableModel(signedReferences);
- JTable hashDataTable = new JTable(tableModel);
-// hashDataTable.setDefaultRenderer(HashDataInput.class, signedReferences.getRenderer());
+ final JTable hashDataTable = new JTable(tableModel);
+ hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperlinkRenderer());
hashDataTable.setTableHeader(null);
+ // not possible to add mouse listener to TableCellRenderer
+ hashDataTable.addMouseMotionListener(new MouseMotionAdapter() {
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ if (hashDataTable.columnAtPoint(e.getPoint()) == 0) {
+ hashDataTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ } else {
+ hashDataTable.setCursor(Cursor.getDefaultCursor());
+ }
+ }
+ });
+
hashDataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
hashDataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java
index 502f93ec..3c8c7d6c 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java
@@ -27,6 +27,10 @@ import javax.swing.SwingUtilities;
*/
public class DefaultHelpListener extends AbstractHelpListener {
+ /**
+ * applet context to open external links in help pages,
+ * if null, no external links will be opened
+ */
protected AppletContext ctx;
/**
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 9a43e99d..b0f51a78 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
@@ -30,14 +30,15 @@ class HashDataTableModel extends DefaultTableModel {
protected static final Log log = LogFactory.getLog(HashDataTableModel.class);
- protected Class[] types = new Class[]{ String.class, String.class };
+ /** HashDataInput in first column, register hyperlinkrenderer only here */
+ protected Class[] types = new Class[]{ HashDataInput.class, String.class };
protected List<HashDataInput> hashDataInputs;
public HashDataTableModel(List<HashDataInput> hashDataInputs) {
super(0, 2);
this.hashDataInputs = hashDataInputs;
for (HashDataInput hdi : hashDataInputs) {
- addRow(new Object[]{hdi.getReferenceId(), hdi.getMimeType()});
+ addRow(new Object[]{ hdi, hdi.getMimeType()});
}
}
@@ -50,46 +51,4 @@ class HashDataTableModel extends DefaultTableModel {
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
-
-// public HashDataInput getValue(int rowIndex) {
-// return hashDataInputs.get(rowIndex);
-// }
-//
-
-// public class HashDataLinkRenderer extends JLabel
-// implements TableCellRenderer {
-//// extends DefaultTableCellRenderer {
-//
-//// protected ActionListener saveHashDataListener;
-////
-//// public HashDataLinkRenderer(ActionListener saveHashDataListener) {
-//// this.saveHashDataListener = saveHashDataListener;
-//// }
-//
-// @Override
-// public Component getTableCellRendererComponent(JTable table,
-// Object value,
-// boolean isSelected,
-// boolean hasFocus,
-// final int row,
-// int column) {
-// final HashDataInput hdi = (HashDataInput) value;
-// log.debug("render hashdatainput " + hdi.getReferenceId() + " - (" + row + "," + column + ") " + isSelected + hasFocus);
-// setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
-// setFont(getFont().deriveFont(getFont().getStyle() & ~java.awt.Font.BOLD));
-// setText(hdi.getReferenceId() + " (" + hdi.getMimeType() + ")");
-// addMouseListener(new MouseAdapter() {
-//
-// @Override
-// public void mouseClicked(MouseEvent e) {
-// log.debug("received mouseclick on " + hdi.getReferenceId());
-//// saveHashDataListener.actionPerformed();
-// JOptionPane.showInputDialog(hashDataInputs.get(row).getReferenceId());
-// }
-//
-// });
-//
-// return this;
-// }
-// }
} \ 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
index 263c3c04..777e8960 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java
@@ -184,7 +184,6 @@ public class HashDataViewer extends JDialog
JEditorPane viewer = new JEditorPane();
if ("text/plain".equals(mimeType)) {
- //line wrapping, etc.
viewer.setEditorKit(new StyledEditorKit());
viewer.setFont(new Font(PLAINTEXT_FONT, viewer.getFont().getStyle(), viewer.getFont().getSize()));
// } else if ("text/html".equals(mimeType)) {
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..f983706e
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java
@@ -0,0 +1,38 @@
+/*
+ * 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 javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class HyperlinkRenderer extends DefaultTableCellRenderer {
+
+ /**
+ * cannot change mouse cursor here, do in jTable
+ * @param value
+ */
+ @Override
+ protected void setValue(Object value) {
+ super.setText("<html><u>" + ((HashDataInput) value).getReferenceId() + "</u></html>");
+ setForeground(BKUGUIFacade.HYPERLINK_COLOR);
+ }
+}