load default config from class path instead of current directory
This commit is contained in:
parent
c32390ab76
commit
8c2765f0f7
|
@ -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: GUI.java,v 1.1 2006/08/21 12:12:51 fros4943 Exp $
|
* $Id: GUI.java,v 1.2 2006/08/22 08:56:08 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -77,7 +77,7 @@ public class GUI extends JDesktopPane {
|
||||||
/**
|
/**
|
||||||
* Default platform configuration filename.
|
* Default platform configuration filename.
|
||||||
*/
|
*/
|
||||||
public static final String PLATFORM_DEFAULT_CONFIG_FILENAME = "cooja_default.config";
|
public static final String PLATFORM_DEFAULT_CONFIG_FILENAME = "/cooja_default.config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User platform configuration filename.
|
* User platform configuration filename.
|
||||||
|
@ -565,11 +565,19 @@ public class GUI extends JDesktopPane {
|
||||||
// logger.info("Loading default platform configuration: " +
|
// logger.info("Loading default platform configuration: " +
|
||||||
// PLATFORM_DEFAULT_CONFIG_FILENAME);
|
// PLATFORM_DEFAULT_CONFIG_FILENAME);
|
||||||
try {
|
try {
|
||||||
platformConfig.appendConfig(new File(PLATFORM_DEFAULT_CONFIG_FILENAME));
|
InputStream input =
|
||||||
} catch (FileNotFoundException e) {
|
GUI.class.getResourceAsStream(PLATFORM_DEFAULT_CONFIG_FILENAME);
|
||||||
|
if (input != null) {
|
||||||
|
try {
|
||||||
|
platformConfig.appendConfig(input);
|
||||||
|
} finally {
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
logger.fatal("Could not find default platform config file: "
|
logger.fatal("Could not find default platform config file: "
|
||||||
+ PLATFORM_DEFAULT_CONFIG_FILENAME);
|
+ PLATFORM_DEFAULT_CONFIG_FILENAME);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.fatal("Error when reading default platform config file: "
|
logger.fatal("Error when reading default platform config file: "
|
||||||
+ PLATFORM_DEFAULT_CONFIG_FILENAME);
|
+ PLATFORM_DEFAULT_CONFIG_FILENAME);
|
||||||
|
|
|
@ -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: UserPlatformsDialog.java,v 1.1 2006/08/21 12:13:02 fros4943 Exp $
|
* $Id: UserPlatformsDialog.java,v 1.2 2006/08/22 08:56:08 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.dialogs;
|
package se.sics.cooja.dialogs;
|
||||||
|
@ -36,10 +36,10 @@ import java.awt.event.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import se.sics.cooja.GUI;
|
import se.sics.cooja.GUI;
|
||||||
|
@ -223,11 +223,19 @@ public class UserPlatformsDialog extends JDialog {
|
||||||
// Create default configuration
|
// Create default configuration
|
||||||
PlatformConfig config = new PlatformConfig();
|
PlatformConfig config = new PlatformConfig();
|
||||||
try {
|
try {
|
||||||
config.appendConfig(new File(GUI.PLATFORM_DEFAULT_CONFIG_FILENAME));
|
InputStream input =
|
||||||
} catch (FileNotFoundException ex) {
|
GUI.class.getResourceAsStream(GUI.PLATFORM_DEFAULT_CONFIG_FILENAME);
|
||||||
logger.fatal("Could not find default platform config file: "
|
if (input != null) {
|
||||||
|
try {
|
||||||
|
config.appendConfig(input);
|
||||||
|
} finally {
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.fatal("Could not find default platform config file1: "
|
||||||
+ GUI.PLATFORM_DEFAULT_CONFIG_FILENAME);
|
+ GUI.PLATFORM_DEFAULT_CONFIG_FILENAME);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.fatal("Error when reading default platform config file: "
|
logger.fatal("Error when reading default platform config file: "
|
||||||
+ GUI.PLATFORM_DEFAULT_CONFIG_FILENAME);
|
+ GUI.PLATFORM_DEFAULT_CONFIG_FILENAME);
|
||||||
|
|
Loading…
Reference in a new issue