[Zerofile-svn] SF.net SVN: zerofile: [44] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <el...@us...> - 2007-11-09 12:18:32
|
Revision: 44
http://zerofile.svn.sourceforge.net/zerofile/?rev=44&view=rev
Author: elpedr0
Date: 2007-11-09 04:18:29 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Working Save/load except for downloadpath and checkbox
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileSettings.java
trunk/src/ZeroFileSettingsWindow.java
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-09 10:30:52 UTC (rev 43)
+++ trunk/src/ZeroFile.java 2007-11-09 12:18:29 UTC (rev 44)
@@ -8,7 +8,6 @@
public static void main(String[] args) throws IOException {
ZeroFileMainWindow.startMainWindow();
ZeroFileChatWindow.startChatWindow();
- ZeroFileSettings.saveSettings();
ZeroFileSettings.loadSettings();
try
{
Modified: trunk/src/ZeroFileSettings.java
===================================================================
--- trunk/src/ZeroFileSettings.java 2007-11-09 10:30:52 UTC (rev 43)
+++ trunk/src/ZeroFileSettings.java 2007-11-09 12:18:29 UTC (rev 44)
@@ -5,33 +5,9 @@
import java.io.*;
public class ZeroFileSettings {
- //private static String _nickName;
- private static String _firstName;
- private static String _lastName;
- private static String _email;
- private static int _mainPort;
+
private static Properties _zeroFileProperties = new Properties();
- /*public static void saveSettings() throws IOException
- {
- // set up default properties
- Properties defaultProps = new Properties();
- FileInputStream defaultStream = new FileInputStream("defaultProperties");
- defaultProps.load(defaultStream);
- defaultStream.close();
-
- // set up real properties
- Properties applicationProps = new Properties(defaultProps);
- FileOutputStream appStream = new FileOutputStream("appProperties");
-
-
- applicationProps.put ( "HEIGHT","300" ) ;
- applicationProps.put ( "WIDTH","300" ) ;
-
-
- }*/
-
-
public static String getNickName()
{
if (_zeroFileProperties.containsKey("NickName"))
@@ -47,66 +23,66 @@
public static String getFirstName()
{
- return _firstName;
+ if (_zeroFileProperties.containsKey("FirstName"))
+ return _zeroFileProperties.getProperty("FirstName");
+ else
+ return "Anonymous";
}
public static void setFirstName(String f)
{
- _firstName = f;
+ _zeroFileProperties.put("FirstName", f);
}
public static String getLastName()
{
- return _lastName;
+ if (_zeroFileProperties.containsKey("LastName"))
+ return _zeroFileProperties.getProperty("LastName");
+ else
+ return "Anonymous";
}
public static void setLastName(String l)
{
- _lastName = l;
+ _zeroFileProperties.put("LastName", l);
}
public static String getEmail()
{
- return _email;
+ if (_zeroFileProperties.containsKey("Email"))
+ return _zeroFileProperties.getProperty("Email");
+ else
+ return "Ano...@an...";
}
public static void setEmail(String e)
{
- _email = e;
+ _zeroFileProperties.put("Email", e);
}
- public static int getMainPort()
- {
- return _mainPort;
+ public static String getMainPort() {
+ if (_zeroFileProperties.containsKey("Port"))
+ return _zeroFileProperties.getProperty("Port");
+ else
+ return "1337";
}
- public static void setMainPort(int p)
+ public static void setMainPort(String p)
{
- _mainPort = p;
+ _zeroFileProperties.put("Port", p);
}
public static void saveSettings() throws IOException {
-
- //Properties applicationProps = new Properties();
FileOutputStream appStream = new FileOutputStream("appProperties");
- _zeroFileProperties.put("first", "balle");
- //applicationProps.put("first", "balle");
- //applicationProps.put("last", "ballesson");
- _zeroFileProperties.store(appStream, "sttings");
- //applicationProps.store(appStream, "settings");
+ _zeroFileProperties.store(appStream, "settings");;
appStream.close();
}
public static void loadSettings() throws IOException {
- Properties applicationProps = new Properties();
FileInputStream appStream = new FileInputStream("appProperties");
- applicationProps.load(appStream);
- String key = "last";
- String val = applicationProps.getProperty ( key ) ;
- System.out.println ( val ) ;
- appStream.close();
+ _zeroFileProperties.load(appStream);
+ appStream.close();
}
-
}
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-09 10:30:52 UTC (rev 43)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-09 12:18:29 UTC (rev 44)
@@ -49,7 +49,7 @@
//Label + field for port parameter
JLabel portLabel = new JLabel("Port", JLabel.CENTER);
final JTextField portField = new JTextField();
- portField.setText(String.valueOf(ZeroFileSettings.getMainPort()));
+ portField.setText(ZeroFileSettings.getMainPort());
settingsWindowFrame.add(portLabel);
settingsWindowFrame.add(portField);
@@ -103,7 +103,7 @@
if(!emailField.getText().equals(""))
ZeroFileSettings.setEmail(emailField.getText());
if(!portField.getText().equals(""))
- ZeroFileSettings.setMainPort(Integer.valueOf(portField.getText()));
+ ZeroFileSettings.setMainPort(portField.getText());
try {
ZeroFileSettings.saveSettings();
} catch (IOException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|