Example usage for com.vaadin.ui VerticalLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java

License:Apache License

/**
 * Create the component to take a snapshot.
 * /*from  w  ww  . j a v  a2 s .  c o m*/
 * @return the component
 */
@SuppressWarnings("serial")
private final AbstractComponent createTakeSnap() {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    final FormLayout takeSnapLayout = new FormLayout();
    takeSnapLayout.setMargin(true);
    takeSnapLayout.setImmediate(true);
    takeSnapLayout.setWidth(null);
    layout.addComponent(takeSnapLayout);
    layout.setComponentAlignment(takeSnapLayout, Alignment.MIDDLE_CENTER);

    // Enter name
    final TextField vvrName = new TextField("Name", "");
    takeSnapLayout.addComponent(vvrName);

    // take button
    final Button take = new Button("Take snapshot");
    layout.addComponent(take);
    layout.setComponentAlignment(take, Alignment.MIDDLE_CENTER);

    take.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                model.takeDeviceSnapshot(vvrName.getValue());
                Notification.show("New snapshot created", Notification.Type.TRAY_NOTIFICATION);
            } catch (final Exception e) {
                final ErrorWindow err = new ErrorWindow("Snapshot not taken: " + e.getMessage());
                err.add(model);
            }
        }
    });
    return layout;
}

From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java

License:Apache License

/**
 * Create the component to activate/deactivate a device.
 * /* ww w  . j  av a  2  s. c om*/
 * @return the component
 */
@SuppressWarnings("serial")
private final AbstractComponent createActivate() {

    final VerticalLayout rootlayout = new VerticalLayout();
    rootlayout.setMargin(true);
    rootlayout.setSpacing(true);

    final OptionGroup activate = new OptionGroup("Select an option: ");
    rootlayout.addComponent(activate);
    rootlayout.setComponentAlignment(activate, Alignment.MIDDLE_CENTER);

    activate.setNullSelectionAllowed(false);
    activate.setHtmlContentAllowed(true);
    activate.setImmediate(true);
    activate.addItem(DEACTIVATE);
    activate.addItem(RWACTIVATE);
    activate.addItem(ROACTIVATE);

    final boolean isActivated = model.isDeviceActive();
    if (isActivated) {
        final boolean isReadOnly = model.isDeviceReadOnly();
        if (isReadOnly) {
            activate.select(ROACTIVATE);
            // rw is not authorized, deactivate first
            activate.setItemEnabled(RWACTIVATE, false);
        } else {
            activate.select(RWACTIVATE);
            // ro is not authorized, deactivate first
            activate.setItemEnabled(ROACTIVATE, false);
        }
    } else {
        activate.select(DEACTIVATE);
    }

    activate.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(final ValueChangeEvent event) {
            final String valueString = String.valueOf(event.getProperty().getValue());

            if (valueString.equals(DEACTIVATE)) {
                final String action = DEACTIVATE;

                // Run activation in background
                WaitingComponent.executeBackground(model, new Background() {
                    @Override
                    public void processing() {
                        model.deActivateDevice();
                    }

                    @Override
                    public void postProcessing() {
                        activate.setItemEnabled(RWACTIVATE, true);
                        activate.setItemEnabled(ROACTIVATE, true);
                        updateAttributes();
                        Notification.show("Device " + action + "d", Notification.Type.TRAY_NOTIFICATION);
                    }
                });

            } else if (valueString.equals(RWACTIVATE)) {
                final String action = RWACTIVATE;
                WaitingComponent.executeBackground(model, new Background() {
                    @Override
                    public void processing() {
                        model.activateDeviceRW();
                    }

                    @Override
                    public void postProcessing() {
                        // ro is not authorized, deactivate first
                        activate.setItemEnabled(ROACTIVATE, false);
                        updateAttributes();
                        Notification.show("Device " + action + "d", Notification.Type.TRAY_NOTIFICATION);
                    }
                });
            } else if (valueString.equals(ROACTIVATE)) {
                final String action = ROACTIVATE;
                WaitingComponent.executeBackground(model, new Background() {
                    @Override
                    public void processing() {
                        model.activateDeviceRO();
                    }

                    @Override
                    public void postProcessing() {
                        // rw is not authorized, deactivate first
                        activate.setItemEnabled(RWACTIVATE, false);
                        updateAttributes();
                        Notification.show("Device " + action + "d", Notification.Type.TRAY_NOTIFICATION);
                    }
                });
            }

        }
    });

    return rootlayout;
}

From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java

License:Apache License

/**
 * Create delete tab in the accordion.//  ww  w .ja  va 2s .  c  om
 * 
 * @return the component.
 */
@SuppressWarnings("serial")
private final AbstractComponent createDelete() {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);

    final Label label = new Label("Deleting a snapshot can be done, only if it is not the root snapshot.");
    label.setWidth(null);
    layout.addComponent(label);
    layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    final Button deleteButton = new Button("Delete");

    if (model.getItemUuid().equals(model.getSnapshotParent())) {
        // Root snapshot can not be deleted
        deleteButton.setEnabled(false);
    }
    layout.addComponent(deleteButton);
    layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_CENTER);

    deleteButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final SnapshotDeleteWindow deleteWindow = new SnapshotDeleteWindow(model.getItemUuid());
                deleteWindow.add(model);
            } catch (final Exception e) {
                LOGGER.error("Can not delete snapshot:", e);
                final ErrorWindow err = new ErrorWindow("Snapshot not deleted: " + e.getMessage());
                err.add(model);
            }
        }
    });
    return layout;
}

From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java

License:Apache License

/**
 * Create the component to create a device.
 * /* w  w  w.  ja  v  a 2s  .  c o  m*/
 * @return the component
 */
@SuppressWarnings("serial")
private final AbstractComponent createDevice() {

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    final FormLayout createDeviceLayout = new FormLayout();
    createDeviceLayout.setMargin(true);
    createDeviceLayout.setWidth(null);
    createDeviceLayout.setImmediate(true);
    layout.addComponent(createDeviceLayout);
    layout.setComponentAlignment(createDeviceLayout, Alignment.MIDDLE_CENTER);

    // Enter name
    final TextField deviceName = new TextField("Name", "");
    createDeviceLayout.addComponent(deviceName);

    // Enter size
    final TextField deviceSize = new TextField("Size", "");
    createDeviceLayout.addComponent(deviceSize);

    // Create button
    final Button create = new Button("Create device");
    layout.addComponent(create);
    layout.setComponentAlignment(create, Alignment.MIDDLE_CENTER);

    create.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                model.createDevice(deviceName.getValue(), Long.valueOf(deviceSize.getValue()));
                Notification.show("New device created", Notification.Type.TRAY_NOTIFICATION);
            } catch (final NumberFormatException e) {
                final ErrorWindow err = new ErrorWindow("Size must be a valid number");
                err.add(model);
            } catch (final Exception e) {
                final ErrorWindow err = new ErrorWindow("Device not created: " + e.getMessage());
                err.add(model);
            }
        }
    });
    return layout;
}

From source file:com.oodrive.nuage.webui.component.window.AbstractConfirmationWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override//from ww  w  .ja  v a2s .c  om
public Window init(final AbstractItemModel model) {

    // Add new window
    final Window vvrConfirmationWindow = new Window("Confirmation");
    vvrConfirmationWindow.center();
    vvrConfirmationWindow.setResizable(false);
    final VerticalLayout vvrConfirmationLayout = new VerticalLayout();
    vvrConfirmationLayout.setMargin(true);
    vvrConfirmationWindow.setContent(vvrConfirmationLayout);

    // Message to display before buttons
    final Label confirmationMessage = new Label(confirmation);
    vvrConfirmationLayout.addComponent(confirmationMessage);
    vvrConfirmationLayout.setComponentAlignment(confirmationMessage, Alignment.MIDDLE_CENTER);
    vvrConfirmationLayout.setSpacing(true);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    vvrConfirmationLayout.addComponent(buttonLayout);
    // Button OK
    final Button okButton = new Button("OK");
    buttonLayout.setSizeFull();
    buttonLayout.addComponent(okButton);
    buttonLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                action.execute(model);
                vvrConfirmationWindow.close();
            } catch (final Exception e) {
                vvrConfirmationWindow.close();
            }
        }
    });

    // Button cancel
    final Button cancelButton = new Button("Cancel");
    buttonLayout.addComponent(cancelButton);
    buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);
    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrConfirmationWindow.close();
        }
    });
    return vvrConfirmationWindow;
}

From source file:com.oodrive.nuage.webui.component.window.ErrorWindow.java

License:Apache License

@SuppressWarnings("serial")
@Override// w w w  .  j a  va 2  s.  c  o m
public final Window init(final AbstractItemModel model) {
    // Add new window with title "Error"
    final Window vvrErrorWindow = new Window("Error");
    vvrErrorWindow.center();
    vvrErrorWindow.setResizable(false);
    final VerticalLayout vvrErrorLayout = new VerticalLayout();
    vvrErrorLayout.setMargin(true);
    vvrErrorWindow.setContent(vvrErrorLayout);

    // Display message
    final Label errorMessage = new Label(message);
    vvrErrorLayout.addComponent(errorMessage);
    vvrErrorLayout.setComponentAlignment(errorMessage, Alignment.MIDDLE_CENTER);
    vvrErrorLayout.setSpacing(true);

    // Button OK
    final Button okButton = new Button("OK");
    vvrErrorLayout.addComponent(okButton);
    vvrErrorLayout.setComponentAlignment(okButton, Alignment.BOTTOM_CENTER);
    okButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            // Just close the window
            vvrErrorWindow.close();
        }
    });
    return vvrErrorWindow;
}

From source file:com.openhris.administrator.ChangePassword.java

public ComponentContainer layout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);
    vlayout.setMargin(true);/*from  w  w  w .  ja va 2  s . c o  m*/
    vlayout.setSizeFull();
    vlayout.setImmediate(true);

    final PasswordField currentPassword = createPasswordField("Current Password: ");
    vlayout.addComponent(currentPassword);

    final PasswordField newPassword = createPasswordField("New Password: ");
    vlayout.addComponent(newPassword);

    final PasswordField rePassword = createPasswordField("Re-enter Password: ");
    vlayout.addComponent(rePassword);

    Button changeBtn = new Button("UPDATE PASSWORD");
    changeBtn.setWidth("100%");
    changeBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!adminService.checkEnteredPasswordIfCorrect(getUserId(),
                    currentPassword.getValue().toString().toLowerCase().trim())) {
                getWindow().showNotification("Incorrect Password, contact your Administrator!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            if (!newPassword.getValue().toString().toLowerCase().trim()
                    .equals(rePassword.getValue().toString().toLowerCase().trim())) {
                getWindow().showNotification("Entered Password do not Match!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            boolean result = adminService.updateUserPassword(getUserId(),
                    rePassword.getValue().toString().toLowerCase().trim());
            if (result) {
                GlobalVariables.setLogoutAfterPasswordChange(true);
                close();
            } else {
                GlobalVariables.setLogoutAfterPasswordChange(false);
                getWindow().showNotification("Change Password SQL Error!, Contact your DBA",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

        }
    });
    vlayout.addComponent(changeBtn);

    return vlayout;
}

From source file:com.openhris.calendar.CalendarScheduleWindow.java

VerticalLayout scheduleLayout() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//from   ww  w  .  jav a 2 s.co m
    layout.setSpacing(true);

    eventType = createEventTypelect();
    layout.addComponent(eventType);

    startDate = createDateField("Start Date: ");
    layout.addComponent(startDate);

    endDate = createDateField("End Date: ");
    layout.addComponent(endDate);

    caption = createTextField("Caption: ");
    layout.addComponent(caption);

    location = createTextField("Where: ");
    layout.addComponent(location);

    description = new TextArea("Description: ");
    description.setWidth("100%");
    description.setRows(3);
    layout.addComponent(description);

    color = createStyleNameSelect();
    layout.addComponent(color);

    saveEventButton = new Button("SAVE", saveEventBtnListener);
    saveEventButton.setWidth("100%");

    deleteEventButton = new Button("DELETE", deleteEventBtnListener);
    deleteEventButton.setWidth("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidth("100%");
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(saveEventButton);
    //        buttons.addComponent(editEventButton);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

    return layout;
}

From source file:com.openhris.calendar.CalendarScheduleWindow.java

VerticalLayout populateSchedule(CalendarComponentEvents.EventClick event) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*w  w w.  j  a v  a 2  s.c  om*/
    layout.setSpacing(true);

    eventType = createEventTypelect();
    eventType.setValue(basicEvent.getEventType());
    layout.addComponent(eventType);

    startDate = createDateField("Start Date: ");
    startDate.setValue(event.getCalendarEvent().getStart());
    layout.addComponent(startDate);

    endDate = createDateField("End Date: ");
    endDate.setValue(event.getCalendarEvent().getEnd());
    layout.addComponent(endDate);

    caption = createTextField("Caption: ");
    caption.setValue(event.getCalendarEvent().getCaption());
    layout.addComponent(caption);

    location = createTextField("Where: ");
    location.setValue(getBasicEvent().getLocation());
    layout.addComponent(location);

    description = new TextArea("Description: ");
    description.setWidth("100%");
    description.setRows(3);
    description.setValue(event.getCalendarEvent().getDescription());
    layout.addComponent(description);

    color = createStyleNameSelect();
    color.setValue(basicEvent.getStyleName());
    layout.addComponent(color);

    eventDataId = createTextField("id: ");
    eventDataId.setValue(getBasicEvent().getEventId());
    eventDataId.setVisible(false);
    layout.addComponent(eventDataId);

    editEventButton = new Button("EDIT", editEventBtnListener);
    editEventButton.setWidth("100%");

    deleteEventButton = new Button("DELETE", deleteEventBtnListener);
    deleteEventButton.setWidth("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidth("100%");
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(editEventButton);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

    return layout;
}

From source file:com.openhris.commons.AboutHris.java

public Window aboutHris() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);
    vlayout.setMargin(true);//from ww  w  .  j av  a2 s .  c  om

    final Window subWindow = new Window("About HRMS", vlayout);
    subWindow.setWidth("300px");

    Label version = new Label("Version: <b>1.0</b>");
    version.setContentMode(Label.CONTENT_XHTML);
    subWindow.addComponent(version);

    Label title = new Label("Title: <b>Human Resource Information System</b>");
    title.setContentMode(Label.CONTENT_XHTML);
    subWindow.addComponent(title);

    Label developer = new Label("Developed By: <b>Engr. Godfrey D. Beray</b>");
    developer.setContentMode(Label.CONTENT_XHTML);
    subWindow.addComponent(developer);

    Label framework = new Label("Framework: <b>VAADIN - Sept2012</b>");
    framework.setContentMode(Label.CONTENT_XHTML);
    subWindow.addComponent(framework);

    return subWindow;
}