Added "no internet connection available" error message

This commit is contained in:
Federico Fissore 2015-03-20 11:23:16 +01:00
parent 402c24d103
commit 87d5159da7
4 changed files with 23 additions and 15 deletions

View File

@ -79,7 +79,7 @@ public class LibraryManagerUI extends InstallerJDialog {
}
public LibraryManagerUI(Frame parent) {
super(parent, "Library Manager", Dialog.ModalityType.APPLICATION_MODAL);
super(parent, "Library Manager", Dialog.ModalityType.APPLICATION_MODAL, _("No internet connection available, the list of available libraries is not complete. You will be able to manage only the libraries you've already installed."));
}
public void setIndexer(LibrariesIndexer indexer) {
@ -155,7 +155,7 @@ public class LibraryManagerUI extends InstallerJDialog {
}
}
});
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this));
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread.start();
}
@ -176,7 +176,7 @@ public class LibraryManagerUI extends InstallerJDialog {
}
}
});
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this));
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread.start();
}
@ -184,7 +184,7 @@ public class LibraryManagerUI extends InstallerJDialog {
boolean managedByIndex = indexer.getIndex().getLibraries().contains(lib);
if (!managedByIndex) {
int chosenOption = JOptionPane.showConfirmDialog(getParent(), _("This library is not listed on Library Manager. You won't be able to resinstall it from here.\nAre you sure you want to delete it?"), _("Please confirm library deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
int chosenOption = JOptionPane.showConfirmDialog(getParent(), _("This library is not listed on Library Manager. You won't be able to resinstall it from here.<br/>Are you sure you want to delete it?"), _("Please confirm library deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (chosenOption != JOptionPane.YES_OPTION) {
return;
}
@ -206,7 +206,7 @@ public class LibraryManagerUI extends InstallerJDialog {
}
}
});
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this));
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread.start();
}

View File

@ -78,7 +78,7 @@ public class ContributionManagerUI extends InstallerJDialog {
}
public ContributionManagerUI(Frame parent) {
super(parent, _("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL);
super(parent, _("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL, _("No internet connection available, the list of available boards is not complete. You will be able to manage only the boards you've already installed."));
}
public void setIndexer(ContributionsIndexer indexer) {
@ -145,7 +145,7 @@ public class ContributionManagerUI extends InstallerJDialog {
}
}
});
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this));
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread.start();
}
@ -168,7 +168,7 @@ public class ContributionManagerUI extends InstallerJDialog {
}
}
});
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this));
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread.start();
}
@ -194,7 +194,7 @@ public class ContributionManagerUI extends InstallerJDialog {
}
}
});
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this));
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
installerThread.start();
}

View File

@ -9,21 +9,28 @@ import static processing.app.I18n._;
public class InstallerJDialogUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
private final InstallerJDialog parent;
private final String connectionErrorMessage;
public InstallerJDialogUncaughtExceptionHandler(InstallerJDialog parent) {
public InstallerJDialogUncaughtExceptionHandler(InstallerJDialog parent, String connectionErrorMessage) {
this.parent = parent;
this.connectionErrorMessage = connectionErrorMessage;
}
@Override
public void uncaughtException(Thread t, final Throwable e) {
String errorMessage = _(e.getMessage().substring(e.getMessage().indexOf(":") + 2));
if (errorMessage.startsWith("Error downloading")) {
errorMessage = connectionErrorMessage;
}
final String finalErrorMessage = errorMessage;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
System.err.println(_(e.getMessage().substring(e.getMessage().indexOf(":") + 2)));
System.err.println(finalErrorMessage);
e.printStackTrace();
}
});
parent.setErrorMessage(_(e.getMessage().substring(e.getMessage().indexOf(":") + 2)));
parent.setErrorMessage(finalErrorMessage);
}
}

View File

@ -58,6 +58,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
// Currently selected category and filters
protected Predicate<T> categoryFilter;
protected String[] filters;
protected final String noConnectionErrorMessage;
// Real contribution table
protected JTable contribTable;
@ -79,9 +80,9 @@ public abstract class InstallerJDialog<T> extends JDialog {
protected InstallerTableCell cellEditor;
public InstallerJDialog(Frame parent, String title,
ModalityType applicationModal) {
public InstallerJDialog(Frame parent, String title, ModalityType applicationModal, String noConnectionErrorMessage) {
super(parent, title, applicationModal);
this.noConnectionErrorMessage = noConnectionErrorMessage;
setResizable(true);
@ -218,7 +219,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
}
public void setErrorMessage(String message) {
errorMessage.setText(message);
errorMessage.setText("<html><body>" + message + "</body></html>");
errorMessageBox.setVisible(true);
}