minor fix: only reset dialogstate if mote type is not loaded

This commit is contained in:
fros4943 2009-03-12 13:20:58 +00:00
parent 063bf88f90
commit a17e7d109a

View file

@ -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: AbstractCompileDialog.java,v 1.4 2009/03/11 18:18:57 fros4943 Exp $ * $Id: AbstractCompileDialog.java,v 1.5 2009/03/12 13:20:58 fros4943 Exp $
*/ */
package se.sics.cooja.dialogs; package se.sics.cooja.dialogs;
@ -286,9 +286,8 @@ public abstract class AbstractCompileDialog extends JDialog {
} }
}); });
setDialogState(DialogState.NO_SELECTION);
/* Restore old configuration if mote type is already configured */ /* Restore old configuration if mote type is already configured */
boolean restoredDialogState = false;
if (moteType != null) { if (moteType != null) {
/* Restore description */ /* Restore description */
if (moteType.getDescription() != null) { if (moteType.getDescription() != null) {
@ -299,9 +298,11 @@ public abstract class AbstractCompileDialog extends JDialog {
if (moteType.getContikiSourceFile() != null) { if (moteType.getContikiSourceFile() != null) {
contikiField.setText(moteType.getContikiSourceFile().getAbsolutePath()); contikiField.setText(moteType.getContikiSourceFile().getAbsolutePath());
setDialogState(DialogState.SELECTED_SOURCE); setDialogState(DialogState.SELECTED_SOURCE);
restoredDialogState = true;
} else if (moteType.getContikiFirmwareFile() != null) { } else if (moteType.getContikiFirmwareFile() != null) {
contikiField.setText(moteType.getContikiFirmwareFile().getAbsolutePath()); contikiField.setText(moteType.getContikiFirmwareFile().getAbsolutePath());
setDialogState(DialogState.SELECTED_FIRMWARE); setDialogState(DialogState.SELECTED_FIRMWARE);
restoredDialogState = true;
} }
/* Restore mote interface classes */ /* Restore mote interface classes */
@ -315,8 +316,12 @@ public abstract class AbstractCompileDialog extends JDialog {
if (moteType.getCompileCommands() != null) { if (moteType.getCompileCommands() != null) {
setCompileCommands(moteType.getCompileCommands()); setCompileCommands(moteType.getCompileCommands());
setDialogState(DialogState.AWAITING_COMPILATION); setDialogState(DialogState.AWAITING_COMPILATION);
restoredDialogState = true;
} }
} }
if (!restoredDialogState) {
setDialogState(DialogState.NO_SELECTION);
}
descriptionField.requestFocus(); descriptionField.requestFocus();
descriptionField.select(0, descriptionField.getText().length()); descriptionField.select(0, descriptionField.getText().length());