📄 pwizardpanel7c.java
字号:
ldapDirectly.setText("");
LDAP_Component.setEnabled(false);
}
else if (ev.getSource() == LDAPComponent_Option)
{
urlTextField.setEnabled(false);
urlTextField.setText("");
ldapDirectly.setEnabled(true);
ldapDirectly.grabFocus();
LDAP_Component.setEnabled(true);
}
}
/**
* Sets the text the component will show. If component parameter is not found
* in the list of parameters, the method will call its super method to attempt
* to find the component there.
*
* @param internalName The internal name used in the program.
* @param internationalName The international name to set the text to.
*/
public void setCaption(String internalName, String internationalName)
{
if (internalName.equals("URL_CHECKBOX"))
{
urlTextField_Option.setText(internationalName);
}
else if (internalName.equals("LDAP_CHECKBOX"))
{
LDAPComponent_Option.setText(internationalName);
}
else if (internalName.equals("RESOURCE_LABEL"))
{
resourcesLabel.setText(internationalName);
}
else if (internalName.equals("RESOURCE_BUTTON"))
{
resourcesButton.setText(internationalName);
}
else if (internalName.equals("RESOURCE_PANEL"))
{
resourcesAddOn.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), internationalName));
}
super.setCaption(internalName, internationalName);
}
/**
* Adds a resource type from the resource type textfield.
* The Resource Type text field, must not be empty, and the selected
* node must be right.
*/
public void addResource()
{
if (((Element)domainTree.getSelectionPath().getLastPathComponent()).getParentNode() == getRoot())
{
Element child = xmlED.DOM.createElement(DomainPolicyEditorObjectClass);
if (resTextField.getText() != null && !resTextField.getText().equals(""))
{
String attribute = resTextField.getText();
child.setAttribute(targetDomainPolicyName, attribute);
if (!isInSubTree(child, targetDomainPolicyName))
xmlED.addItem(child, (Element)domainTree.getSelectionPath().getLastPathComponent());
else JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError4, errorHeader, JOptionPane.ERROR_MESSAGE);
}
}
}
public void includeEditItem()
{
if (((Element)domainTree.getSelectionPath().getLastPathComponent()).getParentNode() != getRoot())
{
return;
}
if (LDAPComponent_Option.isSelected())
{
if (ldapDirectly.getText().equals(""))
{
JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError1, errorHeader, JOptionPane.ERROR_MESSAGE);
return;
}
Element child = xmlED.DOM.createElement(DomainPolicyEditorInclude);
String attribute = ldapDirectly.getText();
child.setAttribute(DomainPolicyEditorLDAPDN, attribute);
if (isInSubTree(child, DomainPolicyEditorLDAPDN))
{
JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError5, errorHeader, JOptionPane.ERROR_MESSAGE);
return;
}
NodeList nlist = getChildElements(((Element)domainTree.getSelectionPath().getLastPathComponent()));
int resourcesIndex = -1;
for (int i = 0; i < nlist.getLength(); i++)
{
if (((Element)nlist.item(i)).getTagName().equals("ObjectClass"))
{
resourcesIndex = 0;
}
}
if (resourcesIndex == -1) xmlED.addItem(child, (Element)domainTree.getSelectionPath().getLastPathComponent());
else xmlED.addItem(child, (Element)domainTree.getSelectionPath().getLastPathComponent(), resourcesIndex);
}
if (urlTextField_Option.isSelected())
{
if (urlTextField == null || urlTextField.getText().equals(""))
{
JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError2, errorHeader, JOptionPane.ERROR_MESSAGE);
return;
}
Element child = xmlED.DOM.createElement(DomainPolicyEditorInclude);
String attribute = urlTextField.getText();
child.setAttribute(DomainPolicyEditorURL, attribute);
xmlED.addItem(child, (Element)domainTree.getSelectionPath().getLastPathComponent());
}
}
public void excludeEditItem()
{
if (((Element)getCurrentTreeSelection().getParentNode()).getParentNode() != getRoot())
{
return;
}
if (LDAPComponent_Option.isSelected())
{
if (ldapDirectly.getText().equals(""))
{
JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError1, errorHeader, JOptionPane.ERROR_MESSAGE);
return;
}
if (!isChildOfLDAPElement(getCurrentTreeSelection().getAttribute(DomainPolicyEditorLDAPDN), ldapDirectly.getText())) return;
Element child = xmlED.DOM.createElement(DomainPolicyEditorExclude);
String attribute = ldapDirectly.getText();
child.setAttribute(DomainPolicyEditorLDAPDN, attribute);
if (isInSubTree(child, DomainPolicyEditorLDAPDN))
{
JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError5, errorHeader, JOptionPane.ERROR_MESSAGE);
return;
}
xmlED.addItem(child, getCurrentTreeSelection());
}
else if (urlTextField_Option.isSelected())
{
if (urlTextField == null || urlTextField.getText().equals(""))
{
JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError2, errorHeader, JOptionPane.ERROR_MESSAGE);
return;
}
Element child = xmlED.DOM.createElement(DomainPolicyEditorExclude);
String attribute = urlTextField.getText();
child.setAttribute(DomainPolicyEditorURL, attribute);
xmlED.addItem(child, getCurrentTreeSelection());
}
}
public void replaceEditItem()
{
if(((Element)getCurrentTreeSelection().getParentNode()).getParentNode() == getRoot() ||
((Element)((Element)getCurrentTreeSelection().getParentNode()).getParentNode()).getParentNode() == getRoot())
{
if(!ldapDirectly.getText().equals("") && LDAPComponent_Option.isEnabled())
{
if (!isChildOfLDAPElement(getCurrentTreeSelection().getAttribute(DomainPolicyEditorLDAPDN), ldapDirectly.getText())) return;
String attrib[] = { DomainPolicyEditorLDAPDN };
String value[] = { ldapDirectly.getText() };
xmlED.setAttributeValue((Element)domainTree.getLastSelectedPathComponent(), attrib, value);
}
if(!urlTextField.getText().equals("") && urlTextField_Option.isEnabled())
{
String attrib[] = { DomainPolicyEditorURL };
String value[] = { urlTextField.getText() };
xmlED.setAttributeValue((Element)domainTree.getLastSelectedPathComponent(), attrib, value);
}
}
}
public void addDomainItem()
{
if ((ldapDirectly.getText().equals("")) &&
(urlTextField.getText().equals("")))
{
JOptionPane.showMessageDialog(xmlED, targetDomainPolicyError3, errorHeader, JOptionPane.ERROR_MESSAGE);
return;
}
Element child = xmlED.DOM.createElement(domainSpecName);
defaultName = domainSpecName;
defaultName = defaultName + count;
child.setAttribute(DomainPolicyEditorID, defaultName);
count++;
if (urlTextField_Option.isSelected())
{
Element newChild = xmlED.DOM.createElement(DomainPolicyEditorInclude);
String attribute = urlTextField.getText();
newChild.setAttribute(DomainPolicyEditorURL, attribute);
((Node)child).appendChild(newChild);
}
else if (LDAPComponent_Option.isSelected())
{
Element newChild = xmlED.DOM.createElement(DomainPolicyEditorInclude);
String attribute = ldapDirectly.getText();
newChild.setAttribute(DomainPolicyEditorLDAPDN, attribute);
((Node)child).appendChild(newChild);
}
xmlED.addItem(child, (Element)getRoot());
domainTree.startEditingAtPath(domainTree.getSelectionPath());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -