List of usage examples for com.vaadin.ui HorizontalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:at.peppol.webgui.app.components.TabInvoiceLine.java
License:Mozilla Public License
private void initElements() { invoiceLineList = parent.getInvoice().getInvoiceLine(); final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);/* www. ja va 2 s .c om*/ hiddenContent.setMargin(true); table = new InvoiceLineTable(parent.getInvoice().getInvoiceLine()); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(false); table.addStyleName("striped strong"); //table.addListener(parent.new LinesTotalAmountListener()); //table.addListener(parent.new TaxExclusiveAmountListener()); final VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); // buttons Add, Edit, Delete final Button addBtn = new Button("Add new"); final Button editBtn = new Button("Edit selected"); final Button deleteBtn = new Button("Delete Selected"); addBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { addBtn.setEnabled(false); editBtn.setEnabled(false); deleteBtn.setEnabled(false); //addMode = true; hiddenContent.removeAllComponents(); invoiceLineItem = createInvoiceLineItem(); final Label formLabel = new Label("<h3>Adding new invoice line</h3>", Label.CONTENT_XHTML); hiddenContent.addComponent(formLabel); final Form form = createInvoiceLineMainForm(); hiddenContent.addComponent(form); HorizontalLayout h1 = new HorizontalLayout(); h1.setSpacing(true); h1.setMargin(true); // Set invoiceLine 0..N cardinality panels //final Panel itemPropertyPanel = new ItemPropertyForm ("Additional", // invoiceLineItem.getInvLineAdditionalItemPropertyList ()); final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional", invoiceLineItem.getInvLineAdditionalItemPropertyList()); h1.addComponent(itemPropertyPanel); //add the allowance/charge indicator 0..N cardinality final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm( "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice()); //add the listeners for line extension amount calculation BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form); form.getField("Price Amount").addListener(biirule_t10_r018); form.getField("Base Quantity").addListener(biirule_t10_r018); form.getField("Invoiced Quantity").addListener(biirule_t10_r018); lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018); //add the listeners for VAT AE tax total amount EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID", "Tax Total Amount"); form.getField("Tax Scheme ID").addListener(eugen_t10_r018); form.getField("Tax Category ID").addListener(eugen_t10_r018); h1.addComponent(lineAllowanceChargePanel); HorizontalLayout h2 = new HorizontalLayout(); h2.setSpacing(true); h2.setMargin(true); final Panel lineOrderPanel = new InvoiceLineOrderForm("", invoiceLineItem.getInvLineOrderList()); h2.addComponent(lineOrderPanel); final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("", invoiceLineItem.getInvLineCommodityClassificationList()); h2.addComponent(lineCommodityPanel); hiddenContent.addComponent(h1); hiddenContent.addComponent(h2); // Save new line button final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(new Button("Save invoice line", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { AbstractTextField itemName = (AbstractTextField) form.getField("Item Name"); itemName.setMaxLength(50); if (itemName.getValue().toString().length() > 50) { //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters")); itemName.setValue(itemName.getValue().toString().substring(0, 49)); getWindow().showNotification("Item Name truncated to 50 chars", Notification.TYPE_TRAY_NOTIFICATION); } try { /*Collection<String> props = (Collection<String>) form.getItemPropertyIds(); List<Field> fields = new ArrayList<Field>(); for (String property : props) { fields.add(form.getField(property)); } List<BlurListener> listeners = new ArrayList<BlurListener>(); for (Field f : fields) { if (f instanceof AbstractTextField) { AbstractTextField ff = (AbstractTextField)f; listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class)); } } ValidatorsList.validateListenersNotify(listeners); form.validate();*/ Utils.validateFormFields(form); //form.commit(); // update table (and consequently add new item to invoiceList list) table.addLine(invoiceLineItem); //hide form hiddenContent.setVisible(false); //addMode = false; addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); //itemName.setComponentError(null); } catch (InvalidValueException e) { getWindow().showNotification("Invoice line has errors", Notification.TYPE_TRAY_NOTIFICATION); } } })); buttonLayout.addComponent(new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); hiddenContent.removeAllComponents(); // hide form hiddenContent.setVisible(false); addMode = false; } })); hiddenContent.addComponent(buttonLayout); // hiddenContent.setVisible(!hiddenContent.isVisible()); hiddenContent.setVisible(true); } }); editBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { final Object rowId = table.getValue(); // get the selected rows id if (rowId != null) { addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue(); // TODO: PUT THIS IN FUNCTION BEGINS editMode = true; hiddenContent.removeAllComponents(); // get selected item invoiceLineItem = (InvoiceLineAdapter) invoiceLineList.get(table.getIndexFromID(sid)); // clone it to original item originalItem = new InvoiceLineAdapter(); cloneInvoiceLineItem(invoiceLineItem, originalItem); final Label formLabel = new Label("<h3>Editing invoice line</h3>", Label.CONTENT_XHTML); hiddenContent.addComponent(formLabel); final Form form = createInvoiceLineMainForm(); hiddenContent.addComponent(form); HorizontalLayout h1 = new HorizontalLayout(); h1.setSpacing(true); h1.setMargin(true); // Set invoiceLine 0..N cardinality panels final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional", invoiceLineItem.getInvLineAdditionalItemPropertyList()); h1.addComponent(itemPropertyPanel); //add the allowance/charge indicator 0..N cardinality final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm( "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice()); //add the listeners for line extension amount calculation BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form); form.getField("Price Amount").addListener(biirule_t10_r018); form.getField("Base Quantity").addListener(biirule_t10_r018); lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018); //add the listeners for VAT AE tax total amount EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID", "Tax Total Amount"); form.getField("Tax Scheme ID").addListener(eugen_t10_r018); form.getField("Tax Category ID").addListener(eugen_t10_r018); h1.addComponent(lineAllowanceChargePanel); HorizontalLayout h2 = new HorizontalLayout(); h2.setSpacing(true); h2.setMargin(true); final Panel lineOrderPanel = new InvoiceLineOrderForm("", invoiceLineItem.getInvLineOrderList()); h2.addComponent(lineOrderPanel); final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("", invoiceLineItem.getInvLineCommodityClassificationList()); h2.addComponent(lineCommodityPanel); hiddenContent.addComponent(h1); hiddenContent.addComponent(h2); /*// Set invoiceLine 0..N cardinalily panels final Panel itemPropertyPanel = new ItemPropertyForm ("Additional", invoiceLineItem.getInvLineAdditionalItemPropertyList ()); hiddenContent.addComponent (itemPropertyPanel);*/ // Save new line button final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(new Button("Save changes", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { // update table (and consequently edit item to allowanceChargeList // list) AbstractTextField itemName = (AbstractTextField) form.getField("Item Name"); itemName.setMaxLength(50); if (itemName.getValue().toString().length() > 50) { //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters")); itemName.setValue(itemName.getValue().toString().substring(0, 49)); getWindow().showNotification("Item Name truncated to 50 chars", Notification.TYPE_TRAY_NOTIFICATION); } try { /*Collection<String> props = (Collection<String>) form.getItemPropertyIds(); List<Field> fields = new ArrayList<Field>(); for (String property : props) { fields.add(form.getField(property)); } List<BlurListener> listeners = new ArrayList<BlurListener>(); for (Field f : fields) { if (f instanceof AbstractTextField) { AbstractTextField ff = (AbstractTextField)f; listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class)); } } ValidatorsList.validateListenersNotify(listeners); form.validate();*/ Utils.validateFormFields(form); //table.setInvoiceLine (sid, invoiceLineItem); table.setLine(sid, invoiceLineItem); addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); // hide form hiddenContent.setVisible(false); editMode = false; } catch (InvalidValueException e) { getWindow().showNotification("Invoice line has errors", Notification.TYPE_TRAY_NOTIFICATION); } } })); buttonLayout.addComponent(new Button("Cancel editing", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { hiddenContent.removeAllComponents(); addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); //table.setInvoiceLine (sid, originalItem); table.setLine(sid, originalItem); // hide form hiddenContent.setVisible(false); editMode = false; } })); hiddenContent.addComponent(buttonLayout); // hiddenContent.setVisible(!hiddenContent.isVisible()); hiddenContent.setVisible(true); // TODO: PUT THIS IN FUNCTION ENDS } else { parent.getWindow().showNotification("Info", "No table line is selected", Window.Notification.TYPE_HUMANIZED_MESSAGE); } } }); deleteBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { final Object rowId = table.getValue(); // get the selected rows id if (rowId != null) { if (table.getContainerProperty(rowId, "ID.value").getValue() != null) { final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue(); //table.removeInvoiceLine (sid); table.removeLine(sid); } } else { parent.getWindow().showNotification("Info", "No table line is selected", Window.Notification.TYPE_HUMANIZED_MESSAGE); } } }); final VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addBtn); buttonsContainer.addComponent(editBtn); buttonsContainer.addComponent(deleteBtn); final Panel outerPanel = new Panel("Invoice Line"); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerLayout.addComponent(outerPanel); // ---- HIDDEN FORM BEGINS ----- final VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); outerLayout.addComponent(formLayout); // ---- HIDDEN FORM ENDS ----- setLayout(outerLayout); grid.setSizeUndefined(); outerPanel.requestRepaintAll(); }
From source file:at.peppol.webgui.app.MainWindow.java
License:Mozilla Public License
public void showInitialMainContent(UserFolder<?> userFolder) { // ------ START: Main Content ------- final VerticalLayout mainContentLayout = new VerticalLayout(); mainContentLayout.addStyleName("margin"); final VerticalLayout topmain = new VerticalLayout(); topmain.setSpacing(true);//from ww w . j a va 2s. c o m topmain.setWidth("100%"); final Label bigPAWGLabel = new Label("PEPPOL Post Award Web GUI"); bigPAWGLabel.setStyleName("huge"); topmain.addComponent(bigPAWGLabel); final Label blahContent = new Label( "This is a mockup of the GUI that is going" + " to be the PAWG. It is created by the Greek" + " and Austrian teams as a fine replacement " + " of the Demo Client"); blahContent.setWidth("80%"); blahContent.addStyleName("big"); //topmain.addComponent (blahContent); //HorizontalLayout itemsPanel = new ShowItemsPanel("Items", um, userFolder); final ShowItemsPanel itemsPanel = new ShowItemsPanel("Items", um, userFolder); this.itemsPanel = itemsPanel; topmain.addComponent(itemsPanel); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); topmain.addComponent(buttonsLayout); Button loadButton = new Button("Load invoice"); //topmain.addComponent(loadButton); buttonsLayout.addComponent(loadButton); loadButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Table table = itemsPanel.getTable(); if (table.getValue() != null) { //InvoiceType inv = (InvoiceType)table.getItem(table.getValue()).getItemProperty("invoice").getValue(); //InvoiceBean invBean = (InvoiceBean)table.getItem(table.getValue()); InvoiceBean invBean = ((InvoiceBeanContainer) table.getContainerDataSource()) .getItem(table.getValue()).getBean(); //System.out.println("Invoice is: "+invBean); showInvoiceForm(invBean); } } }); Button sendButton = new Button("Send invoice"); buttonsLayout.addComponent(sendButton); sendButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Table table = itemsPanel.getTable(); if (table.getValue() != null) { InvoiceBean invBean = ((InvoiceBeanContainer) table.getContainerDataSource()) .getItem(table.getValue()).getBean(); String path = invBean.getFolderEntryID(); FileSystemResource s = new FileSystemResource(path); SendInvoice.sendDocument(s); //file is sent. move invoice to outbox um.moveInvoice(invBean, um.getDrafts(), um.getOutbox()); //itemsPanel.getTable().requestRepaint(); itemsPanel.init(um.getDrafts()); } } catch (FileNotFoundException e) { getWindow().showNotification("Could not find invoice file", Notification.TYPE_ERROR_MESSAGE); } catch (Exception e) { getWindow().showNotification("Could not send invoice. AP connection error", Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); } } }); final Button learnMoreBtn = new Button("Learn More >>"); learnMoreBtn.addStyleName("tall default"); //topmain.addComponent (learnMoreBtn); mainContentLayout.addComponent(topmain); // ------ END: Main Content --------- mainContentLayout.setHeight("100%"); mainContentLayout.setSizeFull(); mainContentLayout.setSpacing(true); mainContentLayout.setWidth("100%"); middleContentLayout.setWidth("100%"); middleContentLayout.setHeight("100%"); middleContentLayout.setMargin(true); // -------- addComponent(middleContentLayout); addComponent(footerLayout); if (mainContentComponent != null) { middleContentLayout.replaceComponent(mainContentComponent, mainContentLayout); } else { middleContentLayout.addComponent(mainContentLayout); } middleContentLayout.setExpandRatio(mainContentLayout, 1); mainContentComponent = mainContentLayout; }
From source file:biz.eelis.translation.EntriesFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(new FilterDescriptor("basename", "basename", "Basename", new TextField(), 200, "like", String.class, "")); filterDefinitions.add(new FilterDescriptor("language", "language", "Language", new TextField(), 30, "=", String.class, "")); filterDefinitions.add(//w w w . j a va2s. co m new FilterDescriptor("country", "country", "Country", new TextField(), 30, "=", String.class, "")); filterDefinitions .add(new FilterDescriptor("key", "key", "Key", new TextField(), 200, "like", String.class, "")); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull(); gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 0); final Table table = new FormattingTable(); grid = new Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); gridLayout.addComponent(grid, 0, 1); final Button addButton = getSite().getButton("add"); buttonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entry = new Entry(); entry.setCreated(new Date()); entry.setModified(entry.getCreated()); entry.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class); entryView.edit(entry, true); } }); final Button editButton = getSite().getButton("edit"); buttonLayout.addComponent(editButton); editButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entity = container.getEntity(grid.getSelectedItemId()); final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class); entryView.edit(entity, false); } }); final Button removeButton = getSite().getButton("remove"); buttonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { container.removeItem(grid.getSelectedItemId()); container.commit(); } }); final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); }
From source file:biz.eelis.translation.EntryFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 3); gridLayout.setSizeFull();/* ww w . j a v a 2s.co m*/ gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(2, 1f); setViewContent(gridLayout); entryEditor = new ValidatingEditor(TranslationSiteFields.getFieldDescriptors(Entry.class)); entryEditor.setCaption("Entry"); entryEditor.addListener((ValidatingEditorStateListener) this); gridLayout.addComponent(entryEditor, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 1); saveButton = new Button("Save"); saveButton.setImmediate(true); buttonLayout.addComponent(saveButton); saveButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { entryEditor.commit(); entityManager.getTransaction().begin(); try { entity = entityManager.merge(entity); entity.setAuthor(getSite().getSecurityProvider().getUser()); entity.setModified(new Date()); entityManager.persist(entity); entityManager.getTransaction().commit(); entityManager.detach(entity); entryEditor.discard(); container.refresh(); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + entity, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); buttonLayout.addComponent(discardButton); discardButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { entryEditor.discard(); } }); final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); container.getQueryView().getQueryDefinition().setMaxQuerySize(1); ContainerUtil.addContainerProperties(container, fieldDescriptors); final Table table = new FormattingTable(); final Grid grid = new Grid(table, container); grid.setCaption("All Translations"); grid.setSizeFull(); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); gridLayout.addComponent(grid, 0, 2); }
From source file:br.com.anteros.mobileserver.app.form.ExecuteForm.java
License:Apache License
private void createForm() { if (actionSynchronism.getItems() != null) { Label lblTitle = new Label("Parmetros de execuo Ao " + actionSynchronism.getName() + " (" + actionSynchronism.getId() + ")"); lblTitle.setStyleName("h2 color"); lblTitle.setImmediate(false);//from w w w.jav a2s .co m addComponent(lblTitle); setComponentAlignment(lblTitle, Alignment.TOP_LEFT); Synchronism synchronism = actionSynchronism.getItems().iterator().next(); executeForm = new Form(); fields.clear(); ParameterSynchronism[] parameters = null; if (synchronism instanceof TableSynchronism) parameters = ((TableSynchronism) synchronism).getParameters(); if (synchronism instanceof ProcedureSynchronism) parameters = ((ProcedureSynchronism) synchronism).getParameters(); for (ParameterSynchronism param : parameters) { if (param.getParameterType().intValue() == ParameterSynchronism.INPUT || param.getParameterType().intValue() == ParameterSynchronism.SUBSTITUITION) { String value = FieldTypes.getFieldTypes().get(param.getParameterDataType().intValue() + ""); if (value != null) { if (FieldTypes.UNKNOW.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("400px"); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.INTEGER.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.VARCHAR.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("400px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.FLOAT.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.NUMERIC.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.DATE.equalsIgnoreCase(value)) { PopupDateField field = new PopupDateField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); field.setResolution(PopupDateField.RESOLUTION_DAY); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.TIME.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } else if (FieldTypes.TIMESTAMP.equalsIgnoreCase(value)) { TextField field = new TextField(); field.setCaption(param.getName()); field.setWidth("150px"); field.setRequired(true); field.setRequiredError("Informe o valor para o campo " + param.getName()); executeForm.addField(param.getName(), field); fields.add(field); } } } } panelForm = new Panel(); panelForm.setHeight("100%"); panelForm.setWidth("100%"); panelForm.setScrollable(true); addComponent(panelForm); executeForm.setImmediate(true); executeForm.setWidth("100%"); panelForm.addComponent(executeForm); executeCommit = new CheckBox("Executar COMMIT no final do processo?"); addComponent(executeCommit); HorizontalLayout buttons = new HorizontalLayout(); buttons.setImmediate(false); buttons.setWidth("600px"); buttons.setHeight("-1px"); buttons.setMargin(false); buttons.setSpacing(true); addComponent(buttons); btnExecute = new Button(); btnExecute.setCaption("Executar"); btnExecute.setIcon(new ThemeResource("icons/16/run.png")); btnExecute.addListener(clickListener); buttons.addComponent(btnExecute); buttons.setComponentAlignment(btnExecute, Alignment.MIDDLE_RIGHT); buttons.setExpandRatio(btnExecute, 1); btnClose = new Button(); btnClose.setCaption("Fechar"); btnClose.setIcon(new ThemeResource("icons/16/doorOut.png")); btnClose.addListener(clickListener); buttons.addComponent(btnClose); buttons.setComponentAlignment(btnClose, Alignment.MIDDLE_RIGHT); buttons.setMargin(true, false, true, false); addComponent(buttons); pageControl = new TabSheet(); pageControl.setImmediate(true); pageControl.setWidth("100.0%"); pageControl.setHeight("100.0%"); textPanel = new Panel(); textPanel.setImmediate(true); textPanel.setWidth("100%"); textPanel.setHeight("100%"); pageControl.addTab(textPanel, "Resultado", null); addComponent(pageControl); setExpandRatio(pageControl, 1.0f); } }
From source file:br.com.anteros.mobileserver.util.UserMessages.java
License:Apache License
public Window confirm(String title, String message, String okTitle, String cancelTitle, Button.ClickListener listener) { if (title == null) { title = CONFIRM_OK_TITLE;// ww w . j a v a2 s . c o m } if (cancelTitle == null) { cancelTitle = CONFIRM_CANCEL_TITLE; } if (okTitle == null) { okTitle = CONFIRM_OK_TITLE; } final Window confirm = new Window(title); this.confirm = confirm; win.addWindow(confirm); confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { Object data = ce.getWindow().getData(); if (data != null) { try { } catch (Exception exception) { error("Unhandled Exception", exception); } } } }); int chrW = 5; int chrH = 15; int txtWidth = Math.max(250, Math.min(350, message.length() * chrW)); int btnHeight = 25; int vmargin = 100; int hmargin = 40; int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth; confirm.setWidth((txtWidth + hmargin) + "px"); confirm.setHeight((vmargin + txtHeight + btnHeight) + "px"); confirm.getContent().setSizeFull(); confirm.center(); confirm.setModal(true); Label text = new Label(message); text.setWidth("100%"); text.setHeight("100%"); HorizontalLayout buttons = new HorizontalLayout(); buttons.setHeight(btnHeight + 5 + "px"); buttons.setWidth("100%"); buttons.setSpacing(true); buttons.setMargin(false); Button cancel = new Button(cancelTitle, listener); cancel.setIcon(new ThemeResource("icons/16/no.png")); cancel.setData(USER_CONFIRM_CANCEL); cancel.setClickShortcut(KeyCode.ESCAPE); Button ok = new Button(okTitle, listener); ok.setIcon(new ThemeResource("icons/16/yes.png")); ok.setData(USER_CONFIRM_OK); ok.setClickShortcut(KeyCode.ENTER); buttons.addComponent(ok); buttons.setExpandRatio(ok, 1); buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT); buttons.addComponent(cancel); buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT); confirm.addComponent(text); confirm.addComponent(buttons); ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f); confirm.setResizable(false); return confirm; }
From source file:br.gov.frameworkdemoiselle.vaadin.ui.CrudForm.java
License:Open Source License
protected void createButtons() { buttonSave = new Button(this.bundle.getString("button.save")); buttonClear = new Button(this.bundle.getString("button.clear")); buttonDelete = new Button(this.bundle.getString("button.delete")); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(getButtonSave()); buttons.addComponent(getButtonDelete()); buttons.addComponent(buttonClear);/*from w w w.ja v a2 s. c om*/ getFooter().addComponent(buttons); getButtonSave().addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { try { commit(); } catch (InvalidValueException exception) { beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessInvalidValue>() { }); getWindow().showNotification(exception.getMessage(), Notification.TYPE_WARNING_MESSAGE); return; } beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessSave>() { }); } }); buttonClear.addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { CrudForm.this.discard(); beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessClear>() { }); } }); getButtonDelete().addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessDelete>() { }); } }); }
From source file:br.gov.sp.saovicente.MyVaadinApplication.java
License:Apache License
@Override public void init() { final Window mainWindow = new Window("Sampleinvientchart2 Application"); mainWindow.setSizeFull();/* www .j av a2s . c o m*/ setMainWindow(mainWindow); mgberr = new MessageBox(getMainWindow(), "My message ERRO...", MessageBox.Icon.ERROR, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); mgbinf = new MessageBox(getMainWindow(), "My message INFO...", MessageBox.Icon.INFO, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); mgbquest = new MessageBox(getMainWindow(), "My message QUESTION...", MessageBox.Icon.QUESTION, "Hello World!", new MessageBox.ButtonConfig(ButtonType.YES, "YES"), new MessageBox.ButtonConfig(ButtonType.NO, "NO")); mgbnone = new MessageBox(getMainWindow(), "My message NONE...", MessageBox.Icon.QUESTION, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); mgbwarn = new MessageBox(getMainWindow(), "My message WARN...", MessageBox.Icon.WARN, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); infomacao = new Button("Informao"); infomacao.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbinf.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { } }); } }); erro = new Button("Erro"); erro.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgberr.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { System.out.println("Este boto foi pressionado: " + buttonType); } }); } }); none = new Button("None"); none.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbnone.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { System.out.println("Este boto foi pressionado: " + buttonType); } }); } }); question = new Button("Question"); question.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbquest.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType.toString().equals("YES")) { mainWindow.open(new ExternalResource("http://10.171.0.9:8080/bic/")); System.out.println("Este boto foi pressionado: " + buttonType); } else if (buttonType.toString().equals("NO")) { mainWindow.open(new ExternalResource("http://localhost:8080/modelo/")); } } }); } }); warn = new Button("Warn"); warn.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbwarn.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { System.out.println("Este boto foi pressionado: " + buttonType); } }); } }); HorizontalLayout botao = new HorizontalLayout(); botao.setSpacing(true); botao.addComponent(erro); botao.addComponent(warn); botao.addComponent(none); botao.addComponent(infomacao); botao.addComponent(question); // CustomDateField df = new CustomDateField(); //df.setbTwelveHourClock(false); // df.setbTwelveHourClock(true); // mainWindow.addComponent(df); //mainWindow.addComponent(new WidgetSetTest()); mainWindow.addComponent(botao); }
From source file:by.bigvova.ui.LoginUI.java
License:Apache License
private Component buildFields() { final VerticalLayout layout = new VerticalLayout(); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.setIcon(FontAwesome.USER);//from w w w.jav a 2 s . c o m username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final PasswordField password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(ShortcutAction.KeyCode.ENTER); signin.focus(); final CheckBox checkBox = new CheckBox("Remember me", true); signin.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { login(username.getValue(), password.getValue(), checkBox.getValue()); } }); fields.addComponents(username, password, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); layout.setSpacing(true); layout.addComponent(fields); layout.addComponent(checkBox); return layout; }
From source file:ch.bfh.ti.soed.hs16.srs.black.view.loginView.LoginView.java
License:Open Source License
public LoginView() { usernameField = new TextField("Username"); usernameField.setIcon(FontAwesome.USER); usernameField.setWidth(12, Unit.EM); passwordField = new PasswordField("Password"); passwordField.setIcon(FontAwesome.KEY); passwordField.setWidth(12, Unit.EM); loginButton = new Button("Login"); loginButton.setWidth(5, Unit.EM);//from w w w. j av a2 s . c o m loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY); signUpButton = new Button("Sign Up"); signUpButton.setWidth(6, Unit.EM); VerticalLayout layout = new VerticalLayout(); HorizontalLayout layoutButtons = new HorizontalLayout(loginButton, signUpButton); layoutButtons.setSpacing(true); Panel panel = new Panel("Login - Smart ReservationEntity System"); panel.setSizeUndefined(); layout.addComponent(panel); FormLayout content = new FormLayout(); content.addComponents(usernameField, passwordField, layoutButtons); content.setSizeFull(); content.setMargin(true); panel.setContent(content); setCompositionRoot(layout); layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); layout.setMargin(new MarginInfo(true, false, false, false)); }