use of javafx.event.ActionEvent in project SmartCity-Market by TechnionYP5777.
the class DialogMessagesService method alertCreator.
private static void alertCreator(String title, String header, String content) {
JFXDialogLayout dialogContent = new JFXDialogLayout();
dialogContent.setHeading(new Text(header == null ? title : title + "\n" + header));
dialogContent.setBody(new Text(content));
JFXButton close = new JFXButton("Close");
close.getStyleClass().add("JFXButton");
dialogContent.setActions(close);
JFXDialog dialog = new JFXDialog((StackPane) AbstractApplicationScreen.stage.getScene().getRoot(), dialogContent, JFXDialog.DialogTransition.CENTER);
close.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent __) {
dialog.close();
}
});
dialog.show();
}
use of javafx.event.ActionEvent in project SmartCity-Market by TechnionYP5777.
the class ManageCatalogProductDetailsTab method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
createManufacturerList();
createIngredientList();
filterManu.textProperty().addListener(obs -> {
String filter = filterManu.getText();
filteredDataManu.setPredicate(filter == null || filter.length() == 0 ? s -> true : s -> s.contains(filter));
});
manufacturerList.setCellFactory(CheckBoxListCell.forListView(new Callback<String, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(String item) {
BooleanProperty observable = new SimpleBooleanProperty();
observable.set(selectedManu.contains(item));
observable.addListener((obs, wasSelected, isNowSelected) -> {
if (isNowSelected)
selectedManu.add(item);
else
selectedManu.remove(item);
enableButtons();
});
return observable;
}
}));
filterIngr.textProperty().addListener(obs -> {
String filter = filterIngr.getText();
filteredDataIngr.setPredicate(filter == null || filter.length() == 0 ? s -> true : s -> s.contains(filter));
});
ingredientsList.setCellFactory(CheckBoxListCell.forListView(new Callback<String, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(String item) {
BooleanProperty observable = new SimpleBooleanProperty();
observable.set(selectedIngr.contains(item));
observable.addListener((obs, wasSelected, isNowSelected) -> {
if (isNowSelected)
selectedIngr.add(item);
else
selectedIngr.remove(item);
enableButtons();
});
return observable;
}
}));
Label lbl1 = new Label("Insert New Manufacturar");
newManu = new JFXTextField();
okNewManu = new JFXButton("Done!");
okNewManu.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent __) {
addManuPressed();
}
});
VBox manuContainer = new VBox();
manuContainer.getChildren().addAll(lbl1, newManu, okNewManu);
manuContainer.setPadding(new Insets(10, 50, 50, 50));
manuContainer.setSpacing(10);
JFXPopup popup1 = new JFXPopup(manuContainer);
addManuBtn.setOnMouseClicked(e -> popup1.show(addManuBtn, PopupVPosition.TOP, PopupHPosition.LEFT));
newManu.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
Label lbl2 = new Label("Insert New Ingredient");
newIngr = new JFXTextField();
okNewIngr = new JFXButton("Done!");
okNewIngr.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent __) {
addIngPressed();
}
});
VBox ingrContainer = new VBox();
ingrContainer.getChildren().addAll(lbl2, newIngr, okNewIngr);
ingrContainer.setPadding(new Insets(10, 50, 50, 50));
ingrContainer.setSpacing(10);
JFXPopup popup2 = new JFXPopup(ingrContainer);
addIngrBtn.setOnMouseClicked(e -> popup2.show(addIngrBtn, PopupVPosition.TOP, PopupHPosition.LEFT));
newIngr.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
Label lbl3 = new Label("Rename Selected Manufacturar");
renameManuLbl = new JFXTextField();
okRenameManu = new JFXButton("Done!");
okRenameManu.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent __) {
renameManuPressed();
}
});
VBox renameManuContainer = new VBox();
renameManuContainer.getChildren().addAll(lbl3, renameManuLbl, okRenameManu);
renameManuContainer.setPadding(new Insets(10, 50, 50, 50));
renameManuContainer.setSpacing(10);
JFXPopup popup3 = new JFXPopup(renameManuContainer);
renameManu.setOnMouseClicked(e -> popup3.show(renameManu, PopupVPosition.TOP, PopupHPosition.LEFT));
renameManuLbl.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
Label lbl4 = new Label("Rename Selected Ingredient");
renameIngrLbl = new JFXTextField();
okRenameIngr = new JFXButton("Done!");
okRenameIngr.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent __) {
renameIngrPressed();
}
});
VBox renameIngrContainer = new VBox();
renameIngrContainer.getChildren().addAll(lbl4, renameIngrLbl, okRenameIngr);
renameIngrContainer.setPadding(new Insets(10, 50, 50, 50));
renameIngrContainer.setSpacing(10);
JFXPopup popup4 = new JFXPopup(renameIngrContainer);
renameIngr.setOnMouseClicked(e -> popup4.show(renameIngr, PopupVPosition.TOP, PopupHPosition.LEFT));
renameIngrLbl.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
enableButtons();
enableAddButtons();
}
use of javafx.event.ActionEvent in project Smartcity-Smarthouse by TechnionYP5777.
the class ConfigController method subscribe.
public void subscribe(final StoveAppController mainController) {
HBox.setHgrow(Apply, Priority.ALWAYS);
HBox.setHgrow(Cancel, Priority.ALWAYS);
final int btnCount = ButtonBox.getChildren().size();
Apply.prefWidthProperty().bind(ButtonBox.widthProperty().divide(btnCount));
Cancel.prefWidthProperty().bind(ButtonBox.widthProperty().divide(btnCount));
Cancel.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent __1) {
// do what you have to do
((Stage) Cancel.getScene().getWindow()).close();
}
});
Apply.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent __1) {
final Stage stage = (Stage) Apply.getScene().getWindow();
final String time = secs.getText(), degrees = cels.getText();
if (validateInput(time, degrees)) {
mainController.set_alert_seconds(Integer.parseInt(secs.getText()));
mainController.set_alert_temperature(Integer.parseInt(cels.getText()));
stage.close();
} else {
final Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error Dialog");
alert.setHeaderText("Bad Input");
alert.setContentText("Make sure to enter only numbers");
alert.showAndWait();
}
}
});
}
use of javafx.event.ActionEvent in project POL-POM-5 by PlayOnLinux.
the class RepositoriesPanel method populateRepositoryGrid.
private void populateRepositoryGrid() {
this.title = new TextWithStyle(tr("Repositories Settings"), "title");
this.repositoryGrid = new GridPane();
this.repositoryGrid.getStyleClass().add("grid");
this.repositoryText = new TextWithStyle(tr("Repository:"), "captionTitle");
this.repositoryLayout = new VBox();
this.repositoryLayout.setSpacing(5);
this.repositoryListView = new ListView<>(repositories);
this.repositoryListView.setPrefHeight(0);
this.repositoryListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
this.repositoryListView.setEditable(true);
this.repositoryListView.setCellFactory(param -> new DragableRepositoryListCell((repositoryUrl, toIndex) -> {
this.repositoryManager.moveRepository(repositoryUrl, toIndex.intValue());
this.save();
}));
this.repositoryButtonLayout = new HBox();
this.repositoryButtonLayout.setSpacing(5);
this.addButton = new Button();
this.addButton.setText(tr("Add"));
this.addButton.setOnAction((ActionEvent event) -> {
TextInputDialog dialog = new TextInputDialog();
dialog.initOwner(getScene().getWindow());
dialog.setTitle(tr("Add repository"));
dialog.setHeaderText(tr("Add repository"));
dialog.setContentText(tr("Please add the new repository:"));
Optional<String> result = dialog.showAndWait();
result.ifPresent(newRepository -> {
repositories.add(0, newRepository);
this.save();
repositoryManager.addRepositories(0, newRepository);
});
});
this.removeButton = new Button();
this.removeButton.setText(tr("Remove"));
this.removeButton.setOnAction((ActionEvent event) -> {
String[] toRemove = repositoryListView.getSelectionModel().getSelectedItems().toArray(new String[0]);
repositories.removeAll(toRemove);
this.save();
repositoryManager.removeRepositories(toRemove);
});
this.repositoryButtonLayout.getChildren().addAll(addButton, removeButton);
this.repositoryLayout.getChildren().addAll(repositoryListView, repositoryButtonLayout);
VBox.setVgrow(repositoryListView, Priority.ALWAYS);
this.repositoryGrid.add(repositoryText, 0, 0);
this.repositoryGrid.add(repositoryLayout, 1, 0);
GridPane.setHgrow(repositoryLayout, Priority.ALWAYS);
GridPane.setVgrow(repositoryLayout, Priority.ALWAYS);
GridPane.setValignment(repositoryText, VPos.TOP);
}
use of javafx.event.ActionEvent in project TeachingInSimulation by ScOrPiOzzy.
the class ExamController method initialize.
public void initialize(LibraryPublish publish) {
clear();
this.publish = publish;
this.library = publish.getLibrary();
this.libraryName.setTitle(library.getName());
// 创建答题卡项
List<Question> questions = this.library.getQuestions();
// // XXX 暂时不做:顺序打乱
// Collections.shuffle(questions);
float total = 0f;
for (int i = 0; i < questions.size(); i++) {
ToggleButton toggle = new ToggleButton(String.valueOf(i + 1));
toggle.getStyleClass().add("undo");
toggle.setUserData(i);
toggle.setWrapText(false);
flow.getChildren().add(toggle);
group.getToggles().add(toggle);
Question question = questions.get(i);
LibraryAnswer libraryAnswer = new LibraryAnswer();
libraryAnswer.setIndex(i);
libraryAnswer.setQuestion(question);
libraryAnswer.setQuestionId(question.getId());
this.answers.put(i, libraryAnswer);
total += question.getPoint();
}
this.total.setText(String.valueOf(total));
groupListener = (b, o, n) -> {
if (o == null) {
return;
} else if (n == null) {
this.group.selectToggle(o);
return;
}
if (!submited) {
// 验证上一个试题是否作答完成
checkAnswer((ToggleButton) o);
}
// 加载下一个试题
currIndex = (int) n.getUserData();
prev.setDisable(false);
next.setDisable(false);
if (currIndex <= 0) {
prev.setDisable(true);
}
if (currIndex >= questions.size() - 1) {
next.setDisable(true);
}
loadQuestion();
};
group.selectedToggleProperty().addListener(groupListener);
group.selectToggle(group.getToggles().get(0));
loadQuestion();
// 启动计时器
timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1), (ActionEvent event1) -> {
cost++;
this.minute.setText(String.valueOf(cost / 60));
this.second.setText(String.valueOf(cost % 60));
}));
timeline.play();
}
Aggregations