Search in sources :

Example 36 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 37 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 38 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 39 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)

Example 40 with ActionEvent

use of javafx.event.ActionEvent in project arquivoProject by fader-azevedo.

the class ListaEstanteController method setAnimacao.

private void setAnimacao() {
    /* Initial position setting for Top Pane*/
    clipRectNovoEstante = new Rectangle();
    clipRectNovoEstante.setWidth(boxBounds.getWidth());
    clipRectNovoEstante.setHeight(ACTION_BOX_HGT);
    clipRectNovoEstante.translateYProperty().set(boxBounds.getHeight() - ACTION_BOX_HGT);
    paneRegistarEstante.setClip(clipRectNovoEstante);
    paneRegistarEstante.translateYProperty().set(-(boxBounds.getHeight() - ACTION_BOX_HGT));
    final Timeline timelineDown1 = new Timeline();
    timelineDown1.setCycleCount(2);
    timelineDown1.setAutoReverse(true);
    final KeyValue kv1 = new KeyValue(clipRectNovoEstante.heightProperty(), (boxBounds.getHeight() - 15));
    final KeyValue kv2 = new KeyValue(clipRectNovoEstante.translateYProperty(), 15);
    final KeyValue kv3 = new KeyValue(paneRegistarEstante.translateYProperty(), -15);
    final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
    timelineDown1.getKeyFrames().add(kf1);
    EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() {

        public void handle(ActionEvent t) {
            timelineDown1.play();
        }
    };
    timelineDown = new Timeline();
    timelineUp = new Timeline();
    /* Animation for scroll down. */
    timelineDown.setCycleCount(1);
    timelineDown.setAutoReverse(true);
    final KeyValue kvDwn1 = new KeyValue(clipRectNovoEstante.heightProperty(), boxBounds.getHeight());
    final KeyValue kvDwn2 = new KeyValue(clipRectNovoEstante.translateYProperty(), 0);
    final KeyValue kvDwn3 = new KeyValue(paneRegistarEstante.translateYProperty(), 0);
    final KeyFrame kfDwn = new KeyFrame(Duration.millis(200), onFinished, kvDwn1, kvDwn2, kvDwn3);
    timelineDown.getKeyFrames().add(kfDwn);
    /* Animation for scroll up. */
    timelineUp.setCycleCount(1);
    timelineUp.setAutoReverse(true);
    final KeyValue kvUp1 = new KeyValue(clipRectNovoEstante.heightProperty(), ACTION_BOX_HGT);
    final KeyValue kvUp2 = new KeyValue(clipRectNovoEstante.translateYProperty(), boxBounds.getHeight() - ACTION_BOX_HGT);
    final KeyValue kvUp3 = new KeyValue(paneRegistarEstante.translateYProperty(), -(boxBounds.getHeight() - ACTION_BOX_HGT));
    final KeyFrame kfUp = new KeyFrame(Duration.millis(200), kvUp1, kvUp2, kvUp3);
    timelineUp.getKeyFrames().add(kfUp);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) ActionEvent(javafx.event.ActionEvent) Rectangle(javafx.scene.shape.Rectangle) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler)

Aggregations

ActionEvent (javafx.event.ActionEvent)41 Label (javafx.scene.control.Label)13 List (java.util.List)11 Button (javafx.scene.control.Button)11 Stage (javafx.stage.Stage)11 File (java.io.File)10 ObservableList (javafx.collections.ObservableList)10 MenuItem (javafx.scene.control.MenuItem)10 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)9 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 Optional (java.util.Optional)9 ResourceLoader (com.kyj.fx.voeditor.visual.momory.ResourceLoader)8 DialogUtil (com.kyj.fx.voeditor.visual.util.DialogUtil)8 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)8 MouseEvent (javafx.scene.input.MouseEvent)8 ConfigResourceLoader (com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader)7 Iterator (java.util.Iterator)7 FXCollections (javafx.collections.FXCollections)7 EventHandler (javafx.event.EventHandler)7