📄 permisactionpolicy.java
字号:
}
/**************************************************************************\
* actionAddButtonActionPerformed *
\**************************************************************************/
/**
* Adds the selected item to the Action list.
*
* @param evt Add button operated.
*/
private void actionAddButtonActionPerformed(ActionEvent evt)
{
PermisDataBox datalistener = new PermisDataBox();
boolean deleteText = true;
if (listBoxContains(actionTextField.getText().trim()
,actionPolicyListModel )){
PermisPolicyEditorMenu.dialog.showOkDialog(
getString(actionTextField.getText())+ " " +
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("rol_hie_err_msg_exist"));
actionTextField.requestFocus();
return;
}
datalistener.addToComboBoxList( actionRemoveButton,
actionTextField,
actionPolicyListModel,
actionPolicyList,
null ,
deleteText);
}
/**************************************************************************\
* actionCloseButton1ActionPerformed *
\**************************************************************************/
/**
* Closes the Action Policy window.
*
* @param evt Close button operated.
*/
private void actionCloseButton1ActionPerformed(ActionEvent evt)
{
actionPolicyInternalFrame.setVisible(false);
}
/**************************************************************************\
* actionCancelButtonActionPerformed *
\**************************************************************************/
/**
* Clears the data entered by the user from all data entry points
*
* @param evt Cancel button operated.
*/
private void actionCancelButtonActionPerformed(ActionEvent evt)
{
if(editPressed){
editActionButtonActionPerformed(evt);
}
else{
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{
clearBoxes();
}
}
}
/**************************************************************************\
* actionOkButtonActionPerformed *
\**************************************************************************/
/**
* 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 actionOkButtonActionPerformed(ActionEvent evt)
{
if(!actionPolicyListModel.isEmpty()){
deleteItemsFromDom();
PermisPolicyEditorMenu.permisXmlDom.addFromListToDom(
actionPolicyListModel,
"ActionPolicy",
"Action",
"Name");
PermisPolicyEditorMenu.permisXmlDom.showMessage();
String button = "targetAccessButton";
parent.controlButton(button, true);
if(parent.getPermisParent().getMenuItems().
getReadablePolicy() != null){
parent.getPermisParent().getMenuItems().getReadablePolicy().
comboBoxSetSelectedIndex(8);
}
performRefresh();
clearBoxes();
actionPolicyInternalFrame.setVisible(false);
//clear the Hashtable
itemsDeletedTable.clear();
}
}
/**************************************************************************\
* actionViewCloseButtonActionPerformed *
\**************************************************************************/
/**
* Closes the Action Policy window.
*
* @param evt Close button operated.
*/
private void actionViewCloseButtonActionPerformed(ActionEvent evt)
{
actionPolicyInternalFrame.setVisible(false);
}
/**************************************************************************\
* deleteActionButtonActionPerformed *
\**************************************************************************/
/**
* Deletes the selected item from the Action list.
*
* @param evt Delete button operated.
*/
private void deleteActionButtonActionPerformed(ActionEvent evt)
{
removeItem(actionViewList, deleteActionButton);
}
/**************************************************************************\
* actionParameterAddButtonActionPerformed *
\**************************************************************************/
/**
* Adds the action entered by the user to the list of Actions
*
* @param evt Add button operated.
*/
private void actionParameterAddButtonActionPerformed(ActionEvent evt)
{
PermisDataBox datalistener = new PermisDataBox();
boolean deleteText = false;
datalistener.addToList( actionParameterRemoveButton,
actionParameterTextField,
actionParameterListModel,
actionParameterList,
deleteText);
}
/**************************************************************************\
* editActionButtonActionPerformed *
\**************************************************************************/
/**
* To be implemented
*
* @param evt Edit button operated.
*/
private void editActionButtonActionPerformed(ActionEvent evt)
{
String actionListArray[] = PermisPolicyEditorMenu.permisXmlDom.
getActionNames();
actionPolicyListModel.clear();
for (int i = 0; i < actionListArray.length; i++) {
actionPolicyListModel.addElement(actionListArray[i]);
}
actionAddScrollPane.setViewportView(actionPolicyList);
actionTabbedPane.setSelectedIndex(1);
editPressed = true;
}
public void addExistingActions()
{
String actionListArray[] = PermisPolicyEditorMenu.permisXmlDom.
getActionNames();
actionPolicyListModel.clear();
if(actionListArray.length != -1){
for (int i = 0; i < actionListArray.length; i++) {
actionPolicyListModel.addElement(actionListArray[i]);
}
actionAddScrollPane.setViewportView(actionPolicyList);
actionTabbedPane.setSelectedIndex(1);
editPressed = true;
}
}
/**************************************************************************\
* actionParameterRemoveButtonActionPerformed *
\**************************************************************************/
/**
* Removes the selected parameter from the paramter list
*
* @param evt Parameter remove button operated.
*/
private void actionParameterRemoveButtonActionPerformed(ActionEvent evt)
{
// targetActionComboBox is null which is not curently in use.
RemoveFromList deleteItem = new RemoveFromList();
Object item = deleteItem.removeItemComboBox(
actionParameterRemoveButton,
actionParameterListModel,
actionParameterList,
null);
}
/**************************************************************************\
* refreshComboBox *
\**************************************************************************/
/**
* Refreshes the JComboBox every time data is added to or deleted from
* the DOM.
*/
public void performRefresh()
{
String actionListArray[] = PermisPolicyEditorMenu.permisXmlDom.
getActionNames();
actionViewListModel.clear();
for (int i = 0; i < actionListArray.length; i++) {
actionViewListModel.addElement(actionListArray[i]);
}
actionAvailableScrollPane.setViewportView(actionViewList);
}
private void removeItem(JList list, JButton deleteActionbutton)
{
Object itemSelected = null;
ListSelectionModel lsm = list.getSelectionModel();
DefaultListModel listModel = (DefaultListModel) list.getModel();
lsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
try{
// Check that box is not empty
if ((listModel.isEmpty()) != true){
int index = list.getSelectedIndex();
if (lsm.isSelectionEmpty()) {
Toolkit.getDefaultToolkit().beep();
return;
}
int firstSelected = lsm.getMinSelectionIndex();
int lastSelected = lsm.getMaxSelectionIndex();
itemSelected = listModel.getElementAt(firstSelected);
listModel.removeElementAt(index);
// Remove item from combobox
int size = listModel.size();
if (size == 0) {
// List is empty: disable delete button.
deleteActionButton.setEnabled(false);
}
else {
// Adjust the selection.
if (firstSelected == listModel.getSize()) {
// Removed item in last position.
firstSelected--;
}
deleteActionButton.setEnabled(true);
list.setSelectedIndex(firstSelected);
}
}
// Catch and send a ,essage when user has not selected an item
}catch (ArrayIndexOutOfBoundsException e){
}
//add deleted item to table
itemsDeletedTable.put(itemSelected.toString().trim(),
itemSelected.toString().trim());
}
private void clearBoxes()
{
actionPolicyListModel.clear();
actionParameterListModel.clear();
}
private void deleteItemsFromDom()
{
if (!itemsDeletedTable.isEmpty()){
Enumeration deleted = this.itemsDeletedTable.elements();
while (deleted.hasMoreElements()){
String s = deleted.nextElement().toString();
PermisPolicyEditorMenu.permisXmlDom.deleteNode("Action", s);
}
}
}
private boolean listBoxContains( String compare,
DefaultListModel compareList)
{
if(!compareList.isEmpty()){
for (int i = 0; i < compareList.size(); i++){
if (compareList.elementAt(i).equals(compare.trim())){
return true;
}
}
}
return false;
}
/**************************************************************************\
* getString *
\**************************************************************************/
/**
* adds square brackets to a string and return the new string
*
*
*/
private String getString(String string)
{
return "[" + string + "]";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -