List of usage examples for com.vaadin.ui Window getContent
@Override
public Component getContent()
From source file:eu.lod2.stat.StatLOD2Demo.java
License:Apache License
/** * A function to get an ontowiki export command * @param format - the formating string defining the format to export in *//*from w ww. ja v a 2 s .c o m*/ private MenuBar.Command getOWExportCommand(final String format) { return new MenuBar.Command() { public void menuSelected(final MenuItem selectedItem) { String currentGraph = state.getCurrentGraph(); if (currentGraph == null || currentGraph.isEmpty()) { final Window window = new Window("No graph selected"); window.setWidth("550px"); LOD2DemoState.CurrentGraphListener listener = new LOD2DemoState.CurrentGraphListener() { boolean ignoreFirst = true; public void notifyCurrentGraphChange(String graph) { if (ignoreFirst) { ignoreFirst = false; return; } window.getParent().removeWindow(window); menuSelected(selectedItem); state.removeCurrentGraphListener(this); } }; VerticalLayout layout = (VerticalLayout) window.getContent(); layout.addComponent(new Label( "You did not specify a graph to work with. Please do so below and try again: ")); ConfigurationTab configure = new ConfigurationTab(state); layout.addComponent(configure); layout.setComponentAlignment(configure, Alignment.BOTTOM_CENTER); getMainWindow().addWindow(window); window.center(); state.addCurrentGraphListener(listener); return; } try { getMainWindow() .open(new ExternalResource(state.getHostNameWithoutPort() + "/ontowiki/model/export?m=" + URLEncoder.encode(currentGraph, "UTF-8") + "&f=" + format)); } catch (UnsupportedEncodingException e) { // should never happen throw new RuntimeException("The lod2 server encountered error when exporting the graph: " + e.getMessage() + " Please contact an administrator"); } } }; }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void setUserMeter(final Main main, final Base base, final Meter m) { final Database database = main.getDatabase(); final Window subwindow = new Window("Aseta mittarin arvo", new VerticalLayout()); subwindow.setModal(true);/*from w w w. j a v a2 s. c o m*/ subwindow.setWidth("350px"); subwindow.setResizable(false); final VerticalLayout winLayout = (VerticalLayout) subwindow.getContent(); winLayout.setMargin(true); winLayout.setSpacing(true); String caption = m.getCaption(database); if (caption != null && !caption.isEmpty()) { final Label header = new Label(caption); header.addStyleName(ValoTheme.LABEL_LARGE); winLayout.addComponent(header); } final Indicator indicator = m.getPossibleIndicator(database); if (indicator == null) return; Datatype dt = indicator.getDatatype(database); if (!(dt instanceof EnumerationDatatype)) return; final Label l = new Label("Selite: " + indicator.getValueShortComment()); AbstractField<?> forecastField = dt.getEditor(main, base, indicator, true, new CommentCallback() { @Override public void runWithComment(String shortComment, String comment) { l.setValue("Selite: " + indicator.getValueShortComment()); } @Override public void canceled() { } }); forecastField.setWidth("100%"); forecastField.setCaption("Ennuste"); winLayout.addComponent(forecastField); AbstractField<?> currentField = dt.getEditor(main, base, indicator, false, new CommentCallback() { @Override public void runWithComment(String shortComment, String comment) { l.setValue("Selite: " + indicator.getValueShortComment()); } @Override public void canceled() { } }); currentField.setWidth("100%"); currentField.setCaption("Toteuma"); winLayout.addComponent(currentField); winLayout.addComponent(l); l.setWidth("100%"); winLayout.setComponentAlignment(l, Alignment.BOTTOM_CENTER); HorizontalLayout hl = new HorizontalLayout(); winLayout.addComponent(hl); winLayout.setComponentAlignment(hl, Alignment.BOTTOM_CENTER); Button ok = new Button("Sulje", new Button.ClickListener() { private static final long serialVersionUID = 1364802814012491490L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); } }); Button define = new Button("Mrit", new Button.ClickListener() { private static final long serialVersionUID = 1364802814012491490L; public void buttonClick(ClickEvent event) { Meter.editMeter(main, base, m); } }); hl.addComponent(ok); hl.setComponentAlignment(ok, Alignment.BOTTOM_LEFT); hl.addComponent(define); hl.setComponentAlignment(define, Alignment.BOTTOM_LEFT); main.addWindow(subwindow); }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void editTextAndId(final Main main, String title, final Base container) { final Database database = main.getDatabase(); final Window subwindow = new Window(title, new VerticalLayout()); subwindow.setModal(true);/*from w w w .j av a 2s.c o m*/ subwindow.setWidth("400px"); subwindow.setHeight("500px"); subwindow.setResizable(false); VerticalLayout winLayout = (VerticalLayout) subwindow.getContent(); winLayout.setMargin(true); winLayout.setSpacing(true); final TextField tf = new TextField(); tf.setCaption("Lyhytnimi:"); tf.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf.setValue(container.getId(database)); tf.setWidth("100%"); winLayout.addComponent(tf); final TextArea ta = new TextArea(); ta.setCaption("Teksti:"); ta.setValue(container.getText(database)); ta.setWidth("100%"); ta.setHeight("290px"); winLayout.addComponent(ta); Button save = new Button("Tallenna", new Button.ClickListener() { private static final long serialVersionUID = 6641880870005364983L; public void buttonClick(ClickEvent event) { String idValue = tf.getValue(); String value = ta.getValue(); main.removeWindow(subwindow); container.modifyId(main, idValue); container.modifyText(main, value); Collection<String> tags = Tag.extractTags(value); database.assertTags(tags); ArrayList<Tag> tagObjects = new ArrayList<Tag>(); for (String s : tags) tagObjects.add(database.getOrCreateTag(s)); container.assertRelatedTags(database, tagObjects); Updates.update(main, true); Property emails = Property.find(database, Property.EMAIL); String addr = emails.getPropertyValue(container); if (addr != null && !addr.isEmpty()) { String[] addrs = addr.split(","); if (addrs.length > 0) { try { Email.send(addrs, "Muutos strategiakartassa: " + container.getId(database), "Kyttj " + main.account.getId(database) + " on muuttanut strategiakarttaa.<br/><br/>Lyhytnimi: " + container.getId(database) + "<br/><br/>Teksti: " + container.getText(database)); } catch (MessagingException e) { e.printStackTrace(); } } } } }); Button discard = new Button("Peru muutokset", new Button.ClickListener() { private static final long serialVersionUID = -784522457615993823L; public void buttonClick(ClickEvent event) { Updates.update(main, true); main.removeWindow(subwindow); } }); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.addComponent(save); hl2.addComponent(discard); winLayout.addComponent(hl2); winLayout.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); main.addWindow(subwindow); ta.setCursorPosition(ta.getValue().length()); }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void editTags(final Main main, String title, final Base container) { final Database database = main.getDatabase(); final Window subwindow = new Window(title, new VerticalLayout()); subwindow.setModal(true);/* w w w . j a v a2 s .co m*/ subwindow.setWidth("400px"); subwindow.setHeight("360px"); subwindow.setResizable(true); VerticalLayout winLayout = (VerticalLayout) subwindow.getContent(); winLayout.setMargin(true); winLayout.setSpacing(true); // Add some content; a label and a close-button final List<String> tags = new ArrayList<String>(); for (Tag t : container.getRelatedTags(database)) tags.add(t.getId(database)); final CssLayout vl = new CssLayout(); vl.setCaption("Kytss olevat aihetunnisteet:"); fillTagEditor(database, vl, tags, Account.canWrite(main, container)); winLayout.addComponent(vl); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); hl.setSpacing(true); final TagCombo combo = new TagCombo(); final CustomLazyContainer comboContainer = new CustomLazyContainer(database, combo, Tag.enumerate(database)); combo.setWidth("100%"); combo.setCaption("Uusi aihetunniste:"); combo.setInputPrompt("valitse listasta tai kirjoita"); combo.setFilteringMode(FilteringMode.STARTSWITH); combo.setTextInputAllowed(true); combo.setImmediate(true); combo.setNullSelectionAllowed(false); combo.setInvalidAllowed(true); combo.setInvalidCommitted(true); combo.setItemCaptionMode(ItemCaptionMode.PROPERTY); combo.setItemCaptionPropertyId("id"); //should set combo.setContainerDataSource(comboContainer); hl.addComponent(combo); hl.setExpandRatio(combo, 1.0f); Button add = new Button("Lis", new Button.ClickListener() { private static final long serialVersionUID = -2848576385076605664L; public void buttonClick(ClickEvent event) { String filter = (String) combo.getValue(); if (filter != null && filter.length() > 0) { Tag t = database.getOrCreateTag(filter); if (tags.contains(t.getId(database))) return; tags.add(t.getId(database)); fillTagEditor(database, vl, tags, main.account != null); combo.clear(); } } }); hl.addComponent(add); hl.setComponentAlignment(add, Alignment.BOTTOM_LEFT); hl.setExpandRatio(add, 0.0f); winLayout.addComponent(hl); Button close = new Button("Tallenna", new Button.ClickListener() { private static final long serialVersionUID = -451523776456589591L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); List<Tag> newTags = new ArrayList<Tag>(); for (String s : tags) newTags.add(database.getOrCreateTag(s)); container.setRelatedTags(database, newTags); Updates.update(main, true); } }); Button discard = new Button("Peru muutokset", new Button.ClickListener() { private static final long serialVersionUID = -2387057110951581993L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); } }); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.addComponent(close); hl2.addComponent(discard); winLayout.addComponent(hl2); winLayout.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); main.addWindow(subwindow); }
From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.KmlDocumentViewer.java
License:Apache License
public KmlDocumentViewer(String focusedFeature, Coordinate coordinate) { super();/*from w w w.j a v a 2s. c o m*/ setImmediate(true); loadDocument(); setWidth(100, UNITS_PERCENTAGE); addComponent(ufu); addLayer(osm); addLayer(vectorLayer); extractStyles(doc); displayFeatures(focusedFeature); vectorLayer.setSelectionMode(SIMPLE); vectorLayer.setImmediate(true); vectorLayer.addListener(new VectorSelectedListener() { public void vectorSelected(VectorSelectedEvent event) { final Area component = (Area) event.getVector(); final String data = (String) component.getData(); final Window window = new Window("Details"); window.getContent().setSizeFull(); window.setHeight("50%"); window.setWidth("50%"); Button button = new Button("Focus this feature"); button.addListener(new ClickListener() { private static final long serialVersionUID = 3286851301965195290L; @Override public void buttonClick(ClickEvent event) { ufu.setFragment(data); displayFeatures(data); window.getParent().removeWindow(window); } }); window.addComponent(button); window.setClosable(true); window.center(); getWindow().addWindow(window); vectorLayer.setSelectedVector(null); } }); if (coordinate != null) { // Definig a Marker Layer MarkerLayer markerLayer = new MarkerLayer(); // Defining a new Marker final Marker marker = new Marker(coordinate.getLongitude(), coordinate.getLatitude()); // URL of marker Icon marker.setIcon(new ThemeResource("img/marker.png"), 60, 60); markerLayer.addComponent(marker); addLayer(markerLayer); setCenter(coordinate.getLongitude(), coordinate.getLatitude()); } }
From source file:org.apache.ace.webui.vaadin.VaadinClient.java
License:Apache License
public void init() { setTheme("ace"); if (!m_dependenciesResolved.get()) { final Window message = new Window("Apache ACE"); message.getContent().setSizeFull(); setMainWindow(message);// w w w . j a va 2s.c om Label richText = new Label("<h1>Apache ACE User Interface</h1>" + "<p>Due to missing component dependencies on the server, probably due to misconfiguration, " + "the user interface cannot be properly started. Please contact your server administrator. " + "You can retry accessing the user interface by <a href=\"?restartApplication\">following this link</a>.</p>"); richText.setContentMode(Label.CONTENT_XHTML); // TODO we might want to add some more details here as to what's // missing on the other hand, the user probably can't fix that anyway message.addComponent(richText); return; } m_mainWindow = new Window("Apache ACE"); m_mainWindow.getContent().setSizeFull(); m_mainWindow.setBorder(Window.BORDER_NONE); setMainWindow(m_mainWindow); // Authenticate the user either by showing a login window; or by another means... authenticate(); }
From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java
License:Open Source License
@SuppressWarnings("serial") private Window createReviewWindow(final ProjectRating rating) { final Window subwindow = new Window("Rate and Review"); subwindow.setModal(true);/*w ww. jav a 2s . c om*/ subwindow.setWidth("420px"); //$NON-NLS-1$ subwindow.setHeight("320px"); //$NON-NLS-1$ VerticalLayout vl = (VerticalLayout) subwindow.getContent(); vl.setSpacing(true); vl.setSizeFull(); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); Embedded icon = new Embedded(null, getIcon(rating)); Label iconLabel = new Label("<b>" + HSPACE + getReviewComment(rating) + "</b>", Label.CONTENT_XHTML); //$NON-NLS-1$ //$NON-NLS-2$ String captionTextField = getReviewCommentQuestion(rating); hl.addComponent(icon); hl.addComponent(iconLabel); hl.setComponentAlignment(iconLabel, Alignment.MIDDLE_LEFT); vl.addComponent(hl); final TextField editor = new TextField(captionTextField); editor.setRows(3); editor.setColumns(30); editor.setImmediate(true); vl.addComponent(editor); final User user = util.getLoggedInUser(); final ArrayList<String> userSelects = new ArrayList<String>(2); userSelects.add("I want to vote as " + user.getDisplayName()); if (extension.getAllowAnonymous()) { userSelects.add("I want to vote as Anonymous!"); } final OptionGroup userSelect = new OptionGroup(null, userSelects); userSelect.setNullSelectionAllowed(false); userSelect.select(userSelects.get(0)); vl.addComponent(userSelect); CssLayout css = new CssLayout() { @Override protected String getCss(Component c) { return "margin-left:5px;margin-right:5px;margin-top:10px"; //$NON-NLS-1$ } }; Button okButton = new Button("OK"); okButton.setIcon(ICON_BUTTON_OK); okButton.setDescription("Commit changes"); okButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String comment = (String) editor.getValue(); if (StringUtils.isBlank(comment)) { comment = "No Comment"; } ((Window) subwindow.getParent()).removeWindow(subwindow); String userName = "Anonymous"; if (userSelects.get(0).equals(userSelect.getValue())) { userName = user.getDisplayName(); } ReviewEntry review = new ReviewEntry(rating, comment, userName, System.currentTimeMillis()); extension.addReview(review); util.persist(project); reviews = extension.getReviews(); size = reviews.size(); currentPage = 0; lastPage = size / currentPageLength; paintReviewList(); } }); css.addComponent(okButton); Button cancelButton = new Button("Cancel"); cancelButton.setIcon(ICON_BUTTON_CANCEL); cancelButton.setDescription("Discard changes"); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ((Window) subwindow.getParent()).removeWindow(subwindow); } }); css.addComponent(cancelButton); vl.addComponent(css); vl.setComponentAlignment(css, Alignment.MIDDLE_CENTER); return subwindow; }
From source file:org.escidoc.browser.ui.listeners.OnContextAdminDescriptor.java
License:Open Source License
@SuppressWarnings("serial") public void adminDescriptorForm() { final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true);/*from www.j a v a2 s . c o m*/ subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); final TextField txtName = new TextField("Name"); txtName.setImmediate(true); txtName.setValidationVisible(true); final TextArea txtContent = new TextArea("Content"); txtContent.setColumns(30); txtContent.setRows(40); Button addAdmDescButton = new Button("Add Description"); addAdmDescButton.addListener(new ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { if (txtName.getValue().toString() == null) { router.getMainWindow().showNotification(ViewConstants.PLEASE_ENTER_A_NAME, Notification.TYPE_ERROR_MESSAGE); } else if (!XmlUtil.isWellFormed(txtContent.getValue().toString())) { router.getMainWindow().showNotification(ViewConstants.XML_IS_NOT_WELL_FORMED, Notification.TYPE_ERROR_MESSAGE); } else { AdminDescriptor newAdmDesc = controller.addAdminDescriptor(txtName.getValue().toString(), txtContent.getValue().toString()); (subwindow.getParent()).removeWindow(subwindow); router.getMainWindow().showNotification("Addedd Successfully", Notification.TYPE_HUMANIZED_MESSAGE); } } }); subwindow.addComponent(txtName); subwindow.addComponent(txtContent); subwindow.addComponent(addAdmDescButton); Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); }
From source file:org.escidoc.browser.ui.listeners.OnContextAdminDescriptor.java
License:Open Source License
/** * Editing since it has a parameter// w w w . j av a 2 s.co m * * @param adminDescriptor */ public void adminDescriptorForm(AdminDescriptor adminDescriptor) { // Editing final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); final TextField txtName = new TextField("Name"); txtName.setValue(adminDescriptor.getName()); txtName.setImmediate(true); txtName.setValidationVisible(true); final TextArea txtContent = new TextArea("Content"); txtContent.setColumns(30); txtContent.setRows(40); try { txtContent.setValue(adminDescriptor.getContentAsString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } txtContent.setColumns(30); Button addAdmDescButton = new Button("Add Description"); addAdmDescButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (txtName.getValue().toString() == null) { router.getMainWindow().showNotification(ViewConstants.PLEASE_ENTER_A_NAME, Notification.TYPE_ERROR_MESSAGE); } else if (!XmlUtil.isWellFormed(txtContent.getValue().toString())) { router.getMainWindow().showNotification(ViewConstants.XML_IS_NOT_WELL_FORMED, Notification.TYPE_ERROR_MESSAGE); } else { controller.addAdminDescriptor(txtName.getValue().toString(), txtContent.getValue().toString()); (subwindow.getParent()).removeWindow(subwindow); router.getMainWindow().showNotification("Addedd Successfully", Notification.TYPE_HUMANIZED_MESSAGE); } } }); subwindow.addComponent(txtName); subwindow.addComponent(txtContent); subwindow.addComponent(addAdmDescButton); Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); }
From source file:org.escidoc.browser.ui.maincontent.ContainerMetadataRecordsView.java
License:Open Source License
@SuppressWarnings("serial") private Panel lblAddtionalResources() { final Panel pnl = new Panel(); pnl.setSizeFull();/* w w w. j a v a 2 s. c o m*/ VerticalLayout hl = new VerticalLayout(); hl.setSizeFull(); final Button btnVersionHistoryContainer = new Button("Container Version History", new VersionHistoryClickListener(resourceProxy, mainWindow, repositories)); btnVersionHistoryContainer.setStyleName(BaseTheme.BUTTON_LINK); btnVersionHistoryContainer.setDescription("Show Version history in a Pop-up"); final CssLayout cssLayout = new CssLayout(); buildPanelHeader(cssLayout, "Additional Resources"); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); final Button addResourceButton = new Button(); addResourceButton.setStyleName(BaseTheme.BUTTON_LINK); addResourceButton.addStyleName("floatright paddingtop3"); addResourceButton.setWidth("20px"); addResourceButton.setIcon(ICON); addResourceButton.addListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); subwindow.addComponent(new Label("Not yet implemented")); Button close = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); } }); cssLayout.addComponent(addResourceButton); hl.addComponent(cssLayout); hl.addComponent(btnVersionHistoryContainer); pnl.setContent(hl); return pnl; }