added some functionality like save compilation output + updated initial scan to the testapps directory

This commit is contained in:
fros4943 2007-11-25 23:32:05 +00:00
parent 7acad03398
commit 6012ef9c21

View file

@ -26,12 +26,14 @@
* 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.36 2007/09/28 07:21:22 fros4943 Exp $ * $Id: ContikiMoteTypeDialog.java,v 1.37 2007/11/25 23:32:05 fros4943 Exp $
*/ */
package se.sics.cooja.contikimote; package se.sics.cooja.contikimote;
import java.awt.*; import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.*; import java.awt.event.*;
import java.io.*; import java.io.*;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -702,6 +704,11 @@ public class ContikiMoteTypeDialog extends JDialog {
label = new JLabel("Communication stack"); label = new JLabel("Communication stack");
commStackComboBox = new JComboBox(CommunicationStack.values()); commStackComboBox = new JComboBox(CommunicationStack.values());
commStackComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createButton.setEnabled(libraryCreatedOK = false);
}
});
commStackComboBox.setSelectedIndex(0); commStackComboBox.setSelectedIndex(0);
smallPane.add(label); smallPane.add(label);
@ -1013,11 +1020,12 @@ public class ContikiMoteTypeDialog extends JDialog {
taskOutput = new MessageList(); taskOutput = new MessageList();
final Thread compilationThreadCopy = compilationThread;
button = new JButton("Close/Abort"); button = new JButton("Close/Abort");
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (compilationThread != null && compilationThread.isAlive()) { if (compilationThreadCopy != null && compilationThreadCopy.isAlive()) {
compilationThread.interrupt(); compilationThreadCopy.interrupt();
} }
if (progressDialog != null && progressDialog.isDisplayable()) { if (progressDialog != null && progressDialog.isDisplayable()) {
progressDialog.dispose(); progressDialog.dispose();
@ -1025,6 +1033,54 @@ public class ContikiMoteTypeDialog extends JDialog {
} }
}); });
final JPopupMenu popup = new JPopupMenu();
JMenuItem headerMenuItem = new JMenuItem("Compilation output:");
headerMenuItem.setEnabled(false);
popup.add(headerMenuItem);
popup.add(new JSeparator());
JMenuItem consoleOutputMenuItem = new JMenuItem("Output to console");
consoleOutputMenuItem.setEnabled(true);
consoleOutputMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int nrRows = taskOutput.getModel().getSize();
System.out.println("\nCOMPILATION OUTPUT:\n");
for (int n=0; n < nrRows; n++) {
System.out.println(taskOutput.getModel().getElementAt(n));
}
System.out.println();
}
});
popup.add(consoleOutputMenuItem);
JMenuItem clipboardMenuItem = new JMenuItem("Copy to clipboard");
clipboardMenuItem.setEnabled(true);
clipboardMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String output = "";
int nrRows = taskOutput.getModel().getSize();
for (int n=0; n < nrRows; n++) {
output += taskOutput.getModel().getElementAt(n) + "\n";
}
StringSelection stringSelection = new StringSelection(output);
clipboard.setContents(stringSelection, null);
logger.info("Output copied to clipboard");
}
});
popup.add(clipboardMenuItem);
taskOutput.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e)) {
popup.show(taskOutput, e.getX(), e.getY());
}
}
});
progressPanel.add(BorderLayout.CENTER, new JScrollPane(taskOutput)); progressPanel.add(BorderLayout.CENTER, new JScrollPane(taskOutput));
progressPanel.add(BorderLayout.NORTH, progressBar); progressPanel.add(BorderLayout.NORTH, progressBar);
progressPanel.add(BorderLayout.SOUTH, button); progressPanel.add(BorderLayout.SOUTH, button);
@ -1110,7 +1166,13 @@ public class ContikiMoteTypeDialog extends JDialog {
// Add all project directories // Add all project directories
compilationFiles = (Vector<File>) myGUI compilationFiles = (Vector<File>) myGUI
.getProjectDirs().clone(); .getProjectDirs().clone();
compilationFiles.addAll(moteTypeProjectDirs);
if (moteTypeProjectDirs == null || moteTypeProjectDirs.isEmpty()) {
compilationFiles.add(new File(textCoreDir.getText(), "testapps"));
} else {
compilationFiles.addAll(moteTypeProjectDirs);
}
// Add source files from project configs // Add source files from project configs
String[] projectSourceFiles = newMoteTypeConfig.getStringArrayValue( String[] projectSourceFiles = newMoteTypeConfig.getStringArrayValue(
@ -1135,9 +1197,9 @@ public class ContikiMoteTypeDialog extends JDialog {
// Add selected process source files // Add selected process source files
for (Component checkBox : processPanel.getComponents()) { for (Component checkBox : processPanel.getComponents()) {
if (((JCheckBox) checkBox).isSelected()) { if (((JCheckBox) checkBox).isSelected()) {
String processName = ((JCheckBox) checkBox).getToolTipText(); String fileName = ((JCheckBox) checkBox).getToolTipText();
if (processName != null) { if (fileName != null) {
compilationFiles.add(new File(processName)); compilationFiles.add(new File(fileName));
} }
} }
} }
@ -2276,19 +2338,24 @@ public class ContikiMoteTypeDialog extends JDialog {
processPanel.removeAll(); processPanel.removeAll();
Vector<String[]> processes = new Vector<String[]>(); Vector<String[]> processes = new Vector<String[]>();
// Scan core platform for processes /* Scan GUI project directories */
processes.addAll(ContikiMoteTypeDialog.scanForProcesses(new File(
textCoreDir.getText())));
// If project directories exists, scan those too
for (File projectDir : myGUI.getProjectDirs()) { for (File projectDir : myGUI.getProjectDirs()) {
processes processes
.addAll(ContikiMoteTypeDialog.scanForProcesses(projectDir)); .addAll(ContikiMoteTypeDialog.scanForProcesses(projectDir));
} }
if (moteTypeProjectDirs != null) {
for (File projectDir : moteTypeProjectDirs) { /* If mote type specific project directories, scan the testapps directory */
processes.addAll(ContikiMoteTypeDialog if (moteTypeProjectDirs == null || moteTypeProjectDirs.isEmpty()) {
.scanForProcesses(projectDir)); logger.info("No project directories selected, scanning testapps");
processes.addAll(ContikiMoteTypeDialog.scanForProcesses(new File(
textCoreDir.getText(), "testapps")));
} else {
if (moteTypeProjectDirs != null) {
for (File projectDir : moteTypeProjectDirs) {
logger.info("Scanning " + projectDir.getPath());
processes.addAll(ContikiMoteTypeDialog
.scanForProcesses(projectDir));
}
} }
} }