本文整理匯總了Java中com.haulmont.cuba.gui.components.actions.ItemTrackingAction類的典型用法代碼示例。如果您正苦於以下問題:Java ItemTrackingAction類的具體用法?Java ItemTrackingAction怎麽用?Java ItemTrackingAction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ItemTrackingAction類屬於com.haulmont.cuba.gui.components.actions包,在下文中一共展示了ItemTrackingAction類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.haulmont.cuba.gui.components.actions.ItemTrackingAction; //導入依賴的package包/類
@Override
public void init(Map<String, Object> params) {
super.init(params);
filesTable.addAction(new ItemTrackingAction("download")
.withCaption(getMessage("download"))
.withHandler(event -> {
FileDescriptor fileDescriptor = filesTable.getSingleSelected();
if (fileDescriptor != null) {
exportDisplay.show(fileDescriptor, null);
}
}));
BaseAction multiUploadAction = new BaseAction("multiupload")
.withCaption(getMessage("multiupload"))
.withHandler(event -> {
if (!security.isEntityOpPermitted(FileDescriptor.class, EntityOp.READ)) {
throw new AccessDeniedException(PermissionType.ENTITY_OP, FileDescriptor.class.getSimpleName());
}
Window window = openWindow("multiuploadDialog", OpenType.DIALOG);
window.addCloseListener(actionId -> {
if (COMMIT_ACTION_ID.equals(actionId)) {
Collection<FileDescriptor> items = ((MultiUploader) window).getFiles();
for (FileDescriptor fdesc : items) {
boolean modified = filesDs.isModified();
filesDs.addItem(fdesc);
((DatasourceImplementation) filesDs).setModified(modified);
}
filesTable.requestFocus();
}
});
});
multiUploadAction.setEnabled(security.isEntityOpPermitted(FileDescriptor.class, EntityOp.CREATE));
multiUploadBtn.setAction(multiUploadAction);
}
示例2: init
import com.haulmont.cuba.gui.components.actions.ItemTrackingAction; //導入依賴的package包/類
@Override
public void init(Map<String, Object> params) {
super.init(params);
Action copyRoles = new ItemTrackingAction("copy")
.withCaption(getMessage("actions.Copy"))
.withHandler(event -> {
userManagementService.copyRole(rolesTable.getSingleSelected().getId());
rolesDs.refresh();
});
boolean hasPermissionsToCreateRole = security.isEntityOpPermitted(Role.class, EntityOp.CREATE);
copyRoles.setEnabled(hasPermissionsToCreateRole);
rolesTable.addAction(copyRoles);
Action assignToUsersAction = new ItemTrackingAction(rolesTable, "assignToUsers")
.withCaption(getMessage("assignToUsers"))
.withHandler(event -> {
Set<Role> selected = rolesTable.getSelected();
if (selected.isEmpty()) {
showNotification(getMessage("selectRole.msg"), NotificationType.HUMANIZED);
return;
}
Role role = selected.iterator().next();
Map<String, Object> userLookupParams = new HashMap<>();
WindowParams.MULTI_SELECT.set(userLookupParams, true);
openLookup(User.class, items -> {
assignRoleUsers(role, items);
}, OpenType.THIS_TAB, userLookupParams);
});
rolesTable.addAction(assignToUsersAction);
boolean hasPermissionsToCreateUserRole = security.isEntityOpPermitted(UserRole.class, EntityOp.CREATE);
Action copy = rolesTable.getAction("assignToUsers");
if (copy != null) {
copy.setEnabled(hasPermissionsToCreateUserRole);
}
String windowOpener = (String) params.get("param$windowOpener");
if ("sec$User.edit".equals(windowOpener)) {
rolesTable.setMultiSelect(true);
}
rolesDs.addItemPropertyChangeListener(e -> {
if (DEFAULT_ROLE_PROPERTY.equals(e.getProperty())) {
Role reloadedRole = dataManager.reload(e.getItem(), View.LOCAL);
reloadedRole.setDefaultRole(e.getItem().getDefaultRole());
rolesDs.updateItem(reloadedRole);
rolesDs.modifyItem(reloadedRole);
rolesDs.commit();
}
});
importRolesUpload.addFileUploadSucceedListener(event -> {
importRoles();
});
importRolesUpload.setCaption(null);
importRolesUpload.setUploadButtonCaption(null);
}
示例3: initConstraintsTab
import com.haulmont.cuba.gui.components.actions.ItemTrackingAction; //導入依賴的package包/類
protected void initConstraintsTab() {
if (constraintsTabInitialized) {
return;
}
@SuppressWarnings("unchecked")
Table<Constraint> constraintsTable = (Table) getComponentNN("constraintsTable");
constraintCreateAction = new GroupPropertyCreateAction(constraintsTable);
constraintsTable.addAction(constraintCreateAction);
Action activateAction = new ItemTrackingAction("activate")
.withHandler(event -> {
Constraint constraint = constraintsTable.getSingleSelected();
if (constraint != null) {
constraint.setIsActive(!Boolean.TRUE.equals(constraint.getIsActive()));
constraintsDs.commit();
constraintsDs.refresh();
}
});
constraintsTable.addAction(activateAction);
constraintsTable.addAction(new ConstraintLocalizationEditAction(constraintsTable));
constraintsDs.addItemChangeListener(e -> {
if (e.getItem() != null) {
activateAction.setCaption(Boolean.TRUE.equals(e.getItem().getIsActive()) ?
getMessage("deactivate") : getMessage("activate"));
}
});
constraintsTable.addGeneratedColumn(
"entityName",
constraint -> {
if (StringUtils.isEmpty(constraint.getEntityName())) {
return componentsFactory.createComponent(Label.class);
}
MetaClass metaClass = metadata.getClassNN(constraint.getEntityName());
MetaClass effectiveMetaClass = metadata.getExtendedEntities().getEffectiveMetaClass(metaClass);
Label label = componentsFactory.createComponent(Label.class);
label.setValue(effectiveMetaClass.getName());
return label;
}
);
constraintsTabInitialized = true;
constraintsTable.refresh();
}