summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'BKUCommonGUI/src/main')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java4
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java140
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java21
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java14
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties4
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties5
6 files changed, 144 insertions, 44 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 5ee0058f..51906616 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
@@ -63,9 +63,11 @@ public interface BKUGUIFacade {
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_HASHDATALINK_TINY = "message.hashdatalink.tiny";
// 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_LAST_RETRY = "message.retries.last";
public static final String MESSAGE_OVERWRITE = "message.overwrite";
public static final String MESSAGE_HELP = "message.help";
public static final String WARNING_XHTML = "warning.xhtml";
@@ -90,7 +92,7 @@ public interface BKUGUIFacade {
public static final String SAVE_HASHDATAINPUT_PREFIX = "save.hashdatainput.prefix";
public static final String ALT_HELP = "alt.help";
- public enum Style { simple, advanced };
+ public enum Style { tiny, simple, advanced };
// public void init(Container contentPane, Locale locale, Style guiStyle, URL background, ActionListener helpListener);
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 d61c9a03..1e63c8d7 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
@@ -53,6 +53,7 @@ import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
+import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
@@ -69,6 +70,10 @@ public class BKUGUIImpl implements BKUGUIFacade {
private static final Log log = LogFactory.getLog(BKUGUIImpl.class);
+ protected enum PinLabelPosition {
+ LEFT, ABOVE
+ }
+
protected HelpMouseListener helpListener;
protected Container contentPane;
@@ -92,6 +97,9 @@ public class BKUGUIImpl implements BKUGUIFacade {
protected boolean renderHeaderPanel = false;
protected boolean renderIconPanel = false;
protected boolean renderCancelButton = false;
+ protected boolean shortText = false;
+ protected PinLabelPosition pinLabelPos = PinLabelPosition.LEFT;
+ protected boolean renderRefId = false;
/**
* set contentPane
@@ -125,6 +133,10 @@ public class BKUGUIImpl implements BKUGUIFacade {
renderHeaderPanel = true;
renderIconPanel = false;
renderCancelButton = true;
+ renderRefId = true;
+ } else if (guiStyle == Style.tiny) {
+ shortText = true;
+ pinLabelPos = PinLabelPosition.ABOVE;
}
registerHelpListener(helpListener);
@@ -537,11 +549,21 @@ public class BKUGUIImpl implements BKUGUIFacade {
if (numRetries < 0) {
infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
String infoPattern = messages.getString(MESSAGE_ENTERPIN);
- infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {pinSpec.getLocalizedName()}));
+ if (shortText) {
+ infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {"PIN"}));
+ } else {
+ infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {pinSpec.getLocalizedName()}));
+ }
helpListener.setHelpTopic(HELP_CARDPIN);
} else {
+ String retryPattern;
+ if (numRetries < 2) {
+ retryPattern = messages.getString(MESSAGE_LAST_RETRY);
+ } else {
+ retryPattern = messages.getString(MESSAGE_RETRIES);
+ }
infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD));
- infoLabel.setText(MessageFormat.format(messages.getString(MESSAGE_RETRIES), new Object[]{String.valueOf(numRetries)}));
+ infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)}));
infoLabel.setForeground(ERROR_COLOR);
helpListener.setHelpTopic(HELP_RETRY);
}
@@ -570,27 +592,47 @@ public class BKUGUIImpl implements BKUGUIFacade {
infoVertical
.addComponent(helpLabel);
}
-
- mainPanelLayout.setHorizontalGroup(
- mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addGroup(infoHorizontal)
+
+ GroupLayout.Group pinHorizontal;
+ GroupLayout.Group pinVertical;
+
+ if (pinLabelPos == PinLabelPosition.ABOVE) {
+ pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.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.UNRELATED, 0, Short.MAX_VALUE)
+ .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
+ pinVertical = mainPanelLayout.createSequentialGroup()
+ .addComponent(cardPinLabel)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(cardPinLabel)
- .addComponent(pinField))
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
+ } else {
+ pinHorizontal = mainPanelLayout.createSequentialGroup()
+ .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(pinsizeLabel));
-
-
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(pinsizeLabel));
+ pinVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(cardPinLabel)
+ .addComponent(pinField);
+ }
+
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(infoHorizontal)
+ .addGroup(pinHorizontal));
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(infoVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(pinVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinsizeLabel));
+
+
GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
buttonPanel.setLayout(buttonPanelLayout);
@@ -707,7 +749,11 @@ public class BKUGUIImpl implements BKUGUIFacade {
JLabel infoLabel = new JLabel();
if (numRetries < 0) {
infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
- infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK));
+ if (shortText) {
+ infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK_TINY));
+ } else {
+ infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK));
+ }
infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
infoLabel.setForeground(HYPERLINK_COLOR);
infoLabel.addMouseListener(new MouseAdapter() {
@@ -720,8 +766,14 @@ public class BKUGUIImpl implements BKUGUIFacade {
});
helpListener.setHelpTopic(HELP_SIGNPIN);
} else {
+ String retryPattern;
+ if (numRetries < 2) {
+ retryPattern = messages.getString(MESSAGE_LAST_RETRY);
+ } else {
+ retryPattern = messages.getString(MESSAGE_RETRIES);
+ }
+ infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)}));
infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD));
- infoLabel.setText(MessageFormat.format(messages.getString(MESSAGE_RETRIES), new Object[]{String.valueOf(numRetries)}));
infoLabel.setForeground(ERROR_COLOR);
helpListener.setHelpTopic(HELP_RETRY);
}
@@ -737,28 +789,48 @@ public class BKUGUIImpl implements BKUGUIFacade {
if (!renderHeaderPanel) {
infoHorizontal
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
- .addComponent(helpLabel); //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
+ .addComponent(helpLabel);
infoVertical
.addComponent(helpLabel);
}
+ GroupLayout.Group pinHorizontal;
+ GroupLayout.Group pinVertical;
+
+ if (pinLabelPos == PinLabelPosition.ABOVE) {
+ pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
+ .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
+
+ pinVertical = mainPanelLayout.createSequentialGroup()
+ .addComponent(signPinLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
+ } else {
+ pinHorizontal = 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(pinsizeLabel));
+ pinVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(signPinLabel)
+ .addComponent(pinField);
+ }
+
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(infoHorizontal)
- .addGroup(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(pinsizeLabel))));
+ .addGroup(pinHorizontal));
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createSequentialGroup()
.addGroup(infoVertical)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(signPinLabel)
- .addComponent(pinField))
+ .addGroup(pinVertical)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pinsizeLabel));
@@ -1084,9 +1156,9 @@ public class BKUGUIImpl implements BKUGUIFacade {
String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST);
refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.size()}));
- HashDataTableModel tableModel = new HashDataTableModel(signedReferences);
+ HashDataTableModel tableModel = new HashDataTableModel(signedReferences, renderRefId);
final JTable hashDataTable = new JTable(tableModel);
- hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperlinkRenderer());
+ hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperlinkRenderer(renderRefId));
hashDataTable.setTableHeader(null);
// not possible to add mouse listener to TableCellRenderer
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 b0f51a78..70842102 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
@@ -31,14 +31,23 @@ class HashDataTableModel extends DefaultTableModel {
protected static final Log log = LogFactory.getLog(HashDataTableModel.class);
/** HashDataInput in first column, register hyperlinkrenderer only here */
- protected Class[] types = new Class[]{ HashDataInput.class, String.class };
+ protected Class[] types;
protected List<HashDataInput> hashDataInputs;
-
- public HashDataTableModel(List<HashDataInput> hashDataInputs) {
- super(0, 2);
+
+ public HashDataTableModel(List<HashDataInput> hashDataInputs, boolean twoColLayout) {
+ super(0, (twoColLayout) ? 2 : 1);
this.hashDataInputs = hashDataInputs;
- for (HashDataInput hdi : hashDataInputs) {
- addRow(new Object[]{ hdi, hdi.getMimeType()});
+
+ if (twoColLayout) {
+ types = new Class[] { HashDataInput.class, String.class };
+ for (HashDataInput hdi : hashDataInputs) {
+ addRow(new Object[] { hdi, hdi.getMimeType() });
+ }
+ } else {
+ types = new Class[] { HashDataInput.class };
+ for (HashDataInput hdi : hashDataInputs) {
+ addRow(new Object[] { hdi });
+ }
}
}
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
index f983706e..16024fcc 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HyperlinkRenderer.java
@@ -26,13 +26,25 @@ import javax.swing.table.DefaultTableCellRenderer;
*/
public class HyperlinkRenderer extends DefaultTableCellRenderer {
+ protected boolean renderReferenceId;
+
+ public HyperlinkRenderer(boolean renderReferenceId) {
+ this.renderReferenceId = renderReferenceId;
+ }
+
/**
* 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>");
+ String hrefText;
+ if (renderReferenceId) {
+ hrefText = ((HashDataInput) value).getReferenceId();
+ } else {
+ hrefText = ((HashDataInput) value).getMimeType();
+ }
+ super.setText("<html><u>" + hrefText + "</u></html>");
setForeground(BKUGUIFacade.HYPERLINK_COLOR);
}
}
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 d2b47a9d..4562fda5 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
@@ -32,11 +32,13 @@ message.wait=<html>Bitte warten...</html>
message.insertcard=<html>Bitte die B\u00FCrgerkarte in den Kartenleser stecken</html>
message.enterpin=<html>{0} eingeben</html>
message.hashdatalink=<html><a href=\"anzeige\">Signaturdaten anzeigen</a></html>
+message.hashdatalink.tiny=<html><a href=\"anzeige\">Signaturdaten</a></html>
#message.hashdata=<html>Hinweis: Dies ist eine Voransicht des zu signierenden Inhalts. F\u00FCr eine standardkonforme Darstellung siehe Hilfe (i).</html>
#message.hashdata=<html>Dies ist eine Voransicht des zu signierenden Inhaltes. F\u00FCr Details siehe Hilfe (i).</html>
#verwenden sie bitte die von ihrem System zur Verf\u00FCgung gestellte {0} Anwendung.
message.hashdatalist=<html>{0} Signaturdaten:</html>
-message.retries=<html>Noch {0} Versuch(e)</html>
+message.retries.last=<html>Letzter Versuch!</html>
+message.retries=<html>Noch {0} Versuche</html>
message.overwrite=<html>M\u00F6chten Sie das existierende Dokument {0} \u00FCberschreiben?</html>
message.help=<html>Hilfe zu {0}</html>
warning.xhtml=<html>Hinweis: Dies ist eine Voransicht des zu signierenden Inhalts. F\u00FCr eine standardkonforme Darstellung siehe Hilfe (i).</html>
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
index 524a2a98..0faa3dba 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
@@ -32,8 +32,10 @@ message.wait=<html>Please wait...</html>
message.insertcard=<html>Please insert your citizen card into the reader</html>
message.enterpin=<html>Enter {0}</html>
message.hashdatalink=<html><a href=\"anzeige\">Display signature data</a></html>
+message.hashdatalink.tiny=<html><a href=\"anzeige\">signature data</a></html>
#message.hashdata=<html>Remark: This is a preview of the data to-be signed. For standards compliant display see help.</html>
message.hashdatalist=<html>{0} signature data objects:</html>
+message.retries.last=<html>Last try!</html>
message.retries=<html>{0} tries left</html>
message.overwrite=<html>Overwrite {0}?</html>
message.help=<html>Help topic {0}</html>
@@ -60,7 +62,8 @@ error.no.hashdata=<html>No signature data available: {0}</html>
error.display.hashdata=<html>Could not display signature data: {0}</html>
error.write.hashdata=<html>Could not save signature data: {0}</html>
error.invalid.hash=<html>Invalid signature data: {0}</html>
-error.ws.unreachable=<html>Web-service unreachable: {0}</html>
+error.ws.unreachable=<html>Server unreachable</html>
+#error.ws.unreachable=<html>Web-service unreachable: {0}</html>
error.pcsc=<html>No PC/SC interface for smartcard access provided</html>
error.cardterminal=<html>Could not find smartcard reader</html>
error.unknown=<html>An error occured: {0}</html>