Search in sources :

Example 6 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class FqlppDisplay method showSet.

@SuppressWarnings("ConstantConditions")
private static JPanel showSet(Set<?> view, Color c) {
    JTabbedPane px = new JTabbedPane();
    if (DefunctGlobalOptions.debug.fqlpp.set_graph) {
        JComponent gp = makeCatViewer(Category.fromSet(view), c);
        px.add("Graph", gp);
    }
    if (DefunctGlobalOptions.debug.fqlpp.set_tabular) {
        Object[][] rowData = new Object[view.size()][1];
        int i = 0;
        for (Object o : view) {
            rowData[i++][0] = Util.nice(o.toString());
        }
        Object[] colNames = new Object[] { "Element" };
        JPanel gp = GuiUtil.makeTable(BorderFactory.createEtchedBorder(), view.size() + " elements", rowData, colNames);
        px.add("Table", gp);
    }
    if (DefunctGlobalOptions.debug.fqlpp.set_textual) {
        CodeTextPanel gp = new CodeTextPanel(BorderFactory.createEtchedBorder(), view.size() + " elements", Util.nice(view.toString()));
        px.add("Text", gp);
    }
    JPanel top = new JPanel(new GridLayout(1, 1));
    top.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    top.add(px);
    return top;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) CodeTextPanel(catdata.ide.CodeTextPanel) JTabbedPane(javax.swing.JTabbedPane) JComponent(javax.swing.JComponent) Paint(java.awt.Paint)

Example 7 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class OplExp method display.

@Override
public JComponent display() {
    CodeTextPanel p = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", toString());
    JTabbedPane ret = new JTabbedPane();
    ret.add(p, "Text");
    return ret;
}
Also used : CodeTextPanel(catdata.ide.CodeTextPanel) JTabbedPane(javax.swing.JTabbedPane)

Example 8 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class SqlChecker method doChecks.

// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
private void doChecks(List<Pair<String, Pair<Triple<String, List<Pair<String, List<Pair<String, String>>>>, List<Pair<String, String>>>, Triple<String, List<Pair<String, List<Pair<String, String>>>>, List<Pair<String, String>>>>>> tocheck) throws SQLException {
    for (Pair<String, Pair<Triple<String, List<Pair<String, List<Pair<String, String>>>>, List<Pair<String, String>>>, Triple<String, List<Pair<String, List<Pair<String, String>>>>, List<Pair<String, String>>>>> eq : tocheck) {
        JTabbedPane ret = new JTabbedPane();
        Triple<String, List<Pair<String, List<Pair<String, String>>>>, List<Pair<String, String>>> lhs = eq.second.first;
        Triple<String, List<Pair<String, List<Pair<String, String>>>>, List<Pair<String, String>>> rhs = eq.second.second;
        if (!lhs.first.equals(rhs.first)) {
            throw new RuntimeException(eq.first + " starts at two different tables, " + lhs.first + " and " + rhs.first);
        }
        Triple<String, Set<String>, String> q1 = path(lhs.first, lhs.second, lhs.third, info);
        Triple<String, Set<String>, String> q2 = path(rhs.first, rhs.second, rhs.third, info);
        endMatches(eq.first, q1.third, q2.third, lhs.third, rhs.third);
        Statement stmt = conn.createStatement();
        stmt.execute(q1.first);
        ResultSet q1r = stmt.getResultSet();
        stmt = conn.createStatement();
        stmt.execute(q2.first);
        ResultSet q2r = stmt.getResultSet();
        Set<Map<String, String>> tuples1 = toTuples(q1r);
        Set<Map<String, String>> tuples2 = toTuples(q2r);
        boolean b = tuples1.equals(tuples2);
        if (b) {
            CodeTextPanel p2 = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", "OK");
            ret.add(p2, "Result");
        } else {
            ret.add(showDiff(lhs.first, q1.third, tuples1, tuples2, new LinkedList<>(endType(info, q1.third, lhs.third).keySet())), "Result");
        }
        if (!q1.second.isEmpty() || !q2.second.isEmpty()) {
            String exns = "LHS warnings:\n\n" + Util.sep(q1.second, "\n") + "\n\nRHS warnings:\n\n" + Util.sep(q2.second, "\n");
            CodeTextPanel p = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", exns);
            ret.add("Warnings", p);
        }
        CodeTextPanel p = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", q1.first + "\n\n = \n\n" + q2.first);
        ret.add(p, "Query");
        frames.add(new Pair<>(eq.first, ret));
    }
}
Also used : ResultSet(java.sql.ResultSet) Set(java.util.Set) HashSet(java.util.HashSet) Statement(java.sql.Statement) JTabbedPane(javax.swing.JTabbedPane) LinkedList(java.util.LinkedList) CodeTextPanel(catdata.ide.CodeTextPanel) ResultSet(java.sql.ResultSet) List(java.util.List) LinkedList(java.util.LinkedList) JList(javax.swing.JList) Map(java.util.Map) HashMap(java.util.HashMap) Pair(catdata.Pair)

Example 9 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class Mpl method display.

@Override
public JComponent display() {
    CodeTextPanel p = new CodeTextPanel(BorderFactory.createEtchedBorder(), "", toString());
    JTabbedPane ret = new JTabbedPane();
    ret.add(p, "Text");
    return ret;
}
Also used : CodeTextPanel(catdata.ide.CodeTextPanel) JTabbedPane(javax.swing.JTabbedPane)

Example 10 with CodeTextPanel

use of catdata.ide.CodeTextPanel in project fql by CategoricalData.

the class XMapping method display.

@SuppressWarnings("ConstantConditions")
@Override
public JComponent display() {
    JTabbedPane pane = new JTabbedPane();
    if (DefunctGlobalOptions.debug.fpql.x_text) {
        String ret = toString();
        pane.addTab("Text", new CodeTextPanel(BorderFactory.createEtchedBorder(), "", ret));
    }
    if (src.schema != null) {
        if (DefunctGlobalOptions.debug.fpql.x_tables) {
            pane.addTab("Tables", makeTables());
        }
    } else {
        if (DefunctGlobalOptions.debug.fpql.x_tables) {
            pane.addTab("Tables", makeTables2());
        }
    }
    if (DefunctGlobalOptions.debug.fpql.x_graph && src.schema == null) {
        pane.addTab("Graph", makeGraph());
    }
    return pane;
}
Also used : CodeTextPanel(catdata.ide.CodeTextPanel) JTabbedPane(javax.swing.JTabbedPane)

Aggregations

CodeTextPanel (catdata.ide.CodeTextPanel)31 JTabbedPane (javax.swing.JTabbedPane)19 JPanel (javax.swing.JPanel)18 GridLayout (java.awt.GridLayout)17 LinkedList (java.util.LinkedList)11 JComponent (javax.swing.JComponent)11 Paint (java.awt.Paint)10 List (java.util.List)9 Graph (edu.uci.ics.jung.graph.Graph)7 HashMap (java.util.HashMap)7 JSplitPane (javax.swing.JSplitPane)7 Pair (catdata.Pair)6 Unit (catdata.Unit)5 Const (catdata.fqlpp.CatExp.Const)5 Map (java.util.Map)5 Set (java.util.Set)5 JButton (javax.swing.JButton)5 JScrollPane (javax.swing.JScrollPane)5 Triple (catdata.Triple)4 Util (catdata.Util)4