List of usage examples for javax.swing.table TableModel getValueAt
public Object getValueAt(int rowIndex, int columnIndex);
columnIndex
and rowIndex
. From source file:gdt.jgui.tool.JEntityEditor.java
private String getEditCellLocator() { try {/*from ww w . j av a2s .co m*/ save(); JTextEditor textEditor = new JTextEditor(); String locator$ = textEditor.getLocator(); locator$ = Locator.merge(getLocator(), locator$); JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent(); JTable table = (JTable) scrollPane.getViewport().getView(); int i = tabbedPane.getSelectedIndex(); String element$ = tabbedPane.getTitleAt(i); int x = table.getEditingRow(); int y = table.getEditingColumn(); String cellField$ = CELL_FIELD_TYPE; if (y == 1) cellField$ = CELL_FIELD_NAME; else if (y == 2) cellField$ = CELL_FIELD_VALUE; TableModel model = table.getModel(); String text$ = (String) model.getValueAt(x, y); text$ = Locator.compressText(text$); locator$ = Locator.append(locator$, JTextEditor.IS_BASE64, Locator.LOCATOR_TRUE); String coreName$ = (String) model.getValueAt(x, 1); locator$ = Locator.append(locator$, JTextEditor.TEXT, text$); locator$ = Locator.append(locator$, ELEMENT, element$); locator$ = Locator.append(locator$, CELL_FIELD, cellField$); locator$ = Locator.append(locator$, CORE_NAME, coreName$); locator$ = Locator.append(locator$, JRequester.REQUESTER_ACTION, ACTION_EDIT_CELL); locator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, "Edit item"); locator$ = Locator.append(locator$, BaseHandler.HANDLER_CLASS, JTextEditor.class.getName()); return locator$; } catch (Exception e) { LOGGER.severe(e.toString()); return null; } }
From source file:org.datacleaner.widgets.result.AbstractCrosstabResultSwingRenderer.java
protected void valueCell(Object value, final ResultProducer drillToDetailResultProducer, TableModel tableModel, int row, int col, boolean headersIncluded, Alignment alignment) { final Object resultValue; ActionListener action = null; if (drillToDetailResultProducer != null) { final StringBuilder sb = new StringBuilder("Detailed result for ["); sb.append(getLabelText(value));/*from ww w . ja v a 2s . c o m*/ sb.append(" ("); final String cat1; if (headersIncluded) { cat1 = tableModel.getColumnName(col); } else { cat1 = tableModel.getValueAt(0, col).toString(); } sb.append(cat1).append(", "); final String cat2 = tableModel.getValueAt(row, 0).toString(); sb.append(cat2); sb.append(")]"); action = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _drillToDetailsCallback.drillToDetails(sb.toString(), drillToDetailResultProducer); } }; resultValue = createActionableValuePanel(value, alignment, action, IMAGE_PATH_DRILL_TO_DETAIL); } else { resultValue = getLabelText(value); } tableModel.setValueAt(resultValue, row, col); }
From source file:gdt.jgui.entity.fields.JFieldsEditor.java
private String getEditCellLocator() { try {//ww w .j a v a2 s . c o m save(); String locator$ = getLocator(); if (entihome$ != null) locator$ = Locator.append(locator$, Entigrator.ENTIHOME, entihome$); if (entityKey$ != null) locator$ = Locator.append(locator$, EntityHandler.ENTITY_KEY, entityKey$); JTable table = (JTable) scrollPane.getViewport().getView(); int x = table.getEditingRow(); int y = table.getEditingColumn(); String cellField$ = CELL_FIELD_NAME; if (y == 1) cellField$ = CELL_FIELD_VALUE; TableModel model = table.getModel(); text$ = (String) model.getValueAt(x, y); String fieldName$ = (String) model.getValueAt(x, 0); locator$ = Locator.append(locator$, JTextEditor.TEXT, text$); locator$ = Locator.append(locator$, CELL_FIELD, cellField$); locator$ = Locator.append(locator$, CELL_FIELD_NAME, fieldName$); if (requesterResponseLocator$ != null) locator$ = Locator.append(locator$, JRequester.REQUESTER_RESPONSE_LOCATOR, requesterResponseLocator$); locator$ = Locator.append(locator$, BaseHandler.HANDLER_METHOD, JFacetOpenItem.METHOD_RESPONSE); // System.out.println("FieldsEditor:getEditCellLocator:END:"+locator$); return locator$; } catch (Exception e) { LOGGER.severe(e.toString()); return null; } }
From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java
/** * * @param offset/*w w w. ja va2 s .co m*/ * @param evt */ public void showPopUpMenu(int offset, java.awt.event.MouseEvent evt) { JTable target = (JTable) evt.getSource(); int rowNumber = target.rowAtPoint(new Point(evt.getX(), evt.getY())); rowNumber = target.convertRowIndexToModel(rowNumber); JPopupMenu jpm = new JPopupMenu(); jpm.add(java.util.ResourceBundle .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame") .getString("SHOW_IN_BROWSER")); TableModel tableModel = target.getModel(); // resultTable.get // jpm.add("Column " + rowNumber +" " + tableColumnModel.getColumn(tableColumnModel.getColumnIndexAtX(evt.getX())).getHeaderValue()); int year = Integer.parseInt((String) tableModel.getValueAt(rowNumber, 0)); String filterString = "INCID >= '" + year * 10000 + "' AND INCID <'" + (year + 1) * 10000 + "'"; for (DatabaseVariablesListElement dvle : chosenVariables) { int columnNumber = tableColumnModel .getColumnIndex(canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName())); String value = tableModel.getValueAt(rowNumber, columnNumber).toString(); filterString += " AND " + canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName()) + " = " + dvle.getSQLqueryFormat(value); } DatabaseFilter filter = new DatabaseFilter(); filter.setFilterString(filterString); Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.INFO, "FilterString: {0}", filterString); try { tableDatadescriptionPopUp = canreg.client.CanRegClientApp.getApplication() .getDistributedTableDescription(filter, rangeFilterPanel.getSelectedTable()); Object[][] rows = canreg.client.CanRegClientApp.getApplication().retrieveRows( tableDatadescriptionPopUp.getResultSetID(), 0, MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK); String[] variableNames = tableDatadescriptionPopUp.getColumnNames(); for (Object[] row : rows) { String line = ""; int i = 0; for (Object obj : row) { if (obj != null) { line += variableNames[i] + ": " + obj.toString() + ", "; } i++; } jpm.add(line); } } catch (SQLException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (RemoteException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (SecurityException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (DistributedTableDescriptionException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (UnknownTableException ex) { Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex); } int cases = (Integer) tableModel.getValueAt(rowNumber, tableColumnModel.getColumnIndex("CASES")); if (MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK < cases) { jpm.add("..."); } MenuItem menuItem = new MenuItem(); jpm.show(target, evt.getX(), evt.getY()); }
From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java
private void initButtonSaveResults() { btnSaveResults = new JButton("Save as ..."); btnSaveResults.setEnabled(false); // can't save right away, need a first search btnSaveResults.addActionListener(new ActionListener() { @Override//from w ww .j a v a 2s .c o m public void actionPerformed(ActionEvent e) { fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (fileChooser.getSelectedFile() != null) { // reusing the dialog fileChooser.setSelectedFile(null); } int returnVal = fileChooser.showDialog(SimilarityRetrievalGUI.this, "Save results to file ..."); if (returnVal == JFileChooser.APPROVE_OPTION) { try { PrintWriter w = FileUtils.openFileForWriting("Results file", fileChooser.getSelectedFile().getAbsolutePath()); TableModel model = resultsTable.getModel(); // column headers for (int col = 0; col < model.getColumnCount(); col++) { w.print(model.getColumnName(col) + "\t"); } w.println(); // write each data row for (int row = 0; row < model.getRowCount(); row++) { for (int col = 0; col < model.getColumnCount(); col++) { w.print(model.getValueAt(row, col) + "\t"); } w.println(); } w.flush(); w.close(); JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this, "Successfully wrote to file " + fileChooser.getSelectedFile().getAbsolutePath(), "Results stored", JOptionPane.INFORMATION_MESSAGE); } catch (IOException e1) { e1.printStackTrace(); } } } }); }
From source file:gdt.jgui.entity.fields.JFieldsEditor.java
private void save() { try {/*from w w w . ja v a 2 s . co m*/ int rCnt; Core row; TableModel model; table = (JTable) scrollPane.getViewport().getView(); rCnt = table.getRowCount(); model = table.getModel(); entity.clearElement("field"); for (int j = 0; j < rCnt; j++) { row = new Core(null, (String) model.getValueAt(j, 0), (String) model.getValueAt(j, 1)); entity.putElementItem("field", row); } entigrator.save(entity); } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:uk.ac.lkl.cram.ui.report.Report.java
private void addLearningActivities() { MainDocumentPart mdp = wordMLPackage.getMainDocumentPart(); mdp.addStyledParagraphOfText("Heading1", "Learning Activities"); float online_hours = 0f; float f2f_hours = 0f; Tbl table = factory.createTbl();/* ww w. j a v a 2 s . co m*/ Tr tableHead = factory.createTr(); TableModel tableModel = new ModuleReportModel(module); for (int col = 0; col < tableModel.getColumnCount(); col++) { addTableCell(tableHead, tableModel.getColumnName(col), JcEnumeration.CENTER, true); } table.getContent().add(tableHead); int columnCount = tableModel.getColumnCount(); for (int row = 0; row < tableModel.getRowCount(); row++) { boolean lastRow = row == tableModel.getRowCount() - 1; Tr tableRow = factory.createTr(); addTableCell(tableRow, tableModel.getValueAt(row, 0).toString(), JcEnumeration.LEFT, lastRow); for (int col = 1; col < columnCount; col++) { addTableCell(tableRow, FLOAT_FORMATTER.format(tableModel.getValueAt(row, col)), JcEnumeration.RIGHT, lastRow); } table.getContent().add(tableRow); } addBorders(table); List<TLALineItem> lineItems = module.getTLALineItems(); for (TLALineItem lineItem : lineItems) { TLActivity activity = lineItem.getActivity(); float totalLearnerHourCount = lineItem.getTotalLearnerHourCount(module); StudentTeacherInteraction sti = activity.getStudentTeacherInteraction(); if (sti.isOnline()) { online_hours += totalLearnerHourCount; } if (sti.isTutorSupported() && sti.isLocationSpecific()) { f2f_hours += totalLearnerHourCount; } } mdp.addStyledParagraphOfText("BodyText", "Number of learner hours online: " + (int) online_hours); mdp.addStyledParagraphOfText("BodyText", "Number of learner hours face-to-face: " + (int) f2f_hours); addBorders(table); mdp.addObject(table); }
From source file:uk.ac.lkl.cram.ui.report.Report.java
private void addSummary() { MainDocumentPart mdp = wordMLPackage.getMainDocumentPart(); mdp.addStyledParagraphOfText("Heading1", "Summary"); Tbl table = factory.createTbl();// w ww. j av a2s .c om Tr tableHead = factory.createTr(); TableModel tableModel = new SummaryReportModel(module); int columnCount = tableModel.getColumnCount(); for (int col = 0; col < columnCount; col++) { addTableCell(tableHead, tableModel.getColumnName(col), JcEnumeration.CENTER, true); } table.getContent().add(tableHead); for (int row = 0; row < tableModel.getRowCount(); row++) { boolean lastRow = row == tableModel.getRowCount() - 1; Tr tableRow = factory.createTr(); if (lastRow) { addTableCell(tableRow, tableModel.getValueAt(row, 0).toString(), JcEnumeration.LEFT, true); } else { addSimpleTableCell(tableRow, tableModel.getValueAt(row, 0).toString()); } for (int col = 1; col < columnCount; col++) { if (row > 4) { addTableCell(tableRow, CURRENCY_FORMATTER.format(tableModel.getValueAt(row, col)), JcEnumeration.RIGHT, lastRow); } else { addTableCell(tableRow, INTEGER_FORMATTER.format(tableModel.getValueAt(row, col)), JcEnumeration.RIGHT, lastRow); } } table.getContent().add(tableRow); } addBorders(table); mdp.addObject(table); }
From source file:uk.ac.lkl.cram.ui.report.Report.java
private void addTutorPreparationCost() { MainDocumentPart mdp = wordMLPackage.getMainDocumentPart(); mdp.addStyledParagraphOfText("Heading2", "Cost of Preparation"); Tbl table = factory.createTbl();/*from w ww.ja v a 2s . c o m*/ Tr tableHead = factory.createTr(); TableModel tableModel = new TutorCostTableModel(module); addTableCell(tableHead, tableModel.getColumnName(0), JcEnumeration.CENTER, true); for (int col = 1; col < 4; col++) { addTableCell(tableHead, tableModel.getColumnName(col), JcEnumeration.CENTER, true); } table.getContent().add(tableHead); for (int row = 0; row < tableModel.getRowCount(); row++) { boolean lastRow = row == tableModel.getRowCount() - 1; Tr tableRow = factory.createTr(); if (lastRow) { addTableCell(tableRow, tableModel.getValueAt(row, 0).toString(), JcEnumeration.LEFT, true); } else { addSimpleTableCell(tableRow, tableModel.getValueAt(row, 0).toString()); } for (int col = 1; col < 4; col++) { addTableCell(tableRow, CURRENCY_FORMATTER.format(tableModel.getValueAt(row, col)), JcEnumeration.RIGHT, lastRow); } table.getContent().add(tableRow); } addBorders(table); mdp.addObject(table); }
From source file:uk.ac.lkl.cram.ui.report.Report.java
private void addTutorSupportCost() { MainDocumentPart mdp = wordMLPackage.getMainDocumentPart(); mdp.addStyledParagraphOfText("Heading2", "Cost of Support"); Tbl table = factory.createTbl();// ww w .j av a 2 s . c om Tr tableHead = factory.createTr(); TableModel tableModel = new TutorCostTableModel(module); addTableCell(tableHead, tableModel.getColumnName(0), JcEnumeration.CENTER, true); for (int col = 4; col < 7; col++) { addTableCell(tableHead, tableModel.getColumnName(col), JcEnumeration.CENTER, true); } table.getContent().add(tableHead); for (int row = 0; row < tableModel.getRowCount(); row++) { boolean lastRow = row == tableModel.getRowCount() - 1; Tr tableRow = factory.createTr(); if (lastRow) { addTableCell(tableRow, tableModel.getValueAt(row, 0).toString(), JcEnumeration.LEFT, true); } else { addSimpleTableCell(tableRow, tableModel.getValueAt(row, 0).toString()); } for (int col = 4; col < 7; col++) { addTableCell(tableRow, CURRENCY_FORMATTER.format(tableModel.getValueAt(row, col)), JcEnumeration.RIGHT, lastRow); } table.getContent().add(tableRow); } addBorders(table); mdp.addObject(table); }