use of catdata.ide.CodeTextPanel in project fql by CategoricalData.
the class AqlViewer method viewMorphism.
private static <Ty, En1, Sym, Fk1, Att1, Gen1, Sk1, En2, Fk2, Att2, Gen2, Sk2> JComponent viewMorphism(Morphism m, AqlJs js) {
CodeTextPanel input = new CodeTextPanel("Input term-in-ctx", "");
CodeTextPanel output = new CodeTextPanel("Output term-in-ctx", "");
JButton nf = new JButton("Translate");
JPanel buttonPanel = new JPanel(new GridLayout(1, 1));
buttonPanel.add(nf);
// TODO: aql does not position correctly
Split split = new Split(.5, JSplitPane.VERTICAL_SPLIT);
split.add(input);
split.add(output);
JPanel main = new JPanel(new BorderLayout());
main.add(split, BorderLayout.CENTER);
main.add(buttonPanel, BorderLayout.NORTH);
nf.addActionListener(x -> {
try {
Pair<List<Pair<String, String>>, RawTerm> y = AqlParser.getParser().parseTermInCtx(input.getText());
Triple<Ctx<Var, Chc<Ty, En1>>, Term<Ty, En1, Sym, Fk1, Att1, Gen1, Sk1>, Term<Ty, En1, Sym, Fk1, Att1, Gen1, Sk1>> z = RawTerm.infer2(y.first, y.second, y.second, m.src(), js);
Pair<Ctx<Var, Chc<Ty, En2>>, Term<Ty, En2, Sym, Fk2, Att2, Gen2, Sk2>> a = m.translate(z.first, z.second);
output.setText(a.first.toString() + a.second);
} catch (Exception ex) {
ex.printStackTrace();
output.setText(ex.getMessage());
}
});
return main;
}
Aggregations