diff --git a/fmframework/src/.gitignore b/fmframework/src/.gitignore new file mode 100644 index 0000000..cf1db2e --- /dev/null +++ b/fmframework/src/.gitignore @@ -0,0 +1 @@ +/org/ diff --git a/fmframework/src/META-INF/MANIFEST.MF b/fmframework/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..5e94951 --- /dev/null +++ b/fmframework/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/fmframework/src/sarsoo/fmframework/file/Persister.java b/fmframework/src/sarsoo/fmframework/file/Persister.java new file mode 100644 index 0000000..1c77206 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/file/Persister.java @@ -0,0 +1,49 @@ +package sarsoo.fmframework.file; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import sarsoo.fmframework.util.FMObjList; + +public class Persister { + + public void saveToFile(File file, T obj) { + ObjectOutputStream out = null; + try { + + out = new ObjectOutputStream(new BufferedOutputStream( + new FileOutputStream(file))); + + out.writeObject(obj); + out.close(); + + }catch(Exception e) { + e.printStackTrace(); + } + } + + public T readFromFile(File file) { + + ObjectInputStream in = null; + T obj = null; + try { + + in = new ObjectInputStream(new BufferedInputStream( + new FileInputStream(file))); + obj = (T)in.readObject(); + + in.close(); + + }catch(Exception e) { + e.printStackTrace(); + } + + return obj; + } + +} diff --git a/fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java b/fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java index 9784115..c53fa8c 100644 --- a/fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java +++ b/fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java @@ -34,7 +34,7 @@ public class FMObjListTab extends Tab { setContent(pane); - setText("list"); + setText(list.getGroupName()); FMObjListPaneController control = (FMObjListPaneController) loader.getController(); diff --git a/fmframework/src/sarsoo/fmframework/fx/FmFramework.java b/fmframework/src/sarsoo/fmframework/fx/FmFramework.java index b3c5df2..f91fe59 100644 --- a/fmframework/src/sarsoo/fmframework/fx/FmFramework.java +++ b/fmframework/src/sarsoo/fmframework/fx/FmFramework.java @@ -20,6 +20,7 @@ public class FmFramework extends Application { @Override public void start(Stage stage) throws Exception { this.stage = stage; + Reference.setUserName("sarsoo"); FXMLLoader loader = new FXMLLoader(getClass().getResource("ui/main.fxml")); @@ -30,12 +31,13 @@ public class FmFramework extends Application { rootScene = scene; // scene.getStylesheets().add("styles/style.css"); - + + control = (ControllerMain)loader.getController(); // (new Thread(new TagCaller())).start(); stage.setMinHeight(800); stage.setMinWidth(960); - stage.setTitle("fm framework"); + stage.setTitle("fmframework"); stage.setScene(scene); stage.show(); diff --git a/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java b/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java index 425aa13..aa073bb 100644 --- a/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java +++ b/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java @@ -55,7 +55,7 @@ public class ControllerMain { @FXML public void initialize() { - Reference.setUserName("sarsoo"); +// Reference.setUserName("sarsoo"); Reference.setVerbose(TextAreaConsole.getInstance()); @@ -443,6 +443,50 @@ public class ControllerMain { refresh(); } } + + @FXML + protected void handleChangeUsername(ActionEvent event) throws IOException { +// System.out.println("USERNAME"); +// String username = JOptionPane.showInputDialog("enter username:"); +// if(username != null) { +// Reference.setUserName(username); +// } +// refresh(); + + Service service = new Service() { + @Override + protected Task createTask() { + return new Task() { + @Override + protected Void call() throws Exception { + + System.out.println("USERNAME"); + String username = JOptionPane.showInputDialog("enter username:"); + if(username != null) { + Reference.setUserName(username); + + + final CountDownLatch latch = new CountDownLatch(1); + Platform.runLater(new Runnable() { + @Override + public void run() { + try { + refresh(); + } finally { + latch.countDown(); + } + } + }); + latch.await(); + } + // Keep with the background work + return null; + } + }; + } + }; + service.start(); + } @FXML protected void handleLookupAlbum(ActionEvent event) throws IOException { diff --git a/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml b/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml index 2dd515c..4134de9 100644 --- a/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml +++ b/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml @@ -29,6 +29,7 @@ + diff --git a/fmframework/src/sarsoo/fmframework/util/Scrobbler.java b/fmframework/src/sarsoo/fmframework/util/Scrobbler.java index e7488cf..61d4484 100644 --- a/fmframework/src/sarsoo/fmframework/util/Scrobbler.java +++ b/fmframework/src/sarsoo/fmframework/util/Scrobbler.java @@ -1,9 +1,36 @@ package sarsoo.fmframework.util; +import java.io.File; + +import sarsoo.fmframework.file.Persister; import sarsoo.fmframework.music.Track; public class Scrobbler { + + private String token; + private String sessionKey; + + public Scrobbler() { + + + + } + + public void auth() { + + + + } + public int scrobble(Track track) { return 0; } + + public void saveSessionKey(File file) { + + Persister persist = new Persister(); + + + + } }