List of usage examples for com.vaadin.ui CssLayout addComponent
@Override public void addComponent(Component c)
From source file:com.hivesys.dashboard.view.search.TextualView.java
public void UpdateSearchPane(String searchString) { css.removeAllComponents();// w w w . j av a 2s. co m SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString); logResponse(response); SearchHits results = response.getHits(); Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>", ContentMode.HTML); css.addComponent(labelResultSummary); for (SearchHit hit : results) { CssLayout cssResult = new CssLayout(); cssResult.setStyleName("search-result"); try { String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId()); String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId()); String highlight = ""; HighlightField objhighlight = hit.highlightFields().get("file"); if (objhighlight != null) { for (Text fgmt : objhighlight.getFragments()) { highlight += fgmt.string() + "<br>"; } } Button lblfileName = new Button(filename); lblfileName.addClickListener((Button.ClickEvent event) -> { if (boxviewID != null) { String url = BoxViewDocuments.getInstance().getViewURL(boxviewID); if (url != null || !url.equals("")) { url = BoxViewDocuments.getInstance().getViewURL(boxviewID); BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url)); VerticalLayout vlayout = new VerticalLayout(bframe); final Window w = new Window(); w.setSizeFull(); w.setModal(true); w.setWindowMode(WindowMode.MAXIMIZED); w.setContent(vlayout); vlayout.setSizeFull(); vlayout.setMargin(true); w.setResizable(false); w.setDraggable(false); UI.getCurrent().addWindow(w); bframe.setSizeFull(); return; } Notification.show("Preview not available for this document!"); } }); lblfileName.setPrimaryStyleName("filename"); Label lblHighlight = new Label(highlight, ContentMode.HTML); lblHighlight.setStyleName("highlight"); cssResult.addComponent(lblfileName); cssResult.addComponent(lblHighlight); css.addComponent(cssResult); css.addComponent(new Label("<br>", ContentMode.HTML)); } catch (SQLException ex) { } } }
From source file:com.klwork.explorer.project.PublicProjectListPage.java
License:Apache License
Layout buildTree() { CssLayout margin = new CssLayout(); margin.setWidth("100%"); //margin.setMargin(new MarginInfo(true, false, true, true)); // Spacing/*from w w w . j a v a 2 s .c om*/ margin.addComponent(new Label(" ", ContentMode.HTML)); Label text = new Label("hello,word"); text.addStyleName(Runo.LABEL_SMALL); margin.addComponent(text); text.setWidth("90%"); Tree t = new Tree(); String itemId = "?"; t.addItem(itemId); t.select(itemId); t.setItemIcon(itemId, new ThemeResource("icons/16/calendar.png")); createTreeItem(t, "(5000)", itemId); t.expandItem(itemId); String itemId2 = ""; t.addItem(itemId2); t.setItemIcon(itemId2, new ThemeResource("icons/16/document.png")); createTreeItem(t, "?(300)", itemId2); createTreeItem(t, "log", itemId2); t.expandItem(itemId2); String itemId3 = "?"; t.addItem(itemId3); t.setItemIcon(itemId3, new ThemeResource("icons/16/document.png")); createTreeItem(t, "?(3009)", itemId3); createTreeItem(t, "(40000)", itemId3); t.expandItem(itemId3); margin.addComponent(t); return margin; }
From source file:com.klwork.explorer.ui.custom.DetailPanel.java
License:Apache License
public DetailPanel() { setSizeFull();//from ww w . j a va 2 s. co m addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL); setMargin(true); CssLayout cssLayout = new CssLayout(); // Needed for rounded corners, cssLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_PANEL); cssLayout.setSizeFull(); super.addComponent(cssLayout); mainPanel = new Panel(); mainPanel.addStyleName(Reindeer.PANEL_LIGHT); mainPanel.setSizeFull(); cssLayout.addComponent(mainPanel); // Use default layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setWidth(100, Unit.PERCENTAGE); verticalLayout.setMargin(true); mainPanel.setContent(verticalLayout); }
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void initDescription() { CssLayout descriptionLayout = new CssLayout(); descriptionLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); descriptionLayout.setWidth(100, UNITS_PERCENTAGE); if (historicTask.getDescription() != null) { Label descriptionLabel = new Label(historicTask.getDescription()); descriptionLayout.addComponent(descriptionLabel); }/*from www .j a v a 2 s . com*/ centralLayout.addComponent(descriptionLayout); }
From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java
License:Apache License
protected void initDescription(HorizontalLayout layout) { final CssLayout descriptionLayout = new CssLayout(); descriptionLayout.setWidth(100, Unit.PERCENTAGE); layout.addComponent(descriptionLayout); layout.setExpandRatio(descriptionLayout, 1.0f); layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT); String descriptionText = null; if (task.getDescription() != null && !"".equals(task.getDescription())) { descriptionText = task.getDescription(); } else {//?? descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION); }//from ww w.ja v a 2 s . c om final Label descriptionLabel = new Label(descriptionText); descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE); descriptionLayout.addComponent(descriptionLabel); descriptionLayout.addLayoutClickListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) { // layout for textarea + ok button final VerticalLayout editLayout = new VerticalLayout(); editLayout.setSpacing(true); // textarea final TextArea descriptionTextArea = new TextArea(); // descriptionTextArea.setNullRepresentation(""); descriptionTextArea.setWidth(100, Unit.PERCENTAGE); descriptionTextArea.setValue(task.getDescription()); editLayout.addComponent(descriptionTextArea); // ok button Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); editLayout.addComponent(okButton); editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); // replace descriptionLayout.replaceComponent(descriptionLabel, editLayout); // When OK is clicked -> update task data + ui okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { // Update data task.setDescription(descriptionTextArea.getValue().toString()); taskService.saveTask(task); // Update UI descriptionLabel.setValue(task.getDescription()); descriptionLayout.replaceComponent(editLayout, descriptionLabel); } }); } } }); }
From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java
License:Apache License
protected void initTaskForm() { // Check if task requires a form //task.getT/*from w ww . j a v a 2s . com*/ TaskFormData formData = formService.getTaskFormData(task.getId()); if (formData != null && StringTool.judgeBlank(formData.getFormKey())) { TaskForm c = TaskFormFactory.create(formData.getFormKey(), task); centralLayout.addComponent(c); c.addListener(new SubmitEventListener() { private static final long serialVersionUID = -3893467157397686736L; @Override protected void submitted(SubmitEvent event) { //?????? Map<String, Object> properties = (Map<String, Object>) event.getData(); System.out.println(properties); taskService.complete(task.getId(), properties); notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName()); taskPage.refreshSelectNext(); } @Override protected void cancelled(SubmitEvent event) { taskForm.clear(); } }); return; } //formService.getS if (formData != null && formData.getFormProperties() != null && formData.getFormProperties().size() > 0) { taskForm = new FormPropertiesForm(); taskForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.TASK_COMPLETE)); taskForm.setCancelButtonCaption(i18nManager.getMessage(Messages.TASK_RESET_FORM)); taskForm.setFormHelp(i18nManager.getMessage(Messages.TASK_FORM_HELP)); taskForm.setFormProperties(formData.getFormProperties()); //WW_TODO form? taskForm.addListener(new FormPropertiesEventListener() { private static final long serialVersionUID = -3893467157397686736L; @Override protected void handleFormSubmit(FormPropertiesEvent event) { //?????? Map<String, String> properties = event.getFormProperties(); formService.submitTaskFormData(task.getId(), properties); notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName()); taskPage.refreshSelectNext(); } @Override protected void handleFormCancel(FormPropertiesEvent event) { // Clear the form values taskForm.clear(); } }); // Only if current user is task's assignee taskForm.setEnabled(isCurrentUserAssignee()); // Add component to page centralLayout.addComponent(taskForm); } else { // Just add a button to complete the task // TODO: perhaps move to a better place CssLayout buttonLayout = new CssLayout(); buttonLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); buttonLayout.setWidth(100, Unit.PERCENTAGE); centralLayout.addComponent(buttonLayout); completeButton = new Button(i18nManager.getMessage(Messages.TASK_COMPLETE)); completeButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { // If no owner, make assignee owner (will go into archived then) if (task.getOwner() == null) { task.setOwner(task.getAssignee()); taskService.setOwner(task.getId(), task.getAssignee()); } taskService.complete(task.getId()); notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName()); taskPage.refreshSelectNext(); } }); completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner()); buttonLayout.addComponent(completeButton); } }
From source file:com.lizardtech.expresszip.ui.FindLayersPresenter.java
License:Apache License
private void addClusteredVectorLayer() { if (clusterLayer != null) { findLayersMap.removeLayer(clusterLayer); }/*from w w w. jav a 2 s.com*/ clusterLayer = new VectorLayer(); clusterLayer.setSelectionMode(SelectionMode.SIMPLE); clusterLayer.addListener(new org.vaadin.vol.VectorLayer.VectorSelectedListener() { @Override public void vectorSelected(org.vaadin.vol.VectorLayer.VectorSelectedEvent event) { Vector[] vectors = event.getVectors(); if (null == vectors) return; if (null != popup) { findLayersMap.removeComponent(popup); } popup = new Popup(); findLayersMap.addPopup(popup); CssLayout cssLayout = new CssLayout(); VerticalLayout verticalLayout = new VerticalLayout(); Panel panel = new Panel(); panel.setStyleName(Runo.PANEL_LIGHT); panel.setContent(verticalLayout); int height = Math.min(400, (vectors.length + 1) * 32 + 10); panel.setHeight(height + "px"); cssLayout.addComponent(panel); popup.addComponent(cssLayout); TreeTable popupTable = findLayersView.getPopupTable(); popupTable.removeAllItems(); verticalLayout.addComponent(popupTable); List<ExpressZipLayer> layers = new ArrayList<ExpressZipLayer>(); for (Vector selected : vectors) { final ExpressZipLayer layer = (ExpressZipLayer) selected.getData(); findLayersView.addLayerItem(layer, popupTable); layers.add(layer); } Bounds b = MapModel.getBoundsForLayers(layers, MapModel.EPSG4326); popup.setLat((b.getMinLat() + b.getMaxLat()) / 2.0d); popup.setLon((b.getMaxLon() + b.getMinLon()) / 2.0d); } }); clusterLayer.addListener(new org.vaadin.vol.VectorLayer.VectorUnSelectedListener() { @Override public void vectorUnSelected(VectorUnSelectedEvent event) { if (null != popup) { findLayersMap.removeComponent(popup); popup = null; } } }); clusterLayer.setImmediate(true); findLayersMap.addLayer(clusterLayer); }
From source file:com.m4gik.views.component.LibraryScreen.java
/** * @param audioFile/*from w ww .j a v a2 s.com*/ * @return */ private CssLayout addDetails(AudioFile audioFile) { CssLayout details = new CssLayout(); details.setWidth("100%"); Label title = new Label("<h3>" + audioFile.getArtist() + "–" + audioFile.getTitle() + "</h3>", ContentMode.HTML); details.addComponent(title); title.setSizeUndefined(); TabSheet tabs = new TabSheet(); tabs.addStyleName(Runo.TABSHEET_SMALL); tabs.setWidth("100%"); tabs.setHeight("180px"); details.addComponent(tabs); FormLayout formLayout = new FormLayout(); tabs.addTab(formLayout, "Info"); Label text = new Label(audioFile.getTitle()); text.setCaption("Title:"); formLayout.addComponent(text); text = new Label(audioFile.getArtist()); text.setCaption("Artist:"); formLayout.addComponent(text); text = new Label(audioFile.getAlbum()); text.setCaption("Album:"); formLayout.addComponent(text); text = new Label(audioFile.getGenre()); text.setCaption("Genre:"); formLayout.addComponent(text); text = new Label(audioFile.getPrice() + "$"); text.setCaption("Price"); formLayout.addComponent(text); formLayout = new FormLayout(); tabs.addTab(formLayout, "Decription"); text = new Label(audioFile.getAbout()); formLayout.addComponent(text); formLayout = new FormLayout(); tabs.addTab(formLayout, "Lyrics"); text = new Label(audioFile.getLyrics()); formLayout.addComponent(text); return details; }
From source file:com.m4gik.views.component.LibraryScreen.java
/** * This method builds audio library for current filter. * //www . j a v a 2 s . c o m * @param grid * The object to locate the audio covers. * @param filter * The filter to extract need music files. */ private void buildAudioLibrary(GridLayout grid, String filter) { AudioCollection audio = new AudioCollection(); for (final AudioFile audioFile : audio.getAudioCollection(filter)) { CssLayout select = new CssLayout(); select.addStyleName(Runo.CSSLAYOUT_SELECTABLE); CssLayout musicFile = new CssLayout(); musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW); musicFile.addComponent(createImageCover(audioFile.getCover())); select.addComponent(musicFile); musicFile.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 5789650754220216969L; @Override public void layoutClick(LayoutClickEvent event) { buildInformationPanel(audioFile); } }); grid.addComponent(select); grid.setComponentAlignment(select, Alignment.MIDDLE_CENTER); } Label text = new Label("Note: This track are on Crative Common license."); text.addStyleName(Runo.LABEL_SMALL); text.setWidth("90%"); grid.addComponent(text); grid.setComponentAlignment(text, Alignment.MIDDLE_CENTER); }
From source file:com.m4gik.views.component.LibraryScreen.java
/** * @param audioFile/*from w w w.ja v a 2 s . com*/ */ protected void buildInformationPanel(AudioFile audioFile) { if (bottom == null) { this.bottom = new HorizontalLayout(); bottom.setWidth("100%"); content.addComponent(bottom); VerticalLayout side = new VerticalLayout(); side.setMargin(true); side.setSpacing(true); side.setWidth("170px"); bottom.addComponent(side); CssLayout musicFile = new CssLayout(); musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW); musicFile.addComponent(createPlayImage(audioFile, audioFile.getCover())); side.addComponent(musicFile); side.addComponent(setFavorite()); side.addComponent(setRate()); Component details = addDetails(audioFile); bottom.addComponent(details); bottom.setExpandRatio(details, 1); } else { bottom.removeAllComponents(); content.removeComponent(bottom); this.bottom = null; buildInformationPanel(audioFile); } }