public boolean getBitValue(PermissionAccess access, PermissionType type) { return (permissions & (type.toInt() << (access.toInt()*3))) != 0; } }
/** * 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); } } }
/** * 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; }
@Override public void changePermission(PermissionAccess access, PermissionType permission, boolean enabled) throws IOException, UnsupportedFileOperationException { changePermissions(ByteUtils.setBit(permissions.getIntValue(), (permission.toInt() << (access.toInt()*3)), enabled)); }
@Override public void changePermission(PermissionAccess access, PermissionType permission, boolean enabled) throws IOException, UnsupportedFileOperationException { changePermissions(ByteUtils.setBit(getPermissions().getIntValue(), (permission.toInt() << (access.toInt()*3)), enabled)); }
@Override public void changePermission(PermissionAccess access, PermissionType permission, boolean enabled) throws IOException { changePermissions(ByteUtils.setBit(getPermissions().getIntValue(), (permission.toInt() << (access.toInt()*3)), enabled)); }
@Override public void changePermission(PermissionAccess access, PermissionType permission, boolean enabled) throws IOException { changePermissions(ByteUtils.setBit(getPermissions().getIntValue(), (permission.toInt() << (access.toInt()*3)), enabled)); }
int bitShift = PermissionAccess.USER.toInt() *3;