use of javax.swing.JTable in project knime-core by knime.
the class AggregationSettingsButtonCellRenderer method mouseReleased.
/**
* {@inheritDoc}
*/
@Override
public void mouseReleased(final MouseEvent e) {
JTable table = m_rootPanel.getTable();
if (m_isButtonColumnEditor && table.isEditing()) {
table.getCellEditor().stopCellEditing();
}
m_isButtonColumnEditor = false;
}
use of javax.swing.JTable in project knime-core by knime.
the class AggregationSettingsButtonCellRenderer method openSettingsDialog.
private void openSettingsDialog() {
final JTable table = m_rootPanel.getTable();
final int rowIdx = table.convertRowIndexToModel(table.getEditingRow());
fireEditingStopped();
final AggregationFunctionRow<?> row = m_rootPanel.getTableModel().getRow(rowIdx);
if (!row.getFunction().hasOptionalSettings()) {
// the operator has no additional settings
return;
}
// figure out the parent to be able to make the dialog modal
Frame f = null;
Container c = m_rootPanel.getComponentPanel().getParent();
final Component root = SwingUtilities.getRoot(c);
if (root instanceof Frame) {
f = (Frame) root;
}
while (f == null && c != null) {
if (c instanceof Frame) {
f = (Frame) c;
break;
}
c = c.getParent();
}
try {
final AggregationSettingsDialog dialog = new AggregationSettingsDialog(f, row.getFunction(), m_rootPanel.getInputTableSpec());
// center the dialog
dialog.setLocationRelativeTo(c);
dialog.pack();
// show it
dialog.setVisible(true);
} catch (NotConfigurableException e) {
// show the error message
JOptionPane.showMessageDialog(m_rootPanel.getComponentPanel(), e.getMessage(), "Unable to open dialog", JOptionPane.ERROR_MESSAGE);
return;
}
}
use of javax.swing.JTable 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;
}
use of javax.swing.JTable in project megameklab by MegaMek.
the class CriticalTransferHandler method createTransferable.
@Override
protected Transferable createTransferable(JComponent c) {
if (c instanceof JTable) {
JTable table = (JTable) c;
Mounted mount = (Mounted) ((CriticalTableModel) table.getModel()).getValueAt(table.getSelectedRow(), CriticalTableModel.EQUIPMENT);
return new StringSelection(Integer.toString(getUnit().getEquipmentNum(mount)));
} else if (c instanceof DropTargetCriticalList) {
DropTargetCriticalList<?> list = (DropTargetCriticalList<?>) c;
Mounted mount = list.getMounted();
if (mount != null) {
return new StringSelection(Integer.toString(getUnit().getEquipmentNum(mount)));
}
}
return null;
}
use of javax.swing.JTable in project megameklab by MegaMek.
the class CriticalTransferHandler method createTransferable.
@Override
protected Transferable createTransferable(JComponent c) {
JTable table = (JTable) c;
Mounted mount = (Mounted) ((CriticalTableModel) table.getModel()).getValueAt(table.getSelectedRow(), CriticalTableModel.EQUIPMENT);
return new StringSelection(Integer.toString(getUnit().getEquipmentNum(mount)));
}
Aggregations