List of usage examples for com.vaadin.ui Alignment MIDDLE_LEFT
Alignment MIDDLE_LEFT
To view the source code for com.vaadin.ui Alignment MIDDLE_LEFT.
Click Source Link
From source file:fr.univlorraine.mondossierweb.views.windows.PreferencesApplicationWindow.java
License:Apache License
/** * Cre une fentre d'dition des preferences applicative * @param prfrence diter//from w w w . j av a2 s. c o m */ public PreferencesApplicationWindow(PreferencesApplication prefApp) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Formulaire */ fieldGroup = new BeanFieldGroup<>(PreferencesApplication.class); fieldGroup.setItemDataSource(prefApp); fieldGroup.setFieldFactory(new FieldGroupFieldFactory() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("rawtypes") public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) { if (fieldType == NativeSelect.class) { final NativeSelect field = new NativeSelect(); field.addItem("true"); field.addItem("false"); field.setNullSelectionAllowed(false); field.setImmediate(true); //field.setValue(centre.getTemSrv()); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { field.setValue(event.getProperty().getValue()); } }); return fieldType.cast(field); } else { final TextField field = new TextField(); field.setImmediate(true); field.addTextChangeListener(new FieldEvents.TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { if (!field.isReadOnly()) { field.setValue(event.getText()); } } }); return fieldType.cast(field); } } }); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".confAppTable." + fieldName, null, getLocale()); //Si on est sur un parametre booleen if (fieldName.equals("valeur") && estUneValeurBooleenne(prefApp.getValeur())) { //On forme le nativeSelect Field<?> field = fieldGroup.buildAndBind(caption, fieldName, NativeSelect.class); formLayout.addComponent(field); } else { Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } formLayout.addComponent(field); } } fieldGroup.getField("prefId").setReadOnly(prefApp.getPrefId() != null); fieldGroup.getField("prefDesc").setReadOnly(prefApp.getPrefDesc() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); /* Enregistre la conf saisie */ configController.saveAppParameter(prefApp); /* Ferme la fentre */ close(); } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:fr.univlorraine.mondossierweb.views.windows.SwapUtilisateurWindow.java
License:Apache License
/** * Cre une fentre d'dition du swap utilisateur * @param swap utilisateur diter//from w w w . j a va 2s . c o m */ public SwapUtilisateurWindow(UtilisateurSwap swap, boolean ajout) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ if (ajout) { setCaption(applicationContext.getMessage(NAME + ".title.ajout", null, getLocale())); } else { setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); } /* Formulaire */ fieldGroup = new BeanFieldGroup<>(UtilisateurSwap.class); fieldGroup.setItemDataSource(swap); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".swapUserTable." + fieldName, null, getLocale()); Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } if (field instanceof DateField) { ((DateField) field).setResolution(DateField.RESOLUTION_MIN); } formLayout.addComponent(field); } //fieldGroup.getField("loginCible").setReadOnly(swap.getLoginCible() != null); fieldGroup.getField("loginSource").setReadOnly(swap.getLoginSource() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); boolean commitok = true; if (ajout) { //On regarde si le login source n'est pas dj dans la table String loginSource = (String) fieldGroup.getField("loginSource").getValue(); if (configController.getSwapUtilisateur(loginSource) != null) { commitok = false; //afficher message d'erreur Notification.show(applicationContext.getMessage(NAME + ".error.loginexistant", null, UI.getCurrent().getLocale()), Notification.Type.ERROR_MESSAGE); } } if (commitok) { /* Enregistre le swap saisie */ configController.saveSwap(swap); /* Ferme la fentre */ close(); } } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:gms.demo.service.presentation.ui.CreateMemberInfoPanel.java
License:Open Source License
CreateMemberInfoPanel(MainUI app) { this.app = app; // createButton form and data source Form form = new Form(); form.setCaption("Create New MemberInfo"); form.setWriteThrough(false);//w w w . j a v a2 s . co m form.setItemDataSource(propertysetItem); // validation // todo: more of these form.getField(PORT).addValidator(new IntegerValidator(PORT + " field must be an integer.")); // buttons createButton = new Button("Create", form, "commit"); Button resetButton = new Button("Reset", form, "discard"); cancelButton = new Button("Cancel"); form.getFooter().addComponent(createButton); form.getFooter().addComponent(resetButton); form.getFooter().addComponent(cancelButton); form.setWidth(24f, Sizeable.UNITS_EM); // explanatory text Label instructions = new Label(INSTRUCTIONS_TEXT, Label.CONTENT_XHTML); instructions.setWidth(24f, Sizeable.UNITS_EM); // now add to panel HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSpacing(true); hLayout.addComponent(form); hLayout.addComponent(instructions); hLayout.setComponentAlignment(instructions, Alignment.MIDDLE_LEFT); addComponent(hLayout); }
From source file:info.magnolia.configuration.app.overview.toolbar.ToolbarViewImpl.java
License:Open Source License
@Inject public ToolbarViewImpl() { Responsive.makeResponsive(this); addStyleName("toolbar-layout"); setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); setSpacing(true);// w w w. jav a2s. c o m setMargin(new MarginInfo(true, false, true, false)); setWidth("100%"); initFilterInputProperties(moduleFilterSelect); initFilterInputProperties(definitionTypeFilterSelect); initFilterInputProperties(nameField); initFilterInputProperties(onlyIncludeDefinitionsWithErrorsCheckBox); initFilterInputProperties(onlyIncludeFileBasedDefinitions); groupBySelect.setHeight("25px"); moduleFilterSelect.setHeight("25px"); definitionTypeFilterSelect.setHeight("25px"); groupBySelect.setWidth("160px"); groupBySelect.setNullSelectionAllowed(false); for (ConfigOverviewView.DefinitionAggregationType type : ConfigOverviewView.DefinitionAggregationType .values()) { groupBySelect.addItem(type); } groupBySelect.setValue(ConfigOverviewView.DefinitionAggregationType.registry); groupBySelect.addValueChangeListener(groupByChangeListener); groupByLayout.setSizeUndefined(); filterLayout.setSizeUndefined(); groupByLayout.addComponent(decorateComponent("Group by:", groupBySelect)); ; filterLayout.addComponent(decorateComponent("Module:", moduleFilterSelect)); filterLayout.addComponent(decorateComponent("Type:", definitionTypeFilterSelect)); filterLayout.addComponent(decorateComponent("Name:", nameField)); filterLayout.addComponent(decorateComponent("Invalid:", onlyIncludeDefinitionsWithErrorsCheckBox)); filterLayout.addComponent(decorateComponent("File-based:", onlyIncludeFileBasedDefinitions)); moduleFilterSelect.setInputPrompt("All modules"); definitionTypeFilterSelect.setInputPrompt("All types"); nameField.setInputPrompt("Any name"); groupByLayout.addStyleName("entry"); groupByLayout.setMargin(true); filterLayout.addStyleName("entry"); filterLayout.setSpacing(true); filterLayout.setMargin(true); addComponent(groupByLayout); final Component filterWrapper = decorateComponent("Filter:", filterLayout); addComponent(filterWrapper); addComponent(showFileButton); addComponent(openJcrConfig); setExpandRatio(openJcrConfig, 1f); }
From source file:info.magnolia.configuration.app.overview.toolbar.ToolbarViewImpl.java
License:Open Source License
private Component decorateComponent(String caption, Component toWrap) { final HorizontalLayout result = new HorizontalLayout(); result.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); result.setSpacing(true);/*from ww w . j av a 2 s. c o m*/ result.setSizeUndefined(); final Label captionLabel = new Label(caption); captionLabel.setSizeUndefined(); captionLabel.addStyleName("caption-label"); result.addComponent(captionLabel); result.addComponent(toWrap); return result; }
From source file:info.magnolia.configuration.app.problem.toolbar.ProblemToolbarViewImpl.java
License:Open Source License
@Inject public ProblemToolbarViewImpl(SimpleTranslator i18n) { this.i18n = i18n; Responsive.makeResponsive(this); addStyleName("toolbar-layout"); setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); setSpacing(true);/*from w w w.j a v a 2 s . c o m*/ setMargin(new MarginInfo(true, false, true, false)); setWidth("100%"); initGroupByLayout(); iniSearchField(); }
From source file:info.magnolia.ui.form.field.LinkField.java
License:Open Source License
@Override protected Component initContent() { addStyleName("linkfield"); // Initialize root rootLayout.setSizeFull();/*from w ww .j av a2 s.c o m*/ rootLayout.setSpacing(true); // Handle Text Field textField.setImmediate(true); textField.setWidth(100, Unit.PERCENTAGE); textField.setNullRepresentation(""); textField.setNullSettingAllowed(true); // Handle Link Layout (Text Field & Select Button) linkLayout.setSizeFull(); linkLayout.addComponent(textField); linkLayout.setExpandRatio(textField, 1); linkLayout.setComponentAlignment(textField, Alignment.MIDDLE_LEFT); // Only Handle Select button if the Text field is not Read Only. if (!textField.isReadOnly()) { selectButton.addStyleName("magnoliabutton"); linkLayout.addComponent(selectButton); linkLayout.setExpandRatio(selectButton, 0); linkLayout.setComponentAlignment(selectButton, Alignment.MIDDLE_RIGHT); } setButtonCaption(StringUtils.EMPTY); rootLayout.addComponent(linkLayout); // Register the content preview if it's define. if (definition.getContentPreviewDefinition() != null && definition.getContentPreviewDefinition().getContentPreviewClass() != null) { registerContentPreview(); } return rootLayout; }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * construye el menu//ww w.j a v a2 s. com * * @param request * @return */ CssLayout buildMenu(VaadinRequest request) { HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName(ValoTheme.MENU_TITLE); menu.addComponent(top); //menu.addComponent(createThemeSelect()); Button showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (menu.getStyleName().contains("valo-menu-visible")) { menu.removeStyleName("valo-menu-visible"); } else { menu.addStyleName("valo-menu-visible"); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName("valo-menu-toggle"); showMenu.setIcon(FontAwesome.LIST); menu.addComponent(showMenu); //Label title = new Label("<h3><strong>" + getApp().getName() + "</strong></h3>", ContentMode.HTML); Button title = new Button(getApp().getName(), new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); title.addStyleName(ValoTheme.BUTTON_LINK); title.addStyleName("tituloapp"); title.setSizeUndefined(); top.addComponent(title); top.setExpandRatio(title, 1); settings = new MenuBar(); settings.addStyleName("user-menu"); settings.addStyleName("mi-user-menu"); menu.addComponent(settings); HorizontalLayout navlinks = new HorizontalLayout(); navlinks.setSpacing(true); { Button nav = new Button(VaadinIcons.ARROWS_CROSS, new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!nav", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.setDescription("Search inside menu"); nav.addStyleName("navlink"); navlinks.addComponent(nav); } if (MateuUI.getApp().isFavouritesAvailable()) { Button nav = new Button(VaadinIcons.USER_STAR, new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!favourites", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.addStyleName("navlink"); nav.setDescription("My favourites"); nav.setVisible(MateuUI.getApp().getUserData() != null); linkFavoritos = nav; navlinks.addComponent(nav); } if (MateuUI.getApp().isLastEditedAvailable()) { Button nav = new Button(VaadinIcons.RECORDS, new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!lastedited", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.addStyleName("navlink"); nav.setDescription("Last edited records"); nav.setVisible(MateuUI.getApp().getUserData() != null); linkUltimosRegistros = nav; navlinks.addComponent(nav); } HorizontalLayout aux = new HorizontalLayout(navlinks); aux.setSpacing(false); aux.addStyleName("contenedoriconosnav"); menu.addComponent(aux); if (MateuUI.getApp().isFavouritesAvailable()) { aux = new HorizontalLayout(); { Button nav = new Button(VaadinIcons.STAR, new ClickListener() { @Override public void buttonClick(ClickEvent event) { System.out.println(Page.getCurrent().getUriFragment()); System.out.println(Page.getCurrent().getLocation()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.addStyleName("navlink"); nav.setDescription("Add current page to my favourites"); nav.setVisible(MateuUI.getApp().getUserData() != null); linkNuevoFavorito = nav; aux.addComponent(nav); } aux.setSpacing(false); aux.addStyleName("contenedoriconosnav"); menu.addComponent(aux); } menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); refreshMenu(null, null); return menu; }
From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaPagedTable.java
License:Apache License
@Override public HorizontalLayout createControls() { I18nManager I18nManager = get().getI18nManager(); final PagedTableContainer container = (PagedTableContainer) getContainerDataSource(); Label itemsPerPageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PER_PAGINA)); final ComboBox itemsPerPageSelect = new ComboBox(); itemsPerPageSelect.addItem("3"); itemsPerPageSelect.addItem("10"); itemsPerPageSelect.addItem("25"); itemsPerPageSelect.addItem("50"); itemsPerPageSelect.setImmediate(true); itemsPerPageSelect.setNullSelectionAllowed(false); itemsPerPageSelect.setWidth("50px"); itemsPerPageSelect.addListener(new ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue()))); }/* w ww. java2s .c o m*/ }); itemsPerPageSelect.select(maxRecords + ""); Label pageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PAG) + " ", Label.CONTENT_XHTML); final TextField currentPageTextField = new TextField(); currentPageTextField.setValue(String.valueOf(getCurrentPage())); currentPageTextField.addValidator(new IntegerValidator(null)); Label separatorLabel = new Label(" / ", Label.CONTENT_XHTML); final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), Label.CONTENT_XHTML); currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL); currentPageTextField.setImmediate(true); currentPageTextField.addListener(new ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) { int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue())); setCurrentPage(page); } } }); pageLabel.setWidth(null); currentPageTextField.setWidth("20px"); separatorLabel.setWidth(null); totalPagesLabel.setWidth(null); HorizontalLayout controlBar = new HorizontalLayout(); HorizontalLayout pageSize = new HorizontalLayout(); HorizontalLayout pageManagement = new HorizontalLayout(); final Button first = new Button("<<", new ClickListener() { private static final long serialVersionUID = -355520120491283992L; public void buttonClick(ClickEvent event) { setCurrentPage(0); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); final Button previous = new Button("<", new ClickListener() { private static final long serialVersionUID = -355520120491283992L; public void buttonClick(ClickEvent event) { previousPage(); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); final Button next = new Button(">", new ClickListener() { private static final long serialVersionUID = -1927138212640638452L; public void buttonClick(ClickEvent event) { nextPage(); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); final Button last = new Button(">>", new ClickListener() { private static final long serialVersionUID = -355520120491283992L; public void buttonClick(ClickEvent event) { setCurrentPage(getTotalAmountOfPages()); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); first.setStyleName(Reindeer.BUTTON_LINK); previous.setStyleName(Reindeer.BUTTON_LINK); next.setStyleName(Reindeer.BUTTON_LINK); last.setStyleName(Reindeer.BUTTON_LINK); itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption"); itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox"); pageLabel.addStyleName("pagedtable-pagecaption"); currentPageTextField.addStyleName("pagedtable-pagefield"); separatorLabel.addStyleName("pagedtable-separator"); totalPagesLabel.addStyleName("pagedtable-total"); first.addStyleName("pagedtable-first"); previous.addStyleName("pagedtable-previous"); next.addStyleName("pagedtable-next"); last.addStyleName("pagedtable-last"); itemsPerPageLabel.addStyleName("pagedtable-label"); itemsPerPageSelect.addStyleName("pagedtable-combobox"); pageLabel.addStyleName("pagedtable-label"); currentPageTextField.addStyleName("pagedtable-label"); separatorLabel.addStyleName("pagedtable-label"); totalPagesLabel.addStyleName("pagedtable-label"); first.addStyleName("pagedtable-button"); previous.addStyleName("pagedtable-button"); next.addStyleName("pagedtable-button"); last.addStyleName("pagedtable-button"); pageSize.addComponent(itemsPerPageLabel); pageSize.addComponent(itemsPerPageSelect); pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT); pageSize.setSpacing(true); pageManagement.addComponent(first); pageManagement.addComponent(previous); pageManagement.addComponent(pageLabel); pageManagement.addComponent(currentPageTextField); pageManagement.addComponent(separatorLabel); pageManagement.addComponent(totalPagesLabel); pageManagement.addComponent(next); pageManagement.addComponent(last); pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT); pageManagement.setWidth(null); pageManagement.setSpacing(true); controlBar.addComponent(pageSize); controlBar.addComponent(pageManagement); controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER); controlBar.setWidth("100%"); controlBar.setExpandRatio(pageSize, 1); addListener(new PageChangeListener() { public void pageChanged(PagedTableChangeEvent event) { first.setEnabled(container.getStartIndex() > 0); previous.setEnabled(container.getStartIndex() > 0); next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); currentPageTextField.setValue(String.valueOf(getCurrentPage())); totalPagesLabel.setValue(getTotalAmountOfPages()); itemsPerPageSelect.setValue(String.valueOf(getPageLength())); } }); controlBar.setStyleName("pagination"); return controlBar; }
From source file:jp.primecloud.auto.ui.MyCloudManage.java
License:Open Source License
MyCloudManage(Application ap) { apl = ap;/* w w w . j a v a 2 s . com*/ // setIcon(Icons.EDITMINI.resource()); setCaption(ViewProperties.getCaption("window.myCloudManage")); setModal(true); setWidth("550px"); VerticalLayout layout = (VerticalLayout) getContent(); layout.setMargin(true); // ? HorizontalLayout tbar = new HorizontalLayout(); tbar.setWidth("100%"); tbar.setSpacing(true); // ? Label tcaption = new Label(ViewProperties.getCaption("table.cloud")); tcaption.setWidth("300px"); tbar.addComponent(tcaption); tbar.setComponentAlignment(tcaption, Alignment.MIDDLE_LEFT); // Edit Button editButton = new Button(ViewProperties.getCaption("button.editCloud")); editButton.setDescription(ViewProperties.getCaption("description.editCloud")); editButton.setIcon(Icons.EDITMINI.resource()); editButton.setWidth("85px"); editButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.editButtonClick(event); } }); tbar.addComponent(editButton); tbar.setComponentAlignment(editButton, Alignment.BOTTOM_RIGHT); // Delete Button deleteButton = new Button(ViewProperties.getCaption("button.delete")); deleteButton.setDescription(ViewProperties.getCaption("description.delete")); deleteButton.setWidth("85px"); deleteButton.setIcon(Icons.DELETEMINI.resource()); deleteButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.deleteButtonClick(event); } }); tbar.addComponent(deleteButton); tbar.setComponentAlignment(deleteButton, Alignment.BOTTOM_RIGHT); tbar.setExpandRatio(tcaption, 10); layout.addComponent(tbar); // ? Label spacer1 = new Label(""); spacer1.setHeight("5px"); layout.addComponent(spacer1); // cloudTable = new CloudTable(); layout.addComponent(cloudTable); // ? Label spacer2 = new Label(""); spacer2.setHeight("7px"); layout.addComponent(spacer2); // ?? HorizontalLayout bbar = new HorizontalLayout(); bbar.setWidth("100%"); HorizontalLayout rlay = new HorizontalLayout(); rlay.setSpacing(true); // New Button addButton = new Button(ViewProperties.getCaption("button.newCloud")); addButton.setDescription(ViewProperties.getCaption("description.newCloud")); addButton.setIcon(Icons.ADD.resource()); addButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.addButtonClick(event); } }); bbar.addComponent(addButton); bbar.setComponentAlignment(addButton, Alignment.MIDDLE_LEFT); // Switch Button switchButton = new Button(ViewProperties.getCaption("button.switch")); switchButton.setDescription(ViewProperties.getCaption("description.mycloud.switch")); switchButton.setWidth("85px"); switchButton.setIcon(Icons.SELECTMINI.resource()); switchButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.switchButtonClick(event); } }); // [Enter]?switchButton switchButton.setClickShortcut(KeyCode.ENTER); switchButton.focus(); rlay.addComponent(switchButton); // Cancel Button cancelButton = new Button(ViewProperties.getCaption("button.cancel")); cancelButton.setDescription(ViewProperties.getCaption("description.cancel")); cancelButton.setWidth("85px"); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.close(); } }); rlay.addComponent(cancelButton); bbar.addComponent(rlay); bbar.setComponentAlignment(rlay, Alignment.MIDDLE_RIGHT); layout.addComponent(bbar); // ??? initData(); //???/? if (ViewContext.getPowerUser()) { addButton.setEnabled(true); deleteButton.setEnabled(true); editButton.setEnabled(true); //?????????????? if (ViewContext.getPowerUser() && !ViewContext.getPowerDefaultMaster().equals(ViewContext.getLoginUser())) { addButton.setEnabled(false); } } else if (ViewContext.getUserNo().equals(ViewContext.getLoginUser())) { addButton.setEnabled(true); deleteButton.setEnabled(true); editButton.setEnabled(true); } else { addButton.setEnabled(false); deleteButton.setEnabled(false); editButton.setEnabled(false); } // showClouds(); }