mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
04.57.2016 3082bffd895391a94bd1600af3e5a954a9c30262
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
@@ -138,7 +138,6 @@
  private boolean ignoreChangeEvents;
  /** Default constructor of the panel. */
  public CustomObjectClassPanel()
  {
@@ -203,7 +202,7 @@
      public void actionPerformed(ActionEvent ev)
      {
        ArrayList<LocalizableMessage> errors = new ArrayList<>();
        saveChanges(false, errors);
        saveChanges(errors);
      }
    });
  }
@@ -451,12 +450,9 @@
    titlePanel.setDetails(LocalizableMessage.raw(n));
    name.setText(n);
    SortableListModel<AttributeType> modelRequired =
      attributes.getSelectedListModel1();
    SortableListModel<AttributeType> modelAvailable =
      attributes.getSelectedListModel2();
    SortableListModel<AttributeType> availableModel =
      attributes.getAvailableListModel();
    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();
@@ -535,31 +531,14 @@
  {
    final ServerDescriptor desc = ev.getNewDescriptor();
    Schema s = desc.getSchema();
    final boolean schemaChanged;
    if (schema != null && s != null)
    {
      schemaChanged = !ServerDescriptor.areSchemasEqual(s, schema);
    }
    else if (schema == null && s != null)
    {
      schemaChanged = true;
    }
    else if (s == null && schema != null)
    {
      schemaChanged = false;
    }
    else
    {
      schemaChanged = false;
    }
    final boolean schemaChanged = schemaChanged(s);
    if (schemaChanged)
    {
      schema = s;
      updateErrorPaneIfAuthRequired(desc,
          isLocal() ?
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_OBJECTCLASS_EDIT.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
      updateErrorPaneIfAuthRequired(desc, isLocal()
          ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_OBJECTCLASS_EDIT.get()
          : INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    }
    else if (schema == null)
    {
@@ -574,14 +553,10 @@
      @Override
      public void run()
      {
        delete.setEnabled(!authenticationRequired(desc)
            && !authenticationRequired(desc)
            && schema != null);
        final boolean enabled = !authenticationRequired(desc) && schema != null;
        delete.setEnabled(enabled);
        checkEnableSaveChanges();
        saveChanges.setEnabled(saveChanges.isEnabled() &&
            !authenticationRequired(desc)
            && !authenticationRequired(desc)
            && schema != null);
        saveChanges.setEnabled(enabled && saveChanges.isEnabled());
        if (schemaChanged && schema != null)
        {
          superiors.setSchema(schema);
@@ -591,6 +566,15 @@
    });
  }
  private boolean schemaChanged(Schema s)
  {
    if (s != null)
    {
      return schema == null || !ServerDescriptor.areSchemasEqual(s, schema);
    }
    return false;
  }
  @Override
  public boolean mustCheckUnsavedChanges()
  {
@@ -612,8 +596,8 @@
    result = unsavedChangesDlg.getResult();
    if (result == UnsavedChangesDialog.Result.SAVE)
    {
      ArrayList<LocalizableMessage> errors = new ArrayList<>();
      saveChanges(true, errors);
      List<LocalizableMessage> errors = new ArrayList<>();
      saveChanges(errors);
      if (!errors.isEmpty())
      {
        result = UnsavedChangesDialog.Result.CANCEL;
@@ -706,7 +690,7 @@
    }
  }
  private void saveChanges(boolean modal, ArrayList<LocalizableMessage> errors)
  private void saveChanges(List<LocalizableMessage> errors)
  {
    for (JLabel label : labels)
    {
@@ -771,15 +755,7 @@
        }
        else
        {
          boolean notPreviouslyDefined = true;
          for (String oldAlias : oldAliases)
          {
            if (oldAlias.equalsIgnoreCase(alias))
            {
              notPreviouslyDefined = false;
              break;
            }
          }
          boolean notPreviouslyDefined = !containsIgnoreCase(oldAliases, alias);
          if (notPreviouslyDefined)
          {
            LocalizableMessage elementType =
@@ -794,7 +770,6 @@
      }
    }
   //validate the superiority.
    for(ObjectClass superior : getObjectClassSuperiors())
    {
@@ -841,9 +816,19 @@
    }
  }
  private boolean containsIgnoreCase(Collection<String> col, String toFind)
  {
    for (String s : col)
    {
      if (s.equalsIgnoreCase(toFind))
      {
        return true;
      }
    }
    return false;
  }
  private void validateSuperiority(ObjectClass superior,
          ArrayList<LocalizableMessage> errors)
  private void validateSuperiority(ObjectClass superior, List<LocalizableMessage> errors)
  {
    if(superior.getNameOrOID().equalsIgnoreCase(objectClass.getNameOrOID()))
    {
@@ -1008,7 +993,6 @@
    Collection<AttributeType> allAttrs = schema.getAttributeTypes();
    attributes.getAvailableListModel().addAll(allAttrs);
    HashSet<AttributeType> toDelete = new HashSet<>();
    for (AttributeType attr : attributes.getSelectedListModel1().getData())
    {
@@ -1122,7 +1106,6 @@
        attributes.getSelectedListModel2().getSize() - 1);
  }
  /**
   * A renderer for the attribute lists.  The renderer basically marks the
   * inherited attributes with an asterisk.