removing strict dependency on project platform configuration files (cooja.config).
files are still used if existing.
This commit is contained in:
parent
4cc56a741d
commit
70a74f624a
5 changed files with 51 additions and 57 deletions
|
@ -24,7 +24,7 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: GUI.java,v 1.81 2008/09/29 13:02:15 fros4943 Exp $
|
||||
* $Id: GUI.java,v 1.82 2008/10/03 10:23:05 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -910,18 +910,6 @@ public class GUI extends Observable {
|
|||
logger.info("> Reparsing project directories and creating config");
|
||||
for (String projectDir : projectDirs) {
|
||||
logger.info(">> Adding: " + projectDir);
|
||||
|
||||
// Check if config file exists
|
||||
File configFile = new File(projectDir + File.separatorChar + PROJECT_CONFIG_FILENAME);
|
||||
if (!configFile.exists()) {
|
||||
logger.debug(">>> Creating empty cooja.config file");
|
||||
try {
|
||||
configFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
logger.fatal(">> Error when creating cooja.config file, aborting");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
gui.currentProjectDirs.add(new File(projectDir));
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ProjectConfig.java,v 1.2 2008/02/18 08:18:18 fros4943 Exp $
|
||||
* $Id: ProjectConfig.java,v 1.3 2008/10/03 10:23:33 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -135,10 +135,15 @@ public class ProjectConfig {
|
|||
*/
|
||||
public boolean appendProjectDir(File projectDir)
|
||||
throws FileNotFoundException, IOException {
|
||||
myProjectDirHistory.add(projectDir);
|
||||
|
||||
File projectConfig = new File(projectDir.getPath(),
|
||||
GUI.PROJECT_CONFIG_FILENAME);
|
||||
myProjectDirHistory.add(projectDir);
|
||||
return appendConfigFile(projectConfig);
|
||||
if (projectConfig.exists()) {
|
||||
return appendConfigFile(projectConfig);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,6 +232,11 @@ public class ProjectConfig {
|
|||
*/
|
||||
public boolean appendConfigFile(File propertyFile)
|
||||
throws FileNotFoundException, IOException {
|
||||
if (!propertyFile.exists()) {
|
||||
logger.warn("Trying to import non-existant project configuration");
|
||||
return true;
|
||||
}
|
||||
|
||||
FileInputStream in = new FileInputStream(propertyFile);
|
||||
return appendConfigStream(myConfig, in);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ContikiMoteTypeDialog.java,v 1.42 2008/03/19 09:41:03 fros4943 Exp $
|
||||
* $Id: ContikiMoteTypeDialog.java,v 1.43 2008/10/03 10:25:56 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.contikimote;
|
||||
|
@ -2132,9 +2132,7 @@ public class ContikiMoteTypeDialog extends JDialog {
|
|||
|
||||
// Check that all project directories are valid
|
||||
for (File projectDir : moteTypeProjectDirs) {
|
||||
File userProjectConfig = new File(projectDir.getPath(),
|
||||
GUI.PROJECT_CONFIG_FILENAME);
|
||||
if (!userProjectConfig.exists()) {
|
||||
if (!projectDir.exists()) {
|
||||
textProjectDirs.setBackground(Color.RED);
|
||||
textProjectDirs.setToolTipText("Invalid project directory: "
|
||||
+ projectDir);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ProjectDirectoriesDialog.java,v 1.7 2008/05/02 05:47:53 fros4943 Exp $
|
||||
* $Id: ProjectDirectoriesDialog.java,v 1.8 2008/10/03 10:26:16 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.dialogs;
|
||||
|
@ -383,7 +383,7 @@ public class ProjectDirectoriesDialog extends JDialog {
|
|||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new java.io.File("."));
|
||||
fc.setCurrentDirectory(new java.io.File(GUI.getExternalToolsSetting("PATH_CONTIKI")));
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
fc.setDialogTitle("Select project directory");
|
||||
|
||||
|
@ -446,34 +446,34 @@ public class ProjectDirectoriesDialog extends JDialog {
|
|||
return;
|
||||
}
|
||||
|
||||
File projectConfigFile = new File(projectDir.getPath(),
|
||||
GUI.PROJECT_CONFIG_FILENAME);
|
||||
if (!projectConfigFile.exists()) {
|
||||
|
||||
Object[] options = {"Create",
|
||||
"Cancel"};
|
||||
|
||||
int n = JOptionPane.showOptionDialog(
|
||||
this,
|
||||
"No " + GUI.PROJECT_CONFIG_FILENAME + " file exists in specified directory!"
|
||||
+ "\nCreate an empty " + GUI.PROJECT_CONFIG_FILENAME + " file?",
|
||||
"Create project directory configuration?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null, options, options[1]);
|
||||
|
||||
if (n == JOptionPane.NO_OPTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
projectConfigFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
logger.fatal("Could not create project directory configuration file: "
|
||||
+ projectConfigFile);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// File projectConfigFile = new File(projectDir.getPath(),
|
||||
// GUI.PROJECT_CONFIG_FILENAME);
|
||||
// if (!projectConfigFile.exists()) {
|
||||
//
|
||||
// Object[] options = {"Create",
|
||||
// "Cancel"};
|
||||
//
|
||||
// int n = JOptionPane.showOptionDialog(
|
||||
// this,
|
||||
// "No " + GUI.PROJECT_CONFIG_FILENAME + " file exists in specified directory!"
|
||||
// + "\nCreate an empty " + GUI.PROJECT_CONFIG_FILENAME + " file?",
|
||||
// "Create project directory configuration?",
|
||||
// JOptionPane.YES_NO_OPTION,
|
||||
// JOptionPane.QUESTION_MESSAGE,
|
||||
// null, options, options[1]);
|
||||
//
|
||||
// if (n == JOptionPane.NO_OPTION) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// projectConfigFile.createNewFile();
|
||||
// } catch (IOException e) {
|
||||
// logger.fatal("Could not create project directory configuration file: "
|
||||
// + projectConfigFile);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
changeableProjectsList.add(projectDir.getPath(), index);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import javax.swing.*;
|
|||
import javax.swing.event.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import se.sics.cooja.GUI;
|
||||
|
||||
class ProjectDirectoryInputDialog extends JDialog implements ActionListener, PropertyChangeListener {
|
||||
private static Logger logger = Logger.getLogger(ProjectDirectoryInputDialog.class);
|
||||
|
||||
|
@ -105,11 +103,11 @@ class ProjectDirectoryInputDialog extends JDialog implements ActionListener, Pro
|
|||
return;
|
||||
}
|
||||
|
||||
if (!new File(projectDir, GUI.PROJECT_CONFIG_FILENAME).exists()) {
|
||||
textField.setBackground(Color.LIGHT_GRAY);
|
||||
textField.setToolTipText("No configuration file found");
|
||||
return;
|
||||
}
|
||||
// if (!new File(projectDir, GUI.PROJECT_CONFIG_FILENAME).exists()) {
|
||||
// textField.setBackground(Color.LIGHT_GRAY);
|
||||
// textField.setToolTipText("No configuration file found");
|
||||
// return;
|
||||
// }
|
||||
|
||||
textField.setBackground(Color.WHITE);
|
||||
textField.setToolTipText("");
|
||||
|
|
Loading…
Reference in a new issue