List of usage examples for com.vaadin.shared.ui MarginInfo MarginInfo
public MarginInfo(MarginInfo other)
From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
private void buildShortcutIconPanel() { FormContainer formContainer = new FormContainer(); MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true)); MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false); Label logoDesc = new Label(AppContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION)); leftPanel.with(logoDesc).withWidth("250px"); MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false); final Image favIconRes = new Image("", new ExternalResource(StorageFactory.getInstance() .getFavIconPath(billingAccount.getId(), billingAccount.getFaviconpath()))); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, false, false)); buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT); final UploadField favIconUploadField = new UploadField() { private static final long serialVersionUID = 1L; @Override//from ww w . j a v a 2 s . c o m protected void updateDisplay() { byte[] imageData = (byte[]) this.getValue(); String mimeType = this.getLastMimeType(); if (mimeType.equals("image/jpeg")) { imageData = ImageUtil.convertJpgToPngFormat(imageData); if (imageData == null) { throw new UserInvalidInputException( AppContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT)); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { try { AccountFavIconService favIconService = AppContextUtil .getSpringBean(AccountFavIconService.class); BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData)); String newFavIconPath = favIconService.upload(AppContext.getUsername(), image, AppContext.getAccountId()); favIconRes.setSource(new ExternalResource(StorageFactory.getInstance() .getFavIconPath(billingAccount.getId(), newFavIconPath))); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException(e); } } else { throw new UserInvalidInputException( AppContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; favIconUploadField.setButtonCaption(AppContext.getMessage(GenericI18Enum.ACTION_CHANGE)); favIconUploadField.addStyleName("upload-field"); favIconUploadField.setSizeUndefined(); favIconUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); favIconUploadField.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); Button resetButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { BillingAccountService billingAccountService = AppContextUtil .getSpringBean(BillingAccountService.class); billingAccount.setFaviconpath(null); billingAccountService.updateWithSession(billingAccount, AppContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } }); resetButton.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); resetButton.setStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(favIconUploadField, resetButton); rightPanel.with(favIconRes, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Favicon", layout); this.with(formContainer); }
From source file:com.google.code.vaadin.internal.preconfigured.VaadinComponentsInjector.java
License:Apache License
/** * Applies {@link Preconfigured} attributes to Vaadin Components. * * @param c component to configure/*from w w w . j a v a 2s.com*/ * * @return configured component */ @SuppressWarnings("OverlyComplexMethod") private <T extends Component> T configureComponent(T c) { T component = c; if (!preconfigured.implementation().equals(Component.class)) { if (component.getClass().isAssignableFrom(preconfigured.implementation())) { try { component = (T) preconfigured.implementation().newInstance(); } catch (Exception e) { throw new MVPApplicationException(e); } } } configureComponentApi(component, preconfigured); if (component instanceof com.vaadin.ui.Field) { configureFieldApi((com.vaadin.ui.Field) component, preconfigured); } if (component instanceof AbstractField) { configureAbstractFieldApi((AbstractField) component, preconfigured); } if (component instanceof AbstractComponent) { ((AbstractComponent) component).setImmediate(preconfigured.immediate()); } if (component instanceof AbstractSelect) { configureAbstractSelectApi((AbstractSelect) component, preconfigured); } MarginInfo mi = null; boolean[] margin = preconfigured.margin(); if (margin.length == 1) { mi = new MarginInfo(margin[0]); } else if (margin.length == 2) { mi = new MarginInfo(margin[0], margin[1], margin[0], margin[1]); } else if (margin.length == 3) { mi = new MarginInfo(margin[0], margin[1], margin[2], margin[1]); } else if (margin.length == 4) { mi = new MarginInfo(margin[0], margin[1], margin[2], margin[3]); } if (mi != null) { if (component instanceof AbstractOrderedLayout) { ((AbstractOrderedLayout) component).setMargin(mi); } else if (component instanceof GridLayout) { ((GridLayout) component).setMargin(mi); } } if (component instanceof AbstractOrderedLayout) { ((AbstractOrderedLayout) component).setSpacing(preconfigured.spacing()); } return component; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.cssactionslayout.CubaCssActionsLayoutConnector.java
License:Apache License
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); getWidget().setMargin(new MarginInfo(getState().marginsBitmask)); getWidget().setSpacing(getState().spacing); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.groupbox.CubaGroupBoxConnector.java
License:Apache License
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); CubaGroupBoxWidget widget = getWidget(); if (!widgetInitialized) { widget.init();//from ww w .j av a2 s. co m if (!getState().showAsPanel) { LayoutManager layoutManager = getLayoutManager(); layoutManager.registerDependency(this, widget.captionStartDeco); layoutManager.registerDependency(this, widget.captionEndDeco); layoutManager.registerDependency(this, widget.captionTextNode); } widgetInitialized = true; } widget.setCollapsable(getState().collapsable); widget.setExpanded(getState().expanded); widget.setShowAsPanel(getState().showAsPanel); if (!getState().showAsPanel) { widget.setOuterMargin(new MarginInfo(getState().outerMarginsBitmask)); } if (stateChangeEvent.hasPropertyChanged("caption")) { widget.captionNode.getStyle().clearWidth(); getLayoutManager().setNeedsMeasure(this); } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaCssActionsLayout.java
License:Apache License
@Override public void setMargin(boolean enabled) { setMargin(new MarginInfo(enabled)); }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaCssActionsLayout.java
License:Apache License
@Override public MarginInfo getMargin() { return new MarginInfo(getState().marginsBitmask); }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaGroupBox.java
License:Apache License
public MarginInfo getOuterMargin() { return new MarginInfo(getState(false).outerMarginsBitmask); }
From source file:com.jain.addon.web.layout.JainGroupLayout.java
License:Apache License
/** * Create a instance with number of columns <br/> * Default spacing and margin will be enabled * @param columns//from w ww .j a v a2 s. c o m */ public JainGroupLayout(int columns) { this(true, new MarginInfo(true), columns); }
From source file:com.jain.addon.web.layout.JainLayout.java
License:Apache License
/** * Create a instance with number of columns <br/> * Default spacing and margin will be enabled * @param columns//from w ww . j av a2s. c o m */ public JainLayout(int columns) { this(true, new MarginInfo(true), columns); }
From source file:com.jain.addon.web.layout.JainPanelLayout.java
License:Apache License
/** * Create a instance with number of columns <br/> * Default spacing and margin will be enabled * @param columns/* w ww .j a va 2s . c om*/ */ public JainPanelLayout(int columns) { this(true, new MarginInfo(true), columns); }