List of usage examples for com.vaadin.ui CssLayout addComponent
@Override public void addComponent(Component c)
From source file:com.siemens.ct.osgi.vaadin.pm.main.MainApplication.java
License:Open Source License
private Window getAboutDialog() { if (aboutWindow == null) { aboutWindow = new Window("About..."); aboutWindow.setModal(true);//from w w w . j a v a 2s . c om aboutWindow.setWidth("400px"); VerticalLayout layout = (VerticalLayout) aboutWindow.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName("blue"); CssLayout titleLayout = new CssLayout(); H2 title = new H2("Dynamic Vaadin OSGi Demo"); titleLayout.addComponent(title); SmallText description = new SmallText("<br>Copyright (c) Siemens AG, Kai Tdter and others.<br>" + "Licensed under Eclipse Public License (EPL).<br><br>" + "This software contains modules licenced under<br>" + " the Apache Software Foundation 2.0 license (ASF) and EPL<br><br>" + "Many thanks to Chris Brind, Neil Bartlett and<br>" + " Petter Holmstrm for their OSGi and Vaadin<br>" + " related work, blogs, and bundles.<br><br>" + "The icons are from the Silk icon set by Mark James<br>" + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>"); description.setSizeUndefined(); description.setContentMode(Label.CONTENT_XHTML); titleLayout.addComponent(description); aboutWindow.addComponent(titleLayout); @SuppressWarnings("serial") Button close = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (aboutWindow.getParent()).removeWindow(aboutWindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, "right"); } return aboutWindow; }
From source file:com.thingtrack.myToolbar.MyVaadinApplication.java
License:Apache License
@Override public void init() { setTheme("konekti"); mainWindow = new Window("My dynamic toolbar"); mainWindow.setStyleName("background"); toolbarLayout = new CssLayout() { int brickCounter = 0; @Override/*w ww. j a v a 2 s .c o m*/ protected String getCss(Component c) { // colorize every third rendered brick if (c instanceof Brick) { brickCounter++; if (brickCounter % 3 == 0) { // make every third brick colored and italic return "color: #ff6611; font-style: italic;"; } } return null; } public void removeComponent(Component c) { brickCounter--; super.removeComponent(c); }; }; toolbarLayout.setStyleName("toolbar_layout"); toolbarLayout.setWidth("100%"); mainWindow.addComponent(toolbarLayout); setMainWindow(mainWindow); //Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); mainWindow.addComponent(buttonLayout); Button btnAddToolbar = new Button("Add Toolbar"); btnAddToolbar.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { // toolbarLayout.addComponent(new NavigationToolbar()); // toolbarLayout.addComponent(new Brick()); // toolbarLayout.addComponent(new SimplifiedNavigationToolbar()); CssLayout layout = new CssLayout(); layout.setStyleName("toolbar"); layout.addComponent(new Button("Botn 1")); layout.addComponent(new Button("Botn 2")); layout.addComponent(new Button("Botn 3")); toolbarLayout.addComponent(layout); } }); buttonLayout.addComponent(btnAddToolbar); Button btnBoxToolbar = new Button("Box Toolbar"); btnBoxToolbar.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { //toolbarLayout2.addToolbar(new BoxToolbar()); toolbarLayout.addComponent(new BoxToolbar()); } }); buttonLayout.addComponent(btnBoxToolbar); Button btnRemoveToolbar = new Button("Remove Toolbar"); btnRemoveToolbar.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { // if (toolBarPanel.getToolbarLayout().getToolbars().length == 0) // return; // // Component toolbar = toolBarPanel.getToolbarLayout().getToolbars()[toolBarPanel.getToolbarLayout().getToolbars().length - 1]; // // toolbarLayout.removeComponent((CustomComponent) toolbar); if (toolbarLayout.getComponentCount() == 0) return; toolbarLayout.removeComponent(toolbarLayout.getComponent(toolbarLayout.getComponentCount() - 1)); // } }); buttonLayout.addComponent(btnRemoveToolbar); }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java
private Component buildContent() { final CssLayout menuContent = new CssLayout(); menuContent.addStyleName("sidebar"); menuContent.addStyleName(ValoTheme.MENU_PART); menuContent.addStyleName("no-vertical-drag-hints"); menuContent.addStyleName("no-horizontal-drag-hints"); menuContent.setWidth(null);// w w w . j a va 2 s . c om menuContent.setHeight("100%"); menuContent.addComponent(buildTitle()); menuContent.addComponent(buildUserMenu()); menuContent.addComponent(buildToggleButton()); menuContent.addComponent(new PFSearchBar()); reloadFolderUI(); // menuContent.addComponent(buildMenuItems()); menuContent.addComponent(folderUI); return menuContent; }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java
private Component buildFolderUI() { final CssLayout folderUIComponent = new CssLayout(); folderUIComponent.setWidth("100%"); folderUIComponent.addComponent(buildFolderTree()); return folderUIComponent; }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java
private Component buildFolderTree() { CssLayout treeLayout = new CssLayout(); treeLayout.setWidth("100%"); if (treeLayout.getComponentCount() > 0) { treeLayout.removeAllComponents(); }//from ww w.j a v a2s. c o m System.out.println("Init Dataasource"); for (PFDataSource source : PFCore.core.getDataSources()) { System.out.println("NEW TREE"); Label label = new Label(source.getName(), ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); treeLayout.addComponent(label); // label.setIcon(FontAwesome.LAPTOP); treeLayout.addStyleName("valo-menuitems"); Tree tree = new Tree(); //tree.setIcon(FontAwesome.LAPTOP); // tree.setWidth("100%"); // container.setItemSorter(new l); source.Session().OpenSession(); source.Session().getSession().beginTransaction(); source.Session().getSession().getTransaction().setTimeout(4); System.out.println(": " + source.getDatabase().getSessionManager()); Set<PFFolder> rootFolders = PFLocation.getRootDirectoriesFromDatabase(source.getDatabase()); System.out.println(": " + source.getDatabase().getSessionManager()); final PFFolderProxyContainer container = new PFFolderProxyContainer(rootFolders, source); container.setSortAlphabetic(true); tree.setContainerDataSource(container); tree.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); tree.setItemCaptionPropertyId("Name"); tree.setItemIconPropertyId("Icon"); ItemClickListener treeclick; treeclick = new ItemClickListener() { @Override public void itemClick(final ItemClickEvent event) { // Notification note = new Notification("Notificaton", event.getItemId().toString(), Notification.Type.ERROR_MESSAGE); // note.show(Page.getCurrent()); PFFolderProxy proxyFolder = (PFFolderProxy) event.getItemId(); MyUI.getPFNavigator().navigateTo(MyUI.PAGE_FOLDERVIEW + "/" + proxyFolder.getIdentifier()); } }; tree.addItemClickListener(treeclick); // Allow all nodes to have children // .dashboard-menu-folder-wrapper // all these wrappers are a hacky workaround to a Vaadin CSS glitch CssLayout treeWrapper = new CssLayout(); treeWrapper.setStyleName(".dashboard-menu-folder-wrapper"); treeWrapper.addComponent(tree); treeWrapper.setWidth("40px"); tree.setWidth("800px"); tree.setStyleName(".dashboard-menu-folder-tree"); treeLayout.addComponent(treeWrapper); source.Session().getSession().getTransaction().commit(); source.getDatabase().getSessionManager().CloseSession(); } return treeLayout; }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java
private Component buildMenuItems() { CssLayout menuItemsLayout = new CssLayout(); menuItemsLayout.addStyleName("valo-menuitems"); for (final DashboardViewType view : DashboardViewType.values()) { Component menuItemComponent = new ValoMenuItemButton(view); /*/*from w w w . j a va2 s. c o m*/ if (view == DashboardViewType.REPORTS) { // Add drop target to reports button DragAndDropWrapper reports = new DragAndDropWrapper( menuItemComponent); reports.setSizeUndefined(); reports.setDragStartMode(DragStartMode.NONE); reports.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent event) { UI.getCurrent() .getNavigator() .navigateTo( DashboardViewType.REPORTS.getViewName()); Table table = (Table) event.getTransferable() .getSourceComponent(); DashboardEventBus.post(new TransactionReportEvent( (Collection<Transaction>) table.getValue())); } @Override public AcceptCriterion getAcceptCriterion() { return AcceptItem.ALL; } }); menuItemComponent = reports; }*/ if (view == DashboardViewType.DASHBOARD) { notificationsBadge = new Label(); notificationsBadge.setId(NOTIFICATIONS_BADGE_ID); menuItemComponent = buildBadgeWrapper(menuItemComponent, notificationsBadge); } if (view == DashboardViewType.REPORTS) { reportsBadge = new Label(); reportsBadge.setId(REPORTS_BADGE_ID); menuItemComponent = buildBadgeWrapper(menuItemComponent, reportsBadge); } menuItemsLayout.addComponent(menuItemComponent); } return menuItemsLayout; }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java
private Component buildBadgeWrapper(final Component menuItemButton, final Component badgeLabel) { CssLayout dashboardWrapper = new CssLayout(menuItemButton); dashboardWrapper.addStyleName("badgewrapper"); dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM); badgeLabel.addStyleName(ValoTheme.MENU_BADGE); badgeLabel.setWidthUndefined();/*from w w w.j a va 2 s. com*/ badgeLabel.setVisible(false); dashboardWrapper.addComponent(badgeLabel); return dashboardWrapper; }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java
private Component buildLabels() { CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label welcome = new Label("Welcome"); welcome.setSizeUndefined();/* w w w . ja va 2 s. c o m*/ welcome.addStyleName(ValoTheme.LABEL_H4); welcome.addStyleName(ValoTheme.LABEL_COLORED); labels.addComponent(welcome); Label title = new Label("PFServer Dashboard"); title.setSizeUndefined(); title.addStyleName(ValoTheme.LABEL_H3); title.addStyleName(ValoTheme.LABEL_LIGHT); labels.addComponent(title); return labels; }
From source file:de.fatalix.app.view.login.LoginView.java
public LoginView() { CssLayout rootLayout = new CssLayout(); rootLayout.addStyleName("login-screen"); Component loginForm = buildLoginForm(); VerticalLayout centeringLayout = new VerticalLayout(); centeringLayout.setStyleName("centering-layout"); centeringLayout.addComponent(loginForm); centeringLayout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER); CssLayout loginInformation = buildLoginInformation(); rootLayout.addComponent(centeringLayout); rootLayout.addComponent(loginInformation); setCompositionRoot(rootLayout);// w w w . j a v a2 s .c o m }
From source file:de.fatalix.app.view.login.LoginView.java
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();/*w w w . ja va 2 s .co m*/ loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription("Write anything"); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); buttons.addComponent(login = new Button("Login")); login.setDisableOnClick(true); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } finally { login.setEnabled(true); } } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Try anything", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }