List of usage examples for com.vaadin.ui Panel setWidth
@Override public void setWidth(String width)
From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java
private Panel getAllergies() { Panel panel = new Panel(); panel.setCaption("Recent Test Results"); panel.setWidth("80%"); panel.setHeight("100px"); return panel; }
From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java
private Panel getTests() { Panel panel = new Panel(); panel.setCaption("Recent Results"); panel.setWidth("100%"); panel.setHeight("100px"); return panel; }
From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java
private Panel getCarePlan() { Panel panel = new Panel(); panel.setCaption("Care Plan"); panel.setWidth("100%"); panel.setHeight("100px"); return panel; }
From source file:info.magnolia.ui.framework.overlay.OverlayPresenter.java
License:Open Source License
/** * Opens a notification of given {@link MessageStyleType type}, with given body; it can close automatically after a timeout. *//*from ww w .jav a 2s . c o m*/ @Override public void openNotification(final MessageStyleType type, boolean doesTimeout, View viewToShow) { final Notification notification = new Notification(type); notification.setContent(viewToShow.asVaadinComponent()); Panel shortcutPanel = new Panel(); shortcutPanel.setStyleName("shortcut-panel"); shortcutPanel.setWidth(null); shortcutPanel.setContent(notification.asVaadinComponent()); final OverlayCloser closer = openOverlay(new ViewAdapter(shortcutPanel), ModalityLevel.NON_MODAL); final ShortcutListener escapeShortcut = new ShortcutListener("Escape shortcut", ShortcutAction.KeyCode.ESCAPE, null) { @Override public void handleAction(Object sender, Object target) { closer.close(); } }; shortcutPanel.addShortcutListener(escapeShortcut); notification.addCloseButtonListener(new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { closer.close(); } }); notification.addNotificationBodyClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent layoutClickEvent) { closer.setCloseTimeout(-1); } }); if (doesTimeout) { closer.setCloseTimeout(TIMEOUT_SECONDS_DEFAULT); } }
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java
License:Open Source License
public AdminAuthView() { setSizeFull();/*from w w w . ja va2 s . c o m*/ VerticalLayout header = new VerticalLayout(); header.setSizeFull(); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); addComponents(header, content); setExpandRatio(header, 1); setExpandRatio(content, 6); welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>"); welcomeText.setContentMode(ContentMode.HTML); welcomeText.setSizeUndefined(); header.addComponent(welcomeText); header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER); Panel controlPanel = new Panel("Administrator control panel"); controlPanel.setSizeUndefined(); Panel addCoordPanel = new Panel("Create a new coordinator"); addCoordPanel.setSizeUndefined(); Panel messagesPanel = new Panel("Administrator messages"); messagesPanel.setWidth("580px"); Table adminMessagesTable = new Table(); adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource()); adminMessagesTable.setColumnWidth("inputEvent", 180); adminMessagesTable.setSizeFull(); VerticalLayout controlLayout = new VerticalLayout(controlPanel); controlLayout.setSizeFull(); controlLayout.setMargin(false); controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER); VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel); coordOperationsLayout.setSizeFull(); coordOperationsLayout.setMargin(false); coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER); /******************************************/ coordOperationsLayout.setVisible(true); // main layout in the middle addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator" /******************************************/ HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel); VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable); messagesExternalLayout.setSizeFull(); messagesExternalLayout.setMargin(false); messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER); messagesInternalLayout.setMargin(false); messagesInternalLayout.setSizeFull(); messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER); messagesPanel.setContent(messagesInternalLayout); TextField idCoordAdd = new TextField(); TextField loginCoord = new TextField(); PasswordField pwdCoord = new PasswordField(); Label idCaptionAdd = new Label("ID"); Label loginCaption = new Label("Login"); Label pwdCaption = new Label("Password"); idCaptionAdd.setSizeUndefined(); idCoordAdd.setSizeUndefined(); loginCaption.setSizeUndefined(); loginCoord.setSizeUndefined(); pwdCaption.setSizeUndefined(); pwdCoord.setSizeUndefined(); Button validateNewCoord = new Button("Validate"); validateNewCoord.setClickShortcut(KeyCode.ENTER); validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY); GridLayout addCoordinatorLayout = new GridLayout(2, 4); addCoordinatorLayout.setSpacing(true); addCoordinatorLayout.setMargin(true); addCoordinatorLayout.setSizeFull(); addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption, pwdCoord); addCoordinatorLayout.addComponent(validateNewCoord, 1, 3); addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT); addCoordPanel.setContent(addCoordinatorLayout); content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setExpandRatio(controlLayout, 20); content.setExpandRatio(coordOperationsLayout, 10); content.setExpandRatio(messagesExternalLayout, 28); Button addCoordinator = new Button("Add coordinator"); Button deleteCoordinator = new Button("Delete coordinator"); addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE); VerticalLayout buttons = new VerticalLayout(); buttons.setMargin(true); buttons.setSpacing(true); buttons.setSizeFull(); buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); controlPanel.setContent(buttons); buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn); /******* DELETE COORDINATOR PANEL BEGIN *********/ Label idCaptionDel = new Label("ID"); TextField idCoordDel = new TextField(); Panel delCoordPanel = new Panel("Delete a coordinator"); coordOperationsLayout.addComponent(delCoordPanel); delCoordPanel.setVisible(false); coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER); delCoordPanel.setSizeUndefined(); GridLayout delCoordinatorLayout = new GridLayout(2, 2); delCoordinatorLayout.setSpacing(true); delCoordinatorLayout.setMargin(true); delCoordinatorLayout.setSizeFull(); Button deleteCoordBtn = new Button("Delete"); deleteCoordBtn.setClickShortcut(KeyCode.ENTER); deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY); delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel); delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1); delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT); delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT); delCoordPanel.setContent(delCoordinatorLayout); /******* DELETE COORDINATOR PANEL END *********/ /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/ addCoordinator.addClickListener(event -> { if (!addCoordPanel.isVisible()) { delCoordPanel.setVisible(false); addCoordPanel.setVisible(true); idCoordAdd.focus(); } else addCoordPanel.setVisible(false); }); deleteCoordinator.addClickListener(event -> { if (!delCoordPanel.isVisible()) { addCoordPanel.setVisible(false); delCoordPanel.setVisible(true); idCoordDel.focus(); } else delCoordPanel.setVisible(false); }); /************************************************* MAIN BUTTONS LOGIC END *************************************************/ /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/ validateNewCoord.addClickListener(event -> { String currentURL = Page.getCurrent().getLocation().toString(); int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName); String iCrashURL = currentURL.substring(0, strIndexCreator); String googleShebang = "#!"; String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang; try { sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())), new DtLogin(new PtString(loginCoord.getValue())), new DtPassword(new PtString(pwdCoord.getValue()))); // open new browser tab with the newly created coordinator console... // "_blank" instructs the browser to open a new tab instead of a new window... // unhappily not all browsers interpret it correctly, // some versions of some browsers might still open a new window instead (notably Firefox)! Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank"); } catch (Exception e) { e.printStackTrace(); } idCoordAdd.setValue(""); loginCoord.setValue(""); pwdCoord.setValue(""); idCoordAdd.focus(); }); /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/ /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/ deleteCoordBtn.addClickListener(event -> { IcrashSystem sys = IcrashSystem.getInstance(); try { sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue()))); } catch (Exception e) { e.printStackTrace(); } idCoordDel.setValue(""); idCoordDel.focus(); }); /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/ }
From source file:net.antoinecomte.regex.RegExTesterApplication.java
License:Apache License
@Override public void init() { setTheme("chameleon"); final TextField text = new TextField(); final TextField regex = new TextField(); Panel mainPanel = new Panel("Simple Java regular expression tool "); mainPanel.setWidth("460px"); VerticalLayout mainPanelLayout = new VerticalLayout(); mainPanelLayout.setSpacing(true);//w w w .j av a2 s . com mainPanelLayout.setMargin(true); mainPanel.setContent(mainPanelLayout); regex.setCaption("Regular Expression"); regex.setWidth("400px"); regex.addStyleName("big"); regex.setInputPrompt("enter a regular expression here"); regex.setTextChangeEventMode(TextChangeEventMode.TIMEOUT); regex.setImmediate(true); text.setCaption("Test input"); text.setInputPrompt("Enter a test string here"); text.setTextChangeEventMode(TextChangeEventMode.TIMEOUT); text.setImmediate(true); text.setWidth("400px"); text.addStyleName("big"); result.setSizeUndefined(); result.setWidth("460px"); result.setStyleName("light"); result.setVisible(false); regex.addListener(new TextChangeListener() { private static final long serialVersionUID = 7783333579512074097L; @Override public void textChange(TextChangeEvent event) { showResult(event.getText(), text.getValue().toString()); } }); text.addListener(new TextChangeListener() { private static final long serialVersionUID = -2294521048305268959L; @Override public void textChange(TextChangeEvent event) { showResult(regex.getValue().toString(), event.getText()); } }); Window mainWindow = new Window(); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSpacing(true); mainLayout.setMargin(true); mainWindow.setContent(mainLayout); mainWindow.addComponent(mainPanel); mainPanel.addComponent(regex); mainPanel.addComponent(text); mainWindow.addComponent(result); setMainWindow(mainWindow); }
From source file:nl.kpmg.lcm.ui.component.DefinedLabel.java
License:Apache License
public DefinedLabel(String title, String content, String tooltip) { // A layout structure used for composition Panel panel = new Panel(); panel.setStyleName("v-panel-borderless"); panel.setWidth("100%"); VerticalLayout panelContent = new VerticalLayout(); panelContent.setMargin(true); // Very useful panelContent.setWidth("100%"); panel.setContent(panelContent);/*from w w w. j a v a2 s . c o m*/ // Compose from multiple components Label titleLabel = new Label(title); titleLabel.setStyleName("v-label-h4"); panelContent.addComponent(titleLabel); Label contentLabel = new Label(content); panelContent.addComponent(contentLabel); // The composition root MUST be set setCompositionRoot(panel); }
From source file:nz.co.senanque.vaadinsupport.viewmanager.HelpLayout.java
License:Apache License
public void afterPropertiesSet() throws Exception { setSizeFull();// w ww. j av a 2s.c om Panel panel = new Panel(); panel.setWidth("50%"); panel.addComponent(new Label(getI18nHTML(), Label.CONTENT_XHTML)); addComponent(panel); setComponentAlignment(panel, Alignment.MIDDLE_CENTER); m_OKButton = new Button("OK"); panel.addComponent(m_OKButton); m_OKButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1904763239654990140L; public void buttonClick(ClickEvent event) { getViewManager().popScreen(); getViewManager().getMainWindow().requestRepaint(); } }); }
From source file:nz.co.senanque.vaadinsupport.viewmanager.LoginLayout.java
License:Apache License
public void afterPropertiesSet() throws Exception { setSizeFull();//from www .j a va 2s . c o m Panel loginPanel = new Panel(); AbstractLayout panelLayout = (AbstractLayout) loginPanel.getContent(); panelLayout.setMargin(false); loginPanel.setWidth("460px"); final MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); final LoginForm loginForm = new LoginFormI18n(messageSourceAccessor.getMessage("username"), messageSourceAccessor.getMessage("password"), messageSourceAccessor.getMessage("login.button"), messageSourceAccessor.getMessage("welcome")); loginForm.setHeight("300px"); loginForm.addListener(new LoginListener() { private static final long serialVersionUID = 5201900702970450254L; public void onLogin(LoginEvent event) { if (getLoginListener() != null) { try { getLoginListener().onLogin(event); } catch (Exception e) { Throwable cause = e.getCause(); if (cause == null || !(cause instanceof LoginException)) { logger.error(e.getMessage(), e); } String message = messageSourceAccessor.getMessage("Bad.Login", "Bad Login"); getViewManager().getMainWindow().showNotification(message, Notification.TYPE_ERROR_MESSAGE); return; } } getViewManager().loadApplication(); } }); loginPanel.addComponent(loginForm); addComponent(loginPanel); setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); }
From source file:org.bitpimp.VaadinCurrencyConverter.MyVaadinApplication.java
License:Apache License
@Override protected void init(VaadinRequest request) { // Set the window or tab title getPage().setTitle("Yahoo Currency Converter"); // Create the content root layout for the UI final FormLayout content = new FormLayout(); content.setMargin(true);/*from ww w .j a v a2 s. c om*/ final Panel panel = new Panel(content); panel.setWidth("500"); panel.setHeight("400"); final VerticalLayout root = new VerticalLayout(); root.addComponent(panel); root.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); root.setSizeFull(); root.setMargin(true); setContent(root); content.addComponent(new Embedded("", new ExternalResource("https://vaadin.com/vaadin-theme/images/vaadin/vaadin-logo-color.png"))); content.addComponent(new Embedded("", new ExternalResource("http://images.wikia.com/logopedia/images/e/e4/YahooFinanceLogo.png"))); // Display the greeting final Label heading = new Label("<b>Simple Currency Converter " + "Using YQL/Yahoo Finance Service</b>", ContentMode.HTML); heading.setWidth(null); content.addComponent(heading); // Build the set of fields for the converter form final TextField fromField = new TextField("From Currency", "AUD"); fromField.setRequired(true); fromField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false)); content.addComponent(fromField); final TextField toField = new TextField("To Currency", "USD"); toField.setRequired(true); toField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false)); content.addComponent(toField); final TextField resultField = new TextField("Result"); resultField.setEnabled(false); content.addComponent(resultField); final TextField timeField = new TextField("Time"); timeField.setEnabled(false); content.addComponent(timeField); final Button submitButton = new Button("Submit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { // Do the conversion final String result = converter.convert(fromField.getValue().toUpperCase(), toField.getValue().toUpperCase()); if (result != null) { resultField.setValue(result); timeField.setValue(new Date().toString()); } } }); content.addComponent(submitButton); // Configure the error handler for the UI UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { // Find the final cause String cause = "<b>The operation failed :</b><br/>"; Throwable th = Throwables.getRootCause(event.getThrowable()); if (th != null) cause += th.getClass().getName() + "<br/>"; // Display the error message in a custom fashion content.addComponent(new Label(cause, ContentMode.HTML)); // Do the default error handling (optional) doDefault(event); } }); }