List of usage examples for com.vaadin.ui Component addStyleName
public void addStyleName(String style);
From source file:annis.gui.EmbeddedVisUI.java
License:Apache License
private void generateVisFromRemoteURL(final String visName, final String rawUri, Map<String, String[]> args) { try {//from w w w.j a v a 2 s .com // find the matching visualizer final VisualizerPlugin visPlugin = this.getVisualizer(visName); if (visPlugin == null) { displayMessage("Unknown visualizer \"" + visName + "\"", "This ANNIS instance does not know the given visualizer."); return; } URI uri = new URI(rawUri); // fetch content of the URI Client client = null; AnnisUser user = Helper.getUser(); if (user != null) { client = user.getClient(); } if (client == null) { client = Helper.createRESTClient(); } final WebResource saltRes = client.resource(uri); displayLoadingIndicator(); // copy the arguments for using them later in the callback final Map<String, String[]> argsCopy = new LinkedHashMap<>(args); Background.runWithCallback(new Callable<SaltProject>() { @Override public SaltProject call() throws Exception { return saltRes.get(SaltProject.class); } }, new FutureCallback<SaltProject>() { @Override public void onFailure(Throwable t) { displayMessage("Could not query the result.", t.getMessage()); } @Override public void onSuccess(SaltProject p) { // TODO: allow to display several visualizers when there is more than one document SCorpusGraph firstCorpusGraph = null; SDocument doc = null; if (p.getCorpusGraphs() != null && !p.getCorpusGraphs().isEmpty()) { firstCorpusGraph = p.getCorpusGraphs().get(0); if (firstCorpusGraph.getDocuments() != null && !firstCorpusGraph.getDocuments().isEmpty()) { doc = firstCorpusGraph.getDocuments().get(0); } } if (doc == null) { displayMessage("No documents found in provided URL.", ""); return; } if (argsCopy.containsKey(KEY_INSTANCE)) { Map<String, InstanceConfig> allConfigs = loadInstanceConfig(); InstanceConfig newConfig = allConfigs.get(argsCopy.get(KEY_INSTANCE)[0]); if (newConfig != null) { setInstanceConfig(newConfig); } } // now it is time to load the actual defined instance fonts loadInstanceFonts(); // generate the visualizer VisualizerInput visInput = new VisualizerInput(); visInput.setDocument(doc); if (getInstanceConfig() != null && getInstanceConfig().getFont() != null) { visInput.setFont(getInstanceFont()); } Properties mappings = new Properties(); for (Map.Entry<String, String[]> e : argsCopy.entrySet()) { if (!KEY_SALT.equals(e.getKey()) && e.getValue().length > 0) { mappings.put(e.getKey(), e.getValue()[0]); } } visInput.setMappings(mappings); String[] namespace = argsCopy.get(KEY_NAMESPACE); if (namespace != null && namespace.length > 0) { visInput.setNamespace(namespace[0]); } else { visInput.setNamespace(null); } String baseText = null; if (argsCopy.containsKey(KEY_BASE_TEXT)) { String[] value = argsCopy.get(KEY_BASE_TEXT); if (value.length > 0) { baseText = value[0]; } } List<SNode> segNodes = CommonHelper.getSortedSegmentationNodes(baseText, doc.getDocumentGraph()); if (argsCopy.containsKey(KEY_MATCH)) { String[] rawMatch = argsCopy.get(KEY_MATCH); if (rawMatch.length > 0) { // enhance the graph with match information from the arguments Match match = Match.parseFromString(rawMatch[0]); addMatchToDocumentGraph(match, doc); } } Map<String, String> markedColorMap = new HashMap<>(); Map<String, String> exactMarkedMap = Helper.calculateColorsForMarkedExact(doc); Map<String, Long> markedAndCovered = Helper.calculateMarkedAndCoveredIDs(doc, segNodes, baseText); Helper.calulcateColorsForMarkedAndCovered(doc, markedAndCovered, markedColorMap); visInput.setMarkedAndCovered(markedAndCovered); visInput.setMarkableMap(markedColorMap); visInput.setMarkableExactMap(exactMarkedMap); visInput.setContextPath(Helper.getContext()); String template = Helper.getContext() + "/Resource/" + visName + "/%s"; visInput.setResourcePathTemplate(template); visInput.setSegmentationName(baseText); // TODO: which other thing do we have to provide? Component c = visPlugin.createComponent(visInput, null); // add the styles c.addStyleName("corpus-font"); c.addStyleName("vis-content"); Link link = new Link(); link.setCaption("Show in ANNIS search interface"); link.setIcon(ANNISFontIcon.LOGO); link.setVisible(false); link.addStyleName("dontprint"); link.setTargetName("_blank"); if (argsCopy.containsKey(KEY_SEARCH_INTERFACE)) { String[] interfaceLink = argsCopy.get(KEY_SEARCH_INTERFACE); if (interfaceLink.length > 0) { link.setResource(new ExternalResource(interfaceLink[0])); link.setVisible(true); } } VerticalLayout layout = new VerticalLayout(link, c); layout.setComponentAlignment(link, Alignment.TOP_LEFT); layout.setSpacing(true); layout.setMargin(true); setContent(layout); IDGenerator.assignID(link); } }); } catch (URISyntaxException ex) { displayMessage("Invalid URL", "The provided URL is malformed:<br />" + ex.getMessage()); } catch (LoginDataLostException ex) { displayMessage("LoginData Lost", "No login data available any longer in the session:<br /> " + ex.getMessage()); } catch (UniformInterfaceException ex) { if (ex.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode()) { displayMessage("Corpus access forbidden", "You are not allowed to access this corpus. " + "Please login at the <a target=\"_blank\" href=\"" + Helper.getContext() + "\">main application</a> first and then reload this page."); } else { displayMessage("Service error", ex.getMessage()); } } catch (ClientHandlerException ex) { displayMessage("Could not generate the visualization because the ANNIS service reported an error.", ex.getMessage()); } catch (Throwable ex) { displayMessage("Could not generate the visualization.", ex.getMessage() == null ? ("An unknown error of type " + ex.getClass().getSimpleName()) + " occured." : ex.getMessage()); } }
From source file:annis.gui.resultview.VisualizerPanel.java
License:Apache License
private Component createComponent() { if (visPlugin == null) { return null; }//ww w .java2s . com final VisualizerInput input = createInput(); Component c = visPlugin.createComponent(input, this); c.setVisible(false); c.addStyleName(Helper.CORPUS_FONT); c.addStyleName("vis-content"); return c; }
From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java
License:Apache License
Panel windows() { Panel p = new Panel("Dialogs"); VerticalLayout content = new VerticalLayout() { final Window win = new Window("Window Caption"); String prevHeight = "300px"; boolean footerVisible = true; boolean autoHeight = false; boolean tabsVisible = false; boolean toolbarVisible = false; boolean footerToolbar = false; boolean toolbarLayout = false; String toolbarStyle = null; VerticalLayout windowContent() { VerticalLayout root = new VerticalLayout(); if (toolbarVisible) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setSizeUndefined(); menuBar.setStyleName(toolbarStyle); Component toolbar = menuBar; if (toolbarLayout) { menuBar.setWidth(null); HorizontalLayout toolbarLayout = new HorizontalLayout(); toolbarLayout.setWidth("100%"); toolbarLayout.setSpacing(true); Label label = new Label("Tools"); label.setSizeUndefined(); toolbarLayout.addComponents(label, menuBar); toolbarLayout.setExpandRatio(menuBar, 1); toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT); toolbar = toolbarLayout; }/*from w w w . j a v a 2s. c o m*/ toolbar.addStyleName("v-window-top-toolbar"); root.addComponent(toolbar); } Component content = null; if (tabsVisible) { TabSheet tabs = new TabSheet(); tabs.setSizeFull(); VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); tabs.addTab(l, "Selected"); tabs.addTab(new Label(" ", ContentMode.HTML), "Another"); tabs.addTab(new Label(" ", ContentMode.HTML), "One more"); tabs.addStyleName("padded-tabbar"); tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { try { Thread.sleep(600); } catch (InterruptedException e) { e.printStackTrace(); } } }); content = tabs; } else if (!autoHeight) { Panel p = new Panel(); p.setSizeFull(); p.addStyleName("borderless"); if (!toolbarVisible || !toolbarLayout) { p.addStyleName("scroll-divider"); } VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); p.setContent(l); content = p; } else { content = new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML); root.setMargin(true); } root.addComponent(content); if (footerVisible) { HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName("v-window-bottom-toolbar"); Label footerText = new Label("Footer text"); footerText.setSizeUndefined(); Button ok = new Button("OK"); ok.addStyleName("primary"); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok, cancel); footer.setExpandRatio(footerText, 1); if (footerToolbar) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setStyleName(toolbarStyle); menuBar.setWidth(null); footer.removeAllComponents(); footer.addComponent(menuBar); } root.addComponent(footer); } if (!autoHeight) { root.setSizeFull(); root.setExpandRatio(content, 1); } return root; } { setSpacing(true); setMargin(true); win.setWidth("380px"); win.setHeight(prevHeight); win.setClosable(false); win.setResizable(false); win.setContent(windowContent()); win.setCloseShortcut(KeyCode.ESCAPE, null); Command optionsCommand = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Footer")) { footerVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Auto Height")) { autoHeight = selectedItem.isChecked(); if (!autoHeight) { win.setHeight(prevHeight); } else { prevHeight = win.getHeight() + win.getHeightUnits().toString(); win.setHeight(null); } } if (selectedItem.getText().equals("Tabs")) { tabsVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top")) { toolbarVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Footer")) { footerToolbar = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top layout")) { toolbarLayout = selectedItem.isChecked(); } if (selectedItem.getText().equals("Borderless")) { toolbarStyle = selectedItem.isChecked() ? "borderless" : null; } win.setContent(windowContent()); } }; MenuBar options = new MenuBar(); options.setCaption("Content"); options.addItem("Auto Height", optionsCommand).setCheckable(true); options.addItem("Tabs", optionsCommand).setCheckable(true); MenuItem option = options.addItem("Footer", optionsCommand); option.setCheckable(true); option.setChecked(true); options.addStyleName("small"); addComponent(options); options = new MenuBar(); options.setCaption("Toolbars"); options.addItem("Footer", optionsCommand).setCheckable(true); options.addItem("Top", optionsCommand).setCheckable(true); options.addItem("Top layout", optionsCommand).setCheckable(true); options.addItem("Borderless", optionsCommand).setCheckable(true); options.addStyleName("small"); addComponent(options); Command optionsCommand2 = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Caption")) { win.setCaption(selectedItem.isChecked() ? "Window Caption" : null); } else if (selectedItem.getText().equals("Closable")) { win.setClosable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Resizable")) { win.setResizable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Modal")) { win.setModal(selectedItem.isChecked()); } } }; options = new MenuBar(); options.setCaption("Options"); MenuItem caption = options.addItem("Caption", optionsCommand2); caption.setCheckable(true); caption.setChecked(true); options.addItem("Closable", optionsCommand2).setCheckable(true); options.addItem("Resizable", optionsCommand2).setCheckable(true); options.addItem("Modal", optionsCommand2).setCheckable(true); options.addStyleName("small"); addComponent(options); final Button show = new Button("Open Window", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { getUI().addWindow(win); win.center(); win.focus(); event.getButton().setEnabled(false); } }); show.addStyleName("primary"); addComponent(show); final CheckBox hidden = new CheckBox("Hidden"); hidden.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { win.setVisible(!hidden.getValue()); } }); addComponent(hidden); win.addCloseListener(new CloseListener() { @Override public void windowClose(final CloseEvent e) { show.setEnabled(true); } }); } }; p.setContent(content); return p; }
From source file:com.cavisson.gui.dashboard.components.controls.ValoMenuLayout.java
License:Apache License
public void addMenu(Component menu) { menu.addStyleName("valo-menu-part"); menuArea.addComponent(menu); }
From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java
License:Apache License
@Override protected void init(final VaadinRequest request) { if (request.getParameter("test") != null) { testMode = true;/*from www . ja v a 2 s .c o m*/ if (browserCantRenderFontsConsistently()) { getPage().getStyles().add(".v-app.v-app.v-app {font-family: Sans-Serif;}"); } } if (getPage().getWebBrowser().isIE() && getPage().getWebBrowser().getBrowserMajorVersion() == 9) { menu.setWidth("320px"); } // Show .v-app-loading valo-menu-badge // try { // Thread.sleep(2000); // } catch (InterruptedException e) { // e.printStackTrace(); // } if (!testMode) { Responsive.makeResponsive(this); } getPage().setTitle("Valo Theme Test"); setContent(root); root.setWidth("100%"); root.addMenu(buildMenu()); navigator = new Navigator(this, viewDisplay); navigator.addView("common", CommonParts.class); navigator.addView("labels", Labels.class); navigator.addView("buttons-and-links", ButtonsAndLinks.class); navigator.addView("textfields", TextFields.class); navigator.addView("datefields", DateFields.class); navigator.addView("comboboxes", ComboBoxes.class); navigator.addView("checkboxes", CheckBoxes.class); navigator.addView("sliders", Sliders.class); navigator.addView("menubars", MenuBars.class); navigator.addView("panels", Panels.class); navigator.addView("trees", Trees.class); navigator.addView("tables", Tables.class); navigator.addView("splitpanels", SplitPanels.class); navigator.addView("tabs", Tabsheets.class); navigator.addView("accordions", Accordions.class); navigator.addView("colorpickers", ColorPickers.class); navigator.addView("selects", NativeSelects.class); navigator.addView("calendar", CalendarTest.class); navigator.addView("forms", Forms.class); navigator.addView("popupviews", PopupViews.class); navigator.addView("dragging", Dragging.class); final String f = Page.getCurrent().getUriFragment(); if (f == null || f.equals("")) { navigator.navigateTo("common"); } navigator.setErrorView(CommonParts.class); navigator.addViewChangeListener(new ViewChangeListener() { @Override public boolean beforeViewChange(final ViewChangeEvent event) { return true; } @Override public void afterViewChange(final ViewChangeEvent event) { for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) { it.next().removeStyleName("selected"); } for (final Entry<String, String> item : menuItems.entrySet()) { if (event.getViewName().equals(item.getKey())) { for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) { final Component c = it.next(); if (c.getCaption() != null && c.getCaption().startsWith(item.getValue())) { c.addStyleName("selected"); break; } } break; } } menu.removeStyleName("valo-menu-visible"); } }); }
From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java
public MainLayoutImpl(AppLayerFactory appLayerFactory) { this.presenter = new MainLayoutPresenter(this); mainMenuContentFooterLayout = new HorizontalLayout(); mainMenuContentFooterLayout.setSizeFull(); mainMenuContentFooterLayout.addStyleName("main-menu-content-footer"); contentViewWrapper = new Panel(); Navigator navigator = new Navigator(UI.getCurrent(), contentViewWrapper); NavigatorConfigurationService navigatorConfigurationService = appLayerFactory .getNavigatorConfigurationService(); navigatorConfigurationService.configure(navigator); UI.getCurrent().setNavigator(navigator); contentFooterWrapperLayout = new CssLayout(); contentFooterWrapperLayout.setId("content-footer-wrapper"); contentFooterLayout = new VerticalLayout(); contentFooterLayout.addStyleName("content-footer"); header = buildHeader();/*w w w .j av a2s . c om*/ header.setSizeUndefined(); mainMenu = buildMainMenu(); userDocumentsWindow = new UserDocumentsWindow(); dragAndDropWrapper = new DragAndDropWrapper(mainMenuContentFooterLayout); dragAndDropWrapper.setSizeFull(); dragAndDropWrapper.setDropHandler(userDocumentsWindow); navigator.addViewChangeListener(new ViewChangeListener() { @Override public boolean beforeViewChange(ViewChangeEvent event) { return true; } @Override public void afterViewChange(ViewChangeEvent event) { View newView = event.getNewView(); if (newView instanceof NoDragAndDrop) { dragAndDropWrapper.setDropHandler(null); } else if (newView instanceof DropHandler) { dragAndDropWrapper.setDropHandler((DropHandler) newView); } else { List<DropHandler> viewDropHandlers = ComponentTreeUtils.getChildren((Component) newView, DropHandler.class); if (viewDropHandlers.size() > 1) { dragAndDropWrapper.setDropHandler(null); } else if (viewDropHandlers.size() == 1) { dragAndDropWrapper.setDropHandler(viewDropHandlers.get(0)); } else if (dragAndDropWrapper.getDropHandler() != userDocumentsWindow) { dragAndDropWrapper.setDropHandler(userDocumentsWindow); } } // SerializationUtils.clone(event.getOldView()); // SerializationUtils.clone(newView); } }); addComponent(header); addComponent(dragAndDropWrapper); setExpandRatio(dragAndDropWrapper, 1); mainMenuContentFooterLayout.addComponent(mainMenu); mainMenuContentFooterLayout.addComponent(contentFooterWrapperLayout); mainMenuContentFooterLayout.setExpandRatio(contentFooterWrapperLayout, 1); contentFooterWrapperLayout.addComponent(contentFooterLayout); contentFooterLayout.addComponent(contentViewWrapper); Component message = buildMessage(); if (message != null) { message.addStyleName("message"); contentFooterLayout.addComponent(message); } contentFooterLayout.setExpandRatio(contentViewWrapper, 1); Component footer = buildFooter(); if (footer != null) { contentFooterLayout.addComponent(footer); } Component license = buildLicense(); if (license != null) { license.addStyleName("license"); } PagesComponentsExtensionParams params = new PagesComponentsExtensionParams(header, mainMenu, contentFooterLayout, this, contentViewWrapper, contentFooterWrapperLayout, presenter.getUser()); appLayerFactory.getExtensions().getSystemWideExtensions().decorateView(params); String collection = ConstellioUI.getCurrentSessionContext().getCurrentCollection(); if (collection != null) { appLayerFactory.getExtensions().forCollection(collection).decorateView(params); } buildInitJavascript(); }
From source file:com.esofthead.mycollab.mobile.ui.AbstractMobileMenuPageView.java
License:Open Source License
public void addMenuItem(Component comp) { comp.addStyleName(SlideMenu.STYLENAME_BUTTON); getMenu().addComponent(comp); }
From source file:com.esofthead.mycollab.vaadin.ui.AddViewLayout2.java
License:Open Source License
public void addControlButtons(final Component controlsBtn) { controlsBtn.addStyleName("control-buttons"); addHeaderRight(controlsBtn);//from ww w. j a v a 2 s . c om }
From source file:com.esofthead.mycollab.vaadin.ui.FormContainer.java
License:Open Source License
public void addSection(Component sectionHeader, ComponentContainer container) { sectionHeader.addStyleName("section"); sectionHeader.setWidth("100%"); container.setWidth("100%"); this.addComponent(sectionHeader); this.addComponent(container); }
From source file:com.esofthead.mycollab.vaadin.ui.NotificationButton.java
License:Open Source License
@Override public void popupVisibilityChange(PopupVisibilityEvent event) { notificationContainer.removeAllComponents(); if (notificationItems.size() > 0) { for (AbstractNotification item : notificationItems) { Component comp = item.renderContent(); comp.setStyleName("notification-type"); comp.addStyleName("notification-type-" + item.getType()); notificationContainer.addComponent(comp); }//from w w w . j ava 2 s . com } else { Label noItemLbl = new Label("There is no notification right now"); notificationContainer.addComponent(noItemLbl); notificationContainer.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER); } }