Search in sources :

Example 1 with NodeSimpleLabel

use of replete.gui.controls.simpletree.NodeSimpleLabel in project n2a by frothga.

the class ParameterTree method filter.

// //////////
// FILTER //
// //////////
public void filter(String text) {
    saveState();
    if (text.equals("")) {
        setModel(origModel);
    } else {
        text = text.toUpperCase();
        List<TNode> found = new ArrayList<TNode>();
        search(origModel.getTRoot(), found, text);
        if (found.size() == 0) {
            TNode nRoot = new TNode();
            nRoot.add(new NodeSimpleLabel("<No Results>", ImageUtil.getImage("noresults.gif")));
            setModel(new TModel(nRoot));
        } else {
            TNode nRoot = new TNode();
            Map<TNode, TNode> oldNewMap = new HashMap<TNode, TNode>();
            for (TNode nFound : found) {
                TNode[] path = nFound.getTPathSegments();
                TNode nParent = nRoot;
                for (TNode nSegment : path) {
                    if (nSegment == origModel.getRoot() && nParent == nRoot) {
                    // do nothing
                    } else if (oldNewMap.containsKey(nSegment)) {
                        nParent = oldNewMap.get(nSegment);
                    } else {
                        Object uSegment = nSegment.getUserObject();
                        TNode nNew = new TNode(uSegment);
                        nParent.add(nNew);
                        nParent = nNew;
                        oldNewMap.put(nSegment, nNew);
                    }
                }
            }
            setModel(new TModel(nRoot));
        }
    }
    restoreStateNoFire();
    updateUI();
}
Also used : TNode(replete.gui.controls.simpletree.TNode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NodeSimpleLabel(replete.gui.controls.simpletree.NodeSimpleLabel) TModel(replete.gui.controls.simpletree.TModel)

Example 2 with NodeSimpleLabel

use of replete.gui.controls.simpletree.NodeSimpleLabel 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)

Aggregations

ArrayList (java.util.ArrayList)2 NodeSimpleLabel (replete.gui.controls.simpletree.NodeSimpleLabel)2 TNode (replete.gui.controls.simpletree.TNode)2 ParameterSetList (gov.sandia.umf.platform.ensemble.params.ParameterSetList)1 FilterableParameterTreePanel (gov.sandia.umf.platform.ui.ensemble.tree.FilterableParameterTreePanel)1 NodeSubdomain (gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain)1 ParameterTree (gov.sandia.umf.platform.ui.ensemble.tree.ParameterTree)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 HashMap (java.util.HashMap)1 List (java.util.List)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 TreePath (javax.swing.tree.TreePath)1 TModel (replete.gui.controls.simpletree.TModel)1