Example usage for com.vaadin.ui VerticalLayout setExpandRatio

List of usage examples for com.vaadin.ui VerticalLayout setExpandRatio

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setExpandRatio.

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:org.ow2.sirocco.cloudmanager.CloudProviderView.java

License:Open Source License

public CloudProviderView() {
    this.setSizeFull();

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();//ww  w .j  a  v  a  2 s.c  o  m

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Add Provider Account...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            CloudProviderView.this.providerAccountCreationWizard.init(CloudProviderView.this);
            UI.getCurrent().addWindow(CloudProviderView.this.providerAccountCreationWizard);
        }
    });
    actionButtonHeader.addComponent(button);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            CloudProviderView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    verticalLayout.addComponent(actionButtonHeader);
    verticalLayout.addComponent(this.providerAccountTable = this.createCloudProviderAccountTable());
    verticalLayout.setExpandRatio(this.providerAccountTable, 1.0f);

    this.setFirstComponent(verticalLayout);
    this.setSecondComponent(this.detailView = new ProviderAccountDetailView(this));
    this.setSplitPosition(60.0f);
}

From source file:org.ow2.sirocco.cloudmanager.MachineImageView.java

License:Open Source License

public MachineImageView() {
    this.setSizeFull();

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();//from  w  w  w  .  ja  va2  s.c o  m

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    this.registerMachineImageButton = new Button("Register Image...");
    this.registerMachineImageButton.setIcon(new ThemeResource("img/add.png"));
    this.registerMachineImageButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            if (MachineImageView.this.machineImageRegisterWizard.init(MachineImageView.this)) {
                UI.getCurrent().addWindow(MachineImageView.this.machineImageRegisterWizard);
            }
        }
    });
    actionButtonHeader.addComponent(this.registerMachineImageButton);

    this.deleteMachineImageButton = new Button("Delete");
    this.deleteMachineImageButton.setIcon(new ThemeResource("img/delete.png"));
    this.deleteMachineImageButton.setEnabled(false);
    this.deleteMachineImageButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedImageIds = (Set<?>) MachineImageView.this.machineImageTable.getValue();
            StringBuilder sb = new StringBuilder();
            sb.append("Are you sure you want to delete ");
            if (selectedImageIds.size() == 1) {
                Object id = selectedImageIds.iterator().next();
                sb.append("image " + MachineImageView.this.images.getItem(id).getBean().getName() + " ?");
            } else {
                sb.append(" these " + selectedImageIds.size() + " images ?");
            }
            String name = MachineImageView.this.images.getItem(selectedImageIds.iterator().next()).getBean()
                    .getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialogWithOption("Delete Image",
                    sb.toString(), "delete image on provider", new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean deleteOnProvider) {
                            if (ok) {
                                for (Object id : selectedImageIds) {
                                    try {
                                        if (deleteOnProvider) {
                                            MachineImageView.this.machineImageManager
                                                    .deleteMachineImage(id.toString());
                                        } else {
                                            MachineImageView.this.machineImageManager
                                                    .unregisterMachineImage(id.toString());
                                        }
                                    } catch (CloudProviderException e) {
                                        Util.diplayErrorMessageBox("Image delete failure", e);
                                    }
                                }
                                MachineImageView.this.valueChange(null);
                            }
                        }
                    });
            MachineImageView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteMachineImageButton);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    Button button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            MachineImageView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    verticalLayout.addComponent(actionButtonHeader);
    verticalLayout.addComponent(this.machineImageTable = this.createMachineImageTable());
    verticalLayout.setExpandRatio(this.machineImageTable, 1.0f);

    this.setFirstComponent(verticalLayout);
    this.setSecondComponent(this.detailView = new MachineImageDetailView(this));
    this.setSplitPosition(60.0f);

}

From source file:org.ow2.sirocco.cloudmanager.MachineView.java

License:Open Source License

public MachineView() {
    this.setSizeFull();

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();/* w  ww  .  j  a v  a2s  .  com*/

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Launch Instance...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            if (MachineView.this.machineCreationWizard.init(MachineView.this)) {
                UI.getCurrent().addWindow(MachineView.this.machineCreationWizard);
            }
        }
    });
    actionButtonHeader.addComponent(button);

    this.startMachineButton = new Button("Start");
    this.startMachineButton.setIcon(new ThemeResource("img/poweron.png"));
    this.startMachineButton.setEnabled(false);
    this.startMachineButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue();
            String id = (String) selectedMachineIds.iterator().next();
            try {
                MachineView.this.machineManager.startMachine(id);
            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Cannot start instance", e);
            }
        }
    });
    actionButtonHeader.addComponent(this.startMachineButton);

    this.stopMachineButton = new Button("Stop");
    this.stopMachineButton.setIcon(new ThemeResource("img/poweroff.png"));
    this.stopMachineButton.setEnabled(false);
    this.stopMachineButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue();
            String id = (String) selectedMachineIds.iterator().next();
            try {
                MachineView.this.machineManager.stopMachine(id);
            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Cannot stop instance", e);
            }
        }
    });
    actionButtonHeader.addComponent(this.stopMachineButton);

    this.restartMachineButton = new Button("Reboot");
    this.restartMachineButton.setIcon(new ThemeResource("img/restart.png"));
    this.restartMachineButton.setEnabled(false);
    this.restartMachineButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue();
            String id = (String) selectedMachineIds.iterator().next();
            try {
                MachineView.this.machineManager.restartMachine(id, false);
            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Cannot reboot instance", e);
            }
        }
    });
    actionButtonHeader.addComponent(this.restartMachineButton);

    this.deleteMachineButton = new Button("Delete");
    this.deleteMachineButton.setIcon(new ThemeResource("img/delete.png"));
    this.deleteMachineButton.setEnabled(false);
    this.deleteMachineButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedMachineIds = (Set<?>) MachineView.this.machineTable.getValue();
            StringBuilder sb = new StringBuilder();
            sb.append("Are you sure you want to delete ");
            if (selectedMachineIds.size() == 1) {
                Object id = selectedMachineIds.iterator().next();
                sb.append("instance " + MachineView.this.machines.getItem(id).getBean().getName() + " ?");
            } else {
                sb.append(" these " + selectedMachineIds.size() + " instances ?");
            }
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Machine", sb.toString(),
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedMachineIds) {
                                    try {
                                        MachineView.this.machineManager.deleteMachine(id.toString());
                                    } catch (CloudProviderException e) {
                                        Util.diplayErrorMessageBox("Cannot delete instance", e);
                                    }
                                }
                                MachineView.this.valueChange(null);
                            }
                        }
                    });
            MachineView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteMachineButton);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            MachineView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    verticalLayout.addComponent(actionButtonHeader);
    verticalLayout.addComponent(this.machineTable = this.createMachineTable());
    verticalLayout.setExpandRatio(this.machineTable, 1.0f);

    this.setFirstComponent(verticalLayout);
    this.setSecondComponent(this.detailView = new MachineDetailView(this));
    this.setSplitPosition(60.0f);

}

From source file:org.ow2.sirocco.cloudmanager.MyUI.java

License:Open Source License

@Override
protected void init(final VaadinRequest request) {
    this.userName = request.getUserPrincipal().getName();
    this.identityContext.setUserName(this.userName);

    this.getPage().setTitle("Sirocco Dashboard");
    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from   w  ww  .  j a va 2  s.c  o  m
    this.setContent(layout);

    // Top header *********************
    HorizontalLayout header = new HorizontalLayout();
    header.setMargin(true);
    header.setWidth("100%");
    header.setHeight("70px");
    header.setStyleName("topHeader");

    // logo
    Image image = new Image(null, new ThemeResource("img/sirocco_small_logo.png"));
    header.addComponent(image);

    // spacer
    Label spacer = new Label();
    spacer.setWidth("100%");
    header.addComponent(spacer);
    header.setExpandRatio(spacer, 1.0f);

    HorizontalLayout rightButtons = new HorizontalLayout();
    rightButtons.setStyleName("topHeader");
    rightButtons.setSpacing(true);

    this.userName = request.getUserPrincipal().getName();
    User user = null;
    try {
        user = this.userManager.getUserByUsername(this.userName);
    } catch (CloudProviderException e) {
        e.printStackTrace();
    }

    Label label = new Label("Tenant:");
    label.setStyleName("topHeaderLabel");
    rightButtons.addComponent(label);
    final ComboBox tenantSelect = new ComboBox();
    tenantSelect.setTextInputAllowed(false);
    tenantSelect.setNullSelectionAllowed(false);
    for (Tenant tenant : user.getTenants()) {
        tenantSelect.addItem(tenant.getName());
    }
    tenantSelect.setValue(user.getTenants().iterator().next().getName());
    tenantSelect.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(final ValueChangeEvent event) {
            Notification.show("Switching to tenant " + tenantSelect.getValue());

        }
    });
    tenantSelect.setImmediate(true);
    rightButtons.addComponent(tenantSelect);

    this.tenantId = user.getTenants().iterator().next().getUuid();
    this.identityContext.setTenantId(this.tenantId);

    // logged user name

    label = new Label("Logged in as: " + this.userName);
    label.setStyleName("topHeaderLabel");
    rightButtons.addComponent(label);

    // sign out button
    Button button = new Button("Sign Out");
    // button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(final ClickEvent event) {
            MyUI.this.logout();
        }
    });
    rightButtons.addComponent(button);

    header.addComponent(rightButtons);
    layout.addComponent(header);

    // Split view
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setFirstComponent(this.createLeftMenu());

    this.inventoryContainer = new VerticalLayout();
    this.inventoryContainer.setSizeFull();

    this.inventoryContainer.addComponent(this.machineView);

    splitPanel.setSecondComponent(this.inventoryContainer);
    splitPanel.setSplitPosition(15);

    layout.addComponent(splitPanel);
    layout.setExpandRatio(splitPanel, 1.0f);

    this.listenToNotifications();

}

From source file:org.ow2.sirocco.cloudmanager.SecurityGroupView.java

License:Open Source License

public SecurityGroupView() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();/* w w w.  j ava2 s.co  m*/

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Create SecurityGroup...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            if (SecurityGroupView.this.securityGroupCreationWizard.init(SecurityGroupView.this)) {
                UI.getCurrent().addWindow(SecurityGroupView.this.securityGroupCreationWizard);
            }
        }
    });
    actionButtonHeader.addComponent(button);

    this.deleteSecurityGroupButton = new Button("Delete");
    this.deleteSecurityGroupButton.setIcon(new ThemeResource("img/delete.png"));
    this.deleteSecurityGroupButton.setEnabled(false);
    this.deleteSecurityGroupButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedSecurityGroupIds = (Set<?>) SecurityGroupView.this.securityGroupTable
                    .getValue();
            String name = SecurityGroupView.this.securityGroups
                    .getItem(selectedSecurityGroupIds.iterator().next()).getBean().getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete SecurityGroup",
                    "Are you sure you want to delete securityGroup " + name + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedSecurityGroupIds) {
                                    try {
                                        SecurityGroupView.this.networkManager
                                                .deleteSecurityGroup(id.toString());
                                    } catch (CloudProviderException e) {
                                        Util.diplayErrorMessageBox("Cannot delete security group "
                                                + SecurityGroupView.this.securityGroups.getItem(id).getBean()
                                                        .getName(),
                                                e);
                                    }
                                }
                                SecurityGroupView.this.valueChange(null);
                            }
                        }
                    });
            SecurityGroupView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteSecurityGroupButton);

    Label spacer = new Label();
    spacer.setWidth("100%");
    actionButtonHeader.addComponent(spacer);
    actionButtonHeader.setExpandRatio(spacer, 1.0f);

    button = new Button("Refresh", new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            SecurityGroupView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    verticalLayout.addComponent(actionButtonHeader);
    verticalLayout.addComponent(this.securityGroupTable = this.createSecurityGroupTable());
    verticalLayout.setExpandRatio(this.securityGroupTable, 1.0f);

    this.setFirstComponent(verticalLayout);
    this.setSecondComponent(this.detailView = new SecurityGroupDetailView(this));
    this.setSplitPosition(60.0f);

}

From source file:org.plukh.fluffymeow.ui.FluffyUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    //Create and set root layout
    VerticalLayout root = new VerticalLayout();
    root.setSizeFull();/*from  w ww  .  j a  v  a  2 s . com*/
    setContent(root);

    //Create and add header
    Header header = injector.getInstance(Header.class);
    root.addComponent(header);

    //Add navigable part
    navigableContent.setSizeFull();
    root.addComponent(navigableContent);
    root.setExpandRatio(navigableContent, 1.0f);

    //Create and add footer
    Footer footer = injector.getInstance(Footer.class);
    root.addComponent(footer);

    //Set locale as the last init action, after all components/views have been created
    setLocale(getPage().getWebBrowser().getLocale());
}

From source file:org.processbase.ui.bpm.admin.ProcessDefinitionWindow.java

License:Open Source License

public void initUI() {
    try {//  w ww  .j  ava 2 s . c  om
        String caption = processDefinition.getLabel() != null ? processDefinition.getLabel()
                : processDefinition.getName();
        setCaption(caption + " (v." + processDefinition.getVersion() + ")");
        VerticalLayout layout = (VerticalLayout) this.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName(Reindeer.LAYOUT_WHITE);

        v1.setMargin(true, false, false, false);
        v1.setSizeFull();

        if (processDefinition.getLabel() != null) {
            Label pdLabel = new Label("<b>" + processDefinition.getLabel() + "</b>");
            pdLabel.setContentMode(Label.CONTENT_XHTML);
            v1.addComponent(pdLabel);
        }

        if (processDefinition.getDescription() != null) {
            Label pdDescription = new Label(processDefinition.getDescription());
            pdDescription.setContentMode(Label.CONTENT_XHTML);
            v1.addComponent(pdDescription);
            v1.setExpandRatio(pdDescription, 1);
        }

        tabSheet.addTab(v1, ProcessbaseApplication.getCurrent().getPbMessages().getString("tabDescription"),
                null);

        activitiesTable.setSizeFull();

        v2.setMargin(false, false, false, false);
        v2.addComponent(activitiesTable);
        v2.setSizeFull();
        tabSheet.addTab(v2, ProcessbaseApplication.getCurrent().getPbMessages().getString("tabCustomUI"), null);

        // prepare membership
        prepareTableMembership();
        addBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnAdd"), this);
        addBtn.setStyleName(Runo.BUTTON_SMALL);
        v3.setMargin(false, false, false, false);
        v3.setSpacing(true);
        v3.addComponent(addBtn);
        v3.setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT);
        v3.addComponent(tableMembership);
        v3.setSizeFull();
        tabSheet.addTab(v3, ProcessbaseApplication.getCurrent().getPbMessages().getString("processAccess"),
                null);
        refreshTableMembership();

        tabSheet.setStyleName(Reindeer.TABSHEET_MINIMAL);
        tabSheet.setSizeFull();
        tabSheet.addListener((TabSheet.SelectedTabChangeListener) this);
        layout.addComponent(tabSheet);
        layout.setExpandRatio(tabSheet, 1);

        closeBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnClose"), this);
        applyBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSaveCustomUI"),
                this);
        saveAccessBtn = new Button(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSaveProcessAccess"), this);
        deleteAllBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDeleteAll"),
                this);
        deleteInstancesBtn = new Button(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDeleteInstances"), this);
        downloadBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDownload"),
                this);
        enableBtn = new CheckBox(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnEnable"),
                this);
        archiveBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnArchive"),
                this);

        deleteAllBtn.setDescription(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("deleteProcessDefinition"));
        buttons.addButton(deleteAllBtn);
        buttons.setComponentAlignment(deleteAllBtn, Alignment.MIDDLE_RIGHT);
        deleteInstancesBtn.setDescription(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("deleteProcessInstances"));
        buttons.addButton(deleteInstancesBtn);
        buttons.setComponentAlignment(deleteInstancesBtn, Alignment.MIDDLE_RIGHT);

        Label expand = new Label("");
        buttons.addComponent(expand);
        buttons.setExpandRatio(expand, 1);

        enableBtn.setValue(processDefinition.getState().equals(ProcessState.ENABLED));
        buttons.addButton(enableBtn);
        buttons.setComponentAlignment(enableBtn, Alignment.MIDDLE_RIGHT);

        buttons.addButton(archiveBtn);
        buttons.setComponentAlignment(archiveBtn, Alignment.MIDDLE_RIGHT);

        applyBtn.setVisible(false);
        buttons.addButton(applyBtn);
        buttons.setComponentAlignment(applyBtn, Alignment.MIDDLE_RIGHT);
        buttons.addButton(saveAccessBtn);
        saveAccessBtn.setVisible(false);
        buttons.setComponentAlignment(saveAccessBtn, Alignment.MIDDLE_RIGHT);
        buttons.addButton(closeBtn);
        buttons.setComponentAlignment(closeBtn, Alignment.MIDDLE_RIGHT);
        buttons.setMargin(false);
        buttons.setHeight("30px");
        buttons.setWidth("100%");
        layout.addComponent(buttons);
        layout.setWidth("800px");
        layout.setHeight("400px");
        setResizable(false);
        setModal(true);

        //        activitiesTable.addContainerProperty("activityUUID", String.class, null, "UUID", null, null);
        //        activitiesTable.setColumnWidth("activityUUID", 0);
        activitiesTable.addContainerProperty("activityLabel", String.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tableCaptionActivityName"), null,
                null);
        activitiesTable.addContainerProperty("url", String.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tabCaptionTaskURL"), null, null);
        activitiesTable.setColumnWidth("url", 300);
        activitiesTable.setTableFieldFactory(new PbTableFieldFactory());
        activitiesTable.setEditable(true);
        activitiesTable.setImmediate(true);

        refreshTable();
    } catch (Exception ex) {
        ex.printStackTrace();
        showError(ex.getMessage());
    }
}

From source file:org.processbase.ui.bpm.admin.UserWindow.java

License:Open Source License

public void initUI() {
    try {/*from   w  w w . j a v a2s  .  c  o  m*/
        if (user == null) {
            setCaption(ProcessbaseApplication.getString("newUser"));
        } else {
            setCaption(ProcessbaseApplication.getString("user"));
        }
        setModal(true);
        VerticalLayout layout = (VerticalLayout) this.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName(Reindeer.LAYOUT_WHITE);
        layout.setSizeFull();

        addBtn = new Button(ProcessbaseApplication.getString("btnAdd"), this);
        closeBtn = new Button(ProcessbaseApplication.getString("btnClose"), this);
        saveBtn = new Button(ProcessbaseApplication.getString("btnSave"), this);
        userFirstName = new TextField(ProcessbaseApplication.getString("userFirstName"));
        userLastName = new TextField(ProcessbaseApplication.getString("userLastName"));
        userName = new TextField(ProcessbaseApplication.getString("userName"));
        userEmail = new TextField(ProcessbaseApplication.getString("userEmail"));
        userJobTitle = new TextField(ProcessbaseApplication.getString("userJobTitle"));
        password = new PasswordField(ProcessbaseApplication.getString("password"));

        // prepare user information
        userInfofmation.setMargin(true);
        userInfofmation.setSpacing(true);
        userName.setWidth("270px");
        userInfofmation.addComponent(userName);
        password.setWidth("270px");
        userInfofmation.addComponent(password);
        userFirstName.setWidth("270px");
        userInfofmation.addComponent(userFirstName);
        userLastName.setWidth("270px");
        userInfofmation.addComponent(userLastName);
        userEmail.setWidth("270px");
        userInfofmation.addComponent(userEmail);
        userJobTitle.setWidth("270px");
        userInfofmation.addComponent(userJobTitle);

        // prepare user membership
        userMembership.setMargin(true);
        userMembership.setSpacing(true);
        userMembership.setSizeFull();
        prepareTableMembership();
        userMembership.addComponent(tableMembership);

        // prepare user metadata
        userMetadata.setMargin(true);
        userMetadata.setSpacing(true);
        userMetadata.setSizeFull();
        prepareTableMetadata();
        userMetadata.addComponent(tableMetadata);

        // prepare tabSheet
        tabSheet.addTab(userInfofmation, ProcessbaseApplication.getString("userInfofmation"), null);
        tabSheet.addTab(userMembership, ProcessbaseApplication.getString("userMembership"), null);
        tabSheet.addTab(userMetadata, ProcessbaseApplication.getString("userMetadata"), null);
        tabSheet.addListener((TabSheet.SelectedTabChangeListener) this);
        tabSheet.setImmediate(true);
        tabSheet.setSizeFull();
        layout.addComponent(tabSheet);
        layout.setExpandRatio(tabSheet, 1);

        addBtn.setVisible(false);
        buttons.addButton(addBtn);
        buttons.setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT);
        buttons.addButton(saveBtn);
        buttons.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT);
        buttons.setExpandRatio(saveBtn, 1);
        buttons.addButton(closeBtn);
        buttons.setComponentAlignment(closeBtn, Alignment.MIDDLE_RIGHT);
        buttons.setMargin(false);
        buttons.setHeight("30px");
        buttons.setWidth("100%");
        addComponent(buttons);

        if (user != null) {
            userFirstName.setValue(user.getFirstName());
            userLastName.setValue(user.getLastName());
            userName.setValue(user.getUsername());
            userEmail.setValue(
                    user.getProfessionalContactInfo() != null ? user.getProfessionalContactInfo().getEmail()
                            : "");
            userJobTitle.setValue(user.getJobTitle());
            password.setValue(user.getPassword());
            refreshTableMembership();
            refreshTableMetadata();
            userName.setReadOnly(true);
        }
        setWidth("800px");
        setHeight("500px");
        setResizable(false);
        setModal(true);
    } catch (Exception ex) {
        ex.printStackTrace();
        showError(ex.getMessage());
        throw new RuntimeException(ex);
    }
}

From source file:org.processbase.ui.bpm.identity.UserWindow.java

License:Open Source License

public void initUI() {
    try {//from w  ww. ja  v  a  2s  .com
        if (user == null) {
            setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("newUser"));
        } else {
            setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("user"));
        }
        setModal(true);
        VerticalLayout layout = (VerticalLayout) this.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName(Reindeer.LAYOUT_WHITE);
        layout.setSizeFull();

        addBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnAdd"), this);
        closeBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnClose"), this);
        saveBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSave"), this);
        userFirstName = new TextField(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("userFirstName"));
        userLastName = new TextField(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("userLastName"));
        userName = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("userName"));
        userEmail = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("userEmail"));
        userJobTitle = new TextField(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("userJobTitle"));
        password = new PasswordField(ProcessbaseApplication.getCurrent().getPbMessages().getString("password"));

        // prepare user information
        userInfofmation.setMargin(true);
        userInfofmation.setSpacing(true);
        userName.setWidth("270px");
        userInfofmation.addComponent(userName);
        password.setWidth("270px");
        userInfofmation.addComponent(password);
        userFirstName.setWidth("270px");
        userInfofmation.addComponent(userFirstName);
        userLastName.setWidth("270px");
        userInfofmation.addComponent(userLastName);
        userEmail.setWidth("270px");
        userInfofmation.addComponent(userEmail);
        userJobTitle.setWidth("270px");
        userInfofmation.addComponent(userJobTitle);

        // prepare user membership
        userMembership.setMargin(true);
        userMembership.setSpacing(true);
        userMembership.setSizeFull();
        prepareTableMembership();
        userMembership.addComponent(tableMembership);

        // prepare user metadata
        userMetadata.setMargin(true);
        userMetadata.setSpacing(true);
        userMetadata.setSizeFull();
        prepareTableMetadata();
        userMetadata.addComponent(tableMetadata);

        // prepare tabSheet
        tabSheet.addTab(userInfofmation,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("userInfofmation"), null);
        tabSheet.addTab(userMembership,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("userMembership"), null);
        tabSheet.addTab(userMetadata,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("userMetadata"), null);
        tabSheet.addListener((TabSheet.SelectedTabChangeListener) this);
        tabSheet.setImmediate(true);
        tabSheet.setSizeFull();
        layout.addComponent(tabSheet);
        layout.setExpandRatio(tabSheet, 1);

        addBtn.setVisible(false);
        buttons.addButton(addBtn);
        buttons.setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT);
        buttons.addButton(saveBtn);
        buttons.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT);
        buttons.setExpandRatio(saveBtn, 1);
        buttons.addButton(closeBtn);
        buttons.setComponentAlignment(closeBtn, Alignment.MIDDLE_RIGHT);
        buttons.setMargin(false);
        buttons.setHeight("30px");
        buttons.setWidth("100%");
        addComponent(buttons);

        if (user != null) {
            userFirstName.setValue(user.getFirstName());
            userLastName.setValue(user.getLastName());
            userName.setValue(user.getUsername());
            userEmail.setValue(
                    user.getProfessionalContactInfo() != null ? user.getProfessionalContactInfo().getEmail()
                            : "");
            userJobTitle.setValue(user.getJobTitle());
            password.setValue(user.getPassword());
            refreshTableMembership();
            refreshTableMetadata();
            userName.setReadOnly(true);
        }
        setWidth("800px");
        setHeight("500px");
        setResizable(false);
        setModal(true);
    } catch (Exception ex) {
        ex.printStackTrace();
        showError(ex.getMessage());
    }
}

From source file:org.processbase.ui.core.template.DefaultConfirmDialogFactory.java

License:Open Source License

public ConfirmDialog create(final String caption, final String message, final String okCaption,
        final String cancelCaption) {

    // Create a confirm dialog
    final ConfirmDialog confirm = new ConfirmDialog();
    confirm.setCaption(caption != null ? caption : DEFAULT_CAPTION);

    // Close listener implementation
    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            confirm.setConfirmed(false);
            if (confirm.getListener() != null) {
                confirm.getListener().onClose(confirm);
            }//from   w ww  . ja  va  2s .  c om
        }
    });

    // Create content
    VerticalLayout c = (VerticalLayout) confirm.getContent();
    c.setSizeFull();
    c.setSpacing(true);

    // Panel for scrolling lengthty messages.
    Panel scroll = new Panel(new VerticalLayout());
    scroll.setScrollable(true);
    c.addComponent(scroll);
    scroll.setWidth("100%");
    scroll.setHeight("100%");
    scroll.setStyleName(Reindeer.PANEL_LIGHT);
    c.setExpandRatio(scroll, 1f);

    // Always HTML, but escape
    Label text = new Label("", Label.CONTENT_RAW);
    scroll.addComponent(text);
    confirm.setMessageLabel(text);
    confirm.setMessage(message);

    HorizontalLayout buttons = new HorizontalLayout();
    c.addComponent(buttons);
    buttons.setSpacing(true);

    buttons.setHeight(format(BUTTON_HEIGHT) + "em");
    buttons.setWidth("100%");
    Label spacer = new Label("");
    buttons.addComponent(spacer);
    spacer.setWidth("100%");
    buttons.setExpandRatio(spacer, 1f);

    final Button cancel = new Button(cancelCaption != null ? cancelCaption : DEFAULT_CANCEL_CAPTION);
    cancel.setData(false);
    cancel.setClickShortcut(KeyCode.ESCAPE, null);
    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);
    confirm.setCancelButton(cancel);

    final Button ok = new Button(okCaption != null ? okCaption : DEFAULT_OK_CAPTION);
    ok.setData(true);
    ok.setClickShortcut(KeyCode.ENTER, null);
    ok.setStyleName(Reindeer.BUTTON_DEFAULT);
    ok.focus();
    buttons.addComponent(ok);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);
    confirm.setOkButton(ok);

    // Create a listener for buttons
    Button.ClickListener cb = new Button.ClickListener() {
        private static final long serialVersionUID = 3525060915814334881L;

        public void buttonClick(ClickEvent event) {
            // Copy the button date to window for passing through either
            // "OK" or "CANCEL"
            confirm.setConfirmed(event.getButton() == ok);

            // This has to be invoked as the window.close
            // event is not fired when removed.
            if (confirm.getListener() != null) {
                confirm.getListener().onClose(confirm);
            }
            confirm.close();

        }

    };
    cancel.addListener(cb);
    ok.addListener(cb);

    // Approximate the size of the dialog
    double[] dim = getDialogDimensions(message, ConfirmDialog.CONTENT_TEXT_WITH_NEWLINES);
    confirm.setWidth(format(dim[0]) + "em");
    confirm.setHeight(format(dim[1]) + "em");
    confirm.setResizable(false);

    return confirm;
}