Search in sources :

Example 1 with NodeSubdomain

use of gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain in project n2a by frothga.

the class FixedParameterSpacePanel method populate.

// AMap wrap operation
private void populate(TNode nParent, ParameterDomain domain) {
    for (ParameterDomain subdomain : domain.getSubdomains()) {
        TNode nSubdomain = new TNode(new NodeSubdomain(subdomain));
        populate(nSubdomain, subdomain);
        nParent.add(nSubdomain);
    }
    for (Parameter param : domain.getParameters()) {
        TNode nParam = new TNode(new NodeParameter(param));
        nParent.add(nParam);
    }
}
Also used : NodeSubdomain(gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain) TNode(replete.gui.controls.simpletree.TNode) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter) Parameter(gov.sandia.n2a.parms.Parameter)

Example 2 with NodeSubdomain

use of gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain in project n2a by frothga.

the class OutputParameterPanel method dragGestureRecognized.

public void dragGestureRecognized(DragGestureEvent event) {
    Cursor cursor = null;
    SimpleTree list = (SimpleTree) event.getComponent();
    TreePath[] paths = list.getSelectionPaths();
    if (paths == null) {
        return;
    }
    List<ParameterBundle> bundles = new ArrayList<ParameterBundle>();
    for (TreePath path : paths) {
        List<ParameterDomain> domains = new ArrayList<ParameterDomain>();
        for (int p = 0; p < path.getPathCount(); p++) {
            Object u = ((TNode) path.getPathComponent(p)).getObject();
            if (u instanceof NodeSubdomain) {
                domains.add(((NodeSubdomain) u).getSubdomain());
            }
        }
        NodeBase uLeaf = ((TNode) path.getLastPathComponent()).getObject();
        if (uLeaf instanceof NodeParameter) {
            NodeParameter p = (NodeParameter) uLeaf;
            bundles.add(new ParameterBundle(domains, p.getParameter()));
        } else {
            // TODO: add all children?
            return;
        }
    }
    if (event.getDragAction() == DnDConstants.ACTION_LINK) {
        cursor = DragCursors.getGrabhandcursor();
    }
    event.startDrag(cursor, new TransferableParameterBundles(bundles));
}
Also used : ArrayList(java.util.ArrayList) TransferableParameterBundles(gov.sandia.umf.platform.ui.ensemble.TransferableParameterBundles) ParameterBundle(gov.sandia.n2a.parms.ParameterBundle) Cursor(java.awt.Cursor) SimpleTree(replete.gui.controls.simpletree.SimpleTree) NodeSubdomain(gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain) NodeBase(replete.gui.controls.simpletree.NodeBase) TNode(replete.gui.controls.simpletree.TNode) TreePath(javax.swing.tree.TreePath) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain)

Example 3 with NodeSubdomain

use of gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain in project n2a by frothga.

the class FixedParameterSpacePanel method getSelectedParamsAsBundles.

private List<ParameterBundle> getSelectedParamsAsBundles(TreePath[] paths) {
    List<ParameterBundle> bundles = new ArrayList<ParameterBundle>();
    for (TreePath path : paths) {
        List<ParameterDomain> domains = new ArrayList<ParameterDomain>();
        if (tabParamDomains.getSelectedIndex() == 0) {
            domains.add(new ParameterDomain("Model"));
        } else {
            domains.add(new ParameterDomain("Simulator"));
        }
        for (int p = 0; p < path.getPathCount(); p++) {
            Object u = ((TNode) path.getPathComponent(p)).getObject();
            if (u instanceof NodeSubdomain) {
                domains.add(((NodeSubdomain) u).getSubdomain());
            }
        }
        NodeBase uLeaf = ((TNode) path.getLastPathComponent()).getObject();
        if (uLeaf instanceof NodeParameter) {
            NodeParameter p = (NodeParameter) uLeaf;
            bundles.add(new ParameterBundle(domains, p.getParameter()));
        } else {
            // TODO: add all children?
            return null;
        }
    }
    return bundles;
}
Also used : NodeSubdomain(gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain) NodeBase(replete.gui.controls.simpletree.NodeBase) TNode(replete.gui.controls.simpletree.TNode) TreePath(javax.swing.tree.TreePath) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter) ArrayList(java.util.ArrayList) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain) ParameterBundle(gov.sandia.n2a.parms.ParameterBundle)

Example 4 with NodeSubdomain

use of gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain in project n2a by frothga.

the class FixedParameterSpacePanel method buildDomainTab.

private void buildDomainTab(ParameterDomain domain) {
    TNode nRoot = new TNode(new NodeSimpleLabel(domain.getName()));
    populate(nRoot, domain);
    FilterableParameterTreePanel pnlFilterableTree = new FilterableParameterTreePanel(nRoot);
    final ParameterTree treParams = pnlFilterableTree.getTree();
    treParams.addMouseMotionListener(new MouseMotionAdapter() {

        @Override
        public void mouseMoved(MouseEvent e) {
            TreePath path = treParams.getPathForLocation(e.getX(), e.getY());
            if (path == null || ((TNode) path.getLastPathComponent()).getUserObject() instanceof NodeSubdomain) {
                treParams.setCursor(Cursor.getDefaultCursor());
            } else {
                treParams.setCursor(DragCursors.getOpenhandcursor());
            }
        }
    });
    treParams.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            updateDetailsPanelFromTree(treParams);
        }
    });
    treParams.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1 && treParams.getSelectionCount() != 0) {
                List<ParameterBundle> bundles = getSelectedParamsAsBundles(treParams.getSelectionPaths());
                if (bundles != null) {
                    dropIntoGroups(bundles, dropEmphasis);
                }
            }
        }
    });
    DragSource ds = new DragSource();
    ds.createDefaultDragGestureRecognizer(treParams, DnDConstants.ACTION_LINK, this);
    int existingIndex = tabParamDomains.indexOfTabByKey(domain.getName());
    if (existingIndex != -1) {
        tabParamDomains.remove(existingIndex);
    }
    tabParamDomains.add(domain.getName(), pnlFilterableTree);
    int index = tabParamDomains.getTabCount();
    tabParamDomains.setIconAt(index - 1, domain.getIcon());
    tabParamDomains.setUseBorderAt(index - 1, true);
}
Also used : MouseEvent(java.awt.event.MouseEvent) ParameterTree(gov.sandia.umf.platform.ui.ensemble.tree.ParameterTree) MouseAdapter(java.awt.event.MouseAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DragSource(java.awt.dnd.DragSource) NodeSimpleLabel(replete.gui.controls.simpletree.NodeSimpleLabel) NodeSubdomain(gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain) FilterableParameterTreePanel(gov.sandia.umf.platform.ui.ensemble.tree.FilterableParameterTreePanel) TNode(replete.gui.controls.simpletree.TNode) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) TreePath(javax.swing.tree.TreePath) List(java.util.List) ParameterSetList(gov.sandia.umf.platform.ensemble.params.ParameterSetList) ArrayList(java.util.ArrayList) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 5 with NodeSubdomain

use of gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain in project n2a by frothga.

the class OutputParameterPanel method populate.

// AMap wrap operation
private void populate(TNode nParent, ParameterDomain domain) {
    for (ParameterDomain subdomain : domain.getSubdomains()) {
        TNode nSubdomain = new TNode(new NodeSubdomain(subdomain));
        populate(nSubdomain, subdomain);
        nParent.add(nSubdomain);
    }
    for (Parameter param : domain.getParameters()) {
        TNode nParam = new TNode(new NodeParameter(param));
        nParent.add(nParam);
    }
}
Also used : NodeSubdomain(gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain) TNode(replete.gui.controls.simpletree.TNode) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain) Parameter(gov.sandia.n2a.parms.Parameter) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter)

Aggregations

NodeSubdomain (gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain)5 TNode (replete.gui.controls.simpletree.TNode)5 ParameterDomain (gov.sandia.n2a.parms.ParameterDomain)4 NodeParameter (gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter)4 ArrayList (java.util.ArrayList)3 TreePath (javax.swing.tree.TreePath)3 Parameter (gov.sandia.n2a.parms.Parameter)2 ParameterBundle (gov.sandia.n2a.parms.ParameterBundle)2 NodeBase (replete.gui.controls.simpletree.NodeBase)2 ParameterSetList (gov.sandia.umf.platform.ensemble.params.ParameterSetList)1 TransferableParameterBundles (gov.sandia.umf.platform.ui.ensemble.TransferableParameterBundles)1 FilterableParameterTreePanel (gov.sandia.umf.platform.ui.ensemble.tree.FilterableParameterTreePanel)1 ParameterTree (gov.sandia.umf.platform.ui.ensemble.tree.ParameterTree)1 Cursor (java.awt.Cursor)1 DragSource (java.awt.dnd.DragSource)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 MouseMotionAdapter (java.awt.event.MouseMotionAdapter)1 List (java.util.List)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1