Skip to content

Commit

Permalink
Merge pull request #199 from DropSnorz/fix/welcome-view
Browse files Browse the repository at this point in the history
Fix various issues on the welcome dialog
  • Loading branch information
DropSnorz authored Aug 17, 2023
2 parents 5daa508 + 17e5f32 commit a36c1b1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,29 @@
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.Stack;

@Component
public class DialogManager {

@Autowired
private MainController mainController;

private JFXDialog dialog;
private Stack<JFXDialog> dialogStack = new Stack<>();

/**
* Creates a new dialog.
*
* @return
*/
public JFXDialog newDialog() {
dialog = new JFXDialog();
JFXDialog dialog = new JFXDialog();
dialog.setDialogContainer(mainController.getRootPane());
dialogStack.push(dialog);

dialog.setOnDialogClosed(e -> {
dialogStack.pop();
});

return dialog;
}
Expand Down Expand Up @@ -124,7 +131,7 @@ public JFXDialog newDialog(double width, double height, Node body, Node heading)
*/
public JFXDialog newDialog(JFXDialogLayout layout) {

newDialog();
JFXDialog dialog = newDialog();
dialog.setContent(layout);
return dialog;
}
Expand All @@ -143,6 +150,7 @@ public JFXDialog newSimpleInfoDialog(String title, String body) {
*/
public JFXDialog newSimpleInfoDialog(Node title, Node body) {
JFXDialogLayout layout = new JFXDialogLayout();
JFXDialog dialog = newDialog(layout);

layout.setHeading(title);
layout.setBody(body);
Expand All @@ -154,12 +162,12 @@ public JFXDialog newSimpleInfoDialog(Node title, Node body) {
});

layout.setActions(button);
return newDialog(layout);
return dialog;

}

public JFXDialog getDialog() {
return dialog;
return dialogStack.peek();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ public class ListDirectoryDialogController extends AbstractDialogController impl

@Autowired
private OptionsController optionsController;
@Autowired
private WelcomeDialogController welcomeDialogController;

@Autowired
private LazyViewRegistry lazyViewRegistry;

@FXML
private JFXButton addDirectoryButton;
@FXML
private ListView<String> directoryListView;
@FXML
private JFXButton closeButton;

private final String newDirectoryItem = "[New directory] (double-click to update)";
private String currentPreferenceKey;
Expand All @@ -56,6 +61,9 @@ public void initialize() {
observableItems.add(newDirectoryItem);
});
directoryListView.setCellFactory(TextFieldListCell.forListView());
closeButton.setOnAction(e -> {
this.close();
});
}

public void configure (String preferenceKey) {
Expand Down Expand Up @@ -87,6 +95,7 @@ public void onChanged(Change<? extends String> change) {
this.getPreferences().putList(currentPreferenceKey, prefList);

optionsController.refreshView();
welcomeDialogController.refreshView();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@
</children>
</HBox>
<ListView fx:id="directoryListView" editable="true" prefHeight="200.0" prefWidth="200.0" />
<HBox alignment="CENTER_RIGHT" prefHeight="50.0" spacing="10.0">
<children>
<JFXButton fx:id="closeButton" mnemonicParsing="false" text="Close" />
</children>
</HBox>
</children>
</VBox>

0 comments on commit a36c1b1

Please sign in to comment.