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:com.cdd.bao.editor.EditSchema.java

public void actionEditMove(int dir) {
    TreeItem<Branch> item = currentBranch();
    Branch branch = item == null ? null : item.getValue();
    if (item == treeRoot || branch == null
            || (branch.group == null && branch.assignment == null && branch.assay == null))
        return;/*from   w w  w  . jav a  2s.co  m*/

    pullDetail();
    Schema schema = stack.getSchema();
    String newLocator = "";
    if (branch.group != null) {
        Schema.Group group = schema.obtainGroup(branch.locatorID);
        schema.moveGroup(group, dir);
        newLocator = schema.locatorID(group);
    } else if (branch.assignment != null) {
        Schema.Assignment assn = schema.obtainAssignment(branch.locatorID);
        schema.moveAssignment(assn, dir);
        newLocator = schema.locatorID(assn);
    } else if (branch.assay != null) {
        Schema.Assay assay = schema.obtainAssay(branch.locatorID);
        schema.moveAssay(assay, dir);
        newLocator = schema.locatorID(assay);
    }
    stack.changeSchema(schema);
    rebuildTree();
    setCurrentBranch(locateBranch(newLocator));
}

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

public void actionFileGraphicsAssay() {
    // NOTE: stripped down version; upgrade it to let the user pick the filename, or ideally code up a preview panel

    TreeItem<Branch> item = currentBranch();
    Branch branch = item == null ? null : item.getValue();
    if (branch == null || branch.assay == null) {
        Util.informMessage("Graphics for Assay", "Pick an assay first.");
        return;/*from   www.  j a  v a 2s  .  c o  m*/
    }

    if (schemaFile == null)
        return;
    RenderSchema render = new RenderSchema(stack.peekSchema());
    try {
        render.createPageAssay(branch.assay);

        String fn = schemaFile.getAbsolutePath();
        int i = fn.lastIndexOf('.');
        if (i < fn.lastIndexOf('/'))
            i = -1;
        if (i >= 0)
            fn = fn.substring(0, i);
        fn += "_assay.pdf";
        render.write(new File(fn));

        Util.informMessage("Saved PDF", "Written to:\n" + fn);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

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

private void actionValueCleanup() {
    TreeItem<Branch> item = currentBranch();
    Branch branch = item == null ? null : item.getValue();
    if (branch == null || branch.assignment == null) {
        Util.informMessage("Cleanup Values", "Select an assignment in order to remove non-URI values.");
        return;/*from w ww.  j a va2  s  .  c o m*/
    }

    pullDetail();

    Schema schema = stack.getSchema();
    Schema.Assignment assn = schema.obtainAssignment(branch.locatorID);

    int snippy = 0;
    for (int n = assn.values.size() - 1; n >= 0; n--) {
        Schema.Value v = assn.values.get(n);
        if (!v.uri.startsWith("http://") && !v.uri.startsWith("https://")) {
            snippy++;
            assn.values.remove(n);
        }
    }

    if (snippy == 0) {
        Util.informMessage("Cleanup Values", "No values were removed.");
        return;
    }
    stack.changeSchema(schema);
    rebuildTree();
    setCurrentBranch(locateBranch(branch.locatorID));

    Util.informMessage("Cleanup Values",
            "Number of values removed on account of not having a proper URI: " + snippy);
}

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

public void actionValueDuplicates() {
    TreeItem<Branch> item = currentBranch();
    Branch branch = item == null ? null : item.getValue();
    if (branch == null || branch.assignment == null) {
        Util.informMessage("Remove Duplicate Values", "Select an assignment with values to de-duplicate.");
        return;//from  w w  w.  j a va 2s.  c om
    }

    pullDetail();

    Schema schema = stack.getSchema();
    Schema.Assignment assn = schema.obtainAssignment(branch.locatorID);

    int snippy = 0;
    for (int i = 1; i < assn.values.size(); i++) {
        Schema.Value v = assn.values.get(i);
        for (int j = 0; j < i; j++)
            if (v.uri.equals(assn.values.get(j).uri)) {
                snippy++;
                assn.values.remove(i);
                i--;
                break;
            }
    }

    if (snippy == 0) {
        Util.informMessage("Remove Duplicate Values", "No duplicate URI values were found.");
        return;
    }
    stack.changeSchema(schema);
    rebuildTree();
    setCurrentBranch(locateBranch(branch.locatorID));

    Util.informMessage("Remove Duplicate Values",
            "Number of values removed because of duplicated URI values: " + snippy);
}

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

public void actionEditDelete() {
    TreeItem<Branch> item = currentBranch();
    Branch branch = item == null ? null : item.getValue();
    if (branch == null || (branch.group == null && branch.assignment == null && branch.assay == null)) {
        Util.informMessage("Delete Branch", "Select a group, assignment or assay to delete.");
        return;/*w  ww  . j  a v  a2  s  .  c  om*/
    }
    if (item == treeRoot) {
        Util.informMessage("Delete Branch", "Can't delete the root branch.");
        return;
    }

    pullDetail();

    Schema schema = stack.getSchema();
    Schema.Group parent = null;
    if (branch.group != null) {
        Schema.Group group = schema.obtainGroup(branch.locatorID);
        parent = group.parent;
        schema.deleteGroup(group);
    }
    if (branch.assignment != null) {
        Schema.Assignment assn = schema.obtainAssignment(branch.locatorID);
        parent = assn.parent;
        schema.deleteAssignment(assn);
    }
    if (branch.assay != null) {
        Schema.Assay assay = schema.obtainAssay(branch.locatorID);
        schema.deleteAssay(assay);
    }
    stack.changeSchema(schema);
    rebuildTree();
    if (parent != null)
        setCurrentBranch(locateBranch(schema.locatorID(parent)));
    else
        detail.clearContent();
}

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

public void updateBranchAssay(Schema.Assay modAssay) {
    if (modAssay == null)
        return;// w w w .  java 2 s .  c  om
    TreeItem<Branch> item = currentBranch();
    if (item == null)
        return;
    Branch branch = item.getValue();
    if (branch == null)
        return;
    updateBranchAssay(branch, modAssay);

    item.setValue(new Branch(this));
    item.setValue(branch); // triggers redraw
}

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

private TreeItem<FXICCWrapper> isProcessable(TreeItem<FXICCWrapper> currentNode, boolean hideUnprocessable,
        String idFilter, String analysisIDFilter) {
    WildcardFileFilter wffID = new WildcardFileFilter(idFilter);
    WildcardFileFilter wffAID = new WildcardFileFilter(analysisIDFilter);
    FXICCWrapper cWrapper = currentNode.getValue();
    boolean isVisible = false;
    TreeItem<FXICCWrapper> copyOfTreeItem = new TreeItem<>(currentNode.getValue());
    copyOfTreeItem.setExpanded(currentNode.isExpanded());
    //        System.out.println(currentNode.getValue().getID() + " " + currentNode.getChildren().size());
    //At first: Check, if the node has children and if one of those children is visible.
    for (TreeItem<FXICCWrapper> treeItem : currentNode.getChildren()) {
        TreeItem<FXICCWrapper> childVisible = isProcessable(treeItem, hideUnprocessable, idFilter,
                analysisIDFilter);// w w  w.j a  v a 2s .co  m
        if (childVisible != null)
            copyOfTreeItem.getChildren().add(childVisible);
    }

    //If there are no visible children, then check the node itself.
    if (copyOfTreeItem.getChildren().size() == 0) {
        //            System.out.println(cWrapper.getID());
        //Is this a project node or an analysis node?
        isVisible = wffID.accept(new File(cWrapper.getID()));
        if (!isVisible)
            return null;
        if (cWrapper.isAnalysisWrapper()) {
            isVisible = wffAID.accept(new File(cWrapper.getAnalysisID()));
            if (!isVisible)
                return null;
        } else {
            if (hideUnprocessable) {
                isVisible = false;
                return null;
            } else {
                if (cWrapper.hasAnalyses())
                    return null;
            }
        }
        //            if (isVisible && !cWrapper.hasAnalyses()) {
        //                if (currentNode.getChildren().size() > 0)
        //                    isVisible = false;
        //            }
    } else {
        isVisible = true;
    }

    if (isVisible)
        return copyOfTreeItem;
    return null;
}

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

private void pushDetail(TreeItem<Branch> item) {
    if (currentlyRebuilding || item == null)
        return;/*from w w  w  . j  ava  2 s  .co  m*/
    Branch branch = item.getValue();

    Schema schema = stack.peekSchema();
    if (branch.group != null) {
        Schema.Group group = schema.obtainGroup(branch.locatorID);
        detail.setGroup(schema, group, true);
    } else if (branch.assignment != null) {
        Schema.Assignment assn = schema.obtainAssignment(branch.locatorID);
        detail.setAssignment(schema, assn, true);
    } else if (branch.assay != null) {
        Schema.Assay assay = schema.obtainAssay(branch.locatorID);
        detail.setAssay(schema, assay, true);
    } else
        detail.clearContent();
}

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

public void actionEditCopyLayoutTSV() {
    TreeItem<Branch> item = currentBranch();
    if (item == null)
        return;/*from   www  .j  ava 2  s .  c om*/
    Branch branch = item.getValue();

    String tsv = null;
    try {
        if (branch.group != null)
            tsv = ClipboardSchema.composeGroupTSV(branch.group);
        else if (branch.assignment != null)
            tsv = ClipboardSchema.composeAssignmentTSV(branch.assignment);
        if (tsv == null) {
            Util.informWarning("Clipboard Copy", "Select a branch or assignment to copy.");
            return;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        return;
    }

    ClipboardContent content = new ClipboardContent();
    content.putString(tsv);
    if (!Clipboard.getSystemClipboard().setContent(content)) {
        Util.informWarning("Clipboard Copy", "Unable to copy to the clipboard.");
        return;
    }
}

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

public void actionEditCopy(boolean andCut) {
    if (!treeView.isFocused())
        return; // punt to default action

    TreeItem<Branch> item = currentBranch();
    if (item == null)
        return;//from w w w .ja va 2 s.  c om
    Branch branch = item.getValue();

    JSONObject json = null;
    if (branch.group != null)
        json = ClipboardSchema.composeGroup(branch.group);
    else if (branch.assignment != null)
        json = ClipboardSchema.composeAssignment(branch.assignment);
    else if (branch.assay != null)
        json = ClipboardSchema.composeAssay(branch.assay);

    String serial = null;
    try {
        serial = json.toString(2);
    } catch (JSONException ex) {
        return;
    }

    ClipboardContent content = new ClipboardContent();
    content.putString(serial);
    if (!Clipboard.getSystemClipboard().setContent(content)) {
        Util.informWarning("Clipboard Copy", "Unable to copy to the clipboard.");
        return;
    }

    if (andCut)
        actionEditDelete();
}