List of usage examples for com.vaadin.ui GridLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:org.bubblecloud.ilves.ui.administrator.directory.UserDirectoryFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull();//w w w. j av a2 s . c om gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); userDirectoryEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(UserDirectory.class)); userDirectoryEditor.setCaption("UserDirectory"); userDirectoryEditor.addListener((ValidatingEditorStateListener) this); gridLayout.addComponent(userDirectoryEditor, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 1); saveButton = new Button("Save"); saveButton.setImmediate(true); buttonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { userDirectoryEditor.commit(); if (entity.getUserDirectoryId() == null) { SecurityService.addUserDirectory(getSite().getSiteContext(), entity); } else { SecurityService.updateUserDirectory(getSite().getSiteContext(), entity); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); buttonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { userDirectoryEditor.discard(); } }); }
From source file:org.bubblecloud.ilves.ui.administrator.group.GroupFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout layout = new GridLayout(2, 3); layout.setSizeFull();/*from w ww . j a v a2 s. c om*/ layout.setMargin(false); layout.setSpacing(true); layout.setRowExpandRatio(1, 1f); setViewContent(layout); groupEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(Group.class)); groupEditor.setCaption("Group"); groupEditor.addListener((ValidatingEditorStateListener) this); groupEditor.setReadOnly(detailsReadonly); layout.addComponent(groupEditor, 0, 1); final List<FieldDescriptor> childFieldDescriptors = SiteFields.getFieldDescriptors(GroupMember.class); final List<FilterDescriptor> childFilterDescriptors = new ArrayList<FilterDescriptor>(); childContainer = new EntityContainer<GroupMember>(entityManager, GroupMember.class, "groupMemberId", 1000, true, false, false); childContainer.getQueryView().getQueryDefinition().setDefaultSortState( new String[] { "user.firstName", "user.lastName" }, new boolean[] { true, true }); ContainerUtil.addContainerProperties(childContainer, childFieldDescriptors); final Table childTable = new FormattingTable(); childGrid = new Grid(childTable, childContainer); childGrid.setFields(childFieldDescriptors); childGrid.setFilters(childFilterDescriptors); childTable.setColumnCollapsed("created", true); layout.addComponent(childGrid, 1, 1); final HorizontalLayout editorButtonLayout = new HorizontalLayout(); editorButtonLayout.setSpacing(true); layout.addComponent(editorButtonLayout, 0, 2); saveButton = new Button("Save"); saveButton.setImmediate(true); editorButtonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { groupEditor.commit(); if (entity.getGroupId() == null) { SecurityService.addGroup(getSite().getSiteContext(), entity); } else { SecurityService.updateGroup(getSite().getSiteContext(), entity); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); editorButtonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { groupEditor.discard(); } }); childListButtonLayout = new HorizontalLayout(); childListButtonLayout.setSpacing(true); childListButtonLayout.setSizeUndefined(); layout.addComponent(childListButtonLayout, 1, 0); final Button addButton = getSite().getButton("add"); childListButtonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final GroupMember groupMember = new GroupMember(); groupMember.setGroup(entity); groupMember.setCreated(new Date()); final GroupUserMemberFlowlet userGroupMemberFlowlet = getFlow() .forward(GroupUserMemberFlowlet.class); userGroupMemberFlowlet.edit(groupMember, true); } }); final Button removeButton = getSite().getButton("remove"); childListButtonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (childGrid.getSelectedItemId() == null) { return; } final GroupMember groupMember = childContainer.getEntity(childGrid.getSelectedItemId()); if (groupMember != null) { SecurityService.removeGroupMember(getSite().getSiteContext(), groupMember.getGroup(), groupMember.getUser()); childContainer.refresh(); } } }); }
From source file:org.bubblecloud.ilves.ui.administrator.group.GroupsFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = SiteFields.getFieldDescriptors(Group.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new EntityContainer<Group>(entityManager, true, false, false, Group.class, 1000, new String[] { "name" }, new boolean[] { true }, "groupId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull();/*w w w . j a v a2s .c om*/ gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 0); final Table table = new FormattingTable(); grid = new Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); gridLayout.addComponent(grid, 0, 1); final Button addButton = getSite().getButton("add"); buttonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Group group = new Group(); group.setCreated(new Date()); group.setModified(group.getCreated()); group.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final GroupFlowlet groupView = getFlow().forward(GroupFlowlet.class); groupView.edit(group, true); } }); final Button editButton = getSite().getButton("edit"); buttonLayout.addComponent(editButton); editButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (grid.getSelectedItemId() == null) { return; } final Group entity = container.getEntity(grid.getSelectedItemId()); final GroupFlowlet groupView = getFlow().forward(GroupFlowlet.class); groupView.edit(entity, false); } }); final Button removeButton = getSite().getButton("remove"); buttonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (grid.getSelectedItemId() == null) { return; } final Group entity = container.getEntity(grid.getSelectedItemId()); final List<User> users = UserDao.getGroupMembers(entityManager, (Company) getSite().getSiteContext().getObject(Company.class), entity); for (final User user : users) { SecurityService.removeGroupMember(getSite().getSiteContext(), entity, user); } final List<Privilege> privileges = UserDao.getGroupPrivileges(entityManager, entity); for (final Privilege privilege : privileges) { SecurityService.removeGroupPrivilege(getSite().getSiteContext(), entity, privilege.getKey(), null, privilege.getDataId(), null); } SecurityService.removeGroup(getSite().getSiteContext(), entity); container.refresh(); } }); final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); }
From source file:org.bubblecloud.ilves.ui.administrator.group.GroupUserMemberFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull();//from ww w .j a v a 2 s . c o m gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final List<FieldDescriptor> fieldDescriptors = new ArrayList<FieldDescriptor>( SiteFields.getFieldDescriptors(GroupMember.class)); for (final FieldDescriptor fieldDescriptor : fieldDescriptors) { if ("group".equals(fieldDescriptor.getId())) { fieldDescriptors.remove(fieldDescriptor); break; } } groupMemberEditor = new ValidatingEditor(fieldDescriptors); groupMemberEditor.setCaption("GroupMember"); groupMemberEditor.addListener(this); gridLayout.addComponent(groupMemberEditor, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 1); saveButton = new Button("Save"); saveButton.setImmediate(true); buttonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { groupMemberEditor.commit(); SecurityService.addGroupMember(getSite().getSiteContext(), entity.getGroup(), entity.getUser()); } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); buttonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { groupMemberEditor.discard(); } }); }
From source file:org.bubblecloud.ilves.ui.administrator.user.UserFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout layout = new GridLayout(2, 3); layout.setSizeFull();//from w w w . ja va 2 s .c o m layout.setMargin(false); layout.setSpacing(true); layout.setRowExpandRatio(1, 1f); layout.setColumnExpandRatio(1, 1f); setViewContent(layout); editor = new ValidatingEditor(SiteFields.getFieldDescriptors(User.class)); editor.setCaption("User"); editor.addListener((ValidatingEditorStateListener) this); editor.setWidth("480px"); layout.addComponent(editor, 0, 1); final List<FieldDescriptor> childFieldDescriptors = SiteFields.getFieldDescriptors(GroupMember.class); final List<FilterDescriptor> childFilterDescriptors = new ArrayList<FilterDescriptor>(); childContainer = new EntityContainer<GroupMember>(entityManager, GroupMember.class, "groupMemberId", 1000, true, false, false); childContainer.getQueryView().getQueryDefinition().setDefaultSortState( new String[] { "user.firstName", "user.lastName" }, new boolean[] { true, true }); ContainerUtil.addContainerProperties(childContainer, childFieldDescriptors); final Table childTable = new FormattingTable(); childGrid = new Grid(childTable, childContainer); childGrid.setFields(childFieldDescriptors); childGrid.setFilters(childFilterDescriptors); childTable.setColumnCollapsed("created", true); layout.addComponent(childGrid, 1, 1); final HorizontalLayout editorButtonLayout = new HorizontalLayout(); editorButtonLayout.setSpacing(true); layout.addComponent(editorButtonLayout, 0, 2); saveButton = new Button("Save"); saveButton.setImmediate(true); editorButtonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.commit(); try { final boolean toBeAdded = user.getUserId() == null; if (user.getPasswordHash() != null) { final int hashSize = 64; if (user.getPasswordHash().length() != hashSize) { try { PasswordLoginUtil.setUserPasswordHash(user.getOwner(), user, user.getPasswordHash()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } } // UserLogic.updateUser(user, // UserDao.getGroupMembers(entityManager, user)); if (toBeAdded) { SecurityService.addUser(getSite().getSiteContext(), user, UserDao.getGroup(entityManager, user.getOwner(), DefaultRoles.USER)); childGrid.refresh(); } else { SecurityService.updateUser(getSite().getSiteContext(), user); } editor.setItem(new BeanItem<User>(user), false); //entityManager.detach(user); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + user, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); editorButtonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.discard(); } }); childListButtonLayout = new HorizontalLayout(); childListButtonLayout.setSpacing(true); childListButtonLayout.setSizeUndefined(); layout.addComponent(childListButtonLayout, 1, 0); final Button addButton = getSite().getButton("add"); childListButtonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final GroupMember userElement = new GroupMember(); userElement.setUser(user); userElement.setCreated(new Date()); final UserGroupMemberFlowlet userGroupMemberFlowlet = getFlow() .forward(UserGroupMemberFlowlet.class); userGroupMemberFlowlet.edit(userElement, true); } }); final Button removeButton = getSite().getButton("remove"); childListButtonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (childGrid.getSelectedItemId() == null) { return; } childContainer.removeItem(childGrid.getSelectedItemId()); childContainer.commit(); } }); }
From source file:org.bubblecloud.ilves.ui.administrator.user.UserGroupMemberFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull();// ww w . j av a 2 s . c om gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final List<FieldDescriptor> fieldDescriptors = new ArrayList<FieldDescriptor>( SiteFields.getFieldDescriptors(GroupMember.class)); for (final FieldDescriptor fieldDescriptor : fieldDescriptors) { if ("user".equals(fieldDescriptor.getId())) { fieldDescriptors.remove(fieldDescriptor); break; } } groupMemberEditor = new ValidatingEditor(fieldDescriptors); groupMemberEditor.setCaption("GroupMember"); groupMemberEditor.addListener(this); gridLayout.addComponent(groupMemberEditor, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 1); saveButton = new Button("Save"); saveButton.setImmediate(true); buttonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { groupMemberEditor.commit(); entityManager.getTransaction().begin(); try { entity = entityManager.merge(entity); entityManager.persist(entity); entityManager.getTransaction().commit(); //entityManager.detach(entity); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + entity, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); buttonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { groupMemberEditor.discard(); } }); }
From source file:org.bubblecloud.ilves.ui.administrator.user.UsersFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = SiteFields.getFieldDescriptors(User.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new EntityContainer<User>(entityManager, true, false, false, User.class, 1000, new String[] { "lastName", "firstName" }, new boolean[] { true, true }, "userId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull();// ww w . j av a2 s. c om gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 0); final Table table = new FormattingTable(); grid = new Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); table.setColumnCollapsed("passwordHash", true); table.setColumnCollapsed("openIdIdentifier", true); table.setColumnCollapsed("certificate", true); table.setColumnCollapsed("failedLoginCount", true); gridLayout.addComponent(grid, 0, 1); final Button addButton = getSite().getButton("add"); buttonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final User user = new User(); user.setCreated(new Date()); user.setModified(user.getCreated()); user.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final UserFlowlet userView = getFlow().getFlowlet(UserFlowlet.class); userView.edit(user, true); getFlow().forward(UserFlowlet.class); } }); final Button editButton = getSite().getButton("edit"); buttonLayout.addComponent(editButton); editButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (grid.getSelectedItemId() == null) { return; } final User entity = container.getEntity(grid.getSelectedItemId()); final UserFlowlet userView = getFlow().getFlowlet(UserFlowlet.class); userView.edit(entity, false); getFlow().forward(UserFlowlet.class); } }); final Button removeButton = getSite().getButton("remove"); buttonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (grid.getSelectedItemId() == null) { return; } final User entity = container.getEntity(grid.getSelectedItemId()); final List<Group> groups = UserDao.getUserGroups(entityManager, (Company) getSite().getSiteContext().getObject(Company.class), entity); for (final Group group : groups) { SecurityService.removeGroupMember(getSite().getSiteContext(), group, entity); } final List<Privilege> privileges = UserDao.getUserPrivileges(entityManager, entity); for (final Privilege privilege : privileges) { SecurityService.removeUserPrivilege(getSite().getSiteContext(), entity, privilege.getKey(), null, privilege.getDataId(), null); } SecurityService.removeUser(getSite().getSiteContext(), entity); container.refresh(); } }); final Button lockButton = getSite().getButton("lock"); lockButton.setImmediate(true); buttonLayout.addComponent(lockButton); lockButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (grid.getSelectedItemId() == null) { return; } final User user = container.getEntity(grid.getSelectedItemId()); user.setLockedOut(true); SecurityService.updateUser(getSite().getSiteContext(), user); container.refresh(); } }); final Button unlockButton = getSite().getButton("unlock"); unlockButton.setImmediate(true); buttonLayout.addComponent(unlockButton); unlockButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (grid.getSelectedItemId() == null) { return; } final User user = container.getEntity(grid.getSelectedItemId()); user.setLockedOut(false); user.setFailedLoginCount(0); SecurityService.updateUser(getSite().getSiteContext(), user); container.refresh(); } }); final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); }
From source file:org.bubblecloud.ilves.ui.user.AccountFlowlet.java
License:Apache License
@Override public void initialize() { final GridLayout gridLayout = new GridLayout(1, 6); gridLayout.setRowExpandRatio(0, 0.0f); gridLayout.setRowExpandRatio(1, 0.0f); gridLayout.setRowExpandRatio(2, 0.0f); gridLayout.setRowExpandRatio(3, 0.0f); gridLayout.setRowExpandRatio(4, 0.0f); gridLayout.setRowExpandRatio(5, 1.0f); gridLayout.setSizeFull();/*from w w w . j av a 2 s.c o m*/ gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(4, 1f); setViewContent(gridLayout); final HorizontalLayout userAccountTitle = new HorizontalLayout(); userAccountTitle.setMargin(new MarginInfo(false, false, false, false)); userAccountTitle.setSpacing(true); final Embedded userAccountTitleIcon = new Embedded(null, getSite().getIcon("view-icon-user")); userAccountTitleIcon.setWidth(32, Unit.PIXELS); userAccountTitleIcon.setHeight(32, Unit.PIXELS); userAccountTitle.addComponent(userAccountTitleIcon); final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", ContentMode.HTML); userAccountTitle.addComponent(userAccountTitleLabel); gridLayout.addComponent(userAccountTitle, 0, 0); final Button editUserButton = new Button("Edit User Account"); editUserButton.setIcon(getSite().getIcon("button-icon-edit")); gridLayout.addComponent(editUserButton, 0, 2); editUserButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final User entity = ((SecurityProviderSessionImpl) getSite().getSecurityProvider()) .getUserFromSession(); final UserAccountFlowlet customerView = getFlow().getFlowlet(UserAccountFlowlet.class); customerView.edit(entity, false); getFlow().forward(UserAccountFlowlet.class); } }); final Company company = getSite().getSiteContext().getObject(Company.class); if (company.isOpenIdLogin()) { final VerticalLayout mainPanel = new VerticalLayout(); mainPanel.setCaption("Choose OpenID Provider:"); gridLayout.addComponent(mainPanel, 0, 1); final HorizontalLayout openIdLayout = new HorizontalLayout(); mainPanel.addComponent(openIdLayout); openIdLayout.setMargin(new MarginInfo(false, false, true, false)); openIdLayout.setSpacing(true); final String returnViewName = "openidlink"; final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap(); for (final String url : urlIconMap.keySet()) { openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName)); } } if (SiteModuleManager.isModuleInitialized(CustomerModule.class)) { final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Customer.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name", new TextField(), 101, "=", String.class, "")); filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101, "=", String.class, "")); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000, new String[] { "companyName", "lastName" }, new boolean[] { false, false }, "customerId"); for (final FieldDescriptor fieldDefinition : fieldDefinitions) { entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(), fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable()); } final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, false, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-customer")); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h2>Customer Accounts</h2>", ContentMode.HTML); titleLayout.addComponent(titleLabel); gridLayout.addComponent(titleLayout, 0, 3); final Table table = new Table(); table.setPageLength(5); entityGrid = new Grid(table, entityContainer); entityGrid.setFields(fieldDefinitions); entityGrid.setFilters(filterDefinitions); //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId"); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); table.setColumnCollapsed("company", true); gridLayout.addComponent(entityGrid, 0, 5); final HorizontalLayout customerButtonsLayout = new HorizontalLayout(); gridLayout.addComponent(customerButtonsLayout, 0, 4); customerButtonsLayout.setMargin(false); customerButtonsLayout.setSpacing(true); final Button editCustomerDetailsButton = new Button("Edit Customer Details"); customerButtonsLayout.addComponent(editCustomerDetailsButton); editCustomerDetailsButton.setEnabled(false); editCustomerDetailsButton.setIcon(getSite().getIcon("button-icon-edit")); editCustomerDetailsButton.addClickListener(new ClickListener() { /** * Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (entityGrid.getSelectedItemId() == null) { return; } final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId()); final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class); customerView.edit(entity, false); } }); final Button editCustomerMembersButton = new Button("Edit Customer Members"); customerButtonsLayout.addComponent(editCustomerMembersButton); editCustomerMembersButton.setEnabled(false); editCustomerMembersButton.setIcon(getSite().getIcon("button-icon-edit")); editCustomerMembersButton.addClickListener(new ClickListener() { /** * Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (entityGrid.getSelectedItemId() == null) { return; } final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId()); final GroupFlowlet view = getFlow().forward(GroupFlowlet.class); view.edit(entity.getMemberGroup(), false); } }); final Button editCustomerAdminsButton = new Button("Edit Customer Admins"); customerButtonsLayout.addComponent(editCustomerAdminsButton); editCustomerAdminsButton.setEnabled(false); editCustomerAdminsButton.setIcon(getSite().getIcon("button-icon-edit")); editCustomerAdminsButton.addClickListener(new ClickListener() { /** * Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (entityGrid.getSelectedItemId() == null) { return; } final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId()); final GroupFlowlet view = getFlow().forward(GroupFlowlet.class); view.edit(entity.getAdminGroup(), false); } }); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final Property.ValueChangeEvent event) { editCustomerDetailsButton.setEnabled(table.getValue() != null); editCustomerMembersButton.setEnabled(table.getValue() != null); editCustomerAdminsButton.setEnabled(table.getValue() != null); } }); } }
From source file:org.bubblecloud.ilves.ui.user.UserAccountFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout layout = new GridLayout(1, 3); layout.setSizeFull();/*from w w w .ja v a 2s . com*/ layout.setMargin(false); layout.setSpacing(true); layout.setRowExpandRatio(1, 1f); layout.setColumnExpandRatio(1, 1f); setViewContent(layout); editor = new ValidatingEditor(SiteFields.getFieldDescriptors(User.class)); editor.setCaption("User"); editor.addListener((ValidatingEditorStateListener) this); editor.setWidth("380px"); layout.addComponent(editor, 0, 1); final HorizontalLayout editorButtonLayout = new HorizontalLayout(); editorButtonLayout.setSpacing(true); layout.addComponent(editorButtonLayout, 0, 2); saveButton = new Button("Save"); saveButton.setImmediate(true); editorButtonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.commit(); try { if (user.getPasswordHash() != null) { final int hashSize = 64; if (user.getPasswordHash().length() != hashSize) { try { PasswordLoginUtil.setUserPasswordHash(user.getOwner(), user, user.getPasswordHash()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } } // UserLogic.updateUser(user, // UserDao.getGroupMembers(entityManager, user)); user = entityManager.merge(user); SecurityService.updateUser(getSite().getSiteContext(), user); editor.setItem(new BeanItem<User>(user), false); entityManager.detach(user); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + user, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); editorButtonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.discard(); } }); }
From source file:org.diretto.web.richwebclient.view.windows.UploadSettingsWindow.java
/** * Constructs an {@link UploadSettingsWindow}. * /*w w w . j a va 2s .c o m*/ * @param mainWindow The corresponding {@code MainWindow} * @param uploadSection The corresponding {@code UploadSection} * @param fileInfo The {@code FileInfo} object * @param mediaType The {@code MediaType} of the file * @param uploadSettings The corresponding {@code UploadSettings} * @param otherFiles The names of the other upload files */ public UploadSettingsWindow(final MainWindow mainWindow, final UploadSection uploadSection, FileInfo fileInfo, MediaType mediaType, UploadSettings uploadSettings, List<String> otherFiles) { super("Upload Settings"); this.mainWindow = mainWindow; setModal(true); setStyleName(Reindeer.WINDOW_BLACK); setWidth("940px"); setHeight((((int) mainWindow.getHeight()) - 160) + "px"); setResizable(false); setClosable(false); setDraggable(false); setPositionX((int) (mainWindow.getWidth() / 2.0f) - 470); setPositionY(126); wrapperLayout = new HorizontalLayout(); wrapperLayout.setSizeFull(); wrapperLayout.setMargin(true, true, true, true); addComponent(wrapperLayout); mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.setSpacing(true); HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setWidth("100%"); mainLayout.addComponent(titleLayout); HorizontalLayout leftTitleLayout = new HorizontalLayout(); titleLayout.addComponent(leftTitleLayout); titleLayout.setComponentAlignment(leftTitleLayout, Alignment.MIDDLE_LEFT); Label fileNameLabel = StyleUtils.getLabelH2(fileInfo.getName()); leftTitleLayout.addComponent(fileNameLabel); leftTitleLayout.setComponentAlignment(fileNameLabel, Alignment.MIDDLE_LEFT); Label bullLabel = StyleUtils.getLabelHTML( " • "); leftTitleLayout.addComponent(bullLabel); leftTitleLayout.setComponentAlignment(bullLabel, Alignment.MIDDLE_LEFT); Label titleLabel = StyleUtils.getLabelHTML("<b>Title</b> "); leftTitleLayout.addComponent(titleLabel); leftTitleLayout.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT); final TextField titleField = new TextField(); titleField.setMaxLength(50); titleField.setWidth("100%"); titleField.setImmediate(true); if (uploadSettings != null && uploadSettings.getTitle() != null) { titleField.setValue(uploadSettings.getTitle()); } titleField.focus(); titleField.setCursorPosition(((String) titleField.getValue()).length()); titleLayout.addComponent(titleField); titleLayout.setComponentAlignment(titleField, Alignment.MIDDLE_RIGHT); titleLayout.setExpandRatio(leftTitleLayout, 0); titleLayout.setExpandRatio(titleField, 1); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout topGridLayout = new GridLayout(2, 3); topGridLayout.setColumnExpandRatio(0, 1.0f); topGridLayout.setColumnExpandRatio(1, 0.0f); topGridLayout.setWidth("100%"); topGridLayout.setSpacing(true); mainLayout.addComponent(topGridLayout); Label descriptionLabel = StyleUtils.getLabelBold("Description"); topGridLayout.addComponent(descriptionLabel, 0, 0); final TextArea descriptionArea = new TextArea(); descriptionArea.setSizeFull(); descriptionArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getDescription() != null) { descriptionArea.setValue(uploadSettings.getDescription()); } topGridLayout.addComponent(descriptionArea, 0, 1); VerticalLayout tagsWrapperLayout = new VerticalLayout(); tagsWrapperLayout.setHeight("30px"); tagsWrapperLayout.setSpacing(false); topGridLayout.addComponent(tagsWrapperLayout, 0, 2); HorizontalLayout tagsLayout = new HorizontalLayout(); tagsLayout.setWidth("100%"); tagsLayout.setSpacing(true); Label tagsLabel = StyleUtils.getLabelBoldHTML("Tags "); tagsLabel.setSizeUndefined(); tagsLayout.addComponent(tagsLabel); tagsLayout.setComponentAlignment(tagsLabel, Alignment.MIDDLE_LEFT); addTagField = new TextField(); addTagField.setImmediate(true); addTagField.setInputPrompt("Enter new Tag"); addTagField.addShortcutListener(new ShortcutListener(null, KeyCode.ENTER, new int[0]) { private static final long serialVersionUID = -4767515198819351723L; @Override public void handleAction(Object sender, Object target) { if (target == addTagField) { addTag(); } } }); tagsLayout.addComponent(addTagField); tagsLayout.setComponentAlignment(addTagField, Alignment.MIDDLE_LEFT); tabSheet = new TabSheet(); tabSheet.setStyleName(Reindeer.TABSHEET_SMALL); tabSheet.addStyleName("view"); tabSheet.addListener(new ComponentDetachListener() { private static final long serialVersionUID = -657657505471281795L; @Override public void componentDetachedFromContainer(ComponentDetachEvent event) { tags.remove(tabSheet.getTab(event.getDetachedComponent()).getCaption()); } }); Button addTagButton = new Button("Add", new Button.ClickListener() { private static final long serialVersionUID = 5914473126402594623L; @Override public void buttonClick(ClickEvent event) { addTag(); } }); addTagButton.setStyleName(Reindeer.BUTTON_DEFAULT); tagsLayout.addComponent(addTagButton); tagsLayout.setComponentAlignment(addTagButton, Alignment.MIDDLE_LEFT); Label spaceLabel = StyleUtils.getLabelHTML(""); spaceLabel.setSizeUndefined(); tagsLayout.addComponent(spaceLabel); tagsLayout.setComponentAlignment(spaceLabel, Alignment.MIDDLE_LEFT); tagsLayout.addComponent(tabSheet); tagsLayout.setComponentAlignment(tabSheet, Alignment.MIDDLE_LEFT); tagsLayout.setExpandRatio(tabSheet, 1.0f); tagsWrapperLayout.addComponent(tagsLayout); tagsWrapperLayout.setComponentAlignment(tagsLayout, Alignment.TOP_LEFT); if (uploadSettings != null && uploadSettings.getTags() != null && uploadSettings.getTags().size() > 0) { for (String tag : uploadSettings.getTags()) { addTagField.setValue(tag); addTag(); } } Label presettingLabel = StyleUtils.getLabelBold("Presetting"); topGridLayout.addComponent(presettingLabel, 1, 0); final TwinColSelect twinColSelect; if (otherFiles != null && otherFiles.size() > 0) { twinColSelect = new TwinColSelect(null, otherFiles); } else { twinColSelect = new TwinColSelect(); } twinColSelect.setWidth("400px"); twinColSelect.setRows(10); topGridLayout.addComponent(twinColSelect, 1, 1); topGridLayout.setComponentAlignment(twinColSelect, Alignment.TOP_RIGHT); Label otherFilesLabel = StyleUtils .getLabelSmallHTML("Select the files which should get the settings of this file as presetting."); otherFilesLabel.setSizeUndefined(); topGridLayout.addComponent(otherFilesLabel, 1, 2); topGridLayout.setComponentAlignment(otherFilesLabel, Alignment.MIDDLE_CENTER); mainLayout.addComponent(StyleUtils.getHorizontalLine()); final UploadGoogleMap googleMap; if (uploadSettings != null && uploadSettings.getTopographicPoint() != null) { googleMap = new UploadGoogleMap(mediaType, 12, uploadSettings.getTopographicPoint().getLatitude(), uploadSettings.getTopographicPoint().getLongitude(), MapType.HYBRID); } else { googleMap = new UploadGoogleMap(mediaType, 12, 48.42255269321401d, 9.956477880477905d, MapType.HYBRID); } googleMap.setWidth("100%"); googleMap.setHeight("300px"); mainLayout.addComponent(googleMap); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout bottomGridLayout = new GridLayout(3, 3); bottomGridLayout.setSizeFull(); bottomGridLayout.setSpacing(true); mainLayout.addComponent(bottomGridLayout); Label licenseLabel = StyleUtils.getLabelBold("License"); bottomGridLayout.addComponent(licenseLabel, 0, 0); final TextArea licenseArea = new TextArea(); licenseArea.setWidth("320px"); licenseArea.setHeight("175px"); licenseArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getLicense() != null) { licenseArea.setValue(uploadSettings.getLicense()); } bottomGridLayout.addComponent(licenseArea, 0, 1); final Label startTimeLabel = StyleUtils.getLabelBold("Earliest possible Start Date"); startTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(startTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeLabel, 1, 0); final InlineDateField startTimeField = new InlineDateField(); startTimeField.setImmediate(true); startTimeField.setResolution(InlineDateField.RESOLUTION_SEC); boolean currentTimeAdjusted = false; if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getStartDateTime() != null) { startTimeField.setValue(uploadSettings.getTimeRange().getStartDateTime().toDate()); } else { currentTimeAdjusted = true; startTimeField.setValue(new Date()); } bottomGridLayout.setComponentAlignment(startTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeField, 1, 1); final CheckBox exactTimeCheckBox = new CheckBox("This is the exact point in time."); exactTimeCheckBox.setImmediate(true); bottomGridLayout.setComponentAlignment(exactTimeCheckBox, Alignment.TOP_CENTER); bottomGridLayout.addComponent(exactTimeCheckBox, 1, 2); final Label endTimeLabel = StyleUtils.getLabelBold("Latest possible Start Date"); endTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(endTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeLabel, 2, 0); final InlineDateField endTimeField = new InlineDateField(); endTimeField.setImmediate(true); endTimeField.setResolution(InlineDateField.RESOLUTION_SEC); if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getEndDateTime() != null) { endTimeField.setValue(uploadSettings.getTimeRange().getEndDateTime().toDate()); } else { endTimeField.setValue(startTimeField.getValue()); } bottomGridLayout.setComponentAlignment(endTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeField, 2, 1); if (!currentTimeAdjusted && ((Date) startTimeField.getValue()).equals((Date) endTimeField.getValue())) { exactTimeCheckBox.setValue(true); endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } exactTimeCheckBox.addListener(new ValueChangeListener() { private static final long serialVersionUID = 7193545421803538364L; @Override public void valueChange(ValueChangeEvent event) { if ((Boolean) event.getProperty().getValue()) { endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } else { endTimeLabel.setEnabled(true); endTimeField.setEnabled(true); } } }); mainLayout.addComponent(StyleUtils.getHorizontalLine()); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true, false, false, false); buttonLayout.setSpacing(false); HorizontalLayout uploadButtonLayout = new HorizontalLayout(); uploadButtonLayout.setMargin(false, true, false, false); uploadButton = new Button("Upload File", new Button.ClickListener() { private static final long serialVersionUID = 8013811216568950479L; @Override @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { String titleValue = titleField.getValue().toString().trim(); Date startTimeValue = (Date) startTimeField.getValue(); Date endTimeValue = (Date) endTimeField.getValue(); boolean exactTimeValue = (Boolean) exactTimeCheckBox.getValue(); if (titleValue.equals("")) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils.getLabelHTML("A title entry is required.")); mainWindow.addWindow(confirmWindow); } else if (titleValue.length() < 5 || titleValue.length() > 50) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils .getLabelHTML("The number of characters of the title has to be between 5 and 50.")); mainWindow.addWindow(confirmWindow); } else if (!exactTimeValue && startTimeValue.after(endTimeValue)) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The second date has to be after the first date.")); mainWindow.addWindow(confirmWindow); } else if (startTimeValue.after(new Date()) || (!exactTimeValue && endTimeValue.after(new Date()))) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The dates are not allowed to be in the future.")); mainWindow.addWindow(confirmWindow); } else { disableButtons(); String descriptionValue = descriptionArea.getValue().toString().trim(); String licenseValue = licenseArea.getValue().toString().trim(); TopographicPoint topographicPointValue = googleMap.getMarkerPosition(); Collection<String> presettingValues = (Collection<String>) twinColSelect.getValue(); if (exactTimeValue) { endTimeValue = startTimeValue; } TimeRange timeRange = new TimeRange(new DateTime(startTimeValue), new DateTime(endTimeValue)); UploadSettings uploadSettings = new UploadSettings(titleValue, descriptionValue, licenseValue, new Vector<String>(tags), topographicPointValue, timeRange); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.upload(uploadSettings, new Vector<String>(presettingValues)); } } }); uploadButton.setStyleName(Reindeer.BUTTON_DEFAULT); uploadButtonLayout.addComponent(uploadButton); buttonLayout.addComponent(uploadButtonLayout); HorizontalLayout cancelButtonLayout = new HorizontalLayout(); cancelButtonLayout.setMargin(false, true, false, false); cancelButton = new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = -2565870159504952913L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelUpload(); } }); cancelButton.setStyleName(Reindeer.BUTTON_DEFAULT); cancelButtonLayout.addComponent(cancelButton); buttonLayout.addComponent(cancelButtonLayout); cancelAllButton = new Button("Cancel All", new Button.ClickListener() { private static final long serialVersionUID = -8578124709201789182L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelAllUploads(); } }); cancelAllButton.setStyleName(Reindeer.BUTTON_DEFAULT); buttonLayout.addComponent(cancelAllButton); mainLayout.addComponent(buttonLayout); mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER); wrapperLayout.addComponent(mainLayout); }