added change username
This commit is contained in:
parent
290ec96270
commit
b355c8a5d3
1
fmframework/src/.gitignore
vendored
Normal file
1
fmframework/src/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/org/
|
3
fmframework/src/META-INF/MANIFEST.MF
Normal file
3
fmframework/src/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Class-Path:
|
||||||
|
|
49
fmframework/src/sarsoo/fmframework/file/Persister.java
Normal file
49
fmframework/src/sarsoo/fmframework/file/Persister.java
Normal file
@ -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<T> {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,7 +34,7 @@ public class FMObjListTab extends Tab {
|
|||||||
|
|
||||||
setContent(pane);
|
setContent(pane);
|
||||||
|
|
||||||
setText("list");
|
setText(list.getGroupName());
|
||||||
|
|
||||||
FMObjListPaneController control = (FMObjListPaneController) loader.getController();
|
FMObjListPaneController control = (FMObjListPaneController) loader.getController();
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ public class FmFramework extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws Exception {
|
public void start(Stage stage) throws Exception {
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
|
Reference.setUserName("sarsoo");
|
||||||
|
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("ui/main.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("ui/main.fxml"));
|
||||||
|
|
||||||
@ -30,12 +31,13 @@ public class FmFramework extends Application {
|
|||||||
|
|
||||||
rootScene = scene;
|
rootScene = scene;
|
||||||
// scene.getStylesheets().add("styles/style.css");
|
// scene.getStylesheets().add("styles/style.css");
|
||||||
|
|
||||||
|
|
||||||
control = (ControllerMain)loader.getController();
|
control = (ControllerMain)loader.getController();
|
||||||
// (new Thread(new TagCaller())).start();
|
// (new Thread(new TagCaller())).start();
|
||||||
stage.setMinHeight(800);
|
stage.setMinHeight(800);
|
||||||
stage.setMinWidth(960);
|
stage.setMinWidth(960);
|
||||||
stage.setTitle("fm framework");
|
stage.setTitle("fmframework");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class ControllerMain {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
Reference.setUserName("sarsoo");
|
// Reference.setUserName("sarsoo");
|
||||||
|
|
||||||
Reference.setVerbose(TextAreaConsole.getInstance());
|
Reference.setVerbose(TextAreaConsole.getInstance());
|
||||||
|
|
||||||
@ -443,6 +443,50 @@ public class ControllerMain {
|
|||||||
refresh();
|
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<Void> service = new Service<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Task<Void> createTask() {
|
||||||
|
return new Task<Void>() {
|
||||||
|
@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
|
@FXML
|
||||||
protected void handleLookupAlbum(ActionEvent event) throws IOException {
|
protected void handleLookupAlbum(ActionEvent event) throws IOException {
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" />
|
<MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" />
|
||||||
<MenuItem fx:id="menuItemCurrentTrack" mnemonicParsing="false" onAction="#handleCurrentTrack" text="current track" />
|
<MenuItem fx:id="menuItemCurrentTrack" mnemonicParsing="false" onAction="#handleCurrentTrack" text="current track" />
|
||||||
<MenuItem fx:id="menuItemOpenConsole" mnemonicParsing="false" onAction="#handleOpenConsole" text="open console" />
|
<MenuItem fx:id="menuItemOpenConsole" mnemonicParsing="false" onAction="#handleOpenConsole" text="open console" />
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#handleChangeUsername" text="set username" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
|
@ -1,9 +1,36 @@
|
|||||||
package sarsoo.fmframework.util;
|
package sarsoo.fmframework.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import sarsoo.fmframework.file.Persister;
|
||||||
import sarsoo.fmframework.music.Track;
|
import sarsoo.fmframework.music.Track;
|
||||||
|
|
||||||
public class Scrobbler {
|
public class Scrobbler {
|
||||||
|
|
||||||
|
private String token;
|
||||||
|
private String sessionKey;
|
||||||
|
|
||||||
|
public Scrobbler() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void auth() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public int scrobble(Track track) {
|
public int scrobble(Track track) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveSessionKey(File file) {
|
||||||
|
|
||||||
|
Persister<String> persist = new Persister<String>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user