CustomAttributePanel.java revision 776a73e6a9d48721747ed06cf70746b661d3b03a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/** The panel that displays a custom attribute definition. */
class CustomAttributePanel extends SchemaElementPanel
{
private static final long serialVersionUID = 2850763193735843746L;
private JButton saveChanges;
private AttributeType attribute;
private ScrollPaneBorderListener scrollListener;
private final TitlePanel titlePanel = new TitlePanel(LocalizableMessage.EMPTY, LocalizableMessage.EMPTY);
private final JLabel lDescription = createPrimaryLabel(INFO_CTRL_PANEL_ATTRIBUTE_DESCRIPTION_LABEL.get());
private final JLabel lEquality = createPrimaryLabel(INFO_CTRL_PANEL_ATTRIBUTE_EQUALITY_MATCHING_RULE_LABEL.get());
private final JLabel lOrdering = createPrimaryLabel(INFO_CTRL_PANEL_ATTRIBUTE_ORDERING_MATCHING_RULE_LABEL.get());
private final JLabel lSubstring = createPrimaryLabel(INFO_CTRL_PANEL_ATTRIBUTE_SUBSTRING_MATCHING_RULE_LABEL.get());
};
private final JCheckBox nonModifiable = createCheckBox(INFO_CTRL_PANEL_ATTRIBUTE_NON_MODIFIABLE_LABEL.get());
private final JCheckBox singleValued = createCheckBox(INFO_CTRL_PANEL_ATTRIBUTE_SINGLE_VALUED_LABEL.get());
private final JCheckBox collective = createCheckBox(INFO_CTRL_PANEL_ATTRIBUTE_COLLECTIVE_LABEL.get());
private final LocalizableMessage NO_MATCHING_RULE =
private boolean ignoreChangeEvents;
/** Default constructor of the panel. */
public CustomAttributePanel()
{
createLayout();
}
/** {@inheritDoc} */
public LocalizableMessage getTitle()
{
return INFO_CTRL_PANEL_CUSTOM_ATTRIBUTE_TITLE.get();
}
/**
* Creates the layout of the panel (but the contents are not populated here).
*/
private void createLayout()
{
p.setOpaque(false);
createBasicLayout(p, gbc);
gbc = new GridBagConstraints();
{
/** {@inheritDoc} */
{
}
});
saveChanges.setOpaque(false);
{
/** {@inheritDoc} */
{
saveChanges();
}
});
}
/**
* Creates the basic layout of the panel.
* @param c the container where all the components will be laid out.
* @param gbc the grid bag constraints.
*/
{
addErrorPane(c, gbc);
};
{
new Object[]{defaultValues[i]});
}
{
}
syntax};
new BasicExpander(
};
}
};
{
p.setOpaque(false);
{
/** {@inheritDoc} */
public void stateChanged(ChangeEvent e)
{
}
};
expander.setSelected(false);
}
{
/** {@inheritDoc} */
{
{
}
}
};
};
{
if (i == 0)
{
}
else
{
}
if (i == 0)
{
}
else
{
}
{
/** {@inheritDoc} */
{
{
}
}
};
{
/** {@inheritDoc} */
{
{
}
}
};
}
{
/** {@inheritDoc} */
{
}
/** {@inheritDoc} */
{
}
/** {@inheritDoc} */
{
}
};
{
}
{
{
}
};
{
}
obsolete};
{
}
}
/** {@inheritDoc} */
public boolean mustCheckUnsavedChanges()
{
return saveChanges.isEnabled();
}
/** {@inheritDoc} */
{
attribute.getNameOrOID()));
Utilities.getParentDialog(this));
unsavedChangesDlg.setVisible(true);
{
}
return result;
}
/** {@inheritDoc} */
public boolean requiresScroll()
{
return false;
}
{
ignoreChangeEvents = true;
if (n == null)
{
n = "";
}
n = attr.getDescription();
if (n == null)
{
n = "";
}
description.setText(n);
lastAliases.clear();
{
sOrigin = "";
}
{
sFile = "";
}
};
{
}
{
{
}
}
{
}
{
{
}
}
{
}
{
}
saveChanges.setEnabled(false);
ignoreChangeEvents = false;
}
/** {@inheritDoc} */
{
if (hasSchemaChanged(s))
{
schema = s;
{
{
}
}
{
}
{
}
{
}
}
{
}
{
isLocal() ?
}
{
/** {@inheritDoc} */
public void run()
{
}
});
}
private boolean hasSchemaChanged(Schema s)
{
{
}
}
/** {@inheritDoc} */
public Component getPreferredFocusComponent()
{
return name;
}
/** {@inheritDoc} */
public void okClicked()
{
}
private void deleteAttribute()
{
Utilities.getParentDialog(this),
{
}
{
{
{
}
}
{
{
}
{
}
}
}
else
{
}
{
if (!childAttributes.isEmpty())
{
}
if (!dependentClasses.isEmpty())
{
}
{
null,
dlg);
dlg.setVisible(true);
}
}
else
{
}
}
private boolean saveChanges()
{
// Check if the aliases or the name have changed
{
}
String n = getAttributeName();
if (n.length() == 0)
{
}
{
{
err = new LocalizableMessageBuilder();
}
else
{
if (elementType != null)
{
}
}
}
{
{
err = new LocalizableMessageBuilder();
}
else
{
if (elementType != null)
{
}
}
}
{
{
{
}
{
if (elementType != null)
{
}
}
}
}
{
{
}
else
{
// Check whether this object class is defined as parent as the superior.
{
{
getSuperior().getNameOrOID()));
break;
}
}
}
}
if (nonModifiable.isSelected()
{
}
{
Utilities.getParentDialog(this),
{
}
{
}
{
null,
dlg);
dlg.setVisible(true);
}
}
{
}
}
{
{
{
return false;
}
}
return true;
}
private void checkEnableSaveChanges()
{
if (!ignoreChangeEvents)
{
}
}
private boolean hasChanged()
{
{
try
{
}
catch (Throwable t)
{
return true;
}
}
return false;
}
private String getAttributeName()
{
}
{
if (o.length() == 0)
{
return getAttributeName() + "-oid";
}
return o;
}
{
if (s.length() > 0)
{
{
}
}
return al;
}
{
return al;
}
private AttributeType getSuperior()
{
{
return null;
}
else
{
return (AttributeType)o;
}
}
{
{
}
return null;
}
{
if (f.length() > 0)
{
}
{
}
return map;
}
private String getDescription()
{
}
private AttributeType getNewAttribute()
{
getAllNames(),
getOID(),
getSuperior(),
}
private void updateDefaultMatchingRuleNames()
{
{
{
{
}
{
}
else
{
}
}
}
}
}