org.jdesktop.swingx.renderer.DefaultTableRenderer Java Examples

The following examples show how to use org.jdesktop.swingx.renderer.DefaultTableRenderer. 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: AjaxSpiderResultsTable.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public AjaxSpiderResultsTable(AjaxSpiderResultsTableModel resultsModel) {
    super(resultsModel);

    setName(RESULTS_TABLE_NAME);

    setAutoCreateColumnsFromModel(false);

    getColumnExt(0)
            .setCellRenderer(
                    new DefaultTableRenderer(
                            new MappedValue(StringValues.EMPTY, IconValues.NONE),
                            JLabel.CENTER));
    getColumnExt(0).setHighlighters(new ProcessedCellItemIconHighlighter(0));

    getColumnExt(Constant.messages.getString("view.href.table.header.timestamp.response"))
            .setVisible(false);
    getColumnExt(Constant.messages.getString("view.href.table.header.size.requestheader"))
            .setVisible(false);
    getColumnExt(Constant.messages.getString("view.href.table.header.size.requestbody"))
            .setVisible(false);

    extensionHistory =
            Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class);
}
 
Example #2
Source File: TokenGenMessagesTable.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void configureTableColumn(final TableModel model, final TableColumnExt columnExt) {
    super.configureTableColumn(model, columnExt);

    if (columnExt.getModelIndex() == TokenGenMessagesTableModel.RTT_COLUMN_INDEX
            && TimeDurationStringValue.isTargetClass(
                    model.getColumnClass(TokenGenMessagesTableModel.RTT_COLUMN_INDEX))) {
        columnExt.setCellRenderer(new DefaultTableRenderer(new TimeDurationStringValue()));
    }

    if (columnExt.getModelIndex()
                    == TokenGenMessagesTableModel.RESPONSE_BODY_SIZE_COLUMN_INDEX
            && SizeBytesStringValue.isTargetClass(
                    model.getColumnClass(
                            TokenGenMessagesTableModel.RESPONSE_BODY_SIZE_COLUMN_INDEX))) {
        columnExt.setCellRenderer(new DefaultTableRenderer(new SizeBytesStringValue()));
    }
}
 
Example #3
Source File: TokenGenMessagesTable.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
protected void createDefaultRenderers() {
    super.createDefaultRenderers();

    setDefaultRenderer(Date.class, new DefaultTableRenderer(new DateFormatStringValue()));
}
 
Example #4
Source File: ChipsterAnnotationsScreen.java    From chipster with MIT License 4 votes vote down vote up
@SuppressWarnings("serial")
	private JXTable getTable() {
		if (table == null) {
			this.tableModel = new AnnotationsTableModel();
			this.table = new JXTable(tableModel) {

				// To make the custom selection colors also after font size
				// change
				@Override
				public void updateUI() {
					super.updateUI();
					setSelectionBackground(getBackground());
					setSelectionForeground(getForeground());
				}

				public Component prepareRenderer(TableCellRenderer renderer,
						int rowIndex, int vColIndex) {
					Component c = super.prepareRenderer(renderer, rowIndex,
							vColIndex);

//					Column col = Column.values()[table
//							.convertColumnIndexToModel(vColIndex)];

					rowIndex = table.convertRowIndexToModel(rowIndex);

//					if (c instanceof JComponent) {
//						JComponent jc = (JComponent) c;
//
//						Task task = tasks.get(rowIndex);
//						if (col == Column.TOOL) {
//							try {
//								jc.setToolTipText(task.getParameters()
//										.toString());
//							} catch (Exception e) {
//							}
//						} else if (col == Column.STATUS) {
//							String status = task.getState().toString();
//
//							if (task.getStateDetail() != null
//									&& task.getStateDetail().length() > 0) {
//								status += " ( " + task.getStateDetail() + " )";
//							} else if (tasks.get(rowIndex)
//									.getCompletionPercentage() != -1) {
//								status += " ( "
//										+ task.getCompletionPercentage()
//										+ "% )";
//							}
//							jc.setToolTipText(status);
//
//						} else if (col == Column.TIME) {
//							long longTime = task.getExecutionTime();
//							String min = Strings.toString(
//									(int) (longTime / 1000) / 60, 2);
//							String sec = Strings.toString(
//									(int) (longTime / 1000) % 60, 2);
//							jc.setToolTipText("Execution time: " + min + ":"
//									+ sec);
//						}
//					}
					return c;
				}
			};

			table.getSelectionModel().addListSelectionListener(this);
			table.getColumnModel().getSelectionModel()
					.addListSelectionListener(this);
			table.getSelectionModel().setSelectionMode(
					ListSelectionModel.SINGLE_SELECTION);
			table.setAutoResizeMode(JXTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
			table.getColumnModel().getColumn(Column.GENOME.ordinal())
					.setPreferredWidth(250);
			table.getColumnModel().getColumn(Column.ANNOTATIONS.ordinal())
					.setPreferredWidth(80);
			table.getColumnModel().getColumn(Column.REFERENCE.ordinal())
					.setPreferredWidth(80);
			table.setShowVerticalLines(false);

			LinkModelAction<LinkModel> linkAction = new LinkModelAction<LinkModel>() {
				public void actionPerformed(ActionEvent e) {
					logger.debug("Canceling task: "
							+ tasks.get(table.convertRowIndexToModel(table
									.getSelectedRow())));
					taskExecutor.kill(tasks.get(table
							.convertRowIndexToModel(table.getSelectedRow())));
					setVisited(true);
				}
			};

			table.getColumn(Column.ANNOTATIONS.ordinal())
					.setCellRenderer(
							new DefaultTableRenderer(new HyperlinkProvider(
									linkAction)));
		}
		return table;
	}