Example usage for com.vaadin.ui Label setWidth

List of usage examples for com.vaadin.ui Label setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui Label setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

License:Open Source License

public CloudProviderView() {
    this.setSizeFull();

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();/*  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");

    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.KeyPairView.java

License:Open Source License

public KeyPairView() {
    this.setSizeFull();

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);//  w  ww.  j  av a2s  .co  m
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

    Button button = new Button("Import Key Pair...");
    button.setIcon(new ThemeResource("img/add.png"));
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            KeyPairImportDialog dialog = new KeyPairImportDialog(new KeyPairImportDialog.DialogCallback() {

                @Override
                public void response(final String name, final String publicKey) {
                    try {
                        CredentialsCreate credentialsCreate = new CredentialsCreate();
                        credentialsCreate.setName(name);
                        CredentialsTemplate credentialsTemplate = new CredentialsTemplate();
                        credentialsTemplate.setPublicKey(publicKey);
                        credentialsCreate.setCredentialTemplate(credentialsTemplate);
                        KeyPairView.this.credentialManager.createCredentials(credentialsCreate);
                    } catch (CloudProviderException e) {
                        Notification.show("Key Pair creation failure", e.getMessage(),
                                Notification.Type.ERROR_MESSAGE);
                    }
                    KeyPairView.this.refresh();
                    KeyPairView.this.valueChange(null);
                }
            });
            UI.getCurrent().addWindow(dialog);
        }
    });
    actionButtonHeader.addComponent(button);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedKeyPairIds = (Set<?>) KeyPairView.this.keyPairTable.getValue();
            String name = KeyPairView.this.keyPairs.getItem(selectedKeyPairIds.iterator().next()).getBean()
                    .getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Image",
                    "Are you sure you want to delete key pair " + name + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedKeyPairIds) {
                                    try {
                                        KeyPairView.this.credentialManager.deleteCredentials(id.toString());
                                        KeyPairView.this.keyPairs.removeItem(id);
                                    } catch (CloudProviderException e) {
                                        e.printStackTrace();
                                    }
                                }
                                KeyPairView.this.keyPairTable.setValue(null);
                                KeyPairView.this.valueChange(null);
                            }
                        }
                    });
            KeyPairView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteKeyPairButton);

    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) {
            KeyPairView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    this.addComponent(actionButtonHeader);
    this.addComponent(this.keyPairTable = this.createkeyPairTable());
    this.setExpandRatio(this.keyPairTable, 1.0f);

}

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

License:Open Source License

public MachineImageView() {
    this.setSizeFull();

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();// w  w  w.j a va2s.  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();/*from   w w  w . ja va2s  .  c  om*/

    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();/*w w w.  java2s.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.NetworkView.java

License:Open Source License

public NetworkView() {
    this.setSizeFull();

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);/*from ww w  .j av a 2s . c  o  m*/
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

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

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

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

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedNetworkIds = (Set<?>) NetworkView.this.networkTable.getValue();
            String name = NetworkView.this.networks.getItem(selectedNetworkIds.iterator().next()).getBean()
                    .getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Network",
                    "Are you sure you want to delete network " + name + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedNetworkIds) {
                                    try {
                                        NetworkView.this.networkManager.deleteNetwork(id.toString());
                                    } catch (CloudProviderException e) {
                                        e.printStackTrace();
                                    }
                                }
                                NetworkView.this.valueChange(null);
                            }
                        }
                    });
            NetworkView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteNetworkButton);

    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) {
            NetworkView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    this.addComponent(actionButtonHeader);
    this.addComponent(this.networkTable = this.createNetworkTable());
    this.setExpandRatio(this.networkTable, 1.0f);

}

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

License:Open Source License

public SecurityGroupView() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();/*from   w  ww  . ja  v  a 2s.  c  om*/

    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.ow2.sirocco.cloudmanager.util.InputDialog.java

License:Open Source License

private InputDialog(final String title, final String name, final String initialValue, final boolean isPassword,
        final DialogCallback callback) {
    super(title);
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);/* ww w  .ja  v  a  2 s.co m*/
    verticalLayout.setMargin(true);

    FormLayout content = new FormLayout();
    content.setMargin(true);
    content.setWidth("400px");
    content.setHeight("100px");

    this.textField = isPassword ? new PasswordField(name) : new TextField(name);
    this.textField.setRequired(true);
    this.textField.setWidth("100%");
    this.textField.setRequired(true);
    this.textField.setRequiredError("Please provide a " + name);
    this.textField.setImmediate(true);
    if (initialValue != null) {
        this.textField.setValue(initialValue);
    }
    content.addComponent(this.textField);

    verticalLayout.addComponent(content);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");
    Label spacer = new Label("");
    buttonLayout.addComponent(spacer);
    spacer.setWidth("100%");
    buttonLayout.setExpandRatio(spacer, 1f);
    this.okButton = new Button("Ok", this);
    this.okButton.setClickShortcut(KeyCode.ENTER, null);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.setClickShortcut(KeyCode.ESCAPE, null);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    // content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    verticalLayout.addComponent(buttonLayout);

    this.setContent(verticalLayout);
}

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

License:Open Source License

public VolumeView() {
    this.setSizeFull();

    HorizontalLayout actionButtonHeader = new HorizontalLayout();
    actionButtonHeader.setMargin(true);/* ww w .j av  a  2 s  . c  o m*/
    actionButtonHeader.setSpacing(true);
    actionButtonHeader.setWidth("100%");
    actionButtonHeader.setHeight("50px");

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

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

    this.attachVolumeButton = new Button("Attach");
    this.attachVolumeButton.setEnabled(false);
    this.attachVolumeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue();
            final String volumeId = (String) selectedVolumeIds.iterator().next();
            List<VolumeAttachDialog.MachineChoice> choices = new ArrayList<>();
            Volume volume;
            try {
                volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId);
                List<Machine> machines = VolumeView.this.machineManager.getMachines().getItems();
                for (Machine machine : machines) {
                    if (machine.getCloudProviderAccount().getId() == volume.getCloudProviderAccount().getId()
                            && machine.getLocation().getId() == volume.getLocation().getId()) {
                        MachineChoice machineChoice = new MachineChoice();
                        machineChoice.id = machine.getUuid();
                        machineChoice.name = machine.getName();
                        choices.add(machineChoice);
                    }
                }

            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Internal error", e);
            }

            VolumeAttachDialog volumeAttachDialog = new VolumeAttachDialog(choices,
                    new VolumeAttachDialog.DialogCallback() {

                        @Override
                        public void response(final String machineId, final String location) {
                            try {
                                Volume volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId);
                                MachineVolume volumeAttachment = new MachineVolume();
                                volumeAttachment.setInitialLocation(location);
                                volumeAttachment.setVolume(volume);
                                VolumeView.this.machineManager.addVolumeToMachine(machineId, volumeAttachment);
                            } catch (CloudProviderException e) {
                                Util.diplayErrorMessageBox("Volume attach failure", e);
                            }
                        }
                    });
            UI.getCurrent().addWindow(volumeAttachDialog);
        }
    });
    actionButtonHeader.addComponent(this.attachVolumeButton);

    this.detachVolumeButton = new Button("Detach");
    this.detachVolumeButton.setEnabled(false);
    this.detachVolumeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue();
            String volumeId = (String) selectedVolumeIds.iterator().next();
            try {
                Volume volume = VolumeView.this.volumeManager.getVolumeByUuid(volumeId);
                MachineVolume volumeAttachment = volume.getAttachments().get(0);
                VolumeView.this.machineManager.removeVolumeFromMachine(volumeAttachment.getOwner().getUuid(),
                        volumeAttachment.getUuid());
            } catch (CloudProviderException e) {
                Util.diplayErrorMessageBox("Volume detach failure", e);
            }
        }
    });
    actionButtonHeader.addComponent(this.detachVolumeButton);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            final Set<?> selectedVolumeIds = (Set<?>) VolumeView.this.volumeTable.getValue();
            String name = VolumeView.this.volumes.getItem(selectedVolumeIds.iterator().next()).getBean()
                    .getName();
            ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialog("Delete Volume",
                    "Are you sure you want to delete volume " + name + " ?",
                    new ConfirmDialog.ConfirmationDialogCallback() {

                        @Override
                        public void response(final boolean ok, final boolean ignored) {
                            if (ok) {
                                for (Object id : selectedVolumeIds) {
                                    try {
                                        VolumeView.this.volumeManager.deleteVolume(id.toString());
                                    } catch (CloudProviderException e) {
                                        Util.diplayErrorMessageBox("Volume delete failure", e);
                                    }
                                }
                                VolumeView.this.valueChange(null);
                            }
                        }
                    });
            VolumeView.this.getUI().addWindow(confirmDialog);
        }
    });
    actionButtonHeader.addComponent(this.deleteVolumeButton);

    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) {
            VolumeView.this.refresh();
        }
    });
    button.setIcon(new ThemeResource("img/refresh.png"));
    actionButtonHeader.addComponent(button);

    this.addComponent(actionButtonHeader);
    this.addComponent(this.volumeTable = this.createVolumeTable());
    this.setExpandRatio(this.volumeTable, 1.0f);
}

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

License:Open Source License

private void addTableMembershipRow(Membership membership) throws Exception {
    String uuid = membership != null ? membership.getUUID()
            : "NEW_MEMBERSHIP_UUID_" + UUID.randomUUID().toString();
    Item woItem = tableMembership.addItem(uuid);

    if (membership != null) {
        Label groups = new Label(getGroups()
                .getItem(membership != null ? membership.getGroup().getUUID() : null).getItemProperty("path"));
        woItem.getItemProperty("group").setValue(groups);

        Label roles = new Label(getRoles().getItem(membership != null ? membership.getRole().getUUID() : null)
                .getItemProperty("name"));
        woItem.getItemProperty("role").setValue(roles);

    } else {/*from w  ww . j a  va  2 s . c  om*/
        ComboBox groups = new ComboBox();
        groups.setWidth("100%");
        groups.setContainerDataSource(getGroups());
        groups.setItemCaptionPropertyId("path");
        groups.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
        groups.setValue(membership != null ? membership.getGroup().getUUID() : null);
        woItem.getItemProperty("group").setValue(groups);

        ComboBox roles = new ComboBox();
        roles.setWidth("100%");
        roles.setContainerDataSource(getRoles());
        roles.setItemCaptionPropertyId("name");
        roles.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
        roles.setValue(membership != null ? membership.getRole().getUUID() : null);
        woItem.getItemProperty("role").setValue(roles);
    }
    TableLinkButton tlb = new TableLinkButton(
            ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDelete"), "icons/cancel.png",
            uuid, this, Constants.ACTION_DELETE);
    woItem.getItemProperty("actions").setValue(tlb);
}