List of usage examples for com.vaadin.ui FormLayout addComponent
@Override public void addComponent(Component c)
From source file:com.peergreen.webconsole.scope.deployment.internal.components.DeployableWindow.java
License:Open Source License
public Component getContent() { FormLayout content = new FormLayout(); content.setSpacing(true);/* w w w . j a v a 2 s .com*/ content.setMargin(true); Label name = new Label(deployableEntry.getName()); name.setCaption("Name"); content.addComponent(name); Label uri = new Label(deployableEntry.getUri().toString()); uri.setCaption("URI"); content.addComponent(uri); VerticalLayout status = new VerticalLayout(); status.setCaption("Status"); content.addComponent(status); if (report == null) { // is not deployed yet status.addComponent(new Label("Ready to be deployed")); } else { if (report.getExceptions().size() == 0) { status.addComponent(new Label("<p style=\"color:#329932\">Deployed</p>", ContentMode.HTML)); } else { for (ArtifactError artifactError : report.getExceptions()) { for (ArtifactErrorDetail detail : artifactError.getDetails()) { ExceptionView exceptionView = new ExceptionView(detail); status.addComponent(exceptionView); } } } VerticalLayout endPointsLayout = new VerticalLayout(); for (Endpoint endpoint : report.getEndpoints()) { try { Link link = new Link(endpoint.getURI().toString(), new ExternalResource(endpoint.getURI().toURL())); link.setTargetName("_blank"); endPointsLayout.addComponent(link); } catch (MalformedURLException e) { endPointsLayout.addComponent(new Label(endpoint.getURI().toString())); } } if (endPointsLayout.getComponentCount() > 0) { content.addComponent(endPointsLayout); endPointsLayout.setCaption("End points"); } } return content; }
From source file:com.peergreen.webconsole.scope.home.extensions.PeergreenNewsFeedFrame.java
License:Open Source License
/** * News popup//from w w w. java 2s .c o m * * @param feedMessage * @return */ private Window getNewsDescription(FeedMessage feedMessage) { FormLayout fields = new FormLayout(); fields.setWidth("35em"); fields.setSpacing(true); fields.setMargin(true); Label label = new Label("<a href=\"" + feedMessage.getLink() + "\">" + feedMessage.getLink().substring(0, 50) + "..." + "</a>"); label.setContentMode(ContentMode.HTML); label.setSizeUndefined(); label.setCaption("URL"); fields.addComponent(label); String description = feedMessage.getDescription(); if (description.length() > 1000) { description = description.substring(0, 999) + "..."; } Label desc = new Label(description); desc.setContentMode(ContentMode.HTML); desc.setCaption("Description"); fields.addComponent(desc); Button ok = new Button("Close"); ok.addStyleName("wide"); ok.addStyleName("default"); final Window w = new DefaultWindow(feedMessage.getTitle(), fields, ok); w.center(); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { w.close(); } }); return w; }
From source file:com.peergreen.webconsole.scope.logs.LogsScope.java
License:Open Source License
public LogsScope() { setMargin(true);/*ww w . j a v a 2 s. com*/ setSpacing(true); setSizeFull(); HorizontalLayout topBar = new HorizontalLayout(); topBar.setWidth("100%"); addComponent(topBar); FormLayout form = new FormLayout(); form.setWidth("40%"); topBar.addComponent(form); TextField textFieldFilter = new TextField(); textFieldFilter.setCaption("Filter:"); textFieldFilter.setInputPrompt("filter"); textFieldFilter.setWidth("60%"); textFieldFilter.addTextChangeListener(new TextChangeListener() { @Override public void textChange(final FieldEvents.TextChangeEvent event) { container.removeAllContainerFilters(); Container.Filter or = new Or(new SimpleStringFilter("caller", event.getText().trim(), true, false), new SimpleStringFilter("text", event.getText().trim(), true, false)); Filter and = new And(or, filter); container.addContainerFilter(and); } }); topBar.addComponent(textFieldFilter); //form.setWidth("100%"); form.setSpacing(true); form.setMargin(true); HorizontalLayout systemLayout = new HorizontalLayout(); systemLayout.setCaption("JVM System streams:"); form.addComponent(systemLayout); HorizontalLayout loggerLayout = new HorizontalLayout(); loggerLayout.setCaption("Loggers:"); form.addComponent(loggerLayout); final CheckBox systemOut = new CheckBox("out"); systemOut.setValue(true); systemLayout.addComponent(systemOut); this.container = new BeanItemContainer<TableEntry>(TableEntry.class); filter = new TypeFilter(); container.addContainerFilter(filter); systemOut.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptSystemOut(value); container.addContainerFilter(filter); } }); CheckBox systemErr = new CheckBox("err"); systemLayout.addComponent(systemErr); systemErr.setValue(true); systemErr.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptSystemErr(value); container.addContainerFilter(filter); } }); CheckBox loggerInfo = new CheckBox("Info"); loggerLayout.addComponent(loggerInfo); loggerInfo.setValue(true); loggerInfo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptLoggerInfo(value); container.addContainerFilter(filter); } }); CheckBox loggerWarning = new CheckBox("Warning"); loggerLayout.addComponent(loggerWarning); loggerWarning.setValue(true); loggerWarning.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptLoggerWarning(value); container.addContainerFilter(filter); } }); CheckBox loggerError = new CheckBox("Error"); loggerLayout.addComponent(loggerError); loggerError.setValue(true); loggerError.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptLoggerError(value); container.addContainerFilter(filter); } }); Button clearButton = new Button("clear"); //horizontalLayout.addComponent(clearButton); clearButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { container.removeAllItems(); } }); this.table = new Table(); table.setSizeFull(); table.setImmediate(true); // Define the names and data types of columns. table.addContainerProperty("date", Date.class, null); table.addContainerProperty("type", String.class, null); table.addContainerProperty("caller", String.class, null); table.addContainerProperty("text", String.class, "empty"); table.setContainerDataSource(container); table.addGeneratedColumn("text", new TextColumnGenerator()); table.setItemDescriptionGenerator(new ItemDescriptionGenerator() { @Override public String generateDescription(Component source, Object itemId, Object propertyId) { TableEntry tableEntry = (TableEntry) itemId; return simpleDateFormat.format(tableEntry.getDate()).concat(" : ").concat(tableEntry.getType()) .concat(" : ").concat(tableEntry.getCaller()); } }); table.setVisibleColumns(new Object[] { "text" }); table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); table.setSortEnabled(true); addComponent(table); setExpandRatio(table, 1.5f); }
From source file:com.save.employee.CreateNewAccountWindow.java
FormLayout getLayout() { FormLayout f = new FormLayout(); f.setReadOnly(false);/*from www . j a v a 2 s.c o m*/ f.setSpacing(true); f.setMargin(true); final TextField employeeNo = new TextField("Employee No: "); employeeNo.setWidth("100%"); employeeNo.setRequired(true); employeeNo.setNullSettingAllowed(false); f.addComponent(employeeNo); final TextField firstname = new TextField("Firstname: "); firstname.setWidth("100%"); firstname.setRequired(true); firstname.setNullSettingAllowed(false); f.addComponent(firstname); final TextField middlename = new TextField("Middlename: "); middlename.setWidth("100%"); middlename.setRequired(true); middlename.setNullSettingAllowed(false); f.addComponent(middlename); final TextField lastname = new TextField("Lastname: "); lastname.setWidth("100%"); lastname.setRequired(true); lastname.setNullSettingAllowed(false); f.addComponent(lastname); final OptionGroup gender = new OptionGroup("Gender: "); gender.addItem("Female"); gender.addItem("Male"); gender.addStyleName("horizontal"); gender.setValue("Female"); f.addComponent(gender); final ComboBox status = new ComboBox("Status: "); status.setWidth("100%"); status.setNullSelectionAllowed(false); status.addItem("Single"); status.addItem("Married"); status.addItem("Widow"); status.addItem("Separated"); f.addComponent(status); Button saveBtn = new Button("SAVE"); saveBtn.setWidth("100%"); saveBtn.addClickListener((Button.ClickEvent event) -> { //TODO if (employeeNo.getValue().isEmpty() || employeeNo.getValue() == null) { Notification.show("Requried Emloyee ID", Notification.Type.WARNING_MESSAGE); return; } if (firstname.getValue().isEmpty() || firstname.getValue() == null) { Notification.show("Requried Firstname", Notification.Type.WARNING_MESSAGE); return; } if (middlename.getValue().isEmpty() || middlename.getValue() == null) { Notification.show("Requried Middlename", Notification.Type.WARNING_MESSAGE); return; } if (lastname.getValue().isEmpty() || lastname.getValue() == null) { Notification.show("Requried Lastname", Notification.Type.WARNING_MESSAGE); return; } if (status.getValue() == null) { Notification.show("Requried Status", Notification.Type.WARNING_MESSAGE); } if (employeeService.checkIfEmployeeNoExist(employeeNo.getValue().trim().toLowerCase())) { Notification.show("EmployeeId already Exist!", Notification.Type.ERROR_MESSAGE); return; } Employee e = new Employee(); e.setEmployeeNo(employeeNo.getValue().trim().toLowerCase()); e.setFirstname(firstname.getValue().trim().toLowerCase()); e.setMiddlename(middlename.getValue().trim().toLowerCase()); e.setLastname(lastname.getValue().trim().toLowerCase()); e.setGender(gender.getValue().toString().trim().toLowerCase()); e.setPersonalStatus(status.getValue().toString()); boolean result = employeeService.createNewAccount(e); if (result) { close(); getHsplit().setFirstComponent(new EmployeesDataGridProperties(getHsplit(), "personal")); } }); f.addComponent(saveBtn); return f; }
From source file:com.save.employee.maintenance.MRFormWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true);//from w w w .ja v a 2s . c om formType = CommonComboBox.getFormType("Select Form Type.."); formType.setValue(1); formType.setWidth("60%"); form.addComponent(formType); area = CommonComboBox.areas(); area.setWidth("60%"); form.addComponent(area); plateNo = new TextField("Plate No: "); plateNo.setWidth("60%"); form.addComponent(plateNo); dateCovered = new DateField("Date Covered: "); dateCovered.setWidth("60%"); form.addComponent(dateCovered); amount = new TextField("Amount: "); amount.setWidth("60%"); amount.addStyleName("align-right"); form.addComponent(amount); description = new TextArea("Description: "); description.setWidth("100%"); description.setRows(3); form.addComponent(description); actionButton = new Button(); actionButton.setCaption("SAVE"); actionButton.setWidth("100%"); actionButton.addStyleName(ValoTheme.BUTTON_PRIMARY); actionButton.addClickListener(buttonClickListener); form.addComponent(actionButton); formType.addValueChangeListener((Property.ValueChangeEvent e) -> { if (e.getProperty().getValue().toString().equals("1")) { if (getMrId() != 0) { actionButton.setCaption("UPDATE"); } else { actionButton.setCaption("SAVE"); } panel.setCaption("MAINTENANCE FORM"); } else { if (getMrId() != 0) { actionButton.setCaption("UPDATE"); } else { actionButton.setCaption("SAVE"); } panel.setCaption("REIMBURSEMENT FORM"); } }); editForm(); viewForm(form); return form; }
From source file:com.save.employee.request.ViewRLWindow.java
FormLayout buildFormLayout() { FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true);/* w w w . j a va 2 s . c om*/ LiquidationForm lf = rls.getRLById(getRequestId()); controlNo = new TextField("Control No."); controlNo.setWidth("100%"); controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL); controlNo.setValue(String.valueOf(lf.getControlNo())); controlNo.setEnabled(false); f.addComponent(controlNo); dateOfActivity = new DateField("Date of Activity: "); dateOfActivity.setWidth("100%"); dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL); dateOfActivity.setValue(lf.getDateOfActivity()); dateOfActivity.setEnabled(false); f.addComponent(dateOfActivity); area = CommonComboBox.areas(); area.setWidth("100%"); area.setValue(lf.getAreaId()); area.setEnabled(false); f.addComponent(area); activity = new TextField("Activity: "); activity.setWidth("100%"); activity.addStyleName(ValoTheme.TEXTFIELD_SMALL); activity.setValue(lf.getActivity()); activity.setEnabled(false); f.addComponent(activity); venue = new TextField("Venue: "); venue.setWidth("100%"); venue.addStyleName(ValoTheme.TEXTFIELD_SMALL); venue.setValue(lf.getVenue()); venue.setEnabled(false); f.addComponent(venue); requirements = new TextArea("Requirements: "); requirements.setWidth("100%"); requirements.addStyleName(ValoTheme.TEXTAREA_SMALL); requirements.setValue(lf.getRequirements()); requirements.setEnabled(false); f.addComponent(requirements); HorizontalLayout h1 = new HorizontalLayout(); h1.setWidth("100%"); h1.setCaption("Request Lodging"); h1.addStyleName("light"); // h1.setReadOnly(true); requestLodgingPax = new TextField(); requestLodgingPax.setWidth("100%"); requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingPax.addStyleName("align-right"); requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax())); requestLodgingPax.setEnabled(false); h1.addComponent(requestLodgingPax); requestLodgingBudget = new TextField(); requestLodgingBudget.setWidth("100%"); requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingBudget.addStyleName("align-right"); requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget())); requestLodgingBudget.setEnabled(false); h1.addComponent(requestLodgingBudget); requestLodgingAmount = new TextField(); requestLodgingAmount.setWidth("100%"); requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingAmount.addStyleName("align-right"); requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount())); requestLodgingAmount.setEnabled(false); h1.addComponent(requestLodgingAmount); f.addComponent(h1); f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT); HorizontalLayout h2 = new HorizontalLayout(); h2.setWidth("100%"); h2.setCaption("Request Meals"); // h2.setReadOnly(true); requestMealsPax = new TextField(); requestMealsPax.setWidth("100%"); requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsPax.addStyleName("align-right"); requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax())); requestMealsPax.setEnabled(false); h2.addComponent(requestMealsPax); requestMealsBudget = new TextField(); requestMealsBudget.setWidth("100%"); requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsBudget.addStyleName("align-right"); requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget())); requestMealsBudget.setEnabled(false); h2.addComponent(requestMealsBudget); requestMealsAmount = new TextField(); requestMealsAmount.setWidth("100%"); requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsAmount.addStyleName("align-right"); requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount())); requestMealsAmount.setEnabled(false); h2.addComponent(requestMealsAmount); f.addComponent(h2); f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT); HorizontalLayout h3 = new HorizontalLayout(); h3.setWidth("100%"); h3.setCaption("Liquidated Lodging"); // h3.setReadOnly(true); liquidateLodgingPax = new TextField(); liquidateLodgingPax.setWidth("100%"); liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingPax.addStyleName("align-right"); liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax())); liquidateLodgingPax.setEnabled(false); h3.addComponent(liquidateLodgingPax); liquidateLodgingBudget = new TextField(); liquidateLodgingBudget.setWidth("100%"); liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingBudget.addStyleName("align-right"); liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget())); liquidateLodgingBudget.setEnabled(false); h3.addComponent(liquidateLodgingBudget); liquidateLodgingAmount = new TextField(); liquidateLodgingAmount.setWidth("100%"); liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingAmount.addStyleName("align-right"); liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount())); liquidateLodgingAmount.setEnabled(false); h3.addComponent(liquidateLodgingAmount); f.addComponent(h3); f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT); HorizontalLayout h4 = new HorizontalLayout(); h4.setWidth("100%"); h4.setCaption("Liquidated Meals"); h4.setReadOnly(true); liquidateMealsPax = new TextField(); liquidateMealsPax.setWidth("100%"); liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsPax.addStyleName("align-right"); liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax())); liquidateMealsPax.setEnabled(false); h4.addComponent(liquidateMealsPax); liquidateMealsBudget = new TextField(); liquidateMealsBudget.setWidth("100%"); liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsBudget.addStyleName("align-right"); liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget())); liquidateMealsBudget.setEnabled(false); h4.addComponent(liquidateMealsBudget); liquidateMealsAmount = new TextField(); liquidateMealsAmount.setWidth("100%"); liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsAmount.addStyleName("align-right"); liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount())); liquidateMealsAmount.setEnabled(false); h4.addComponent(liquidateMealsAmount); f.addComponent(h4); f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT); reimbursement = new TextField("Reimbursement: "); reimbursement.setWidth("50%"); reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL); reimbursement.setValue(String.valueOf(lf.getReimbursedAmount())); reimbursement.setEnabled(false); f.addComponent(reimbursement); f.addStyleName("light"); f.setReadOnly(true); return f; }
From source file:com.save.reports.maintenance.MaintenanceReportUI.java
private Window filterReport() { Window sub = new Window("FILTER REPORT"); sub.setWidth("400px"); sub.setModal(true);// ww w . j a va 2 s. c o m sub.center(); FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true); f.setSpacing(true); CheckBox areaCheckBox = new CheckBox("Filter by Area"); f.addComponent(areaCheckBox); CheckBox employeeCheckBox = new CheckBox("Filter by Employee"); f.addComponent(employeeCheckBox); CheckBox amountCheckBox = new CheckBox("Filter by Amount"); f.addComponent(amountCheckBox); CheckBox dateCheckBox = new CheckBox("Filter by Date"); f.addComponent(dateCheckBox); ComboBox areaComboBox = CommonComboBox.areas(); ComboBox employeeComboBox = CommonComboBox.getAllClients(); areaComboBox.setEnabled(false); f.addComponent(areaComboBox); areaCheckBox.addValueChangeListener((Property.ValueChangeEvent event) -> { areaComboBox.setEnabled((boolean) event.getProperty().getValue()); employeeComboBox.setEnabled(!(boolean) event.getProperty().getValue()); employeeCheckBox.setValue(!(boolean) event.getProperty().getValue()); isAreaSelect = (boolean) event.getProperty().getValue(); isEmployeeSelect = !(boolean) event.getProperty().getValue(); }); employeeComboBox.setEnabled(false); f.addComponent(employeeComboBox); employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { employeeComboBox.setEnabled((boolean) e.getProperty().getValue()); areaComboBox.setEnabled(!(boolean) e.getProperty().getValue()); areaCheckBox.setValue(!(boolean) e.getProperty().getValue()); isAreaSelect = !(boolean) e.getProperty().getValue(); isEmployeeSelect = (boolean) e.getProperty().getValue(); }); TextField amountField = new CommonTextField("Amount: "); amountField.addStyleName("align-right"); amountField.setEnabled(false); f.addComponent(amountField); amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { amountField.setEnabled((boolean) e.getProperty().getValue()); isAmountSelect = (boolean) e.getProperty().getValue(); }); HorizontalLayout h = new HorizontalLayout(); h.setCaption("Date: "); h.setWidth("100%"); h.setSpacing(true); DateField from = new DateField(); from.setWidth("100%"); from.setEnabled(false); h.addComponent(from); DateField to = new DateField(); to.setWidth("100%"); to.setEnabled(false); h.addComponent(to); dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { from.setEnabled((boolean) e.getProperty().getValue()); to.setEnabled((boolean) e.getProperty().getValue()); isDateSelect = (boolean) e.getProperty().getValue(); }); f.addComponent(h); Button generate = new CommonButton("Generate Report"); generate.addClickListener((Button.ClickEvent e) -> { if (!isEmployeeSelect && !isAmountSelect && !isDateSelect) { mrDataGrid.setContainerDataSource(new MaintenanceDataContainer()); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new MaintenanceDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()))); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && !isAmountSelect && !isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployeeSelect && isAmountSelect && !isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployeeSelect && !isAmountSelect && isDateSelect) { if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer(from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource( new MaintenanceDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && isAmountSelect && !isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer( areaComboBox.getItemCaption(areaComboBox.getValue()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && !isAmountSelect && isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployeeSelect && isAmountSelect && isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new MaintenanceDataContainer(employeeComboBox.getItemCaption(employeeComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && isAmountSelect && isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } sub.close(); }); f.addComponent(generate); sub.setContent(f); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.reports.promodeals.PromoDealReportUI.java
private Window filterReport() { Window sub = new Window("FILTER REPORT"); sub.setWidth("400px"); sub.setModal(true);//from w ww. java 2s .co m sub.center(); FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true); f.setSpacing(true); CheckBox areaCheckBox = new CheckBox("Filter by Area"); f.addComponent(areaCheckBox); CheckBox clientCheckBox = new CheckBox("Filter by Client"); f.addComponent(clientCheckBox); CheckBox amountCheckBox = new CheckBox("Filter by Amount"); f.addComponent(amountCheckBox); CheckBox dateCheckBox = new CheckBox("Filter by Date"); f.addComponent(dateCheckBox); ComboBox areaComboBox = CommonComboBox.areas(); ComboBox clientComboBox = CommonComboBox.getAllClients(); areaComboBox.setEnabled(false); f.addComponent(areaComboBox); areaCheckBox.addValueChangeListener((Property.ValueChangeEvent event) -> { areaComboBox.setEnabled((boolean) event.getProperty().getValue()); clientComboBox.setEnabled(!(boolean) event.getProperty().getValue()); clientCheckBox.setValue(!(boolean) event.getProperty().getValue()); isAreaSelect = (boolean) event.getProperty().getValue(); isClientSelect = !(boolean) event.getProperty().getValue(); }); clientComboBox.setEnabled(false); f.addComponent(clientComboBox); clientCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { clientComboBox.setEnabled((boolean) e.getProperty().getValue()); areaComboBox.setEnabled(!(boolean) e.getProperty().getValue()); areaCheckBox.setValue(!(boolean) e.getProperty().getValue()); isClientSelect = (boolean) e.getProperty().getValue(); isAreaSelect = !(boolean) e.getProperty().getValue(); }); TextField amountField = new CommonTextField("Amount: "); amountField.addStyleName("align-right"); amountField.setEnabled(false); f.addComponent(amountField); amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { amountField.setEnabled((boolean) e.getProperty().getValue()); isAmountSelect = (boolean) e.getProperty().getValue(); }); HorizontalLayout h = new HorizontalLayout(); h.setCaption("Date: "); h.setWidth("100%"); h.setSpacing(true); DateField from = new DateField(); from.setWidth("100%"); from.setEnabled(false); h.addComponent(from); DateField to = new DateField(); to.setWidth("100%"); to.setEnabled(false); h.addComponent(to); dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { from.setEnabled((boolean) e.getProperty().getValue()); to.setEnabled((boolean) e.getProperty().getValue()); isDateSelect = (boolean) e.getProperty().getValue(); }); f.addComponent(h); Button generate = new CommonButton("Generate Report"); generate.addClickListener((Button.ClickEvent e) -> { if (!isClientSelect && !isAmountSelect && !isDateSelect) { promoDealGrid.setContainerDataSource(new PromoDealDataContainer()); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource( new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()))); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && !isAmountSelect && !isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (!isClientSelect && isAmountSelect && !isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } promoDealGrid.setContainerDataSource(new PromoDealDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); promoDealGrid.setFrozenColumnCount(2); } if (!isClientSelect && !isAmountSelect && isDateSelect) { if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer(from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } promoDealGrid.setContainerDataSource( new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && isAmountSelect && !isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer( areaComboBox.getItemCaption(areaComboBox.getValue()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && !isAmountSelect && isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (!isClientSelect && isAmountSelect && isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource( new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && isAmountSelect && isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } sub.close(); }); f.addComponent(generate); sub.setContent(f); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.reports.reimbursement.ReimbursementReportUI.java
private Window filterReport() { Window sub = new Window("FILTER REPORT"); sub.setWidth("400px"); sub.setModal(true);//from w ww . j a v a2s . c o m sub.center(); FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true); f.setSpacing(true); CheckBox employeeCheckBox = new CheckBox("Filter by Employee"); f.addComponent(employeeCheckBox); CheckBox amountCheckBox = new CheckBox("Filter by Amount"); f.addComponent(amountCheckBox); CheckBox dateCheckBox = new CheckBox("Filter by Date"); f.addComponent(dateCheckBox); ComboBox employeeComboBox = CommonComboBox.getAllEmpployees(null); employeeComboBox.setEnabled(false); f.addComponent(employeeComboBox); employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { employeeComboBox.setEnabled((boolean) e.getProperty().getValue()); isEmployee = (boolean) e.getProperty().getValue(); }); TextField amountField = new CommonTextField("Amount: "); amountField.addStyleName("align-right"); amountField.setEnabled(false); f.addComponent(amountField); amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { amountField.setEnabled((boolean) e.getProperty().getValue()); isAmount = (boolean) e.getProperty().getValue(); }); HorizontalLayout h = new HorizontalLayout(); h.setCaption("Date: "); h.setWidth("100%"); h.setSpacing(true); DateField from = new DateField(); from.setWidth("100%"); from.setEnabled(false); h.addComponent(from); DateField to = new DateField(); to.setWidth("100%"); to.setEnabled(false); h.addComponent(to); dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { from.setEnabled((boolean) e.getProperty().getValue()); to.setEnabled((boolean) e.getProperty().getValue()); isDate = (boolean) e.getProperty().getValue(); }); f.addComponent(h); Button generate = new CommonButton("Generate Report"); generate.addClickListener((Button.ClickEvent e) -> { if (!isEmployee && !isAmount && !isDate) { mrDataGrid.setContainerDataSource(new ReimbursementDataContainer()); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && !isAmount && !isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new ReimbursementDataContainer(employeeComboBox.getValue().toString())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployee && isAmount && !isDate) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployee && !isAmount && isDate) { if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && isAmount && !isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource( new ReimbursementDataContainer(employeeComboBox.getValue().toString(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && !isAmount && isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer( employeeComboBox.getValue().toString(), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployee && isAmount && isDate) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && isAmount && isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new ReimbursementDataContainer(employeeComboBox.getValue().toString(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } sub.close(); }); f.addComponent(generate); sub.setContent(f); sub.getContent().setHeightUndefined(); return sub; }
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 w w. j av a 2s . c o m*/ * @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); }