List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:org.adho.dhconvalidator.ui.AboutWindow.java
private void initComponents() { setModal(true);//w ww.ja v a 2 s .co m setHeight("100px"); setWidth("300px"); center(); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSizeFull(); Label aboutLabel = new Label(Messages.getString("AboutWindow.info", PropertyKey.version.getValue()), ContentMode.HTML); content.addComponent(aboutLabel); content.setComponentAlignment(aboutLabel, Alignment.MIDDLE_CENTER); setContent(content); }
From source file:org.adho.dhconvalidator.ui.ConverterPanel.java
/** Setup GUI. */ private void initComponents() { setMargin(true);/*from w ww . ja v a 2 s .co m*/ setSizeFull(); setSpacing(true); HeaderPanel headerPanel = new HeaderPanel(null); addComponent(headerPanel); Label title = new Label(Messages.getString("ConverterPanel.title")); title.addStyleName("title-caption"); addComponent(title); setComponentAlignment(title, Alignment.TOP_LEFT); Label info = new Label(Messages.getString("ConverterPanel.info"), ContentMode.HTML); addComponent(info); HorizontalLayout inputPanel = new HorizontalLayout(); inputPanel.setSpacing(true); addComponent(inputPanel); upload = new Upload(Messages.getString("ConverterPanel.uploadCaption"), new Receiver() { @Override public OutputStream receiveUpload(String filename, String mimeType) { // we store the uploaded content in the panel instance ConverterPanel.this.filename = filename; ConverterPanel.this.uploadContent = new ByteArrayOutputStream(); return ConverterPanel.this.uploadContent; } }); inputPanel.addComponent(upload); progressBar = new ProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(false); inputPanel.addComponent(progressBar); inputPanel.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER); progressBar.addStyleName("converterpanel-progressbar"); resultCaption = new Label(Messages.getString("ConverterPanel.previewTitle2")); resultCaption.setWidth("100%"); resultCaption.addStyleName("converterpanel-resultcaption"); addComponent(resultCaption); setComponentAlignment(resultCaption, Alignment.MIDDLE_CENTER); resultPanel = new HorizontalSplitPanel(); addComponent(resultPanel); resultPanel.setSizeFull(); setExpandRatio(resultPanel, 1.0f); preview = new Label("", ContentMode.HTML); preview.addStyleName("tei-preview"); resultPanel.addComponent(preview); VerticalLayout rightPanel = new VerticalLayout(); rightPanel.setMargin(new MarginInfo(false, false, true, true)); rightPanel.setSpacing(true); resultPanel.addComponent(rightPanel); logArea = new Label("", ContentMode.HTML); logArea.setSizeFull(); logArea.setReadOnly(true); rightPanel.addComponent(logArea); downloadInfo = new Label(Messages.getString("ConverterPanel.downloadMsg")); rightPanel.addComponent(downloadInfo); downloadInfo.setVisible(false); btDownloadResult = new Button(Messages.getString("ConverterPanel.downloadBtCaption")); btDownloadResult.setVisible(false); rightPanel.addComponent(btDownloadResult); rightPanel.setComponentAlignment(btDownloadResult, Alignment.BOTTOM_CENTER); btDownloadResult.setHeight("50px"); rightPanel.addComponent(new Label(Messages.getString("ConverterPanel.exampleMsg"))); Button btExample = new Button(Messages.getString("ConverterPanel.exampleButtonCaption")); btExample.setStyleName(BaseTheme.BUTTON_LINK); btExample.addStyleName("plain-link"); rightPanel.addComponent(btExample); confToolLabel = new Label( Messages.getString("ConverterPanel.gotoConfToolMsg", PropertyKey.conftool_login_url.getValue()), ContentMode.HTML); confToolLabel.setVisible(false); confToolLabel.addStyleName("postDownloadInfoRedAndBold"); rightPanel.addComponent(confToolLabel); new BrowserWindowOpener(DHConvalidatorExample.class).extend(btExample); }
From source file:org.adho.dhconvalidator.ui.DHConvalidatorExample.java
@Override protected void init(VaadinRequest request) { try {// w w w .ja v a 2 s . c o m Messages.setLocaleProvider(VaadinSessionLocaleProvider.INSTANCE); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); setContent(content); HeaderPanel headerPanel = new HeaderPanel(null); headerPanel.getBackLink().setVisible(false); content.addComponent(headerPanel); // prepare downloader for input file Button btGetInputfile = new Button(Messages.getString("DHConvalidatorExample.btInputCaption")); content.addComponent(btGetInputfile); FileDownloader inputFileDownloader = new FileDownloader(new StreamResource(new StreamSource() { @Override public InputStream getStream() { return Thread.currentThread().getContextClassLoader().getResourceAsStream( "/org/adho/dhconvalidator/conversion/example/1_Digital_Humanities.odt"); } }, "1_Digital_Humanities.odt")); inputFileDownloader.extend(btGetInputfile); // prepare downloader for output file Button btGetOutputfile = new Button( Messages.getString("DHConvalidatorExample.btConversionResultCaption")); content.addComponent(btGetOutputfile); FileDownloader outputFileDownloader = new FileDownloader(new StreamResource(new StreamSource() { @Override public InputStream getStream() { return Thread.currentThread().getContextClassLoader().getResourceAsStream( "/org/adho/dhconvalidator/conversion/example/1_Digital_Humanities.dhc"); } }, "1_Digital_Humanities.dhc")); outputFileDownloader.extend(btGetOutputfile); // setup visual feedback Label preview = new Label("", ContentMode.HTML); preview.addStyleName("tei-preview"); preview.setWidth("800px"); content.addComponent(preview); content.setComponentAlignment(preview, Alignment.MIDDLE_CENTER); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream( "/org/adho/dhconvalidator/conversion/example/1_Digital_Humanities.html"), buffer); preview.setValue(buffer.toString("UTF-8")); Page.getCurrent().setTitle(Messages.getString("DHConvalidatorExample.title")); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Default constructor./* w w w .j a v a2s. c o m*/ */ public BuildingControlPanel() { site = ((AgoControlSiteUI) UI.getCurrent()).getSite(); siteContext = site.getSiteContext(); entityManager = siteContext.getObject(EntityManager.class); layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setSizeFull(); layout.setStyleName(Reindeer.LAYOUT_WHITE); final Label title = new Label("Control Panel"); title.setIcon(getSite().getIcon("inventory")); title.setStyleName(Reindeer.LABEL_H2); layout.addComponent(title); layout.setExpandRatio(title, 0); elementLayout = new VerticalLayout(); elementLayout.setSpacing(true); elementLayout.setMargin(false); layout.addComponent(elementLayout); layout.setExpandRatio(elementLayout, 1); roomIcon = site.getIcon("room"); deviceIcon = site.getIcon("device"); temperatureIcon = site.getIcon("temperature"); brightnessIcon = site.getIcon("brightness"); humidityIcon = site.getIcon("humidity"); eventIcon = site.getIcon("event"); setCompositionRoot(layout); // the Refresher polls automatically final Refresher refresher = new Refresher(); refresher.setRefreshInterval(200); refresher.addListener(new Refresher.RefreshListener() { @Override public void refresh(final Refresher refresher) { while (!recordsQueue.isEmpty()) { final List<Record> records = recordsQueue.remove(); if (records.size() > 0) { final Record record = records.get(0); final RecordSet recordSet = record.getRecordSet(); final Element element = recordSet.getElement(); final GridLayout recordsLayout = recordsLayouts.get(element.getElementId()); if (recordsLayout == null) { continue; } final int columnIndex = recordSet.getType().ordinal(); final int rowIndex = 0; if (recordsLayout.getComponent(columnIndex, rowIndex) != null) { continue; } final VerticalLayout recordLayout = new VerticalLayout(); recordLayout.setSpacing(true); final Resource recordIcon; switch (recordSet.getType()) { case TEMPERATURE: recordIcon = temperatureIcon; break; case BRIGHTNESS: recordIcon = brightnessIcon; break; case HUMIDITY: recordIcon = humidityIcon; break; default: recordIcon = eventIcon; break; } final Embedded embedded = new Embedded(null, recordIcon); recordLayout.addComponent(embedded); recordLayout.setExpandRatio(embedded, 0.1f); embedded.setWidth(32, Unit.PIXELS); embedded.setHeight(32, Unit.PIXELS); final Label label = new Label(); recordLayout.addComponent(label); recordLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); final String recordUnit = recordSet.getUnit(); final String displayUnit = DisplayValueConversionUtil.getDisplayUnit(recordSet.getType(), recordUnit); final double displayValue = DisplayValueConversionUtil.convertValue(recordSet.getType(), recordUnit, displayUnit, record.getValue()); final String displayValueString = DisplayValueConversionUtil.formatDouble(displayValue); label.setValue(displayValueString + " " + displayUnit); label.setDescription(record.getCreated().toString()); recordsLayout.addComponent(recordLayout, columnIndex, rowIndex); } } } }); addExtension(refresher); }
From source file:org.airline.CelestiaLogin.java
@Override protected void init(VaadinRequest request) { //Vista final para la UI final VerticalLayout layout = new VerticalLayout(); Panel loginPanel = new Panel("Login"); CustomLayout login = new CustomLayout("LoginLayout"); //Seccin de Vista del Login //VerticalLayout login=new VerticalLayout(); Label label = new Label("Iniciar Sesin / Registrarse"); TextField user = new TextField("", "Usuario"); TextField passwd = new TextField("", "Contrasea"); Button init_session = new Button("Iniciar Sesin"); init_session.setStyleName(ValoTheme.BUTTON_PRIMARY); init_session.addClickListener(cliqueo -> { Notification.show("Bienvenido " + user.getValue()); });// ww w. java 2 s . c o m login.addComponent(label); login.addComponent(user); login.addComponent(passwd); login.addComponent(init_session); login.setWidth("500px"); //login.setMargin(true); login.setResponsive(true); layout.addComponent(login); layout.setComponentAlignment(login, Alignment.MIDDLE_CENTER); setContent(login); }
From source file:org.apache.ace.tageditor.ACETagEditorExtension.java
License:Apache License
/** * {@inheritDoc}/*from w ww . j a v a2s . c om*/ */ public Component create(Map<String, Object> context) { final RepositoryObject sgo = getRepositoryObjectFromContext(context); Component editor; if (sgo instanceof StatefulTargetObject) { StatefulTargetObject statefulTarget = (StatefulTargetObject) sgo; if (statefulTarget.isRegistered()) { editor = createTagEditor(sgo); } else { editor = new Label("This target is not yet registered, so you cannot add tags."); } } else { editor = createTagEditor(sgo); } VerticalLayout result = new VerticalLayout(); result.setCaption("Tag Editor"); result.addComponent(editor); result.setComponentAlignment(editor, Alignment.MIDDLE_CENTER); return result; }
From source file:org.apache.ace.webui.vaadin.AddArtifactWindow.java
License:Apache License
/** * Creates a new {@link AddArtifactWindow} instance. * //ww w .j a va2 s . c o m * @param sessionDir * the session directory to temporary place artifacts in; * @param obrUrl * the URL of the OBR to use. */ public AddArtifactWindow(File sessionDir, URL obrUrl, String repositoryXML) { super("Add artifact"); m_sessionDir = sessionDir; m_obrUrl = obrUrl; m_repositoryXML = repositoryXML; setModal(true); setWidth("50em"); setCloseShortcut(KeyCode.ESCAPE); m_artifactsTable = new Table("Artifacts in repository"); m_artifactsTable.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null); m_artifactsTable.addContainerProperty(PROPERTY_VERSION, String.class, null); m_artifactsTable.addContainerProperty(PROPERTY_PURGE, Button.class, null); m_artifactsTable.setSizeFull(); m_artifactsTable.setSelectable(true); m_artifactsTable.setMultiSelect(true); m_artifactsTable.setImmediate(true); m_artifactsTable.setHeight("15em"); final Table uploadedArtifacts = new Table("Uploaded artifacts"); uploadedArtifacts.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null); uploadedArtifacts.addContainerProperty(PROPERTY_VERSION, String.class, null); uploadedArtifacts.setSizeFull(); uploadedArtifacts.setSelectable(false); uploadedArtifacts.setMultiSelect(false); uploadedArtifacts.setImmediate(true); uploadedArtifacts.setHeight("15em"); final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir) { @Override public void updateProgress(long readBytes, long contentLength) { // TODO Auto-generated method stub } @Override protected void artifactsUploaded(List<UploadHandle> uploads) { for (UploadHandle handle : uploads) { try { URL artifact = handle.getFile().toURI().toURL(); Item item = uploadedArtifacts.addItem(artifact); item.getItemProperty(PROPERTY_SYMBOLIC_NAME).setValue(handle.getFilename()); item.getItemProperty(PROPERTY_VERSION).setValue(""); m_uploadedArtifacts.add(handle.getFile()); } catch (MalformedURLException e) { showErrorNotification("Upload artifact processing failed", "<br />Reason: " + e.getMessage()); logError("Processing of " + handle.getFilename() + " failed.", e); } } } }; final Upload uploadArtifact = new Upload(); uploadArtifact.setCaption("Upload Artifact"); uploadHandler.install(uploadArtifact); final DragAndDropWrapper finalUploadedArtifacts = new DragAndDropWrapper(uploadedArtifacts); finalUploadedArtifacts.setDropHandler(new ArtifactDropHandler(uploadHandler)); addListener(new Window.CloseListener() { public void windowClose(CloseEvent e) { for (File artifact : m_uploadedArtifacts) { artifact.delete(); } } }); HorizontalLayout searchBar = new HorizontalLayout(); searchBar.setMargin(false); searchBar.setSpacing(true); final TextField searchField = new TextField(); searchField.setImmediate(true); searchField.setValue(""); final IndexedContainer dataSource = (IndexedContainer) m_artifactsTable.getContainerDataSource(); m_searchButton = new Button("Search", new ClickListener() { public void buttonClick(ClickEvent event) { String searchValue = (String) searchField.getValue(); dataSource.removeAllContainerFilters(); if (searchValue != null && searchValue.trim().length() > 0) { dataSource.addContainerFilter(PROPERTY_SYMBOLIC_NAME, searchValue, true /* ignoreCase */, false /* onlyMatchPrefix */); } } }); m_searchButton.setImmediate(true); searchBar.addComponent(searchField); searchBar.addComponent(m_searchButton); m_addButton = new Button("Add", new ClickListener() { public void buttonClick(ClickEvent event) { // Import all "local" (existing) bundles... importLocalBundles(m_artifactsTable); // Import all "remote" (non existing) bundles... importRemoteBundles(m_uploadedArtifacts); close(); } }); m_addButton.setImmediate(true); m_addButton.setStyleName(Reindeer.BUTTON_DEFAULT); m_addButton.setClickShortcut(KeyCode.ENTER); VerticalLayout layout = (VerticalLayout) getContent(); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(searchBar); layout.addComponent(m_artifactsTable); layout.addComponent(uploadArtifact); layout.addComponent(finalUploadedArtifacts); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(m_addButton); layout.setComponentAlignment(m_addButton, Alignment.MIDDLE_RIGHT); searchField.focus(); }
From source file:org.apache.ace.webui.vaadin.EditWindow.java
License:Apache License
/** * @param object//from w w w. j a v a2 s . co m * @param factories */ protected void initDialog(final NamedObject object, List<UIExtensionFactory> factories) { VerticalLayout fields = new VerticalLayout(); fields.setSpacing(true); fields.addComponent(m_name); fields.addComponent(m_description); TabSheet tabs = new TabSheet(); tabs.setHeight("350px"); tabs.setWidth("100%"); tabs.setVisible(!factories.isEmpty()); Map<String, Object> context = new HashMap<>(); context.put("object", object); populateContext(context); for (UIExtensionFactory factory : factories) { try { tabs.addTab(factory.create(context)); } catch (Throwable ex) { // We ignore extension factories that throw exceptions // TODO: log this or something ex.printStackTrace(); } } Button okButton = new Button("Ok", new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { onOk((String) m_name.getValue(), (String) m_description.getValue()); close(); } catch (Exception e) { handleError(e); } } }); // Allow enter to be used to close this dialog with enter directly... okButton.setClickShortcut(KeyCode.ENTER); okButton.addStyleName("primary"); Button cancelButton = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); cancelButton.setClickShortcut(KeyCode.ESCAPE); HorizontalLayout buttonBar = new HorizontalLayout(); buttonBar.setSpacing(true); buttonBar.addComponent(okButton); buttonBar.addComponent(cancelButton); VerticalLayout layout = (VerticalLayout) getContent(); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(fields); layout.addComponent(tabs); layout.addComponent(buttonBar); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.setComponentAlignment(buttonBar, Alignment.BOTTOM_RIGHT); m_name.focus(); }
From source file:org.apache.ace.webui.vaadin.GenericAddWindow.java
License:Apache License
/** * Initializes this dialog by placing all components on it. *//* w ww . ja v a2 s .c om*/ protected void initDialog() { VerticalLayout fields = new VerticalLayout(); fields.setSpacing(true); fields.addComponent(m_name); fields.addComponent(m_description); final Button okButton = new Button("Ok", new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { onOk((String) m_name.getValue(), (String) m_description.getValue()); close(); } catch (Exception e) { handleError(e); } } }); okButton.setEnabled(false); // Allow enter to be used to close this dialog with enter directly... okButton.setClickShortcut(KeyCode.ENTER); okButton.addStyleName(Reindeer.BUTTON_DEFAULT); Button cancelButton = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); cancelButton.setClickShortcut(KeyCode.ESCAPE); m_name.addListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { String text = event.getText(); okButton.setEnabled((text != null) && !"".equals(text.trim())); } }); m_name.setTextChangeTimeout(250); m_name.setTextChangeEventMode(TextChangeEventMode.TIMEOUT); HorizontalLayout buttonBar = new HorizontalLayout(); buttonBar.setSpacing(true); buttonBar.addComponent(okButton); buttonBar.addComponent(cancelButton); VerticalLayout layout = (VerticalLayout) getContent(); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(fields); layout.addComponent(buttonBar); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.setComponentAlignment(buttonBar, Alignment.BOTTOM_RIGHT); // Allow direct typing... m_name.focus(); }
From source file:org.apache.ace.webui.vaadin.LoginWindow.java
License:Apache License
/** * Creates a new {@link LoginWindow} instance. * /*from w w w. j a va 2 s .c o m*/ * @param log * the log service to use; * @param loginFunction * the login callback to use. */ public LoginWindow(LogService log, LoginFunction loginFunction) { super("Apache ACE Login"); m_log = log; m_loginFunction = loginFunction; setResizable(false); setClosable(false); setModal(true); setWidth("20em"); m_additionalInfo = new Label(""); m_additionalInfo.setImmediate(true); m_additionalInfo.setStyleName("alert"); m_additionalInfo.setHeight("1.2em"); // Ensures the information message disappears when starting typing... FieldEvents.TextChangeListener changeListener = new FieldEvents.TextChangeListener() { @Override public void textChange(TextChangeEvent event) { m_additionalInfo.setValue(""); } }; final TextField nameField = new TextField("Name", ""); nameField.addListener(changeListener); nameField.setImmediate(true); nameField.setWidth("100%"); final PasswordField passwordField = new PasswordField("Password", ""); passwordField.addListener(changeListener); passwordField.setImmediate(true); passwordField.setWidth("100%"); Button loginButton = new Button("Login"); loginButton.setImmediate(true); // Allow enter to be used to login directly... loginButton.setClickShortcut(KeyCode.ENTER); // Highlight this button as the default one... loginButton.addStyleName(Reindeer.BUTTON_DEFAULT); loginButton.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Button button = event.getButton(); button.setEnabled(false); try { String username = (String) nameField.getValue(); String password = (String) passwordField.getValue(); if (m_loginFunction.login(username, password)) { m_log.log(LogService.LOG_INFO, "Apache Ace WebUI succesfull login by user: " + username); closeWindow(); } else { m_log.log(LogService.LOG_WARNING, "Apache Ace WebUI invalid username or password entered."); m_additionalInfo.setValue("Invalid username or password!"); nameField.focus(); nameField.selectAll(); } } finally { button.setEnabled(true); } } }); final VerticalLayout content = (VerticalLayout) getContent(); content.setSpacing(true); content.setMargin(true); content.setSizeFull(); content.addComponent(nameField); content.addComponent(passwordField); content.addComponent(m_additionalInfo); content.addComponent(loginButton); content.setComponentAlignment(loginButton, Alignment.BOTTOM_CENTER); nameField.focus(); }