Search in sources :

Example 91 with ActionEvent

use of javafx.event.ActionEvent in project fxexperience2 by EricCanull.

the class DemoController method bringBackAfter.

private void bringBackAfter() {
    PauseTransition pauseTransition = new PauseTransition();
    pauseTransition.setDuration(Duration.seconds(1.5));
    pauseTransition.play();
    pauseTransition.setOnFinished((ActionEvent t) -> {
        btn.setOpacity(1);
        btn.autosize();
    });
}
Also used : ActionEvent(javafx.event.ActionEvent) PauseTransition(javafx.animation.PauseTransition)

Example 92 with ActionEvent

use of javafx.event.ActionEvent in project SmartCity-Market by TechnionYP5777.

the class DialogMessagesService method showConfirmationDialog.

public static void showConfirmationDialog(String title, String header, String content, IConfiramtionDialog d) {
    JFXDialogLayout dialogContent = new JFXDialogLayout();
    dialogContent.setHeading(new Text(header == null ? title : title + "\n" + header));
    dialogContent.setBody(new Text(content));
    JFXButton yes = new JFXButton("Yes");
    yes.getStyleClass().add("JFXButton");
    JFXButton no = new JFXButton("No");
    no.getStyleClass().add("JFXButton");
    dialogContent.setActions(yes, new Label("   "), no);
    JFXDialog dialog = new JFXDialog((StackPane) AbstractApplicationScreen.stage.getScene().getRoot(), dialogContent, JFXDialog.DialogTransition.CENTER);
    yes.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent __) {
            dialog.close();
            d.onYes();
        }
    });
    no.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent __) {
            dialog.close();
            d.onNo();
        }
    });
    dialog.show();
}
Also used : ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) JFXDialog(com.jfoenix.controls.JFXDialog) Text(javafx.scene.text.Text) JFXButton(com.jfoenix.controls.JFXButton) JFXDialogLayout(com.jfoenix.controls.JFXDialogLayout)

Example 93 with ActionEvent

use of javafx.event.ActionEvent in project Smartcity-Smarthouse by TechnionYP5777.

the class SensorConfigurationController method initialize.

@Override
public void initialize(final URL location, final ResourceBundle __) {
    nameColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getName()));
    typeColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getType().getFieldDescription()));
    deleteColumn.setCellValueFactory(param -> new SimpleBooleanProperty(param.getValue() != null));
    deleteColumn.setCellFactory(p -> {
        final ButtonCell $ = new ButtonCell();
        $.setAlignment(Pos.CENTER);
        return $;
    });
    backButton.setOnAction(__1 -> mainController.loadSensorList());
    HBox.setHgrow(addNameField, Priority.ALWAYS);
    HBox.setHgrow(addTypeField, Priority.ALWAYS);
    HBox.setHgrow(saveButton, Priority.ALWAYS);
    addTypeField.setPromptText("Sensor Type");
    addTypeField.getItems().addAll(Types.values());
    final int btnCount = buttonBox.getChildren().size();
    addNameField.prefWidthProperty().bind(buttonBox.widthProperty().divide(btnCount));
    addTypeField.prefWidthProperty().bind(buttonBox.widthProperty().divide(btnCount));
    saveButton.prefWidthProperty().bind(buttonBox.widthProperty().divide(btnCount));
    saveButton.setOnAction(__1 -> addField());
    deleteButton.setOnAction(__1 -> {
        mainController.removeSensor(currentSensor);
        mainController.loadSensorList();
    });
    messageButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(final ActionEvent __1) {
            try {
                final FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("message_ui.fxml"));
                final Parent root1 = (Parent) fxmlLoader.load();
                ((MessageViewController) fxmlLoader.getController()).setCurrentSensor(currentSensor);
                final Stage stage = new Stage();
                stage.setScene(new Scene(root1));
                stage.show();
            } catch (final Exception $) {
                System.out.println($);
            }
        }
    });
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) Parent(javafx.scene.Parent) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader)

Example 94 with ActionEvent

use of javafx.event.ActionEvent in project Gargoyle by callakrsos.

the class HtmlEditorExam method start.

@Override
public void start(Stage stage) {
    stage.setTitle("HTMLEditor Sample");
    stage.setWidth(500);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());
    VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);
    final HTMLEditor htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setStyle("-fx-background-color: white");
    scrollPane.setContent(browser);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);
    Button showHTMLButton = new Button("Load Content in Browser");
    root.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            webEngine.loadContent(htmlEditor.getHtmlText());
        }
    });
    root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane);
    scene.setRoot(root);
    stage.setScene(scene);
    stage.show();
}
Also used : Group(javafx.scene.Group) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) ScrollPane(javafx.scene.control.ScrollPane) ActionEvent(javafx.event.ActionEvent) HTMLEditor(javafx.scene.web.HTMLEditor) Scene(javafx.scene.Scene) WebView(javafx.scene.web.WebView) VBox(javafx.scene.layout.VBox) WebEngine(javafx.scene.web.WebEngine)

Example 95 with ActionEvent

use of javafx.event.ActionEvent in project Gargoyle by callakrsos.

the class PostgreSqlPane method menuExportMergeScriptOnAction.

/* (non-Javadoc)
	 * @see com.kyj.fx.voeditor.visual.component.sql.view.SqlPane#menuExportMergeScriptOnAction(javafx.event.ActionEvent)
	 */
@Override
public void menuExportMergeScriptOnAction(ActionEvent e) {
    //		TableView<Map<String, Object>> tbResult = getTbResult();
    List<Map<String, Object>> items = getSelectedTabResultItems();
    //		TreeView<DatabaseItemTree<String>> schemaTree = getSchemaTree();
    //
    //		List<String> schemaList = schemaTree.getRoot().getChildren().stream().map(v -> v.getValue().getName()).collect(Collectors.toList());
    //
    String defaultSchema = "";
    try {
        Map<String, Object> findOne = DbUtil.findOne(connectionSupplier.get(), "select current_schema() as currentschema");
        if (findOne != null && !findOne.isEmpty()) {
            defaultSchema = ValueUtil.decode(findOne.get("currentschema"), "").toString();
        }
    } catch (Exception e4) {
        e4.printStackTrace();
    }
    //
    final String _defaultSchema = defaultSchema;
    //
    //		if (items.isEmpty())
    //			return;
    //
    //		// TODO :: DBMS에 따라 Merge문 생성 로직 분기 처리 필요.
    //
    //		Optional<Pair<String, String[]>> showInputDialog = DialogUtil.showInputCustomDialog(tbResult.getScene().getWindow(), "table Name",
    //				"테이블명을 입력하세요.", new CustomInputDialogAction<GridPane, String[]>() {
    //
    //					TextField txtSchema;
    //					TextField txtTable;
    //
    //					@Override
    //					public GridPane getNode() {
    //						GridPane gridPane = new GridPane();
    //						txtSchema = new TextField();
    //						txtTable = new TextField();
    //
    //						FxUtil.installAutoTextFieldBinding(txtSchema, () -> {
    //							return schemaList;
    //						});
    //
    //						FxUtil.installAutoTextFieldBinding(txtTable, () -> {
    //							return searchPattern(txtSchema.getText(), txtTable.getText()).stream().map(v -> v.getValue().getName())
    //									.collect(Collectors.toList());
    //						});
    //						txtSchema.setText(_defaultSchema);
    //
    //						//Default TableName
    //						TreeItem<DatabaseItemTree<String>> selectedItem = getSchemaTree().getSelectionModel().getSelectedItem();
    //						if (null != selectedItem) {
    //							DatabaseItemTree<String> value = selectedItem.getValue();
    //							if (value instanceof TableItemTree) {
    //								txtTable.setText(value.getName());
    //							}
    //						}
    //
    //						Label label = new Label("Schema : ");
    //						Label label2 = new Label("Table : ");
    //						gridPane.add(label, 0, 0);
    //						gridPane.add(label2, 1, 0);
    //						gridPane.add(txtSchema, 0, 1);
    //						gridPane.add(txtTable, 1, 1);
    //						return gridPane;
    //					}
    //
    //					@Override
    //					public String[] okClickValue() {
    //
    //						String schema = txtSchema.getText().trim();
    //						String table = txtTable.getText().trim();
    //
    //						String[] okValue = new String[2];
    //						okValue[0] = schema;
    //						okValue[1] = table;
    //						return okValue;
    //					}
    //
    //					@Override
    //					public String[] cancelClickValue() {
    //						return null;
    //					}
    //
    //				});
    Optional<Pair<String, String[]>> showTableInputDialog = showTableInputDialog(v -> v.getName());
    showTableInputDialog.ifPresent(op -> {
        if (!"OK".equals(op.getKey()))
            return;
        String[] resultValue = op.getValue();
        try {
            StringBuilder clip = new StringBuilder();
            PostgreTableItemTree dirtyTreeItem = new PostgreTableItemTree();
            String schemaName = (resultValue[0] == null || resultValue[0].isEmpty()) ? _defaultSchema : resultValue[0];
            String tableName = resultValue[1];
            String childrenSQL = dirtyTreeItem.getChildrenSQL(schemaName, tableName);
            List<Map<String, Object>> select = DbUtil.select(childrenSQL);
            List<String> pkList = new ArrayList<>();
            List<String> notPkList = new ArrayList<>();
            List<String> columnList = new ArrayList<>();
            for (Map<String, Object> map : select) {
                String columnName = map.get("column_name").toString();
                Object primaryKeyYn = map.get("primary_yn");
                columnList.add(columnName);
                if ("Y".equals(primaryKeyYn)) {
                    pkList.add(columnName);
                } else {
                    notPkList.add(columnName);
                }
            }
            String mergePreffix = String.format("with upsert as ( update %s set  ", tableName);
            String mergeMiddle = " returning * )\n";
            String collect = columnList.stream().collect(Collectors.joining(", ", "(", ")"));
            String insertPreffix = String.format("insert into %s", tableName);
            String insertend = " where not exists (select * from upsert);\n";
            List<String> valueList = items.stream().map(v -> {
                return ValueUtil.toJSONObject(v);
            }).map(v -> {
                String updateSetSql = notPkList.stream().map(str -> {
                    if (str == null)
                        return null;
                    else {
                        JsonElement jsonElement = v.get(str);
                        if (jsonElement == null) {
                            return str.concat("=").concat("null");
                        } else {
                            String dataValue = jsonElement.toString();
                            dataValue = dataValue.substring(1, dataValue.length() - 1);
                            if (dataValue.indexOf("'") >= 0) {
                                dataValue = StringUtils.replace(dataValue, "'", "''");
                            }
                            return str.concat("=").concat("'").concat(dataValue).concat("'");
                        }
                    }
                }).collect(Collectors.joining(", "));
                String updateWhereSql = pkList.stream().map(str -> {
                    if (str == null)
                        return null;
                    else {
                        if (null == v.get(str))
                            return null;
                        String dataValue = v.get(str).toString();
                        dataValue = dataValue.substring(1, dataValue.length() - 1);
                        if (dataValue.indexOf("'") >= 0) {
                            try {
                                dataValue = StringUtils.replace(dataValue, "'", "''");
                            } catch (Exception e1) {
                                e1.printStackTrace();
                            }
                        }
                        return str.concat(" = ").concat("'").concat(dataValue).concat("'");
                    }
                }).filter(str -> str != null).collect(Collectors.joining(" and "));
                String insertValueSql = columnList.stream().map(str -> {
                    if (str == null)
                        return null;
                    else {
                        JsonElement jsonElement = v.get(str);
                        if (jsonElement == null) {
                            return "null";
                        } else {
                            String dataValue = jsonElement.toString();
                            dataValue = dataValue.substring(1, dataValue.length() - 1);
                            if (dataValue.indexOf("'") >= 0) {
                                dataValue = StringUtils.replace(dataValue, "'", "''");
                            }
                            return "'".concat(dataValue).concat("'");
                        }
                    }
                }).collect(Collectors.joining(", "));
                return new StringBuilder().append(mergePreffix).append(updateSetSql).append(" where ").append(updateWhereSql).append(mergeMiddle).append(insertPreffix).append(collect).append(" select ").append(insertValueSql).append(insertend).toString();
            }).collect(Collectors.toList());
            valueList.forEach(str -> {
                clip.append(str);
            });
            SqlKeywords parent = new SqlKeywords();
            {
                MenuBar menuBar = new MenuBar();
                Menu menuFile = new Menu("File");
                MenuItem miSaveAs = new MenuItem("Save As");
                miSaveAs.setOnAction(ev -> {
                    File saveAsFile = DialogUtil.showFileSaveCheckDialog(getScene().getWindow(), chooser -> {
                        chooser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.SQL_NAME, GargoyleExtensionFilters.SQL));
                    });
                    if (saveAsFile != null) {
                        ThreadUtil.createNewThreadAndRun("Saveas", () -> {
                            SaveSQLFileFunction function = new SaveSQLFileFunction();
                            function.apply(saveAsFile, parent.getText());
                        });
                    }
                });
                menuFile.getItems().add(miSaveAs);
                menuBar.getMenus().add(menuFile);
                parent.setTop(menuBar);
            }
            parent.setContent(clip.toString());
            parent.setWrapText(false);
            parent.setPrefSize(1200d, 800d);
            FxUtil.createStageAndShow(parent, stage -> {
                stage.initOwner(getScene().getWindow());
                stage.setTitle(String.format("[Merge Script] Table : %s", tableName));
            });
        } catch (Exception e2) {
            LOGGER.error(ValueUtil.toString(e2));
            DialogUtil.showExceptionDailog(e2, "에러발생, 테이블을 잘못 선택하셨을 수 있습니다.");
        }
    });
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Connection(java.sql.Connection) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) TreeItem(javafx.scene.control.TreeItem) LoggerFactory(org.slf4j.LoggerFactory) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) ThreadUtil(com.kyj.fx.voeditor.visual.util.ThreadUtil) Map(java.util.Map) GargoyleExtensionFilters(com.kyj.fx.voeditor.visual.util.GargoyleExtensionFilters) SaveSQLFileFunction(com.kyj.fx.voeditor.visual.component.sql.functions.SaveSQLFileFunction) SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) Pair(javafx.util.Pair) Logger(org.slf4j.Logger) MenuBar(javafx.scene.control.MenuBar) MenuItem(javafx.scene.control.MenuItem) DatabaseTreeNode(com.kyj.fx.voeditor.visual.component.sql.dbtree.DatabaseTreeNode) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Collectors(java.util.stream.Collectors) File(java.io.File) PostgreDatabaseItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.postgre.PostgreDatabaseItemTree) Menu(javafx.scene.control.Menu) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) ActionEvent(javafx.event.ActionEvent) DatabaseItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree) PostgreTableItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.postgre.PostgreTableItemTree) Optional(java.util.Optional) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) ArrayList(java.util.ArrayList) MenuBar(javafx.scene.control.MenuBar) MenuItem(javafx.scene.control.MenuItem) JsonElement(com.google.gson.JsonElement) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Menu(javafx.scene.control.Menu) SaveSQLFileFunction(com.kyj.fx.voeditor.visual.component.sql.functions.SaveSQLFileFunction) Map(java.util.Map) File(java.io.File) Pair(javafx.util.Pair) PostgreTableItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.postgre.PostgreTableItemTree)

Aggregations

ActionEvent (javafx.event.ActionEvent)171 EventHandler (javafx.event.EventHandler)61 Stage (javafx.stage.Stage)52 KeyFrame (javafx.animation.KeyFrame)47 Timeline (javafx.animation.Timeline)47 FXML (javafx.fxml.FXML)44 Alert (javafx.scene.control.Alert)36 Button (javafx.scene.control.Button)35 Label (javafx.scene.control.Label)35 MenuItem (javafx.scene.control.MenuItem)33 ContextMenu (javafx.scene.control.ContextMenu)25 File (java.io.File)24 Insets (javafx.geometry.Insets)24 Scene (javafx.scene.Scene)24 List (java.util.List)21 ObservableList (javafx.collections.ObservableList)21 Node (javafx.scene.Node)20 TextField (javafx.scene.control.TextField)20 Optional (java.util.Optional)18 FXCollections (javafx.collections.FXCollections)18