List of usage examples for com.vaadin.ui Alignment MIDDLE_CENTER
Alignment MIDDLE_CENTER
To view the source code for com.vaadin.ui Alignment MIDDLE_CENTER.
Click Source Link
From source file:com.mycollab.vaadin.web.ui.VerticalTabsheet.java
License:Open Source License
public void setNavigatorVisibility(boolean visibility) { if (!visibility) { navigatorWrapper.setWidth("65px"); navigatorContainer.setWidth("65px"); this.hideTabsCaption(); navigatorContainer.setComponentAlignment(toggleBtn, Alignment.MIDDLE_CENTER); toggleBtn.setIcon(FontAwesome.ANGLE_DOUBLE_RIGHT); toggleBtn.setStyleName(WebThemes.BUTTON_ICON_ONLY + " expand-button"); toggleBtn.setDescription(UserUIContext.getMessage(ShellI18nEnum.ACTION_EXPAND_MENU)); toggleBtn.setCaption(""); } else {/*from ww w .ja va 2s.c o m*/ navigatorWrapper.setWidth("200px"); navigatorContainer.setWidth("200px"); this.showTabsCaption(); toggleBtn.setStyleName(WebThemes.BUTTON_ICON_ONLY + " closed-button"); navigatorContainer.setComponentAlignment(toggleBtn, Alignment.TOP_RIGHT); toggleBtn.setIcon(FontAwesome.TIMES); toggleBtn.setDescription(UserUIContext.getMessage(ShellI18nEnum.ACTION_COLLAPSE_MENU)); } }
From source file:com.mycollab.web.AdWindow.java
License:Open Source License
public AdWindow() { super("Buy MyCollab Pro edition"); this.setWidth("700px"); this.setModal(true); this.setResizable(false); RestTemplate restTemplate = new RestTemplate(); MVerticalLayout content = new MVerticalLayout(); try {/*from w ww . j av a 2 s .c o m*/ String result = restTemplate.getForObject("https://api.mycollab.com/api/storeweb", String.class); Label webPage = new Label(result, ContentMode.HTML); webPage.setHeight("600px"); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } catch (Exception e) { Div informDiv = new Div() .appendText("Can not load the store page. You can check the online edition at ") .appendChild(new A("https://www.mycollab.com/pricing/download/", "_blank").appendText("here")); Label webPage = new Label(informDiv.write(), ContentMode.HTML); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { MButton editLicenseBtn = new MButton("Enter license code", clickEvent -> { Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class); UI.getCurrent().addWindow(activateWindow); close(); }).withStyleName(UIConstants.BUTTON_ACTION); content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER); } }
From source file:com.mycollab.web.BuyPremiumSoftwareWindow.java
License:Open Source License
public BuyPremiumSoftwareWindow() { super("Buy MyCollab Pro edition"); this.setWidth("700px"); this.setModal(true); this.setResizable(false); RestTemplate restTemplate = new RestTemplate(); MVerticalLayout content = new MVerticalLayout(); try {//ww w . j ava 2s . c o m String result = restTemplate.getForObject("https://api.mycollab.com/api/linktobuy", String.class); Label webPage = new Label(result, ContentMode.HTML); webPage.setHeight("600px"); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } catch (Exception e) { String result = FileUtils.readFileAsPlainString("buying.html"); Label webPage = new Label(result, ContentMode.HTML); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { MButton editLicenseBtn = new MButton("Enter license code", clickEvent -> { Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class); UI.getCurrent().addWindow(activateWindow); close(); }).withStyleName(UIConstants.BUTTON_ACTION); content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER); } }
From source file:com.mycompany.exodious.login.java
public login() { this.setId("loginPanel"); this.setSpacing(true); Image logo = new Image(); logo.setId("logo"); logo.setSource(slikaLogo);//from ww w. java 2 s.c om logo.setHeight("18em"); logo.setWidth("30em"); Label welcome = new Label("Welcome, please login"); welcome.setId("welcome"); TextField username = new TextField("Your ID"); PasswordField password = new PasswordField("Password"); Button submit = new Button("Login"); submit.setIcon(FontAwesome.SIGN_IN); submit.addStyleName(ValoTheme.BUTTON_PRIMARY); submit.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { } }); addComponents(logo, welcome, username, password, submit); setComponentAlignment(logo, Alignment.MIDDLE_CENTER); setComponentAlignment(welcome, Alignment.MIDDLE_CENTER); setComponentAlignment(username, Alignment.MIDDLE_CENTER); setComponentAlignment(password, Alignment.MIDDLE_CENTER); setComponentAlignment(submit, Alignment.MIDDLE_CENTER); }
From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java
License:Apache License
/** * Create delete tab in the accordion./*from w w w . j a va2 s . c o m*/ * * @return the component. */ @SuppressWarnings("serial") private final AbstractComponent createDelete() { /* root layout */ final VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.setMargin(true); layout.setSpacing(true); final Label label = new Label("Deleting a device can be done, only if it is de-activated."); layout.addComponent(label); label.setWidth(null); layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); final Button deleteButton = new Button("Delete"); layout.addComponent(deleteButton); layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_CENTER); deleteButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final DeviceDeleteWindow deleteWindow = new DeviceDeleteWindow(model.getItemUuid()); deleteWindow.add(model); } catch (final Exception e) { LOGGER.error("Can not delete device: ", e); } } }); return layout; }
From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java
License:Apache License
/** * Create the component to take a snapshot. * /*from w w w . java 2 s.c om*/ * @return the component */ @SuppressWarnings("serial") private final AbstractComponent createTakeSnap() { final VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); final FormLayout takeSnapLayout = new FormLayout(); takeSnapLayout.setMargin(true); takeSnapLayout.setImmediate(true); takeSnapLayout.setWidth(null); layout.addComponent(takeSnapLayout); layout.setComponentAlignment(takeSnapLayout, Alignment.MIDDLE_CENTER); // Enter name final TextField vvrName = new TextField("Name", ""); takeSnapLayout.addComponent(vvrName); // take button final Button take = new Button("Take snapshot"); layout.addComponent(take); layout.setComponentAlignment(take, Alignment.MIDDLE_CENTER); take.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { model.takeDeviceSnapshot(vvrName.getValue()); Notification.show("New snapshot created", Notification.Type.TRAY_NOTIFICATION); } catch (final Exception e) { final ErrorWindow err = new ErrorWindow("Snapshot not taken: " + e.getMessage()); err.add(model); } } }); return layout; }
From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java
License:Apache License
/** * Create the component to activate/deactivate a device. * //from w w w .java 2 s . c om * @return the component */ @SuppressWarnings("serial") private final AbstractComponent createActivate() { final VerticalLayout rootlayout = new VerticalLayout(); rootlayout.setMargin(true); rootlayout.setSpacing(true); final OptionGroup activate = new OptionGroup("Select an option: "); rootlayout.addComponent(activate); rootlayout.setComponentAlignment(activate, Alignment.MIDDLE_CENTER); activate.setNullSelectionAllowed(false); activate.setHtmlContentAllowed(true); activate.setImmediate(true); activate.addItem(DEACTIVATE); activate.addItem(RWACTIVATE); activate.addItem(ROACTIVATE); final boolean isActivated = model.isDeviceActive(); if (isActivated) { final boolean isReadOnly = model.isDeviceReadOnly(); if (isReadOnly) { activate.select(ROACTIVATE); // rw is not authorized, deactivate first activate.setItemEnabled(RWACTIVATE, false); } else { activate.select(RWACTIVATE); // ro is not authorized, deactivate first activate.setItemEnabled(ROACTIVATE, false); } } else { activate.select(DEACTIVATE); } activate.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final String valueString = String.valueOf(event.getProperty().getValue()); if (valueString.equals(DEACTIVATE)) { final String action = DEACTIVATE; // Run activation in background WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.deActivateDevice(); } @Override public void postProcessing() { activate.setItemEnabled(RWACTIVATE, true); activate.setItemEnabled(ROACTIVATE, true); updateAttributes(); Notification.show("Device " + action + "d", Notification.Type.TRAY_NOTIFICATION); } }); } else if (valueString.equals(RWACTIVATE)) { final String action = RWACTIVATE; WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.activateDeviceRW(); } @Override public void postProcessing() { // ro is not authorized, deactivate first activate.setItemEnabled(ROACTIVATE, false); updateAttributes(); Notification.show("Device " + action + "d", Notification.Type.TRAY_NOTIFICATION); } }); } else if (valueString.equals(ROACTIVATE)) { final String action = ROACTIVATE; WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.activateDeviceRO(); } @Override public void postProcessing() { // rw is not authorized, deactivate first activate.setItemEnabled(RWACTIVATE, false); updateAttributes(); Notification.show("Device " + action + "d", Notification.Type.TRAY_NOTIFICATION); } }); } } }); return rootlayout; }
From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java
License:Apache License
/** * Create attributes component./*from www . java 2s . c o m*/ * * @return the component */ private final AbstractComponent createAttributes() { final VerticalLayout layout = new VerticalLayout(); final FormLayout deviceAttributesLayout = new FormLayout(); deviceAttributesLayout.setMargin(true); deviceAttributesLayout.setWidth(null); deviceAttributesLayout.setImmediate(true); layout.addComponent(deviceAttributesLayout); layout.setComponentAlignment(deviceAttributesLayout, Alignment.MIDDLE_CENTER); // Enter NAME WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceName(value); } @Override public String getStringValue() { return model.getDeviceName(); } }, "Name", deviceAttributesLayout, model); // Enter DESCRIPTION WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceDescription(value); } @Override public String getStringValue() { return model.getDeviceDescription(); } }, "Description", deviceAttributesLayout, model); // Enter UUID (not editable) final TextField deviceUUID = new TextField("UUID", model.getItemUuid().toString()); deviceUUID.setReadOnly(true); deviceUUID.setWidth("300px"); deviceAttributesLayout.addComponent(deviceUUID); // Enter active final TextField deviceActive = new TextField("Active"); if (model.isDeviceActive()) { deviceActive.setValue("yes"); } else { deviceActive.setValue("no"); } deviceActive.setReadOnly(true); deviceActive.setSizeFull(); deviceAttributesLayout.addComponent(deviceActive); // Enter read only final TextField deviceReadOnly = new TextField("Read Only"); if (model.isDeviceReadOnly()) { deviceReadOnly.setValue("yes"); } else { deviceReadOnly.setValue("no"); } deviceReadOnly.setReadOnly(true); deviceReadOnly.setSizeFull(); deviceAttributesLayout.addComponent(deviceReadOnly); // Enter size WebUiUtils.createFieldLong(new LongAttributeOperation() { @Override public void setLongValue(final long value) { model.setDeviceSize(value); } @Override public long getLongValue() { return model.getDeviceSize(); } }, "Size", deviceAttributesLayout, model); // Enter IQN WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceIqn(value); } @Override public String getStringValue() { return model.getDeviceIqn(); } }, "IQN", deviceAttributesLayout, model); // Enter Alias WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceIscsiAlias(value); } @Override public String getStringValue() { return model.getDeviceIscsiAlias(); } }, "iSCSI Alias", deviceAttributesLayout, model); // Enter iscsi block size WebUiUtils.createFieldInteger(new IntegerAttributeOperation() { @Override public void setIntegerValue(final int value) { model.setDeviceIscsiBlockSize(value); } @Override public int getIntegerValue() { return model.getDeviceIscsiBlockSize(); } }, "iSCSI Block Size", deviceAttributesLayout, model, true); return layout; }
From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java
License:Apache License
/** * Create delete tab in the accordion.//from w w w . ja va 2 s . c o m * * @return the component. */ @SuppressWarnings("serial") private final AbstractComponent createDelete() { final VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.setMargin(true); layout.setSpacing(true); final Label label = new Label("Deleting a snapshot can be done, only if it is not the root snapshot."); label.setWidth(null); layout.addComponent(label); layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); final Button deleteButton = new Button("Delete"); if (model.getItemUuid().equals(model.getSnapshotParent())) { // Root snapshot can not be deleted deleteButton.setEnabled(false); } layout.addComponent(deleteButton); layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_CENTER); deleteButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final SnapshotDeleteWindow deleteWindow = new SnapshotDeleteWindow(model.getItemUuid()); deleteWindow.add(model); } catch (final Exception e) { LOGGER.error("Can not delete snapshot:", e); final ErrorWindow err = new ErrorWindow("Snapshot not deleted: " + e.getMessage()); err.add(model); } } }); return layout; }
From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java
License:Apache License
/** * Create the component to create a device. * //w w w . ja v a 2 s. c o m * @return the component */ @SuppressWarnings("serial") private final AbstractComponent createDevice() { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); final FormLayout createDeviceLayout = new FormLayout(); createDeviceLayout.setMargin(true); createDeviceLayout.setWidth(null); createDeviceLayout.setImmediate(true); layout.addComponent(createDeviceLayout); layout.setComponentAlignment(createDeviceLayout, Alignment.MIDDLE_CENTER); // Enter name final TextField deviceName = new TextField("Name", ""); createDeviceLayout.addComponent(deviceName); // Enter size final TextField deviceSize = new TextField("Size", ""); createDeviceLayout.addComponent(deviceSize); // Create button final Button create = new Button("Create device"); layout.addComponent(create); layout.setComponentAlignment(create, Alignment.MIDDLE_CENTER); create.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { model.createDevice(deviceName.getValue(), Long.valueOf(deviceSize.getValue())); Notification.show("New device created", Notification.Type.TRAY_NOTIFICATION); } catch (final NumberFormatException e) { final ErrorWindow err = new ErrorWindow("Size must be a valid number"); err.add(model); } catch (final Exception e) { final ErrorWindow err = new ErrorWindow("Device not created: " + e.getMessage()); err.add(model); } } }); return layout; }