Search in sources :

Example 1 with InteriorLabel

use of catdata.aql.exp.InteriorLabel in project fql by CategoricalData.

the class AqlOutline method getComp.

protected synchronized JTree getComp() {
    if (tree != null) {
        return tree;
    }
    tree = new JTree(new DefaultMutableTreeNode());
    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    tree.setCellRenderer(makeRenderer());
    tree.setEditable(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            // TODO Auto-generated method stub
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            Object o = node.getUserObject();
            if (o instanceof TreeLabel) {
                TreeLabel l = (TreeLabel) o;
                if (codeEditor.parsed_prog.exps.containsKey(l.s)) {
                    Integer line = codeEditor.parsed_prog.getLine(l.s);
                    codeEditor.setCaretPos(line);
                    codeEditor.addToHistory(line);
                }
            } else if (o instanceof InteriorLabel) {
                InteriorLabel<?> l = (InteriorLabel<?>) o;
                codeEditor.setCaretPos(l.loc);
                codeEditor.addToHistory(l.loc);
            }
        /* else if (node.getChildCount() != 0) {
					DefaultMutableTreeNode n = (DefaultMutableTreeNode) node.getChildAt(0);
					if (n.getUserObject() instanceof InteriorLabel) {
						InteriorLabel<?> lx = (InteriorLabel<?>) n.getUserObject();
						codeEditor.setCaretPos(lx.loc);
						codeEditor.addToHistory(lx.loc);
					}
				} */
        }
    });
    return tree;
}
Also used : JTree(javax.swing.JTree) MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MouseAdapter(java.awt.event.MouseAdapter) InteriorLabel(catdata.aql.exp.InteriorLabel)

Example 2 with InteriorLabel

use of catdata.aql.exp.InteriorLabel in project fql by CategoricalData.

the class AqlOutline method asTree.

private void asTree(DefaultMutableTreeNode root, boolean alpha, Exp<?> e) {
    if (e instanceof Raw) {
        Raw T = (Raw) e;
        for (String k : T.raw().keySet()) {
            List<InteriorLabel<Object>> v = T.raw().get(k);
            add(root, v, k, t -> t, alpha);
        }
    }
}
Also used : Raw(catdata.aql.exp.Raw) InteriorLabel(catdata.aql.exp.InteriorLabel)

Example 3 with InteriorLabel

use of catdata.aql.exp.InteriorLabel in project fql by CategoricalData.

the class AqlOutline method add.

private <X, Y, Z> void add(DefaultMutableTreeNode root, Collection<X> x, Y y, Function<X, Z> f, boolean alpha) {
    if (x.size() > 0) {
        DefaultMutableTreeNode n = new DefaultMutableTreeNode();
        n.setUserObject(y);
        for (X t : Util.alphaMaybe(alpha, x)) {
            DefaultMutableTreeNode m = new DefaultMutableTreeNode();
            m.setUserObject(f.apply(t));
            if (t instanceof Exp) {
                asTree(m, alpha, (Exp<?>) t);
            } else if (t instanceof InteriorLabel) {
                InteriorLabel<?> l = (InteriorLabel<?>) t;
                if (l.s instanceof Exp) {
                    asTree(m, alpha, (Exp<?>) l.s);
                }
            }
            n.add(m);
        }
        root.add(n);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Exp(catdata.aql.exp.Exp) InteriorLabel(catdata.aql.exp.InteriorLabel)

Aggregations

InteriorLabel (catdata.aql.exp.InteriorLabel)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 Exp (catdata.aql.exp.Exp)1 Raw (catdata.aql.exp.Raw)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 JTree (javax.swing.JTree)1