Search in sources :

Example 11 with TreeItem

use of javafx.scene.control.TreeItem in project tokentool by RPTools.

the class TokenTool_Controller method initialize.

@FXML
void initialize() {
    // Note: A Pane is added to the compositeTokenPane so the ScrollPane doesn't consume the mouse events
    assert fileManageOverlaysMenu != null : "fx:id=\"fileManageOverlaysMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileSaveAsMenu != null : "fx:id=\"fileSaveAsMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileExitMenu != null : "fx:id=\"fileExitMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editCaptureScreenMenu != null : "fx:id=\"editCaptureScreenMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editCopyImageMenu != null : "fx:id=\"editCopyImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editPasteImageMenu != null : "fx:id=\"editPasteImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert helpAboutMenu != null : "fx:id=\"helpAboutMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert saveOptionsPane != null : "fx:id=\"saveOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayOptionsPane != null : "fx:id=\"overlayOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert backgroundOptionsPane != null : "fx:id=\"backgroundOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert zoomOptionsPane != null : "fx:id=\"zoomOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert compositeTokenPane != null : "fx:id=\"compositeTokenPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert tokenPreviewPane != null : "fx:id=\"tokenPreviewPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitScrollPane != null : "fx:id=\"portraitScrollPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert compositeGroup != null : "fx:id=\"compositeGroup\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayTreeView != null : "fx:id=\"overlayTreeview\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitImageView != null : "fx:id=\"portraitImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert maskImageView != null : "fx:id=\"maskImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayImageView != null : "fx:id=\"overlayImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert tokenImageView != null : "fx:id=\"tokenImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert useFileNumberingCheckbox != null : "fx:id=\"useFileNumberingCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayUseAsBaseCheckbox != null : "fx:id=\"overlayUseAsBaseCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert clipPortraitCheckbox != null : "fx:id=\"clipPortraitCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameTextField != null : "fx:id=\"fileNameTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameSuffixLabel != null : "fx:id=\"fileNameSuffixLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameSuffixTextField != null : "fx:id=\"fileNameSuffixTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayNameLabel != null : "fx:id=\"overlayNameLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert backgroundColorPicker != null : "fx:id=\"backgroundColorPicker\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayAspectToggleButton != null : "fx:id=\"overlayAspectToggleButton\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitTransparencySlider != null : "fx:id=\"portraitTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitBlurSlider != null : "fx:id=\"portraitBlurSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitGlowSlider != null : "fx:id=\"portraitGlowSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayTransparencySlider != null : "fx:id=\"overlayTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayWidthSpinner != null : "fx:id=\"overlayWidthSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayHeightSpinner != null : "fx:id=\"overlayHeightSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayTreeProgressBar != null : "fx:id=\"overlayTreeProgressIndicator\" was not injected: check your FXML file 'ManageOverlays.fxml'.";
    executorService = Executors.newCachedThreadPool(runable -> {
        loadOverlaysThread = Executors.defaultThreadFactory().newThread(runable);
        loadOverlaysThread.setDaemon(true);
        return loadOverlaysThread;
    });
    overlayTreeView.setShowRoot(false);
    overlayTreeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> updateCompositImageView((TreeItem<Path>) newValue));
    addPseudoClassToLeafs(overlayTreeView);
    // Bind color picker to compositeTokenPane background fill
    backgroundColorPicker.setValue(Color.TRANSPARENT);
    ObjectProperty<Background> background = compositeTokenPane.backgroundProperty();
    background.bind(Bindings.createObjectBinding(() -> {
        BackgroundFill fill = new BackgroundFill(backgroundColorPicker.getValue(), CornerRadii.EMPTY, Insets.EMPTY);
        return new Background(fill);
    }, backgroundColorPicker.valueProperty()));
    // Bind transparency slider to portraitImageView opacity
    portraitTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            portraitImageView.setOpacity(new_val.doubleValue());
            updateTokenPreviewImageView();
        }
    });
    // // Restrict text field to valid filename characters
    // Pattern validDoubleText = Pattern.compile("[^a-zA-Z0-9\\\\._ \\\\/`~!@#$%\\\\^&\\\\(\\\\)\\\\-\\\\=\\\\+\\\\[\\\\]\\\\{\\\\}',\\\\\\\\:]");
    // Pattern validText = Pattern.compile("[^a-zA-Z0-9 ]");
    // TextFormatter<> textFormatter = new TextFormatter<>(
    // change -> {
    // String newText = change.getControlNewText();
    // if (validText.matcher(newText).matches()) {
    // return change;
    // } else
    // return null;
    // });
    // UnaryOperator<TextFormatter.Change> filter = new UnaryOperator<TextFormatter.Change>() {
    // @Override
    // public TextFormatter.Change apply(TextFormatter.Change t) {
    // String validText = "[^a-zA-Z0-9]";
    // 
    // if (t.isReplaced())
    // if (t.getText().matches(validText))
    // t.setText(t.getControlText().substring(t.getRangeStart(), t.getRangeEnd()));
    // 
    // if (t.isAdded()) {
    // if (t.getText().matches(validText)) {
    // return null;
    // }
    // }
    // 
    // return t;
    // }
    // };
    UnaryOperator<Change> filter = change -> {
        String text = change.getText();
        if (text.matches(AppConstants.VALID_FILE_NAME_PATTERN)) {
            return change;
        } else {
            change.setText(FileSaveUtil.cleanFileName(text));
            ;
            return change;
        }
    // 
    // return null;
    };
    TextFormatter<String> textFormatter = new TextFormatter<>(filter);
    fileNameTextField.setTextFormatter(textFormatter);
    // Effects
    GaussianBlur gaussianBlur = new GaussianBlur(0);
    Glow glow = new Glow(0);
    gaussianBlur.setInput(glow);
    // Bind blur slider to portraitImageView opacity
    portraitBlurSlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            gaussianBlur.setRadius(new_val.doubleValue());
            portraitImageView.setEffect(gaussianBlur);
            updateTokenPreviewImageView();
        }
    });
    // Bind glow slider to portraitImageView opacity
    portraitGlowSlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            glow.setLevel(new_val.doubleValue());
            portraitImageView.setEffect(gaussianBlur);
            updateTokenPreviewImageView();
        }
    });
    // Bind transparency slider to overlayImageView opacity
    overlayTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            overlayImageView.setOpacity(new_val.doubleValue());
            updateTokenPreviewImageView();
        }
    });
    // Bind width/height spinners to overlay width/height
    overlayWidthSpinner.getValueFactory().valueProperty().bindBidirectional(overlayHeightSpinner.getValueFactory().valueProperty());
    overlayWidthSpinner.valueProperty().addListener((observable, oldValue, newValue) -> overlayWidthSpinner_onTextChanged(oldValue, newValue));
    overlayHeightSpinner.valueProperty().addListener((observable, oldValue, newValue) -> overlayHeightSpinner_onTextChanged(oldValue, newValue));
}
Also used : Arrays(java.util.Arrays) ListIterator(java.util.ListIterator) PseudoClass(javafx.css.PseudoClass) Credits(net.rptools.tokentool.client.Credits) ManageOverlays(net.rptools.tokentool.client.ManageOverlays) Glow(javafx.scene.effect.Glow) Point(java.awt.Point) UnaryOperator(java.util.function.UnaryOperator) StackPane(javafx.scene.layout.StackPane) TextFormatter(javafx.scene.control.TextFormatter) DragEvent(javafx.scene.input.DragEvent) RegionSelector(net.rptools.tokentool.client.RegionSelector) Task(javafx.concurrent.Task) ScrollPane(javafx.scene.control.ScrollPane) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) ImageIO(javax.imageio.ImageIO) RotateEvent(javafx.scene.input.RotateEvent) GaussianBlur(javafx.scene.effect.GaussianBlur) Path(java.nio.file.Path) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) NavigableSet(java.util.NavigableSet) Spinner(javafx.scene.control.Spinner) Group(javafx.scene.Group) Executors(java.util.concurrent.Executors) TreeView(javafx.scene.control.TreeView) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Duration(javafx.util.Duration) Logger(org.apache.logging.log4j.Logger) ImageUtil(net.rptools.tokentool.util.ImageUtil) ToggleButton(javafx.scene.control.ToggleButton) Clipboard(javafx.scene.input.Clipboard) Entry(java.util.Map.Entry) ClipboardContent(javafx.scene.input.ClipboardContent) BorderPane(javafx.scene.layout.BorderPane) FilenameUtils(org.apache.commons.io.FilenameUtils) CornerRadii(javafx.scene.layout.CornerRadii) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) FileSaveUtil(net.rptools.tokentool.util.FileSaveUtil) Bindings(javafx.beans.binding.Bindings) TreeSet(java.util.TreeSet) TransferMode(javafx.scene.input.TransferMode) ArrayList(java.util.ArrayList) AppConstants(net.rptools.tokentool.AppConstants) LinkedHashMap(java.util.LinkedHashMap) Dragboard(javafx.scene.input.Dragboard) FadeTransition(javafx.animation.FadeTransition) Insets(javafx.geometry.Insets) ProgressBar(javafx.scene.control.ProgressBar) Slider(javafx.scene.control.Slider) BackgroundFill(javafx.scene.layout.BackgroundFill) I18N(net.rptools.tokentool.util.I18N) ZoomEvent(javafx.scene.input.ZoomEvent) ExecutorService(java.util.concurrent.ExecutorService) ColorPicker(javafx.scene.control.ColorPicker) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Label(javafx.scene.control.Label) Change(javafx.scene.control.TextFormatter.Change) TitledPane(javafx.scene.control.TitledPane) MouseDragEvent(javafx.scene.input.MouseDragEvent) Files(java.nio.file.Files) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) ScrollEvent(javafx.scene.input.ScrollEvent) Background(javafx.scene.layout.Background) File(java.io.File) Cursor(javafx.scene.Cursor) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) ImageView(javafx.scene.image.ImageView) AppPreferences(net.rptools.tokentool.AppPreferences) SwingFXUtils(javafx.embed.swing.SwingFXUtils) TreeCell(javafx.scene.control.TreeCell) ObservableValue(javafx.beans.value.ObservableValue) Comparator(java.util.Comparator) ChangeListener(javafx.beans.value.ChangeListener) LogManager(org.apache.logging.log4j.LogManager) Image(javafx.scene.image.Image) TextFormatter(javafx.scene.control.TextFormatter) Background(javafx.scene.layout.Background) TreeItem(javafx.scene.control.TreeItem) GaussianBlur(javafx.scene.effect.GaussianBlur) BackgroundFill(javafx.scene.layout.BackgroundFill) Change(javafx.scene.control.TextFormatter.Change) Glow(javafx.scene.effect.Glow) FXML(javafx.fxml.FXML)

Example 12 with TreeItem

use of javafx.scene.control.TreeItem in project org.csstudio.display.builder by kasemir.

the class WidgetTree method setModel.

/**
 * @param model Model to display as widget tree
 */
public void setModel(final DisplayModel model) {
    // Could recursively remove all old model tree elements,
    // on UI thread, one by one.
    // Faster: Unlink listeners and then replace the whole
    // tree model which was created in background.
    final DisplayModel old_model = this.model;
    if (old_model != null) {
        old_model.runtimeChildren().removePropertyListener(children_listener);
        for (Widget widget : old_model.runtimeChildren().getValue()) removeWidgetListeners(widget);
        widget2tree.clear();
        tab_name2tree.clear();
    }
    this.model = model;
    // Might be called on UI thread, move off
    EditorUtil.getExecutor().execute(() -> {
        final TreeItem<WidgetOrTab> root = new TreeItem<WidgetOrTab>(WidgetOrTab.of(model));
        if (model != null) {
            widget2tree.put(model, root);
            for (Widget widget : model.runtimeChildren().getValue()) addWidget(widget, -1);
            root.setExpanded(true);
            model.runtimeChildren().addPropertyListener(children_listener);
        }
        logger.log(Level.FINE, "Computed new tree on {0}, updating UI", Thread.currentThread().getName());
        Platform.runLater(() -> {
            tree_view.setRoot(root);
            setSelectedWidgets(editor.getWidgetSelectionHandler().getSelection());
        });
    });
}
Also used : DisplayModel(org.csstudio.display.builder.model.DisplayModel) TreeItem(javafx.scene.control.TreeItem) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget)

Example 13 with TreeItem

use of javafx.scene.control.TreeItem in project org.csstudio.display.builder by kasemir.

the class WidgetTree method bindSelections.

/**
 * Link selections in tree view and model
 */
private void bindSelections() {
    // Update selected widgets in model from selection in tree_view
    final ObservableList<TreeItem<WidgetOrTab>> tree_selection = tree_view.getSelectionModel().getSelectedItems();
    InvalidationListener listener = (Observable observable) -> {
        if (!active.compareAndSet(false, true))
            return;
        try {
            final List<Widget> widgets = new ArrayList<>(tree_selection.size());
            for (TreeItem<WidgetOrTab> item : tree_selection) {
                final WidgetOrTab wot = item.getValue();
                final Widget widget = wot.isWidget() ? wot.getWidget() : wot.getTab().getWidget();
                if (!widgets.contains(widget))
                    widgets.add(widget);
            }
            ;
            logger.log(Level.FINE, "Selected in tree: {0}", widgets);
            editor.getWidgetSelectionHandler().setSelection(widgets);
        } finally {
            active.set(false);
        }
    };
    tree_selection.addListener(listener);
    // Update selection in tree_view from selected widgets in model
    editor.getWidgetSelectionHandler().addListener(this::setSelectedWidgets);
}
Also used : TreeItem(javafx.scene.control.TreeItem) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget) InvalidationListener(javafx.beans.InvalidationListener) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) Observable(javafx.beans.Observable)

Example 14 with TreeItem

use of javafx.scene.control.TreeItem in project blue by kunstmusik.

the class UserSoundObjectLibrary method buildContextMenu.

public ContextMenu buildContextMenu(TreeView<LibraryItem<SoundObject>> treeView) {
    ContextMenu popupMenu = new ContextMenu();
    // popupMenu.getItems().add(new MenuItem("Test"));
    ObservableList<TreeItem<LibraryItem<SoundObject>>> selectedItems = treeView.getSelectionModel().getSelectedItems();
    final ScoreController.ScoreObjectBuffer scoreObjectBuffer = ScoreController.getInstance().getScoreObjectBuffer();
    // FOLDER MENU ITEMS
    List<MenuItem> folderMenuItems = new ArrayList<>();
    MenuItem addFolder = new MenuItem("Add Folder");
    addFolder.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        item.getChildren().add(new LibraryTreeItem(new LibraryItem<>("New Folder")));
    });
    MenuItem deleteFolder = new MenuItem("Delete Folder");
    deleteFolder.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        item.getParent().getChildren().remove(item);
    });
    MenuItem paste = new MenuItem("Paste SoundObject");
    paste.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        SoundObject sObj = (SoundObject) scoreObjectBuffer.scoreObjects.get(0).deepCopy();
        if (!SoundObjectUtilities.isOrContainsInstance(sObj)) {
            item.getChildren().add(new LibraryTreeItem(new LibraryItem<>(sObj)));
        }
    });
    folderMenuItems.add(addFolder);
    folderMenuItems.add(deleteFolder);
    folderMenuItems.add(paste);
    // FOLDER MENU ITEMS
    List<MenuItem> sObjMenuItems = new ArrayList<>();
    MenuItem cut = new MenuItem("Cut");
    cut.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        SoundObject sObj = item.getValue().getValue();
        if (sObj == null) {
            return;
        }
        scoreObjectBuffer.clear();
        scoreObjectBuffer.scoreObjects.add(sObj.deepCopy());
        scoreObjectBuffer.layerIndexes.add(0);
        item.getParent().getChildren().remove(item);
    });
    MenuItem copy = new MenuItem("Copy");
    copy.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        SoundObject sObj = item.getValue().getValue();
        if (sObj == null) {
            return;
        }
        scoreObjectBuffer.clear();
        scoreObjectBuffer.scoreObjects.add(sObj.deepCopy());
        scoreObjectBuffer.layerIndexes.add(0);
    });
    MenuItem delete = new MenuItem("Delete");
    delete.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        item.getParent().getChildren().remove(item);
    });
    sObjMenuItems.add(cut);
    sObjMenuItems.add(copy);
    sObjMenuItems.add(new SeparatorMenuItem());
    sObjMenuItems.add(delete);
    popupMenu.getItems().addAll(folderMenuItems);
    popupMenu.getItems().addAll(sObjMenuItems);
    popupMenu.setOnShowing(evt -> {
        if (selectedItems.size() == 1) {
            TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
            boolean isFolder = item.getValue().getValue() == null;
            deleteFolder.setDisable(item == soundObjectLibrary.getRoot());
            if (isFolder) {
                boolean isScoreObj = scoreObjectBuffer.scoreObjects.size() == 1 && scoreObjectBuffer.scoreObjects.get(0) instanceof SoundObject;
                if (isScoreObj) {
                    SoundObject sObj = (SoundObject) scoreObjectBuffer.scoreObjects.get(0);
                    paste.setDisable(SoundObjectUtilities.isOrContainsInstance(sObj));
                } else {
                    paste.setDisable(true);
                }
            }
            for (MenuItem menuItem : folderMenuItems) {
                menuItem.setVisible(isFolder);
            }
            for (MenuItem menuItem : sObjMenuItems) {
                menuItem.setVisible(!isFolder);
            }
        }
    });
    return popupMenu;
}
Also used : LibraryItem(blue.library.LibraryItem) LibraryTreeItem(blue.library.LibraryTreeItem) TreeItem(javafx.scene.control.TreeItem) LibraryTreeItem(blue.library.LibraryTreeItem) ArrayList(java.util.ArrayList) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ScoreController(blue.ui.core.score.ScoreController) SoundObject(blue.soundObject.SoundObject)

Example 15 with TreeItem

use of javafx.scene.control.TreeItem in project blue by kunstmusik.

the class SoundObjectExportPane method jbInit.

private void jbInit() throws Exception {
    this.setLayout(new BorderLayout());
    this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    soundObjectListPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    categoryPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    cateogriesLabel.setText(BlueSystem.getString("common.categories"));
    categoryPanel.setLayout(new BorderLayout());
    this.add(namePasswordPanel, BorderLayout.NORTH);
    this.add(mainSplitPane, BorderLayout.CENTER);
    this.add(jPanel2, BorderLayout.SOUTH);
    descriptionText.setText(BlueSystem.getString("blueShare.enterDescription"));
    descriptionText.setLineWrap(true);
    descriptionScrollPane.setBorder(new TitledBorder(null, BlueSystem.getString("blueShare.instrDescription")));
    submitButton.setText(BlueSystem.getString("common.submit"));
    soundObjectListPanel.setLayout(new BorderLayout());
    iLabel.setText("SoundObjects from Library");
    // soundObjectLibraryTree.setSelectionModel(TreeSelectionModel.SINGLE_TREE_SELECTION);
    topSplitPane.add(soundObjectListPanel, JSplitPane.LEFT);
    soundObjectListPanel.add(soundObjectListScrollPane, BorderLayout.CENTER);
    soundObjectListPanel.add(iLabel, BorderLayout.NORTH);
    soundObjectListScrollPane.getViewport().add(soundObjectLibraryTree, null);
    descriptionScrollPane.getViewport().add(descriptionText, null);
    jPanel2.add(submitButton, null);
    topSplitPane.setDividerLocation(300);
    mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    mainSplitPane.add(topSplitPane, JSplitPane.TOP);
    mainSplitPane.add(descriptionScrollPane, JSplitPane.BOTTOM);
    topSplitPane.add(categoryPanel, JSplitPane.RIGHT);
    categoryPanel.add(cateogriesLabel, BorderLayout.NORTH);
    categoryPanel.add(categoryScrollPane, BorderLayout.CENTER);
    categoryScrollPane.getViewport().add(categoryTree, null);
    mainSplitPane.setDividerLocation(200);
    submitButton.addActionListener((ActionEvent e) -> {
        submitSoundObject();
    });
    soundObjectLibraryTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            TreePath path = soundObjectLibraryTree.getSelectionPath();
            if (path == null) {
                descriptionText.setText(SELECT_INSTR_TEXT);
                descriptionText.setEnabled(false);
                return;
            }
            Object userObj = path.getLastPathComponent();
            TreeItem<LibraryItem<SoundObject>> node = (TreeItem<LibraryItem<SoundObject>>) userObj;
            if (!node.isLeaf()) {
                descriptionText.setText(SELECT_INSTR_TEXT);
                descriptionText.setEnabled(false);
                return;
            }
            SoundObject instr = node.getValue().getValue();
            if (instr instanceof Sound) {
                descriptionText.setText(((Sound) instr).getComment());
            } else if (instr instanceof ObjectBuilder) {
                descriptionText.setText(((ObjectBuilder) instr).getComment());
            } else {
                descriptionText.setText("");
            }
            descriptionText.setEnabled(true);
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) LibraryItem(blue.library.LibraryItem) TreeItem(javafx.scene.control.TreeItem) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) Sound(blue.soundObject.Sound) ObjectBuilder(blue.soundObject.ObjectBuilder) TitledBorder(javax.swing.border.TitledBorder) BorderLayout(java.awt.BorderLayout) TreePath(javax.swing.tree.TreePath) SoundObject(blue.soundObject.SoundObject) SoundObject(blue.soundObject.SoundObject)

Aggregations

TreeItem (javafx.scene.control.TreeItem)76 File (java.io.File)15 TreeView (javafx.scene.control.TreeView)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 ObjectProperty (javafx.beans.property.ObjectProperty)9 MenuItem (javafx.scene.control.MenuItem)9 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)7 IOException (java.io.IOException)7 FXCollections (javafx.collections.FXCollections)7 ListChangeListener (javafx.collections.ListChangeListener)7 ObservableList (javafx.collections.ObservableList)7 ActionEvent (javafx.event.ActionEvent)7 ContextMenu (javafx.scene.control.ContextMenu)7 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)6 FXML (javafx.fxml.FXML)6 Button (javafx.scene.control.Button)6