List of usage examples for com.vaadin.ui Embedded setWidth
@Override public void setWidth(float width, Unit unit)
From source file:org.bubblecloud.ilves.component.flow.AbstractFlowlet.java
License:Apache License
@Override public final void attach() { super.attach(); this.setSizeFull(); rootLayout = new GridLayout(1, 2); rootLayout.setMargin(false);/* w w w .j av a2 s .c o m*/ rootLayout.setSpacing(true); rootLayout.setSizeFull(); rootLayout.setRowExpandRatio(0, 0f); rootLayout.setRowExpandRatio(1, 1f); final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-" + getFlowletKey())); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h1>" + getSite().localize("view-" + getFlowletKey()) + "</h1>", ContentMode.HTML); titleLayout.addComponent(titleLabel); rootLayout.addComponent(titleLayout, 0, 0); setCompositionRoot(rootLayout); initialize(); }
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 ww w .j a v a2 s. com*/ 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.privilege.PrivilegesFlowlet.java
License:Apache License
@Override protected void initialize() { final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true);//from w w w . ja v a 2 s . co m final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-privileges")); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); titleLabel = new Label("<h1>" + getSite().localize("view-privileges") + "</h1>", ContentMode.HTML); titleLayout.addComponent(titleLabel); matrixLayout = new VerticalLayout(); matrixLayout.setSpacing(true); matrixLayout.setMargin(false); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); saveButton = getSite().getButton("save"); buttonLayout.addComponent(saveButton); saveButton.addClickListener(new Button.ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { saveGroupMatrix(); saveUserMatrix(); PrivilegeCache.flush((Company) Site.getCurrent().getSiteContext().getObject(Company.class)); } }); discardButton = getSite().getButton("discard"); buttonLayout.addComponent(discardButton); discardButton.addClickListener(new Button.ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { refreshGroupMatrix(); refreshUserMatrix(); } }); final CssLayout panel = new CssLayout(); panel.addComponent(titleLayout); panel.addComponent(matrixLayout); panel.addComponent(buttonLayout); setCompositionRoot(panel); }
From source file:org.fossa.rolp.ui.leb.LebAnzeigen.java
License:Open Source License
public LebAnzeigen(FossaApplication app, SchuelerLaso schueler, KlasseLaso klasse) throws DocumentException, IOException { super(app);/* ww w. java 2 s .co m*/ setCaption(" - Lernentwicklungsbericht anzeigen - "); VerticalLayout layout = new VerticalLayout(); setWidth("800px"); setContent(layout); layout.setSpacing(true); Embedded embeddedPdf = new Embedded(); embeddedPdf.setType(Embedded.TYPE_BROWSER); DateFormat dateFormat = new SimpleDateFormat("ddMMyy-HHmmss"); String dateiname = "Klasse" + klasse.getKlassenname() + "_" + schueler.getVorname() + "_" + schueler.getName() + "_" + dateFormat.format(new Date()) + ".pdf"; embeddedPdf.setSource(new LebCreator(app, schueler, klasse, dateiname).getLebResource()); embeddedPdf.setWidth(100, Sizeable.UNITS_PERCENTAGE); embeddedPdf.setHeight("580px"); windowCloseButton.setWidth(100, Sizeable.UNITS_PERCENTAGE); layout.addComponent(embeddedPdf); layout.addComponent(windowCloseButton); }
From source file:org.vaadin.addons.sitekit.example.FeedbackViewlet.java
License:Apache License
/** * Default constructor.//from w ww . j av a 2 s .co m */ public FeedbackViewlet() { final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister.getFieldSetDescriptor("feedback") .getFieldDescriptors(); editor = new ValidatingEditor(fieldDescriptors); final Button submitButton = new Button(getSite().localize("button-submit")); submitButton.addClickListener(new ClickListener() { /** The default serial version ID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.commit(); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); final Company company = getSite().getSiteContext().getObject(Company.class); try { Notification.show(getSite().localize("message-feedback-submit-success"), Notification.Type.HUMANIZED_MESSAGE); } catch (final Exception e) { LOGGER.error("Error adding user.", e); Notification.show(getSite().localize("message-feedback-submit-error"), Notification.Type.WARNING_MESSAGE); } reset(); } }); editor.addListener(new ValidatingEditorStateListener() { @Override public void editorStateChanged(final ValidatingEditor source) { if (source.isValid()) { submitButton.setEnabled(true); } else { submitButton.setEnabled(false); } } }); reset(); final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-feedback")); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h1>" + getSite().localize("view-feedback") + "</h1>", ContentMode.HTML); titleLayout.addComponent(titleLabel); final VerticalLayout panel = new VerticalLayout(); panel.addComponent(titleLayout); panel.addComponent(editor); panel.addComponent(submitButton); panel.setSpacing(true); panel.setMargin(true); final Panel mainLayout = new Panel(); mainLayout.setStyleName(Reindeer.PANEL_LIGHT); mainLayout.setContent(panel); setCompositionRoot(mainLayout); }
From source file:org.vaadin.addons.sitekit.flow.AbstractFlowlet.java
License:Apache License
@Override public final void attach() { super.attach(); this.setSizeFull(); rootLayout = new GridLayout(1, 2); rootLayout.setMargin(true);/*ww w. jav a 2s .com*/ rootLayout.setSpacing(true); rootLayout.setSizeFull(); rootLayout.setRowExpandRatio(0, 0f); rootLayout.setRowExpandRatio(1, 1f); final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-" + getFlowletKey())); titleIcon.setWidth(32, UNITS_PIXELS); titleIcon.setHeight(32, UNITS_PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h1>" + getSite().localize("view-" + getFlowletKey()) + "</h1>", Label.CONTENT_XHTML); titleLayout.addComponent(titleLabel); rootLayout.addComponent(titleLayout, 0, 0); setCompositionRoot(rootLayout); initialize(); }
From source file:org.vaadin.addons.sitekit.viewlet.anonymous.HorizontalNavigationViewlet.java
License:Apache License
public void refresh() { final CssLayout navigationLayout = new CssLayout(); //navigationLayout.setSpacing(true); //navigationLayout.setMargin(true); final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion(); final String[] elements = navigationVersion.getTree().split(";"); for (final String element : elements) { final int indentLastIndex = element.lastIndexOf('+'); final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1); final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName); if (pageVersion == null) { throw new SiteException("Unknown page: " + pageName); }/* w ww .j a va 2s. c o m*/ if (pageVersion.getViewerRoles().length > 0) { boolean roleMatch = false; for (final String role : pageVersion.getViewerRoles()) { if (getSite().getSecurityProvider().getRoles().contains(role)) { roleMatch = true; break; } } if (!roleMatch) { continue; } } final String localizedPageName = getSite().localize("page-link-" + pageName); final Resource iconResource = getSite().getIcon("page-icon-" + pageName); final HorizontalLayout itemLayout = new HorizontalLayout(); itemLayout.setSpacing(true); itemLayout.setMargin(false); itemLayout.setStyleName("horizontal-navigation-" + pageName); navigationLayout.addComponent(itemLayout); final int indentCount = indentLastIndex + 1; final StringBuilder indentBuilder = new StringBuilder(); for (int i = 0; i < indentCount; i++) { indentBuilder.append(" "); } final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML); itemLayout.addComponent(indent); if (iconResource != null) { final Embedded embedded = new Embedded(null, iconResource); embedded.setWidth(20, UNITS_PIXELS); embedded.setHeight(20, UNITS_PIXELS); itemLayout.addComponent(embedded); } final Button link = new Button(localizedPageName); link.setStyleName(BaseTheme.BUTTON_LINK); link.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().getNavigator().navigateTo(pageName); } }); /*if (page.getName().equals(pageName)) { link.setEnabled(false); }*/ itemLayout.addComponent(link); itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT); } if (getSite().getSecurityProvider().getUser() != null) { final HorizontalLayout itemLayout = new HorizontalLayout(); itemLayout.setStyleName("horizontal-navigation-logout"); itemLayout.setSpacing(true); itemLayout.setMargin(false); navigationLayout.addComponent(itemLayout); final int indentCount = 0; final StringBuilder indentBuilder = new StringBuilder(); for (int i = 0; i < indentCount; i++) { indentBuilder.append(" "); } final Resource iconResource = getSite().getIcon("page-icon-logout"); final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML); itemLayout.addComponent(indent); if (iconResource != null) { final Embedded embedded = new Embedded(null, iconResource); embedded.setWidth(20, UNITS_PIXELS); embedded.setHeight(20, UNITS_PIXELS); itemLayout.addComponent(embedded); } final Button logoutButton = new Button(getSite().localize("button-logout")); logoutButton.setStyleName(BaseTheme.BUTTON_LINK); logoutButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Company company = getSite().getSiteContext().getObject(Company.class); getUI().getPage().setLocation(company.getUrl()); // Close the VaadinSession getSession().close(); } }); itemLayout.addComponent(logoutButton); itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT); } setCompositionRoot(navigationLayout); }
From source file:org.vaadin.addons.sitekit.viewlet.anonymous.ImageViewlet.java
License:Apache License
@Override public void attach() { super.attach(); final String logoImageThemeFileName = getViewletDescriptor().getConfiguration(); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(false);/*from w ww .j a va 2s.co m*/ final Embedded embedded = new Embedded(null, new ThemeResource(logoImageThemeFileName)); embedded.setWidth(32, UNITS_PIXELS); embedded.setHeight(32, UNITS_PIXELS); layout.addComponent(embedded); layout.setComponentAlignment(embedded, Alignment.MIDDLE_CENTER); this.setCompositionRoot(layout); }
From source file:org.vaadin.addons.sitekit.viewlet.anonymous.VerticalNavigationViewlet.java
License:Apache License
public void refresh() { final VerticalLayout navigationLayout = new VerticalLayout(); navigationLayout.setSpacing(true);/* w ww .ja va 2s . c o m*/ navigationLayout.setMargin(true); final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion(); //final ViewDescriptor page = getPageWindow().getViewDescriptor(); final String[] elements = navigationVersion.getTree().split(";"); for (final String element : elements) { final int indentLastIndex = element.lastIndexOf('+'); final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1); final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName); if (pageVersion == null) { throw new SiteException("Unknown page: " + pageName); } if (pageVersion.getViewerRoles().length > 0) { boolean roleMatch = false; for (final String role : pageVersion.getViewerRoles()) { if (getSite().getSecurityProvider().getRoles().contains(role)) { roleMatch = true; break; } } if (!roleMatch) { continue; } } final String localizedPageName = getSite().localize("page-link-" + pageName); final Resource iconResource = getSite().getIcon("page-icon-" + pageName); final HorizontalLayout itemLayout = new HorizontalLayout(); itemLayout.setSpacing(true); itemLayout.setMargin(false); navigationLayout.addComponent(itemLayout); final int indentCount = indentLastIndex + 1; final StringBuilder indentBuilder = new StringBuilder(); for (int i = 0; i < indentCount; i++) { indentBuilder.append(" "); } final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML); itemLayout.addComponent(indent); if (iconResource != null) { final Embedded embedded = new Embedded(null, iconResource); embedded.setWidth(32, UNITS_PIXELS); embedded.setHeight(32, UNITS_PIXELS); itemLayout.addComponent(embedded); } final Button link = new Button(localizedPageName); link.setStyleName(BaseTheme.BUTTON_LINK); link.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().getNavigator().navigateTo(pageName); } }); /*if (page.getName().equals(pageName)) { link.setEnabled(false); }*/ itemLayout.addComponent(link); itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT); } if (getSite().getSecurityProvider().getUser() != null) { final HorizontalLayout itemLayout = new HorizontalLayout(); itemLayout.setSpacing(true); itemLayout.setMargin(false); navigationLayout.addComponent(itemLayout); final int indentCount = 0; final StringBuilder indentBuilder = new StringBuilder(); for (int i = 0; i < indentCount; i++) { indentBuilder.append(" "); } final Resource iconResource = getSite().getIcon("page-icon-logout"); final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML); itemLayout.addComponent(indent); if (iconResource != null) { final Embedded embedded = new Embedded(null, iconResource); embedded.setWidth(32, UNITS_PIXELS); embedded.setHeight(32, UNITS_PIXELS); itemLayout.addComponent(embedded); } final Button logoutButton = new Button(getSite().localize("button-logout")); logoutButton.setStyleName(BaseTheme.BUTTON_LINK); logoutButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Company company = getSite().getSiteContext().getObject(Company.class); getUI().getPage().setLocation(company.getUrl()); // Close the VaadinSession getSession().close(); } }); itemLayout.addComponent(logoutButton); itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT); } setCompositionRoot(navigationLayout); }
From source file:org.vaadin.addons.sitekit.viewlet.user.AccountFlowlet.java
License:Apache License
@Override public void initialize() { 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()); }/* w w w . j a v a 2s . c o m*/ 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(); 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, UNITS_PIXELS); userAccountTitleIcon.setHeight(32, UNITS_PIXELS); userAccountTitle.addComponent(userAccountTitleIcon); final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", Label.CONTENT_XHTML); userAccountTitle.addComponent(userAccountTitleLabel); gridLayout.addComponent(userAccountTitle, 0, 0); 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, UNITS_PIXELS); titleIcon.setHeight(32, UNITS_PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h2>Customer Accounts</h2>", Label.CONTENT_XHTML); titleLayout.addComponent(titleLabel); gridLayout.addComponent(titleLayout, 0, 3); final Table table = new Table(); table.setPageLength(10); 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 Button editUserButton = new Button("Edit User Account"); editUserButton.setIcon(getSite().getIcon("button-icon-edit")); gridLayout.addComponent(editUserButton, 0, 2); editUserButton.addListener(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 Panel openIdPanel = new Panel(); openIdPanel.setStyleName(Reindeer.PANEL_LIGHT); openIdPanel.setCaption("Choose OpenID Provider:"); gridLayout.addComponent(openIdPanel, 0, 1); final HorizontalLayout openIdLayout = new HorizontalLayout(); openIdPanel.setContent(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)); } } 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.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { 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.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { 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.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { 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); } }); }