[Schmitzm-commits] r2418 - in trunk/schmitzm-core/src/main: java/de/schmitzm/swing resources/de/schmitzm/swing/resource/locales
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Fri Jan 15 20:05:02 CET 2016
Author: mojays
Date: 2016-01-15 20:05:02 +0100 (Fri, 15 Jan 2016)
New Revision: 2418
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListItemsSwingWorker.java
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
Log:
ExceptionDialog: optional Checkbox in dialog to "hide further messages" (default: checkbox is not shown)
ListItemsSwingWorker: provide possibility to hide further messages during process of multiple items
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java 2015-09-10 09:08:46 UTC (rev 2417)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ExceptionDialog.java 2016-01-15 19:05:02 UTC (rev 2418)
@@ -42,6 +42,7 @@
import java.util.TreeSet;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
@@ -108,6 +109,8 @@
protected JTextArea detailsTextArea = null;
/** ScrollPane, in dem sich die TextArea fuer die Details befinden. */
protected JScrollPane detailsScrollPane = null;
+ /** Checkbox, um weitere Fehlermeldungen zu unterdruecken */
+ protected JCheckBox hideFurtherMessages = null;
/** Verbindung zwischen StackTrace-PrintStream und TextArea */
private TextAreaPrintStream detailsPrintStream = null;
/**
@@ -170,6 +173,27 @@
this(parent, err, title, errMessage, false);
}
+ /**
+ * Erzeugt einen neuen Fehler-Dialog. Der Dialog wird relativ zum
+ * Parent-Fenster zentriert.
+ *
+ * @param parent
+ * uebergeordnetes Fenster (kann <code>null</code> sein!)
+ * @param err
+ * darzustellender Fehler
+ * @param title
+ * Titel fuer das Fenster (kann <code>null</code> sein!)
+ * @param errMessage
+ * Meldung, die zu dem Fehler angezeigt angezeigt wird (kann
+ * <code>null</code> sein!)
+ * @param showDetails
+ * wenn {@code true} werden die Details initial angezeigt
+ */
+ public ExceptionDialog(Component parent, Throwable err, String title,
+ String errMessage, boolean showDetails) {
+ this(parent, err, title, errMessage, showDetails, false);
+ }
+
/**
* Erzeugt einen neuen Fehler-Dialog. Der Dialog wird relativ zum
* Parent-Fenster zentriert.
@@ -185,9 +209,12 @@
* <code>null</code> sein!)
* @param showDetails
* wenn {@code true} werden die Details initial angezeigt
+ * @param showHideFurtherMessages
+ * wenn {@code true} wird eine Check Box angezeigt, um nachfolgende
+ * Meldungen zu unterdruecken
*/
public ExceptionDialog(Component parent, Throwable err, String title,
- String errMessage, boolean showDetails) {
+ String errMessage, boolean showDetails, boolean showHideFurtherMessages) {
super((Frame) null, true);
/**
@@ -241,6 +268,8 @@
this.detailsPrintStream = new TextAreaPrintStream(detailsTextArea);
this.detailsScrollPane = new JScrollPane(detailsTextArea);
this.detailsScrollPane.setVisible(showDetails);
+ this.hideFurtherMessages = new JCheckBox(SwingUtil.R("ExceptionDialog.HideFurtherMessages"), false);
+
this.setError(err);
JComponent messageComp = messageLabel;
@@ -260,6 +289,8 @@
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(dialog.getContentPane(), BorderLayout.NORTH);
this.getContentPane().add(detailsScrollPane, BorderLayout.CENTER);
+ if ( showHideFurtherMessages )
+ this.getContentPane().add(hideFurtherMessages, BorderLayout.SOUTH);
// this.setDefaultCloseOperation( DO_NOTHING_ON_CLOSE );
this.okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -406,7 +437,7 @@
if (GraphicsEnvironment.isHeadless())
err.printStackTrace();
else
- constructDialog(parent, err, title, errMessage, false);
+ constructDialog(parent, err, title, errMessage, false, false);
}
/**
@@ -421,7 +452,7 @@
if (GraphicsEnvironment.isHeadless())
err.printStackTrace();
else
- constructDialog(parent, err, null, null, false);
+ constructDialog(parent, err, null, null, false, false);
}
@@ -435,7 +466,7 @@
if (GraphicsEnvironment.isHeadless())
err.printStackTrace();
else {
- constructDialog(null, err, null, null, false);
+ constructDialog(null, err, null, null, false, false);
}
}
@@ -461,28 +492,64 @@
if (GraphicsEnvironment.isHeadless())
err.printStackTrace();
else {
- constructDialog(parent, err, title, errMessage, showDetails);
+ constructDialog(parent, err, title, errMessage, showDetails, false);
}
}
- /**
+ /**
+ * Zeigt einen Fehler-Dialog an.
+ *
+ * @param parent
+ * uebergeordnetes Fenster (kann <code>null</code> sein!)
+ * @param err
+ * darzustellender Fehler
+ * @param title
+ * Titel fuer das Fenster (kann <code>null</code> sein!)
+ * @param errMessage
+ * Meldung, die zu dem Fehler angezeigt angezeigt wird (kann
+ * <code>null</code> sein!)
+ * @param showDetails
+ * wenn {@code true} werden die Details initial angezeigt
+ * @param allowHideFurtherMessages
+ * wenn {@code true} wird eine Check Box angezeigt, um nachfolgende
+ * Meldungen zu unterdruecken
+ * @return {@code false} wenn weitere Meldungen unterdrueckt werden sollen (Wert der CheckBox);
+ * {@code true} wenn weitere Meldungen angezeigt werden sollen
+ */
+ public static boolean show(final Component parent, final Throwable err,
+ final String title, final String errMessage,
+ final boolean showDetails, final boolean allowHideFurtherMessages) {
+ if (GraphicsEnvironment.isHeadless()) {
+ err.printStackTrace();
+ return true;
+ } else {
+ ExceptionDialog dialog = constructDialog(parent, err, title, errMessage, showDetails, allowHideFurtherMessages);
+ return dialog.hideFurtherMessages == null || !dialog.hideFurtherMessages.isSelected();
+ }
+ }
+
+ /**
* This method will construct the {@link ExceptionDialog} on the Event
* Dispatching Thread, even if it has been started from another thread!
*/
- private static void constructDialog(final Component parent,
+ private static ExceptionDialog constructDialog(final Component parent,
final Throwable err, final String title, final String errMessage,
- final boolean showDetails) {
+ final boolean showDetails, final boolean showHideFurtherMessages) {
+
+ // Quick-And-Dirty Workaround to return the dialog object created
+ // on EDT!
+ final ExceptionDialog[] dialog = new ExceptionDialog[1];
+
if (SwingUtilities.isEventDispatchThread()) {
- new ExceptionDialog(parent, err, title, errMessage, showDetails)
- .setVisible(true);
+ dialog[0] = new ExceptionDialog(parent, err, title, errMessage, showDetails, showHideFurtherMessages);
+ dialog[0].setVisible(true);
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
-
@Override
public void run() {
- new ExceptionDialog(parent, err, title, errMessage,
- showDetails).setVisible(true);
+ dialog[0] = new ExceptionDialog(parent, err, title, errMessage, showDetails, showHideFurtherMessages);
+ dialog[0].setVisible(true);
}
});
} catch (InterruptedException e) {
@@ -495,6 +562,7 @@
e.printStackTrace();
}
}
+ return dialog[0];
}
/**
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListItemsSwingWorker.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListItemsSwingWorker.java 2015-09-10 09:08:46 UTC (rev 2417)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ListItemsSwingWorker.java 2016-01-15 19:05:02 UTC (rev 2418)
@@ -64,6 +64,9 @@
protected ProgressUpdater progressUpdater;
/** Holds the processed items. */
protected List<E> processedItems = new ArrayList<E>();
+ /** Flag do maintain {@link ExceptionDialog} checkbox value whether or not to
+ * show/hide further messages */
+ protected boolean showFurtherMessages = true;
/** Holds the message, which will be shown during work when
* an error occurs on an item. Can be changed by {@link #initMessages(String, String, String, String)}. */
@@ -226,10 +229,14 @@
* @param err
*/
public void performError(E item, Exception err) {
- ExceptionDialog.show(parent,
- err,
- getItemDescription(item),
- errorMess+": "+err.getMessage());
+ if ( showFurtherMessages )
+ showFurtherMessages = ExceptionDialog.show(parent,
+ err,
+ getItemDescription(item),
+ errorMess+": "+err.getMessage(),
+ false,
+ true // allow to hide further messages
+ );
}
/**
@@ -256,6 +263,7 @@
@Override
public void run() {
operationCanceled = false;
+ showFurtherMessages = true;
ProgressUpdater progressUpdater = this.progressUpdater != null ? this.progressUpdater : ProgressUpdater.DUMMY;
SwingUtil.setWaitCursor(this.parent, this.escListener);
Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties 2015-09-10 09:08:46 UTC (rev 2417)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties 2016-01-15 19:05:02 UTC (rev 2418)
@@ -100,6 +100,7 @@
ExceptionDialog.Mail=Mail
ExceptionDialog.MailDisabled.Desc=Mailing currently not available, because a destination mail address for bug reporting is not set in this application (ExceptionDialog.setMailDestinationAddress(..))
#ExceptionDialog.Mail.SendBySmtpOk=<html>An email has been send to bugreport at wikisquare.de.<br>If you supplied your email-address, expect feedback from tzeggai at wikisquare.de.</html>
+ExceptionDialog.HideFurtherMessages=Do not show further messages
ManualInputOption.PasswordVisible.visibility=visible
Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties 2015-09-10 09:08:46 UTC (rev 2417)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties 2016-01-15 19:05:02 UTC (rev 2418)
@@ -70,6 +70,7 @@
ExceptionDialog.CopyToConsole=Auf Console ausgeben
ExceptionDialog.Mail=Mailen
ExceptionDialog.MailDisabled.Desc=Mailen derzeit nicht m\u00F6glich, da in der aktuellen Anwendung keine Ziel-Adresse f\u00FCr Bug-Reporting eingestellt ist (ExceptionDialog.setMailDestinationAddress(..))
+ExceptionDialog.HideFurtherMessages=Keine weiteren Fehler anzeigen
ManualInputOption.PasswordVisible.visibility=sichtbar
More information about the Schmitzm-commits
mailing list