List of usage examples for com.vaadin.ui Alignment TOP_LEFT
Alignment TOP_LEFT
To view the source code for com.vaadin.ui Alignment TOP_LEFT.
Click Source Link
From source file:com.esofthead.mycollab.module.user.ui.components.ImagePreviewCropWindow.java
License:Open Source License
public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) { super("Preview and modify image"); setModal(true);// w ww .j av a 2 s .co m setResizable(false); setWidth("700px"); center(); MVerticalLayout content = new MVerticalLayout(); setContent(content); try { originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(false, true, true, false)).withFullWidth(); previewPhoto = new VerticalLayout(); previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); previewPhoto.setWidth("100px"); previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT); VerticalLayout previewBoxTitle = new VerticalLayout(); previewBoxTitle.setMargin(new MarginInfo(false, true, false, true)); Label lbPreview = new Label("<p style='margin: 0px;'><strong>To the bottom is what your profile photo will " + "look like.</strong></p>" + "<p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. " + "When you are happy with your photo, click the “Accept“ button.</p>", ContentMode.HTML); previewBoxTitle.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); imageSelectionCommand.process(image); close(); } catch (IOException e) { throw new MyCollabException("Error when saving user avatar", e); } } } }); acceptBtn.setStyleName(UIConstants.BUTTON_ACTION); acceptBtn.setIcon(FontAwesome.CHECK); controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT); previewBoxTitle.addComponent(controlBtns); previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT); previewBox.with(previewBoxTitle).expand(previewBoxTitle); CssLayout cropBox = new CssLayout(); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(1.0f); cropField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { VCropSelection newSelection = (VCropSelection) event.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } } }); currentPhotoBox.setWidth("520px"); currentPhotoBox.setHeight("470px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); displayPreviewImage(); }
From source file:com.esofthead.mycollab.vaadin.ui.AddViewLayout2.java
License:Open Source License
public AddViewLayout2(final String title, final Resource icon) { setStyleName("addview-layout"); this.viewIcon = icon; this.header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withWidth("100%") .withStyleName(UIConstants.HEADER_VIEW); this.header.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (!(icon instanceof FontAwesome)) { Image iconEmbed = new Image(); iconEmbed.setSource(icon);/*from ww w. j a va 2 s .c o m*/ this.header.with(iconEmbed); } this.titleLbl = new Label("", ContentMode.HTML); this.titleLbl.setStyleName(UIConstants.HEADER_TEXT); this.header.with(this.titleLbl).expand(titleLbl); if (title == null) { if (icon != null) { this.setTitle("Undefined"); } } else { this.setTitle(title); } this.addComponent(header); body = new MVerticalLayout().withSpacing(false).withMargin(false).withStyleName("addview-layout-body"); this.addComponent(body); }
From source file:com.esofthead.mycollab.vaadin.ui.GridFormLayoutHelper.java
License:Open Source License
public GridFormLayoutHelper(final int columns, final int rows) { this(columns, rows, UIConstants.DEFAULT_CONTROL_WIDTH, UIConstants.DEFAULT_CAPTION_FORM_WIDTH, Alignment.TOP_LEFT); }
From source file:com.esofthead.mycollab.vaadin.web.ui.AddViewLayout.java
License:Open Source License
public void addHeaderTitle(ComponentContainer headerContainer) { header.addComponent(headerContainer, 0); header.setComponentAlignment(headerContainer, Alignment.TOP_LEFT); header.setExpandRatio(headerContainer, 1.0f); }
From source file:com.esofthead.mycollab.vaadin.web.ui.AddViewLayout2.java
License:Open Source License
public AddViewLayout2(String title, Resource icon) { this.setMargin(new MarginInfo(false, false, true, false)); setStyleName("addview-layout"); this.viewIcon = icon; header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)).withFullWidth(); header.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (!(icon instanceof FontAwesome)) { Image iconEmbed = new Image(); iconEmbed.setSource(icon);/*from ww w . j a va 2 s . c o m*/ header.with(iconEmbed); } titleLbl = ELabel.h2(""); header.with(titleLbl).expand(titleLbl); if (title == null) { if (icon != null) { this.setTitle("Undefined"); } } else { this.setTitle(title); } this.addComponent(header); body = new MVerticalLayout().withSpacing(false).withMargin(false).withStyleName("addview-layout-body"); this.addComponent(body); }
From source file:com.esofthead.mycollab.vaadin.web.ui.BuildCriterionComponent.java
License:Open Source License
public BuildCriterionComponent(GenericSearchPanel.SearchLayout<S> searchLayout, Param[] paramFields, Class<S> type, String searchCategory) { this.hostSearchLayout = searchLayout; this.paramFields = paramFields; this.type = type; this.searchCategory = searchCategory; MHorizontalLayout headerBox = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, true)); headerBox.setDefaultComponentAlignment(Alignment.TOP_LEFT); addComponent(headerBox);// w w w . j a v a 2 s . c o m Label filterLbl = new Label(AppContext.getMessage(GenericI18Enum.OPT_SAVED_FILTER)); headerBox.with(filterLbl).withAlign(filterLbl, Alignment.TOP_LEFT); filterBox = new MHorizontalLayout(); headerBox.with(filterBox).withAlign(filterBox, Alignment.TOP_LEFT); buildFilterBox(null); searchContainer = new MVerticalLayout().withMargin(false); searchContainer.setDefaultComponentAlignment(Alignment.TOP_LEFT); MHorizontalLayout controlsBtn = new MHorizontalLayout().withMargin(true); Button addCriteriaBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD_CRITERIA), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { CriteriaSelectionLayout newCriteriaBar = new CriteriaSelectionLayout( searchContainer.getComponentCount() + 1); searchContainer.addComponent(newCriteriaBar); } }); addCriteriaBtn.setStyleName(UIConstants.BUTTON_ACTION); addCriteriaBtn.setIcon(FontAwesome.PLUS); controlsBtn.with(addCriteriaBtn); this.with(searchContainer, controlsBtn); }
From source file:com.esofthead.mycollab.vaadin.web.ui.DefaultDynaFormLayout.java
License:Open Source License
@Override public ComponentContainer getLayout() { FormContainer layout = new FormContainer(); int sectionCount = dynaForm.getSectionCount(); sectionMappings = new HashMap<>(); for (int i = 0; i < sectionCount; i++) { DynaSection section = dynaForm.getSection(i); if (section.isDeletedSection()) { continue; }//from w ww.j a v a 2 s . c o m if (StringUtils.isNotBlank(section.getHeader())) { Label header = new Label(section.getHeader()); MCssLayout formSection = new MCssLayout(header).withStyleName(UIConstants.FORM_SECTION) .withFullWidth(); formSection.addStyleName(UIConstants.HOVER_EFFECT_NOT_BOX); layout.addComponent(formSection); } GridFormLayoutHelper gridLayout; if (section.isDeletedSection() || section.getFieldCount() == 0) { continue; } if (section.getLayoutType() == LayoutType.ONE_COLUMN) { gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1); for (int j = 0; j < section.getFieldCount(); j++) { AbstractDynaField dynaField = section.getField(j); if (!excludeFields.contains(dynaField.getFieldName())) { gridLayout.buildCell(dynaField.getDisplayName(), dynaField.getContextHelp(), 0, gridLayout.getRows() - 1, 2, "100%", Alignment.TOP_LEFT); if (j < section.getFieldCount() - 1) { gridLayout.appendRow(); } if (dynaField.isCustom()) { fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField); } else { fieldMappings.put(dynaField.getFieldName(), dynaField); } } } } else if (section.getLayoutType() == LayoutType.TWO_COLUMN) { gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1); int columnIndex = 0; for (int j = 0; j < section.getFieldCount(); j++) { AbstractDynaField dynaField = section.getField(j); if (!excludeFields.contains(dynaField.getFieldName())) { if (dynaField.isColSpan()) { if (columnIndex > 0) { gridLayout.appendRow(); } gridLayout.buildCell(dynaField.getDisplayName(), dynaField.getContextHelp(), 0, gridLayout.getRows() - 1, 2, "100%", Alignment.TOP_LEFT); columnIndex = 0; if (j < section.getFieldCount() - 1) { gridLayout.appendRow(); } } else { gridLayout.buildCell(dynaField.getDisplayName(), dynaField.getContextHelp(), columnIndex, gridLayout.getRows() - 1); columnIndex++; if (columnIndex == 2) { columnIndex = 0; if (j < section.getFieldCount() - 1) { gridLayout.appendRow(); } } } if (dynaField.isCustom()) { fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField); } else { fieldMappings.put(dynaField.getFieldName(), dynaField); } } } } else { throw new MyCollabException("Does not support attachForm layout except 1 or 2 columns"); } layout.addComponent(gridLayout.getLayout()); sectionMappings.put(section, gridLayout); } return layout; }
From source file:com.esofthead.mycollab.vaadin.web.ui.DynaFormLayout.java
License:Open Source License
@Override public ComponentContainer getLayout() { FormContainer layout = new FormContainer(); int sectionCount = dynaForm.getSectionCount(); sectionMappings = new HashMap<>(); for (int i = 0; i < sectionCount; i++) { DynaSection section = dynaForm.getSection(i); if (section.isDeletedSection()) { continue; }/*from ww w .ja va 2s.c om*/ if (StringUtils.isNotBlank(section.getHeader())) { Label header = new Label(section.getHeader()); MCssLayout formSection = new MCssLayout(header).withStyleName(UIConstants.FORM_SECTION) .withFullWidth(); layout.addComponent(formSection); } GridFormLayoutHelper gridLayout; if (section.isDeletedSection() || section.getFieldCount() == 0) { continue; } if (section.getLayoutType() == LayoutType.ONE_COLUMN) { gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1); for (int j = 0; j < section.getFieldCount(); j++) { AbstractDynaField dynaField = section.getField(j); if (!excludeFields.contains(dynaField.getFieldName())) { gridLayout.buildCell(dynaField.getDisplayName(), 0, gridLayout.getRows() - 1, 2, "100%", Alignment.TOP_LEFT); if (j < section.getFieldCount() - 1) { gridLayout.appendRow(); } if (dynaField.isCustom()) { fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField); } else { fieldMappings.put(dynaField.getFieldName(), dynaField); } } } } else if (section.getLayoutType() == LayoutType.TWO_COLUMN) { gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1); int columnIndex = 0; for (int j = 0; j < section.getFieldCount(); j++) { AbstractDynaField dynaField = section.getField(j); if (!excludeFields.contains(dynaField.getFieldName())) { if (dynaField.isColSpan()) { if (columnIndex > 0) { gridLayout.appendRow(); } gridLayout.buildCell(dynaField.getDisplayName(), 0, gridLayout.getRows() - 1, 2, "100%", Alignment.TOP_LEFT); columnIndex = 0; if (j < section.getFieldCount() - 1) { gridLayout.appendRow(); } } else { gridLayout.buildCell(dynaField.getDisplayName(), columnIndex, gridLayout.getRows() - 1); columnIndex++; if (columnIndex == 2) { columnIndex = 0; if (j < section.getFieldCount() - 1) { gridLayout.appendRow(); } } } if (dynaField.isCustom()) { fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField); } else { fieldMappings.put(dynaField.getFieldName(), dynaField); } } } } else { throw new MyCollabException("Does not support attachForm layout except 1 or 2 columns"); } layout.addComponent(gridLayout.getLayout()); sectionMappings.put(section, gridLayout); } return layout; }
From source file:com.esofthead.mycollab.vaadin.web.ui.grid.GridFormLayoutHelper.java
License:Open Source License
public static GridFormLayoutHelper defaultFormLayoutHelper(int columns, int rows, String controlWidth) { GridFormLayoutHelper helper = new GridFormLayoutHelper(columns, rows, "100%", controlWidth, Alignment.TOP_LEFT); helper.getLayout().setWidth("100%"); helper.getLayout().addStyleName(UIConstants.GRIDFORM_STANDARD); return helper; }
From source file:com.esofthead.mycollab.vaadin.web.ui.MultiSelectComp.java
License:Open Source License
@Override protected Component initContent() { MHorizontalLayout content = new MHorizontalLayout().withSpacing(true).withWidth(widthVal) .with(componentsText).withAlign(componentsText, Alignment.MIDDLE_LEFT); componentPopupSelection.addStyleName(UIConstants.MULTI_SELECT_BG); componentPopupSelection.setDirection(Alignment.TOP_LEFT); MHorizontalLayout multiSelectComp = new MHorizontalLayout().withSpacing(false) .with(componentsText, componentPopupSelection).expand(componentsText); content.with(multiSelectComp);/*from ww w. j a va 2s . co m*/ if (canAddNew) { Button newBtn = new Button("New", new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { requestAddNewComp(); } }); newBtn.setStyleName(UIConstants.BUTTON_LINK); newBtn.setWidthUndefined(); content.with(newBtn); } content.expand(multiSelectComp); return content; }