javax.swing.table.TableModel Java Examples

The following examples show how to use javax.swing.table.TableModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableEditorModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void copyInto( final TableModel model ) {
  try {
    setSuspendEvents( true );
    clear();
    if ( model == null ) {
      return;
    }

    final int columnCount = model.getColumnCount();
    for ( int col = 0; col < columnCount; col++ ) {
      addColumn( model.getColumnName( col ), model.getColumnClass( col ) );
    }

    final int rowCount = model.getRowCount();
    for ( int r = 0; r < rowCount; r++ ) {
      addRow();
      for ( int col = 0; col < columnCount; col++ ) {
        final Object originalValue = model.getValueAt( r, col );
        setValueAt( originalValue, r, col + 1 );
      }
    }
  } finally {
    setSuspendEvents( false );
  }
}
 
Example #2
Source File: SwingExtensions.java    From groovy with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an {@link java.util.Iterator} which traverses the TableModel one row at a time.
 *
 * @param self a TableModel
 * @return an Iterator for a TableModel
 * @since 1.6.4
 */
public static Iterator<?> iterator(final TableModel self) {
    return new Iterator<Object>() {
        private int row = 0;

        public boolean hasNext() {
            return row < self.getRowCount();
        }

        public Object next() {
            int cols = self.getColumnCount();
            Object[] rowData = new Object[cols];
            for (int col = 0; col < cols; col++) {
                rowData[col] = self.getValueAt(row, col);
            }
            row++;
            return rowData;
        }

        public void remove() {
            throw new UnsupportedOperationException("TableModel is immutable.");
        }
    };
}
 
Example #3
Source File: PropertySheetTable.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Overriden to register a listener on the model. This listener ensures
 * editing is cancelled when editing row is being changed.
 * 
 * @see javax.swing.JTable#setModel(javax.swing.table.TableModel)
 * @throws IllegalArgumentException
 *           if dataModel is not a {@link PropertySheetTableModel}
 */
public void setModel(TableModel newModel) {
  if (!(newModel instanceof PropertySheetTableModel)) {
    throw new IllegalArgumentException("dataModel must be of type "
        + PropertySheetTableModel.class.getName());
  }

  if (cancelEditing == null) {
    cancelEditing = new CancelEditing();
  }

  TableModel oldModel = getModel();
  if (oldModel != null) {
    oldModel.removeTableModelListener(cancelEditing);
  }
  super.setModel(newModel);
  newModel.addTableModelListener(cancelEditing);

  // ensure the "value" column can not be resized
  getColumnModel().getColumn(1).setResizable(false);
}
 
Example #4
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
private void deleteActionPerformed() {
  int[] selection = table.getSelectedRows();
  if (selection.length == 0) {
    return;
  }
  for (int i: selection) {
    int mi = table.convertRowIndexToModel(i);
    deletedRowSet.add(mi);
    SwingWorker<?, ?> worker = getSwingWorker(mi);
    if (Objects.nonNull(worker) && !worker.isDone()) {
      worker.cancel(true);
      // executor.remove(worker);
    }
    // worker = null;
  }
  RowSorter<? extends TableModel> sorter = table.getRowSorter();
  ((TableRowSorter<? extends TableModel>) sorter).setRowFilter(new RowFilter<TableModel, Integer>() {
    @Override public boolean include(Entry<? extends TableModel, ? extends Integer> entry) {
      return !deletedRowSet.contains(entry.getIdentifier());
    }
  });
  table.clearSelection();
  table.repaint();
}
 
Example #5
Source File: AbstractVTCorrelatorTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected void chooseFromCorrelationPanel(final String correlatorName, Runnable wizardAction) {

		WizardPanel currentWizardPanel = wizardManager.getCurrentWizardPanel();
		assertNotNull(currentWizardPanel);
		assertTrue(currentWizardPanel instanceof CorrelatorPanel);
		CorrelatorPanel correlatorPanel = (CorrelatorPanel) currentWizardPanel;
		runSwing(() -> {
			GhidraTable table = (GhidraTable) TestUtils.getInstanceField("table", correlatorPanel);
			TableModel model = table.getModel();
			int column = getNamedColumnIndex("Name", model);
			assertTrue(column >= 0);
			int row = getRowWithFieldValueInColumn(correlatorName, model, column);
			assertTrue(row >= 0);
			model.setValueAt(Boolean.TRUE, row, 0);
			wizardAction.run();
		});
	}
 
Example #6
Source File: MyTable.java    From gameserver with Apache License 2.0 6 votes vote down vote up
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
	if ( renderFactory != null ) {
		TableModel tableModel = this.getModel();
		if ( tableModel != null ) {
			int modelRowIndex = this.convertRowIndexToModel(row);
			int modelColumnIndex = this.convertColumnIndexToModel(column);
			String columnName = getColumnName(column, tableModel);
			TableCellRenderer renderer = this.renderFactory.getCellRenderer(
					modelRowIndex, modelColumnIndex, columnName, tableModel, this);
			if ( renderer != null ) {
				return renderer;
			}
		}
	}
	return super.getCellRenderer(row, column);
}
 
Example #7
Source File: SortableAndSearchableTable.java    From meka with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the model to display - only {@link #getTableModelClass()}.
 *
 * @param model	the model to display
 */
@Override
public synchronized void setModel(TableModel model) {
	Hashtable<String,Object> settings;

	if (!(getTableModelClass().isInstance(model)))
		model = createDefaultDataModel();

	// backup current setup
	if (m_Model != null) {
		settings = backupModelSettings(m_Model);
		getTableHeader().removeMouseListener(m_Model.getHeaderMouseListener());
	}
	else {
		settings = null;
	}

	m_Model = new SortableAndSearchableWrapperTableModel(model);
	super.setModel(m_Model);
	m_Model.addMouseListenerToHeader(this);

	// restore setup
	restoreModelSettings(m_Model, settings);
}
 
Example #8
Source File: DefaultOutlineModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates a new instance of DefaultOutlineModel.  <strong><b>Note</b> 
 * Do not fire table structure changes from the wrapped TableModel (value
 * changes are okay).  Changes that affect the number of rows must come
 * from the TreeModel.
 * @param treeModel The tree model
 * @param tableModel The table model
 * @param largeModel <code>true</code> if it's a large model tree, <code>false</code> otherwise.
 * @param nodesColumnLabel Label of the node's column
 */
protected DefaultOutlineModel(TreeModel treeModel, TableModel tableModel, boolean largeModel, String nodesColumnLabel) {
    this.treeModel = treeModel;
    this.tableModel = tableModel;
    if (nodesColumnLabel != null) {
        this.nodesColumnLabel = nodesColumnLabel;
    }
    
    layout = largeModel ? (AbstractLayoutCache) new FixedHeightLayoutCache() 
        : (AbstractLayoutCache) new VariableHeightLayoutCache();
        
    broadcaster = new EventBroadcaster (this);
    
    layout.setRootVisible(true);
    layout.setModel(this);
    treePathSupport = new TreePathSupport(this, layout);
    treePathSupport.addTreeExpansionListener(broadcaster);
    treePathSupport.addTreeWillExpandListener(broadcaster);
    treeModel.addTreeModelListener(broadcaster);
    tableModel.addTableModelListener(broadcaster);
    if (tableModel instanceof ProxyTableModel) {
        ((ProxyTableModel) tableModel).setOutlineModel(this);
    }
}
 
Example #9
Source File: PerfBenchmarkingTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private TableModel createFruitTableModel() {
  final String[] names = new String[] { "Id Number", "Cat", "Fruit" };
  final Object[][] data = new Object[][] {
    { "I1", "A", "Apple" },
    { "I2", "A", "Orange" },
    { "I2", "A", "Orange" },
    { "I2", "A", "Orange" },
    { "I2", "A", "Orange" },
    { "I2", "A", "Orange" },
    { "I2", "A", "Orange" },
    { "I2", "A", "Orange" },
    { "I2", "A", "Orange" },
    { "I3", "B", "Water melon" },
    { "I3", "B", "Water melon" },
    { "I3", "B", "Water melon" },
    { "I3", "B", "Water melon" },
    { "I3", "B", "Water melon" },
    { "I3", "B", "Water melon" },
    { "I3", "B", "Water melon" },
    { "I3", "B", "Water melon" },
    { "I4", "B", "Strawberry" },
  };
  return new DefaultTableModel( data, names );
}
 
Example #10
Source File: ExtSubReportDemo.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private TableModel createFruitTableModel()
{
  final String[] names = new String[]{"Id Number", "Cat", "Fruit"};
  final Object[][] data = new Object[][]{
      {"I1", "A", "Apple"},
      {"I2", "A", "Orange"},
      {"I2", "A", "Orange"},
      {"I2", "A", "Orange"},
      {"I2", "A", "Orange"},
      {"I2", "A", "Orange"},
      {"I2", "A", "Orange"},
      {"I2", "A", "Orange"},
      {"I2", "A", "Orange"},
      {"I3", "B", "Water melon"},
      {"I3", "B", "Water melon"},
      {"I3", "B", "Water melon"},
      {"I3", "B", "Water melon"},
      {"I3", "B", "Water melon"},
      {"I3", "B", "Water melon"},
      {"I3", "B", "Water melon"},
      {"I3", "B", "Water melon"},
      {"I4", "B", "Strawberry"},
  };
  return new DefaultTableModel(data, names);
}
 
Example #11
Source File: TableColumnModelState.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void saveColumnSettings(Element columnElement, TableColumn column) {
	TableModel tableModel = table.getUnwrappedTableModel();
	if (!(tableModel instanceof ConfigurableColumnTableModel)) {
		return;
	}

	ConfigurableColumnTableModel configurableTableModel =
		(ConfigurableColumnTableModel) tableModel;
	Settings settings = configurableTableModel.getColumnSettings(column.getModelIndex());
	if (settings == null) {
		return;
	}

	for (String name : settings.getNames()) {
		Object value = settings.getValue(name);
		if (value instanceof String) {
			addSettingElement(columnElement, name, "String", (String) value);
		}
		else if (value instanceof Long) {
			addSettingElement(columnElement, name, "Long", value.toString());
		}
		// else if (value instanceof byte[]) // we don't handle this case; OBE?
	}
}
 
Example #12
Source File: IsEmptyDataExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Checks whether the report has a data-source and wether the datasource is empty. A datasource is considered empty,
 * if it contains no rows. The number of columns is not evaluated.
 *
 * @return the value of the function.
 */
public Object getValue() {

  final ExpressionRuntime runtime = getRuntime();
  if ( runtime == null ) {
    return null;
  }
  final TableModel data = runtime.getData();
  if ( data == null ) {
    return null;
  }
  if ( data.getRowCount() == 0 ) {
    return Boolean.TRUE;
  }
  return Boolean.FALSE;
}
 
Example #13
Source File: EquatePlugin1Test.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleEquatesSameValue() throws Exception {

	createSameValueDifferentNameEquates();

	putCursorOnOperand(0x010062d6, 1);

	SetEquateDialog d = showSetEquateDialog();

	GhidraTable table = findComponent(d.getComponent(), GhidraTable.class);
	assertNotNull(table);

	TableModel model = table.getModel();
	assertEquals(5, model.getRowCount());
	for (int i = 0; i < 5; i++) {
		String value = (String) model.getValueAt(i, 0);
		assertTrue(value.startsWith("MY_EQUATE_"));
	}

	cancel(d);
}
 
Example #14
Source File: ManageCalibration.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void refreshTimes(JTable table) {
    final TableModel model = table.getModel();
    for (int row = 0; row < model.getRowCount(); row++) {
        String javaPlatform = javaPlatforms[row];
        Long modified = null;
        String s = CalibrationSupport.getCalibrationDataFileName(javaPlatform);
        if (s != null) {
            File f = new File(s);
            if (f.isFile()) modified = Long.valueOf(f.lastModified());
        }
        final int index = row;
        final Long _modified = modified;
        SwingUtilities.invokeLater(new Runnable() {
            public void run() { model.setValueAt(_modified, index, 1); }
        });
    }
}
 
Example #15
Source File: ItemMinFunctionIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testReport() throws Exception {
  final TableModel tableModel = createTableModel();
  final MasterReport report = createReport( tableModel );

  report.addExpression( create( "cell-sum", VALUE, null, COLUMN_DIMENSION_B ) );
  report.addExpression( new ValidateFunctionResultExpression( "#cell-sum", true, null ) );

  report.addExpression( create( "detail-sum", VALUE, COLUMN_DIMENSION_B, ROW_DIMENSION_B ) );
  report.addExpression( new ValidateFunctionResultExpression( "#detail-sum", true, COLUMN_DIMENSION_B ) );

  report.addExpression( create( "row-b-sum", VALUE, COLUMN_DIMENSION_A, ROW_DIMENSION_B ) );
  report.addExpression( new ValidateFunctionResultExpression( "#row-b-sum", true, COLUMN_DIMENSION_A ) );

  report.addExpression( create( "row-a-sum", VALUE, COLUMN_DIMENSION_A, ROW_DIMENSION_A ) );
  report.addExpression( new ValidateFunctionResultExpression( "#row-a-sum", true, COLUMN_DIMENSION_A ) );

  report.addExpression( create( "column-a-sum", VALUE, null, COLUMN_DIMENSION_A ) );
  report.addExpression( new ValidateFunctionResultExpression( "#column-a-sum", true, null ) );

  report.addExpression( create( "column-b-sum", VALUE, COLUMN_DIMENSION_B, ROW_DIMENSION_A ) );
  report.addExpression( new ValidateFunctionResultExpression( "#column-b-sum", true, COLUMN_DIMENSION_B ) );

  DebugReportRunner.execGraphics2D( report );
}
 
Example #16
Source File: SortableAndSearchableWrapperTableModel.java    From meka with GNU General Public License v3.0 5 votes vote down vote up
/**
 * initializes with the given model.
 *
 * @param model       the model to initialize the sorted model with
 */
public SortableAndSearchableWrapperTableModel(TableModel model) {
	super();

	m_MouseListener   = null;
	m_SortedIndices   = null;
	m_DisplayIndices  = null;
	m_ColumnIsNumeric = null;

	setUnsortedModel(model);
}
 
Example #17
Source File: FmtImports.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void separateStaticImportsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_separateStaticImportsCheckBoxActionPerformed
    TableModel oldModel = importLayoutTable.getModel();
    TableModel newModel = (DefaultTableModel)createTableModel(importGroupsOrder, preferences);
    importLayoutTable.setModel(newModel);
    setImportLayoutTableColumnsWidth();
    for (TableModelListener l : ((DefaultTableModel)oldModel).getTableModelListeners()) {
        oldModel.removeTableModelListener(l);
        newModel.addTableModelListener(l);
        l.tableChanged(null);
    }
}
 
Example #18
Source File: SortingDataFactory.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private List<SortConstraint> resolveColumnAliases( final TableModel tableModel, final List<SortConstraint> sort ) {
  ArrayList<SortConstraint> result = new ArrayList<SortConstraint>( sort.size() );
  for ( final SortConstraint constraint : sort ) {
    String field = constraint.getField();
    if ( StringUtils.isEmpty( field ) ) {
      DebugLog.log( "Sort field is empty" );
      continue;
    }

    if ( field.startsWith( ClassicEngineBoot.INDEX_COLUMN_PREFIX ) ) {
      String idx = field.substring( ClassicEngineBoot.INDEX_COLUMN_PREFIX.length() );
      try {
        int idxParsed = Integer.parseInt( idx );
        if ( idxParsed >= 0 && idxParsed < tableModel.getColumnCount() ) {
          String columnName = tableModel.getColumnName( idxParsed );
          if ( !StringUtils.isEmpty( columnName ) ) {
            result.add( new SortConstraint( columnName, constraint.isAscending() ) );
          } else {
            DebugLog.log( "Resolved column name for column at index " + idxParsed + " is empty." );
          }
        } else {
          logger.debug( "Invalid index on indexed column '" + field + "'" );
        }
      } catch ( final NumberFormatException iae ) {
        logger.debug( "Unable to parse non-decimal index on indexed column '" + field + "'", iae );
      }
    } else {
      result.add( constraint );
    }
  }
  return result;
}
 
Example #19
Source File: TableModelInfo.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void printTableCellAttributes( final TableModel mod, final PrintStream out ) {
  if ( mod instanceof MetaTableModel == false ) {
    out.println( "TableModel has no meta-data." );
    return;
  }

  final MetaTableModel metaTableModel = (MetaTableModel) mod;
  if ( metaTableModel.isCellDataAttributesSupported() == false ) {
    out.println( "TableModel has no cell-meta-data." );
    return;
  }

  final DataAttributeContext attributeContext =
      new DefaultDataAttributeContext( new GenericOutputProcessorMetaData(), Locale.US );

  out.println( "Tablemodel contains " + mod.getRowCount() + " rows." ); //$NON-NLS-1$ //$NON-NLS-2$
  out.println( "Checking the attributes inside" ); //$NON-NLS-1$
  for ( int rows = 0; rows < mod.getRowCount(); rows++ ) {
    for ( int i = 0; i < mod.getColumnCount(); i++ ) {
      final DataAttributes cellAttributes = metaTableModel.getCellDataAttributes( rows, i );
      final String[] columnAttributeDomains = cellAttributes.getMetaAttributeDomains();
      Arrays.sort( columnAttributeDomains );
      for ( int attrDomainIdx = 0; attrDomainIdx < columnAttributeDomains.length; attrDomainIdx++ ) {
        final String colAttrDomain = columnAttributeDomains[attrDomainIdx];
        final String[] attributeNames = cellAttributes.getMetaAttributeNames( colAttrDomain );
        Arrays.sort( attributeNames );
        for ( int j = 0; j < attributeNames.length; j++ ) {
          final String attributeName = attributeNames[j];
          final Object o =
              cellAttributes.getMetaAttribute( colAttrDomain, attributeName, Object.class, attributeContext );

          out.println( "CellAttribute(" + rows + ", " + i + ") [" + colAttrDomain + ':' + attributeName + "]="
              + format( o ) );
        }
      }
    }
  }
}
 
Example #20
Source File: Util.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
static int findColumn(TableModel model, String name) {
    for (int i = 0; i<model.getColumnCount(); i++) {
        if (name.equals(model.getColumnName(i))) {
            return i;
        }
    }
    return -1;
}
 
Example #21
Source File: JTablePanel.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Set the model used by the right table.
 *
 * @param model table model
 */
public void setRightTableModel(TableModel model)
{
   TableModel old = m_rightTable.getModel();
   m_rightTable.setModel(model);
   firePropertyChange("rightTableModel", old, model);
}
 
Example #22
Source File: GTableFilterPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void initializeSavedFilters() {
	TableModel model = table.getModel();
	if (!(model instanceof GDynamicColumnTableModel)) {
		return;
	}
	@SuppressWarnings("unchecked")
	GDynamicColumnTableModel<ROW_OBJECT, ?> dynamicModel =
		(GDynamicColumnTableModel<ROW_OBJECT, ?>) model;

	ColumnFilterSaveManager<ROW_OBJECT> saveManager =
		new ColumnFilterSaveManager<>(this, table, dynamicModel, dynamicModel.getDataSource());
	savedFilters = saveManager.getSavedFilters();
	Collections.reverse(savedFilters);
	updateColumnFilterButton();
}
 
Example #23
Source File: JFXJavaScriptCallbacksPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static TableModel createModel(final Map<String,String> callbacks) {
    final Object[][] data = new Object[callbacks.size()][];
    final Iterator<Map.Entry<String,String>> it = callbacks.entrySet().iterator();
    for (int i=0; it.hasNext(); i++) {
        final Map.Entry<String,String> entry = it.next();
        data[i] = new Object[] {entry.getKey(),entry.getValue()};
    }
    return new DefaultTableModel(
        data,
        new String[] {
            NbBundle.getMessage(JFXDownloadModePanel.class, "JFXJavaScriptCallbacksPanel.tableCallbacks.columnModel.title0"), //NOI18N
            NbBundle.getMessage(JFXDownloadModePanel.class, "JFXJavaScriptCallbacksPanel.tableCallbacks.columnModel.title1") //NOI18N
        }) {
        @Override
        public boolean isCellEditable(int row, int column) {
            return column != 0;
        }

        @Override
        public Class<?> getColumnClass(int columnIndex) {
            switch (columnIndex) {
                case 0:
                    return String.class;
                case 1:
                    return String.class;
                default:
                    throw new IllegalStateException();
            }
        }
        
    };
}
 
Example #24
Source File: TotalItemCountFunctionIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private MasterReport createReport( final TableModel tableModel ) {
  final MasterReport report = new MasterReport();
  report.setDataFactory( new TableDataFactory( "query", tableModel ) );
  report.setQuery( "query" );
  final DesignTimeDataSchemaModel dataSchemaModel = new DesignTimeDataSchemaModel( report );

  final CrosstabBuilder builder = new CrosstabBuilder( dataSchemaModel );
  builder.addRowDimension( "Row-Dimension-A" );
  builder.addRowDimension( ROW_DIMENSION_B );
  builder.addColumnDimension( COLUMN_DIMENSION_A );
  builder.addColumnDimension( COLUMN_DIMENSION_B );
  builder.addDetails( VALUE, null );
  report.setRootGroup( builder.create() );
  return report;
}
 
Example #25
Source File: LostTextTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static TableModel testSelectionWithFilterTable() {
    model = new DefaultTableModel(0, 1);
    int last = 10;
    for (int i = 0; i <= last; i++) {
        model.addRow(new Object[]{i});
    }
    return model;
}
 
Example #26
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
private static JTable makeTable(TableModel model) {
  JTable table = new JTable(model);
  table.setShowVerticalLines(false);
  table.setShowHorizontalLines(false);
  table.setIntercellSpacing(new Dimension());
  // table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
  // table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  // table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
  return table;
}
 
Example #27
Source File: SearchScreenShots.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Captures the warning dialog displayed when the search results reach the maximum
 * limit.
 */
@Test
public void testSearchLimitExceeded() {

	moveTool(500, 500);

	// Set the search results max to a low number that we know will be hit with the 
	// custom program we've loaded.  Also, we are NOT changing the option so that dialog
	// that is shown will have the default value
	searchPlugin = env.getPlugin(SearchTextPlugin.class);
	searchPlugin.optionsChanged(null, GhidraOptions.OPTION_SEARCH_LIMIT, null, 10);

	performAction("Search Text", "SearchTextPlugin", false);
	waitForSwing();

	DialogComponentProvider dialog = getDialog();

	JRadioButton rbAll = (JRadioButton) getInstanceField("searchAllRB", dialog);
	rbAll.setSelected(true);

	JTextField textField = (JTextField) getInstanceField("valueField", dialog);
	setText(textField, "0");

	final JButton allButton = (JButton) getInstanceField("allButton", dialog);
	pressButton(allButton);

	ComponentProvider provider = getProvider(TableComponentProvider.class);
	JComponent component = provider.getComponent();
	JTable table = findComponent(component, JTable.class);
	TableModel model = table.getModel();
	waitForTableModel((ThreadedTableModel<?, ?>) model);

	Window errorDialog = waitForWindow("Search Limit Exceeded!", 2000);
	captureWindow(errorDialog);
}
 
Example #28
Source File: JWSCustomizerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void appletParamsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_appletParamsButtonActionPerformed

    List<Map<String,String>> origProps = jwsProps.getAppletParamsProperties();
    List<Map<String,String>> props = copyList(origProps);
    TableModel appletParamsTableModel = new JWSProjectProperties.PropertiesTableModel(props, JWSProjectProperties.appletParamsSuffixes, appletParamsColumnNames);
    JPanel panel = new AppletParametersPanel((PropertiesTableModel) appletParamsTableModel, jwsProps.appletWidthDocument, jwsProps.appletHeightDocument);
    DialogDescriptor dialogDesc = new DialogDescriptor(panel, NbBundle.getMessage(JWSCustomizerPanel.class, "TITLE_AppletParameters"), true, null); //NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDesc);
    dialog.setVisible(true);
    if (dialogDesc.getValue() == DialogDescriptor.OK_OPTION) {
        jwsProps.setAppletParamsProperties(props);
    }
    dialog.dispose();

}
 
Example #29
Source File: DataRowPaddingIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static int advanceCrosstab( final CrosstabSpecification specification, final TableModel data,
    final String[][] valData ) {
  // second run. Now with padding ..
  final ProcessingContext prc = new DefaultProcessingContext();
  final GlobalMasterRow gmr =
      GlobalMasterRow.createReportRow( prc, new DefaultDataSchemaDefinition(), new ParameterDataRow() );
  gmr.requireStructuralProcessing();
  MasterDataRow wdata = gmr.deriveWithQueryData( data );
  int advanceCount = 1;
  wdata = wdata.startCrosstabMode( specification );
  logger.debug( "Region:  " + wdata.getGlobalView().get( "Region" ) );
  logger.debug( "Product: " + wdata.getGlobalView().get( "Product" ) );
  logger.debug( "Year:    " + wdata.getGlobalView().get( "Time" ) );
  assertEquals( valData[0][0], wdata.getGlobalView().get( "Region" ) );
  assertEquals( valData[0][1], wdata.getGlobalView().get( "Product" ) );
  assertEquals( valData[0][2], wdata.getGlobalView().get( "Time" ) );

  Object grpVal = wdata.getGlobalView().get( "Region" );
  while ( wdata.isAdvanceable() ) {
    logger.debug( "-- Advance -- " + advanceCount );
    MasterDataRow nextdata = wdata.advance();
    final Object nextGrpVal = nextdata.getGlobalView().get( "Region" );
    if ( ObjectUtilities.equal( grpVal, nextGrpVal ) == false ) {
      nextdata = nextdata.resetRowCursor();
    }

    logger.debug( "Do Advance Count: " + nextdata.getReportDataRow().getCursor() );
    logger.debug( "Region:  " + nextdata.getGlobalView().get( "Region" ) );
    logger.debug( "Product: " + nextdata.getGlobalView().get( "Product" ) );
    logger.debug( "Year:    " + nextdata.getGlobalView().get( "Time" ) );
    assertEquals( valData[advanceCount][0], nextdata.getGlobalView().get( "Region" ) );
    assertEquals( valData[advanceCount][1], nextdata.getGlobalView().get( "Product" ) );
    assertEquals( valData[advanceCount][2], nextdata.getGlobalView().get( "Time" ) );
    advanceCount += 1;
    wdata = nextdata;
    grpVal = nextGrpVal;
  }
  return advanceCount;
}
 
Example #30
Source File: TableJFreeChartDemo.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private TableModel createTableModel()
{
  final Object[][] data = new Object[12 * 5][];
  final int[] votes = new int[5];
  for (int i = 0; i < 12; i++)
  {
    final Integer year = new Integer(1995 + i);
    votes[0] = (int) (Math.random() * 200);
    votes[1] = (int) (Math.random() * 50);
    votes[2] = (int) (Math.random() * 100);
    votes[3] = (int) (Math.random() * 50);
    votes[4] = (int) (Math.random() * 100);

    final JFreeChart chart = createChart(year.intValue(), votes);

    data[i * 5] = new Object[]{
        year, "Java", new Integer(votes[0]), chart
    };
    data[i * 5 + 1] = new Object[]{
        year, "Visual Basic", new Integer(votes[1]), chart
    };
    data[i * 5 + 2] = new Object[]{
        year, "C/C++", new Integer(votes[2]), chart
    };
    data[i * 5 + 3] = new Object[]{
        year, "PHP", new Integer(votes[3]), chart
    };
    data[i * 5 + 4] = new Object[]{
        year, "Perl", new Integer(votes[4]), chart
    };

  }

  final String[] colNames = {
      "year", "language", "votes", "chart"
  };

  return new DefaultTableModel(data, colNames);
}