Example usage for com.vaadin.ui HorizontalLayout addComponent

List of usage examples for com.vaadin.ui HorizontalLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.openhris.payroll.contributions.TaxUI.java

public TaxUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();//from   w  w w .  j  a  va  2  s . c om
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

    HorizontalLayout h = new HorizontalLayout();
    h.setWidth("100%");
    h.setMargin(true);
    h.setSpacing(true);

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE WITHHOLDING TAX");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            taxTable.setContainerDataSource(new TaxDataContainer(corporateId,
                    util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()))));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(taxTable, "TAX Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " TAX Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-TAX-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(taxTable);
    setExpandRatio(taxTable, 2);
}

From source file:com.peergreen.example.webconsole.extensions.ConfirmDialogExtension.java

License:Open Source License

public ConfirmDialogExtension() {
    setSizeFull();//from w  w  w . j a v a2s  .  c o  m
    setSpacing(true);
    setMargin(true);

    Link showCodeSource = new Link("Show code source",
            new ExternalResource(GitHubClassURL.getURL(ConfirmDialogExtension.class)));
    showCodeSource.setTargetName("_blank");
    addComponent(showCodeSource);
    setComponentAlignment(showCodeSource, Alignment.TOP_RIGHT);

    Label title = new Label("Drag and drop components from a panel to another");
    title.addStyleName("h1");
    addComponent(title);
    setComponentAlignment(title, Alignment.MIDDLE_CENTER);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setSpacing(true);
    row.setMargin(true);

    VerticalLayout leftPanel = new VerticalLayout();
    leftPanel.setSpacing(true);
    leftPanel.addStyleName("dashed-area");
    leftPanel.addComponent(getDraggableComponent(new Label("Label")));
    leftPanel.addComponent(getDraggableComponent(new Button("Button")));
    DragAndDropWrapper leftPanelWrapper = new DragAndDropWrapper(leftPanel);
    row.addComponent(leftPanelWrapper);
    row.setComponentAlignment(leftPanelWrapper, Alignment.TOP_LEFT);

    VerticalLayout rightPanel = new VerticalLayout();
    rightPanel.setSpacing(true);
    rightPanel.addStyleName("dashed-area");
    DragAndDropWrapper rightPanelWrapper = new DragAndDropWrapper(rightPanel);
    row.addComponent(rightPanelWrapper);
    row.setComponentAlignment(rightPanelWrapper, Alignment.TOP_RIGHT);

    leftPanelWrapper.setDropHandler(new ConfirmDialogExtensionDropHandler(rightPanel, leftPanel));
    rightPanelWrapper.setDropHandler(new ConfirmDialogExtensionDropHandler(leftPanel, rightPanel));

    addComponent(row);
    setExpandRatio(row, 1.5f);
}

From source file:com.peergreen.example.webconsole.extensions.NavigatorExtension.java

License:Open Source License

@PostConstruct
public void init() {
    Label guide = new Label(
            "The path of a navigable extension is the path of its parent concatenated with the string "
                    + "inside the class annotation @Navigable(\"alias\")");
    guide.addStyleName("h2");
    addComponent(guide);/*from   ww w .  ja  va2 s. c  o m*/

    HorizontalLayout row = new HorizontalLayout();
    row.setSpacing(true);
    row.setMargin(true);
    row.setCaption("Type the alias of an extension you want to navigate to");
    final ComboBox comboBox = new ComboBox();
    comboBox.setWidth("400px");
    comboBox.setNullSelectionAllowed(false);
    comboBox.addItem("/example/simple");
    comboBox.addItem("/example/notifier");
    comboBox.addItem("/example/window");
    comboBox.addItem("/example/confirm");
    row.addComponent(comboBox);
    Button navigate = new Button("Navigate");
    navigate.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (comboBox.getValue() != null && !"".equals(comboBox.getValue())) {
                uiContext.getViewNavigator().navigateTo(comboBox.getValue().toString());
            }
        }
    });
    row.addComponent(navigate);
    addComponent(row);
    setExpandRatio(row, 1.5f);
}

From source file:com.peergreen.example.webconsole.extensions.NotifierExtension.java

License:Open Source License

@PostConstruct
public void init() {
    HorizontalLayout row = new HorizontalLayout();
    row.setWidth("100%");
    Button simpleButton = new Button("Click to create a notification !");
    final Random random = new Random();
    simpleButton.addClickListener(new Button.ClickListener() {
        @Override//from ww  w.  j  a va2 s  . c  o  m
        public void buttonClick(Button.ClickEvent clickEvent) {
            notifierService.addNotification(MESSAGES[random.nextInt(MESSAGES.length)]);
        }
    });
    simpleButton.setWidth("400px");
    row.addComponent(simpleButton);
    row.setComponentAlignment(simpleButton, Alignment.BOTTOM_LEFT);

    final TextField customNotification = new TextField();
    customNotification.setCaption("Write something and type enter");
    final ShortcutListener addNotification = new ShortcutListener("Execute", ShortcutAction.KeyCode.ENTER,
            null) {
        @Override
        public void handleAction(Object o, Object o2) {
            notifierService.addNotification(customNotification.getValue());
            customNotification.setValue("");
        }
    };
    customNotification.addFocusListener(new FieldEvents.FocusListener() {
        @Override
        public void focus(FieldEvents.FocusEvent focusEvent) {
            customNotification.addShortcutListener(addNotification);
        }
    });
    customNotification.addBlurListener(new FieldEvents.BlurListener() {
        @Override
        public void blur(FieldEvents.BlurEvent blurEvent) {
            customNotification.removeShortcutListener(addNotification);
        }
    });
    customNotification.setWidth("400px");
    row.addComponent(customNotification);
    addComponent(row);
    setExpandRatio(row, 1.5f);
}

From source file:com.peergreen.webconsole.core.exception.ExceptionView.java

License:Open Source License

public ExceptionView(Exception ex) {

    setSizeFull();/*from w ww.java  2 s.  co  m*/
    addStyleName("dashboard-view");

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    top.addStyleName("toolbar");
    addComponent(top);
    final Label title = new Label("Oops ! A problem occurred when drawing this view");
    title.setSizeUndefined();
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setMargin(new MarginInfo(true, true, false, true));
    row.setSpacing(true);
    addComponent(row);
    setExpandRatio(row, 1.5f);

    Table t = new Table();
    t.setCaption("Stack trace");
    t.addContainerProperty("<p style=\"display:none\">Stack</p>", String.class, null);
    t.setWidth("100%");
    t.setImmediate(true);
    t.addStyleName("plain");
    t.addStyleName("borderless");
    t.setSortEnabled(false);
    t.setImmediate(true);
    t.setSizeFull();

    int i = 1;
    t.addItem(new Object[] { ex.toString() }, i++);
    for (StackTraceElement element : ex.getStackTrace()) {
        t.addItem(new Object[] { element.toString() }, i++);
    }
    CssLayout panel = new CssLayout();
    panel.addStyleName("layout-panel");
    panel.setSizeFull();

    panel.addComponent(t);

    row.addComponent(panel);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build login view/*from   w w  w  .  ja  va 2s.  c  o  m*/
 *
 * @param exit
 */
private void buildLoginView(final boolean exit) {
    if (exit) {
        root.removeAllComponents();
    }
    notifierService.closeAll();

    addStyleName("login");

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setId("webconsole_loginlayout_id");
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login-layout");
    root.addComponent(loginLayout);

    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    loginPanel.addComponent(labels);

    Label welcome = new Label("Welcome");
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    //title.setSizeUndefined();
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.focus();
    username.setId("webconsole_login_username");
    fields.addComponent(username);

    final PasswordField password = new PasswordField("Password");
    password.setId("webconsole_login_password");
    fields.addComponent(password);

    final Button signin = new Button("Sign In");
    signin.setId("webconsole_login_signin");
    signin.addStyleName("default");
    fields.addComponent(signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            signin.click();
        }
    };

    signin.addShortcutListener(enter);
    loginPanel.addComponent(fields);

    HorizontalLayout bottomRow = new HorizontalLayout();
    bottomRow.setWidth(MAX_WIDTH);
    bottomRow.setMargin(new MarginInfo(false, true, false, true));
    final CheckBox keepLoggedIn = new CheckBox("Keep me logged in");
    bottomRow.addComponent(keepLoggedIn);
    bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT);
    // Add new error message
    final Label error = new Label("Wrong username or password.", ContentMode.HTML);
    error.setId("webconsole_login_error");
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    // Add animation
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    bottomRow.addComponent(error);
    bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT);
    loginPanel.addComponent(bottomRow);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (authenticate(username.getValue(), password.getValue())) {
                //                    if (keepLoggedIn.getValue()) {
                //                        //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
                //                       if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) {
                //                            // Get a token for this user and create a cooki
                //                            Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'",
                //                                    PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath()));
                //                        } else {
                //                            // update token
                //                            userCookie.setValue(token);
                //                            userCookie.setPath(VaadinService.getCurrentRequest().getContextPath());
                //                        }
                //                    }

                buildMainView();
            } else {
                error.setVisible(true);
            }
        }
    });

    loginLayout.addComponent(loginPanel);
    loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build Welcome progress indicator view
 *//*from w  w  w .j  a  v a 2  s. c om*/
private void buildProgressIndicatorView() {

    final CssLayout progressPanel = new CssLayout();
    progressPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    progressPanel.addComponent(labels);

    Label welcome = new Label("Welcome " + ((securityManager == null) ? "" : securityManager.getUserName()));
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    Float scopesViewsBound = (float) scopes.size();
    final Float stopValue = new Float(1.0);

    if (scopesFactories.isEmpty()) {
        progressIndicator.setValue(stopValue);
    } else {
        progressIndicator.setValue(scopesViewsBound / nbScopesToBind);
    }

    if (stopValue.equals(progressIndicator.getValue())) {
        showMainContent();
    } else {
        // We are still waiting for scopes we have requested their creation, wait a while.
        TimeOutThread timeOutThread = new TimeOutThread();
        timeOutThread.start();
        progressIndicator.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                if (stopValue.equals(event.getProperty().getValue())) {
                    showMainContent();
                }
            }
        });
    }

    HorizontalLayout progressBarPanel = new HorizontalLayout();
    progressBarPanel.setWidth(MAX_WIDTH);
    progressBarPanel.setMargin(true);
    progressBarPanel.addComponent(progressIndicator);
    progressBarPanel.setComponentAlignment(progressIndicator, Alignment.MIDDLE_CENTER);
    progressPanel.addComponent(progressBarPanel);

    progressIndicatorLayout.addComponent(progressPanel);
    progressIndicatorLayout.setComponentAlignment(progressPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.all.AllView.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();/*www  . jav a  2s.com*/
    setSpacing(true);
    setMargin(true);

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    final TextField filter = new TextField();
    filter.setInputPrompt("Type artifact name or maven dependency");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(AbstractDeployableContainer.DEPLOYABLE_NAME,
            directoryContainer.getContainer(), mavenContainer.getContainer()));
    header.addComponent(filter);
    header.setComponentAlignment(filter, Alignment.TOP_LEFT);
    header.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.DEPLOY);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    TreeTable directoryTable = createDeployableTable(AbstractDeployableContainer.DEPLOYABLE_NAME,
            DIRECTORY_ITEM_ID, directoryContainer.getContainer());
    TreeTable mavenTable = createDeployableTable(AbstractDeployableContainer.DEPLOYABLE_NAME, MAVEN_ITEM_ID,
            mavenContainer.getContainer());
    //mavenTable.addExpandListener(new TreeItemExpandListener(this, mavenRepositoryService));

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, directoryTable, actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    header.addComponent(actionArea);
    header.setExpandRatio(actionArea, 2);
    header.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    addComponent(header);

    addComponent(directoryTable);
    setExpandRatio(directoryTable, 1.5f);
    addComponent(mavenTable);
    setExpandRatio(mavenTable, 1.5f);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.DeployablePanel.java

License:Open Source License

@PostConstruct
public void init() {

    setSizeFull();//from  w w  w.j av  a2s.  co  m

    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setSpacing(true);
    mainContent.setMargin(true);
    mainContent.setStyleName("deployable-style");
    mainContent.setSizeFull();

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    Button openManager = new Button("Edit repositories");
    openManager.addStyleName("link");
    openManager.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (tabSheet.getTab(manager) == null) {
                tabSheet.addTab(manager, "Manager",
                        new ClassResource(getClass(), "/images/22x22/configuration.png"), containers.size())
                        .setClosable(true);
            }
            tabSheet.setSelectedTab(manager);
        }
    });
    header.addComponent(openManager);
    header.setComponentAlignment(openManager, Alignment.MIDDLE_RIGHT);
    mainContent.addComponent(header);

    tabSheet.setSizeFull();
    mainContent.addComponent(tabSheet);
    mainContent.setExpandRatio(tabSheet, 1.5f);

    DragAndDropWrapper mainContentWrapper = new DragAndDropWrapper(mainContent);
    mainContentWrapper.setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService));
    mainContentWrapper.setSizeFull();

    setContent(mainContentWrapper);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.directory.DirectoryView.java

License:Open Source License

@PostConstruct
public void init() {
    File deploy = new File(System.getProperty("user.dir") + File.separator + "deploy");
    repositoryManager.addRepository(formatUrl(deploy), "Deploy", RepositoryType.DIRECTORY);

    File m2 = new File(
            System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository");
    if (m2.exists()) {
        repositoryManager.addRepository(formatUrl(m2), "Local M2 repository", RepositoryType.DIRECTORY);
    }//w ww .  ja  v  a2s .c  om

    File tmp = new File(Constants.STORAGE_DIRECTORY);
    if (!tmp.exists()) {
        tmp.mkdirs();
    }
    repositoryManager.addRepository(formatUrl(tmp), "Temporary directory", RepositoryType.DIRECTORY);

    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    final TextField filter = new TextField();
    filter.setInputPrompt("Filter deployable files");
    filter.setWidth("100%");
    filter.addTextChangeListener(new FilterFiles(DEPLOYABLE_NAME, getContainer()));
    header.addComponent(filter);
    header.setComponentAlignment(filter, Alignment.TOP_LEFT);
    header.setExpandRatio(filter, 3);

    HorizontalLayout actionArea = new HorizontalLayout();
    final NativeSelect actionSelection = new NativeSelect();
    actionSelection.addItem(DeploymentActions.DEPLOY);
    actionSelection.addItem(DeploymentActions.DELETE);
    actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN);
    actionSelection.setWidth("100px");
    actionSelection.setNullSelectionAllowed(false);

    Button doButton = new Button("Do");
    doButton.addStyleName("default");
    doButton.addClickListener(
            new DoClickListener(artifactBuilder, getTree(), actionSelection, deploymentViewManager));

    actionArea.addComponent(actionSelection);
    actionArea.addComponent(doButton);
    header.addComponent(actionArea);
    header.setExpandRatio(actionArea, 2);
    header.setComponentAlignment(actionArea, Alignment.TOP_RIGHT);
    addComponent(header);

    HorizontalLayout repositoryInfo = new HorizontalLayout();
    repositoryInfo.setWidth("100%");
    repositoryInfo.addComponent(getFetching());
    repositoryInfo.setComponentAlignment(getFetching(), Alignment.MIDDLE_LEFT);
    addComponent(repositoryInfo);

    getTree().addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, getTree(), "Delete",
            ShortcutAction.KeyCode.DELETE, null));
    getTree().addExpandListener(new TreeItemExpandListener(this, getRepositoryService(), repositoryManager));

    addComponent(getTree());
    setExpandRatio(getTree(), 1.5f);
}