/** Creates the layout of the panel (but the contents are not populated here). */
  protected void createLayout() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    p.setOpaque(false);
    p.setBorder(PANEL_BORDER);
    createBasicLayout(p, gbc);
    gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 0;
    JScrollPane scroll = Utilities.createBorderLessScrollBar(p);
    scrollListener = ScrollPaneBorderListener.createBottomBorderListener(scroll);
    add(scroll, gbc);

    gbc.gridy++;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.gridwidth = 1;
    delete = Utilities.createButton(INFO_CTRL_PANEL_DELETE_OBJECTCLASS_BUTTON.get());
    delete.setOpaque(false);
    add(delete, gbc);
    delete.addActionListener(
        new ActionListener() {
          /** {@inheritDoc} */
          @Override
          public void actionPerformed(ActionEvent ev) {
            deleteObjectclass();
          }
        });

    gbc.anchor = GridBagConstraints.EAST;
    gbc.gridx++;
    saveChanges = Utilities.createButton(INFO_CTRL_PANEL_SAVE_CHANGES_LABEL.get());
    saveChanges.setOpaque(false);
    add(saveChanges, gbc);
    saveChanges.addActionListener(
        new ActionListener() {
          /** {@inheritDoc} */
          @Override
          public void actionPerformed(ActionEvent ev) {
            ArrayList<LocalizableMessage> errors = new ArrayList<>();
            saveChanges(false, errors);
          }
        });
  }
  /**
   * Updates the contents of the panel with the provided object class.
   *
   * @param oc the object class.
   * @param schema the schema.
   */
  public void update(ObjectClass oc, Schema schema) {
    ignoreChangeEvents = true;

    objectClass = oc;
    if (oc == null || schema == null) {
      // Ignore: this is called to get an initial panel size.
      return;
    }
    String n = oc.getPrimaryName();
    if (n == null) {
      n = NOT_APPLICABLE.toString();
    }
    titlePanel.setDetails(LocalizableMessage.raw(n));
    name.setText(n);

    SortableListModel<AttributeType> modelRequired = attributes.getSelectedListModel1();
    SortableListModel<AttributeType> modelAvailable = attributes.getSelectedListModel2();
    SortableListModel<AttributeType> availableModel = attributes.getAvailableListModel();
    availableModel.addAll(modelRequired.getData());
    availableModel.addAll(modelAvailable.getData());
    modelRequired.clear();
    modelAvailable.clear();

    superiors.setSelectedSuperiors(oc.getSuperiorClasses());
    superiors.setObjectClassesToExclude(Collections.singleton(oc));
    if (oc.getSuperiorClasses().size() > 1) {
      lSuperior.setText(INFO_CTRL_PANEL_OBJECTCLASS_PARENTS_LABEL.get().toString());
    } else {
      lSuperior.setText(INFO_CTRL_PANEL_OBJECTCLASS_PARENT_LABEL.get().toString());
    }

    updateAttributesWithParent(false);

    for (AttributeType attr : oc.getRequiredAttributes()) {
      availableModel.remove(attr);
      modelRequired.add(attr);
    }
    for (AttributeType attr : oc.getOptionalAttributes()) {
      availableModel.remove(attr);
      modelAvailable.add(attr);
    }
    notifyAttributesChanged();

    oid.setText(oc.getOID());
    n = oc.getDescription();
    if (n == null) {
      n = "";
    }
    description.setText(n);

    Set<String> aliases = getAliases(oc);
    lastAliases.clear();
    lastAliases.addAll(aliases);
    this.aliases.setText(Utilities.getStringFromCollection(aliases, ", "));

    String sOrigin = Utilities.getOrigin(oc);
    if (sOrigin == null) {
      sOrigin = "";
    }
    origin.setText(sOrigin);

    String sFile = getSchemaFile(oc);
    if (sFile == null) {
      sFile = "";
    }
    file.setText(sFile);

    type.setSelectedItem(oc.getObjectClassType());

    obsolete.setSelected(oc.isObsolete());

    ocName = objectClass.getNameOrOID();
    scrollListener.updateBorder();
    for (JLabel label : labels) {
      setPrimaryValid(label);
    }
    saveChanges.setEnabled(false);
    ignoreChangeEvents = false;
  }
Example #3
0
  /** Creates the layout of the panel (but the contents are not populated here). */
  private void createLayout() {
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel p = new JPanel(new GridBagLayout());
    p.setOpaque(false);
    super.createBasicLayout(p, gbc, true);
    p.setBorder(new EmptyBorder(10, 10, 10, 10));
    gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 0;
    JScrollPane scroll = Utilities.createBorderLessScrollBar(p);
    scrollListener = ScrollPaneBorderListener.createBottomBorderListener(scroll);
    add(scroll, gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 1.0;
    gbc.insets.left = 0;
    gbc.gridwidth = 2;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbc.insets = new Insets(10, 10, 0, 10);
    add(warning, gbc);
    Utilities.setWarningLabel(warning, INDEX_MODIFIED);

    gbc.gridy++;
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    buttonPanel.setOpaque(false);
    gbc.insets = new Insets(10, 10, 10, 10);
    add(buttonPanel, gbc);

    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.weightx = 0.0;
    gbc.gridwidth = 1;
    deleteIndex.setOpaque(false);
    gbc.insets.left = 0;
    buttonPanel.add(deleteIndex, gbc);
    deleteIndex.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ev) {
            deleteIndex();
          }
        });
    gbc.gridx = 2;
    gbc.weightx = 1.0;
    buttonPanel.add(Box.createHorizontalGlue(), gbc);
    gbc.weightx = 0.0;
    gbc.insets.left = 10;
    saveChanges.setOpaque(false);
    gbc.gridx = 3;
    buttonPanel.add(saveChanges, gbc);
    saveChanges.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ev) {
            saveIndex(false);
          }
        });

    entryLimit
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent ev) {
                checkSaveButton();
              }

              @Override
              public void changedUpdate(DocumentEvent ev) {
                checkSaveButton();
              }

              @Override
              public void removeUpdate(DocumentEvent ev) {
                checkSaveButton();
              }
            });

    ActionListener listener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ev) {
            checkSaveButton();
          }
        };
    for (JCheckBox cb : types) {
      cb.addActionListener(listener);
    }
  }
Example #4
0
  /**
   * Updates the contents of the panel with the provided index.
   *
   * @param index the index descriptor to be used to update the panel.
   */
  public void update(IndexDescriptor index) {
    ignoreCheckSave = true;
    setPrimaryValid(lEntryLimit);
    setPrimaryValid(lType);
    name.setText(index.getName());
    backendName.setText(index.getBackend().getBackendID());
    titlePanel.setDetails(LocalizableMessage.raw(index.getName()));
    entryLimit.setText(String.valueOf(index.getEntryLimit()));
    approximate.setSelected(false);
    equality.setSelected(false);
    ordering.setSelected(false);
    substring.setSelected(false);
    presence.setSelected(false);
    for (IndexTypeDescriptor type : index.getTypes()) {
      switch (type) {
        case APPROXIMATE:
          approximate.setSelected(true);
          break;
        case PRESENCE:
          presence.setSelected(true);
          break;
        case EQUALITY:
          equality.setSelected(true);
          break;
        case ORDERING:
          ordering.setSelected(true);
          break;
        case SUBSTRING:
          substring.setSelected(true);
          break;
      }
    }

    JComponent[] comps = {entryLimit, lType, typesPanel, lEntryLimit};

    for (JComponent comp : comps) {
      comp.setVisible(!index.isDatabaseIndex());
    }

    AttributeType attr = index.getAttributeType();
    repopulateTypesPanel(attr);

    if (index.isDatabaseIndex()) {
      entryLimit.setText("");
    }
    saveChanges.setVisible(!index.isDatabaseIndex());
    deleteIndex.setVisible(!index.isDatabaseIndex());
    if (index.isDatabaseIndex()) {
      Utilities.setWarningLabel(warning, NON_CONFIGURABLE_INDEX);
      warning.setVisible(true);
    } else if (getInfo() != null) {
      if (getInfo().mustReindex(index)) {
        Utilities.setWarningLabel(warning, INDEX_MODIFIED);
        warning.setVisible(true);
        warning.setVerticalTextPosition(SwingConstants.TOP);
      } else {
        warning.setVisible(false);
      }
    }
    this.index = index;

    ignoreCheckSave = false;
    checkSaveButton();

    scrollListener.updateBorder();
  }
  /** Creates the layout of the panel (but the contents are not populated here). */
  private void createLayout() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridy = 0;

    gbc.gridwidth = 2;
    gbc.gridx = 0;
    add(Utilities.createPrimaryLabel(INFO_CTRL_PANEL_OPERATION_VIEW_LABEL.get()), gbc);
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.insets.top = 10;

    JPanel checkBoxPanel = new JPanel(new GridBagLayout());
    checkBoxPanel.setOpaque(false);
    JScrollPane scroll = Utilities.createBorderLessScrollBar(checkBoxPanel);
    ScrollPaneBorderListener.createFullBorderListener(scroll);

    checkboxes = new JCheckBox[monitoringAttributes.size()];

    int i = 0;
    for (T attribute : monitoringAttributes) {
      LocalizableMessage m = getMessage(attribute);
      checkboxes[i] = Utilities.createCheckBox(m);
      i++;
    }
    selectAll = Utilities.createButton(INFO_CTRL_PANEL_SELECT_ALL_BUTTON.get());
    selectAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            for (JCheckBox cb : checkboxes) {
              cb.setSelected(true);
            }
          }
        });

    selectNone = Utilities.createButton(INFO_CTRL_PANEL_CLEAR_SELECTION_BUTTON.get());
    selectNone.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            for (JCheckBox cb : checkboxes) {
              cb.setSelected(false);
            }
          }
        });

    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridheight = 3;
    gbc.fill = GridBagConstraints.BOTH;
    add(scroll, gbc);

    gbc.gridx = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.insets.left = 10;
    gbc.gridheight = 1;
    add(selectAll, gbc);
    gbc.gridy++;
    gbc.insets.top = 10;
    add(selectNone, gbc);
    gbc.gridy++;
    gbc.weighty = 1.0;
    add(Box.createVerticalGlue(), gbc);

    gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    int preferredViewHeight = -1;
    for (JCheckBox cb : checkboxes) {
      gbc.gridx = 0;
      gbc.weightx = 0.0;
      gbc.anchor = GridBagConstraints.WEST;
      gbc.fill = GridBagConstraints.NONE;
      checkBoxPanel.add(cb, gbc);
      gbc.gridx = 1;
      gbc.weightx = 1.0;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      checkBoxPanel.add(Box.createHorizontalGlue(), gbc);
      gbc.insets.top = 10;
      gbc.gridy++;
      if (gbc.gridy == 15) {
        preferredViewHeight = checkBoxPanel.getPreferredSize().height;
      }
    }
    if (preferredViewHeight < 0) {
      preferredViewHeight = checkBoxPanel.getPreferredSize().height;
    }
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.gridx = 0;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.weighty = 1.0;
    checkBoxPanel.add(Box.createVerticalGlue(), gbc);
    scroll
        .getViewport()
        .setPreferredSize(
            new Dimension(checkBoxPanel.getPreferredSize().width + 15, preferredViewHeight));
  }