Search in sources :

Example 6 with JSortTable

use of org.vcell.util.gui.sorttable.JSortTable in project vcell by virtualcell.

the class ServerManageConsole method getQueryResultTable.

/**
 * Return the QueryResultTable property value.
 * @return cbit.vcell.messaging.admin.sorttable.JSortTable
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private JSortTable getQueryResultTable() {
    if (ivjQueryResultTable == null) {
        try {
            ivjQueryResultTable = new JSortTable();
            ivjQueryResultTable.setName("QueryResultTable");
            ivjQueryResultTable.setModel(new JobTableModel());
            ivjQueryResultTable.disableUneditableForeground();
            final JPopupMenu popup = new JPopupMenu();
            JMenuItem viewMongoMenuItem = new JMenuItem("View Mongo Log Info...");
            popup.add(viewMongoMenuItem);
            viewMongoMenuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    try {
                        Number simID = (Number) ivjQueryResultTable.getModel().getValueAt(ivjQueryResultTable.getSelectedRow(), JobTableModel.columnIndex_SimID);
                        String userid = (String) ivjQueryResultTable.getModel().getValueAt(ivjQueryResultTable.getSelectedRow(), JobTableModel.columnIndex_UserID);
                        System.out.println("----- user=" + userid + " simID=" + simID);
                        String mongoDbHost = PropertyLoader.getRequiredProperty(PropertyLoader.mongodbHostInternal);
                        // default 27017
                        int mongoDbPort = Integer.parseInt(PropertyLoader.getRequiredProperty(PropertyLoader.mongodbPortInternal));
                        Mongo m = new Mongo(mongoDbHost, mongoDbPort);
                        String mongoDbDatabaseName = PropertyLoader.getRequiredProperty(PropertyLoader.mongodbDatabase);
                        DB db = m.getDB(mongoDbDatabaseName);
                        String mongoDbLoggingCollectionName = PropertyLoader.getRequiredProperty(PropertyLoader.mongodbLoggingCollection);
                        DBCollection dbCollection = db.getCollection(mongoDbLoggingCollectionName);
                        BasicDBObject query = new BasicDBObject();
                        query.put(VCMongoMessage.MongoMessage_simId, simID.intValue() + "");
                        DBCursor cur = dbCollection.find(query);
                        TreeMap<String, Integer> mapKeyToColumnIndex = new TreeMap<String, Integer>();
                        Vector<DBObject> dbObjV = new Vector<DBObject>();
                        while (cur.hasNext()) {
                            DBObject dbObject = cur.next();
                            dbObjV.add(dbObject);
                            Set<String> keys = dbObject.keySet();
                            Iterator<String> iter = keys.iterator();
                            while (iter.hasNext()) {
                                String key = iter.next();
                                Integer columnIndex = mapKeyToColumnIndex.get(key);
                                if (columnIndex == null) {
                                    columnIndex = mapKeyToColumnIndex.size();
                                    mapKeyToColumnIndex.put(key, columnIndex);
                                }
                            }
                        }
                        int msgTimeColumnIndex = -1;
                        if (mapKeyToColumnIndex.size() > 0) {
                            String[] columnNames = new String[mapKeyToColumnIndex.size()];
                            Iterator<String> keyIter = mapKeyToColumnIndex.keySet().iterator();
                            while (keyIter.hasNext()) {
                                String key = keyIter.next();
                                int columnIndex = mapKeyToColumnIndex.get(key);
                                columnNames[columnIndex] = key;
                                if (key.equals(VCMongoMessage.MongoMessage_msgTime)) {
                                    msgTimeColumnIndex = columnIndex;
                                }
                            }
                            // //Ask which columns to view
                            // Object[][] colrowdata = new Object[columnNames.length][1];
                            // for (int i = 0; i < colrowdata.length; i++) {
                            // colrowdata[i][0] = columnNames[i];
                            // }
                            // int[] showcolArr =
                            // DialogUtils.showComponentOKCancelTableList(ServerManageConsole.this, "Select Columns to View...", new String[] {"Column Names"}, colrowdata, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                            Object[][] rowData = new Object[dbObjV.size()][columnNames.length];
                            for (int i = 0; i < rowData.length; i++) {
                                DBObject dbObj = dbObjV.get(i);
                                Set<String> keys = dbObj.keySet();
                                Iterator<String> iter = keys.iterator();
                                while (iter.hasNext()) {
                                    String key = iter.next();
                                    rowData[i][mapKeyToColumnIndex.get(key)] = dbObj.get(key);
                                }
                            }
                            // sort by msgtime
                            final int msgTimeColumnIndexFinal = msgTimeColumnIndex;
                            if (msgTimeColumnIndex != -1) {
                                Arrays.sort(rowData, new Comparator<Object[]>() {

                                    public int compare(Object[] o1, Object[] o2) {
                                        Long o1Long = (Long) o1[msgTimeColumnIndexFinal];
                                        Long o2Long = (Long) o2[msgTimeColumnIndexFinal];
                                        int result = (int) (o2Long - o1Long);
                                        return result;
                                    }
                                });
                            }
                            DialogUtils.showComponentOptionsTableList(ServerManageConsole.this, "Mongo Log Info (" + rowData.length + ") " + userid + " " + simID, columnNames, rowData, ListSelectionModel.SINGLE_SELECTION, null, null, null, null, false);
                        } else {
                            DialogUtils.showWarningDialog(ServerManageConsole.this, "No Mongo Log Info found for simID=" + simID.intValue());
                        }
                    } catch (UserCancelException uce) {
                    // ignore
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }
            });
            ivjQueryResultTable.addMouseListener(new MouseAdapter() {

                public void mouseReleased(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        JTable source = (JTable) e.getSource();
                        int row = source.rowAtPoint(e.getPoint());
                        int column = source.columnAtPoint(e.getPoint());
                        if (!source.isRowSelected(row))
                            source.changeSelection(row, column, false, false);
                        popup.show(e.getComponent(), e.getX(), e.getY());
                    }
                }
            });
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjQueryResultTable;
}
Also used : Set(java.util.Set) ActionEvent(java.awt.event.ActionEvent) UserCancelException(org.vcell.util.UserCancelException) BigString(org.vcell.util.BigString) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) Comparator(java.util.Comparator) DBCollection(com.mongodb.DBCollection) BasicDBObject(com.mongodb.BasicDBObject) DBCursor(com.mongodb.DBCursor) Iterator(java.util.Iterator) JMenuItem(javax.swing.JMenuItem) Vector(java.util.Vector) MouseEvent(java.awt.event.MouseEvent) Mongo(com.mongodb.Mongo) MouseAdapter(java.awt.event.MouseAdapter) TreeMap(java.util.TreeMap) JPopupMenu(javax.swing.JPopupMenu) UserCancelException(org.vcell.util.UserCancelException) JSortTable(org.vcell.util.gui.sorttable.JSortTable) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) DB(com.mongodb.DB)

Example 7 with JSortTable

use of org.vcell.util.gui.sorttable.JSortTable in project vcell by virtualcell.

the class ServerManageConsole method getUserConnectionTable.

/**
 * Return the UserConnectionTable property value.
 * @return cbit.vcell.messaging.admin.sorttable.JSortTable
 */
private JSortTable getUserConnectionTable() {
    if (ivjUserConnectionTable == null) {
        try {
            ivjUserConnectionTable = new JSortTable();
            ivjUserConnectionTable.setModel(new UserConnectionTableModel());
            ivjUserConnectionTable.disableUneditableForeground();
        } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    return ivjUserConnectionTable;
}
Also used : JSortTable(org.vcell.util.gui.sorttable.JSortTable)

Example 8 with JSortTable

use of org.vcell.util.gui.sorttable.JSortTable in project vcell by virtualcell.

the class SimulationListPanel method getScrollPaneTable.

/**
 * Return the ScrollPaneTable property value.
 * @return cbit.gui.JTableFixed
 */
private JSortTable getScrollPaneTable() {
    if (ivjScrollPaneTable == null) {
        try {
            // ivjScrollPaneTable = new ScrollTable() {
            // @Override
            // public JToolTip createToolTip() {
            // MultiLineToolTip tip = new MultiLineToolTip();
            // tip.setComponent(this);
            // return tip;
            // }
            // };
            ivjScrollPaneTable = new JSortTable();
            ivjScrollPaneTable.setName("ScrollPaneTable");
            ivjScrollPaneTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN);
            ivjScrollPaneTable.setModel(getSimulationListTableModel1());
        } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    return ivjScrollPaneTable;
}
Also used : JSortTable(org.vcell.util.gui.sorttable.JSortTable)

Example 9 with JSortTable

use of org.vcell.util.gui.sorttable.JSortTable in project vcell by virtualcell.

the class InitialConditionsPanel method getScrollPaneTable.

/**
 * Return the ScrollPaneTable property value.
 * @return javax.swing.JTable
 */
private JSortTable getScrollPaneTable() {
    if (table == null) {
        try {
            table = new JSortTable();
            table.setName("spceciesContextSpecsTable");
            tableModel = new SpeciesContextSpecsTableModel(table);
            table.setModel(tableModel);
            table.setScrollTableActionManager(new InternalScrollTableActionManager(table));
            table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
        } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    return table;
}
Also used : JSortTable(org.vcell.util.gui.sorttable.JSortTable)

Example 10 with JSortTable

use of org.vcell.util.gui.sorttable.JSortTable in project vcell by virtualcell.

the class ModelProcessSpecsPanel method getScrollPaneTable.

/**
 * Return the ScrollPaneTable property value.
 * @return javax.swing.JTable
 */
private JSortTable getScrollPaneTable() {
    if (ivjScrollPaneTable == null) {
        try {
            ivjScrollPaneTable = new JSortTable();
            ivjScrollPaneTable.setName("ScrollPaneTable");
        } catch (java.lang.Throwable ivjExc) {
            handleException(ivjExc);
        }
    }
    return ivjScrollPaneTable;
}
Also used : JSortTable(org.vcell.util.gui.sorttable.JSortTable)

Aggregations

JSortTable (org.vcell.util.gui.sorttable.JSortTable)21 Dimension (java.awt.Dimension)4 GridBagConstraints (java.awt.GridBagConstraints)4 GridBagLayout (java.awt.GridBagLayout)4 Insets (java.awt.Insets)4 JLabel (javax.swing.JLabel)4 JTextField (javax.swing.JTextField)4 Comparator (java.util.Comparator)3 JScrollPane (javax.swing.JScrollPane)3 JTable (javax.swing.JTable)3 VCellSortTableModel (cbit.vcell.client.desktop.biomodel.VCellSortTableModel)2 Component (java.awt.Component)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 Vector (java.util.Vector)2 JMenuItem (javax.swing.JMenuItem)2 JPopupMenu (javax.swing.JPopupMenu)2 UserCancelException (org.vcell.util.UserCancelException)2