Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Donate button and ErrorDialog will now print the throwable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyost committed Aug 7, 2015
1 parent 09de80c commit 7df40e1
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/fr/skyost/algo/desktop/AlgogoDesktop.java
Expand Up @@ -62,7 +62,6 @@ public final void run() {
});
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(null, ex);
}
}
Expand Down
29 changes: 25 additions & 4 deletions src/fr/skyost/algo/desktop/dialogs/AboutDialog.java
Expand Up @@ -10,7 +10,10 @@

import java.awt.Color;
import java.awt.Container;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.BorderFactory;
Expand All @@ -21,6 +24,7 @@
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;

public class AboutDialog extends JDialog {

Expand All @@ -30,7 +34,7 @@ public AboutDialog() {
try {
final String authors = Utils.join(' ', AlgogoDesktop.APP_AUTHORS);
this.setTitle(String.format(LanguageManager.getString("about.title"), AlgogoDesktop.APP_NAME, AlgogoDesktop.APP_VERSION, authors));
this.setSize(430, 406);
this.setSize(430, 460);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.setModalityType(ModalityType.APPLICATION_MODAL);
this.setModal(true);
Expand All @@ -53,14 +57,31 @@ public AboutDialog() {
final JLabel lblBuiltUsing = new JLabel(String.format(LanguageManager.getString("about.builtusing"), "minimal-json v0.9.2", "Heartbeat v0.1", "JTattoo v1.6.11"));
lblBuiltUsing.setHorizontalAlignment(SwingConstants.CENTER);
final Container content = this.getContentPane();
final JButton btnDonate = new JButton(LanguageManager.getString("about.donate"));
btnDonate.setFont(btnDonate.getFont().deriveFont(Font.BOLD));
btnDonate.setIcon(new ImageIcon(AlgogoDesktop.class.getResource("/fr/skyost/algo/desktop/res/icons/btn_donate.png")));
btnDonate.addActionListener(new ActionListener() {

@Override
public final void actionPerformed(final ActionEvent event) {
if(Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(new URL("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4KYYXZTK4HQME").toURI());
}
catch(final Exception ex) {
ErrorDialog.errorMessage(AboutDialog.this, ex);
}
}
}

});
final GroupLayout groupLayout = new GroupLayout(content);
groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblAppDesktopInfos, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE).addContainerGap()).addGroup(groupLayout.createSequentialGroup().addComponent(lblAppName, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE).addGap(0)).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblAppCoreInfos, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE).addContainerGap()).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(panel, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE).addContainerGap()).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblBuiltUsing, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE).addContainerGap()));
groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblAppName).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(lblAppDesktopInfos).addPreferredGap(ComponentPlacement.RELATED).addComponent(lblAppCoreInfos).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(lblBuiltUsing).addContainerGap(34, Short.MAX_VALUE)));
groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblAppDesktopInfos, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE).addContainerGap()).addGroup(groupLayout.createSequentialGroup().addComponent(lblAppName, GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE).addGap(0)).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblAppCoreInfos, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE).addContainerGap()).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(panel, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE).addContainerGap()).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblBuiltUsing, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE).addContainerGap()).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(btnDonate, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE).addContainerGap()));
groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(lblAppName).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(lblAppDesktopInfos, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(lblAppCoreInfos, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(lblBuiltUsing).addGap(18).addComponent(btnDonate, GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE).addContainerGap()));
content.setLayout(groupLayout);
}
catch(final Exception ex) {
ErrorDialog.errorMessage(this, ex);
ex.printStackTrace();
}
}

Expand Down
19 changes: 18 additions & 1 deletion src/fr/skyost/algo/desktop/dialogs/ErrorDialog.java
Expand Up @@ -85,13 +85,30 @@ public final void actionPerformed(final ActionEvent event) {
* Shows an error message (no translation because it can be risky).
*
* @param component The parent component.
* @param throwable The error.
* @param throwable The error. Will be printed.
*
* @return The dialog.
*/

public static ErrorDialog errorMessage(final Component component, final Throwable throwable) {
return errorMessage(component, throwable, true);
}

/**
* Shows an error message (no translation because it can be risky).
*
* @param component The parent component.
* @param throwable The error.
* @param printStackTrace If the error should be printed.
*
* @return The dialog.
*/

public static ErrorDialog errorMessage(final Component component, final Throwable throwable, final boolean printStackTrace) {
try {
if(printStackTrace) {
throwable.printStackTrace();
}
final ErrorDialog dialog = new ErrorDialog(component, throwable);
dialog.setVisible(true);
return dialog;
Expand Down
2 changes: 0 additions & 2 deletions src/fr/skyost/algo/desktop/frames/ConsoleFrame.java
Expand Up @@ -146,7 +146,6 @@ public void actionPerformed(final ActionEvent event) {
}
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(ConsoleFrame.this, ex);
}
}
Expand Down Expand Up @@ -209,7 +208,6 @@ public final void threadInterrupted(final AlgoRunnable thread, final Exception e
currentThread = null;
if(ex != null) {
output.append("Exception occurred :\"" + ex.getClass().getName() + "\", please check the error log." + LINE_SEPARATOR);
ex.printStackTrace();
ErrorDialog.errorMessage(this, ex);
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/fr/skyost/algo/desktop/frames/EditorFrame.java
Expand Up @@ -296,7 +296,6 @@ public final void updaterStarted() {}

@Override
public final void updaterException(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(this, ex);
}

Expand All @@ -316,7 +315,6 @@ public final void updaterUpdateAvailable(final String localVersion, final String
}
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(this, ex);
}
}
Expand Down Expand Up @@ -365,7 +363,6 @@ public final void actionPerformed(final ActionEvent event) {
}
catch(final Exception ex) {
ErrorDialog.errorMessage(EditorFrame.this, ex);
ex.printStackTrace();
}
}

Expand Down Expand Up @@ -427,7 +424,6 @@ public final void actionPerformed(final ActionEvent event) {
}
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(EditorFrame.this, ex);
}
}
Expand All @@ -454,7 +450,6 @@ public final void actionPerformed(final ActionEvent event) {
}
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(EditorFrame.this, ex);
}
}
Expand Down Expand Up @@ -567,7 +562,6 @@ public final void updaterStarted() {}

@Override
public final void updaterException(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(EditorFrame.this, ex);
}

Expand Down Expand Up @@ -862,7 +856,6 @@ else if(extension.equalsIgnoreCase(".aggc")) {
EditorFrame.this.setTitle(buildTitle());
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(this, ex);
}
}
Expand All @@ -886,7 +879,6 @@ public final void saveAs() {
}
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(EditorFrame.this, ex);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/fr/skyost/algo/desktop/res/lang/en.lang
Expand Up @@ -77,6 +77,7 @@ about.title=%s v%s - By %s
about.desktopinfos=<html><b>%s</b> <i>v%s - By %s</i></html>
about.coreinfos=<html><b>%s</b> <i>v%s - By %s</i></html>
about.builtusing=Built using %s, %s and %s.
about.donate=Buy me a coffee !


addline.title=Add line...
Expand Down
1 change: 1 addition & 0 deletions src/fr/skyost/algo/desktop/res/lang/fr.lang
Expand Up @@ -77,6 +77,7 @@ about.title=%s v%s - Par %s
about.desktopinfos=<html><b>%s</b> <i>v%s - Par %s</i></html>
about.coreinfos=<html><b>%s</b> <i>v%s - Par %s</i></html>
about.builtusing=Fait avec %s, %s et %s.
about.donate=Payez moi un café !


addline.title=Ajouter une ligne...
Expand Down
1 change: 0 additions & 1 deletion src/fr/skyost/algo/desktop/utils/JLabelLink.java
Expand Up @@ -84,7 +84,6 @@ public final void mouseClicked(final MouseEvent event) {
}
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(null, ex);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/fr/skyost/algo/desktop/utils/LanguageManager.java
Expand Up @@ -34,7 +34,6 @@ public class LanguageManager {
}
}
catch(final Exception ex) {
ex.printStackTrace();
ErrorDialog.errorMessage(null, ex);
}
}
Expand Down

0 comments on commit 7df40e1

Please sign in to comment.