Search in sources :

Example 96 with ActionEvent

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

the class SqlMultiplePane method applySelectScript.

/**
	 * 테이블의 SELECT문을 리턴.
	 *
	 * @param e
	 */
public void applySelectScript(ActionEvent e) {
    TreeItem<K> selectedItem = schemaTree.getSelectionModel().getSelectedItem();
    String tableName = this.getSelectedTreeByTableName(selectedItem);
    SqlTab selectedTab = getSelectedSqlTab();
    TreeItem<K> schemaTreeItem = selectedItem.getParent();
    String schema = schemaTreeItem.getValue().toString();
    Connection connection = connectionSupplier.get();
    try {
        String driver = DbUtil.getDriverNameByConnection(connection);
        String sql = ConfigResourceLoader.getInstance().get(ConfigResourceLoader.SQL_TABLE_COLUMNS_WRAPPER, driver);
        Map<String, Object> map = new HashMap<>(2);
        map.put("databaseName", schema);
        map.put("tableName", tableName);
        sql = ValueUtil.getVelocityToText(sql, map, true);
        List<String> select = DbUtil.select(connection, sql, 10, (RowMapper<String>) (rs, rowNum) -> rs.getString(1));
        redueceAction(select, ",", v -> selectedTab.appendTextSql(String.format("select %s \nfrom %s ", v.substring(0, v.length()), tableName)));
    } catch (Exception e1) {
        LOGGER.error(ValueUtil.toString(e1));
    }
}
Also used : Button(javafx.scene.control.Button) SystemLayoutViewController(com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController) CheckComboBox(org.controlsfx.control.CheckComboBox) Connection(java.sql.Connection) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) LoggerFactory(org.slf4j.LoggerFactory) NullExpresion(com.kyj.fx.voeditor.visual.util.NullExpresion) ToExcelFileFunction(com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction) Application(javafx.application.Application) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) EncrypUtil(com.kyj.fx.voeditor.visual.util.EncrypUtil) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) SQLPaneMotionable(com.kyj.fx.voeditor.visual.component.sql.functions.SQLPaneMotionable) GargoyleExtensionFilters(com.kyj.fx.voeditor.visual.util.GargoyleExtensionFilters) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) VariableMappingView(com.kyj.fx.voeditor.visual.component.popup.VariableMappingView) DockPos(com.kyj.fx.voeditor.visual.component.dock.pane.DockPos) DockPane(com.kyj.fx.voeditor.visual.component.dock.pane.DockPane) TableView(javafx.scene.control.TableView) SystemUtils(org.apache.commons.lang.SystemUtils) HBox(javafx.scene.layout.HBox) Pair(javafx.util.Pair) MenuItem(javafx.scene.control.MenuItem) KeyEvent(javafx.scene.input.KeyEvent) SimpleTextView(com.kyj.fx.voeditor.visual.component.text.SimpleTextView) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) ISchemaTreeItem(com.kyj.fx.voeditor.visual.component.sql.functions.ISchemaTreeItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) SqlTab(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab) RowMapper(org.springframework.jdbc.core.RowMapper) Optional(java.util.Optional) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) MouseButton(javafx.scene.input.MouseButton) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) DockNode(com.kyj.fx.voeditor.visual.component.dock.pane.DockNode) GagoyleTabProxy(com.kyj.fx.voeditor.visual.main.layout.GagoyleTabProxy) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Supplier(java.util.function.Supplier) IntegerProperty(javafx.beans.property.IntegerProperty) BigDataDVO(com.kyj.fx.voeditor.visual.framework.BigDataDVO) TableColumn(javafx.scene.control.TableColumn) Tooltip(javafx.scene.control.Tooltip) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Modality(javafx.stage.Modality) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) StringConverter(javafx.util.StringConverter) SchoolMgrerSpreadSheetView(com.kyj.fx.voeditor.visual.main.layout.SchoolMgrerSpreadSheetView) File(java.io.File) SqlTabPane(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTabPane) Menu(javafx.scene.control.Menu) Consumer(java.util.function.Consumer) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ActionEvent(javafx.event.ActionEvent) SelectionMode(javafx.scene.control.SelectionMode) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) HashMap(java.util.HashMap) Connection(java.sql.Connection) SqlTab(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab)

Example 97 with ActionEvent

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

the class CommonsSqllPan method menuExportInsertScriptOnAction.

@Override
public void menuExportInsertScriptOnAction(ActionEvent e) {
    Optional<Pair<String, String[]>> showTableInputDialog = showTableInputDialog(f -> f.getName());
    //		Optional<Pair<String, String>> showInputDialog = DialogUtil.showInputDialog("table Name", "테이블명을 입력하세요.");
    if (showTableInputDialog == null)
        return;
    showTableInputDialog.ifPresent(op -> {
        if (op == null || op.getValue() == null)
            return;
        String schemaName = op.getValue()[0];
        String _tableName = op.getValue()[1];
        String tableName = "";
        if (ValueUtil.isNotEmpty(schemaName)) {
            tableName = String.format("%s.%s", schemaName, _tableName);
        } else {
            tableName = _tableName;
        }
        List<Map<String, Object>> items = getSelectedTabResultItems();
        Map<String, Object> map = items.get(0);
        final Set<String> keySet = map.keySet();
        StringBuilder clip = new StringBuilder();
        String insertPreffix = "insert into " + tableName;
        String collect = keySet.stream().collect(Collectors.joining(",", "(", ")"));
        String insertMiddle = " values ";
        List<String> valueList = items.stream().map(v -> {
            return ValueUtil.toJSONObject(v);
        }).map(v -> {
            Iterator<String> iterator = keySet.iterator();
            List<Object> values = new ArrayList<>();
            while (iterator.hasNext()) {
                String columnName = iterator.next();
                Object value = v.get(columnName);
                values.add(value);
            }
            return values;
        }).map(list -> {
            return list.stream().map(str -> {
                if (str == null)
                    return null;
                else {
                    String convert = str.toString();
                    convert = convert.substring(1, convert.length() - 1);
                    if (convert.indexOf("'") >= 0) {
                        try {
                            convert = StringUtils.replace(convert, "'", "''");
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                    return "'".concat(convert).concat("'");
                }
            }).collect(Collectors.joining(",", "(", ")"));
        }).map(str -> {
            return new StringBuilder().append(insertPreffix).append(collect).append(insertMiddle).append(str).append(";\n").toString();
        }).collect(Collectors.toList());
        valueList.forEach(str -> {
            clip.append(str);
        });
        SimpleTextView parent = new SimpleTextView(clip.toString());
        parent.setWrapText(false);
        FxUtil.createStageAndShow(String.format("[InsertScript] Table : %s", tableName), parent, stage -> {
        });
    });
}
Also used : Connection(java.sql.Connection) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) SchemaItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.SchemaItemTree) Map(java.util.Map) ColumnItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.ColumnItemTree) TableInformationUserMetadataVO(com.kyj.fx.voeditor.visual.component.sql.table.TableInformationUserMetadataVO) Pair(javafx.util.Pair) DatabaseTreeNode(com.kyj.fx.voeditor.visual.component.sql.dbtree.DatabaseTreeNode) Set(java.util.Set) KeyEvent(javafx.scene.input.KeyEvent) SimpleTextView(com.kyj.fx.voeditor.visual.component.text.SimpleTextView) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) TableInformationFrameView(com.kyj.fx.voeditor.visual.component.sql.table.TableInformationFrameView) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) DatabaseItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Scene(javafx.scene.Scene) GargoyleConnectionFailException(com.kyj.fx.voeditor.visual.exceptions.GargoyleConnectionFailException) ResultSetToMapConverter(com.kyj.fx.voeditor.visual.functions.ResultSetToMapConverter) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Constructor(java.lang.reflect.Constructor) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) TableItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.TableItemTree) BiConsumer(java.util.function.BiConsumer) KeyCode(javafx.scene.input.KeyCode) Properties(java.util.Properties) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) FxClipboardUtil(com.kyj.fx.voeditor.visual.util.FxClipboardUtil) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) GagoyleParamEmptyException(com.kyj.fx.voeditor.visual.exceptions.GagoyleParamEmptyException) Consumer(java.util.function.Consumer) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) NotYetSupportException(com.kyj.fx.voeditor.visual.exceptions.NotYetSupportException) DatabaseTreeCallback(com.kyj.fx.voeditor.visual.component.sql.dbtree.DatabaseTreeCallback) Collections(java.util.Collections) GargoyleConnectionFailException(com.kyj.fx.voeditor.visual.exceptions.GargoyleConnectionFailException) SQLException(java.sql.SQLException) IOException(java.io.IOException) GagoyleParamEmptyException(com.kyj.fx.voeditor.visual.exceptions.GagoyleParamEmptyException) NotYetSupportException(com.kyj.fx.voeditor.visual.exceptions.NotYetSupportException) Iterator(java.util.Iterator) SimpleTextView(com.kyj.fx.voeditor.visual.component.text.SimpleTextView) List(java.util.List) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Pair(javafx.util.Pair)

Example 98 with ActionEvent

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

the class DaoWizardViewController method menuToVoEditorOnAction.

/********************************
	 * 작성일 : 2016. 2. 27. 작성자 : KYJ
	 *
	 * 내용 : VO에티터로 결과내용을 전달처리한다.
	 *******************************/
public void menuToVoEditorOnAction(ActionEvent e) {
    ObservableList<TbpSysDaoColumnsDVO> items = tbMappings.getItems();
    if (items.isEmpty())
        return;
    DatabaseTypeMappingFunction typeConverter = new DatabaseTypeMappingFunction();
    try {
        FXMLLoader loader = FxUtil.createNewFxmlLoader();
        loader.setLocation(getClass().getResource("VoEditorView.fxml"));
        BorderPane root = loader.load();
        VoEditorController controller = loader.getController();
        List<TableModelDVO> resultItems = items.stream().map(m -> {
            TableModelDVO dvo = new TableModelDVO();
            dvo.setName(ValueUtil.getPrefixLowerTextMyEdit(m.getColumnName()));
            String programType = m.getProgramType();
            if (programType == null || programType.isEmpty()) {
                programType = typeConverter.apply(m.getColumnType());
            }
            dvo.setType(programType);
            return dvo;
        }).collect(Collectors.toList());
        controller.addItem(resultItems);
        SharedMemory.getSystemLayoutViewController().loadNewSystemTab("New VO", root);
    } catch (IOException e1) {
        LOGGER.error(ValueUtil.toString(e1));
    }
}
Also used : SimpleSQLResultView(com.kyj.fx.voeditor.visual.component.popup.SimpleSQLResultView) Arrays(java.util.Arrays) Menus(com.kyj.fx.voeditor.visual.component.Menus) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) NumberingCellValueFactory(com.kyj.fx.voeditor.visual.component.NumberingCellValueFactory) LoggerFactory(org.slf4j.LoggerFactory) NullExpresion(com.kyj.fx.voeditor.visual.util.NullExpresion) MeerketAbstractVoOpenClassResourceView(com.kyj.fx.voeditor.visual.component.popup.MeerketAbstractVoOpenClassResourceView) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) TableView(javafx.scene.control.TableView) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) Path(java.nio.file.Path) EditorUtil(com.kyj.fx.voeditor.util.EditorUtil) DatabaseTypeMappingFunction(com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction) ClassTypeResourceLoader(com.kyj.fx.voeditor.visual.momory.ClassTypeResourceLoader) TableMasterDVO(kyj.Fx.dao.wizard.core.model.vo.TableMasterDVO) SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair) MenuItem(javafx.scene.control.MenuItem) QuerygenUtil(kyj.Fx.dao.wizard.core.util.QuerygenUtil) TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) Set(java.util.Set) KeyEvent(javafx.scene.input.KeyEvent) DatabaseTableView(com.kyj.fx.voeditor.visual.component.popup.DatabaseTableView) FxDAOReadFunction(com.kyj.fx.voeditor.visual.functions.FxDAOReadFunction) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) TableDVO(kyj.Fx.dao.wizard.core.model.vo.TableDVO) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) Stream(java.util.stream.Stream) Optional(java.util.Optional) ChoiceBoxTableCell(javafx.scene.control.cell.ChoiceBoxTableCell) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) CommonsContextMenu(com.kyj.fx.voeditor.visual.component.CommonsContextMenu) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) BaseOpenClassResourceView(com.kyj.fx.voeditor.visual.component.popup.BaseOpenClassResourceView) TextArea(javafx.scene.control.TextArea) MouseEvent(javafx.scene.input.MouseEvent) CommonContextMenuEvent(com.kyj.fx.voeditor.visual.events.CommonContextMenuEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Function(java.util.function.Function) TbmSysDaoDVO(kyj.Fx.dao.wizard.core.model.vo.TbmSysDaoDVO) TableColumn(javafx.scene.control.TableColumn) Wizardtype(com.kyj.fx.voeditor.visual.framework.daowizard.GargoyleDaoWizardFactory.Wizardtype) FXMLLoader(javafx.fxml.FXMLLoader) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) JavaTextView(com.kyj.fx.voeditor.visual.component.popup.JavaTextView) DaoWizard(kyj.Fx.dao.wizard.DaoWizard) LinkedHashSet(java.util.LinkedHashSet) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) FxDAOSaveFunction(com.kyj.fx.voeditor.visual.functions.FxDAOSaveFunction) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) DaoWizardConverter(com.kyj.fx.voeditor.visual.util.DaoWizardConverter) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) DatabaseTypeMappingResourceLoader(kyj.Fx.dao.wizard.memory.DatabaseTypeMappingResourceLoader) IOException(java.io.IOException) LockImagedYnColumn(com.kyj.fx.voeditor.visual.component.LockImagedYnColumn) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO) StringConverter(javafx.util.StringConverter) File(java.io.File) ActionEvent(javafx.event.ActionEvent) SelectionMode(javafx.scene.control.SelectionMode) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) ResultDialog(com.kyj.fx.voeditor.visual.component.ResultDialog) Collections(java.util.Collections) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) BorderPane(javafx.scene.layout.BorderPane) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) IOException(java.io.IOException) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) FXMLLoader(javafx.fxml.FXMLLoader) DatabaseTypeMappingFunction(com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction)

Example 99 with ActionEvent

use of javafx.event.ActionEvent in project bitsquare by bitsquare.

the class CandleStickChart method dataItemRemoved.

@Override
protected void dataItemRemoved(XYChart.Data<Number, Number> item, XYChart.Series<Number, Number> series) {
    if (series.getNode() instanceof Path) {
        Path seriesPath = (Path) series.getNode();
        seriesPath.getElements().clear();
    }
    final Node node = item.getNode();
    if (shouldAnimate()) {
        // fade out old candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), node);
        ft.setToValue(0);
        ft.setOnFinished((ActionEvent actionEvent) -> {
            getPlotChildren().remove(node);
        });
        ft.play();
    } else {
        getPlotChildren().remove(node);
    }
}
Also used : Path(javafx.scene.shape.Path) FadeTransition(javafx.animation.FadeTransition) ActionEvent(javafx.event.ActionEvent) Node(javafx.scene.Node)

Example 100 with ActionEvent

use of javafx.event.ActionEvent in project bitsquare by bitsquare.

the class VolumeChart method dataItemRemoved.

@Override
protected void dataItemRemoved(XYChart.Data<Number, Number> item, XYChart.Series<Number, Number> series) {
    final Node node = item.getNode();
    if (shouldAnimate()) {
        FadeTransition ft = new FadeTransition(Duration.millis(500), node);
        ft.setToValue(0);
        ft.setOnFinished((ActionEvent actionEvent) -> getPlotChildren().remove(node));
        ft.play();
    } else {
        getPlotChildren().remove(node);
    }
}
Also used : FadeTransition(javafx.animation.FadeTransition) ActionEvent(javafx.event.ActionEvent) Node(javafx.scene.Node)

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