public void mouseClicked(MouseEvent e) {
      JTableHeader h = (JTableHeader) e.getSource();
      TableColumnModel columnModel = h.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = columnModel.getColumn(viewColumn).getModelIndex();
      if (column != -1) {
        sorting_column = column;

        // 0 == priority icon column
        // 4 == priority text column
        if (column == 0) sorting_column = 4;

        if (e.isControlDown()) sorting_column = -1;
        else opposite = !opposite;

        TaskTable treetable = ((TaskTable) h.getTable());

        // java.util.Collection expanded = treetable.getExpandedTreeNodes();

        treetable.tableChanged();
        // treetable.setExpandedTreeNodes(expanded);
        // h.updateUI();
        h.resizeAndRepaint();
      }
    }
  private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    // JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "4dlu, d:grow, 4dlu", // columns
            "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, "
                + // rows
                "p, 2dlu, p, 4dlu"); // btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd"));
    contentPB.add(label, cc.xywh(2, 2, 1, 1));

    mediaTypeModel = new MediaTypeModel();
    mediaTypeTable = new JTable(mediaTypeModel);
    JTableHeader tableHeader = mediaTypeTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    // adjust column witdh of checkbox
    JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class);
    TableColumn column = mediaTypeTable.getColumnModel().getColumn(0);
    column.setMaxWidth(box.getPreferredSize().width + 2);
    column.setMinWidth(box.getPreferredSize().width + 2);
    mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer());
    // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable );
    contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1));

    // button bar
    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    okBtn.setDefaultCapable(true);
    okBtn.setRequestFocusEnabled(true);

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);

    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(okBtn);

    pack();
    setLocationRelativeTo(getParent());
  }
 protected JTableHeader createDefaultTableHeader() {
   if (dataTableHeader == null) {
     dataTableHeader = new JTableHeader(getDataColumnModel());
     dataTableHeader.setResizingAllowed(true);
     dataTableHeader.setTable(dataTable);
   }
   return (dataTableHeader);
 }
Exemplo n.º 4
0
 private void sortingStatusChanged() {
   clearSortingState();
   fireTableDataChanged();
   if (tableHeader != null) {
     tableHeader.repaint();
   }
 }
Exemplo n.º 5
0
 public void mouseClicked(MouseEvent e) {
   JTableHeader h = (JTableHeader) e.getSource();
   TableColumnModel columnModel = h.getColumnModel();
   int viewColumn = columnModel.getColumnIndexAtX(e.getX());
   int column = columnModel.getColumn(viewColumn).getModelIndex();
   if (column != -1) {
     int status = getSortingStatus(column);
     if (!e.isControlDown()) {
       cancelSorting();
     }
     // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
     // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
     status = status + (e.isShiftDown() ? -1 : 1);
     status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
     setSortingStatus(column, status);
   }
 }
    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) {
          setFont(header.getFont());
        }
      }
      this.isSelected = isSelected;
      this.hasFocus = hasFocus;
      this.column = column;
      this.hasRollover = (column == rolloverColumn);
      if (skin == null || skin.getContentMargin() == null) {
        skin = XPStyle.getXP().getSkin(header, "header.headeritem");
      }
      setText((value == null) ? "" : value.toString());
      setBorder(new EmptyBorder(skin.getContentMargin()));

      return this;
    }
Exemplo n.º 7
0
    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());
        }
      }

      if (isSelected) {
        setFont(getFont().deriveFont(Font.BOLD));
      }

      setText((value == null) ? "" : value.toString());
      setBorder(UIManager.getBorder("TableHeader.cellBorder"));

      return this;
    }
 public TaskTableSorter(TaskTable table) {
   JTableHeader tableHeader = table.getTableHeader();
   tableHeader.addMouseListener(new MouseHandler());
   tableHeader.setDefaultRenderer(new SortableHeaderRenderer());
 }
Exemplo n.º 9
0
 public void allowSortColChange(boolean allow) {
   JTableHeader hdr = table.getTableHeader();
   if (allow && !allowSortColChange) hdr.addMouseListener(allowSortColChangeMouseListener);
   else if (!allow && allowSortColChange) hdr.removeMouseListener(allowSortColChangeMouseListener);
   allowSortColChange = allow;
 }