Search in sources :

Example 36 with ImageView

use of javafx.scene.image.ImageView in project mybatis-generator-gui by zouzg.

the class MainUIController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    ImageView dbImage = new ImageView("icons/computer.png");
    dbImage.setFitHeight(40);
    dbImage.setFitWidth(40);
    connectionLabel.setGraphic(dbImage);
    connectionLabel.setOnMouseClicked(event -> {
        DbConnectionController controller = (DbConnectionController) loadFXMLPage("新建数据库连接", FXMLPage.NEW_CONNECTION, false);
        controller.setMainUIController(this);
        controller.showDialogStage();
    });
    ImageView configImage = new ImageView("icons/config-list.png");
    configImage.setFitHeight(40);
    configImage.setFitWidth(40);
    configsLabel.setGraphic(configImage);
    configsLabel.setOnMouseClicked(event -> {
        GeneratorConfigController controller = (GeneratorConfigController) loadFXMLPage("配置", FXMLPage.GENERATOR_CONFIG, false);
        controller.setMainUIController(this);
        controller.showDialogStage();
    });
    leftDBTree.setShowRoot(false);
    leftDBTree.setRoot(new TreeItem<>());
    Callback<TreeView<String>, TreeCell<String>> defaultCellFactory = TextFieldTreeCell.forTreeView();
    leftDBTree.setCellFactory((TreeView<String> tv) -> {
        TreeCell<String> cell = defaultCellFactory.call(tv);
        cell.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
            int level = leftDBTree.getTreeItemLevel(cell.getTreeItem());
            TreeCell<String> treeCell = (TreeCell<String>) event.getSource();
            TreeItem<String> treeItem = treeCell.getTreeItem();
            if (level == 1) {
                final ContextMenu contextMenu = new ContextMenu();
                MenuItem item1 = new MenuItem("关闭连接");
                item1.setOnAction(event1 -> treeItem.getChildren().clear());
                MenuItem item2 = new MenuItem("编辑连接");
                item2.setOnAction(event1 -> {
                    DatabaseConfig selectedConfig = (DatabaseConfig) treeItem.getGraphic().getUserData();
                    DbConnectionController controller = (DbConnectionController) loadFXMLPage("编辑数据库连接", FXMLPage.NEW_CONNECTION, false);
                    controller.setMainUIController(this);
                    controller.setConfig(selectedConfig);
                    controller.showDialogStage();
                });
                MenuItem item3 = new MenuItem("删除连接");
                item3.setOnAction(event1 -> {
                    DatabaseConfig selectedConfig = (DatabaseConfig) treeItem.getGraphic().getUserData();
                    try {
                        ConfigHelper.deleteDatabaseConfig(selectedConfig);
                        this.loadLeftDBTree();
                    } catch (Exception e) {
                        AlertUtil.showErrorAlert("Delete connection failed! Reason: " + e.getMessage());
                    }
                });
                contextMenu.getItems().addAll(item1, item2, item3);
                cell.setContextMenu(contextMenu);
            }
            if (event.getClickCount() == 2) {
                treeItem.setExpanded(true);
                if (level == 1) {
                    System.out.println("index: " + leftDBTree.getSelectionModel().getSelectedIndex());
                    DatabaseConfig selectedConfig = (DatabaseConfig) treeItem.getGraphic().getUserData();
                    try {
                        List<String> tables = DbUtil.getTableNames(selectedConfig);
                        if (tables != null && tables.size() > 0) {
                            ObservableList<TreeItem<String>> children = cell.getTreeItem().getChildren();
                            children.clear();
                            for (String tableName : tables) {
                                TreeItem<String> newTreeItem = new TreeItem<>();
                                ImageView imageView = new ImageView("icons/table.png");
                                imageView.setFitHeight(16);
                                imageView.setFitWidth(16);
                                newTreeItem.setGraphic(imageView);
                                newTreeItem.setValue(tableName);
                                children.add(newTreeItem);
                            }
                        }
                    } catch (SQLRecoverableException e) {
                        _LOG.error(e.getMessage(), e);
                        AlertUtil.showErrorAlert("连接超时");
                    } catch (Exception e) {
                        _LOG.error(e.getMessage(), e);
                        AlertUtil.showErrorAlert(e.getMessage());
                    }
                } else if (level == 2) {
                    // left DB tree level3
                    String tableName = treeCell.getTreeItem().getValue();
                    selectedDatabaseConfig = (DatabaseConfig) treeItem.getParent().getGraphic().getUserData();
                    this.tableName = tableName;
                    tableNameField.setText(tableName);
                    domainObjectNameField.setText(MyStringUtils.dbStringToCamelStyle(tableName));
                }
            }
        });
        return cell;
    });
    loadLeftDBTree();
    setTooltip();
}
Also used : SQLRecoverableException(java.sql.SQLRecoverableException) SQLRecoverableException(java.sql.SQLRecoverableException) TextFieldTreeCell(javafx.scene.control.cell.TextFieldTreeCell) ImageView(javafx.scene.image.ImageView) DatabaseConfig(com.zzg.mybatis.generator.model.DatabaseConfig) ColumnOverride(org.mybatis.generator.config.ColumnOverride)

Example 37 with ImageView

use of javafx.scene.image.ImageView in project Challenger4SysAdmins by fvarrui.

the class MenuBuilder method getMenu.

/**
 * @param itemSelected elemento que tengamos seleccionado.
 *
 * @return menu contextual correspondiente al tipo del objeto seleccionado.
 */
public static ContextMenu getMenu(TreeItem<Object> itemSelected) {
    ContextMenu contextMenu = new ContextMenu();
    ListProperty<MenuItem> menuItems = new SimpleListProperty<>(FXCollections.observableArrayList());
    if (itemSelected.getParent() == null) {
        menuItems.add(new MenuItem("A�adir Goal", new ImageView(new Image("/fvarrui/sysadmin/editor/ui/resources/mas-16x16.png"))));
        menuItems.add(new MenuItem("Eliminar Goal", new ImageView(new Image("/fvarrui/sysadmin/editor/ui/resources/menos-16x16.png"))));
        contextMenu.getItems().addAll(menuItems);
    } else {
        menuItems.add(new MenuItem("A�adir Test", new ImageView(new Image("/fvarrui/sysadmin/editor/ui/resources/mas-16x16.png"))));
        menuItems.add(new MenuItem("Eliminar Test", new ImageView(new Image("/fvarrui/sysadmin/editor/ui/resources/menos-16x16.png"))));
        contextMenu.getItems().addAll(menuItems);
    }
    return contextMenu;
}
Also used : SimpleListProperty(javafx.beans.property.SimpleListProperty) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image)

Example 38 with ImageView

use of javafx.scene.image.ImageView in project BTW by TechnionYearlyProject.

the class DrawMapController method playButtonClicked.

/**
 *@author: Orel
 * @date: 20/1/18
 */
private void playButtonClicked(ActionEvent event) {
    Image buttonImage;
    if (isPlayButton) {
        buttonImage = new Image(getClass().getResourceAsStream("/icons8-pause-50.png"));
        tickButton.setDisable(true);
        // only fetch a new task if the previous task didn't finish
        if (!lastTickActionWasPause)
            resetTickTask();
        lastTickActionWasPause = false;
        playCityTimeline.play();
    } else {
        buttonImage = new Image(getClass().getResourceAsStream("/icons8-play-50.png"));
        tickButton.setDisable(false);
        lastTickActionWasPause = true;
        playCityTimeline.stop();
    }
    isPlayButton = !isPlayButton;
    playButton.setGraphic(new ImageView(buttonImage));
}
Also used : ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image)

Example 39 with ImageView

use of javafx.scene.image.ImageView in project Krothium-Launcher by DarkLBP.

the class MainFX method updateIcon.

/**
 * Updates the selected icon
 */
@FXML
public final void updateIcon() {
    if (iconList.getSelectionModel().getSelectedIndex() == -1) {
        // Nothing has been selected
        return;
    }
    ImageView selected = iconList.getSelectionModel().getSelectedItem();
    profileIcon.setImage(selected.getImage());
    profileIcon.setId(selected.getId());
    iconList.setVisible(false);
}
Also used : ImageView(javafx.scene.image.ImageView) FXML(javafx.fxml.FXML)

Example 40 with ImageView

use of javafx.scene.image.ImageView in project Krothium-Launcher by DarkLBP.

the class MainFX method loadProfileList.

/**
 * Loads profiles list items
 */
private void loadProfileList() {
    console.print("Loading profile list...");
    ObservableList<Label> profileListItems = getProfileList();
    // Add "Add New Profile" item
    profileListItems.add(0, new Label(Language.get(51), new ImageView(new Image("/kml/gui/textures/add.png"))));
    profileList.setItems(profileListItems);
    profileListLoaded = true;
    console.print("Profile list loaded.");
}
Also used : ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image)

Aggregations

ImageView (javafx.scene.image.ImageView)201 Image (javafx.scene.image.Image)90 Button (javafx.scene.control.Button)45 Label (javafx.scene.control.Label)41 Insets (javafx.geometry.Insets)35 Tooltip (javafx.scene.control.Tooltip)32 VBox (javafx.scene.layout.VBox)29 Scene (javafx.scene.Scene)25 File (java.io.File)24 ChangeListener (javafx.beans.value.ChangeListener)24 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)20 Node (javafx.scene.Node)20 AnchorPane (javafx.scene.layout.AnchorPane)20 Callback (javafx.util.Callback)20 Pane (javafx.scene.layout.Pane)18 GridPane (javafx.scene.layout.GridPane)17 HBox (javafx.scene.layout.HBox)17 StackPane (javafx.scene.layout.StackPane)17 Inject (javax.inject.Inject)17 List (java.util.List)16