List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:com.hack23.cia.web.impl.ui.application.views.common.formfactory.impl.FormFactoryImpl.java
License:Apache License
@Override public <T extends Serializable> void addRequestInputFormFields(final FormLayout panelContent, final BeanItem<T> item, final Class<T> beanType, final List<String> displayProperties, final String buttonLabel, final ClickListener buttonListener) { final BeanFieldGroup<T> fieldGroup = new BeanFieldGroup<>(beanType); fieldGroup.setItemDataSource(item);/*from w ww.j a v a 2s . c o m*/ fieldGroup.setReadOnly(true); for (final String property : displayProperties) { final Field<?> buildAndBind; if (property.contains(HIDDEN_FIELD_NAME)) { buildAndBind = fieldGroup.buildAndBind(property, property, PasswordField.class); } else { buildAndBind = fieldGroup.buildAndBind(property); } buildAndBind.setId(MessageFormat.format("{0}.{1}", buttonLabel, property)); buildAndBind.setReadOnly(false); buildAndBind.setWidth(ContentSize.HALF_SIZE); panelContent.addComponent(buildAndBind); } final Collection<Object> unboundPropertyIds = fieldGroup.getUnboundPropertyIds(); for (final Object property : unboundPropertyIds) { LOGGER.debug(LOG_MSG_PROPERTY, property); } final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setWidth("50%"); final Button button = new Button(buttonLabel, new CommitFormWrapperClickListener(fieldGroup, buttonListener)); button.setId(buttonLabel); button.setWidth("25%"); button.setIcon(FontAwesome.PAW); verticalLayout.addComponent(button); verticalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT); panelContent.addComponent(verticalLayout); }
From source file:com.haulmont.cuba.web.AppUI.java
License:Apache License
protected void showCriticalExceptionMessage(Exception exception) { String initErrorCaption = messages.getMainMessage("app.initErrorCaption"); String initErrorMessage = messages.getMainMessage("app.initErrorMessage"); VerticalLayout content = new VerticalLayout(); content.setStyleName("c-init-error-view"); content.setSizeFull();/*w w w. j av a 2s . co m*/ VerticalLayout errorPanel = new VerticalLayout(); errorPanel.setStyleName("c-init-error-panel"); errorPanel.setWidthUndefined(); errorPanel.setSpacing(true); Label captionLabel = new Label(initErrorCaption); captionLabel.setWidthUndefined(); captionLabel.setStyleName("c-init-error-caption"); captionLabel.addStyleName("h2"); captionLabel.setValue(initErrorCaption); errorPanel.addComponent(captionLabel); Label messageLabel = new Label(initErrorCaption); messageLabel.setWidthUndefined(); messageLabel.setStyleName("c-init-error-message"); messageLabel.setValue(initErrorMessage); errorPanel.addComponent(messageLabel); Button retryButton = new Button(messages.getMainMessage("app.initRetry")); retryButton.setStyleName("c-init-error-retry"); retryButton.addClickListener(event -> { // always restart UI String url = ControllerUtils.getLocationWithoutParams() + "?restartApp"; getPage().open(url, "_self"); }); errorPanel.addComponent(retryButton); errorPanel.setComponentAlignment(retryButton, Alignment.MIDDLE_CENTER); content.addComponent(errorPanel); content.setComponentAlignment(errorPanel, Alignment.MIDDLE_CENTER); setContent(content); }
From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java
License:Apache License
protected void showNoUserSessionDialog(App app) { Messages messages = AppBeans.get(Messages.NAME); Window dialog = new NoUserSessionExceptionDialog(); dialog.setStyleName("c-nousersession-dialog"); dialog.setCaption(messages.getMainMessage("dialogs.Information", locale)); dialog.setClosable(false);/*from www . j ava2 s . c om*/ dialog.setResizable(false); dialog.setModal(true); AppUI ui = app.getAppUI(); if (ui.isTestMode()) { dialog.setCubaId("optionDialog"); dialog.setId(ui.getTestIdManager().getTestId("optionDialog")); } Label messageLab = new CubaLabel(); messageLab.setWidthUndefined(); messageLab.setValue(messages.getMainMessage("noUserSession.message", locale)); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setWidthUndefined(); layout.setStyleName("c-nousersession-dialog-layout"); layout.setSpacing(true); dialog.setContent(layout); Button reloginBtn = new Button(); if (ui.isTestMode()) { reloginBtn.setCubaId("reloginBtn"); reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn")); } reloginBtn.addStyleName(WebButton.ICON_STYLE); reloginBtn.addStyleName("c-primary-action"); reloginBtn.addClickListener(event -> relogin()); reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey())); String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey()); reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName)); ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class); setClickShortcut(reloginBtn, clientConfig.getCommitShortcut()); reloginBtn.focus(); layout.addComponent(messageLab); layout.addComponent(reloginBtn); layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT); ui.addWindow(dialog); dialog.center(); }
From source file:com.haulmont.cuba.web.gui.components.presentations.PresentationEditor.java
License:Apache License
protected void initLayout() { ThemeConstants theme = App.getInstance().getThemeConstants(); VerticalLayout root = new VerticalLayout(); root.setWidthUndefined();//from w w w. j a v a 2s . c om root.setSpacing(true); setContent(root); messages = AppBeans.get(Messages.class); nameField = new TextField(messages.getMainMessage("PresentationsEditor.name")); nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width")); nameField.setValue(getPresentationCaption()); root.addComponent(nameField); autoSaveField = new CheckBox(); autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave")); autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave())); root.addComponent(autoSaveField); defaultField = new CheckBox(); defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default")); defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId())); root.addComponent(defaultField); if (allowGlobalPresentations) { globalField = new CheckBox(); globalField.setCaption(messages.getMainMessage("PresentationsEditor.global")); globalField.setValue(!isNew && presentation.getUser() == null); root.addComponent(globalField); } HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setWidthUndefined(); root.addComponent(buttons); root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT); Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save")); commitButton.addClickListener(event -> { if (validate()) { commit(); close(); } }); buttons.addComponent(commitButton); Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close")); closeButton.addClickListener(event -> { close(); }); buttons.addComponent(closeButton); nameField.focus(); }
From source file:com.haulmont.cuba.web.LoginWindow.java
License:Apache License
protected VerticalLayout createCenterLayout(int formWidth, int formHeight, int fieldWidth, boolean localesSelectVisible) { VerticalLayout centerLayout = new VerticalLayout(); centerLayout.setStyleName("cuba-login-bottom"); centerLayout.setWidth(formWidth + "px"); centerLayout.setHeight(formHeight + "px"); HorizontalLayout titleLayout = createTitleLayout(); centerLayout.addComponent(titleLayout); centerLayout.setComponentAlignment(titleLayout, Alignment.MIDDLE_CENTER); FormLayout loginFormLayout = createLoginFormLayout(fieldWidth, localesSelectVisible); centerLayout.addComponent(loginFormLayout); centerLayout.setComponentAlignment(loginFormLayout, Alignment.MIDDLE_CENTER); return centerLayout; }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showMessageDialog(String title, String message, MessageType messageType) { backgroundWorker.checkUIAccess();/*from w ww.j a v a 2 s. c om*/ final com.vaadin.ui.Window vWindow = new CubaWindow(title); if (ui.isTestMode()) { vWindow.setCubaId("messageDialog"); vWindow.setId(ui.getTestIdManager().getTestId("messageDialog")); } String closeShortcut = clientConfig.getCloseShortcut(); KeyCombination closeCombination = KeyCombination.create(closeShortcut); vWindow.addAction(new ShortcutListener("Esc", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers())) { @Override public void handleAction(Object sender, Object target) { vWindow.close(); } }); vWindow.addAction(new ShortcutListener("Enter", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { vWindow.close(); } }); VerticalLayout layout = new VerticalLayout(); layout.setStyleName("c-app-message-dialog"); layout.setSpacing(true); if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { layout.setWidthUndefined(); } vWindow.setContent(layout); Label messageLab = new CubaLabel(); messageLab.setValue(message); if (MessageType.isHTML(messageType)) { messageLab.setContentMode(ContentMode.HTML); } else { messageLab.setContentMode(ContentMode.TEXT); } if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { messageLab.setWidthUndefined(); } layout.addComponent(messageLab); DialogAction action = new DialogAction(Type.OK); Button button = WebComponentsHelper.createButton(); button.setCaption(action.getCaption()); button.setIcon(WebComponentsHelper.getIcon(action.getIcon())); button.addStyleName(WebButton.ICON_STYLE); button.addClickListener(event -> vWindow.close()); button.focus(); layout.addComponent(button); layout.setComponentAlignment(button, Alignment.BOTTOM_RIGHT); float width; SizeUnit unit; DialogParams dialogParams = getDialogParams(); if (messageType.getWidth() != null) { width = messageType.getWidth(); unit = messageType.getWidthUnit(); } else if (dialogParams.getWidth() != null) { width = dialogParams.getWidth(); unit = dialogParams.getWidthUnit(); } else { SizeWithUnit size = SizeWithUnit .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.messageDialog.width")); width = size.getSize(); unit = size.getUnit(); } vWindow.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS); vWindow.setResizable(false); boolean modal = true; if (!hasModalWindow()) { if (messageType.getModal() != null) { modal = messageType.getModal(); } else if (dialogParams.getModal() != null) { modal = dialogParams.getModal(); } } vWindow.setModal(modal); boolean closeOnClickOutside = false; if (vWindow.isModal()) { if (messageType.getCloseOnClickOutside() != null) { closeOnClickOutside = messageType.getCloseOnClickOutside(); } } ((CubaWindow) vWindow).setCloseOnClickOutside(closeOnClickOutside); if (messageType.getMaximized() != null) { if (messageType.getMaximized()) { vWindow.setWindowMode(WindowMode.MAXIMIZED); } else { vWindow.setWindowMode(WindowMode.NORMAL); } } dialogParams.reset(); ui.addWindow(vWindow); vWindow.center(); vWindow.focus(); }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showOptionDialog(String title, String message, MessageType messageType, Action[] actions) { backgroundWorker.checkUIAccess();/* ww w . ja va 2 s . co m*/ final com.vaadin.ui.Window window = new CubaWindow(title); if (ui.isTestMode()) { window.setCubaId("optionDialog"); window.setId(ui.getTestIdManager().getTestId("optionDialog")); } window.setClosable(false); Label messageLab = new CubaLabel(); messageLab.setValue(message); if (MessageType.isHTML(messageType)) { messageLab.setContentMode(ContentMode.HTML); } else { messageLab.setContentMode(ContentMode.TEXT); } if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { messageLab.setWidthUndefined(); } float width; SizeUnit unit; if (messageType.getWidth() != null) { width = messageType.getWidth(); unit = messageType.getWidthUnit(); } else if (getDialogParams().getWidth() != null) { width = getDialogParams().getWidth(); unit = getDialogParams().getWidthUnit(); } else { SizeWithUnit size = SizeWithUnit .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.optionDialog.width")); width = size.getSize(); unit = size.getUnit(); } if (messageType.getModal() != null) { log.warn("MessageType.modal is not supported for showOptionDialog"); } getDialogParams().reset(); window.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS); window.setResizable(false); window.setModal(true); boolean closeOnClickOutside = false; if (window.isModal()) { if (messageType.getCloseOnClickOutside() != null) { closeOnClickOutside = messageType.getCloseOnClickOutside(); } } ((CubaWindow) window).setCloseOnClickOutside(closeOnClickOutside); if (messageType.getMaximized() != null) { if (messageType.getMaximized()) { window.setWindowMode(WindowMode.MAXIMIZED); } else { window.setWindowMode(WindowMode.NORMAL); } } VerticalLayout layout = new VerticalLayout(); layout.setStyleName("c-app-option-dialog"); layout.setSpacing(true); if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { layout.setWidthUndefined(); } window.setContent(layout); HorizontalLayout buttonsContainer = new HorizontalLayout(); buttonsContainer.setSpacing(true); boolean hasPrimaryAction = false; Map<Action, Button> buttonMap = new HashMap<>(); for (Action action : actions) { Button button = WebComponentsHelper.createButton(); button.setCaption(action.getCaption()); button.addClickListener(event -> { try { action.actionPerform(null); } finally { ui.removeWindow(window); } }); if (StringUtils.isNotEmpty(action.getIcon())) { button.setIcon(WebComponentsHelper.getIcon(action.getIcon())); button.addStyleName(WebButton.ICON_STYLE); } if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) { button.addStyleName("c-primary-action"); button.focus(); hasPrimaryAction = true; } if (ui.isTestMode()) { button.setCubaId("optionDialog_" + action.getId()); button.setId(ui.getTestIdManager().getTestId("optionDialog_" + action.getId())); } buttonsContainer.addComponent(button); buttonMap.put(action, button); } assignDialogShortcuts(buttonMap); if (!hasPrimaryAction && actions.length > 0) { ((Button) buttonsContainer.getComponent(0)).focus(); } layout.addComponent(messageLab); layout.addComponent(buttonsContainer); layout.setExpandRatio(messageLab, 1); layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT); ui.addWindow(window); window.center(); }
From source file:com.hivesys.dashboard.view.repository.RepositoryUpload.java
public RepositoryUpload() { final Label infoLabel = new Label("asasasasasasasxasx"); final VerticalLayout dropPane = new VerticalLayout(infoLabel); dropPane.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER); dropPane.setWidth(280.0f, Unit.PIXELS); dropPane.setHeight(200.0f, Unit.PIXELS); dropPane.addStyleName("drop-area"); progress = new ProgressBar(); progress.setIndeterminate(true);/*from w ww . ja va 2s . c o m*/ progress.setVisible(false); dropPane.addComponent(progress); final DragAndDropBox dropBox = new DragAndDropBox(dropPane, progress) { @Override void processFile(String name, String type, ByteArrayOutputStream bas) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; dropBox.setSizeUndefined(); }
From source file:com.jain.addon.action.confirm.ConfirmWindow.java
License:Apache License
@JNIComponentInit public void init() { setModal(true);/* w ww . j a v a 2s.c o m*/ setWidth("25%"); VerticalLayout layout = new VerticalLayout(); setContent(layout); layout.setWidth("100%"); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName(JNStyleConstants.J_ALTERNATE_VIEW); JNConfirm confirm = action.getConfirm(); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSpacing(true); hLayout.setWidth("100%"); findNAddIcon(confirm, hLayout); Label label = new Label(confirm.message()); label.setContentMode(confirm.mode()); hLayout.addComponent(label); hLayout.setExpandRatio(label, 2); layout.addComponent(hLayout); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); ActionMenuBar<ConfirmWindow> menuBar = new ActionMenuBar<ConfirmWindow>(null, this); layout.addComponent(menuBar); layout.setExpandRatio(menuBar, 2); layout.setComponentAlignment(menuBar, Alignment.MIDDLE_CENTER); }
From source file:com.jain.addon.component.crud.JCrudWindow.java
License:Apache License
private void createActions(VerticalLayout layout) { if (!isViewOnly()) { ActionBar<JCrudWindow<T>> hLayout = new ActionBar<JCrudWindow<T>>(null, this); VerticalLayout vLayout = new VerticalLayout(); vLayout.setSizeUndefined();/*from w ww .j a v a2 s . c o m*/ vLayout.setStyleName(JNStyleConstants.J_VIEW); vLayout.addComponent(hLayout); layout.addComponent(vLayout); layout.setComponentAlignment(vLayout, Alignment.MIDDLE_CENTER); layout.setExpandRatio(vLayout, 1); } }