use of de.catma.ui.layout.HorizontalFlexLayout in project catma by forTEXT.
the class ProjectCard method initComponents.
protected void initComponents() {
addStyleName("projectlist__card");
CssLayout preview = new CssLayout();
preview.addStyleName("projectlist__card__preview");
descriptionLabel = new Label(projectReference.getDescription());
descriptionLabel.setWidth("100%");
preview.addComponents(descriptionLabel);
preview.addLayoutClickListener(evt -> handleOpenProjectRequest());
addComponent(preview);
HorizontalFlexLayout descriptionBar = new HorizontalFlexLayout();
descriptionBar.addStyleName("projectlist__card__descriptionbar");
descriptionBar.setAlignItems(FlexLayout.AlignItems.BASELINE);
descriptionBar.setWidth("100%");
nameLabel = new Label(projectReference.getName());
nameLabel.setWidth("100%");
descriptionBar.addComponent(nameLabel);
IconButton btnRemove = new IconButton(VaadinIcons.TRASH);
descriptionBar.addComponents(btnRemove);
btnRemove.addClickListener((event -> {
ConfirmDialog.show(UI.getCurrent(), "Delete Project", "Do you want to delete the whole Project '" + projectReference.getName() + "'?", "OK", "Cancel", (evt) -> {
try {
if (evt.isConfirmed()) {
projectManager.delete(projectReference.getProjectId());
eventBus.post(new ProjectChangedEvent(projectReference.getProjectId()));
}
} catch (Exception e) {
errorLogger.showAndLogError("can't delete Project " + projectReference.getName(), e);
}
});
}));
IconButton btnEdit = new IconButton(VaadinIcons.PENCIL);
btnEdit.addClickListener(click -> {
new EditProjectDialog(projectReference, projectManager, result -> {
try {
projectManager.updateProject(result);
descriptionLabel.setValue(result.getDescription());
nameLabel.setValue(result.getName());
} catch (IOException e) {
errorLogger.showAndLogError("Failed to update Project", e);
eventBus.post(new ProjectChangedEvent());
}
}).show();
});
descriptionBar.addComponent(btnEdit);
IconButton btnLeave = new IconButton(VaadinIcons.EXIT);
btnLeave.addClickListener((event -> {
ConfirmDialog.show(UI.getCurrent(), "Leave Project", "Do you want to leave '" + projectReference.getName() + "'?", "OK", "Cancel", (evt) -> {
try {
if (evt.isConfirmed()) {
projectManager.leaveProject(projectReference.getProjectId());
}
} catch (Exception e) {
errorLogger.showAndLogError("can't leave project " + projectReference.getName(), e);
}
eventBus.post(new ProjectChangedEvent());
});
}));
descriptionBar.addComponent(btnLeave);
rbacEnforcer.register(RBACConstraint.ifNotAuthorized((role) -> (rbacManager.hasPermission(role, RBACPermission.PROJECT_EDIT)), () -> {
btnEdit.setVisible(false);
btnEdit.setEnabled(false);
}));
rbacEnforcer.register(RBACConstraint.ifNotAuthorized((role) -> (rbacManager.hasPermission(role, RBACPermission.PROJECT_DELETE)), () -> {
btnRemove.setVisible(false);
btnRemove.setEnabled(false);
}));
rbacEnforcer.register(RBACConstraint.ifNotAuthorized((role) -> rbacManager.hasPermission(role, RBACPermission.PROJECT_LEAVE) && !rbacManager.hasPermission(role, RBACPermission.PROJECT_DELETE), () -> {
btnLeave.setVisible(false);
btnLeave.setEnabled(false);
}));
// IconButton buttonAction = new IconButton(VaadinIcons.ELLIPSIS_DOTS_V);
// descriptionBar.addComponents(buttonAction);
addComponents(descriptionBar);
}
use of de.catma.ui.layout.HorizontalFlexLayout in project catma by forTEXT.
the class CreateProjectCard method initComponents.
private void initComponents() {
addStyleName("projectlist__newproject");
CssLayout newproject = new CssLayout();
newproject.addStyleName("projectlist__newproject__link");
Label labelDesc = new Label("create new project");
labelDesc.setWidth("100%");
newproject.addComponents(labelDesc);
newproject.addLayoutClickListener(evt -> {
new CreateProjectDialog(projectManager, result -> eventBus.post(new ProjectChangedEvent())).show();
});
addComponent(newproject);
HorizontalFlexLayout descriptionBar = new HorizontalFlexLayout();
descriptionBar.addStyleName("projectlist__card__descriptionbar");
descriptionBar.setAlignItems(FlexLayout.AlignItems.BASELINE);
descriptionBar.setWidth("100%");
addComponents(descriptionBar);
}
use of de.catma.ui.layout.HorizontalFlexLayout in project catma by forTEXT.
the class ProjectView method initTeamContent.
private Component initTeamContent() {
HorizontalFlexLayout teamContent = new HorizontalFlexLayout();
teamGrid = new Grid<>();
teamGrid.setHeaderVisible(false);
// $NON-NLS-1$
teamGrid.setWidth("402px");
teamGrid.addColumn((user) -> VaadinIcons.USER.getHtml(), new HtmlRenderer());
teamGrid.addColumn(User::getName).setWidth(200).setComparator((r1, r2) -> String.CASE_INSENSITIVE_ORDER.compare(r1.getName(), r2.getName())).setDescriptionGenerator(User::preciseName);
teamGrid.addColumn(Member::getRole).setExpandRatio(1);
Label membersAnnotations = new Label("Members");
ActionGridComponent<Grid<Member>> membersGridComponent = new ActionGridComponent<>(membersAnnotations, teamGrid);
// $NON-NLS-1$
membersGridComponent.addStyleName("project-view-action-grid");
ContextMenu addContextMenu = membersGridComponent.getActionGridBar().getBtnAddContextMenu();
addContextMenu.addItem("Add Member", (click) -> new AddMemberDialog(project::assignOnProject, // $NON-NLS-1$
(query) -> project.findUser(query.getFilter().isPresent() ? query.getFilter().get() : "", query.getOffset(), query.getLimit()), (evt) -> eventBus.post(new MembersChangedEvent())).show());
ContextMenu moreOptionsContextMenu = membersGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
moreOptionsContextMenu.addItem("Edit Members", (click) -> handleEditMembers());
moreOptionsContextMenu.addItem("Remove Members", (click) -> handleRemoveMembers());
miInvite = moreOptionsContextMenu.addItem("Invite someone to the Project", click -> handleProjectInvitationRequest());
MenuItem editResBtn = moreOptionsContextMenu.addItem("Resource permissions", click -> {
@SuppressWarnings("unchecked") TreeDataProvider<Resource> resourceDataProvider = (TreeDataProvider<Resource>) documentGrid.getDataProvider();
TreeData<Resource> resourceData = resourceDataProvider.getTreeData();
if (!resourceData.getRootItems().isEmpty()) {
new ResourcePermissionView(resourceData, tagsetData.getItems(), this.project).show();
} else {
Notification.show("Info", "You do not have any Documents yet, please add a Document first!", Type.HUMANIZED_MESSAGE);
}
});
editResBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.PROJECT_MEMBERS_EDIT)), () -> editResBtn.setEnabled(true)));
teamContent.addComponent(membersGridComponent);
return teamContent;
}
Aggregations