List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:org.lunifera.examples.ecview.model.ui.PersonUI.java
License:Apache License
@SuppressWarnings("restriction") @Override//from www .j a va 2s .c om protected void init(VaadinRequest request) { VerticalLayout spanningLayout = new VerticalLayout(); spanningLayout.setSizeFull(); setContent(spanningLayout); dtoService = DtoServiceAccess.getService(PersonDto.class); VerticalLayout layout = new VerticalLayout(); spanningLayout.addComponent(layout); layout.setSizeUndefined(); layout.setWidth("100%"); HorizontalLayout buttonBar = new HorizontalLayout(); layout.addComponent(buttonBar); buttonBar.setMargin(true); buttonBar.setSpacing(true); NativeButton setupDB = new NativeButton("Setup DB"); setupDB.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Activator.INSTANCE.setupDB(); } }); buttonBar.addComponent(setupDB); YView yView = findViewModel("org.lunifera.examples.ecview.model.jpa.services.PersonView"); if (yView == null) { Notification.show("PersonView could not be found!", Type.ERROR_MESSAGE); return; } // render the Vaadin UI VaadinRenderer renderer = new VaadinRenderer(); try { viewContext = renderer.render(layout, yView, null); } catch (ContextException e) { e.printStackTrace(); } II18nService service = viewContext.getService(II18nService.ID); for (YExposedAction action : yView.getExposedActions()) { Button temp = new Button(); buttonBar.addComponent(temp); temp.setCaption(service.getValue(action.getLabelI18nKey(), getLocale())); temp.setIcon(new ThemeResource(action.getIcon())); if (action.getId().equals("org.lunifera.actions.load")) { reloadAction = temp; reloadAction.setEnabled(false); temp.addClickListener(new LoadHandler()); } else if (action.getId().equals("org.lunifera.actions.save")) { saveAction = temp; saveAction.setEnabled(false); temp.addClickListener(new SaveHandler()); } else if (action.getId().equals("org.lunifera.actions.delete")) { deleteAction = temp; deleteAction.setEnabled(false); temp.addClickListener(new DeleteHandler()); } else if (action.getId().equals("org.lunifera.actions.find")) { searchAction = temp; temp.addClickListener(new SearchHandler()); } } }
From source file:org.lunifera.examples.kwiee.erp.module.core.presentation.web.vaadin.ui.KwieeUINavigator.java
License:Open Source License
@SuppressWarnings("serial") protected void createTasksTable() { // create layout VerticalLayout tableArea = new VerticalLayout(); tableArea.setSizeFull();// ww w . j av a 2 s . c o m tabSheet.addTab(tableArea, "Tasks"); // create table -> expand 1.0 taskTable = new Table(); tableArea.addComponent(taskTable); tableArea.setExpandRatio(taskTable, 1.0f); taskTable.setSizeFull(); taskTable.setImmediate(true); taskTable.setBuffered(false); taskTable.setSelectable(true); taskTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { showTask((Task) event.getProperty().getValue()); } }); refreshTasks(); // create button -> 28px HorizontalLayout buttonBar = new HorizontalLayout(); buttonBar.setSizeFull(); buttonBar.setMargin(true); buttonBar.setSpacing(true); buttonBar.setHeight("48px"); tableArea.addComponent(buttonBar); refreshTasksButton = new Button("Refresh"); buttonBar.addComponent(refreshTasksButton); buttonBar.setComponentAlignment(refreshTasksButton, Alignment.MIDDLE_LEFT); refreshTasksButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { refreshTasks(); } }); }
From source file:org.metawidget.example.vaadin.addressbook.CommunicationDialog.java
License:BSD License
public CommunicationDialog(final ContactDialog contactDialog, final Communication communication) { setCaption("Communication"); setWidth("350px"); setHeight("175px"); setResizable(false);//from w w w . j a v a2 s. c o m // Metawidget final VaadinMetawidget metawidget = new VaadinMetawidget(); metawidget.setWidth("100%"); metawidget.setConfig("org/metawidget/example/vaadin/addressbook/metawidget.xml"); metawidget.setToInspect(communication); // Buttons final Button saveButton = new Button("Save"); saveButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { try { metawidget.getWidgetProcessor(SimpleBindingProcessor.class).save(metawidget); contactDialog.addCommunication(communication); getParent().removeWindow(CommunicationDialog.this); } catch (Exception e) { showNotification("Save Error", e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE); return; } } }); final Button cancelButton = new Button("Cancel"); cancelButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { getParent().removeWindow(CommunicationDialog.this); } }); Facet facetButtons = new Facet(); facetButtons.setData("buttons"); facetButtons.setWidth("100%"); HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(false); layout.setSpacing(true); layout.addComponent(saveButton); layout.addComponent(cancelButton); facetButtons.addComponent(layout); ((com.vaadin.ui.VerticalLayout) facetButtons.getContent()).setComponentAlignment(layout, Alignment.MIDDLE_CENTER); metawidget.addComponent(facetButtons); addComponent(metawidget); ((VerticalLayout) getContent()).setMargin(true, true, false, true); }
From source file:org.opencms.ui.apps.CmsFileExplorer.java
License:Open Source License
/** * @see org.opencms.ui.apps.I_CmsWorkplaceApp#initUI(org.opencms.ui.apps.I_CmsAppUIContext) *//* ww w . j ava2s . c o m*/ public void initUI(I_CmsAppUIContext context) { m_appContext = context; m_appContext.setMenuDialogContext( new CmsExplorerDialogContext(ContextType.appToolbar, m_fileTable, this, null)); HorizontalSplitPanel sp = new HorizontalSplitPanel(); sp.setSizeFull(); sp.setFirstComponent(m_fileTree); CmsFileExplorerSettings settings; try { settings = OpenCms.getWorkplaceAppManager().getAppSettings(A_CmsUI.getCmsObject(), CmsFileExplorerSettings.class); m_fileTable.setTableState(settings); } catch (Exception e) { LOG.error("Error while reading file explorer settings from user.", e); } sp.setSecondComponent(m_fileTable); sp.setSplitPosition(LAYOUT_SPLIT_POSITION, Unit.PIXELS); context.setAppContent(sp); context.showInfoArea(true); HorizontalLayout inf = new HorizontalLayout(); inf.setSizeFull(); inf.setSpacing(true); inf.setMargin(true); m_siteSelector.setWidth("379px"); inf.addComponent(m_siteSelector); CssLayout crumbWrapper = new CssLayout(); crumbWrapper.setSizeFull(); crumbWrapper.setPrimaryStyleName(OpenCmsTheme.CRUMB_WRAPPER); crumbWrapper.addComponent(m_crumbs); m_infoPath.setWidth("100%"); crumbWrapper.addComponent(m_infoPath); inf.addComponent(crumbWrapper); inf.setExpandRatio(crumbWrapper, 1); m_searchField.setWidth("200px"); inf.addComponent(m_searchField); context.setAppInfo(inf); initToolbarButtons(context); m_fileTable.updateColumnWidths(A_CmsUI.get().getPage().getBrowserWindowWidth() - LAYOUT_SPLIT_POSITION); }
From source file:org.opencms.ui.components.CmsToolBar.java
License:Open Source License
/** * Creates the app select drop down.<p> * * @return the drop down component// w ww . j a va2 s . com */ private Component createQuickLaunchDropDown() { PopupView pv = new PopupView(new PopupView.Content() { private static final long serialVersionUID = 1L; public String getMinimizedValueAsHTML() { return getDropDownButtonHtml(FontOpenCms.APPS); } public Component getPopupComponent() { CmsObject cms = A_CmsUI.getCmsObject(); Locale locale = UI.getCurrent().getLocale(); HorizontalLayout layout = new HorizontalLayout(); layout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); layout.addStyleName(OpenCmsTheme.QUICK_LAUNCH); // layout.setSpacing(true); layout.setMargin(true); for (I_CmsWorkplaceAppConfiguration config : OpenCms.getWorkplaceAppManager() .getQuickLaunchConfigurations(cms)) { layout.addComponent(CmsDefaultAppButtonProvider.createAppButton(cms, config, locale)); } return layout; } }); pv.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_QUICK_LAUNCH_TITLE_0)); pv.addStyleName(OpenCmsTheme.NAVIGATOR_DROPDOWN); pv.setHideOnMouseOut(false); return pv; }
From source file:org.opencms.ui.dialogs.history.CmsHistoryDialog.java
License:Open Source License
/** * Replaces the contents of the window containing a given component with a basic dialog * consisting of a back button to restore the previous window state and another user provided widget.<p> * * @param currentComponent the component whose parent window's content should be replaced * @param newView the user supplied part of the new window content * @param newCaption the caption for the child dialog *///from w w w . ja va 2 s . co m public static void openChildDialog(Component currentComponent, Component newView, String newCaption) { final Window window = CmsVaadinUtils.getWindow(currentComponent); final String oldCaption = window.getCaption(); CmsBasicDialog dialog = new CmsBasicDialog(); VerticalLayout vl = new VerticalLayout(); dialog.setContent(vl); Button backButton = new Button(CmsVaadinUtils.getMessageText(Messages.GUI_CHILD_DIALOG_GO_BACK_0)); HorizontalLayout buttonBar = new HorizontalLayout(); buttonBar.addComponent(backButton); buttonBar.setMargin(true); vl.addComponent(buttonBar); vl.addComponent(newView); final Component oldContent = window.getContent(); if (oldContent instanceof CmsBasicDialog) { List<CmsResource> infoResources = ((CmsBasicDialog) oldContent).getInfoResources(); dialog.displayResourceInfo(infoResources); if (oldContent instanceof CmsHistoryDialog) { dialog.addButton(((CmsHistoryDialog) oldContent).createCloseButton()); } } backButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { window.setContent(oldContent); window.setCaption(oldCaption); window.center(); } }); window.setContent(dialog); window.setCaption(newCaption); window.center(); }
From source file:org.opencms.ui.dialogs.history.diff.CmsImageDiff.java
License:Open Source License
/** * @see org.opencms.ui.dialogs.history.diff.I_CmsDiffProvider#diff(org.opencms.file.CmsObject, org.opencms.gwt.shared.CmsHistoryResourceBean, org.opencms.gwt.shared.CmsHistoryResourceBean) *//*from w w w . j a v a 2s .c o m*/ public Optional<Component> diff(CmsObject cms, CmsHistoryResourceBean v1, CmsHistoryResourceBean v2) throws CmsException { CmsResource r1 = A_CmsAttributeDiff.readResource(cms, v1); if (OpenCms.getResourceManager().matchResourceType(CmsResourceTypeImage.getStaticTypeName(), r1.getTypeId())) { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); String v1Param = v1.getVersion().getVersionNumber() != null ? "" + v1.getVersion().getVersionNumber() : "" + CmsHistoryResourceHandler.PROJECT_OFFLINE_VERSION; String v2Param = v2.getVersion().getVersionNumber() != null ? "" + v2.getVersion().getVersionNumber() : "" + CmsHistoryResourceHandler.PROJECT_OFFLINE_VERSION; String link1 = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, CmsHistoryListUtil.getHistoryLink(cms, v1.getStructureId(), v1Param)); String link2 = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, CmsHistoryListUtil.getHistoryLink(cms, v2.getStructureId(), v2Param)); int scaleWidth = 400; int scaleHeight = (2 * scaleWidth) / 3; final String scaleParams = "w:" + scaleWidth + ",h:" + scaleHeight + ",t:1"; // scale type 1 for thumbnails (no enlargement) link1 = CmsRequestUtil.appendParameter(link1, "__scale", scaleParams); link2 = CmsRequestUtil.appendParameter(link2, "__scale", scaleParams); Image img1 = new Image("", new ExternalResource(link1)); Image img2 = new Image("", new ExternalResource(link2)); for (Image img : new Image[] { img1, img2 }) { img.setWidth("" + scaleWidth + "px"); } img1.setCaption("V1"); img2.setCaption("V2"); hl.addComponent(img1); hl.addComponent(img2); Panel result = new Panel("Image comparison"); hl.setMargin(true); result.setContent(hl); return Optional.fromNullable((Component) result); } else { return Optional.absent(); } }
From source file:org.openeos.services.ui.vaadin.internal.abstractform.EntityActionPanelController.java
License:Apache License
private void createAction(final EntityAction<UIBean> action) { ClickListener listener = new ClickListener() { private static final long serialVersionUID = 1L; @Override//from w ww. j a va2 s. co m public void buttonClick(ClickEvent event) { if (window.getActiveTab().getActualView() == View.EDIT && window.getActiveTab().isModified()) { window.getApplication().showConfirmation("The changes may be lost, are you sure?", new ConfirmationCallback() { @Override public void onCloseConfirmation(boolean accepted) { if (accepted) { action.execute(window.getActiveTab().getSelectedObjects(), uiApplication); window.refresh(RefreshType.SELECTED); } } }); } else { action.execute(window.getActiveTab().getSelectedObjects(), uiApplication); window.refresh(RefreshType.SELECTED); } } }; HorizontalLayout horLayout = new HorizontalLayout(); horLayout.setMargin(false); horLayout.setSpacing(false); horLayout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Button button = new Button(action.getName(), listener); button.addStyleName(Reindeer.BUTTON_LINK); horLayout.addComponent(button); mainPanel.addComponent(horLayout); }
From source file:org.openeos.services.ui.vaadin.internal.abstractform.UIVaadinButtonField.java
License:Apache License
public UIVaadinButtonField(String caption, UIButtonController buttonController, UIApplicationImpl application) { this.buttonController = buttonController; this.application = application; HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setMargin(false); mainLayout.setSpacing(false);/*from w w w. j a va2s . c om*/ mainLayout.setSizeFull(); textField = new TextField(caption); mainLayout.addComponent(textField); button = new Button("...", new ClickListener() { @Override public void buttonClick(ClickEvent event) { UIVaadinButtonField.this.buttonController.onClick(UIVaadinButtonField.this.application, value); } }); ; mainLayout.addComponent(button); setCompositionRoot(mainLayout); }
From source file:org.openeos.services.ui.vaadin.internal.abstractform.UIVaadinFormToolkit.java
License:Apache License
@Override protected AbstractComponent internalBuildField(org.abstractform.core.Field field, Map<String, Object> extraObjects) { AbstractComponent ret;// w w w.j ava 2s .co m if (BFUIButton.TYPE_UI_BUTTON.equals(field.getType())) { UIVaadinButtonField button = new UIVaadinButtonField(field.getName(), (UIButtonController) field.getExtra(BFUIButton.EXTRA_UI_BUTTON_CONTROLLER), (UIApplicationImpl) extraObjects.get(EXTRA_OBJECT_APPLICATION)); ret = button; } else if (BFUITable.TYPE_UITABLE.equals(field.getType())) { final Table table = (Table) buildTableField(field, extraObjects); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setSizeFull(); //mainLayout.setSizeFull(); mainLayout.setMargin(false); mainLayout.setSpacing(true); mainLayout.addComponent(table); VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setMargin(false); buttonLayout.setSpacing(true); //buttonLayout.setSizeFull(); final UITableController controller = (UITableController) field .getExtra(BFUITable.EXTRA_TABLE_CONTROLLER); final UIApplication application = (UIApplication) extraObjects.get(EXTRA_OBJECT_APPLICATION); Button buttonNew = new Button("N", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { controller.onNew(application, ((UITableContainer) table.getContainerDataSource()).getFormInstance(), ((TableContainer) table.getContainerDataSource()).getValues()); } }); buttonNew.setWidth("100%"); buttonLayout.addComponent(buttonNew); Button buttonEdit = new Button("E", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { controller.onEdit(application, ((UITableContainer) table.getContainerDataSource()).getFormInstance(), ((TableContainer) table.getContainerDataSource()).getValues(), table.getValue()); } }); buttonEdit.setWidth("100%"); buttonLayout.addComponent(buttonEdit); Button buttonDelete = new Button("D", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { controller.onDelete(application, ((UITableContainer) table.getContainerDataSource()).getFormInstance(), ((TableContainer) table.getContainerDataSource()).getValues(), table.getValue()); } }); buttonDelete.setWidth("100%"); buttonLayout.addComponent(buttonDelete); buttonLayout.setWidth("50px"); mainLayout.addComponent(buttonLayout); mainLayout.setExpandRatio(table, 1.0f); ret = mainLayout; } else { ret = super.internalBuildField(field, extraObjects); if (field.getType().equals(Field.TYPE_NUMERIC)) { //TODO This normally can be many types of classes and can be with data conversion in binding tier ((TextField) ret).setPropertyDataSource(new ObjectProperty<BigDecimal>(null, BigDecimal.class)); } } return ret; }