Search in sources :

Example 81 with JTableHeader

use of javax.swing.table.JTableHeader in project VideoOptimzer by attdevsupport.

the class CheckBoxHeader method getTableCellRendererComponent.

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (table != null) {
        JTableHeader header = table.getTableHeader();
        if (header != null) {
            setForeground(header.getForeground());
            setBackground(header.getBackground());
            setFont(header.getFont());
            header.addMouseListener(this);
        }
    }
    // For enable the header check box
    setColumn(column);
    setHorizontalAlignment(SwingConstants.CENTER);
    return this;
}
Also used : JTableHeader(javax.swing.table.JTableHeader)

Example 82 with JTableHeader

use of javax.swing.table.JTableHeader in project VideoOptimzer by attdevsupport.

the class SegmentTablePanel method getStreamTable.

private JPanel getStreamTable(String title, SortedMap<String, VideoEvent> eventList, JScrollPane tableScrollPane) {
    // Do not resize columns or setPreferredWidth in this method
    DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
    rightRenderer.setHorizontalAlignment(SwingConstants.RIGHT);
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment(SwingConstants.CENTER);
    Collection<VideoEvent> videoEventList = eventList.values();
    rowCount = videoEventList.size();
    TableModel tableModel = new SegmentTableModel(videoEventList, videoStream.getPlayRequestedTime() != null ? videoStream.getPlayRequestedTime() : 0.0);
    JTable jTable;
    jTable = new JTable(tableModel);
    jTable.setName(title);
    streamTables.put(title, jTable);
    jTable.setGridColor(Color.LIGHT_GRAY);
    for (int idx = 0; idx < jTable.getColumnCount() - 2; idx++) {
        jTable.getColumnModel().getColumn(idx).setCellRenderer(rightRenderer);
    }
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.TRACK)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.TCP_STATE)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.CHANNELS)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.DOWNLOAD_DELAY)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.PLAYBACK_DELAY)).setCellRenderer(centerRenderer);
    JTableHeader header = jTable.getTableHeader();
    header.setDefaultRenderer(new MultiLineTableHeaderRenderer());
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(title));
    if (rowCount > tableHeight) {
        tableScrollPane.setPreferredSize(new Dimension(0, MAX_HEIGHT));
    } else {
        int rowHeight = jTable.getRowHeight();
        tblHeight = 100 + (eventList.size() * (rowHeight + 3));
        tableScrollPane.setPreferredSize(new Dimension(0, tblHeight));
        tableScrollPane.setSize(new Dimension(0, tblHeight));
        panel.setPreferredSize(new Dimension(0, tblHeight));
        panel.setMinimumSize(new Dimension(0, tblHeight));
        panel.setSize(new Dimension(0, tblHeight));
    }
    tableScrollPane.setViewportView(jTable);
    panel.setLayout(new BorderLayout());
    panel.add(header, BorderLayout.NORTH);
    panel.add(tableScrollPane, BorderLayout.CENTER);
    // Sorter for jTable
    TableRowSorter<TableModel> rowSorter = new TableRowSorter<TableModel>(jTable.getModel());
    jTable.setRowSorter(rowSorter);
    refreshSegmentPanel();
    int colCount = rowSorter.getModel().getColumnCount();
    for (int column = 0; column < colCount; column++) {
        rowSorter.setComparator(column, new TableSortComparator(column, "-"));
    }
    jTable.addMouseListener(streamTableClickHandler(tableModel, jTable, jTable.getColumnModel().getColumnIndex("SessionLink")));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) JTableHeader(javax.swing.table.JTableHeader) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) Dimension(java.awt.Dimension) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter)

Example 83 with JTableHeader

use of javax.swing.table.JTableHeader in project VideoOptimzer by attdevsupport.

the class ImageComparatorDataTable method createDefaultTableHeader.

/**
 * Returns a default table header for the DataTable.
 *
 * @return A JTableHeader object with default properties.
 */
@Override
public JTableHeader createDefaultTableHeader() {
    return new JTableHeader(columnModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getToolTipText(MouseEvent mEvent) {
            int column = columnAtPoint(mEvent.getPoint());
            // Locate the renderer under the event location
            if (column != -1) {
                TableColumn aColumn = columnModel.getColumn(column);
                Object tip = aColumn.getHeaderValue();
                if (tip != null) {
                    return tip.toString();
                }
            }
            return null;
        }
    };
}
Also used : MouseEvent(java.awt.event.MouseEvent) JTableHeader(javax.swing.table.JTableHeader) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point)

Example 84 with JTableHeader

use of javax.swing.table.JTableHeader in project VideoOptimzer by attdevsupport.

the class ImageBPTable method createDefaultTableHeader.

/**
 * Returns a default table header for the DataTable.
 *
 * @return A JTableHeader object with default properties.
 */
@Override
public JTableHeader createDefaultTableHeader() {
    return new JTableHeader(columnModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getToolTipText(MouseEvent mEvent) {
            int column = columnAtPoint(mEvent.getPoint());
            // Locate the renderer under the event location
            if (column != -1) {
                TableColumn aColumn = columnModel.getColumn(column);
                Object tip = aColumn.getHeaderValue();
                if (tip != null) {
                    return tip.toString();
                }
            }
            return null;
        }
    };
}
Also used : MouseEvent(java.awt.event.MouseEvent) JTableHeader(javax.swing.table.JTableHeader) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point)

Example 85 with JTableHeader

use of javax.swing.table.JTableHeader in project VideoOptimzer by attdevsupport.

the class VideoRequestPanel method getRequestListPanel.

private JPanel getRequestListPanel() {
    if (requestListPanel == null) {
        requestListPanel = new JPanel();
        requestListPanel.setLayout(new BorderLayout());
        getDummyData();
        requestListTable = new DataTable<HttpRequestResponseInfo>();
        requestListPanel.setName(ResourceBundleHelper.getMessageString("video.tab.requests.tableName"));
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) requestListTable.getPopup();
        popupMenu.initialize();
        videoRequestTableModel.setData(requestURL);
        requestListTable.setModel(videoRequestTableModel);
        JTableHeader header = requestListTable.getTableHeader();
        requestListTable.setGridColor(Color.LIGHT_GRAY);
        int width = requestListTable.getParent() != null ? requestListTable.getParent().getWidth() : 1000;
        width = requestPanel.getWidth();
        requestListTable.getColumnModel().getColumn(0).setPreferredWidth(width);
        requestListTable.getColumnModel().getColumn(0).setCellRenderer(new WordWrapRenderer());
        requestListPanel.add(header, BorderLayout.NORTH);
        requestListPanel.add(requestListTable, BorderLayout.CENTER);
        requestListTable.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent event) {
                if (event.getClickCount() == 2) {
                    int row = requestListTable.getSelectedRow();
                    HttpRequestResponseInfo request = requestURL.get(row);
                    requestListTable.getColumnModel().getColumn(0).setCellRenderer(new WordWrapRenderer(row));
                    if (ResourceBundleHelper.getMessageString("videotab.videorequest.table.url").equals(requestListTable.getColumnName(requestListTable.getSelectedColumn()))) {
                        RegexWizard regexWizard = RegexWizard.getInstance(aroView.getJFrame());
                        regexWizard.setRequest(request);
                        regexWizard.setVisible(true);
                    }
                }
            }
        });
    }
    return requestListPanel;
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) BorderLayout(java.awt.BorderLayout) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu) MouseAdapter(java.awt.event.MouseAdapter) JTableHeader(javax.swing.table.JTableHeader) RegexWizard(com.att.aro.ui.view.menu.tools.RegexWizard)

Aggregations

JTableHeader (javax.swing.table.JTableHeader)240 TableColumn (javax.swing.table.TableColumn)59 MouseEvent (java.awt.event.MouseEvent)56 JTable (javax.swing.JTable)53 TableColumnModel (javax.swing.table.TableColumnModel)45 TableCellRenderer (javax.swing.table.TableCellRenderer)38 Component (java.awt.Component)35 MouseAdapter (java.awt.event.MouseAdapter)32 DefaultTableModel (javax.swing.table.DefaultTableModel)29 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)28 Color (java.awt.Color)25 JPanel (javax.swing.JPanel)25 JScrollPane (javax.swing.JScrollPane)25 JLabel (javax.swing.JLabel)23 Point (java.awt.Point)22 Dimension (java.awt.Dimension)20 BorderLayout (java.awt.BorderLayout)18 JComponent (javax.swing.JComponent)17 TableModel (javax.swing.table.TableModel)17 JButton (javax.swing.JButton)14