added retry option at failed simulation reload
This commit is contained in:
parent
ca6b1d4bf8
commit
fd53ff57dd
|
@ -24,7 +24,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: GUI.java,v 1.44 2007/05/10 17:08:44 fros4943 Exp $
|
* $Id: GUI.java,v 1.45 2007/05/11 10:55:07 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -1848,13 +1848,13 @@ public class GUI {
|
||||||
progressDialog.dispose();
|
progressDialog.dispose();
|
||||||
}
|
}
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
showErrorDialog(frame, "Simulation load error", e);
|
showErrorDialog(frame, "Simulation load error", e, false);
|
||||||
|
|
||||||
if (progressDialog != null && progressDialog.isDisplayable())
|
if (progressDialog != null && progressDialog.isDisplayable())
|
||||||
progressDialog.dispose();
|
progressDialog.dispose();
|
||||||
newSim = null;
|
newSim = null;
|
||||||
} catch (SimulationCreationException e) {
|
} catch (SimulationCreationException e) {
|
||||||
showErrorDialog(frame, "Simulation load error", e);
|
showErrorDialog(frame, "Simulation load error", e, false);
|
||||||
|
|
||||||
if (progressDialog != null && progressDialog.isDisplayable())
|
if (progressDialog != null && progressDialog.isDisplayable())
|
||||||
progressDialog.dispose();
|
progressDialog.dispose();
|
||||||
|
@ -1982,26 +1982,28 @@ public class GUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reload altered simulation config
|
// Reload altered simulation config
|
||||||
|
boolean shouldRetry = false;
|
||||||
|
do {
|
||||||
try {
|
try {
|
||||||
|
shouldRetry = false;
|
||||||
myGUI.doRemoveSimulation(false);
|
myGUI.doRemoveSimulation(false);
|
||||||
Simulation newSim = loadSimulationConfig(new StringReader(configXML), true);
|
Simulation newSim = loadSimulationConfig(new StringReader(configXML), true);
|
||||||
myGUI.setSimulation(newSim);
|
myGUI.setSimulation(newSim);
|
||||||
|
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
showErrorDialog(frame, "Simulation reload error", e);
|
shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true);
|
||||||
|
|
||||||
myGUI.doRemoveSimulation(false);
|
myGUI.doRemoveSimulation(false);
|
||||||
} catch (SimulationCreationException e) {
|
} catch (SimulationCreationException e) {
|
||||||
showErrorDialog(frame, "Simulation reload error", e);
|
shouldRetry = showErrorDialog(frame, "Simulation reload error", e, true);
|
||||||
|
|
||||||
myGUI.doRemoveSimulation(false);
|
myGUI.doRemoveSimulation(false);
|
||||||
} finally {
|
}
|
||||||
|
} while (shouldRetry);
|
||||||
|
|
||||||
if (progressDialog != null && progressDialog.isDisplayable()) {
|
if (progressDialog != null && progressDialog.isDisplayable()) {
|
||||||
progressDialog.dispose();
|
progressDialog.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Display progress dialog while reloading
|
// Display progress dialog while reloading
|
||||||
|
@ -3015,7 +3017,22 @@ public class GUI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showErrorDialog(Component parentComponent, final String title, Throwable exception) {
|
/**
|
||||||
|
* Shows a simple dialog with information about the thrown exception. A user
|
||||||
|
* may watch the stack trace and, if the exception is a
|
||||||
|
* MoteTypeCreationException, watch compilation output.
|
||||||
|
*
|
||||||
|
* @param parentComponent
|
||||||
|
* Parent component
|
||||||
|
* @param title
|
||||||
|
* Title of error window
|
||||||
|
* @param exception
|
||||||
|
* Exception causing window to be shown
|
||||||
|
* @param retryAvailable
|
||||||
|
* If true, a retry option is available
|
||||||
|
*/
|
||||||
|
public static boolean showErrorDialog(Component parentComponent,
|
||||||
|
final String title, Throwable exception, boolean retryAvailable) {
|
||||||
|
|
||||||
MessageList compilationOutput = null;
|
MessageList compilationOutput = null;
|
||||||
MessageList stackTrace = null;
|
MessageList stackTrace = null;
|
||||||
|
@ -3033,15 +3050,17 @@ public class GUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create compilation out message list (if available)
|
// Create compilation out message list (if available)
|
||||||
if (exception != null
|
if (exception != null && exception instanceof MoteTypeCreationException
|
||||||
&& exception instanceof MoteTypeCreationException
|
|
||||||
&& ((MoteTypeCreationException) exception).hasCompilationOutput()) {
|
&& ((MoteTypeCreationException) exception).hasCompilationOutput()) {
|
||||||
compilationOutput = ((MoteTypeCreationException) exception).getCompilationOutput();
|
compilationOutput = ((MoteTypeCreationException) exception)
|
||||||
|
.getCompilationOutput();
|
||||||
} else if (exception != null
|
} else if (exception != null
|
||||||
&& exception.getCause() != null
|
&& exception.getCause() != null
|
||||||
&& exception.getCause() instanceof MoteTypeCreationException
|
&& exception.getCause() instanceof MoteTypeCreationException
|
||||||
&& ((MoteTypeCreationException) exception.getCause()).hasCompilationOutput()) {
|
&& ((MoteTypeCreationException) exception.getCause())
|
||||||
compilationOutput = ((MoteTypeCreationException) exception.getCause()).getCompilationOutput();
|
.hasCompilationOutput()) {
|
||||||
|
compilationOutput = ((MoteTypeCreationException) exception.getCause())
|
||||||
|
.getCompilationOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create error dialog
|
// Create error dialog
|
||||||
|
@ -3051,11 +3070,11 @@ public class GUI {
|
||||||
else if (parentComponent instanceof Frame)
|
else if (parentComponent instanceof Frame)
|
||||||
errorDialog = new JDialog((Frame) parentComponent, title, true);
|
errorDialog = new JDialog((Frame) parentComponent, title, true);
|
||||||
else if (parentComponent instanceof Window)
|
else if (parentComponent instanceof Window)
|
||||||
errorDialog = new JDialog((Window) parentComponent, title, ModalityType.APPLICATION_MODAL);
|
errorDialog = new JDialog((Window) parentComponent, title,
|
||||||
|
ModalityType.APPLICATION_MODAL);
|
||||||
else {
|
else {
|
||||||
logger.fatal("Bad parent for error dialog");
|
logger.fatal("Bad parent for error dialog");
|
||||||
errorDialog = new JDialog((Frame) null, title + " (Java stack trace)");
|
errorDialog = new JDialog((Frame) null, title + " (Java stack trace)");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final JPanel errorPanel = new JPanel();
|
final JPanel errorPanel = new JPanel();
|
||||||
|
@ -3063,7 +3082,8 @@ public class GUI {
|
||||||
errorPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
errorPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
||||||
Box messageBox = Box.createHorizontalBox();
|
Box messageBox = Box.createHorizontalBox();
|
||||||
|
|
||||||
// Icon myIcon = (Icon)DefaultLookup.get(errorPanel, null, "OptionPane.errorIcon");
|
// Icon myIcon = (Icon)DefaultLookup.get(errorPanel, null,
|
||||||
|
// "OptionPane.errorIcon");
|
||||||
// messageBox.add(new JLabel(myIcon));
|
// messageBox.add(new JLabel(myIcon));
|
||||||
messageBox.add(Box.createHorizontalGlue());
|
messageBox.add(Box.createHorizontalGlue());
|
||||||
messageBox.add(new JLabel(message));
|
messageBox.add(new JLabel(message));
|
||||||
|
@ -3080,8 +3100,10 @@ public class GUI {
|
||||||
|
|
||||||
JPanel messageListPanel = new JPanel(new BorderLayout());
|
JPanel messageListPanel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
messageListPanel.add(BorderLayout.CENTER, new JScrollPane(listToDisplay));
|
messageListPanel.add(BorderLayout.CENTER, new JScrollPane(
|
||||||
messageListPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
listToDisplay));
|
||||||
|
messageListPanel.setBorder(BorderFactory.createEmptyBorder(20, 20,
|
||||||
|
20, 20));
|
||||||
messageListPanel.setVisible(true);
|
messageListPanel.setVisible(true);
|
||||||
|
|
||||||
messageListDialog.getContentPane().add(messageListPanel);
|
messageListDialog.getContentPane().add(messageListPanel);
|
||||||
|
@ -3089,13 +3111,16 @@ public class GUI {
|
||||||
messageListDialog.pack();
|
messageListDialog.pack();
|
||||||
messageListDialog.setLocationRelativeTo(errorDialog);
|
messageListDialog.setLocationRelativeTo(errorDialog);
|
||||||
|
|
||||||
Rectangle maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
|
Rectangle maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||||
if (maxSize != null &&
|
.getMaximumWindowBounds();
|
||||||
(messageListDialog.getSize().getWidth() > maxSize.getWidth()
|
if (maxSize != null
|
||||||
|| messageListDialog.getSize().getHeight() > maxSize.getHeight())) {
|
&& (messageListDialog.getSize().getWidth() > maxSize.getWidth() || messageListDialog
|
||||||
|
.getSize().getHeight() > maxSize.getHeight())) {
|
||||||
Dimension newSize = new Dimension();
|
Dimension newSize = new Dimension();
|
||||||
newSize.height = Math.min((int) maxSize.getHeight(), (int) messageListDialog.getSize().getHeight());
|
newSize.height = Math.min((int) maxSize.getHeight(),
|
||||||
newSize.width = Math.min((int) maxSize.getWidth(), (int) messageListDialog.getSize().getWidth());
|
(int) messageListDialog.getSize().getHeight());
|
||||||
|
newSize.width = Math.min((int) maxSize.getWidth(),
|
||||||
|
(int) messageListDialog.getSize().getWidth());
|
||||||
messageListDialog.setSize(newSize);
|
messageListDialog.setSize(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3115,8 +3140,10 @@ public class GUI {
|
||||||
|
|
||||||
JPanel messageListPanel = new JPanel(new BorderLayout());
|
JPanel messageListPanel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
messageListPanel.add(BorderLayout.CENTER, new JScrollPane(listToDisplay));
|
messageListPanel.add(BorderLayout.CENTER, new JScrollPane(
|
||||||
messageListPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
listToDisplay));
|
||||||
|
messageListPanel.setBorder(BorderFactory.createEmptyBorder(20, 20,
|
||||||
|
20, 20));
|
||||||
messageListPanel.setVisible(true);
|
messageListPanel.setVisible(true);
|
||||||
|
|
||||||
messageListDialog.getContentPane().add(messageListPanel);
|
messageListDialog.getContentPane().add(messageListPanel);
|
||||||
|
@ -3124,13 +3151,16 @@ public class GUI {
|
||||||
messageListDialog.pack();
|
messageListDialog.pack();
|
||||||
messageListDialog.setLocationRelativeTo(errorDialog);
|
messageListDialog.setLocationRelativeTo(errorDialog);
|
||||||
|
|
||||||
Rectangle maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
|
Rectangle maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||||
if (maxSize != null &&
|
.getMaximumWindowBounds();
|
||||||
(messageListDialog.getSize().getWidth() > maxSize.getWidth()
|
if (maxSize != null
|
||||||
|| messageListDialog.getSize().getHeight() > maxSize.getHeight())) {
|
&& (messageListDialog.getSize().getWidth() > maxSize.getWidth() || messageListDialog
|
||||||
|
.getSize().getHeight() > maxSize.getHeight())) {
|
||||||
Dimension newSize = new Dimension();
|
Dimension newSize = new Dimension();
|
||||||
newSize.height = Math.min((int) maxSize.getHeight(), (int) messageListDialog.getSize().getHeight());
|
newSize.height = Math.min((int) maxSize.getHeight(),
|
||||||
newSize.width = Math.min((int) maxSize.getWidth(), (int) messageListDialog.getSize().getWidth());
|
(int) messageListDialog.getSize().getHeight());
|
||||||
|
newSize.width = Math.min((int) maxSize.getWidth(),
|
||||||
|
(int) messageListDialog.getSize().getWidth());
|
||||||
messageListDialog.setSize(newSize);
|
messageListDialog.setSize(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3140,6 +3170,17 @@ public class GUI {
|
||||||
buttonBox.add(showTraceButton);
|
buttonBox.add(showTraceButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (retryAvailable) {
|
||||||
|
JButton retryButton = new JButton("Retry");
|
||||||
|
retryButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
errorDialog.dispose();
|
||||||
|
errorDialog.setTitle("-RETRY-");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonBox.add(retryButton);
|
||||||
|
}
|
||||||
|
|
||||||
JButton closeButton = new JButton("Close");
|
JButton closeButton = new JButton("Close");
|
||||||
closeButton.addActionListener(new ActionListener() {
|
closeButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -3149,12 +3190,17 @@ public class GUI {
|
||||||
buttonBox.add(closeButton);
|
buttonBox.add(closeButton);
|
||||||
|
|
||||||
errorPanel.add(messageBox);
|
errorPanel.add(messageBox);
|
||||||
|
errorPanel.add(Box.createVerticalStrut(20));
|
||||||
errorPanel.add(buttonBox);
|
errorPanel.add(buttonBox);
|
||||||
|
|
||||||
errorDialog.getContentPane().add(errorPanel);
|
errorDialog.getContentPane().add(errorPanel);
|
||||||
errorDialog.pack();
|
errorDialog.pack();
|
||||||
errorDialog.setLocationRelativeTo(parentComponent);
|
errorDialog.setLocationRelativeTo(parentComponent);
|
||||||
errorDialog.setVisible(true);
|
errorDialog.setVisible(true);
|
||||||
|
|
||||||
|
if (errorDialog.getTitle().equals("-RETRY-"))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: ContikiMoteType.java,v 1.12 2007/05/10 17:01:02 fros4943 Exp $
|
* $Id: ContikiMoteType.java,v 1.13 2007/05/11 10:55:26 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.contikimote;
|
package se.sics.cooja.contikimote;
|
||||||
|
@ -42,7 +42,6 @@ import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.*;
|
||||||
import se.sics.cooja.MoteType.MoteTypeCreationException;
|
|
||||||
import se.sics.cooja.dialogs.MessageList;
|
import se.sics.cooja.dialogs.MessageList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: ContikiMoteTypeDialog.java,v 1.27 2007/05/10 17:02:04 fros4943 Exp $
|
* $Id: ContikiMoteTypeDialog.java,v 1.28 2007/05/11 10:55:26 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.contikimote;
|
package se.sics.cooja.contikimote;
|
||||||
|
@ -2062,7 +2062,8 @@ public class ContikiMoteTypeDialog extends JDialog {
|
||||||
GUI.showErrorDialog(
|
GUI.showErrorDialog(
|
||||||
myDialog,
|
myDialog,
|
||||||
"Mote type creation error",
|
"Mote type creation error",
|
||||||
ex
|
ex,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue