Filetreefix
This commit is contained in:
@@ -10,14 +10,17 @@ import com.google.common.eventbus.Subscribe;
|
||||
import app.events.CopyEvent;
|
||||
import app.events.CutEvent;
|
||||
import app.events.ExitApplicationEvent;
|
||||
import app.events.FileSelectedEvent;
|
||||
import app.events.LanguageChangedEvent;
|
||||
import app.events.OpenLinkInBrowserEvent;
|
||||
import app.events.OpenProjectEvent;
|
||||
import app.events.PasteEvent;
|
||||
import app.events.RedoEvent;
|
||||
import app.events.ThemeChangedEvent;
|
||||
import app.events.ToggleCommentEvent;
|
||||
import app.events.ToggleWrapTextEvent;
|
||||
import app.events.UndoEvent;
|
||||
import app.model.Model;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@@ -51,35 +54,34 @@ public class MenubarController implements Initializable, Controller {
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* FILE */
|
||||
/* FILE */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
@FXML
|
||||
public String handleOpenFile() {
|
||||
public void handleOpenFile() {
|
||||
FileChooser fc = new FileChooser();
|
||||
fc.setTitle("Open File");
|
||||
Stage stage = (Stage) menubar.getScene().getWindow();
|
||||
|
||||
File chosenFile = fc.showOpenDialog(stage);
|
||||
String corFormat = chosenFile.getAbsolutePath().replace("\\", "\\\\");
|
||||
System.out.println(chosenFile.getAbsolutePath());
|
||||
System.out.println(corFormat);
|
||||
String correctFormat = chosenFile.getAbsolutePath().replace("\\", "\\\\");
|
||||
|
||||
return corFormat;
|
||||
Model.setActiveFilePath(chosenFile.toPath());
|
||||
this.eventBus.post(new FileSelectedEvent(correctFormat));
|
||||
}
|
||||
|
||||
@FXML
|
||||
public String handleOpenProject() {
|
||||
private void handleOpenProject() {
|
||||
DirectoryChooser dc = new DirectoryChooser();
|
||||
dc.setTitle("Open Project");
|
||||
Stage stage = (Stage) menubar.getScene().getWindow();
|
||||
|
||||
File chosenDir = dc.showDialog(stage);
|
||||
String corFormat = chosenDir.getAbsolutePath().replace("\\", "\\\\");
|
||||
System.out.println(chosenDir.getAbsolutePath());
|
||||
System.out.println(corFormat);
|
||||
String correctFormat = chosenDir.getAbsolutePath().replace("\\", "\\\\");
|
||||
|
||||
Model.setProjectPath(chosenDir.toPath());
|
||||
this.eventBus.post(new OpenProjectEvent(correctFormat));
|
||||
|
||||
return corFormat;
|
||||
}
|
||||
|
||||
// @FXML
|
||||
@@ -98,13 +100,12 @@ public class MenubarController implements Initializable, Controller {
|
||||
|
||||
/**
|
||||
* Handles the event where the language was change from the menu.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@FXML
|
||||
private void handleLanguageChange(ActionEvent event) {
|
||||
this.eventBus.post(
|
||||
new LanguageChangedEvent(
|
||||
((RadioMenuItem) event.getSource()).getText()));
|
||||
this.eventBus.post(new LanguageChangedEvent(((RadioMenuItem) event.getSource()).getText()));
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -115,13 +116,12 @@ public class MenubarController implements Initializable, Controller {
|
||||
|
||||
@FXML
|
||||
private void handleThemeChange(ActionEvent event) {
|
||||
this.eventBus.post(
|
||||
new ThemeChangedEvent(
|
||||
((RadioMenuItem) event.getSource()).getText()));
|
||||
this.eventBus.post(new ThemeChangedEvent(((RadioMenuItem) event.getSource()).getText()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event where there was an exit request from the menu.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@FXML
|
||||
@@ -130,7 +130,7 @@ public class MenubarController implements Initializable, Controller {
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* EDIT */
|
||||
/* EDIT */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
@FXML
|
||||
@@ -164,7 +164,7 @@ public class MenubarController implements Initializable, Controller {
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ABOUT */
|
||||
/* ABOUT */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
@FXML
|
||||
@@ -174,23 +174,18 @@ public class MenubarController implements Initializable, Controller {
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* SUBSCRIPTIONS */
|
||||
/* SUBSCRIPTIONS */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* Updates menubuttons whenever the language is changed
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe
|
||||
private void handle(LanguageChangedEvent event) {
|
||||
this.languageToggleGroup
|
||||
.getToggles()
|
||||
.stream()
|
||||
.map(RadioMenuItem.class::cast)
|
||||
.filter(t -> t.getId().equals("toggle" + event.getLanguage()))
|
||||
.findFirst()
|
||||
.orElseThrow()
|
||||
.setSelected(true);
|
||||
this.languageToggleGroup.getToggles().stream().map(RadioMenuItem.class::cast)
|
||||
.filter(t -> t.getId().equals("toggle" + event.getLanguage())).findFirst().orElseThrow().setSelected(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user