Example usage for com.vaadin.ui GridLayout setHeight

List of usage examples for com.vaadin.ui GridLayout setHeight

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setHeight.

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

From source file:com.cerebro.provevaadin.Equipment.java

public Equipment() {
    GridLayout contentSx = new GridLayout(15, 18);
    contentSx.setId("equip_body");
    contentSx.setHeight("600px");
    contentSx.setWidth("300px");

    FileResource helmetFile = new FileResource(new File(basepath + "red.png"));
    Image helmet = new Image("Helmet", helmetFile);
    helmet.setHeight("100px");
    contentSx.addComponent(helmet, 8, 0);

    sinistra.setContent(contentSx);/*from  ww w . ja va 2  s  . co m*/
    //        root.setWidth("300px");
    //        root.setHeight("600px");
    //        
    //        FileResource bodyMaleFile = new FileResource(new File(basepath + "body-male.jpg"));
    //        FileResource helmetFile = new FileResource(new File(basepath + "red.png"));
    //        
    //        Image image = new Image("MaleBody", bodyMaleFile);
    //        image.setWidth(root.getWidth(), root.getWidthUnits());
    //        Image helmet = new Image("Helmet", helmetFile);
    //        helmet.setHeight("100px");
    //        
    //        root.addComponent(image, "left: 0px; top: 0px;");
    //        root.addComponent(helmet, "left: 50%; top: 100px");
    //        
    //        sinistra.setContent(root);
    //        
    //        
    //        destra.setContent(rootDx);
    //        
    this.addComponents(sinistra, destra);
}

From source file:com.cms.utils.CommonUtils.java

public static void setBasicAttributeLayout(GridLayout gridLayout, String caption, boolean isCollapseable) {
    gridLayout.setWidth("100%");
    gridLayout.setHeight("-1px");
    gridLayout.setImmediate(true);//  ww  w.  jav a 2 s. co m
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    if (isCollapseable && !DataUtil.isStringNullOrEmpty(caption)) {
        gridLayout.setStyleName("custom-feildset");
        gridLayout.setCaption(MakeURL.makeURLForGrid(caption));
        gridLayout.setCaptionAsHtml(isCollapseable);
    }
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.DayWidget.java

public DayWidget() {

    //Creating Panel
    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setWidth("876px");
    iPanel.setHeight("41px");

    ProgressBar iDayProgressBar = new ProgressBar();
    iDayProgressBar.setCaption("Period 3, 10th October");
    iDayProgressBar.setWidth("875px");
    iDayProgressBar.setValue(0.3f);//from w  ww  .ja  v a2s.c om
    addComponent(iDayProgressBar);

    //Adding Panel to Vertical Layout
    addComponent(iPanel);
    VerticalLayout iVerticalLayout = new VerticalLayout();

    GridLayout iGridLayout = new GridLayout(9, 1);
    iGridLayout.setWidth("1000px");
    iGridLayout.setHeight("40px");

    for (int i = 1; i <= 8; i++) {

        HourWidget iHourAtAGlanceWidget = new HourWidget(i, 8);
        iHourAtAGlanceWidget.setSizeFull();
        iGridLayout.addComponent(iHourAtAGlanceWidget);
        iGridLayout.setColumnExpandRatio(i, 1);
    }

    iVerticalLayout.addComponent(iGridLayout);
    iPanel.setContent(iVerticalLayout);

}

From source file:com.openhris.employee.allowance.EmployeeAllowanceInformation.java

ComponentContainer component() {
    GridLayout glayout = new GridLayout(3, 14);
    glayout.setSpacing(true);/*from w  w  w . j a  va  2s .c o m*/
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    communication = new TextField("Communication Allowance: ");
    communication.setWidth("170px");
    communication.addStyleName("numerical");
    glayout.addComponent(communication, 0, 0);

    communicationEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    communicationEntry.setWidth("150px");
    glayout.addComponent(communicationEntry, 1, 0);

    Button communicationBtn = new Button("UPDATE COMMUNICATION ALLOWANCE");
    communicationBtn.setWidth("250px");
    communicationBtn.addListener(buttonClickListener);
    glayout.addComponent(communicationBtn, 2, 0);
    glayout.setComponentAlignment(communicationBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        communicationBtn.setEnabled(true);
    } else {
        communicationBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 1, 2, 1);

    perDiem = new TextField("Per Diem: ");
    perDiem.setWidth("170px");
    perDiem.addStyleName("numerical");
    glayout.addComponent(perDiem, 0, 2);

    perDiemEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    perDiemEntry.setWidth("150px");
    glayout.addComponent(perDiemEntry, 1, 2);

    Button perDiemBtn = new Button("UPDATE PER DIEM");
    perDiemBtn.setWidth("250px");
    perDiemBtn.addListener(buttonClickListener);
    glayout.addComponent(perDiemBtn, 2, 2);
    glayout.setComponentAlignment(perDiemBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        perDiemBtn.setEnabled(true);
    } else {
        perDiemBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 3, 2, 3);

    cola = new TextField("Cola: ");
    cola.setWidth("170px");
    cola.addStyleName("numerical");
    glayout.addComponent(cola, 0, 4);

    colaEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    colaEntry.setWidth("150px");
    glayout.addComponent(colaEntry, 1, 4);

    Button colaBtn = new Button("UPDATE COLA");
    colaBtn.setWidth("250px");
    colaBtn.addListener(buttonClickListener);
    glayout.addComponent(colaBtn, 2, 4);
    glayout.setComponentAlignment(colaBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        colaBtn.setEnabled(true);
    } else {
        colaBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 5, 2, 5);

    meal = new TextField("Meal Allowance: ");
    meal.setWidth("170px");
    meal.addStyleName("numerical");
    glayout.addComponent(meal, 0, 6);

    mealEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    mealEntry.setWidth("150px");
    glayout.addComponent(mealEntry, 1, 6);

    Button mealBtn = new Button("UPDATE MEAL ALLOWANCE");
    mealBtn.setWidth("250px");
    mealBtn.addListener(buttonClickListener);
    glayout.addComponent(mealBtn, 2, 6);
    glayout.setComponentAlignment(mealBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        mealBtn.setEnabled(true);
    } else {
        mealBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 7, 2, 7);

    transportation = new TextField("Transportation Allowance: ");
    transportation.setWidth("170px");
    transportation.addStyleName("numerical");
    glayout.addComponent(transportation, 0, 8);

    transportationEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    transportationEntry.setWidth("150px");
    glayout.addComponent(transportationEntry, 1, 8);

    Button transportationBtn = new Button("UPDATE TRANSPORTATION ALLOWANCE");
    transportationBtn.setWidth("250px");
    transportationBtn.addListener(buttonClickListener);
    glayout.addComponent(transportationBtn, 2, 8);
    glayout.setComponentAlignment(transportationBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        transportationBtn.setEnabled(true);
    } else {
        transportationBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 9, 2, 9);

    others = new TextField("Other Allowances: ");
    others.setWidth("170px");
    others.addStyleName("numerical");
    glayout.addComponent(others, 0, 10);

    othersEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    othersEntry.setWidth("150px");
    glayout.addComponent(othersEntry, 1, 10);

    Button othersBtn = new Button("UPDATE OTHER ALLOWANCES");
    othersBtn.setWidth("250px");
    othersBtn.addListener(buttonClickListener);
    glayout.addComponent(othersBtn, 2, 10);
    glayout.setComponentAlignment(othersBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        othersBtn.setEnabled(true);
    } else {
        othersBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 11, 2, 11);

    afl = new TextField("Allowance for Liquidation: ");
    afl.setWidth("170px");
    afl.addStyleName("numerical");
    glayout.addComponent(afl, 0, 12);

    Button aflBtn = new Button("UPDATE AFL");
    aflBtn.setWidth("100%");
    aflBtn.addListener(buttonClickListener);
    glayout.addComponent(aflBtn, 1, 12, 2, 12);
    glayout.setComponentAlignment(aflBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        aflBtn.setEnabled(true);
    } else {
        aflBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        Allowances a = ais.getAllowancesByEmployee(getEmployeeId());

        communication.setValue(a.getCommunication());
        communicationEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getComEntryType()));

        perDiem.setValue(a.getPerDiem());
        perDiemEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getPerDiemEntryType()));

        cola.setValue(a.getCola());
        colaEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getColaEntryType()));

        meal.setValue(a.getMeal());
        mealEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getMealEntryType()));

        transportation.setValue(a.getTransportation());
        transportationEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getTransEntryType()));

        others.setValue(a.getOthers());
        othersEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getOthersEntryType()));

        afl.setValue(a.getAllowanceForLiquidation());
    }

    return glayout;
}

From source file:com.openhris.employee.others.OtherInformation.java

Component component() {
    GridLayout glayout = new GridLayout(2, 13);
    glayout.setSpacing(true);/*w  ww .  j  a v a 2s.  c o  m*/
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    tinField = new HRISTextField("TIN: ");
    glayout.addComponent(tinField, 0, 0);

    Button tinBtn = new Button("UPDATE TIN NO.");
    tinBtn.setWidth("100%");
    tinBtn.addListener(buttonClickListener);
    glayout.addComponent(tinBtn, 1, 0);
    glayout.setComponentAlignment(tinBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        tinBtn.setEnabled(true);
    } else {
        tinBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 1, 1, 1);

    employeeDependent = dropDown.populateTotalDependent("Employee's Dependent");
    employeeDependent.setWidth("100%");
    glayout.addComponent(employeeDependent, 0, 2);

    Button edBtn = new Button("UPDATE EMPLOYEE's DEPENDENT");
    edBtn.setWidth("100%");
    edBtn.addListener(buttonClickListener);
    glayout.addComponent(edBtn, 1, 2);
    glayout.setComponentAlignment(edBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        edBtn.setEnabled(true);
    } else {
        edBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 3, 1, 3);

    sssField = new HRISTextField("SSS: ");
    glayout.addComponent(sssField, 0, 4);

    Button sssbtn = new Button("UPDATE SSS NO.");
    sssbtn.setWidth("100%");
    sssbtn.addListener(buttonClickListener);
    glayout.addComponent(sssbtn, 1, 4);
    glayout.setComponentAlignment(sssbtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        sssbtn.setEnabled(true);
    } else {
        sssbtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 5, 1, 5);

    phicField = new HRISTextField("Philhealth");
    glayout.addComponent(phicField, 0, 6);

    Button phicBtn = new Button("UPDATE PHIC NO.");
    phicBtn.setWidth("100%");
    phicBtn.addListener(buttonClickListener);
    glayout.addComponent(phicBtn, 1, 6);
    glayout.setComponentAlignment(phicBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        phicBtn.setEnabled(true);
    } else {
        phicBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 7, 1, 7);

    hdmfField = new HRISTextField("HDMF: ");
    glayout.addComponent(hdmfField, 0, 8);

    Button hdmfBtn = new Button("UPDATE HDMF NO.");
    hdmfBtn.setWidth("100%");
    hdmfBtn.addListener(buttonClickListener);
    glayout.addComponent(hdmfBtn, 1, 8);
    glayout.setComponentAlignment(hdmfBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        hdmfBtn.setEnabled(true);
    } else {
        hdmfBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 9, 1, 9);

    bankAccountNo = new HRISTextField("Bank Account No: ");
    bankAccountNo.setImmediate(true);
    glayout.addComponent(bankAccountNo, 0, 10);

    Button bankAccountBtn = new Button("UPDATE BANK NO.");
    bankAccountBtn.setWidth("100%");
    bankAccountBtn.addListener(buttonClickListener);
    glayout.addComponent(bankAccountBtn, 1, 10);
    glayout.setComponentAlignment(bankAccountBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        bankAccountBtn.setEnabled(true);
    } else {
        bankAccountBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        EmploymentInformation ei = si.getEmployeeSalaryInformation(getEmployeeId());

        tinField.setValue(ei.getTinNo());
        sssField.setValue(ei.getSssNo());
        phicField.setValue(ei.getPhicNo());
        hdmfField.setValue(ei.gethdmfNo());
        bankAccountNo.setValue(ei.getBankAccountNo());
        employeeDependent
                .setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_DEPENDENT, ei.getTotalDependent()));
    }

    return glayout;
}

From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java

public ComponentContainer layout() {
    GridLayout glayout = new GridLayout(2, 8);
    glayout.setSpacing(true);//  w  w w.ja va  2 s.c o  m
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    employmentStatus = dropDown.populateEmploymentStatus("Employment Status: ");
    employmentStatus.setWidth("200px");
    glayout.addComponent(employmentStatus, 0, 0);

    Button esBtn = new Button("UPDATE EMPLOYMENT STATUS");
    esBtn.setWidth("100%");
    glayout.addComponent(esBtn, 1, 0);
    esBtn.addListener(buttonClickListener);
    glayout.setColumnExpandRatio(1, 1);
    glayout.setComponentAlignment(esBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        esBtn.setEnabled(true);
    } else {
        esBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 2, 1, 2);

    employmentWageStatus = dropDown.populateEmploymentWageStatus("Employment Wage Status: ");
    employmentWageStatus.setWidth("200px");
    glayout.addComponent(employmentWageStatus, 0, 3);

    Button ewsBtn = new Button("UPDATE EMPLOYMENT WAGE STATUS");
    ewsBtn.setWidth("100%");
    ewsBtn.addListener(buttonClickListener);
    glayout.addComponent(ewsBtn, 1, 3);
    glayout.setComponentAlignment(ewsBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        ewsBtn.setEnabled(true);
    } else {
        ewsBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 4, 1, 4);

    employmentWageEntry = dropDown.populateEmploymentWageEntry("Employment Wage Entry: ");
    employmentWageEntry.setWidth("200px");
    glayout.addComponent(employmentWageEntry, 0, 5);

    Button eweBtn = new Button("UPDATE EMPLOYMENT WAGE ENTRY");
    eweBtn.setWidth("100%");
    glayout.addComponent(eweBtn, 1, 5);
    eweBtn.addListener(buttonClickListener);
    glayout.setComponentAlignment(eweBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        eweBtn.setEnabled(true);
    } else {
        eweBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 6, 1, 6);

    employmentWage = new TextField("Employment Wage");
    employmentWage.setWidth("200px");
    employmentWage.addStyleName("numerical");
    glayout.addComponent(employmentWage, 0, 7);

    Button ewBtn = new Button("UPDATE EMPLOYMENT WAGE");
    ewBtn.setWidth("100%");
    glayout.addComponent(ewBtn, 1, 7);
    ewBtn.addListener(buttonClickListener);
    glayout.setComponentAlignment(ewBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        ewBtn.setEnabled(true);
    } else {
        ewBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        EmploymentInformation ei = si.getEmployeeSalaryInformation(getEmployeeId());

        employmentStatus.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_STATUS, ei.getEmploymentStatus()));
        employmentWageStatus.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_WAGE_STATUS,
                ei.getEmploymentWageStatus()));
        employmentWageEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_WAGE_ENTRY,
                ei.getEmploymentWageEntry()));
        employmentWage.setValue(ei.getEmploymentWage());
    }

    return glayout;
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component. Useful for buttons.
 * /*  w  w  w .  j  ava 2  s .c om*/
 * @param comp
 *            The component to display.
 * @return The component in an grid layout. A blank in front and afterwards is inserted.
 */
public static synchronized GridLayout create(final Component comp) {
    final GridLayout hor = new GridLayout(3, 1);
    hor.setHeight(Constants.DEFAULT_HEIGHT);
    hor.addComponent(new Label(" "), 0, 0);
    hor.addComponent(comp, 1, 0);
    hor.setComponentAlignment(comp, Alignment.MIDDLE_RIGHT);
    hor.addComponent(new Label(" "), 2, 0);
    hor.setSpacing(false);
    return hor;
}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

public FHIRChart() {
    session = ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes();
    setCaption("TriCare Portal");
    //final VerticalComponentGroup vert = new VerticalComponentGroup();
    GridLayout layout = new GridLayout(3, 2);
    layout.setMargin(true);// www. ja  va 2  s .c  om
    layout.setWidth("80%");
    layout.setHeight("100%");

    Panel problemListPanel = getProblemList();
    Panel medicationPanel = getMedications();
    Panel encountersPanel = getEncounters();
    Panel allergiesPanel = getAllergies();
    Panel testsPanel = getTests();
    Panel carePanel = getCarePlan();

    layout.addComponent(problemListPanel, 0, 0);
    layout.setComponentAlignment(problemListPanel, Alignment.TOP_LEFT);
    layout.addComponent(medicationPanel, 1, 0);
    layout.setComponentAlignment(medicationPanel, Alignment.TOP_LEFT);
    layout.addComponent(encountersPanel, 2, 0);
    layout.setComponentAlignment(encountersPanel, Alignment.TOP_LEFT);
    layout.addComponent(allergiesPanel, 0, 1);
    layout.setComponentAlignment(allergiesPanel, Alignment.TOP_LEFT);
    layout.addComponent(testsPanel, 1, 1);
    layout.setComponentAlignment(testsPanel, Alignment.TOP_LEFT);
    layout.addComponent(carePanel, 2, 1);
    layout.setComponentAlignment(carePanel, Alignment.TOP_LEFT);

    //vert.addComponent(layout);

    setContent(new CssLayout(layout));

}

From source file:org.accelerators.activiti.admin.ui.MainView.java

License:Open Source License

public MainView(AdminApp application) {

    // Set application
    this.app = application;

    // Setup main layout
    setStyleName(Reindeer.LAYOUT_WHITE);
    setMargin(false);/*from   www  . j a v  a2 s . com*/
    setSpacing(false);
    setSizeFull();

    // Add header
    GridLayout header = new GridLayout(2, 1);
    header.setWidth("100%");
    header.setHeight("34px");
    addComponent(header);

    // Add header styles
    header.addStyleName(Consts.HEADER);
    header.addStyleName("header");
    header.setSpacing(true);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    header.addComponent(logoGrid, 0, 0);
    header.setComponentAlignment(logoGrid, Alignment.MIDDLE_LEFT);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/header-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("header-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add logout button to header
    GridLayout logoutGrid = new GridLayout(2, 1);
    Label userLabel = new Label("Signed in as: " + app.getUser().toString());
    userLabel.addStyleName("user");
    logout.setStyleName(Reindeer.BUTTON_LINK);
    logout.addStyleName("logout");
    logoutGrid.addComponent(userLabel, 0, 0);
    logoutGrid.addComponent(logout, 1, 0);
    header.addComponent(logoutGrid, 1, 0);
    header.setComponentAlignment(logoutGrid, Alignment.TOP_RIGHT);

    // Create tab sheet
    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();

    // Add tab styles
    tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    tabs.addStyleName(Reindeer.LAYOUT_WHITE);

    // Add task view tab
    tabs.addTab(new UserTab(app));
    tabs.addTab(new GroupTab(app));

    // Add tab sheet to layout
    addComponent(tabs);
    setExpandRatio(tabs, 1.0F);

    // Add footer text
    Label footerText = new Label(app.getMessage(Messages.Footer));
    footerText.setSizeUndefined();
    footerText.setStyleName(Reindeer.LABEL_SMALL);
    addComponent(footerText);
    setComponentAlignment(footerText, Alignment.BOTTOM_CENTER);

}

From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java

License:BSD License

/**
 * /*from   w  w  w  . j ava  2s . com*/
 */
protected void createPolicyDropPanel() {
    this.policyDropPanel = new Panel();

    Label rolePoliciesLabel = new Label("Role/Policy Associations");
    rolePoliciesLabel.setStyleName(ValoTheme.LABEL_HUGE);

    this.policyDropPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    this.policyDropPanel.setHeight("100%");
    this.policyDropPanel.setWidth("100%");

    this.rolesCombo = new ComboBox("Roles");
    this.rolesCombo.setWidth("90%");
    this.rolesCombo.addValueChangeListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            final Role role = (Role) event.getProperty().getValue();

            if (role != null) {
                List<Policy> policies = securityService.getAllPoliciesWithRole(role.getName());

                PolicyManagementPanel.this.policyDropTable.removeAllItems();

                for (final Policy policy : policies) {
                    Button deleteButton = new Button();
                    deleteButton.setIcon(VaadinIcons.TRASH);
                    deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                    deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                    deleteButton.setDescription("Remove Policy from this Role");

                    deleteButton.addClickListener(new Button.ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            role.getPolicies().remove(policy);
                            PolicyManagementPanel.this.saveRole(role);

                            PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName());
                            PolicyManagementPanel.this.roleTable.removeItem(role);
                        }
                    });

                    PolicyManagementPanel.this.policyDropTable
                            .addItem(new Object[] { policy.getName(), deleteButton }, policy.getName());
                }
            }
        }
    });

    this.policyDropTable = new Table();
    this.policyDropTable.addContainerProperty("Role Policies", String.class, null);
    this.policyDropTable.addContainerProperty("", Button.class, null);
    this.policyDropTable.setHeight("700px");
    this.policyDropTable.setWidth("300px");

    this.policyDropTable.setDragMode(TableDragMode.ROW);
    this.policyDropTable.setDropHandler(new DropHandler() {
        @Override
        public void drop(final DragAndDropEvent dropEvent) {
            // criteria verify that this is safe
            logger.info("Trying to drop: " + dropEvent);

            if (rolesCombo.getValue() == null) {
                // Do nothing if there is no role selected
                logger.info("Ignoring drop: " + dropEvent);
                return;
            }

            final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable();

            final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent();
            logger.info("sourceContainer.getText(): " + sourceContainer.getText());

            Button deleteButton = new Button();
            deleteButton.setIcon(VaadinIcons.TRASH);
            deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
            deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
            deleteButton.setDescription("Remove Policy from this Role");

            final Policy policy = PolicyManagementPanel.this.securityService
                    .findPolicyByName(sourceContainer.getText());

            final Role selectedRole = PolicyManagementPanel.this.securityService
                    .findRoleByName(((Role) rolesCombo.getValue()).getName());

            deleteButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    selectedRole.getPolicies().remove(policy);
                    PolicyManagementPanel.this.saveRole(selectedRole);

                    policyDropTable.removeItem(policy.getName());
                    roleTable.removeItem(selectedRole);
                }
            });

            PolicyManagementPanel.this.policyDropTable.addItem(
                    new Object[] { sourceContainer.getText(), deleteButton }, sourceContainer.getText());

            selectedRole.getPolicies().add(policy);

            PolicyManagementPanel.this.saveRole(selectedRole);
            policy.getRoles().add(selectedRole);

            PolicyManagementPanel.this.roleTable.removeAllItems();

            for (final Role role : policy.getRoles()) {
                Button roleDeleteButton = new Button();
                roleDeleteButton.setIcon(VaadinIcons.TRASH);
                roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
                deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                deleteButton.setDescription("Remove Policy from this Role");

                roleDeleteButton.addClickListener(new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        selectedRole.getPolicies().remove(policy);
                        PolicyManagementPanel.this.saveRole(selectedRole);

                        PolicyManagementPanel.this.roleTable.removeItem(role);
                        PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName());
                    }
                });

                PolicyManagementPanel.this.roleTable.addItem(new Object[] { role.getName(), roleDeleteButton },
                        role);
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }
    });

    GridLayout layout = new GridLayout();
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setHeight("100%");

    layout.addComponent(rolePoliciesLabel);
    layout.addComponent(this.rolesCombo);

    Label policyDropHintLabel = new Label();
    policyDropHintLabel.setCaptionAsHtml(true);
    policyDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " Drop a policy into the table below to associate with a role.");
    policyDropHintLabel.addStyleName(ValoTheme.LABEL_TINY);
    policyDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT);
    layout.addComponent(policyDropHintLabel);

    layout.addComponent(this.policyDropTable);

    this.policyDropPanel.setContent(layout);
}