gui fixes: allow editing external tools settings, hide advanced tab (not used yet) etc

This commit is contained in:
fros4943 2009-03-11 18:18:57 +00:00
parent d26ba2606b
commit 3a2718279b
2 changed files with 62 additions and 6 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: AbstractCompileDialog.java,v 1.3 2009/03/11 13:27:51 fros4943 Exp $
* $Id: AbstractCompileDialog.java,v 1.4 2009/03/11 18:18:57 fros4943 Exp $
*/
package se.sics.cooja.dialogs;
@ -46,6 +46,8 @@ import org.apache.log4j.Logger;
import se.sics.cooja.*;
import se.sics.cooja.dialogs.MessageList;
import se.sics.cooja.interfaces.MoteID;
import se.sics.cooja.interfaces.Position;
/**
* Abstract configure mote type dialog used by Contiki-based mote type implementations.
@ -543,6 +545,7 @@ public abstract class AbstractCompileDialog extends JDialog {
break;
case SELECTED_FIRMWARE:
contikiSource = null;
contikiFirmware = new File(contikiField.getText());
if (!contikiFirmware.exists()) {
setDialogState(DialogState.NO_SELECTION);
@ -583,7 +586,10 @@ public abstract class AbstractCompileDialog extends JDialog {
private void addMoteInterfacesTab(JTabbedPane parent) {
moteIntfBox = Box.createVerticalBox();
parent.addTab("Mote interfaces", null, new JScrollPane(moteIntfBox), "Mote interfaces");
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.NORTH, new JLabel("COOJA interacts with simulated motes via mote interfaces. You normally do not need to change these settings!"));
panel.add(BorderLayout.CENTER, new JScrollPane(moteIntfBox));
parent.addTab("Mote interfaces", null, panel, "Mote interfaces");
}
/**
@ -649,11 +655,28 @@ public abstract class AbstractCompileDialog extends JDialog {
intfCheckBox.setSelected(selected);
intfCheckBox.putClientProperty("class", intfClass);
intfCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
intfCheckBox.setToolTipText(intfClass.getName());
intfCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setDialogState(DialogState.AWAITING_COMPILATION);
if (contikiSource == null &&
contikiFirmware != null) {
setDialogState(DialogState.SELECTED_FIRMWARE);
} else if (contikiSource != null){
setDialogState(DialogState.AWAITING_COMPILATION);
} else {
setDialogState(DialogState.SELECTED_SOURCE);
}
}
});
/* Always select position and ID interface */
if (intfClass == Position.class ||
intfClass == MoteID.class) {
intfCheckBox.setEnabled(false);
intfCheckBox.setSelected(true);
}
moteIntfBox.add(intfCheckBox);
}

View file

@ -26,25 +26,32 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ContikiMoteCompileDialog.java,v 1.1 2009/03/10 21:21:44 fros4943 Exp $
* $Id: ContikiMoteCompileDialog.java,v 1.2 2009/03/11 18:18:57 fros4943 Exp $
*/
package se.sics.cooja.dialogs;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import se.sics.cooja.CoreComm;
import se.sics.cooja.GUI;
import se.sics.cooja.MoteInterface;
import se.sics.cooja.MoteType;
import se.sics.cooja.ProjectConfig;
@ -87,7 +94,7 @@ public class ContikiMoteCompileDialog extends AbstractCompileDialog {
/* Add Contiki mote type specifics */
addMoteInterfaceClasses();
addAdvancedTab(tabbedPane);
/* TODO addAdvancedTab(tabbedPane);*/
}
public boolean canLoadFirmware(File file) {
@ -244,7 +251,33 @@ public class ContikiMoteCompileDialog extends AbstractCompileDialog {
}
};
parent.addTab("Environment", null, new JScrollPane(table), "Environment variables");
JPanel panel = new JPanel(new BorderLayout());
JButton button = new JButton("Change environment variables: Open external tools dialog");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/* Show external tools dialog */
ExternalToolsDialog.showDialog(GUI.getTopParentContainer());
/* Update and select environment tab */
SwingUtilities.invokeLater(new Runnable() {
public void run() {
getDefaultCompileCommands(((ContikiMoteType)moteType).getContikiSourceFile());
for (int i=0; i < tabbedPane.getTabCount(); i++) {
if (tabbedPane.getTitleAt(i).equals("Environment")) {
tabbedPane.setSelectedIndex(i);
break;
}
}
setDialogState(DialogState.AWAITING_COMPILATION);
}
});
}
});
panel.add(BorderLayout.NORTH, button);
panel.add(BorderLayout.CENTER, new JScrollPane(table));
parent.addTab("Environment", null, panel, "Environment variables");
}
public void writeSettingsToMoteType() {