Example usage for javafx.scene.control TreeItem getValue

List of usage examples for javafx.scene.control TreeItem getValue

Introduction

In this page you can find the example usage for javafx.scene.control TreeItem getValue.

Prototype

public final T getValue() 

Source Link

Document

Returns the application-specific data represented by this TreeItem.

Usage

From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java

public void addChildrenList(TreeItem<JEVisClass> item, ObservableList<TreeItem<JEVisClass>> list) {
    _itemChildren.put(item, list);/*from ww w.  j av  a  2s  .co  m*/
    try {
        //            System.out.println("\nchildren for: " + item.getValue().getName());
        for (JEVisClass child : item.getValue().getHeirs()) {
            //                System.out.println("        posible heir: " + child.getName());
            if (item.getValue().getName().equals("Classes")) {
                TreeItem<JEVisClass> newItem = buildItem(child);
                list.add(newItem);
                //                    } else if (child.getInheritance() != null && item.getValue().getName().equals(child.getInheritance().getName()))
            } else if (child.getInheritance() != null && item.getValue().equals(child.getInheritance())) {// && child.getInheritance().equals(item.getValue())) {

                //                    System.out.println("        is direct heir: " + child.getInheritance());
                TreeItem<JEVisClass> newItem = buildItem(child);
                list.add(newItem);

            }

            //                for (JEVisClassRelationship rel : child.getRelationships(JEVisConstants.ClassRelationship.INHERIT, JEVisConstants.Direction.FORWARD)) {
            //                    System.out.println("rel: " + rel);
            //                    if (rel.getOtherClass(item.getValue().getInheritance())) {
            //                        System.out.println("from: " +);
            //                    } else {
            //                        System.out.println("to");
            //                    }
            //                }
        }
    } catch (JEVisException ex) {
        Logger.getLogger(ClassTree.class.getName()).log(Level.SEVERE, null, ex);
    }
    //        sortList(list);

}

From source file:acmi.l2.clientmod.xdat.Controller.java

private void updateContextMenu(ContextMenu contextMenu, TreeView<Object> elements) {
    contextMenu.getItems().clear();//ww w .ja v a2s.  c o m

    TreeItem<Object> root = elements.getRoot();
    TreeItem<Object> selected = elements.getSelectionModel().getSelectedItem();

    if (selected == null) {
        if (root != null)
            contextMenu.getItems().add(createAddMenu("Add ..", elements, root));
    } else {
        Object value = selected.getValue();
        if (value instanceof ListHolder) {
            contextMenu.getItems().add(createAddMenu("Add ..", elements, selected));
        } else if (selected.getParent() != null && selected.getParent().getValue() instanceof ListHolder) {
            MenuItem add = createAddMenu("Add to parent ..", elements, selected.getParent());

            MenuItem delete = new MenuItem("Delete");
            delete.setOnAction(event -> {
                ListHolder parent = (ListHolder) selected.getParent().getValue();

                int index = parent.list.indexOf(value);
                editor.getHistory().valueRemoved(treeItemToScriptString(selected.getParent()), index);

                parent.list.remove(index);
                selected.getParent().getChildren().remove(selected);

                elements.getSelectionModel().selectPrevious();
                elements.getSelectionModel().selectNext();
            });
            contextMenu.getItems().addAll(add, delete);
        }
        if (value instanceof ComponentFactory) {
            MenuItem view = new MenuItem("View");
            view.setOnAction(event -> {
                if (value instanceof L2Context)
                    ((L2Context) value).setResources(l2resources.getValue());
                Stage stage = new Stage();
                stage.setTitle(value.toString());
                Scene scene = new Scene(((ComponentFactory) value).getComponent());
                scene.getStylesheets().add(getClass().getResource("l2.css").toExternalForm());
                stage.setScene(scene);
                stage.show();
            });
            contextMenu.getItems().add(view);
        }
    }
}

From source file:com.cdd.bao.editor.EditSchema.java

public void updateBranchAssignment(Schema.Assignment modAssn) {
    if (modAssn == null)
        return;/*from w ww .  j a  va 2 s.co m*/
    TreeItem<Branch> item = currentBranch();
    if (item == null || item.getValue() == null)
        return;
    updateBranchAssignment(item.getValue(), modAssn);
}

From source file:com.cdd.bao.editor.EditSchema.java

public void updateBranchGroup(Schema.Group modGroup) {
    if (modGroup == null)
        return;/* w  w  w  .j  av  a2s  . co  m*/
    TreeItem<Branch> item = currentBranch();
    if (item == null || item.getValue() == null)
        return;
    updateBranchGroup(item.getValue(), modGroup);

}

From source file:com.cdd.bao.editor.EditSchema.java

public TreeItem<Branch> locateBranch(String locatorID) {
    List<TreeItem<Branch>> stack = new ArrayList<>();
    stack.add(treeRoot);/*  w  w  w .  j ava 2 s . co m*/
    while (stack.size() > 0) {
        TreeItem<Branch> item = stack.remove(0);
        String lookID = item.getValue().locatorID;
        if (lookID != null && lookID.equals(locatorID))
            return item;
        for (TreeItem<Branch> sub : item.getChildren())
            stack.add(sub);
    }
    return null;
}

From source file:com.cdd.bao.editor.EditSchema.java

public String currentLocatorID() {
    TreeItem<Branch> branch = currentBranch();
    return branch == null ? null : branch.getValue().locatorID;
}

From source file:com.cdd.bao.editor.EditSchema.java

public void actionGroupAdd() {
    TreeItem<Branch> item = currentBranch();
    if (item == null || (item.getValue().group == null && item.getValue().assignment == null)) {
        Util.informMessage("Add Group", "Select a group to add to.");
        return;/*from  w  ww  .j a  v a  2 s .  c  o m*/
    }

    pullDetail();

    Schema schema = stack.getSchema();
    Schema.Group parent = schema.obtainGroup(item.getValue().locatorID);
    Schema.Group newGroup = schema.appendGroup(parent, new Schema.Group(null, ""));
    stack.changeSchema(schema);

    rebuildTree();
    setCurrentBranch(locateBranch(schema.locatorID(newGroup)));
}

From source file:com.cdd.bao.editor.EditSchema.java

public void actionAssignmentAdd() {
    TreeItem<Branch> item = currentBranch();
    if (item == null || (item.getValue().group == null && item.getValue().assignment == null)) {
        Util.informMessage("Add Assignment", "Select a group to add to.");
        return;/*  ww  w.  j a v  a2s.  c om*/
    }

    pullDetail();

    Schema schema = stack.getSchema();

    Schema.Group parent = schema.obtainGroup(item.getValue().locatorID);
    Schema.Assignment newAssn = schema.appendAssignment(parent, new Schema.Assignment(null, "", ""));
    stack.changeSchema(schema);

    rebuildTree();
    setCurrentBranch(locateBranch(schema.locatorID(newAssn)));
}

From source file:com.cdd.bao.editor.EditSchema.java

public void actionValueSort() {
    TreeItem<Branch> item = currentBranch();
    Branch branch = item == null ? null : item.getValue();
    if (branch == null || branch.assignment == null) {
        Util.informMessage("Sort Values", "Select an assignment with values to sort.");
        return;//from   w  w w.  j a  v  a2 s  . c o m
    }

    pullDetail();

    Schema schema = stack.getSchema();
    Schema.Assignment assn = schema.obtainAssignment(branch.locatorID);
    assn.values.sort((v1, v2) -> v1.name.compareToIgnoreCase(v2.name));

    if (schema.equals(stack.peekSchema())) {
        Util.informMessage("Sort", "Values were already sorted.");
        return;
    }
    stack.changeSchema(schema);
    rebuildTree();
    setCurrentBranch(locateBranch(branch.locatorID));
}

From source file:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
    instance = this;

    txtDataSetFilter.textProperty().addListener((observableValue, s, s2) -> refillListOfDataSets());

    comboBoxApplicationIniFiles.getSelectionModel().selectedItemProperty().addListener(
            (observableValue, old, newValue) -> selectedApplicationIniChanged(newValue.toString()));
    comboBoxApplicationIniFiles.getItems()
            .addAll(RoddyIOHelperMethods.readTextFile(getUiSettingsFileForIniFiles()));

    projectTree.setCellFactory(treeView -> new ProjectTreeItemCellImplementation(projectTree, instance));
    projectTree.getSelectionModel().selectedItemProperty()
            .addListener((observableValue, oldValue, newValue) -> {
                TreeItem<FXICCWrapper> pWrapper = (TreeItem<FXICCWrapper>) projectTree.getSelectionModel()
                        .getSelectedItem();
                if (pWrapper == null)
                    return;
                changeSelectedProject(pWrapper.getValue());
            });//from  ww w.  j  a va2 s.  c  om

    listViewDataSets.setCellFactory(listView -> new GenericListViewItemCellImplementation());
    listViewDataSets.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    listViewDataSets.getSelectionModel().selectedItemProperty()
            .addListener((observableValue, old, newValue) -> selectedDataSetsChanged());

    currentListOfDataSets.addListener((ListChangeListener<FXDataSetWrapper>) change -> refillListOfDataSets());

    String txtAnalysisIDFilter = Roddy.getApplicationProperty(RunMode.UI, APP_PROPERTY_FILTER_ANALYSISID,
            StringConstants.EMPTY);
    String txtIDFilter = Roddy.getApplicationProperty(RunMode.UI, APP_PROPERTY_FILTER_PROJECTID,
            StringConstants.EMPTY);
    Boolean filterHideUnprocessable = Boolean.parseBoolean(Roddy.getApplicationProperty(RunMode.UI,
            APP_PROPERTY_FILTER_HIDE_UNPROCESSABLE, Boolean.FALSE.toString()));

    txtProjectFilterByAnalysis.setText(txtAnalysisIDFilter);
    txtProjectFilterByID.setText(txtIDFilter);
    txtProjectFilterByAnalysis.textProperty()
            .addListener((observableValue, oldValue, newValue) -> refreshProjectView(null));
    txtProjectFilterByID.textProperty()
            .addListener((observableValue, oldValue, newValue) -> refreshProjectView(null));
    cbProjectFilterHideUnprocessable.setSelected(filterHideUnprocessable);

    txtProjectFilterByAnalysis.textProperty().addListener((observableValue, oldValue, newValue) -> Roddy
            .setApplicationProperty(RunMode.UI, APP_PROPERTY_FILTER_ANALYSISID, newValue));
    txtProjectFilterByID.textProperty().addListener((observableValue, oldValue, newValue) -> Roddy
            .setApplicationProperty(RunMode.UI, APP_PROPERTY_FILTER_ANALYSISID, newValue));
    cbProjectFilterHideUnprocessable.selectedProperty()
            .addListener((observableValue, aBoolean, newValue) -> Roddy.setApplicationProperty(RunMode.UI,
                    APP_PROPERTY_FILTER_HIDE_UNPROCESSABLE, newValue.toString()));

    setupTitlePaneExpansionProcessing(tpProjectFilterSettings, APP_PROPERTY_PROJECT_FILTER_SETTINGS_OPENED,
            Boolean.TRUE);
    setupTitlePaneExpansionProcessing(tpProjectSettings, APP_PROPERTY_PROJECT_SETTINGS_OPENED, Boolean.TRUE);
    setupTitlePaneExpansionProcessing(tpProjectDataSetFilter, APP_PROPERTY_PROJECT_DATASET_FILTER_OPENED,
            Boolean.TRUE);

    RoddyUITask.activeListOfTasksProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            RoddyUITask.invokeASAP(new Runnable() {
                @Override
                public void run() {
                    listViewOfActiveUITasks.getItems().clear();
                    listViewOfActiveUITasks.getItems().addAll(RoddyUITask.activeListOfTasksProperty().values());
                }
            }, "donttrack::Update tasklist", false);
        }
    });

    startUIUpdateThread();
}