List of usage examples for com.vaadin.ui Alignment TOP_CENTER
Alignment TOP_CENTER
To view the source code for com.vaadin.ui Alignment TOP_CENTER.
Click Source Link
From source file:com.openhris.employee.PostEmploymentInfomation.java
public PostEmploymentInfomation(String employeeId) { this.employeeId = employeeId; init();//from ww w . ja va 2 s . c o m addComponent(layout()); setComponentAlignment(glayout, Alignment.TOP_CENTER); addComponent(positionHistoryTable()); addComponent(layout2()); }
From source file:com.peergreen.webconsole.scope.deployment.internal.DeploymentScope.java
License:Open Source License
@PostConstruct public void init() { deploymentViewManager = createDeploymentViewManager(); OptionGroup option = new OptionGroup(); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setWidth("100%"); toolBar.setSpacing(true);/*from w w w.ja v a 2s.c om*/ toolBar.setMargin(true); VerticalLayout uploadLayout = new VerticalLayout(); Upload uploader = new Upload("Upload a file here", null); uploader.setButtonCaption("Upload"); final FileUploader fileUploader = new FileUploader(deploymentViewManager, notifierService, artifactBuilder, option); uploader.setReceiver(fileUploader); uploader.addSucceededListener(fileUploader); uploader.addStartedListener(fileUploader); uploadLayout.addComponent(uploader); HorizontalLayout target = new HorizontalLayout(); option.addContainerProperty("id", String.class, null); option.setItemCaptionPropertyId("id"); option.addItem(DeployableContainerType.DEPLOYABLE.attribute()).getItemProperty("id") .setValue("Add to deployables"); option.addItem(DeployableContainerType.DEPLOYED.attribute()).getItemProperty("id").setValue("Deploy"); option.addItem(DeployableContainerType.DEPLOYMENT_PLAN.attribute()).getItemProperty("id") .setValue("Create a deployment plan"); option.addStyleName("horizontal"); option.select(DeployableContainerType.DEPLOYABLE.attribute()); target.addComponent(option); uploadLayout.addComponent(target); toolBar.addComponent(uploadLayout); Label infoLabel = new Label("Drop files here to create a deployment plan"); infoLabel.setSizeUndefined(); final VerticalLayout deploymentPlanMaker = new VerticalLayout(infoLabel); deploymentPlanMaker.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER); Button draft = new Button("A draft is under construction"); draft.addStyleName("link"); draft.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { deploymentViewManager.showDeploymentPlanView(); } }); draft.setVisible(false); deploymentViewManager.setDeploymentPlanDraftViewer(draft); deploymentPlanMaker.addComponent(draft); deploymentPlanMaker.setComponentAlignment(draft, Alignment.TOP_CENTER); deploymentPlanMaker.setSizeFull(); deploymentPlanMaker.addStyleName("drop-area"); deploymentPlanMakerWrapper = new DragAndDropWrapper(deploymentPlanMaker); deploymentPlanMakerWrapper.setSizeFull(); toolBar.addComponent(deploymentPlanMakerWrapper); addComponent(toolBar); addComponent(framesContainer); setExpandRatio(framesContainer, 1.5f); helpWindow = notifierService.createHelpOverlay("Deployment module", "<p>To deploy, or undeploy, artifacts, you can drag and drop elements from deployables panel " + "to deployed panel and vice versa.</p>" + "<p>You can also drag files from desktop and drop them where you want to add them."); }
From source file:com.save.employee.request.RequestFormWindow.java
Component buildRequestForm() { GridLayout glayout = new GridLayout(4, 7); glayout.setSizeFull();//from w ww .ja v a 2s . c om glayout.setSpacing(true); glayout.setMargin(true); controlNo = new TextField("Control No."); controlNo.setWidth("100%"); controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(controlNo, 0, 0); dateOfActivity = new DateField("Date of Activity: "); dateOfActivity.setWidth("100%"); dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL); glayout.addComponent(dateOfActivity, 1, 0); area = CommonComboBox.areas(); area.setWidth("100%"); glayout.addComponent(area, 2, 0); activity = new TextField("Activity: "); activity.setWidth("100%"); activity.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(activity, 0, 1, 1, 1); venue = new TextField("Venue: "); venue.setWidth("100%"); venue.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(venue, 0, 2, 1, 2); requirements = new TextArea("Requirements: "); requirements.setWidth("100%"); requirements.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(requirements, 2, 1, 3, 2); Label lodging = new Label("Lodging: "); lodging.setWidthUndefined(); glayout.addComponent(lodging, 0, 3); glayout.setComponentAlignment(lodging, Alignment.MIDDLE_CENTER); lodgingPax = new TextField("Pax: "); lodgingPax.setWidth("100%"); lodgingPax.setValue("0"); lodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingPax.addStyleName("align-right"); glayout.addComponent(lodgingPax, 1, 3); lodgingAmount = new TextField("Amount: "); lodgingAmount.setWidth("100%"); lodgingAmount.setValue("0.00"); lodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingAmount.addStyleName("align-right"); lodgingAmount.setEnabled(false); lodgingAmount.setImmediate(true); glayout.addComponent(lodgingAmount, 3, 3); lodgingBudget = new TextField("Budget: "); lodgingBudget.setWidth("100%"); lodgingBudget.setValue("0.00"); lodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingBudget.addStyleName("align-right"); lodgingBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(lodgingPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(lodgingBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } lodgingAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(lodgingPax.getValue().trim()) * CommonUtilities.convertStringToDouble(lodgingBudget.getValue().trim()))); }); lodgingBudget.setImmediate(true); glayout.addComponent(lodgingBudget, 2, 3); Label meals = new Label("Meals: "); meals.setWidthUndefined(); glayout.addComponent(meals, 0, 4); glayout.setComponentAlignment(meals, Alignment.MIDDLE_CENTER); mealsPax = new TextField("Pax: "); mealsPax.setWidth("100%"); mealsPax.setValue("0"); mealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsPax.addStyleName("align-right"); glayout.addComponent(mealsPax, 1, 4); mealsAmount = new TextField("Amount: "); mealsAmount.setWidth("100%"); mealsAmount.setValue("0.00"); mealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsAmount.addStyleName("align-right"); mealsAmount.setEnabled(false); mealsAmount.setImmediate(liquidated); glayout.addComponent(mealsAmount, 3, 4); mealsBudget = new TextField("Budget: "); mealsBudget.setWidth("100%"); mealsBudget.setValue("0.00"); mealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsBudget.addStyleName("align-right"); mealsBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(mealsPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(mealsBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } mealsAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(mealsPax.getValue().trim()) * CommonUtilities.convertStringToDouble(mealsBudget.getValue().trim()))); }); mealsAmount.setImmediate(true); glayout.addComponent(mealsBudget, 2, 4); others = new TextArea("Others: "); others.setWidth("100%"); others.setRows(3); others.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(others, 0, 5, 2, 6); othersAmount = new TextField("Amount: "); othersAmount.setWidth("100%"); othersAmount.setValue("0.00"); othersAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); othersAmount.addStyleName("align-right"); glayout.addComponent(othersAmount, 3, 5); glayout.setComponentAlignment(othersAmount, Alignment.TOP_CENTER); Button rlButton = new Button(); rlButton.setCaption("SAVE"); rlButton.setWidth("100%"); rlButton.addStyleName(ValoTheme.BUTTON_PRIMARY); rlButton.addStyleName(ValoTheme.BUTTON_SMALL); rlButton.addClickListener(buttonClickListener); glayout.addComponent(rlButton, 3, 6); glayout.setComponentAlignment(rlButton, Alignment.TOP_CENTER); if (getRequestId() != 0) { LiquidationForm lf = rls.getRLById(getRequestId()); controlNo.setValue(String.valueOf(lf.getControlNo())); dateOfActivity.setValue(lf.getDateOfActivity()); area.setValue(lf.getAreaId()); activity.setValue(lf.getActivity()); requirements.setValue(lf.getRequirements()); venue.setValue(lf.getVenue()); others.setValue(lf.getOthersRemarks()); othersAmount.setValue(String.valueOf(lf.getOthersAmount())); lodgingAmount.setValue(String.valueOf(lf.getLodgingAmount())); mealsAmount.setValue(String.valueOf(lf.getMealsAmount())); if (getLiquidated() == true) { setCaption("LIQUIDATE FROM"); rlButton.setCaption("LIQUIDATE"); controlNo.setReadOnly(liquidated); dateOfActivity.setReadOnly(liquidated); area.setReadOnly(liquidated); activity.setReadOnly(liquidated); requirements.setReadOnly(liquidated); venue.setReadOnly(liquidated); } else { rlButton.setCaption("EDIT"); lodgingPax.setValue(String.valueOf(lf.getLodgingPax())); lodgingBudget.setValue(String.valueOf(lf.getLodgingBudget())); mealsPax.setValue(String.valueOf(lf.getMealsPax())); mealsBudget.setValue(String.valueOf(lf.getMealsBudget())); rlButton.setEnabled(rls.getRLById(getRequestId()).getLiquidated() == 0); } // delete.setVisible(true); } return glayout; }
From source file:com.skysql.manager.ui.ChartPreviewLayout.java
License:Open Source License
/** * Instantiates a new chart preview layout. * * @param userChart the user chart// w ww. j a v a 2 s . c om * @param time the time * @param interval the interval */ public ChartPreviewLayout(final UserChart userChart, String time, String interval) { this.userChart = userChart; this.time = time; this.interval = interval; addStyleName("ChartPreviewLayout"); setSpacing(true); setMargin(true); HorizontalLayout formDescription = new HorizontalLayout(); formDescription.setSpacing(true); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n" + " <tr bgcolor=\"#ccccff\">" + " <th align=left>Field" + " <th align=left>Description" + " <tr>" + " <td><code>Title</code>" + " <td>Name of the Chart" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Description</code>" + " <td>Description of the Chart " + " <tr>" + " <td nowrap><code>Measurement Unit</code>" + " <td>Unit of measurement for the data returned by the monitor, used as caption for the vertical axis of the chart" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Type</code>" + " <td>Chart type (LineChart, AreaChart)" + " <tr>" + " <td><code>Points</code>" + " <td>Number of data points displayed"; infoText += " </table>" + " </blockquote>"; info.setDescription(infoText); formDescription.addComponent(info); final Label monitorsLabel = new Label("Display as Chart"); monitorsLabel.setStyleName("dialogLabel"); formDescription.addComponent(monitorsLabel); formDescription.setComponentAlignment(monitorsLabel, Alignment.MIDDLE_LEFT); addComponent(formDescription); setComponentAlignment(formDescription, Alignment.TOP_CENTER); HorizontalLayout chartInfo = new HorizontalLayout(); chartInfo.setSpacing(true); addComponent(chartInfo); setComponentAlignment(chartInfo, Alignment.MIDDLE_CENTER); FormLayout formLayout = new FormLayout(); chartInfo.addComponent(formLayout); chartName = new TextField("Title"); chartName.setImmediate(true); formLayout.addComponent(chartName); chartDescription = new TextField("Description"); chartDescription.setWidth("25em"); chartDescription.setImmediate(true); formLayout.addComponent(chartDescription); chartUnit = new TextField("Measurement Unit"); chartUnit.setImmediate(true); formLayout.addComponent(chartUnit); chartSelectType = new NativeSelect("Type"); chartSelectType.setImmediate(true); for (UserChart.ChartType type : UserChart.ChartType.values()) { chartSelectType.addItem(type.name()); } chartSelectType.setNullSelectionAllowed(false); formLayout.addComponent(chartSelectType); selectCount = new NativeSelect("Points"); selectCount.setImmediate(true); for (int points : UserChart.chartPoints()) { selectCount.addItem(points); selectCount.setItemCaption(points, String.valueOf(points)); } selectCount.setNullSelectionAllowed(false); formLayout.addComponent(selectCount); updateChartInfo(userChart.getName(), userChart.getDescription(), userChart.getUnit(), userChart.getType(), userChart.getPoints()); chartName.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String chartName = (String) (event.getProperty()).getValue(); userChart.setName(chartName); refreshChart(); } }); chartDescription.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String value = (String) (event.getProperty()).getValue(); userChart.setDescription(value); refreshChart(); } }); chartUnit.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String value = (String) (event.getProperty()).getValue(); userChart.setUnit(value); refreshChart(); } }); chartSelectType.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String value = (String) (event.getProperty()).getValue(); userChart.setType(value); refreshChart(); } }); selectCount.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { int points = (Integer) (event.getProperty()).getValue(); userChart.setPoints(points); refreshChart(); } }); chartLayout = drawChart(); addComponent(chartLayout); }
From source file:com.skysql.manager.ui.components.ComponentButton.java
License:Open Source License
/** * Instantiates a new component button.//from ww w .j a v a 2 s .c o m * * @param componentInfo the component info */ public ComponentButton(ClusterComponent componentInfo) { thisButton = this; this.componentInfo = componentInfo; addStyleName("componentButton"); componentInfo.setButton(this); setData(componentInfo); setHeight(COMPONENT_HEIGHT + 4, Unit.PIXELS); float componentWidth = (componentInfo.getType() == ClusterComponent.CCType.system) ? SYSTEM_WIDTH : NODE_WIDTH; setWidth(componentWidth + 8, Unit.PIXELS); imageLayout = new VerticalLayout(); imageLayout.setHeight(COMPONENT_HEIGHT + 4, Unit.PIXELS); imageLayout.setWidth(componentWidth, Unit.PIXELS); //imageLayout.setMargin(new MarginInfo(true, true, false, true)); imageLayout.setImmediate(true); if (componentInfo.getParentID() != null) { String icon = null; switch (componentInfo.getType()) { case system: icon = "system"; break; case node: icon = NodeStates.getNodeIcon(componentInfo.getSystemType(), componentInfo.getState()); break; default: // unknown component type break; } imageLayout.addStyleName(icon); //imageLayout.addStyleName(componentInfo.getType().toString()); commandLabel = new Label(); commandLabel.setSizeUndefined(); imageLayout.addComponent(commandLabel); imageLayout.setComponentAlignment(commandLabel, Alignment.TOP_LEFT); //imageLayout.setExpandRatio(commandLabel, 1.0f); // NodeInfo nodeInfo = (NodeInfo) componentInfo; // TaskRecord taskRecord = nodeInfo.getTask(); // setCommandLabel(taskRecord); Label padding = new Label(""); imageLayout.addComponent(padding); imageLayout.setComponentAlignment(padding, Alignment.MIDDLE_CENTER); HorizontalLayout iconsStrip = new HorizontalLayout(); iconsStrip.addStyleName("componentInfo"); iconsStrip.setWidth(componentInfo.getType() == ClusterComponent.CCType.node ? "60px" : "76px"); imageLayout.addComponent(iconsStrip); imageLayout.setComponentAlignment(iconsStrip, Alignment.MIDDLE_CENTER); info = new Embedded(null, new ThemeResource("img/info.png")); iconsStrip.addComponent(info); iconsStrip.setComponentAlignment(info, Alignment.MIDDLE_LEFT); alert = new Embedded(); alert.setVisible(false); iconsStrip.addComponent(alert); iconsStrip.setComponentAlignment(alert, Alignment.MIDDLE_RIGHT); nameLabel = new Label(componentInfo.getName()); nameLabel.setStyleName("componentName"); nameLabel.setSizeUndefined(); imageLayout.addComponent(nameLabel); imageLayout.setComponentAlignment(nameLabel, Alignment.BOTTOM_CENTER); } addComponent(imageLayout); setComponentAlignment(imageLayout, Alignment.TOP_CENTER); setExpandRatio(imageLayout, 1.0f); }
From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java
License:Open Source License
/** * Instantiates a new scripting progress layout. * * @param runningTask the running task//from w w w . ja v a2 s .c om * @param observerMode the observer mode */ public ScriptingProgressLayout(final RunningTask runningTask, boolean observerMode) { this.runningTask = runningTask; this.observerMode = observerMode; addStyleName("scriptingProgressLayout"); setSpacing(true); setMargin(true); progressLayout = new VerticalLayout(); progressLayout.setSpacing(true); addComponent(progressLayout); scriptLabel = new Label(""); scriptLabel.addStyleName("instructions"); progressLayout.addComponent(scriptLabel); progressLayout.setComponentAlignment(scriptLabel, Alignment.TOP_CENTER); progressIconsLayout = new HorizontalLayout(); progressIconsLayout.addStyleName("progressIconsLayout"); progressLayout.addComponent(progressIconsLayout); progressLayout.setComponentAlignment(progressIconsLayout, Alignment.MIDDLE_CENTER); progressLabel = new Label(""); progressLabel.setImmediate(true); progressLayout.addComponent(progressLabel); progressLayout.setComponentAlignment(progressLabel, Alignment.BOTTOM_CENTER); resultLayout = new VerticalLayout(); resultLayout.addStyleName("scriptingResultsLayout"); resultLayout.setSizeFull(); resultLayout.setSpacing(true); resultLayout.setMargin(true); addComponent(resultLayout); //setComponentAlignment(resultLayout, Alignment.MIDDLE_LEFT); resultLabel = new Label(observerMode ? "Running" : "Has not run yet", ContentMode.HTML); resultLabel.addStyleName("instructions"); resultLabel.setImmediate(true); resultLayout.addComponent(resultLabel); resultLayout.setComponentAlignment(resultLabel, Alignment.MIDDLE_CENTER); }
From source file:com.skysql.manager.ui.ErrorDialog.java
License:Open Source License
/** * Instantiates a new error dialog./*from www . j av a 2s . c o m*/ * * @param e the exception * @param humanizedError the humanized error */ public ErrorDialog(Exception e, String humanizedError) { if (e != null) { ManagerUI.error(e.getMessage()); } dialogWindow = new ModalWindow("An Error has occurred", "775px"); dialogWindow.setHeight("340px"); dialogWindow.addCloseListener(this); UI current = UI.getCurrent(); if (current.getContent() == null) { current.setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null)); } current.addWindow(dialogWindow); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setSizeFull(); wrapper.setMargin(true); VerticalLayout iconLayout = new VerticalLayout(); iconLayout.setWidth("100px"); wrapper.addComponent(iconLayout); Embedded image = new Embedded(null, new ThemeResource("img/error.png")); iconLayout.addComponent(image); VerticalLayout textLayout = new VerticalLayout(); textLayout.setHeight("100%"); textLayout.setSpacing(true); wrapper.addComponent(textLayout); wrapper.setExpandRatio(textLayout, 1.0f); if (humanizedError != null || e != null) { String error = (humanizedError != null) ? humanizedError : e.toString(); ManagerUI.error(error); Label label = new Label(error, ContentMode.HTML); label.addStyleName("warning"); textLayout.addComponent(label); textLayout.setComponentAlignment(label, Alignment.TOP_CENTER); } if (e != null) { TextArea stackTrace = new TextArea("Error Log"); stackTrace.setSizeFull(); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); stackTrace.setValue(sw.toString()); textLayout.addComponent(stackTrace); textLayout.setComponentAlignment(stackTrace, Alignment.TOP_LEFT); textLayout.setExpandRatio(stackTrace, 1.0f); } HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Close"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { dialogWindow.close(); //UI.getCurrent().close(); } }); Button okButton = new Button("Send Error"); okButton.setEnabled(false); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { dialogWindow.close(); } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent(); windowLayout.setHeight("100%"); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.setExpandRatio(wrapper, 1.0f); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.ErrorView.java
License:Open Source License
/** * Instantiates a new error view.//from w ww .j a v a 2 s. c o m * * @param type the notification type * @param errorMsg the error msg */ public ErrorView(Type type, String errorMsg) { addStyleName("loginView"); setSizeFull(); setMargin(true); setSpacing(true); if (errorMsg != null) { Notification.show(errorMsg, type); } Embedded logo = new Embedded(null, new ThemeResource("img/productlogo.png")); addComponent(logo); setComponentAlignment(logo, Alignment.TOP_CENTER); if (type == Notification.Type.ERROR_MESSAGE) { Label refreshLabel = new Label("To try again, please refresh/reload the current page."); refreshLabel.setSizeUndefined(); refreshLabel.addStyleName("instructions"); addComponent(refreshLabel); setComponentAlignment(refreshLabel, Alignment.TOP_CENTER); } }
From source file:com.skysql.manager.ui.LoginView.java
License:Open Source License
/** * Instantiates a new login view./*from www . j a v a 2s .c o m*/ * * @param aboutRecord the about record */ public LoginView() { setSizeFull(); setMargin(true); setSpacing(true); addStyleName("loginView"); VerticalLayout logoLayout = new VerticalLayout(); addComponent(logoLayout); setComponentAlignment(logoLayout, Alignment.BOTTOM_CENTER); setExpandRatio(logoLayout, 1.0f); Embedded logo = new Embedded(null, new ThemeResource("img/loginlogo.png")); logoLayout.addComponent(logo); logoLayout.setComponentAlignment(logo, Alignment.BOTTOM_CENTER); Label releaseInfo = new Label("Version " + ManagerUI.GUI_RELEASE); releaseInfo.setSizeUndefined(); releaseInfo.addStyleName("releaseInfo"); logoLayout.addComponent(releaseInfo); logoLayout.setComponentAlignment(releaseInfo, Alignment.TOP_CENTER); VerticalLayout spacer = new VerticalLayout(); spacer.setHeight("20px"); logoLayout.addComponent(spacer); VerticalLayout loginBox = new VerticalLayout(); loginBox.addStyleName("loginBox"); loginBox.setSizeUndefined(); loginBox.setMargin(true); loginBox.setSpacing(true); addComponent(loginBox); setComponentAlignment(loginBox, Alignment.MIDDLE_CENTER); VerticalLayout loginFormLayout = new VerticalLayout(); loginFormLayout.addStyleName("loginForm"); loginFormLayout.setMargin(true); loginFormLayout.setSpacing(true); loginBox.addComponent(loginFormLayout); // userName.focus(); userName.setStyleName("loginControl"); userName.setInputPrompt("Username"); userName.setImmediate(true); userName.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { password.focus(); login.setClickShortcut(KeyCode.ENTER); } }); loginFormLayout.addComponent(userName); loginFormLayout.setComponentAlignment(userName, Alignment.MIDDLE_CENTER); // spacer loginFormLayout.addComponent(new Label("")); password.setStyleName("loginControl"); password.setInputPrompt("Password"); password.setImmediate(true); password.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { login.focus(); } }); loginFormLayout.addComponent(password); loginFormLayout.setComponentAlignment(password, Alignment.MIDDLE_CENTER); // spacer loginFormLayout.addComponent(new Label(" ")); login.setStyleName("loginControl"); login.setEnabled(false); loginFormLayout.addComponent(login); loginFormLayout.setComponentAlignment(login, Alignment.BOTTOM_CENTER); VerticalLayout filler = new VerticalLayout(); addComponent(filler); setExpandRatio(filler, 1.0f); preload(); }
From source file:com.snowy.Login.java
@PostConstruct void init() {/* w ww .j a v a2 s . co m*/ d = ((MyVaadinUI) UI.getCurrent()).getDataObject(); //Logger.getLogger(Login.class.getName()).info(d); this.setSizeFull(); this.setSpacing(false); this.setMargin(true); Label MainL = new Label("<h1>Connect 4</h1?>", ContentMode.HTML); //layout.addComponent(MainL); MainL.setSizeUndefined(); VerticalLayout lay = new VerticalLayout(); lay.setMargin(false); lay.addComponent(MainL); lay.setComponentAlignment(MainL, Alignment.TOP_CENTER); HorizontalLayout hz = new HorizontalLayout(); hz.setMargin(false); hz.setSpacing(false); LoginForm lf = new LoginForm(); lf.addLoginListener((e) -> { String token = d.genToken(e.getLoginParameter("username"), e.getLoginParameter("password")); //String token="true"; if (!token.equals("false")) { Cookie c = new Cookie("token", token); VaadinService.getCurrentResponse().addCookie(c); //https://vaadin.com/wiki/-/wiki/Main/Setting+and+reading+Cookies //Notification.show(VaadinService.getCurrentRequest().getCookies()[1].getValue(),Notification.Type.ERROR_MESSAGE); //this.getNavigator().navigateTo("main"); //this.getUI().get this.getUI().getNavigator().navigateTo("main"); } else { Label l = new Label("<h4 style=\"color:red\">Invalid Username or Password</h4>", ContentMode.HTML); l.setId("created"); if (lay.getComponent(lay.getComponentIndex(lf) + 1).getId() == null) { //lay.addComponent(new Label(String.valueOf(lay.getComponentIndex(l)))); lay.addComponent(l, lay.getComponentIndex(lf) + 1); l.setSizeUndefined(); lay.setComponentAlignment(l, Alignment.TOP_CENTER); } } }); lay.addComponent(lf); Button newUser = new Button("New User"); newUser.addClickListener((e) -> { this.getUI().addWindow(new NewUserSubWindow(d)); }); //newUser.setWidth((float)5.5, Unit.EM); Button forgotPass = new Button("Forgot Password"); //temp forgotPass.addClickListener((e) -> { //Notification.show(, Notification.Type.ERROR_MESSAGE); }); forgotPass.setEnabled(false); forgotPass.setDescription("Feature Disabled, Contact Administrator for Assistance"); //forgotPass.setWidth((float) 8.5,Unit.EM); forgotPass.setStyleName(ValoTheme.BUTTON_LINK); newUser.setStyleName(ValoTheme.BUTTON_LINK); hz.addComponent(newUser); hz.addComponent(forgotPass); lay.addComponent(hz); lay.setComponentAlignment(lf, Alignment.TOP_CENTER); lay.setComponentAlignment(hz, Alignment.MIDDLE_CENTER); this.addComponent(lay); this.setComponentAlignment(lay, Alignment.MIDDLE_CENTER); }