📄 permisrolehierarchypolicy.java
字号:
setSize(530, 679);
roleHierarchyInternalFrame.setBounds(255, 50, 530, 570);
add(roleHierarchyInternalFrame);
setBackground(new Color(153, 153, 204));
setLocation(150, 45);
roleTextField.requestFocus();
return roleHierarchyInternalFrame;
}
public void performRefresh()
{
subRoleListModel.clear();
roleViewListModel.clear();
roleListModel.clear();
loader.readRolesPolicy(roleListModel,
avRoleListModel,
roleComboBox,
roleViewComboBox,
ROLE_SPEC);
roleHierarchyExistingRolesScrollPane.setViewportView(roleValueList);
roleHierarchyAvailableRolesScrollPane.setViewportView(
availableRoleList);
rolePolicyViewScrollPane.setViewportView(roleViewList);
}
private void roleEditButtonButtonActionPerformed()
{
performRefresh();
roleHierarchyTabbedPane.setSelectedIndex(1);
promtePressed = true;
}
private void createCancelButtonActionPerformed()
{
if(promtePressed){
performRefresh();
hierarchyDeleteButton.setEnabled(true);
promtePressed = true;
return ;
}
else{
if (!roleListModel.isEmpty()){
String answer = PermisPolicyEditorMenu.dialog.confirmDialog(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_warn_msg_a") + "\n" +
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_warn_msg_b"), "Warning");
if (answer.equals("No")){
return;
}
else{
roleListModel.clear();
hierarchyDeleteButton.setEnabled(false);
}
}
}
}
private void createOkButtonActionPerformed()
{
deleteItemsFromDom();
if (!roleListModel.isEmpty()){
for (int i=0; i < roleListModel.size(); i++){
//get object at the index
String stringRole = roleListModel.getElementAt(i).toString();
//check if role already exists
if (!loader.isRole(ROLE_SPEC, stringRole)){
//add the object to DOM
PermisPolicyEditorMenu.permisXmlDom.addDomAttr( ROLE_SPEC,
SUP_ROLE,
VALUE,
stringRole);
}
}
if(parent.getPermisParent().getMenuItems().
getReadablePolicy() != null){
parent.getPermisParent().getMenuItems().getReadablePolicy().
comboBoxSetSelectedIndex(4);
}
PermisPolicyEditorMenu.permisXmlDom.showMessage();
roleListModel.clear();
String button = "roleAssignmentButton";
parent.controlButton(button, true);
performRefresh();
roleListModel.clear();
roleHierarchyInternalFrame.setVisible(false);
deletedHastable.clear();
}
//change state for the cancel button
promtePressed = true;
}
/**
* Closes the Role Hierarchy Policy window.
*
* @param evt roleViewComboBox's item selected .
*/
private void roleViewComboBoxActionPerformed()
{
if(roleViewComboBox.getItemCount() != 0){
if (roleViewComboBox.getSelectedIndex() != -1){
String roleString = roleViewComboBox.getSelectedItem().toString();
String start = ResourceBundle.getBundle(
"issrg/editor/gui/Editor_GUI_i18n").getString("sub_pol_readable")
+ " " + getString(roleString) + " ";
String output = loader.populateRolePolicy(roleString);
if(output != null){
roleViewListModel.clear();
roleViewListModel.addElement(output);
rolePolicyViewScrollPane.setViewportView(roleViewList);
roleViewList.setCellRenderer(
new PermisPolicyTextListCellRenderer());
}
}
}
}
private void closeButtonActionPerformed()
{
roleHierarchyInternalFrame.setVisible(false);
}
private void roleDeleteButtonActionPerformed()
{
String roleId = roleIDTextField.getText().trim();
if(roleViewComboBox.getItemCount() != 0){
if (roleViewComboBox.getSelectedIndex() != -1){
String roleString = roleViewComboBox.getSelectedItem().toString();
PermisPolicyEditorMenu.permisXmlDom.deleteRole(roleId, roleString);
performRefresh();
rolePolicyViewScrollPane.setViewportView(roleViewList);
}
}
}
public void viewCloseButtonActionPerformed()
{
roleHierarchyInternalFrame.setVisible(false);
}
/**
* Closes the Role Hierarchy Policy window.
*
* @param evt Close button operated.
*/
private void promoteCloseButtonActionPerformed()
{
roleHierarchyInternalFrame.setVisible(false);
}
/**
* Clears the data entered by the user from all data entry points.
*
* @param evt Cancel button operated.
*/
private void promteCancelButtonActionPerformed()
{
// This action clears the boxes in the Hierarchy Policy
if(promtePressed && !deleteSubRolHastable.isEmpty()){
performRefresh();
return;
}
else if(roleSubAdd && promtePressed){
performRefresh();
return;
}
else {
//else{
if(!subRoleListModel.isEmpty()){
String answer = PermisPolicyEditorMenu.dialog.confirmDialog(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_warn_msg_a") + "\n" +
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_warn_msg_b"), "Warning");
if (answer.equals("No")){
return;
}
else{
subRoleListModel.clear();
}
}
}
}
/**
* Collects the data entered by the use and writes it to the Document
* Object Model (DOM), the PERMIS Policy, in memory. Informs the user of the
* outcome of the operation.
*
* @param evt OK button operated.
*/
private void promteOkButtonActionPerformed()
{
deleteSubRolesFromSupRole();
/* check the combobox, if empty return else create data in
the Dom memory */
if(roleComboBox.getItemCount() < 1){
PermisPolicyEditorMenu.dialog.showOkDialog(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("rol_hie_err_msg_a"));
return;
}
String selectedItem = roleComboBox.getSelectedItem().toString();
PermisPolicyEditorMenu.permisXmlDom.addDomFromList( subRoleListModel,
selectedItem,
SUP_ROLE,
SUB_ROLE);
//refresh the ReadablePolicy view
if(parent.getPermisParent().getMenuItems().
getReadablePolicy() != null){
parent.getPermisParent().getMenuItems().getReadablePolicy().
comboBoxSetSelectedIndex(4);
}
PermisPolicyEditorMenu.permisXmlDom.showMessage();
String button = "roleAssignmentButton";
parent.controlButton(button, true);
subRoleListModel.clear();
performRefresh();
roleHierarchyInternalFrame.setVisible(false);
deleteSubRolHastable.clear();
//change state for the cancel button
promtePressed = true;
}
/**
* Removes the selected role from the subordinate role window.
*
* @param evt SubRemove button operated.
*/
private void roleSubRemoveButtonActionPerformed()
{
RemoveFromList deleteItem = new RemoveFromList();
if(!subRoleListModel.isEmpty()){
String deleted = subRoleList.getSelectedValue().toString();
deleteItem.removeFromList( subRoleListModel,
subRoleList);
roleSubRemoveButton.setEnabled(subRoleListModel.getSize()!=0);
deleteSubRolHastable.put(deleted, deleted);
// now update the DOM
//System.out.println("Removing "+deleted+" from Selected Sup Role: "+selectedSupRole);//**********
if (selectedSupRole!=null){
NodeList subRoles = selectedSupRole.getElementsByTagName("SubRole");
//System.out.println("* found "+subRoles.getLength()+" SubRole nodes"); //**********
for (int i=0; i<subRoles.getLength(); i++){
if (subRoles.item(i).getNodeType()!=Node.ELEMENT_NODE) continue;
Element r = (Element)subRoles.item(i);
String s = r.getAttribute("Value");
//System.out.println("* found SubRole with Value "+s); //**********
// s should not be null, but we'll be lenient about this
if (s!=null && s.equals(deleted)){ // remove the selected role
//System.out.println("* this is the one, removing "+s); //**********
selectedSupRole.removeChild(r);
break;
}
}
}
}
}
/**
* Adds the selected role to the subordinate role window.
*
* @param evt SubAdd button operated.
*/
private void roleSubAddButtonActionPerformed()
{
PermisDataBox dataListener = new PermisDataBox();
/* Checks that selected item in Superior Role is not includeed in
Subordinate Role */
Object obj = roleComboBox.getSelectedItem();
dataListener.addFromListToList( roleListModel,
subRoleListModel,
availableRoleList,
subRoleList,
obj);
roleSubAdd = true;
String subRoleString = availableRoleList.getSelectedValue().toString();
// ...and now create another SubRole
//System.out.println("Adding "+subRoleString+" to Selected Sup Role: "+selectedSupRole);//**********
if (selectedSupRole != null){ // of course, only if a sup role is selected
Document doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
Element subRole = doc.createElement("SubRole");
subRole.setAttribute("Value", subRoleString);
selectedSupRole.appendChild(subRole);
}
}
/**
* Deletes the selected role from the Document Object Model in memory and
* refreshes the associated list, listmodel and combobox
*
* @param evt Hierarchy delete button operated.
*/
private void hierarchyDeleteButtonActionPerformed()
{
RemoveFromList deleteItem = new RemoveFromList();
int index = roleValueList.getSelectedIndex();
if(index == -1){
return;
}
String selection = roleListModel.getElementAt(index).toString();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -