Added asynchronous method execution support with libRefTools
This commit is contained in:
parent
99eebcdaa2
commit
458bc78b2e
11
.idea/libraries/libRefTools.xml
generated
Normal file
11
.idea/libraries/libRefTools.xml
generated
Normal file
@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="libRefTools">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/libs/libRefTools.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/libs/libRefTools.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
4
TAL.iml
4
TAL.iml
@ -7,6 +7,6 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="libRefTools" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
BIN
libs/libRefTools.jar
Normal file
BIN
libs/libRefTools.jar
Normal file
Binary file not shown.
@ -10,6 +10,7 @@ favour and pour yourself some nice Jack Daniels. You deserve it if you're going
|
||||
|
||||
package Launcher;
|
||||
|
||||
import com.tofvesson.reflection.SafeReflection;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
@ -22,6 +23,7 @@ import javafx.scene.shape.Rectangle;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import java.net.URL;
|
||||
import com.tofvesson.async.*;
|
||||
|
||||
public class Main extends Application {
|
||||
|
||||
@ -48,6 +50,7 @@ public class Main extends Application {
|
||||
primaryStage.getIcons().clear();
|
||||
primaryStage.getIcons().add(appIcon = new Image(getClass().getResourceAsStream("../assets/icons/app.png")));
|
||||
|
||||
|
||||
// Field initialization
|
||||
exit = (Button) root.lookup("#exit");
|
||||
min = (Button) root.lookup("#min");
|
||||
@ -60,12 +63,26 @@ public class Main extends Application {
|
||||
Search_modpacks_btn = (Button) root.lookup("#search-modpacks-btn");
|
||||
Search_modpacks = (TextField) root.lookup("#search-modpacks");
|
||||
|
||||
|
||||
// Infrastructural navigation
|
||||
exit.setOnMouseClicked(event -> primaryStage.close()); // Closes the program if exit button is clicked
|
||||
min.setOnMouseClicked(event -> primaryStage.setIconified(true)); // Minimizes the program if minimize button is clicked
|
||||
Home_btn.setOnMouseClicked(event -> {if(activeTab!=Tabs.Home)(activeTab=Tabs.Home).switchTab(tab);}); // Sets the active tab to the home tab unless it's already active
|
||||
Modpack_btn.setOnMouseClicked(event -> {if(activeTab!=Tabs.Modpacks)(activeTab=Tabs.Modpacks).switchTab(tab);});// Sets the active tab to the modpacks tab unless it's already active
|
||||
Settings_btn.setOnMouseClicked(event -> {if(activeTab!=Tabs.Settings)(activeTab=Tabs.Settings).switchTab(tab);});
|
||||
Home_btn.setOnMouseClicked(event ->{if(activeTab!=Tabs.Home)(activeTab=Tabs.Home).switchTab(tab);}); // Sets the active tab to the home tab unless it's already active
|
||||
Modpack_btn.setOnMouseClicked(event ->{
|
||||
if(activeTab!=Tabs.Modpacks){
|
||||
(activeTab=Tabs.Modpacks).switchTab(tab); // Sets the active tab to the modpacks tab unless it's already active
|
||||
Tabs.Modpacks.loaded.lookup("#search-modpacks").setOnInputMethodTextChanged(System.out::println);
|
||||
}
|
||||
});
|
||||
Settings_btn.setOnMouseClicked(event ->{
|
||||
if(activeTab!=Tabs.Settings){
|
||||
(activeTab=Tabs.Settings).switchTab(tab); // Sets the active tab to the settings tab unless it's already active
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Async a = new Async(null, SafeReflection.getMethod(getClass(), "run", (Class<?>[]) null), null);
|
||||
System.out.println(a.await());
|
||||
|
||||
// Drag
|
||||
dragBar.setOnMousePressed(event -> {
|
||||
@ -77,6 +94,7 @@ public class Main extends Application {
|
||||
primaryStage.setY(event.getScreenY() - yOffset);
|
||||
});
|
||||
|
||||
|
||||
// Set up default layout
|
||||
Tabs.Home.switchTab(tab);
|
||||
icon.setImage(appIcon);
|
||||
@ -86,5 +104,8 @@ public class Main extends Application {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
public static int run(){
|
||||
return 500;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,18 +10,25 @@ public enum Tabs {
|
||||
|
||||
Modpacks(Tabs.class.getResource("../assets/layout/modpacks.fxml")), Home(Tabs.class.getResource("../assets/layout/home.fxml")), Settings(Tabs.class.getResource("../assets/layout/settings.fxml"));
|
||||
|
||||
/**
|
||||
* Url referencing xml.
|
||||
*/
|
||||
public final URL url;
|
||||
private Parent loaded;
|
||||
|
||||
/**
|
||||
* Loaded layout
|
||||
*/
|
||||
public final Parent loaded;
|
||||
|
||||
Tabs(URL url){
|
||||
this.url = url;
|
||||
Parent p = null;
|
||||
try { p = FXMLLoader.load(url); } catch (IOException e) { e.printStackTrace(); }
|
||||
loaded = p;
|
||||
}
|
||||
|
||||
public void switchTab(Pane holder){
|
||||
holder.getChildren().clear();
|
||||
try {
|
||||
holder.getChildren().add(loaded==null?loaded=FXMLLoader.load(url):loaded);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
holder.getChildren().add(loaded);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user