Search in sources :

Example 1 with PseudoClass

use of javafx.css.PseudoClass in project Gargoyle by callakrsos.

the class SkinPreviewViewComposite method previewTabInit.

@FxPostInitialize
public void previewTabInit() {
    Task<Void> task = new Task<Void>() {

        @Override
        protected Void call() throws Exception {
            Thread.sleep(5000L);
            Platform.runLater(() -> {
                //메뉴바 배경.
                {
                    Background background = mbSample.getBackground();
                    Color fill = (Color) background.getFills().get(0).getFill();
                    colorMbSample.setValue(fill);
                    //메뉴바 텍스트
                    {
                        Label lookup = (Label) mbSample.lookup(".label");
                        Color textFill = (Color) lookup.getTextFill();
                        colorMbLabelSample.setValue(textFill);
                    }
                }
                //Hbox 배경.
                {
                    Background background = hboxSample.getBackground();
                    Color fill = (Color) background.getFills().get(0).getFill();
                    colorHboxSample.setValue(fill);
                }
                {
                    //선택디지않는 탭 색상 처리.
                    Set<Node> lookupAll = tabpaneSample.lookupAll(".tab:top");
                    lookupAll.forEach(lookup -> {
                        Optional<PseudoClass> findFirst = lookup.getPseudoClassStates().stream().filter(v -> {
                            return "selected".equals(v.getPseudoClassName());
                        }).findFirst();
                        if (findFirst.isPresent()) {
                            Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
                            Color textFill = (Color) selectedTabLabel.getTextFill();
                            colorSelectedTabText.setValue(textFill);
                        } else {
                            Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
                            Color textFill = (Color) selectedTabLabel.getTextFill();
                            colorUnSelectedTabText.setValue(textFill);
                        }
                    });
                    {
                        lookupAll.stream().findFirst().ifPresent(n -> {
                            Pane p = (Pane) n;
                            Background background = p.getBackground();
                            Color fill = (Color) background.getFills().get(0).getFill();
                            colorTabSample1Selected.setValue(fill);
                        });
                    }
                }
            });
            return null;
        }
    };
    Window window = this.getScene().getWindow();
    if (window != null) {
        FxUtil.showLoading(window, task);
    } else
        FxUtil.showLoading(task);
}
Also used : Button(javafx.scene.control.Button) TextArea(javafx.scene.control.TextArea) PseudoClass(javafx.css.PseudoClass) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) TableColumn(javafx.scene.control.TableColumn) Task(javafx.concurrent.Task) TabPane(javafx.scene.control.TabPane) Map(java.util.Map) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) TableView(javafx.scene.control.TableView) Pane(javafx.scene.layout.Pane) ColorPicker(javafx.scene.control.ColorPicker) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) Pair(javafx.util.Pair) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) Node(javafx.scene.Node) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) Set(java.util.Set) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) JFXToggleButton(com.jfoenix.controls.JFXToggleButton) Background(javafx.scene.layout.Background) File(java.io.File) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) Stage(javafx.stage.Stage) Optional(java.util.Optional) Window(javafx.stage.Window) SkinManager(com.kyj.fx.voeditor.visual.momory.SkinManager) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) StringProperty(javafx.beans.property.StringProperty) Window(javafx.stage.Window) Task(javafx.concurrent.Task) Set(java.util.Set) Background(javafx.scene.layout.Background) Optional(java.util.Optional) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) TabPane(javafx.scene.control.TabPane) Pane(javafx.scene.layout.Pane) BorderPane(javafx.scene.layout.BorderPane) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Example 2 with PseudoClass

use of javafx.css.PseudoClass in project POL-POM-5 by PhoenicisOrg.

the class CreateShortcutPanel method populate.

/**
 * populates the panel
 */
public void populate() {
    final PseudoClass errorClass = PseudoClass.getPseudoClass("error");
    final VBox vBox = new VBox();
    GridPane gridPane = new GridPane();
    gridPane.getStyleClass().add("grid");
    gridPane.getColumnConstraints().addAll(new ColumnConstraintsWithPercentage(30), new ColumnConstraintsWithPercentage(70));
    // name
    Label nameLabel = new Label(tr("Name:"));
    nameLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(nameLabel, VPos.TOP);
    gridPane.add(nameLabel, 0, 0);
    TextField name = new TextField();
    gridPane.add(name, 1, 0);
    Tooltip nameErrorTooltip = new Tooltip(tr("Please specify a name!"));
    // category
    Label categoryLabel = new Label(tr("Category:"));
    categoryLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(categoryLabel, VPos.TOP);
    gridPane.add(categoryLabel, 0, 1);
    TextField category = new TextField();
    gridPane.add(category, 1, 1);
    Tooltip categoryErrorTooltip = new Tooltip(tr("Please specify a category!"));
    // description
    Label descriptionLabel = new Label(tr("Description:"));
    descriptionLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(descriptionLabel, VPos.TOP);
    gridPane.add(descriptionLabel, 0, 2);
    TextArea description = new TextArea();
    gridPane.add(description, 1, 2);
    // miniature
    Label miniatureLabel = new Label(tr("Miniature:"));
    miniatureLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(miniatureLabel, VPos.TOP);
    gridPane.add(miniatureLabel, 0, 3);
    TextField miniature = new TextField();
    Button openMiniatureBrowser = new Button(tr("Choose"));
    openMiniatureBrowser.setOnAction(event -> {
        FileChooser chooser = new FileChooser();
        chooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(tr("Images"), "*.miniature, *.png"));
        File newMiniature = chooser.showOpenDialog(null);
        miniature.setText(newMiniature.toString());
    });
    HBox miniatureHbox = new HBox(miniature, openMiniatureBrowser);
    HBox.setHgrow(miniature, Priority.ALWAYS);
    gridPane.add(miniatureHbox, 1, 3);
    Tooltip miniatureErrorTooltip = new Tooltip(tr("Please specify a valid miniature!"));
    // executable
    Label executableLabel = new Label(tr("Executable:"));
    executableLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(executableLabel, VPos.TOP);
    gridPane.add(executableLabel, 0, 4);
    TextField executable = new TextField();
    Button openExecutableBrowser = new Button(tr("Choose"));
    openExecutableBrowser.setOnAction(event -> {
        FileChooser chooser = new FileChooser();
        File newMiniature = chooser.showOpenDialog(null);
        executable.setText(newMiniature.toString());
    });
    HBox executableHbox = new HBox(executable, openExecutableBrowser);
    HBox.setHgrow(executable, Priority.ALWAYS);
    gridPane.add(executableHbox, 1, 4);
    Tooltip executableErrorTooltip = new Tooltip(tr("Please specify a valid executable!"));
    Region spacer = new Region();
    spacer.getStyleClass().add("detailsButtonSpacer");
    Button createButton = new Button(tr("Create"));
    createButton.setOnMouseClicked(event -> {
        boolean error = false;
        if (StringUtils.isEmpty(name.getText())) {
            name.pseudoClassStateChanged(errorClass, true);
            name.setTooltip(nameErrorTooltip);
            error = true;
        }
        if (StringUtils.isEmpty(category.getText())) {
            category.pseudoClassStateChanged(errorClass, true);
            category.setTooltip(categoryErrorTooltip);
            error = true;
        }
        URI miniatureUri = null;
        // but if a miniature is given, it must exist
        if (StringUtils.isNotEmpty(miniature.getText())) {
            File miniatureFile = new File(miniature.getText());
            if (miniatureFile.exists()) {
                miniatureUri = miniatureFile.toURI();
            } else {
                miniature.pseudoClassStateChanged(errorClass, true);
                miniature.setTooltip(miniatureErrorTooltip);
                error = true;
            }
        }
        File executableFile = new File(executable.getText());
        if (!executableFile.exists()) {
            executable.pseudoClassStateChanged(errorClass, true);
            executable.setTooltip(executableErrorTooltip);
            error = true;
        }
        if (!error) {
            ShortcutCreationDTO newShortcut = new ShortcutCreationDTO.Builder().withName(name.getText()).withCategory(category.getText()).withDescription(description.getText()).withMiniature(miniatureUri).withExecutable(executableFile).build();
            this.onCreateShortcut.accept(newShortcut);
        }
    });
    vBox.getChildren().addAll(gridPane, spacer, createButton);
    this.setCenter(vBox);
}
Also used : PseudoClass(javafx.css.PseudoClass) ShortcutCreationDTO(org.phoenicis.library.dto.ShortcutCreationDTO) URI(java.net.URI) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) FileChooser(javafx.stage.FileChooser) File(java.io.File)

Example 3 with PseudoClass

use of javafx.css.PseudoClass in project phoenicis by PhoenicisOrg.

the class CreateShortcutPanel method populate.

/**
 * populates the panel
 */
public void populate() {
    final PseudoClass errorClass = PseudoClass.getPseudoClass("error");
    final VBox vBox = new VBox();
    GridPane gridPane = new GridPane();
    gridPane.getStyleClass().add("grid");
    gridPane.getColumnConstraints().addAll(new ColumnConstraintsWithPercentage(30), new ColumnConstraintsWithPercentage(70));
    // name
    Label nameLabel = new Label(tr("Name:"));
    nameLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(nameLabel, VPos.TOP);
    gridPane.add(nameLabel, 0, 0);
    TextField name = new TextField();
    gridPane.add(name, 1, 0);
    Tooltip nameErrorTooltip = new Tooltip(tr("Please specify a name!"));
    // category
    Label categoryLabel = new Label(tr("Category:"));
    categoryLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(categoryLabel, VPos.TOP);
    gridPane.add(categoryLabel, 0, 1);
    TextField category = new TextField();
    gridPane.add(category, 1, 1);
    Tooltip categoryErrorTooltip = new Tooltip(tr("Please specify a category!"));
    // description
    Label descriptionLabel = new Label(tr("Description:"));
    descriptionLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(descriptionLabel, VPos.TOP);
    gridPane.add(descriptionLabel, 0, 2);
    TextArea description = new TextArea();
    gridPane.add(description, 1, 2);
    // miniature
    Label miniatureLabel = new Label(tr("Miniature:"));
    miniatureLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(miniatureLabel, VPos.TOP);
    gridPane.add(miniatureLabel, 0, 3);
    TextField miniature = new TextField();
    Button openMiniatureBrowser = new Button(tr("Choose"));
    openMiniatureBrowser.setOnAction(event -> {
        FileChooser chooser = new FileChooser();
        chooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(tr("Images"), "*.miniature, *.png"));
        File newMiniature = chooser.showOpenDialog(null);
        miniature.setText(newMiniature.toString());
    });
    HBox miniatureHbox = new HBox(miniature, openMiniatureBrowser);
    HBox.setHgrow(miniature, Priority.ALWAYS);
    gridPane.add(miniatureHbox, 1, 3);
    Tooltip miniatureErrorTooltip = new Tooltip(tr("Please specify a valid miniature!"));
    // executable
    Label executableLabel = new Label(tr("Executable:"));
    executableLabel.getStyleClass().add(CAPTION_TITLE_CSS_CLASS);
    GridPane.setValignment(executableLabel, VPos.TOP);
    gridPane.add(executableLabel, 0, 4);
    TextField executable = new TextField();
    Button openExecutableBrowser = new Button(tr("Choose"));
    openExecutableBrowser.setOnAction(event -> {
        FileChooser chooser = new FileChooser();
        File newMiniature = chooser.showOpenDialog(null);
        executable.setText(newMiniature.toString());
    });
    HBox executableHbox = new HBox(executable, openExecutableBrowser);
    HBox.setHgrow(executable, Priority.ALWAYS);
    gridPane.add(executableHbox, 1, 4);
    Tooltip executableErrorTooltip = new Tooltip(tr("Please specify a valid executable!"));
    Region spacer = new Region();
    spacer.getStyleClass().add("detailsButtonSpacer");
    Button createButton = new Button(tr("Create"));
    createButton.setOnMouseClicked(event -> {
        boolean error = false;
        if (StringUtils.isEmpty(name.getText())) {
            name.pseudoClassStateChanged(errorClass, true);
            name.setTooltip(nameErrorTooltip);
            error = true;
        }
        if (StringUtils.isEmpty(category.getText())) {
            category.pseudoClassStateChanged(errorClass, true);
            category.setTooltip(categoryErrorTooltip);
            error = true;
        }
        URI miniatureUri = null;
        // but if a miniature is given, it must exist
        if (StringUtils.isNotEmpty(miniature.getText())) {
            File miniatureFile = new File(miniature.getText());
            if (miniatureFile.exists()) {
                miniatureUri = miniatureFile.toURI();
            } else {
                miniature.pseudoClassStateChanged(errorClass, true);
                miniature.setTooltip(miniatureErrorTooltip);
                error = true;
            }
        }
        File executableFile = new File(executable.getText());
        if (!executableFile.exists()) {
            executable.pseudoClassStateChanged(errorClass, true);
            executable.setTooltip(executableErrorTooltip);
            error = true;
        }
        if (!error) {
            ShortcutCreationDTO newShortcut = new ShortcutCreationDTO.Builder().withName(name.getText()).withCategory(category.getText()).withDescription(description.getText()).withMiniature(miniatureUri).withExecutable(executableFile).build();
            this.onCreateShortcut.accept(newShortcut);
        }
    });
    vBox.getChildren().addAll(gridPane, spacer, createButton);
    this.setCenter(vBox);
}
Also used : PseudoClass(javafx.css.PseudoClass) ShortcutCreationDTO(org.phoenicis.library.dto.ShortcutCreationDTO) URI(java.net.URI) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) FileChooser(javafx.stage.FileChooser) File(java.io.File)

Example 4 with PseudoClass

use of javafx.css.PseudoClass in project JavaFXLibrary by eficode.

the class ConvenienceKeywords method findAllWithPseudoClass.

@RobotKeyword("Returns *all* nodes matching query AND given pseudo-class state. \r\n" + "``query`` is a query locator, see `3.1 Using queries`.\n\n" + "``pseudo`` is a String value specifying pseudo class value.\n\n" + "``failIfNotFound`` specifies if keyword should fail if nothing is found. By default it's false and " + "keyword returns null in case lookup returns nothing.\n\n" + "\nExample:\n" + "| ${my node}= | Find All With Pseudo Class | .check-box-tree-cell .check-box | selected | \n")
@ArgumentNames({ "query", "pseudo", "failIfNotFound=" })
public List<Object> findAllWithPseudoClass(String query, String pseudo, boolean failIfNotFound) {
    robotLog("INFO", "Trying to find all nodes with query: \"" + query + "\" that has pseudoclass state as: \"" + pseudo + "\", failIfNotFound= \"" + Boolean.toString(failIfNotFound) + "\"");
    try {
        Set<Node> nodes = robot.lookup(query).queryAll();
        Set<Node> matches = nodes.stream().filter(n -> n.getPseudoClassStates().stream().map(PseudoClass::getPseudoClassName).anyMatch(pseudo::contains)).collect(Collectors.toSet());
        return mapObjects(matches);
    } catch (JavaFXLibraryNonFatalException e) {
        if (failIfNotFound)
            throw e;
        return Collections.emptyList();
    } catch (Exception e) {
        throw new JavaFXLibraryNonFatalException("Find all with pseudo class operation failed for query: \"" + query + "\" and pseudo: \"" + pseudo + "\"", e);
    }
}
Also used : RobotKeywords(org.robotframework.javalib.annotation.RobotKeywords) java.util(java.util) ListViewSkin(com.sun.javafx.scene.control.skin.ListViewSkin) PseudoClass(javafx.css.PseudoClass) javafx.scene.control(javafx.scene.control) BoundingBox(javafx.geometry.BoundingBox) HelperFunctions(javafxlibrary.utils.HelperFunctions) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames) Parent(javafx.scene.Parent) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) InstanceOfMatcher(javafxlibrary.matchers.InstanceOfMatcher) TestFxAdapter(javafxlibrary.utils.TestFxAdapter) Method(java.lang.reflect.Method) KeyCode(javafx.scene.input.KeyCode) Rectangle2D(javafx.geometry.Rectangle2D) Node(javafx.scene.Node) Motion(org.testfx.robot.Motion) VirtualFlow(com.sun.javafx.scene.control.skin.VirtualFlow) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) Screen(javafx.stage.Screen) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) Stage(javafx.stage.Stage) RobotKeywordOverload(org.robotframework.javalib.annotation.RobotKeywordOverload) TableViewSkin(com.sun.javafx.scene.control.skin.TableViewSkin) Window(javafx.stage.Window) ObservableList(javafx.collections.ObservableList) Image(javafx.scene.image.Image) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) Node(javafx.scene.Node) JavaFXLibraryNonFatalException(javafxlibrary.exceptions.JavaFXLibraryNonFatalException) RobotKeyword(org.robotframework.javalib.annotation.RobotKeyword) ArgumentNames(org.robotframework.javalib.annotation.ArgumentNames)

Example 5 with PseudoClass

use of javafx.css.PseudoClass in project jabref by JabRef.

the class GroupTreeController method initialize.

@FXML
public void initialize() {
    viewModel = new GroupTreeViewModel(stateManager, dialogService, taskExecutor);
    // Set-up groups tree
    groupTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    // Set-up bindings
    Consumer<ObservableList<GroupNodeViewModel>> updateSelectedGroups = (newSelectedGroups) -> newSelectedGroups.forEach(this::selectNode);
    Consumer<List<TreeItem<GroupNodeViewModel>>> updateViewModel = (newSelectedGroups) -> {
        if (newSelectedGroups == null) {
            viewModel.selectedGroupsProperty().clear();
        } else {
            viewModel.selectedGroupsProperty().setAll(newSelectedGroups.stream().map(TreeItem::getValue).collect(Collectors.toList()));
        }
    };
    BindingsHelper.bindContentBidirectional(groupTree.getSelectionModel().getSelectedItems(), viewModel.selectedGroupsProperty(), updateSelectedGroups, updateViewModel);
    viewModel.filterTextProperty().bind(searchField.textProperty());
    groupTree.rootProperty().bind(EasyBind.map(viewModel.rootGroupProperty(), group -> new RecursiveTreeItem<>(group, GroupNodeViewModel::getChildren, GroupNodeViewModel::expandedProperty, viewModel.filterPredicateProperty())));
    // Icon and group name
    mainColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
    mainColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>().withText(GroupNodeViewModel::getDisplayName).withIcon(GroupNodeViewModel::getIconCode, GroupNodeViewModel::getColor).withTooltip(GroupNodeViewModel::getDescription));
    // Number of hits
    PseudoClass anySelected = PseudoClass.getPseudoClass("any-selected");
    PseudoClass allSelected = PseudoClass.getPseudoClass("all-selected");
    numberColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>().withGraphic(group -> {
        final StackPane node = new StackPane();
        node.getStyleClass().setAll("hits");
        if (!group.isRoot()) {
            BindingsHelper.includePseudoClassWhen(node, anySelected, group.anySelectedEntriesMatchedProperty());
            BindingsHelper.includePseudoClassWhen(node, allSelected, group.allSelectedEntriesMatchedProperty());
        }
        Text text = new Text();
        text.textProperty().bind(group.getHits().asString());
        text.getStyleClass().setAll("text");
        node.getChildren().add(text);
        node.setMaxWidth(Control.USE_PREF_SIZE);
        return node;
    }));
    // Arrow indicating expanded status
    disclosureNodeColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
    disclosureNodeColumn.setCellFactory(new ViewModelTreeTableCellFactory<GroupNodeViewModel, GroupNodeViewModel>().withGraphic(viewModel -> {
        final StackPane disclosureNode = new StackPane();
        disclosureNode.visibleProperty().bind(viewModel.hasChildrenProperty());
        disclosureNode.getStyleClass().setAll("tree-disclosure-node");
        final StackPane disclosureNodeArrow = new StackPane();
        disclosureNodeArrow.getStyleClass().setAll("arrow");
        disclosureNode.getChildren().add(disclosureNodeArrow);
        return disclosureNode;
    }).withOnMouseClickedEvent(group -> event -> group.toggleExpansion()));
    // Set pseudo-classes to indicate if row is root or sub-item ( > 1 deep)
    PseudoClass rootPseudoClass = PseudoClass.getPseudoClass("root");
    PseudoClass subElementPseudoClass = PseudoClass.getPseudoClass("sub");
    // Pseudo-classes for drag and drop
    PseudoClass dragOverBottom = PseudoClass.getPseudoClass("dragOver-bottom");
    PseudoClass dragOverCenter = PseudoClass.getPseudoClass("dragOver-center");
    PseudoClass dragOverTop = PseudoClass.getPseudoClass("dragOver-top");
    groupTree.setRowFactory(treeTable -> {
        TreeTableRow<GroupNodeViewModel> row = new TreeTableRow<>();
        row.treeItemProperty().addListener((ov, oldTreeItem, newTreeItem) -> {
            boolean isRoot = newTreeItem == treeTable.getRoot();
            row.pseudoClassStateChanged(rootPseudoClass, isRoot);
            boolean isFirstLevel = (newTreeItem != null) && (newTreeItem.getParent() == treeTable.getRoot());
            row.pseudoClassStateChanged(subElementPseudoClass, !isRoot && !isFirstLevel);
        });
        row.setDisclosureNode(null);
        row.disclosureNodeProperty().addListener((observable, oldValue, newValue) -> row.setDisclosureNode(null));
        row.contextMenuProperty().bind(EasyBind.monadic(row.itemProperty()).map(this::createContextMenuForGroup).orElse((ContextMenu) null));
        row.setOnDragDetected(event -> {
            TreeItem<GroupNodeViewModel> selectedItem = treeTable.getSelectionModel().getSelectedItem();
            if ((selectedItem != null) && (selectedItem.getValue() != null)) {
                Dragboard dragboard = treeTable.startDragAndDrop(TransferMode.MOVE);
                dragboard.setDragView(row.snapshot(null, null));
                ClipboardContent content = new ClipboardContent();
                content.put(DragAndDropDataFormats.GROUP, selectedItem.getValue().getPath());
                dragboard.setContent(content);
                event.consume();
            }
        });
        row.setOnDragOver(event -> {
            Dragboard dragboard = event.getDragboard();
            if ((event.getGestureSource() != row) && row.getItem().acceptableDrop(dragboard)) {
                event.acceptTransferModes(TransferMode.MOVE, TransferMode.LINK);
                removePseudoClasses(row, dragOverBottom, dragOverCenter, dragOverTop);
                switch(getDroppingMouseLocation(row, event)) {
                    case BOTTOM:
                        row.pseudoClassStateChanged(dragOverBottom, true);
                        break;
                    case CENTER:
                        row.pseudoClassStateChanged(dragOverCenter, true);
                        break;
                    case TOP:
                        row.pseudoClassStateChanged(dragOverTop, true);
                        break;
                }
            }
            event.consume();
        });
        row.setOnDragExited(event -> {
            removePseudoClasses(row, dragOverBottom, dragOverCenter, dragOverTop);
        });
        row.setOnDragDropped(event -> {
            Dragboard dragboard = event.getDragboard();
            boolean success = false;
            if (dragboard.hasContent(DragAndDropDataFormats.GROUP)) {
                String pathToSource = (String) dragboard.getContent(DragAndDropDataFormats.GROUP);
                Optional<GroupNodeViewModel> source = viewModel.rootGroupProperty().get().getChildByPath(pathToSource);
                if (source.isPresent()) {
                    source.get().draggedOn(row.getItem(), getDroppingMouseLocation(row, event));
                    success = true;
                }
            }
            if (dragboard.hasContent(DragAndDropDataFormats.ENTRIES)) {
                TransferableEntrySelection entrySelection = (TransferableEntrySelection) dragboard.getContent(DragAndDropDataFormats.ENTRIES);
                row.getItem().addEntriesToGroup(entrySelection.getSelection());
                success = true;
            }
            event.setDropCompleted(success);
            event.consume();
        });
        return row;
    });
    // Filter text field
    setupClearButtonField(searchField);
}
Also used : PseudoClass(javafx.css.PseudoClass) TreeItem(javafx.scene.control.TreeItem) Control(javafx.scene.control.Control) BindingsHelper(org.jabref.gui.util.BindingsHelper) DialogService(org.jabref.gui.DialogService) StackPane(javafx.scene.layout.StackPane) DragEvent(javafx.scene.input.DragEvent) TreeTableRow(javafx.scene.control.TreeTableRow) TransferMode(javafx.scene.input.TransferMode) Inject(javax.inject.Inject) TextFields(org.controlsfx.control.textfield.TextFields) TreeTableView(javafx.scene.control.TreeTableView) Dragboard(javafx.scene.input.Dragboard) ContextMenu(javafx.scene.control.ContextMenu) Localization(org.jabref.logic.l10n.Localization) Method(java.lang.reflect.Method) RecursiveTreeItem(org.jabref.gui.util.RecursiveTreeItem) ObjectProperty(javafx.beans.property.ObjectProperty) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) AbstractController(org.jabref.gui.AbstractController) Collectors(java.util.stream.Collectors) InvocationTargetException(java.lang.reflect.InvocationTargetException) Consumer(java.util.function.Consumer) FXML(javafx.fxml.FXML) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Text(javafx.scene.text.Text) TreeTableColumn(javafx.scene.control.TreeTableColumn) TaskExecutor(org.jabref.gui.util.TaskExecutor) List(java.util.List) ActionEvent(javafx.event.ActionEvent) StateManager(org.jabref.gui.StateManager) SelectionMode(javafx.scene.control.SelectionMode) DragAndDropDataFormats(org.jabref.gui.DragAndDropDataFormats) EasyBind(org.fxmisc.easybind.EasyBind) ViewModelTreeTableCellFactory(org.jabref.gui.util.ViewModelTreeTableCellFactory) Optional(java.util.Optional) Log(org.apache.commons.logging.Log) ObservableList(javafx.collections.ObservableList) ClipboardContent(javafx.scene.input.ClipboardContent) LogFactory(org.apache.commons.logging.LogFactory) CustomTextField(org.controlsfx.control.textfield.CustomTextField) PseudoClass(javafx.css.PseudoClass) ViewModelTreeTableCellFactory(org.jabref.gui.util.ViewModelTreeTableCellFactory) ClipboardContent(javafx.scene.input.ClipboardContent) Text(javafx.scene.text.Text) ContextMenu(javafx.scene.control.ContextMenu) RecursiveTreeItem(org.jabref.gui.util.RecursiveTreeItem) ObservableList(javafx.collections.ObservableList) List(java.util.List) ObservableList(javafx.collections.ObservableList) TreeTableRow(javafx.scene.control.TreeTableRow) StackPane(javafx.scene.layout.StackPane) Dragboard(javafx.scene.input.Dragboard) FXML(javafx.fxml.FXML)

Aggregations

PseudoClass (javafx.css.PseudoClass)8 File (java.io.File)3 ObservableList (javafx.collections.ObservableList)3 Node (javafx.scene.Node)3 Stage (javafx.stage.Stage)3 Method (java.lang.reflect.Method)2 URI (java.net.URI)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Platform (javafx.application.Platform)2 FXML (javafx.fxml.FXML)2 Parent (javafx.scene.Parent)2 Control (javafx.scene.control.Control)2 TreeCell (javafx.scene.control.TreeCell)2 TreeItem (javafx.scene.control.TreeItem)2 FileChooser (javafx.stage.FileChooser)2 Window (javafx.stage.Window)2 ColumnConstraintsWithPercentage (org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage)2 ShortcutCreationDTO (org.phoenicis.library.dto.ShortcutCreationDTO)2