Search in sources :

Example 6 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination in project bitsquare by bitsquare.

the class BitsquareApp method start.

@Override
public void start(Stage stage) throws IOException {
    BitsquareApp.primaryStage = stage;
    String logPath = Paths.get(env.getProperty(AppOptionKeys.APP_DATA_DIR_KEY), "bitsquare").toString();
    Log.setup(logPath);
    log.info("Log files under: " + logPath);
    Version.printVersion();
    Utilities.printSysInfo();
    Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));
    UserThread.setExecutor(Platform::runLater);
    UserThread.setTimerClass(UITimer.class);
    shutDownHandler = this::stop;
    // setup UncaughtExceptionHandler
    Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
        // Might come from another thread 
        if (throwable.getCause() != null && throwable.getCause().getCause() != null && throwable.getCause().getCause() instanceof BlockStoreException) {
            log.error(throwable.getMessage());
        } else if (throwable instanceof ClassCastException && "sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData".equals(throwable.getMessage())) {
            log.warn(throwable.getMessage());
        } else {
            log.error("Uncaught Exception from thread " + Thread.currentThread().getName());
            log.error("throwableMessage= " + throwable.getMessage());
            log.error("throwableClass= " + throwable.getClass());
            log.error("Stack trace:\n" + ExceptionUtils.getStackTrace(throwable));
            throwable.printStackTrace();
            UserThread.execute(() -> showErrorPopup(throwable, false));
        }
    };
    Thread.setDefaultUncaughtExceptionHandler(handler);
    Thread.currentThread().setUncaughtExceptionHandler(handler);
    try {
        Utilities.checkCryptoPolicySetup();
    } catch (NoSuchAlgorithmException | LimitedKeyStrengthException e) {
        e.printStackTrace();
        UserThread.execute(() -> showErrorPopup(e, true));
    }
    Security.addProvider(new BouncyCastleProvider());
    try {
        // Guice
        bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
        injector = Guice.createInjector(bitsquareAppModule);
        injector.getInstance(InjectorViewFactory.class).setInjector(injector);
        Version.setBtcNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal());
        if (Utilities.isLinux())
            System.setProperty("prism.lcdtext", "false");
        Storage.setDatabaseCorruptionHandler((String fileName) -> {
            corruptedDatabaseFiles.add(fileName);
            if (mainView != null)
                mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
        });
        // load the main view and create the main scene
        CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
        mainView = (MainView) viewLoader.load(MainView.class);
        mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
        /* Storage.setDatabaseCorruptionHandler((String fileName) -> {
                corruptedDatabaseFiles.add(fileName);
                if (mainView != null)
                    mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
            });*/
        //740
        scene = new Scene(mainView.getRoot(), 1200, 700);
        Font.loadFont(getClass().getResource("/fonts/Verdana.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaBold.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaItalic.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaBoldItalic.ttf").toExternalForm(), 13);
        scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css", "/io/bitsquare/gui/CandleStickChart.css");
        // configure the system tray
        SystemTray.create(primaryStage, shutDownHandler);
        primaryStage.setOnCloseRequest(event -> {
            event.consume();
            stop();
        });
        scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> {
            if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.W, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                stop();
            } else if (new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                stop();
            } else if (new KeyCodeCombination(KeyCode.E, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                showEmptyWalletPopup();
            } else if (new KeyCodeCombination(KeyCode.M, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showSendAlertMessagePopup();
            } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showFilterPopup();
            } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showFPSWindow();
            } else if (new KeyCodeCombination(KeyCode.J, KeyCombination.ALT_DOWN).match(keyEvent)) {
                WalletService walletService = injector.getInstance(WalletService.class);
                if (walletService.getWallet() != null)
                    new ShowWalletDataWindow(walletService).information("Wallet raw data").show();
                else
                    new Popup<>().warning("The wallet is not initialized yet").show();
            } else if (new KeyCodeCombination(KeyCode.G, KeyCombination.ALT_DOWN).match(keyEvent)) {
                TradeWalletService tradeWalletService = injector.getInstance(TradeWalletService.class);
                WalletService walletService = injector.getInstance(WalletService.class);
                if (walletService.getWallet() != null)
                    new SpendFromDepositTxWindow(tradeWalletService).information("Emergency wallet tool").show();
                else
                    new Popup<>().warning("The wallet is not initialized yet").show();
            } else if (DevFlags.DEV_MODE && new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) {
                showDebugWindow();
            }
        });
        // configure the primary stage
        primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY));
        primaryStage.setScene(scene);
        // 1190
        primaryStage.setMinWidth(1000);
        primaryStage.setMinHeight(620);
        // on windows the title icon is also used as task bar icon in a larger size
        // on Linux no title icon is supported but also a large task bar icon is derived from that title icon
        String iconPath;
        if (Utilities.isOSX())
            iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png";
        else if (Utilities.isWindows())
            iconPath = "/images/task_bar_icon_windows.png";
        else
            iconPath = "/images/task_bar_icon_linux.png";
        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));
        // make the UI visible
        primaryStage.show();
        if (!Utilities.isCorrectOSArchitecture()) {
            String osArchitecture = Utilities.getOSArchitecture();
            // We don't force a shutdown as the osArchitecture might in strange cases return a wrong value.
            // Needs at least more testing on different machines...
            new Popup<>().warning("You probably have the wrong Bitsquare version for this computer.\n" + "Your computer's architecture is: " + osArchitecture + ".\n" + "The Bitsquare binary you installed is: " + Utilities.getJVMArchitecture() + ".\n" + "Please shut down and re-install the correct version (" + osArchitecture + ").").show();
        }
        UserThread.runPeriodically(() -> Profiler.printSystemLoad(log), LOG_MEMORY_PERIOD_MIN, TimeUnit.MINUTES);
    } catch (Throwable throwable) {
        showErrorPopup(throwable, false);
    }
}
Also used : StageStyle(javafx.stage.StageStyle) Popup(io.bitsquare.gui.main.overlays.popups.Popup) LoggerFactory(org.slf4j.LoggerFactory) Security(java.security.Security) View(io.bitsquare.gui.common.view.View) StackPane(javafx.scene.layout.StackPane) KeyCombination(javafx.scene.input.KeyCombination) Application(javafx.application.Application) Parent(javafx.scene.Parent) UITimer(io.bitsquare.gui.common.UITimer) TradeWalletService(io.bitsquare.btc.TradeWalletService) ResultHandler(io.bitsquare.common.handlers.ResultHandler) BlockStoreException(org.bitcoinj.store.BlockStoreException) Pane(javafx.scene.layout.Pane) Font(javafx.scene.text.Font) LimitedKeyStrengthException(io.bitsquare.common.util.LimitedKeyStrengthException) FilterManager(io.bitsquare.filter.FilterManager) KeyEvent(javafx.scene.input.KeyEvent) InjectorViewFactory(io.bitsquare.gui.common.view.guice.InjectorViewFactory) Platform(javafx.application.Platform) List(java.util.List) io.bitsquare.gui.main.overlays.windows(io.bitsquare.gui.main.overlays.windows) Logger(ch.qos.logback.classic.Logger) MainViewModel(io.bitsquare.gui.main.MainViewModel) Environment(org.springframework.core.env.Environment) Dialogs(org.controlsfx.dialog.Dialogs) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) EventStreams(org.reactfx.EventStreams) CommonOptionKeys(io.bitsquare.common.CommonOptionKeys) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) Scene(javafx.scene.Scene) MainView(io.bitsquare.gui.main.MainView) DebugView(io.bitsquare.gui.main.debug.DebugView) P2PService(io.bitsquare.p2p.P2PService) ArrayList(java.util.ArrayList) TradeManager(io.bitsquare.trade.TradeManager) CachingViewLoader(io.bitsquare.gui.common.view.CachingViewLoader) WalletService(io.bitsquare.btc.WalletService) SystemTray(io.bitsquare.gui.SystemTray) APP_NAME_KEY(io.bitsquare.app.AppOptionKeys.APP_NAME_KEY) KeyCode(javafx.scene.input.KeyCode) Modality(javafx.stage.Modality) Utilities(io.bitsquare.common.util.Utilities) Label(javafx.scene.control.Label) UserThread(io.bitsquare.common.UserThread) ImageUtil(io.bitsquare.gui.util.ImageUtil) IOException(java.io.IOException) ViewLoader(io.bitsquare.gui.common.view.ViewLoader) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) Injector(com.google.inject.Injector) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) TimeUnit(java.util.concurrent.TimeUnit) Level(ch.qos.logback.classic.Level) Stage(javafx.stage.Stage) Paths(java.nio.file.Paths) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) ArbitratorManager(io.bitsquare.arbitration.ArbitratorManager) Guice(com.google.inject.Guice) Profiler(io.bitsquare.common.util.Profiler) Storage(io.bitsquare.storage.Storage) Image(javafx.scene.image.Image) AlertManager(io.bitsquare.alert.AlertManager) Platform(javafx.application.Platform) TradeWalletService(io.bitsquare.btc.TradeWalletService) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Image(javafx.scene.image.Image) TradeWalletService(io.bitsquare.btc.TradeWalletService) WalletService(io.bitsquare.btc.WalletService) CachingViewLoader(io.bitsquare.gui.common.view.CachingViewLoader) LimitedKeyStrengthException(io.bitsquare.common.util.LimitedKeyStrengthException) Popup(io.bitsquare.gui.main.overlays.popups.Popup) InjectorViewFactory(io.bitsquare.gui.common.view.guice.InjectorViewFactory) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) BlockStoreException(org.bitcoinj.store.BlockStoreException) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) Scene(javafx.scene.Scene) UserThread(io.bitsquare.common.UserThread)

Example 7 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination in project Gargoyle by callakrsos.

the class PagedCodeAreaFindAndReplaceHelper method createMenus.

/**
	 *  FindAndReplace에 대한 메뉴를 정의.
	 * @return
	 * @작성자 : KYJ
	 * @작성일 : 2017. 1. 13.
	 */
public Menu createMenus() {
    menuSearch = new Menu("Search");
    miFindReplace = new MenuItem("Find/Replace");
    miFindReplace.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN));
    miFindReplace.setOnAction(this::findReplaceEvent);
    menuSearch.getItems().add(miFindReplace);
    return menuSearch;
}
Also used : MenuItem(javafx.scene.control.MenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) Menu(javafx.scene.control.Menu)

Example 8 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination in project Gargoyle by callakrsos.

the class MacroSqlComposite method post.

@FxPostInitialize
public void post() {
    MenuItem menuAddItem = new MenuItem("Add");
    menuAddItem.setAccelerator(new KeyCodeCombination(KeyCode.INSERT, KeyCharacterCombination.CONTROL_DOWN));
    menuAddItem.setOnAction(e -> {
        addOnAction();
    });
    MenuItem menuDeleteItem = new MenuItem("Delete");
    menuDeleteItem.setAccelerator(new KeyCodeCombination(KeyCode.DELETE, KeyCharacterCombination.CONTROL_DOWN));
    menuDeleteItem.setOnAction(e -> {
        addOnAction();
    });
    tvFavorite.setContextMenu(new ContextMenu(menuAddItem, menuDeleteItem));
    borContent.setCenter(new MacroControl(connectionSupplier, initText));
    MacroFavorTreeItemCreator macroFavorTreeItem = new MacroFavorTreeItemCreator(connectionSupplier);
    MacroItemVO f = new MacroItemVO();
    tvFavorite.setRoot(macroFavorTreeItem.createRoot(f));
    tvFavorite.setShowRoot(false);
}
Also used : MenuItem(javafx.scene.control.MenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ContextMenu(javafx.scene.control.ContextMenu) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Example 9 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination 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 10 with KeyCodeCombination

use of javafx.scene.input.KeyCodeCombination 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

KeyCodeCombination (javafx.scene.input.KeyCodeCombination)14 MenuItem (javafx.scene.control.MenuItem)8 Menu (javafx.scene.control.Menu)7 ContextMenu (javafx.scene.control.ContextMenu)5 Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 MainView (io.bitsquare.gui.main.MainView)2 SendPrivateNotificationWindow (io.bitsquare.gui.main.overlays.windows.SendPrivateNotificationWindow)2 IOException (java.io.IOException)2 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)2 Level (ch.qos.logback.classic.Level)1 Logger (ch.qos.logback.classic.Logger)1 Guice (com.google.inject.Guice)1 Injector (com.google.inject.Injector)1 FileWrapper (com.kyj.fx.voeditor.visual.component.FileWrapper)1 JavaProjectMemberFileTreeItem (com.kyj.fx.voeditor.visual.component.JavaProjectMemberFileTreeItem)1 CommonsSqllPan (com.kyj.fx.voeditor.visual.component.sql.view.CommonsSqllPan)1 GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)1 FxPostInitialize (com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)1 AlertManager (io.bitsquare.alert.AlertManager)1 APP_NAME_KEY (io.bitsquare.app.AppOptionKeys.APP_NAME_KEY)1