Search in sources :

Example 31 with ContextMenu

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

the class SqlPane method createTabItem.

/**
	 * 탭추가.
	 *
	 * 2016-12-09 CodeAssistHelper 기능 추가.
	 *
	 * 2016-10-27 키 이벤트를 setAccelerator를 사용하지않고 이벤트 방식으로 변경 이유 : 도킹기능을 적용하하면
	 * setAccelerator에 등록된 이벤트가 호출안됨
	 *
	 * @return
	 */
SqlTab createTabItem() {
    SqlTab sqlTab = new SqlTab(this::txtSqlOnKeyEvent);
    SqlKeywords sqlNode = sqlTab.getSqlNode();
    //코드 AreaHelper 설치.
    new ASTSqlCodeAreaHelper(sqlNode.getCodeArea(), connectionSupplier);
    ContextMenu contextMenu = sqlTab.getTxtSqlPaneContextMenu();
    Menu menuFunc = new Menu("Functions");
    MenuItem menuQueryMacro = new MenuItem("Query-Macro");
    menuQueryMacro.setOnAction(this::menuQueryMacroOnAction);
    MenuItem menuFormatter = new MenuItem("SQL Formatter [F + CTRL + SHIFT] ");
    // 2016-10-27 주석
    // menuFormatter.setAccelerator(new KeyCodeCombination(KeyCode.F,
    // KeyCombination.SHIFT_DOWN, KeyCombination.CONTROL_DOWN));
    menuFormatter.setOnAction(this::menuFormatterOnAction);
    MenuItem menuShowApplicationCode = new MenuItem("Show Application Code");
    menuShowApplicationCode.setOnAction(this::menuShowApplicationCodeOnAction);
    menuFunc.getItems().addAll(menuQueryMacro, menuFormatter, menuShowApplicationCode);
    contextMenu.getItems().add(menuFunc);
    return sqlTab;
}
Also used : SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) ASTSqlCodeAreaHelper(com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SqlTab(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu)

Example 32 with ContextMenu

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

the class DragDropWrapping method createContextMenu.

private ContextMenu createContextMenu() {
    contextMenu = new ContextMenu();
    MenuItem menuSelectAll = new MenuItem("모두선택");
    MenuItem menuDelete = new MenuItem("선택 삭제");
    MenuItem menuTopProp = new MenuItem("위로");
    menuDelete.setOnAction(event -> {
        int indexOf = drawingPane.getChildren().indexOf(source);
        drawingPane.getChildren().remove(indexOf);
    });
    menuTopProp.setOnAction(event -> {
        int indexOf = drawingPane.getChildren().indexOf(source);
        try {
            drawingPane.getChildren().remove(indexOf);
            drawingPane.getChildren().add(getNode());
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
    contextMenu.getItems().addAll(menuSelectAll, menuDelete, menuTopProp);
    return contextMenu;
}
Also used : ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem)

Example 33 with ContextMenu

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

the class DaoWizardViewController method tbParamContextMenu.

/**
	 * tbParam 테이블의 컨텍스트 메뉴 적용
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2015. 10. 22.
	 */
private void tbParamContextMenu() {
    MenuItem menuItemExtractFromQuery = new MenuItem("Extract from Query");
    menuItemExtractFromQuery.setOnAction(this::menuItemExtractFromQueryOnAction);
    MenuItem menuItemRemove = new MenuItem("Remove Var.");
    menuItemRemove.setOnAction(this::menuItemRemoveOnAction);
    // 사실 이 항목은 필요없을것같음.
    // MenuItem addMenuItem = new MenuItem("Add");
    // addMenuItem.setOnAction(this::addMenuParamOnAction);
    // MenuItem deleteMenuItem = new MenuItem("Delete");
    // deleteMenuItem.setOnAction(this::deleteMenuParamOnAction);
    tbParams.setContextMenu(new ContextMenu(menuItemExtractFromQuery, menuItemRemove));
}
Also used : MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu) CommonsContextMenu(com.kyj.fx.voeditor.visual.component.CommonsContextMenu)

Example 34 with ContextMenu

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

the class SystemLayoutViewController method closeContextMenu.

/**
	 * 탭 닫기 메뉴
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2015. 10. 8.
	 * @return
	 */
public ContextMenu closeContextMenu() {
    MenuItem closeMenuItem = new MenuItem("Close");
    closeMenuItem.setOnAction(hander -> {
        DockTab tab = tabPanWorkspace.getSelectionModel().getSelectedItem();
        closeTab(tab);
    });
    MenuItem closeAllMenuItem = new MenuItem("Close All   CTRL + SHIFT + W");
    closeAllMenuItem.setOnAction(handler -> {
        for (int i = tabPanWorkspace.getTabs().size() - 1; i >= 1; i--) {
            DockTab tab = tabPanWorkspace.getTabs().get(i);
            closeTab(tab);
        }
    });
    MenuItem closeOtherMenuItem = new MenuItem("Close Others");
    closeOtherMenuItem.setOnAction(hander -> {
        DockTab tab = tabPanWorkspace.getSelectionModel().getSelectedItem();
        for (int i = tabPanWorkspace.getTabs().size() - 1; i >= 1; i--) {
            DockTab otherTab = tabPanWorkspace.getTabs().get(i);
            if (tab != otherTab)
                closeTab(otherTab);
        }
    });
    MenuItem closeRightMenuItem = new MenuItem("Close Tab to the Right");
    closeRightMenuItem.setOnAction(hander -> {
        ObservableList<DockTab> tabs = tabPanWorkspace.getTabs();
        int tabSize = tabs.size();
        int selectedIndex = tabPanWorkspace.getSelectionModel().getSelectedIndex();
        if (selectedIndex == -1)
            return;
        for (int i = tabSize - 1; i > selectedIndex; i--) {
            DockTab otherTab = tabs.get(i);
            closeTab(otherTab);
        }
    });
    MenuItem closeLeftMenuItem = new MenuItem("Close Tab to the Left");
    closeLeftMenuItem.setOnAction(hander -> {
        DockTab selectedItem = tabPanWorkspace.getSelectionModel().getSelectedItem();
        if (selectedItem == null)
            return;
        ObservableList<DockTab> tabs = null;
        while (true) {
            tabs = tabPanWorkspace.getTabs();
            if (tabs.size() == 1)
                break;
            DockTab dockTab = tabs.get(1);
            if (selectedItem == dockTab)
                break;
            if (dockTab != null)
                closeTab(dockTab);
        }
    });
    ContextMenu contextMenu = new ContextMenu(closeMenuItem, closeOtherMenuItem, closeAllMenuItem, closeRightMenuItem, closeLeftMenuItem);
    return contextMenu;
}
Also used : DockTab(com.kyj.fx.voeditor.visual.component.dock.tab.DockTab) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ContextMenu(javafx.scene.control.ContextMenu)

Example 35 with ContextMenu

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

the class SystemLayoutViewController method createNewTreeViewMenuItems.

/**
	 * 트리뷰의 메뉴컨텍스트를 새로 생성ㅎ한다.
	 *
	 * @Date 2015. 10. 17.
	 * @User KYJ
	 */
private void createNewTreeViewMenuItems() {
    fileTreeContextMenu = new ContextMenu();
    MenuItem openFileMenuItem = new MenuItem("Open");
    Menu menuOpenWidth = new Menu("Open With ");
    /***********************************************************************************/
    // 조건에 따라 보여주는 아이템. [start]
    /***********************************************************************************/
    // FXML선택한경우에만 보여주는 조건처리.
    final MenuItem menuItemOpenWithSceneBuilder = new MenuItem("SceneBuilder");
    final MenuItem menuItemSCMGraphs = new MenuItem("SCM Graphs");
    menuItemSCMGraphs.setDisable(true);
    menuItemSCMGraphs.setOnAction(this::menuItemSCMGraphsOnAction);
    menuItemOpenWithSceneBuilder.setOnAction(this::menuItemOpenWithSceneBuilderOnAction);
    menuOpenWidth.setOnShowing(event -> {
        String sceneBuilderLocation = ResourceLoader.getInstance().get(ResourceLoader.SCENEBUILDER_LOCATION);
        TreeItem<FileWrapper> selectedTreeItem = this.treeProjectFile.getSelectionModel().getSelectedItem();
        boolean isRemoveOpenWidthSceneBuilderMenuItem = true;
        if (selectedTreeItem != null) {
            FileWrapper fileWrapper = selectedTreeItem.getValue();
            File selectedTree = fileWrapper.getFile();
            if (FileUtil.isFXML(selectedTree)) {
                if (!menuOpenWidth.getItems().contains(menuItemOpenWithSceneBuilder)) {
                    menuOpenWidth.getItems().add(menuItemOpenWithSceneBuilder);
                }
                isRemoveOpenWidthSceneBuilderMenuItem = false;
                File file = new File(sceneBuilderLocation);
                if (file.exists()) {
                    menuItemOpenWithSceneBuilder.setDisable(false);
                } else {
                    menuItemOpenWithSceneBuilder.setDisable(true);
                }
            }
        }
        if (isRemoveOpenWidthSceneBuilderMenuItem)
            menuOpenWidth.getItems().remove(menuItemOpenWithSceneBuilder);
    });
    Menu menuRunAs = new Menu("Run As");
    Menu menuPMD = new Menu("PMD");
    fileTreeContextMenu.setOnShowing(ev -> {
        TreeItem<FileWrapper> selectedTreeItem = this.treeProjectFile.getSelectionModel().getSelectedItem();
        boolean isDisableSCMGraphsMenuItem = true;
        if (selectedTreeItem != null) {
            menuRunAs.getItems().clear();
            menuPMD.getItems().clear();
            FileWrapper fileWrapper = selectedTreeItem.getValue();
            File file = fileWrapper.getFile();
            if (fileWrapper.isSVNConnected())
                isDisableSCMGraphsMenuItem = false;
            if (fileWrapper.isJavaProjectFile()) {
                LOGGER.debug("isJavaProjectFile true");
                menuRunAs.getItems().add(new MenuItem("Java Application"));
            }
            if (selectedTreeItem instanceof JavaProjectMemberFileTreeItem) {
                LOGGER.debug("projectFile Member true");
                if (FileUtil.isJavaFile(file)) {
                    MenuItem runJavaApp = new MenuItem("Java Application");
                    runJavaApp.setOnAction(this::miRunJavaAppOnAction);
                    menuRunAs.getItems().add(runJavaApp);
                }
            }
            if (PMDUtil.isSupportedLanguageVersions(file)) {
                MenuItem menuRunPmd = new MenuItem("Run PMD");
                menuRunPmd.setUserData(file);
                menuRunPmd.setOnAction(this::menuRunPmdOnAction);
                menuPMD.getItems().add(menuRunPmd);
            }
            if (file.isDirectory()) {
                MenuItem menuRunAllPmd = new MenuItem("Run All PMD");
                menuRunAllPmd.setUserData(file);
                menuRunAllPmd.setOnAction(this::menuRunPmdOnAction);
                menuPMD.getItems().add(menuRunAllPmd);
            }
            menuRunAs.getItems().add(new SeparatorMenuItem());
            menuRunAs.getItems().add(new MenuItem("Run Configurations"));
        }
        menuItemSCMGraphs.setDisable(isDisableSCMGraphsMenuItem);
    });
    /***********************************************************************************/
    // 조건에 따라 보여주는 아이템. [end]
    /***********************************************************************************/
    {
        MenuItem openSystemExplorerMenuItem = new MenuItem("Open Sys. Explorer");
        openSystemExplorerMenuItem.setOnAction(this::openSystemExplorerMenuItemOnAction);
        menuOpenWidth.getItems().add(openSystemExplorerMenuItem);
    }
    Menu newFileMenuItem = new Menu("New");
    MenuItem newDir = new MenuItem("Dir");
    newDir.setOnAction(this::newDirOnAction);
    newFileMenuItem.getItems().add(newDir);
    MenuItem deleteFileMenuItem = new MenuItem("Delete");
    KeyCodeCombination value = new KeyCodeCombination(KeyCode.DELETE);
    deleteFileMenuItem.setAccelerator(value);
    deleteFileMenuItem.setOnAction(this::deleteFileMenuItemOnAction);
    // 선택한 파일아이템을 VoEditor에서 조회시 사용
    // MenuItem voEditorMenuItem = new MenuItem("Show VO Editor");
    // //선택한 파일아이템을 DaoWizard에서 조회시 사용
    // MenuItem daoWizardMenuItem = new MenuItem("Show DAO Wizard");
    // 선택한 파일경로를 Vo Editor Location에 바인딩함.
    // MenuItem setVoEditorMenuItem = new MenuItem("SET Vo Editor
    // Directory");
    // 선택한 파일경로를 Vo Editor Location에 바인딩함.
    MenuItem voEditorMenuItem = new MenuItem("Vo Editor");
    // 선택한 파일경로를 DaoWizard Location에 바인딩함.
    MenuItem setDaoWizardMenuItem = new MenuItem("SET DAO Wizard Directory");
    // 경로 리프레쉬
    MenuItem refleshMenuItem = new MenuItem("Reflesh");
    // 코드분석
    MenuItem chodeAnalysisMenuItem = new MenuItem("자바 코드 분석");
    // 사양서 생성
    MenuItem makeProgramSpecMenuItem = new MenuItem("Gen. Program Spec.");
    // 파일 속성 조회
    MenuItem menuProperties = new MenuItem("Properties");
    menuProperties.setOnAction(this::menuPropertiesOnAction);
    chodeAnalysisMenuItem.setOnAction(this::menuItemCodeAnalysisMenuItemOnAction);
    fileTreeContextMenu.getItems().addAll(openFileMenuItem, menuOpenWidth, newFileMenuItem, deleteFileMenuItem, /* voEditorMenuItem, daoWizardMenuItem, */
    voEditorMenuItem, /* setVoEditorMenuItem, */
    setDaoWizardMenuItem, chodeAnalysisMenuItem, makeProgramSpecMenuItem, menuItemSCMGraphs, new SeparatorMenuItem(), refleshMenuItem, new SeparatorMenuItem(), menuPMD, new SeparatorMenuItem(), menuRunAs, new SeparatorMenuItem(), menuProperties);
    // daoWizardMenuItem.addEventHandler(ActionEvent.ACTION,
    // this::daoWizardMenuItemOnActionEvent);
    // Vo Editor
    // setVoEditorMenuItem.addEventHandler(ActionEvent.ACTION, event -> {
    // Node lookup = borderPaneMain.lookup("#txtLocation");
    // if (lookup != null && tmpSelectFileWrapper != null) {
    // TextField txtLocation = (TextField) lookup;
    // File file = tmpSelectFileWrapper.getFile();
    // if (file.isDirectory()) {
    // String absolutePath = file.getAbsolutePath();
    // ResourceLoader.getInstance().put(ResourceLoader.USER_SELECT_LOCATION_PATH,
    // absolutePath);
    // txtLocation.setText(absolutePath);
    // } else {
    // DialogUtil.showMessageDialog("Only Directory.");
    // }
    // }
    // tmpSelectFileWrapper = null;
    // });
    voEditorMenuItem.addEventHandler(ActionEvent.ACTION, this::voEditorMenuItemOnAction);
    // Dao Wizard
    setDaoWizardMenuItem.addEventHandler(ActionEvent.ACTION, event -> {
        Node lookup = borderPaneMain.lookup("#txtDaoLocation");
        if (lookup != null && tmpSelectFileWrapper != null) {
            TextField txtLocation = (TextField) lookup;
            File file = tmpSelectFileWrapper.getFile();
            if (file.exists() && file.isDirectory()) {
                ResourceLoader.getInstance().put(ResourceLoader.USER_SELECT_LOCATION_PATH, file.getAbsolutePath());
                Path relativize = FileUtil.toRelativizeForGagoyle(file);
                txtLocation.setText(File.separator + relativize.toString());
            } else {
                DialogUtil.showMessageDialog("Only Directory.");
            }
        }
        tmpSelectFileWrapper = null;
    });
    refleshMenuItem.setOnAction(event -> {
        TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
        refleshWorkspaceTreeItem(selectedItem);
    });
    //함수위치로 이동
    //		deleteFileMenuItem.setOnAction(event -> {
    //			TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
    //			if (selectedItem != null) {
    //				File file = selectedItem.getValue().getFile();
    //				if (file != null && file.exists()) {
    //					Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("파일삭제.",
    //							file.getName() + " 정말 삭제하시겠습니까? \n[휴지통에 보관되지않음.]");
    //					showYesOrNoDialog.ifPresent(pair -> {
    //						if ("Y".equals(pair.getValue())) {
    //							TreeItem<FileWrapper> root = treeProjectFile.getRoot();
    //							root.getChildren().remove(selectedItem);
    //							file.delete();
    //						}
    //					});
    //				}
    //			}
    //		});
    makeProgramSpecMenuItem.setOnAction(event -> {
        TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            File sourceFile = selectedItem.getValue().getFile();
            if (sourceFile != null && sourceFile.exists()) {
                try {
                    if (FileUtil.isJavaFile(sourceFile)) {
                        File targetFile = DialogUtil.showFileSaveCheckDialog(SharedMemory.getPrimaryStage(), chooser -> {
                            chooser.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
                            chooser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.DOCX_NAME, GargoyleExtensionFilters.DOCX));
                            chooser.setTitle("Save Program Spec. Doc");
                            chooser.setInitialDirectory(new File(SystemUtils.USER_HOME));
                        });
                        if (targetFile != null) {
                            boolean createDefault = ProgramSpecUtil.createDefault(sourceFile, targetFile);
                            if (createDefault)
                                FileUtil.openFile(targetFile);
                        }
                    } else {
                        DialogUtil.showMessageDialog("사양서 작성 가능한 유형이 아닙니다.");
                    }
                } catch (Exception e) {
                    DialogUtil.showExceptionDailog(e);
                }
            }
        }
    });
}
Also used : Path(java.nio.file.Path) JavaProjectMemberFileTreeItem(com.kyj.fx.voeditor.visual.component.JavaProjectMemberFileTreeItem) Node(javafx.scene.Node) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) IOException(java.io.IOException) GargoyleException(com.kyj.fx.voeditor.visual.exceptions.GargoyleException) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) FileWrapper(com.kyj.fx.voeditor.visual.component.FileWrapper) TextField(javafx.scene.control.TextField) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu) File(java.io.File)

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