List of usage examples for com.vaadin.ui HorizontalLayout addComponent
@Override public void addComponent(Component c)
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();//from ww w. j a v a2 s. com 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 ww .j av a2 s .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;/*from w ww . ja va 2 s . com*/ } 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);/* www . ja v a 2 s. c o m*/ buttons.addComponent(getButtonSave()); buttons.addComponent(getButtonDelete()); buttons.addComponent(buttonClear); 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();/*from w w w. ja v a 2 s . co 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.MainUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { EventBus.register(this); getPage().setTitle("FoodNote"); UI.getCurrent().setLocale(Locale.forLanguageTag("ru-RU")); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override/*from ww w .ja v a2 s. c o m*/ public void error(com.vaadin.server.ErrorEvent event) { if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) { Notification.show("Sorry, you don't have access to do that."); } else { super.error(event); } } }); HorizontalLayout layout = new HorizontalLayout(); layout.setSizeFull(); // By adding a security item filter, only views that are accessible to the user will show up in the side bar. sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity)); sideBar.setHeader(new CssLayout() { { Label header = new Label("<span>Food</span>Note", ContentMode.HTML); header.setWidth(100, Unit.PERCENTAGE); header.setHeightUndefined(); addComponent(header); addComponent(buildUserMenu()); } }); sideBar.getHeader().setStyleName("branding"); layout.addComponent(sideBar); CssLayout viewContainer = new CssLayout(); viewContainer.setSizeFull(); layout.addComponent(viewContainer); layout.setExpandRatio(viewContainer, 1f); Navigator navigator = new Navigator(this, viewContainer); // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all. springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class); navigator.addProvider(springViewProvider); navigator.setErrorView(ErrorView.class); navigator.navigateTo(navigator.getState()); setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI. }
From source file:cb_server.SettingsWindow.java
License:Open Source License
private void addSaveCancelButtons() { HorizontalLayout hl = new HorizontalLayout(); final Button btnSave = new Button(Translation.Get("save".hashCode())); final Button btnCancel = new Button(Translation.Get("cancel".hashCode())); hl.addComponent(btnSave); hl.addComponent(btnCancel);//from w w w . j a va2 s .c o m btnCancel.addClickListener(new ClickListener() { private static final long serialVersionUID = -4799987364890297976L; @Override public void buttonClick(ClickEvent event) { Config.settings.LoadFromLastValue(); SettingsWindow.this.close(); } }); btnSave.addClickListener(new ClickListener() { private static final long serialVersionUID = -878673538684730570L; @Override public void buttonClick(ClickEvent event) { String lang = (String) langSpinner.getValue(); for (Lang tmp : Translation.GetLangs(SettingsClass.LanguagePath.getValue())) { if (lang.equals(tmp.Name)) { CB_UI_Base_Settings.Sel_LanguagePath.setValue(tmp.Path); try { Translation.LoadTranslation(tmp.Path); } catch (Exception e) { try { Translation.LoadTranslation(CB_UI_Base_Settings.Sel_LanguagePath.getDefaultValue()); } catch (IOException e1) { e1.printStackTrace(); } } break; } } Config.settings.WriteToDB(); Config.settings.SaveToLastValue(); SettingsWindow.this.close(); } }); content.addComponent(hl); }
From source file:cb_server.SettingsWindow.java
License:Open Source License
private Component getLogInButton(int i) { com.vaadin.ui.HorizontalLayout box = new HorizontalLayout(); com.vaadin.ui.Button button = new com.vaadin.ui.Button(); button.setCaption("Get API Key"); button.addClickListener(new ClickListener() { private static final long serialVersionUID = -1417363407758383092L; @Override//w w w .j a v a 2 s . c o m public void buttonClick(ClickEvent event) { LogInWindow sub = LogInWindow.getInstanz(); if (!UI.getCurrent().getWindows().contains(sub)) // Add it to the root component UI.getCurrent().addWindow(sub); } }); box.addComponent(button); return box; }
From source file:cb_server.SettingsWindow.java
License:Open Source License
private Component getAudioView(SettingsAudio sB, int backgroundChanger) { com.vaadin.ui.HorizontalLayout box = new HorizontalLayout(); com.vaadin.ui.Label label = new com.vaadin.ui.Label(); label.setCaption(sB.getName());/*from w w w .ja v a2s . com*/ box.addComponent(label); return box; }
From source file:cb_server.SettingsWindow.java
License:Open Source License
private Component getStringView(final SettingString sB, int backgroundChanger) { com.vaadin.ui.HorizontalLayout box = new HorizontalLayout(); box.setWidth(100, Unit.PERCENTAGE);/*from w w w.j a v a 2s . com*/ com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getValue())); input.setWidth(50, Unit.PERCENTAGE); input.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = -634498493292006581L; @Override public void textChange(TextChangeEvent event) { sB.setValue(event.getText()); } }); box.addComponent(input); return box; }