Search in sources :

Example 1 with PermissionAccess

use of com.mucommander.commons.file.PermissionAccess in project mucommander by mucommander.

the class ChangePermissionsDialog method updatePermCheckBoxes.

/**
 * Updates the permission checkboxes' values to reflect the octal permissions text field.
 */
private void updatePermCheckBoxes() {
    JCheckBox permCheckBox;
    String octalStr = octalPermTextField.getText();
    int perms = octalStr.equals("") ? 0 : Integer.parseInt(octalStr, 8);
    for (PermissionAccess a : PermissionAccess.reverseValues()) {
        for (PermissionType p : PermissionType.reverseValues()) {
            permCheckBox = permCheckBoxes[a.toInt()][p.toInt()];
            // if(permCheckBox.isEnabled())
            permCheckBox.setSelected((perms & (p.toInt() << a.toInt() * 3)) != 0);
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) PermissionType(com.mucommander.commons.file.PermissionType) PermissionAccess(com.mucommander.commons.file.PermissionAccess)

Example 2 with PermissionAccess

use of com.mucommander.commons.file.PermissionAccess in project mucommander by mucommander.

the class ChangePermissionsDialog method getPermInt.

/**
 * Creates and returns a permissions int using the values of the permission checkboxes.
 */
private int getPermInt() {
    JCheckBox permCheckBox;
    int perms = 0;
    for (PermissionAccess a : PermissionAccess.reverseValues()) {
        for (PermissionType p : PermissionType.reverseValues()) {
            permCheckBox = permCheckBoxes[a.toInt()][p.toInt()];
            if (permCheckBox.isSelected())
                perms |= (p.toInt() << a.toInt() * 3);
        }
    }
    return perms;
}
Also used : JCheckBox(javax.swing.JCheckBox) PermissionType(com.mucommander.commons.file.PermissionType) PermissionAccess(com.mucommander.commons.file.PermissionAccess)

Aggregations

PermissionAccess (com.mucommander.commons.file.PermissionAccess)2 PermissionType (com.mucommander.commons.file.PermissionType)2 JCheckBox (javax.swing.JCheckBox)2