Exemplo n.º 1
0
  /**
   * Sets whether or not this component is enabled. Disabling this pane will
   * also disable its children.
   *
   * @param enabled <code>true<code> if this component and its children should
   * be enabled, <code>false<code> otherwise
   */
  public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);

    addButton.setEnabled(enabled);
    table.setEnabled(enabled);
    table.getTableHeader().setEnabled(enabled);

    if (enabled) {
      editButton.setEnabled(selectionModel.getSelectedValues().length == 1);
      removeButton.setEnabled(!selectionModel.isSelectionEmpty());
    } else {
      table.clearSelection();

      editButton.setEnabled(enabled);
      removeButton.setEnabled(enabled);
    }
  }
Exemplo n.º 2
0
    public Component getTableCellRendererComponent(
        JTable table,
        Object value,
        boolean selected,
        boolean hasFocus,
        int rowIndex,
        int columnIndex) {
      Component component =
          super.getTableCellRendererComponent(
              table, value, selected, hasFocus, rowIndex, columnIndex);

      if (!selected) component.setBackground(table.getTableHeader().getBackground());

      return component;
    }
Exemplo n.º 3
0
  /**
   * Initializes the layout of this pane.
   *
   * @return The container with all its widgets
   */
  protected void initializeLayout() {
    GridBagConstraints constraints = new GridBagConstraints();
    selectionModel = buildPropertySelectionModel();

    // Property table
    table =
        SwingComponentFactory.buildTable(
            this.buildPropertyTableAdapter(), this.buildTableColumnModel(), this.selectionModel);
    table.setAutoCreateColumnsFromModel(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setAutoscrolls(true);
    table.setSurrendersFocusOnKeystroke(true);
    table.getTableHeader().setReorderingAllowed(false);
    table.addPropertyChangeListener("enabled", new PropertyChangeHandler());

    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 3;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.insets = new Insets(0, 0, 0, 0);

    scrollPane = new JScrollPane(table);
    scrollPane.setMinimumSize(new Dimension(0, 0));
    scrollPane.setPreferredSize(new Dimension(0, 0));
    scrollPane.getViewport().setBackground(table.getBackground());

    add(scrollPane, constraints);

    // Add button
    addButton = buildButton("LOGIN_PROPERTY_ADD_BUTTON");
    addButton.addActionListener(buildAddActionListener());

    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.insets = new Insets(0, 5, 0, 0);

    add(addButton, constraints);

    // Edit button
    editButton = buildButton("LOGIN_PROPERTY_EDIT_BUTTON");
    editButton.addActionListener(buildEditActionListener());
    editButton.setEnabled(false);

    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.insets = new Insets(5, 5, 0, 0);

    add(editButton, constraints);
    buildEditButtonEnabler();

    // Remove button
    removeButton = buildButton("LOGIN_PROPERTY_REMOVE_BUTTON");
    removeButton.addActionListener(buildRemoveActionListener(selectionModel));
    removeButton.setEnabled(false);

    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.PAGE_START;
    constraints.insets = new Insets(5, 5, 0, 0);

    add(removeButton, constraints);
    buildRemoveButtonEnabler();

    addHelpTopicId(this, "session.login.properties");
  }