List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:com.lizardtech.expresszip.vaadin.SetupMapViewComponent.java
License:Apache License
public SetupMapViewComponent() { listeners = new ArrayList<SetupMapViewListener>(); cmbProjection = new ComboBox(); cmbProjection.setTextInputAllowed(false); HorizontalLayout projectionLayout = new HorizontalLayout(); projectionLayout.addComponent(cmbProjection); projectionLayout.setWidth(100f, UNITS_PERCENTAGE); setSizeFull();/*from w ww .j a va2s . com*/ // main layout VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); // instruction banner Label step = new Label("Step 2: Select Export Region"); step.addStyleName("step"); layout.addComponent(step); // // setup tree data source // treeHier = new HierarchicalContainer(); treeHier.addContainerProperty(ExpressZipTreeTable.LAYER, ExpressZipLayer.class, null); treeHier.addContainerProperty(DRAG_PROPERTY, Embedded.class, null); // table holding layers treeTable = new ExpressZipTreeTable(); treeTable.setContainerDataSource(treeHier); treeTable.setDragMode(TableDragMode.ROW); treeTable.setColumnHeaders(new String[] { ExpressZipTreeTable.LAYER, "" }); treeTable.setColumnExpandRatio(ExpressZipTreeTable.LAYER, 1); treeTable.setColumnWidth(DRAG_PROPERTY, 23); // upload shape file btnUploadShapeFile.setFieldType(FieldType.BYTE_ARRAY); btnUploadShapeFile.setButtonCaption(""); btnUploadShapeFile.setSizeUndefined(); btnUploadShapeFile.addStyleName("shapefile"); // remove shape file btnRemoveShapeFile.addListener(this); btnRemoveShapeFile.setSizeUndefined(); btnRemoveShapeFile.setVisible(false); btnRemoveShapeFile.setIcon(new ThemeResource("img/RemoveShapefileStandard23px.png")); btnRemoveShapeFile.setStyleName(BaseTheme.BUTTON_LINK); btnRemoveShapeFile.addStyleName("shapefile"); HorizontalLayout hznUpload = new HorizontalLayout(); Panel coordPanel = new Panel("Export Extent"); layout.addComponent(treeTable); layout.addComponent(new Panel(PROJECTION, projectionLayout)); layout.addComponent(new Panel(SHAPEFILE_UPLOAD, hznUpload)); layout.addComponent(coordPanel); layout.setSpacing(true); hznUpload.addComponent(btnUploadShapeFile); hznUpload.addComponent(btnRemoveShapeFile); hznUpload.addComponent(lblCurrentShapeFile); hznUpload.setExpandRatio(lblCurrentShapeFile, 1f); hznUpload.setComponentAlignment(lblCurrentShapeFile, Alignment.MIDDLE_LEFT); hznUpload.setWidth("100%"); cmbProjection.setWidth("100%"); topTextField.setWidth(150, UNITS_PIXELS); topTextField.setImmediate(true); topTextField.setRequired(true); topTextField.addListener(topListener); leftTextField.setWidth(150, UNITS_PIXELS); leftTextField.setImmediate(true); leftTextField.setRequired(true); leftTextField.addListener(leftListener); bottomTextField.setWidth(150, UNITS_PIXELS); bottomTextField.setImmediate(true); bottomTextField.setRequired(true); bottomTextField.addListener(bottomListener); rightTextField.setWidth(150, UNITS_PIXELS); rightTextField.setImmediate(true); rightTextField.setRequired(true); rightTextField.addListener(rightListener); VerticalLayout coordLayout = new VerticalLayout(); coordLayout.setSizeFull(); coordPanel.setContent(coordLayout); coordLayout.addComponent(topTextField); HorizontalLayout leftRightLayout = new HorizontalLayout(); leftRightLayout.setWidth("100%"); leftRightLayout.addComponent(leftTextField); leftRightLayout.addComponent(rightTextField); leftRightLayout.setComponentAlignment(leftTextField, Alignment.MIDDLE_LEFT); leftRightLayout.setComponentAlignment(rightTextField, Alignment.MIDDLE_RIGHT); coordLayout.addComponent(leftRightLayout); coordLayout.addComponent(bottomTextField); coordLayout.setComponentAlignment(topTextField, Alignment.TOP_CENTER); coordLayout.setComponentAlignment(bottomTextField, Alignment.BOTTOM_CENTER); btnNext = new ExpressZipButton("Next", Style.STEP, this); btnBack = new ExpressZipButton("Back", Style.STEP, this); HorizontalLayout backNextLayout = new HorizontalLayout(); backNextLayout.addComponent(btnBack); backNextLayout.addComponent(btnNext); btnNext.setEnabled(false); backNextLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_LEFT); backNextLayout.setComponentAlignment(btnNext, Alignment.BOTTOM_RIGHT); backNextLayout.setWidth("100%"); VerticalLayout navLayout = new VerticalLayout(); navLayout.addComponent(backNextLayout); navLayout.setSpacing(true); ThemeResource banner = new ThemeResource("img/ProgressBar2.png"); navLayout.addComponent(new Embedded(null, banner)); layout.addComponent(navLayout); layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER); layout.setExpandRatio(treeTable, 1.0f); setCompositionRoot(layout); // notify when selection changes treeTable.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (SetupMapViewListener listener : listeners) { listener.layersSelectedEvent((Set<ExpressZipLayer>) treeTable.getValue()); } } }); treeTable.addActionHandler(this); treeHier.removeAllItems(); // // drag n' drop behavior // treeTable.setDropHandler(new DropHandler() { public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } // Make sure the drag source is the same tree public void drop(DragAndDropEvent event) { // Wrapper for the object that is dragged Transferable t = event.getTransferable(); // Make sure the drag source is the same tree if (t.getSourceComponent() != treeTable) return; AbstractSelectTargetDetails target = (AbstractSelectTargetDetails) event.getTargetDetails(); // Get ids of the dragged item and the target item Object sourceItemId = t.getData("itemId"); Object targetItemId = target.getItemIdOver(); // if we drop on ourselves, ignore if (sourceItemId == targetItemId) return; // On which side of the target the item was dropped VerticalDropLocation location = target.getDropLocation(); // place source after target treeHier.moveAfterSibling(sourceItemId, targetItemId); // if top, switch them if (location == VerticalDropLocation.TOP) { treeHier.moveAfterSibling(targetItemId, sourceItemId); } Collection<ExpressZipLayer> layers = (Collection<ExpressZipLayer>) treeHier.rootItemIds(); for (SetupMapViewListener listener : listeners) listener.layerMovedEvent(layers); } }); cmbProjection.setImmediate(true); cmbProjection.setNullSelectionAllowed(false); cmbProjection.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -5188369735622627751L; @Override public void valueChange(ValueChangeEvent event) { if (cmbProjection.getValue() != null) { selectedEpsg = (String) cmbProjection.getValue(); String currentProjection = ((ExpressZipWindow) getApplication().getMainWindow()) .getExportProps().getMapProjection(); if (!selectedEpsg.equals(currentProjection)) for (SetupMapViewListener listener : new ArrayList<SetupMapViewListener>(listeners)) listener.projectionChangedEvent(selectedEpsg); } } }); }
From source file:com.logicbomb.newschool.pages.masterpages.PrimaryMasterPage.java
public PrimaryMasterPage() { //ContextWidget c= new ContextWidget(); HorizontalLayout iHorizontalLayout = new HorizontalLayout(); //addComponent(iHorizontalLayout,"top:0px;left:0px"); iHorizontalLayout.setWidth(String.valueOf(Page.getCurrent().getBrowserWindowWidth())); iHorizontalLayout.setHeight(String.valueOf(Page.getCurrent().getBrowserWindowHeight())); iHorizontalLayout.setStyleName("backColorBlack"); //String[] captions1 = {"Logo Here", "My Cool School", "Third"}; //Layout A and its sub components Panel AP = new Panel(); iHorizontalLayout.addComponent(AP);/*from ww w.j av a 2 s. co m*/ AP.setSizeFull(); AP.setStyleName("backColorBlack"); VerticalLayout A1 = new VerticalLayout(); AP.setContent(A1); //A.setSizeFull(); A1.setSpacing(true); iHorizontalLayout.setExpandRatio(AP, 1); A1.setStyleName("backColorBlack"); A1.setMargin(new MarginInfo(true, true, true, true)); Button logoImage = new Button(); logoImage.setIcon(FontAwesome.PICTURE_O); logoImage.setWidth("80px"); logoImage.setHeight(logoImage.getWidth(), Unit.PIXELS); //logoImage.setWidth("100px"); A1.addComponent(logoImage); A1.setComponentAlignment(logoImage, Alignment.TOP_CENTER); Label schoolName = new Label("The School Of Future"); schoolName.setStyleName("v-label-big"); A1.addComponent(schoolName); //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER); Label schoolMinorName = new Label("Random Branch"); schoolMinorName.setStyleName("v-label-small"); A1.addComponent(schoolMinorName); VerticalLayout A2 = new VerticalLayout(); A1.addComponent(A2); MainMenuWidget iMainMenuWidget = new MainMenuWidget(); A2.addComponent(iMainMenuWidget); //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER); //Layout B ContextWidgetTop c = new ContextWidgetTop(); c = ContextWidgetTop.ContextWidgetTransformer(c, new UserDetailsWidget(), SliderMode.TOP, SliderPanelStyles.COLOR_RED); VerticalLayout B = new VerticalLayout(); B.setSizeFull(); //B.setSpacing(true); iHorizontalLayout.addComponent(c); c.addComponent(B); iHorizontalLayout.setExpandRatio(c, 7); //Layout B1 and its sub Components HorizontalLayout B1 = new HorizontalLayout(); B.addComponent(B1); //B.setExpandRatio(B1, 1); //B1.setHeight("70px"); B1.setSizeFull(); //B1=ContextWidget.ContextWidgetTransformer(B1, new SliderMasterPage(),SliderMode.RIGHT,SliderPanelStyles.COLOR_RED); HorizontalLayout B11 = new HorizontalLayout(); B1.addComponent(B11); B1.setStyleName("backColorBlack"); B11.setSizeFull(); B1.setHeight("45px"); //B1.setStyleName("backColorWhite"); //B1.setMargin(new MarginInfo(false, true, false, true)); TextField iTextField = new TextField(); iTextField.setWidth("200px"); iTextField.setInputPrompt("Search!"); iTextField.setStyleName("v-text-type-search"); iTextField.focus(); B11.addComponent(iTextField); B11.setComponentAlignment(iTextField, Alignment.MIDDLE_LEFT); //Layout B2 and its Sub Components ContextWidget B2 = new ContextWidget(); B2.setSizeFull(); B.addComponent(B2); B.setExpandRatio(B2, 10); B2 = ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(), SliderMode.RIGHT, SliderPanelStyles.COLOR_BLUE); //B2=ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(),SliderMode.TOP,SliderPanelStyles.COLOR_RED); VerticalLayout v = new VerticalLayout(); B2.addComponent(v); Button b1111 = new Button( "Put all the inner components like this Put all the inner components like this Put all the inner components like this Put all the inner components like this"); v.addComponent(b1111); Button b1112 = new Button("Put all the inner components like this"); v.addComponent(b1112); /* Panel p = new Panel(); VerticalLayout v= new VerticalLayout(); v.addComponent(new TextField("Name")); v.addComponent(new TextField("Street address")); v.addComponent(new TextField("Postal code")); p.setContent(v); B2.addComponent(p); v.setWidth(String.valueOf(B2.getWidth()*10)+"px"); //v.setSizeFull();// <- This will cause issues. Don't do this p.setSizeFull(); */ //ContextWidget iContextPanel= new ContextWidget(p); //B2.addComponent(iContextPanel); //setPosition(p, iComponentPositionPanel); addComponent(iHorizontalLayout); }
From source file:com.lst.deploymentautomation.vaadin.page.TodoListView.java
License:Open Source License
@SuppressWarnings("serial") @Override/*from w w w.j a v a 2s. c om*/ protected Component createHeader(Component titleComponent) { LspsUI ui = (LspsUI) getUI(); actionBtn = new MenuBar(); actionBtn.addStyleName("menu-button-action"); actionBtn.setVisible(false); //initially hidden MenuItem actions = actionBtn.addItem("", new ThemeResource("../icons/popup-menu.png"), null); final ViewAction refreshTodos = new ViewAction() { @Override public void invoke() { toggleSelectionMode(false); container.refresh(); } }; actions.addItem(ui.getMessage("action.lock"), new Command() { @Override public void menuSelected(MenuItem selectedItem) { lock(); } }); actions.addItem(ui.getMessage("action.annotate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoAnnotation(getSelectedTodoIds(), refreshTodos)); } }); actions.addSeparator(); actions.addItem(ui.getMessage("action.unlock"), new Command() { @Override public void menuSelected(MenuItem selectedItem) { unlock(); } }); actions.addItem(ui.getMessage("action.reject") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoRejection(getSelectedTodoIds(), refreshTodos)); } }); actions.addItem(ui.getMessage("action.delegate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoDelegation(getSelectedTodoIds(), refreshTodos)); } }); actions.addItem(ui.getMessage("action.escalate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoEscalation(getSelectedTodoIds(), refreshTodos)); } }); selectBtn = new Button(ui.getMessage("action.select"), new ClickListener() { @Override public void buttonClick(ClickEvent event) { toggleSelectionMode(true); } }); selectBtn.addStyleName("menu-button"); cancelBtn = new Button(ui.getMessage("action.cancel"), new ClickListener() { @Override public void buttonClick(ClickEvent event) { toggleSelectionMode(false); } }); cancelBtn.setVisible(false); //initially hidden cancelBtn.addStyleName("menu-button"); titleComponent.addStyleName("l-content-title"); HorizontalLayout layout = new HorizontalLayout(); HorizontalLayout btnLayout = new HorizontalLayout(); layout.setWidth("100%"); layout.addComponent(titleComponent); layout.addComponent(btnLayout); layout.setSpacing(true); btnLayout.addComponent(actionBtn); btnLayout.addComponent(cancelBtn); btnLayout.addComponent(selectBtn); layout.setComponentAlignment(btnLayout, Alignment.MIDDLE_RIGHT); return layout; }
From source file:com.lst.deploymentautomation.vaadin.page.TodoView.java
License:Open Source License
@SuppressWarnings("serial") @Override// w w w . j a v a 2 s . c o m protected Component createHeader(Component titleComponent) { LspsUI ui = (LspsUI) getUI(); MenuBar menu = new MenuBar(); menu.addStyleName("menu-button-action"); MenuItem actions = menu.addItem("", new ThemeResource("../icons/popup-menu.png"), null); final ViewAction closeView = new ViewAction() { @Override public void invoke() { close(); //maybe close only if the to-do is not allocated to the user anymore } }; final ViewAction refreshAnnotations = new ViewAction() { @Override public void invoke() { Todo todo = todoService.getTodo(todoHolder.getTodo().getId()); refreshAnnotations(todo); } }; actions.addItem(ui.getMessage("action.info"), new Command() { @Override public void menuSelected(MenuItem selectedItem) { //get fresh info Todo todo = todoService.getTodo(todoHolder.getTodo().getId()); getUI().addWindow(new TodoDetails(todo)); } }); actions.addSeparator(); actions.addItem(ui.getMessage("action.annotate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { //get fresh info Todo todo = todoService.getTodo(todoHolder.getTodo().getId()); getUI().addWindow(new TodoAnnotation(todo, refreshAnnotations)); } }); actions.addSeparator(); actions.addItem(ui.getMessage("action.unlock"), new Command() { @Override public void menuSelected(MenuItem selectedItem) { unlock(); } }); actions.addItem(ui.getMessage("action.reject") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoRejection(todoHolder.getTodo().getId(), closeView)); } }); actions.addItem(ui.getMessage("action.delegate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoDelegation(todoHolder.getTodo().getId(), closeView)); } }); actions.addItem(ui.getMessage("action.escalate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoEscalation(todoHolder.getTodo().getId(), closeView)); } }); HorizontalLayout layout = new HorizontalLayout(); layout.setWidth("100%"); layout.addComponent(titleComponent); layout.setExpandRatio(titleComponent, 1); layout.addComponent(menu); layout.setComponentAlignment(menu, Alignment.MIDDLE_RIGHT); return layout; }
From source file:com.m1kah.ui.TodoComponent.java
License:Open Source License
private void initInputRow() { toggleAllButton = new CheckBox(); toggleAllButton.setId("toggle-all"); inputField = new TextField(); inputField.setInputPrompt("What needs to be done?"); Panel panel = new Panel(inputField); panel.addShortcutListener(new ShortcutListener("", ShortcutAction.KeyCode.ENTER, null) { @Override// w w w.j av a2 s .c o m public void handleAction(Object o, Object o1) { addNewTodo(); } }); HorizontalLayout inputFieldLayout = new HorizontalLayout(toggleAllButton, panel); inputFieldLayout.setComponentAlignment(toggleAllButton, Alignment.MIDDLE_LEFT); inputFieldLayout.setId("new-todo"); addComponent(inputFieldLayout); }
From source file:com.m1kah.ui.TodoComponent.java
License:Open Source License
private void initFooter() { itemsLeftLabel = new Label("0 items left"); filterOptionGroup = new OptionGroup(); filterOptionGroup.setId("filter-radio"); for (TodoFilter todoFilter : TodoFilter.values()) { filterOptionGroup.addItem(todoFilter); }/*from w w w . j a va 2 s.com*/ filterOptionGroup.setValue(filter); clearCompletedButton = new Button("Clear completed"); HorizontalLayout footerLayout = new HorizontalLayout(itemsLeftLabel, filterOptionGroup, clearCompletedButton); footerLayout.setWidth(100.0f, Unit.PERCENTAGE); footerLayout.setComponentAlignment(itemsLeftLabel, Alignment.MIDDLE_LEFT); footerLayout.setComponentAlignment(filterOptionGroup, Alignment.MIDDLE_CENTER); footerLayout.setComponentAlignment(clearCompletedButton, Alignment.MIDDLE_RIGHT); footerLayout.setExpandRatio(itemsLeftLabel, 0.25f); footerLayout.setExpandRatio(filterOptionGroup, 0.5f); footerLayout.setExpandRatio(clearCompletedButton, 0.25f); addComponent(footerLayout); }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.SampleCrudView.java
License:Apache License
public HorizontalLayout createTopBar() { TextField filter = new TextField(); filter.setStyleName("filter-textfield"); filter.setInputPrompt("Filter"); ResetButtonForTextField.extend(filter); filter.setImmediate(true);/*w w w. j a va 2 s.c om*/ filter.addTextChangeListener(new FieldEvents.TextChangeListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void textChange(FieldEvents.TextChangeEvent event) { table.setFilter(event.getText()); } }); newProduct = new Button("New product"); newProduct.addStyleName(ValoTheme.BUTTON_PRIMARY); newProduct.setIcon(FontAwesome.PLUS_CIRCLE); newProduct.addClickListener(new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { viewLogic.newProduct(); } }); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setSpacing(true); topLayout.setWidth("100%"); topLayout.addComponent(filter); topLayout.addComponent(newProduct); topLayout.setComponentAlignment(filter, Alignment.MIDDLE_LEFT); topLayout.setExpandRatio(filter, 1); topLayout.setStyleName("top-bar"); return topLayout; }
From source file:com.mechanicshop.components.MaintenanceLayout.java
private void buildLayout() { HorizontalLayout layoutTitle = new HorizontalLayout(); layoutTitle.setSizeUndefined();// www. j ava 2s.c o m layoutTitle.setWidth("100%"); layoutTitle.setSpacing(false); layoutTitle.setMargin(false); titleLabel.addStyleName(ValoTheme.LABEL_H2); titleLabel.addStyleName(ValoTheme.LABEL_COLORED); titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); titleLabel.setSizeUndefined(); layoutTitle.addComponent(titleLabel); layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER); VerticalLayout layoutTable = new VerticalLayout(); layoutTable.setSizeFull(); layoutTable.setSpacing(true); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); layoutButtons.setSpacing(true); layoutButtons.setSizeUndefined(); Button passwordBtn = new Button("Edit Password"); passwordBtn.addClickListener(passwordListener); passwordBtn.setImmediate(true); passwordBtn.setIcon(FontAwesome.EDIT); passwordBtn.setStyleName(ValoTheme.BUTTON_TINY); Button media1Btn = new Button("Media 1 Default Text"); media1Btn.setStyleName(ValoTheme.BUTTON_TINY); media1Btn.setImmediate(true); media1Btn.setIcon(FontAwesome.EDIT); media1Btn.addClickListener(media1Listener); Button media2Btn = new Button("Media 2 Default Text"); media2Btn.setStyleName(ValoTheme.BUTTON_TINY); media2Btn.setImmediate(true); media2Btn.setIcon(FontAwesome.EDIT); media2Btn.addClickListener(media2Listener); layoutButtons.addComponents(passwordBtn, media1Btn, media2Btn); layoutButtons.setComponentAlignment(passwordBtn, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(media1Btn, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(media2Btn, Alignment.MIDDLE_LEFT); addComponent(layoutTitle); addComponent(layoutTable); layoutTable.addComponent(layoutButtons); layoutTable.addComponent(table); layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER); layoutTable.setExpandRatio(table, 3); setComponentAlignment(layoutTitle, Alignment.TOP_CENTER); setComponentAlignment(layoutTable, Alignment.TOP_CENTER); setExpandRatio(layoutTable, 3); setSpacing(true); setMargin(true); }
From source file:com.mechanicshop.components.TableLayout.java
private void buildLayout() { HorizontalLayout layoutTitle = new HorizontalLayout(); layoutTitle.setSizeUndefined();//w w w. j a v a2 s . c om layoutTitle.setWidth("100%"); layoutTitle.setSpacing(false); layoutTitle.setMargin(false); titleLabel.addStyleName(ValoTheme.LABEL_H2); titleLabel.addStyleName(ValoTheme.LABEL_COLORED); titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); titleLabel.setSizeUndefined(); layoutTitle.addComponent(titleLabel); layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER); VerticalLayout layoutTable = new VerticalLayout(); layoutTable.addComponent(table); layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER); layoutTable.setSizeFull(); layoutTable.setSpacing(true); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); layoutButtons.setSpacing(true); layoutButtons.setSizeUndefined(); layoutButtons.setWidth("100%"); Button addBtn = new Button("Add new Car"); addBtn.addClickListener(addBtnListener); addBtn.setImmediate(true); addBtn.setStyleName(ValoTheme.BUTTON_TINY); addBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button deleteBtn = new Button("Delete Selected"); deleteBtn.setStyleName(ValoTheme.BUTTON_TINY); deleteBtn.addStyleName(ValoTheme.BUTTON_DANGER); deleteBtn.setImmediate(true); deleteBtn.addClickListener(removeListener); btnSendSMS.setStyleName(ValoTheme.BUTTON_TINY); btnSendSMS.addStyleName(ValoTheme.BUTTON_FRIENDLY); btnSendSMS.setImmediate(true); btnSendSMS.addClickListener(sendSMSBtnListener); searchTextField.setImmediate(true); searchTextField.addStyleName(ValoTheme.TEXTFIELD_TINY); searchTextField.addTextChangeListener(filterChangeListener); Label lbSearch = new Label("Search"); lbSearch.addStyleName(ValoTheme.LABEL_TINY); lbSearch.setSizeUndefined(); layoutButtons.addComponents(lbSearch, searchTextField, addBtn, deleteBtn, btnSendSMS); layoutButtons.setComponentAlignment(lbSearch, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(searchTextField, Alignment.BOTTOM_LEFT); layoutButtons.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT); layoutButtons.setComponentAlignment(deleteBtn, Alignment.BOTTOM_RIGHT); layoutButtons.setComponentAlignment(btnSendSMS, Alignment.BOTTOM_RIGHT); layoutButtons.setExpandRatio(addBtn, 3); addComponent(layoutTitle); addComponent(layoutTable); layoutTable.addComponent(layoutButtons); layoutTable.setExpandRatio(table, 3); setComponentAlignment(layoutTitle, Alignment.TOP_CENTER); setComponentAlignment(layoutTable, Alignment.TOP_CENTER); setExpandRatio(layoutTable, 3); setSpacing(true); setMargin(true); }
From source file:com.mycollab.module.crm.view.activity.ActivityCalendarViewImpl.java
License:Open Source License
private void initContent() { MHorizontalLayout contentWrapper = new MHorizontalLayout().withSpacing(false).withFullWidth(); this.addComponent(contentWrapper); /* Content cheat */ MVerticalLayout mainContent = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true)) .withFullWidth().withStyleName("readview-layout"); contentWrapper.with(mainContent).expand(mainContent); MVerticalLayout rightColumn = new MVerticalLayout().withMargin(new MarginInfo(true, false, true, false)) .withWidth("250px"); rightColumn.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); contentWrapper.addComponent(rightColumn); MHorizontalLayout actionPanel = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false)) .withFullWidth().withStyleName(WebThemes.HEADER_VIEW); actionPanel.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Component headerText = ComponentUtils.header(CrmTypeConstants.ACTIVITY, "Calendar"); actionPanel.with(headerText).expand(headerText); mainContent.addComponent(actionPanel); dateHdr = new Label(); dateHdr.setSizeUndefined();//from w w w . ja va 2 s .co m dateHdr.setStyleName(ValoTheme.LABEL_H3); mainContent.addComponent(this.dateHdr); mainContent.setComponentAlignment(this.dateHdr, Alignment.MIDDLE_CENTER); toggleViewBtn = new PopupButton(UserUIContext.getMessage(DayI18nEnum.OPT_MONTHLY)); toggleViewBtn.setWidth("200px"); toggleViewBtn.addStyleName("calendar-view-switcher"); MVerticalLayout popupLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true)) .withWidth("190px"); monthViewBtn = new Button(UserUIContext.getMessage(DayI18nEnum.OPT_MONTHLY), clickEvent -> { toggleViewBtn.setPopupVisible(false); toggleViewBtn.setCaption(monthViewBtn.getCaption()); calendarComponent.switchToMonthView(new Date(), true); datePicker.selectDate(new Date()); monthViewBtn.addStyleName("selected-style"); initLabelCaption(); }); monthViewBtn.setStyleName(WebThemes.BUTTON_LINK); popupLayout.addComponent(monthViewBtn); weekViewBtn = new Button(UserUIContext.getMessage(DayI18nEnum.OPT_WEEKLY), clickEvent -> { toggleViewBtn.setPopupVisible(false); toggleViewBtn.setCaption(weekViewBtn.getCaption()); calendarComponent.switchToWeekView(new Date()); datePicker.selectWeek(new Date()); }); weekViewBtn.setStyleName(WebThemes.BUTTON_LINK); popupLayout.addComponent(weekViewBtn); dailyViewBtn = new Button(UserUIContext.getMessage(DayI18nEnum.OPT_DAILY), clickEvent -> { toggleViewBtn.setPopupVisible(false); toggleViewBtn.setCaption(dailyViewBtn.getCaption()); Date currentDate = new Date(); datePicker.selectDate(currentDate); calendarComponent.switchToDateView(currentDate); }); dailyViewBtn.setStyleName(WebThemes.BUTTON_LINK); popupLayout.addComponent(dailyViewBtn); toggleViewBtn.setContent(popupLayout); CssLayout toggleBtnWrap = new CssLayout(); toggleBtnWrap.setStyleName("switcher-wrap"); toggleBtnWrap.addComponent(toggleViewBtn); rightColumn.addComponent(toggleBtnWrap); rightColumn.setComponentAlignment(toggleBtnWrap, Alignment.MIDDLE_CENTER); rightColumn.addComponent(this.datePicker); initLabelCaption(); addCalendarEvent(); actionPanel.addComponent(calendarActionBtn); actionPanel.setComponentAlignment(calendarActionBtn, Alignment.MIDDLE_RIGHT); OptionPopupContent actionBtnLayout = new OptionPopupContent(); Button.ClickListener listener = new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { calendarActionBtn.setPopupVisible(false); String caption = event.getButton().getCaption(); if (caption.equals("New Task")) { EventBusFactory.getInstance().post(new ActivityEvent.TaskAdd(this, null)); } else if (caption.equals("New Call")) { EventBusFactory.getInstance().post(new ActivityEvent.CallAdd(this, null)); } else if (caption.equals("New Meeting")) { EventBusFactory.getInstance().post(new ActivityEvent.MeetingAdd(this, null)); } } }; MButton todoBtn = new MButton(UserUIContext.getMessage(TaskI18nEnum.NEW), listener) .withStyleName(WebThemes.BUTTON_LINK).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK)) .withVisible(UserUIContext.canWrite(RolePermissionCollections.CRM_TASK)); actionBtnLayout.addOption(todoBtn); MButton callBtn = new MButton(UserUIContext.getMessage(MeetingI18nEnum.NEW), listener) .withStyleName(WebThemes.BUTTON_LINK).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL)) .withVisible(UserUIContext.canWrite(RolePermissionCollections.CRM_CALL)); actionBtnLayout.addOption(callBtn); MButton meetingBtn = new MButton(UserUIContext.getMessage(MeetingI18nEnum.NEW), listener) .withStyleName(WebThemes.BUTTON_LINK).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING)) .withVisible(UserUIContext.canWrite(RolePermissionCollections.CRM_MEETING)); actionBtnLayout.addOption(meetingBtn); calendarActionBtn.setContent(actionBtnLayout); ButtonGroup viewSwitcher = new ButtonGroup(); Button calendarViewBtn = new Button("Calendar"); calendarViewBtn.setStyleName("selected"); calendarViewBtn.addStyleName(WebThemes.BUTTON_ACTION); viewSwitcher.addButton(calendarViewBtn); Button activityListBtn = new Button("Activities", event -> { ActivitySearchCriteria criteria = new ActivitySearchCriteria(); criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId())); EventBusFactory.getInstance().post(new ActivityEvent.GotoTodoList(this, null)); }); activityListBtn.addStyleName(WebThemes.BUTTON_ACTION); viewSwitcher.addButton(activityListBtn); actionPanel.addComponent(viewSwitcher); actionPanel.setComponentAlignment(viewSwitcher, Alignment.MIDDLE_RIGHT); calendarComponent = new CalendarDisplay(); mainContent.addComponent(calendarComponent); mainContent.setExpandRatio(calendarComponent, 1); mainContent.setComponentAlignment(calendarComponent, Alignment.MIDDLE_CENTER); HorizontalLayout spacing = new HorizontalLayout(); spacing.setHeight("30px"); mainContent.addComponent(spacing); HorizontalLayout noteInfoLayout = new HorizontalLayout(); noteInfoLayout.setSpacing(true); HorizontalLayout noteWapper = new HorizontalLayout(); noteWapper.setHeight("30px"); Label noteLbl = new Label(UserUIContext.getMessage(GenericI18Enum.OPT_NOTE)); noteWapper.addComponent(noteLbl); noteWapper.setComponentAlignment(noteLbl, Alignment.MIDDLE_CENTER); noteInfoLayout.addComponent(noteWapper); HorizontalLayout completeWapper = new HorizontalLayout(); completeWapper.setWidth("100px"); completeWapper.setHeight("30px"); completeWapper.addStyleName("eventLblcompleted"); Label completeLabel = new Label("Completed"); completeWapper.addComponent(completeLabel); completeWapper.setComponentAlignment(completeLabel, Alignment.MIDDLE_CENTER); noteInfoLayout.addComponent(completeWapper); HorizontalLayout overdueWapper = new HorizontalLayout(); overdueWapper.setWidth("100px"); overdueWapper.setHeight("30px"); overdueWapper.addStyleName("eventLbloverdue"); Label overdueLabel = new Label("Overdue"); overdueWapper.addComponent(overdueLabel); overdueWapper.setComponentAlignment(overdueLabel, Alignment.MIDDLE_CENTER); noteInfoLayout.addComponent(overdueWapper); HorizontalLayout futureWapper = new HorizontalLayout(); futureWapper.setWidth("100px"); futureWapper.setHeight("30px"); futureWapper.addStyleName("eventLblfuture"); Label futureLabel = new Label("Future"); futureWapper.addComponent(futureLabel); futureWapper.setComponentAlignment(futureLabel, Alignment.MIDDLE_CENTER); noteInfoLayout.addComponent(futureWapper); mainContent.addComponent(noteInfoLayout); mainContent.setComponentAlignment(noteInfoLayout, Alignment.MIDDLE_CENTER); }