-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="jfxrt" level="project" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package controller; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.layout.GridPane; | ||
import model.Identity; | ||
|
||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.nio.file.Paths; | ||
import java.util.ResourceBundle; | ||
|
||
public abstract class BaseController implements Initializable { | ||
|
||
@FXML | ||
protected GridPane app; | ||
|
||
protected Identity identity; | ||
|
||
protected String viewURL; | ||
|
||
@Override | ||
public void initialize(URL url, ResourceBundle resourceBundle) { | ||
identity = Identity.getInstance(); | ||
|
||
// Na začiatku si načítame URL | ||
viewURL = System.getProperty("user.dir") + "/src/view/"; | ||
} | ||
|
||
/** | ||
* Logs out user | ||
*/ | ||
protected void logout() { | ||
identity.logOut(); | ||
identity = Identity.getInstance(); | ||
switchScene( "login"); | ||
} | ||
|
||
/** | ||
* Switches between different scenes | ||
* @param view scene to be viewed | ||
* */ | ||
public void switchScene(String view) { | ||
/* | ||
if (identity != null) { | ||
System.out.println("Identity: " + identity.getUsername()); | ||
} else { | ||
System.out.println("No identity"); | ||
} | ||
*/ | ||
|
||
try { | ||
// Odstránime obsah view, ktorý je momentálne zobrazený | ||
app.getChildren().clear(); | ||
|
||
// Absolútna URL k danému fxml súboru | ||
URL fxmlURL = getLocation(view); | ||
|
||
// Vymeníme za nový obsah | ||
app.getChildren().add(FXMLLoader.load(fxmlURL)); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
protected URL getLocation (String view) throws MalformedURLException { | ||
return Paths.get(viewURL + view + ".fxml").toUri().toURL(); | ||
} | ||
} |