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;
}
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);
}
}
}
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);
}
}
Aggregations