Search in sources :

Example 26 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class FxSVNHistoryDataSupplier method createHistoryListView.

public ListView<GargoyleSVNLogEntryPath> createHistoryListView(ObservableList<GargoyleSVNLogEntryPath> list) {
    ListView<GargoyleSVNLogEntryPath> listView = new ListView<GargoyleSVNLogEntryPath>(list);
    listView.setCellFactory(new Callback<ListView<GargoyleSVNLogEntryPath>, ListCell<GargoyleSVNLogEntryPath>>() {

        @Override
        public ListCell<GargoyleSVNLogEntryPath> call(ListView<GargoyleSVNLogEntryPath> param) {
            ListCell<GargoyleSVNLogEntryPath> listCell = new ListCell<GargoyleSVNLogEntryPath>() {

                /* (non-Javadoc)
					 * @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean)
					 */
                @Override
                protected void updateItem(GargoyleSVNLogEntryPath item, boolean empty) {
                    super.updateItem(item, empty);
                    if (empty) {
                        setText(null);
                    } else {
                        String type = "Modify";
                        switch(item.getType()) {
                            case GargoyleSVNLogEntryPath.TYPE_ADDED:
                                type = "Add";
                                break;
                            case GargoyleSVNLogEntryPath.TYPE_MODIFIED:
                                type = "Modify";
                                break;
                            case GargoyleSVNLogEntryPath.TYPE_REPLACED:
                                type = "Replace";
                                break;
                            case GargoyleSVNLogEntryPath.TYPE_DELETED:
                                type = "Delete";
                                break;
                        }
                        String path = item.getPath();
                        setText(String.format("Resivion :%d File : %s Date : %s Type : %s ", item.getCopyRevision(), path.substring(path.lastIndexOf("/")), YYYY_MM_DD_HH_MM_SS_PATTERN.format(item.getDate()), type));
                    }
                }
            };
            return listCell;
        }
    });
    listView.setPrefSize(600, ListView.USE_COMPUTED_SIZE);
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    listView.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
        ContextMenu contextMenu = null;
        ObservableList<GargoyleSVNLogEntryPath> selectedItems = listView.getSelectionModel().getSelectedItems();
        GargoyleSVNLogEntryPath selectedItem = null;
        if (selectedItems != null && !selectedItems.isEmpty()) {
            selectedItem = selectedItems.get(0);
        }
        if (ev.getClickCount() == 2 && ev.getButton() == MouseButton.PRIMARY) {
            if (selectedItem != null) {
                String path = selectedItem.getPath();
                long copyRevision = selectedItem.getCopyRevision();
                String rootUrl = getRootUrl();
                LOGGER.debug("{}", rootUrl);
                LOGGER.debug("Cat Command, Path : {} Revision {}", path, copyRevision);
                String content = "";
                VBox vBox = new VBox(5);
                if (isExists(path)) {
                    content = cat(path, String.valueOf(copyRevision));
                    List<SVNLogEntry> log = log(path, String.valueOf(copyRevision), ex -> {
                        LOGGER.error(ValueUtil.toString(ex));
                    });
                    if (ValueUtil.isNotEmpty(log)) {
                        SVNLogEntry svnLogEntry = log.get(0);
                        String apply = getManager().fromPrettySVNLogConverter().apply(svnLogEntry);
                        Label e = new Label(apply);
                        e.setStyle("-fx-text-fill:black");
                        vBox.getChildren().add(e);
                    }
                    vBox.getChildren().add(createJavaTextArea(content));
                } else {
                    content = "Does not exists. Repository. [Removed]";
                    Label e = new Label(content);
                    e.setStyle("-fx-text-fill:black");
                    vBox.getChildren().add(e);
                }
                FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), vBox);
            }
            ev.consume();
        } else if (ev.getClickCount() == 1 && ev.getButton() == MouseButton.SECONDARY) {
            ObservableList<MenuItem> menus = FXCollections.observableArrayList();
            MenuItem miHist = new MenuItem("History");
            miHist.setUserData(selectedItem);
            MenuItem miAllHist = new MenuItem("All History");
            MenuItem miDiff = new MenuItem("Diff");
            miDiff.setDisable(true);
            menus.add(miHist);
            menus.add(miAllHist);
            menus.add(new SeparatorMenuItem());
            menus.add(miDiff);
            if (selectedItems.size() == 2) {
                miDiff.setUserData(selectedItems);
                miDiff.setDisable(false);
            }
            miHist.setOnAction(event -> {
                GargoyleSVNLogEntryPath userData = (GargoyleSVNLogEntryPath) miHist.getUserData();
                if (userData == null)
                    return;
                FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), createHistoryListView(userData.getPath()));
            });
            miAllHist.setOnAction(event -> {
                GargoyleSVNLogEntryPath userData = (GargoyleSVNLogEntryPath) miHist.getUserData();
                if (userData == null)
                    return;
                String path = userData.getPath();
                try {
                    Collection<SVNLogEntry> allLogs = getManager().getAllLogs(path);
                    ObservableList<GargoyleSVNLogEntryPath> collect = createStream(allLogs).filter(v -> {
                        return path.equals(v.getPath());
                    }).collect(FxCollectors.toObservableList());
                    FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), createHistoryListView(collect));
                } catch (Exception e) {
                    LOGGER.error(ValueUtil.toString(e));
                }
            });
            miDiff.setOnAction(event -> {
                List<GargoyleSVNLogEntryPath> userData = (List<GargoyleSVNLogEntryPath>) miDiff.getUserData();
                if (userData == null && userData.size() != 2)
                    return;
                GargoyleSVNLogEntryPath gargoyleSVNLogEntryPath1 = userData.get(0);
                GargoyleSVNLogEntryPath gargoyleSVNLogEntryPath2 = userData.get(1);
                try {
                    String diff = diff(gargoyleSVNLogEntryPath1.getPath(), gargoyleSVNLogEntryPath1.getCopyRevision(), gargoyleSVNLogEntryPath2.getCopyRevision());
                    TextArea showingNode = new TextArea(diff);
                    showingNode.setPrefSize(600d, 800d);
                    FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), showingNode);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
            contextMenu = new ContextMenu(menus.stream().toArray(MenuItem[]::new));
            contextMenu.show(ev.getPickResult().getIntersectedNode(), ev.getScreenX(), ev.getScreenY());
        }
    });
    return listView;
}
Also used : Arrays(java.util.Arrays) MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) TextArea(javafx.scene.control.TextArea) ListCell(javafx.scene.control.ListCell) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) JavaTextArea(com.kyj.fx.voeditor.visual.component.text.JavaTextArea) FXCollections(javafx.collections.FXCollections) JavaSVNManager(com.kyj.scm.manager.svn.java.JavaSVNManager) VBox(javafx.scene.layout.VBox) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Callback(javafx.util.Callback) SVNLogEntryPath(org.tmatesoft.svn.core.SVNLogEntryPath) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) Collection(java.util.Collection) SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) Node(javafx.scene.Node) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) SelectionMode(javafx.scene.control.SelectionMode) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) TextArea(javafx.scene.control.TextArea) JavaTextArea(com.kyj.fx.voeditor.visual.component.text.JavaTextArea) ListCell(javafx.scene.control.ListCell) Label(javafx.scene.control.Label) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ListView(javafx.scene.control.ListView) ObservableList(javafx.collections.ObservableList) Collection(java.util.Collection) List(java.util.List) ObservableList(javafx.collections.ObservableList) VBox(javafx.scene.layout.VBox)

Example 27 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class ScmCommitComposite method init.

/* (non-Javadoc)
	 * @see com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite#init()
	 */
@Override
public void init() {
    MenuItem miReflesh = new MenuItem("Reflesh");
    miReflesh.setOnAction(ex -> {
        getLineChartDayOfWeek().getData().clear();
        getLineChartDayOfWeekCategory().getCategories().clear();
        getBarChartDayOfMonth().getData().clear();
        getBarChartDayOfMonthCategory().getCategories().clear();
        load();
    });
    ContextMenu contextMenu = new ContextMenu(miReflesh);
    this.addEventFilter(MouseEvent.MOUSE_CLICKED, ev -> {
        contextMenu.hide();
        if (ev.getButton() == MouseButton.SECONDARY) {
            contextMenu.show(FxUtil.getWindow(this), ev.getScreenX(), ev.getScreenY());
        }
    });
}
Also used : MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu)

Example 28 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class SqlMultiplePane method createTreeContextMenu.

/**
	 * 컨텍스트 메뉴 생성 및 기능 적용
	 *
	 * @param schemaTree2
	 */
private void createTreeContextMenu(TreeView<K> schemaTree) {
    MenuItem menuSelectScript = new MenuItem("Select Script");
    menuSelectScript.setOnAction(this::applySelectScript);
    MenuItem menuUpdateScript = new MenuItem("Update Script");
    menuUpdateScript.setOnAction(this::applyUpdateScript);
    MenuItem menuDeleteScript = new MenuItem("Delete Script");
    menuDeleteScript.setOnAction(this::applyDeleteSelectScript);
    MenuItem menuInsertScript = new MenuItem("Insert Script");
    menuInsertScript.setOnAction(this::applyInsertScript);
    Menu menu = new Menu("Script", null, menuSelectScript, menuUpdateScript, menuDeleteScript, menuInsertScript);
    // MenuItem menuPrimaryKeys = new MenuItem("Primary Keys");
    MenuItem menuShowData = new MenuItem("Show 100 rows");
    menuShowData.setOnAction(this::show100RowAction);
    MenuItem menuProperties = new MenuItem("Properties");
    menuProperties.setOnAction(this::showProperties);
    MenuItem menuReflesh = new MenuItem("Reflesh");
    menuReflesh.setOnAction(this::menuRefleshOnAction);
    menuReflesh.setAccelerator(new KeyCodeCombination(KeyCode.F5));
    ContextMenu contextMenu = new ContextMenu(menu, menuShowData, menuProperties, new SeparatorMenuItem(), menuReflesh);
    schemaTree.setContextMenu(contextMenu);
}
Also used : MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ContextMenu(javafx.scene.control.ContextMenu) ContextMenu(javafx.scene.control.ContextMenu) Menu(javafx.scene.control.Menu) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem)

Example 29 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class SqlMultiplePane method createResultTableContextMenu.

private void createResultTableContextMenu(TableView<Map<String, Object>> tbResult) {
    MenuItem menuExportExcel = new MenuItem("Export Excel File");
    menuExportExcel.setOnAction(e -> menuExportExcelOnAction(tbResult));
    MenuItem menuExportSpreadSheet = new MenuItem("Export SpreadSheet");
    menuExportSpreadSheet.setOnAction(this::menuExportSpreadSheetOnAction);
    Menu menuExportExcelFile = new Menu("Export", null, menuExportExcel, menuExportSpreadSheet);
    ContextMenu contextMenu = new ContextMenu(menuExportExcelFile);
    tbResult.setContextMenu(contextMenu);
}
Also used : MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ContextMenu(javafx.scene.control.ContextMenu) ContextMenu(javafx.scene.control.ContextMenu) Menu(javafx.scene.control.Menu)

Example 30 with ContextMenu

use of javafx.scene.control.ContextMenu in project Gargoyle by callakrsos.

the class SqlPane method createResultTableContextMenu.

private void createResultTableContextMenu(TableView<?> tableView) {
    MenuItem menuExportExcel = new MenuItem("Export Excel File");
    menuExportExcel.setOnAction(this::menuExportExcelOnAction);
    MenuItem menuExportSpreadSheet = new MenuItem("Export SpreadSheet");
    menuExportSpreadSheet.setOnAction(this::menuExportSpreadSheetOnAction);
    MenuItem menuExportInsertScript = new MenuItem("Export Insert Script");
    menuExportInsertScript.setOnAction(this::menuExportInsertScriptOnAction);
    MenuItem menuExportMergeScript = new MenuItem("Export Merge Script");
    menuExportMergeScript.setOnAction(this::menuExportMergeScriptOnAction);
    MenuItem menuExportJson = new MenuItem("Export Json");
    menuExportJson.setOnAction(this::menuExportJsonOnAction);
    Menu menuExportExcelFile = new Menu("Export", null, menuExportExcel, menuExportSpreadSheet, menuExportInsertScript, menuExportMergeScript, menuExportJson);
    ContextMenu contextMenu = new ContextMenu(menuExportExcelFile);
    tableView.setContextMenu(contextMenu);
}
Also used : MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ContextMenu(javafx.scene.control.ContextMenu) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu)

Aggregations

ContextMenu (javafx.scene.control.ContextMenu)35 MenuItem (javafx.scene.control.MenuItem)31 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)12 Menu (javafx.scene.control.Menu)6 Node (javafx.scene.Node)5 File (java.io.File)3 List (java.util.List)3 FXML (javafx.fxml.FXML)3 Scene (javafx.scene.Scene)3 Label (javafx.scene.control.Label)3 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)3 Stage (javafx.stage.Stage)3 CommonsContextMenu (com.kyj.fx.voeditor.visual.component.CommonsContextMenu)2 JavaTextArea (com.kyj.fx.voeditor.visual.component.text.JavaTextArea)2 SqlKeywords (com.kyj.fx.voeditor.visual.component.text.SqlKeywords)2 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)2 IOException (java.io.IOException)2 Collectors (java.util.stream.Collectors)2 ObservableList (javafx.collections.ObservableList)2 ActionEvent (javafx.event.ActionEvent)2