Example usage for com.vaadin.ui HorizontalLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.lizardtech.expresszip.vaadin.ExportOptionsViewComponent.java

License:Apache License

public ExportOptionsViewComponent(ExportProps exportProps) {

    this.exportProps = exportProps;

    listeners = new ArrayList<ExportOptionsViewListener>();
    txtJobName = new TextField(JOB_NAME);
    txtEmail = new TextField(EMAIL_ADDRESS);
    txtUserNotation = new TextField(JOB_USER_NOTATION);
    numTilesLabel = new Label();
    exportSizeEstimate = new Label();
    outputFormatComboBox = new ComboBox(OUTPUT_FORMAT, OUTPUT_FORMATS);
    outputFormatComboBox.setTextInputAllowed(false);
    outputFormatComboBox.addListener(griddingValuesChangeListener);

    setSizeFull();//from w  w w  . jav a  2  s  .  c om

    /**
     * Setup output resolution
     */

    exportSizeComboBox = new ComboBox(null, exportSizes);
    exportSizeComboBox.setNullSelectionAllowed(false);
    exportSizeComboBox.setNewItemsAllowed(false);
    exportSizeComboBox.setTextInputAllowed(false);
    exportSizeComboBox.setImmediate(true);
    exportSizeComboBox.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Object choice = event.getProperty().getValue();
            String value = "";
            if (SMALL.equals(choice)) {
                gridCheckbox.setValue(Boolean.FALSE);
                gridCheckbox.setEnabled(false);
                value = "512";
            } else if (MEDIUM.equals(choice)) {
                gridCheckbox.setValue(Boolean.FALSE);
                gridCheckbox.setEnabled(false);
                value = "1280";
            } else if (LARGE.equals(choice)) {
                gridCheckbox.setValue(Boolean.FALSE);
                gridCheckbox.setEnabled(false);
                value = "5000";
            }

            boolean custom = CUSTOM.equals(choice);
            if (!custom) {
                if (NATIVE.equals(choice)) {
                    txtGroundResolution.setValue(Double.toString(maximumResolution));
                } else {
                    if (getExportProps().getAspectRatio() > 1.0d) {
                        txtDimHeight.setValue(value);
                    } else
                        txtDimWidth.setValue(value);
                }
            }

            txtDimWidth.setEnabled(custom);
            txtDimHeight.setEnabled(custom);
            txtGroundResolution.setEnabled(custom);
        }
    });

    // Add Output Resolution to view
    HorizontalLayout dimensionsLayout = new HorizontalLayout();
    dimensionsLayout.addComponent(txtDimWidth);
    dimensionsLayout.addComponent(txtDimHeight);
    dimensionsLayout.setSpacing(true);
    dimensionsLayout.setWidth("100%");

    // Format dimensions layout
    txtDimHeight.setMaxLength(10);
    txtDimHeight.setWidth("100%");
    txtDimHeight.setImmediate(true);
    txtDimHeight.addListener(heightValChangeListener);
    txtDimHeight.setRequired(true);
    txtDimHeight.addValidator(new WidthHeightValidator());

    txtDimWidth.setMaxLength(10);
    txtDimWidth.setWidth("100%");
    txtDimWidth.setImmediate(true);
    txtDimWidth.addListener(widthValChangeListener);
    txtDimWidth.setRequired(true);
    txtDimWidth.addValidator(new WidthHeightValidator());

    // Format Ground Resolution layout
    txtGroundResolution.setValue("0");
    txtGroundResolution.setImmediate(true);
    txtGroundResolution.addListener(groundResValChangeListener);
    txtGroundResolution.setRequired(true);
    txtGroundResolution.addValidator(new GroundResolutionValidator());

    vrtOutputResolution = new VerticalLayout();
    vrtOutputResolution.setSpacing(true);
    vrtOutputResolution.addComponent(exportSizeComboBox);
    vrtOutputResolution.addComponent(dimensionsLayout);
    txtGroundResolution.setWidth("75%");
    vrtOutputResolution.addComponent(txtGroundResolution);
    vrtOutputResolution.setComponentAlignment(txtGroundResolution, Alignment.BOTTOM_CENTER);

    /**
     * Setup Gridding options
     */

    // Add Gridding option to view
    griddingLayout = new VerticalLayout();
    griddingLayout.setSpacing(true);

    // Format GridCheckbox layout
    griddingLayout.addComponent(gridCheckbox);
    gridCheckbox.setImmediate(true);
    gridCheckbox.setValue(false);
    gridCheckbox.addListener(griddingModeChangeListener);

    xPixelsTextBox.setWidth("100%");
    xPixelsTextBox.setImmediate(true);
    xPixelsTextBox.addValidator(new TileWidthValidator());
    xPixelsTextBox.addListener(griddingValuesChangeListener);

    yPixelsTextBox.setWidth("100%");
    yPixelsTextBox.setImmediate(true);
    yPixelsTextBox.addValidator(new TileHeightValidator());
    yPixelsTextBox.addListener(griddingValuesChangeListener);

    xDistanceTextBox.setWidth("100%");
    xDistanceTextBox.setImmediate(true);
    xDistanceTextBox.addValidator(new TileGeoXValidator());
    xDistanceTextBox.addListener(griddingValuesChangeListener);

    yDistanceTextBox.setWidth("100%");
    yDistanceTextBox.setImmediate(true);
    yDistanceTextBox.addValidator(new TileGeoYValidator());
    yDistanceTextBox.addListener(griddingValuesChangeListener);

    // Format gridding options
    xTilesTextBox.setWidth("100%");
    xTilesTextBox.setImmediate(true);
    xTilesTextBox.addValidator(new TileXDivisorValidator());
    xTilesTextBox.addListener(griddingValuesChangeListener);

    yTilesTextBox.setWidth("100%");
    yTilesTextBox.setImmediate(true);
    yTilesTextBox.addValidator(new TileYDivisorValidator());
    yTilesTextBox.addListener(griddingValuesChangeListener);

    optGridOpt.setValue(GRID_TILE_DIMENSIONS);
    optGridOpt.setImmediate(true);
    optGridOpt.addListener(griddingModeChangeListener);

    HorizontalLayout hznGridOptions = new HorizontalLayout();
    griddingLayout.addComponent(hznGridOptions);
    hznGridOptions.setWidth("100%");
    hznGridOptions.setSpacing(true);
    hznGridOptions.addComponent(optGridOpt);

    VerticalLayout vrtGridComboFields = new VerticalLayout();
    hznGridOptions.addComponent(vrtGridComboFields);
    vrtGridComboFields.setWidth("100%");
    hznGridOptions.setExpandRatio(vrtGridComboFields, 1.0f);

    HorizontalLayout hznTileDim = new HorizontalLayout();
    hznTileDim.setWidth("100%");
    vrtGridComboFields.addComponent(hznTileDim);
    hznTileDim.addComponent(xPixelsTextBox);
    hznTileDim.addComponent(yPixelsTextBox);

    HorizontalLayout hznDistanceDim = new HorizontalLayout();
    hznDistanceDim.setWidth("100%");
    vrtGridComboFields.addComponent(hznDistanceDim);
    hznDistanceDim.addComponent(xDistanceTextBox);
    hznDistanceDim.addComponent(yDistanceTextBox);

    HorizontalLayout hznDivideGrid = new HorizontalLayout();
    hznDivideGrid.setWidth("100%");
    vrtGridComboFields.addComponent(hznDivideGrid);
    hznDivideGrid.addComponent(xTilesTextBox);
    hznDivideGrid.addComponent(yTilesTextBox);
    hznDivideGrid.setSpacing(true);
    hznTileDim.setSpacing(true);
    hznDistanceDim.setSpacing(true);

    /**
     * Format options panel
     */

    // Add Format options to view
    formatOptionsLayout = new VerticalLayout();
    formatOptionsLayout.setWidth("100%");
    formatOptionsLayout.setSpacing(true);
    formatOptionsLayout.setMargin(true);

    // Format outputformat
    formatOptionsLayout.addComponent(outputFormatComboBox);

    outputFormatComboBox.setNullSelectionAllowed(false);

    formatOptionsLayout.addComponent(packageComboBox);
    packageComboBox.addItem(ExportProps.OutputPackageFormat.TAR);
    packageComboBox.addItem(ExportProps.OutputPackageFormat.ZIP);
    packageComboBox.setNullSelectionAllowed(false);
    packageComboBox.setTextInputAllowed(false);
    packageComboBox.setValue(ExportProps.OutputPackageFormat.ZIP);

    /**
     * Job Details
     */

    // Set Jobname panel
    jobDetailsLayout = new VerticalLayout();
    jobDetailsLayout.setSpacing(true);
    jobDetailsLayout.setMargin(true);

    jobDetailsLayout.addComponent(txtJobName);
    txtJobName.setRequired(true);
    txtJobName.setRequiredError("Please enter a job name.");
    txtJobName.setWidth("100%");
    txtJobName.setImmediate(true);
    String jobname_regexp = "^[ A-Za-z0-9._-]{1,128}$";
    txtJobName.addValidator(new RegexpValidator(jobname_regexp,
            "Job names should be alpha-numeric, less than 128 characters and may include spaces, dashes and underscores"));
    txtJobName.addValidator(new JobNameUniqueValidator(
            "A job by that name already exists in your configured export directory"));
    txtJobName.addListener(resolutionValuesChangeListener);

    jobDetailsLayout.addComponent(txtUserNotation);
    txtUserNotation.setWidth("100%");
    txtUserNotation.setImmediate(true);
    String usernotation_regexp = "^[ A-Za-z0-9_-]{0,32}$";
    txtUserNotation.addValidator(new RegexpValidator(usernotation_regexp,
            "User names should be alpha-numeric, less than 32 characters and may include spaces, dashes and underscores"));
    txtUserNotation.addListener(resolutionValuesChangeListener);

    // Format Email
    boolean enableEmail = new BackgroundExecutor.Factory().getBackgroundExecutor().getMailServices()
            .isValidEmailConfig();
    txtEmail.setEnabled(enableEmail);
    if (enableEmail) {
        jobDetailsLayout.addComponent(txtEmail);
        txtEmail.setWidth("100%");
        txtEmail.setInputPrompt("enter your email address");
        txtEmail.setImmediate(true);
        txtEmail.addValidator(new EmailValidator("Invalid format for email address."));
        txtEmail.addListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                updateSubmitEnabledState();
            }
        });
    }

    VerticalLayout exportSummary = new VerticalLayout();
    exportSummary.addComponent(numTilesLabel);
    exportSummary.addComponent(exportSizeEstimate);
    jobDetailsLayout.addComponent(new Panel(("Export summary"), exportSummary));

    // Set submit and back buttons
    // Add listeners to all fields
    backButton = new ExpressZipButton("Back", Style.STEP);
    backButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            ((ExpressZipWindow) getApplication().getMainWindow()).regressToPrev();
        }
    });

    submitButton = new ExpressZipButton("Submit", Style.STEP);
    submitButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                txtJobName.validate();
            } catch (InvalidValueException e) {
                txtJobName.requestRepaint();
                updateSubmitEnabledState();
                return;
            }
            for (ExportOptionsViewListener listener : listeners) {
                listener.submitJobEvent(getExportProps());
            }
        }
    });

    accordian = new Accordion();
    accordian.addStyleName("expresszip");
    accordian.setImmediate(true);
    accordian.addTab(jobDetailsLayout, JOB_DETAILS);
    accordian.addTab(formatOptionsLayout, FORMAT_OPTIONS);
    accordian.setSizeFull();

    outputDetails = new VerticalLayout();
    outputDetails.setMargin(true);
    outputDetails.setSpacing(true);
    outputDetails.addComponent(new Panel(DIMENSIONS, vrtOutputResolution));
    outputDetails.addComponent(new Panel(TILING, griddingLayout));
    accordian.addTab(outputDetails, EXPORT_CONFIGURATION);

    HorizontalLayout backSubmitLayout = new HorizontalLayout();
    backSubmitLayout.setWidth("100%");
    backSubmitLayout.addComponent(backButton);
    backSubmitLayout.addComponent(submitButton);
    backSubmitLayout.setComponentAlignment(backButton, Alignment.BOTTOM_LEFT);
    backSubmitLayout.setComponentAlignment(submitButton, Alignment.BOTTOM_RIGHT);

    VerticalLayout navLayout = new VerticalLayout();
    navLayout.addComponent(backSubmitLayout);
    navLayout.setSpacing(true);

    ThemeResource banner = new ThemeResource("img/ProgressBar3.png");
    navLayout.addComponent(new Embedded(null, banner));

    // add scrollbars around formLayout
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSizeFull();
    layout.setSpacing(true);

    Label step = new Label("Step 3: Configure Export Options");
    step.addStyleName("step");
    layout.addComponent(step);

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

    layout.addComponent(navLayout);
    layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER);

    setCompositionRoot(layout);

    outputFormatComboBox.select(OUTPUT_FORMATS.get(0));

    forceGriddingCheck();
    updateGriddingEnabledState();
}

From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java

License:Apache License

public FindLayersViewComponent() {

    treeTable = new ExpressZipTreeTable();
    popupTable = new ExpressZipTreeTable();
    configureTable(treeTable);//from   www. ja  v a  2  s. co m

    popupSelectionListener = new Property.ValueChangeListener() {
        private static final long serialVersionUID = 625365970493526725L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // the current popup selection
            Set<ExpressZipLayer> popupSelection = (Set<ExpressZipLayer>) event.getProperty().getValue();

            // get the tree's current selection
            HashSet<ExpressZipLayer> treeSelection = new HashSet<ExpressZipLayer>(
                    (Set<ExpressZipLayer>) treeTable.getValue());

            // remove all items in common with popup
            treeSelection.removeAll(popupTable.getItemIds());

            // set the treeTable selection to the union
            Set<ExpressZipLayer> unionSelection = new HashSet<ExpressZipLayer>();
            unionSelection.addAll(popupSelection);
            unionSelection.addAll(treeSelection);
            treeTable.setValue(unionSelection);
        }
    };
    popupTable.addListener(popupSelectionListener);

    treeTable.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 6236114836521221107L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            Set<ExpressZipLayer> highlightedLayers = (Set<ExpressZipLayer>) event.getProperty().getValue();
            for (FindLayersViewListener listener : listeners) {
                listener.layerHighlightedEvent(highlightedLayers);
            }

            // reset selection of popup table
            popupTable.removeListener(popupSelectionListener);

            // intersection of treeTable's selection and popupTable items
            Set<ExpressZipLayer> popupSelection = new HashSet<ExpressZipLayer>();
            popupSelection.addAll(highlightedLayers);
            popupSelection.retainAll(popupTable.getItemIds());
            popupTable.setValue(popupSelection);

            popupTable.addListener(popupSelectionListener);
        }
    });
    configureTable(popupTable);

    filter = new Filter(this);
    filterButtonListener = new FilterListeners();
    axisSelectedListener = new AxisSelected();
    listeners = new ArrayList<FindLayersViewListener>();
    btnNext = new ExpressZipButton("Next", Style.STEP);
    btnBack = new ExpressZipButton("Back", Style.STEP);

    btnAddFilter = new ExpressZipButton("Add Filter", Style.ACTION);
    btnAddFilter.addStyleName("filter-flow");

    hshFilterButtons = new HashMap<Button, FilterObject>();
    cssLayers = new CssLayout();

    basemapSelector = new ComboBox();
    basemapSelector.setWidth(100.0f, UNITS_PERCENTAGE);
    basemapSelector.setTextInputAllowed(false);
    basemapSelector.setImmediate(true);
    basemapSelector.setNullSelectionAllowed(false);
    basemapSelector.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -7358667131762099215L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue();
            boolean enableCheckbox = false;
            if (l instanceof WebMapServiceLayer) {
                for (ExpressZipLayer local : mapModel.getLocalBaseLayers()) {
                    if (l.toString().equals(local.getName())) {
                        enableCheckbox = true;
                        break;
                    }
                }
            }
            includeBasemap.setEnabled(enableCheckbox);
            if (!enableCheckbox) {
                includeBasemap.setValue(false);
            }

            if (mapModel.getBaseLayerTerms(l) != null && !mapModel.getBaseLayerTermsAccepted(l)) {
                final Window modal = new Window("Terms of Use");
                modal.setModal(true);
                modal.setClosable(false);
                modal.setResizable(false);
                modal.getContent().setSizeUndefined(); // trick to size around content
                Button bOK = new ExpressZipButton("OK", Style.ACTION, new ClickListener() {
                    private static final long serialVersionUID = -2872178665349848542L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue();
                        mapModel.setBaseLayerTermsAccepted(l);
                        for (FindLayersViewListener listener : listeners)
                            listener.baseMapChanged(l);
                        ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal);
                    }
                });
                Button bCancel = new ExpressZipButton("Cancel", Style.ACTION, new ClickListener() {
                    private static final long serialVersionUID = -3044064554876422836L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        basemapSelector.select(mapModel.getBaseLayers().get(0));
                        ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal);
                    }
                });
                HorizontalLayout buttons = new HorizontalLayout();
                buttons.setSpacing(true);
                buttons.addComponent(bOK);
                buttons.addComponent(bCancel);
                Label termsText = new Label(mapModel.getBaseLayerTerms(l));
                termsText.setContentMode(Label.CONTENT_XHTML);
                VerticalLayout vlay = new VerticalLayout();
                vlay.addComponent(termsText);
                vlay.addComponent(buttons);
                vlay.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);
                vlay.setWidth(400, UNITS_PIXELS);
                modal.getContent().addComponent(vlay);
                ((ExpressZipWindow) getApplication().getMainWindow()).addWindow(modal);
            } else {
                for (FindLayersViewListener listener : listeners)
                    listener.baseMapChanged(l);
            }
        }
    });

    includeBasemap = new CheckBox();
    includeBasemap.setDescription("Include this basemap in the exported image.");
    includeBasemap.setWidth(64f, UNITS_PIXELS);

    HorizontalLayout basemapLayout = new HorizontalLayout();
    basemapLayout.setWidth(100f, UNITS_PERCENTAGE);

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

    Label step = new Label("Step 1: Select Layers");
    step.addStyleName("step");
    layout.addComponent(step);

    layout.addComponent(treeTable);
    layout.setSpacing(true);
    treeTable.setSizeFull();
    layout.setExpandRatio(treeTable, 1f);

    layout.addComponent(new Panel(BASEMAP, basemapLayout));
    basemapLayout.addComponent(basemapSelector);
    basemapLayout.setExpandRatio(basemapSelector, 1f);
    basemapLayout.addComponent(includeBasemap);

    layout.addComponent(cssLayers);
    cssLayers.addComponent(btnAddFilter);

    HorizontalLayout backSubmitLayout = new HorizontalLayout();
    backSubmitLayout.setWidth("100%");
    backSubmitLayout.addComponent(btnBack);
    backSubmitLayout.addComponent(btnNext);
    backSubmitLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_LEFT);
    backSubmitLayout.setComponentAlignment(btnNext, Alignment.BOTTOM_RIGHT);

    VerticalLayout navLayout = new VerticalLayout();
    navLayout.addComponent(backSubmitLayout);
    navLayout.setSpacing(true);

    ThemeResource banner = new ThemeResource("img/ProgressBar1.png");
    navLayout.addComponent(new Embedded(null, banner));

    layout.addComponent(navLayout);
    layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER);

    btnNext.addListener(this);
    btnNext.setEnabled(false);
    btnBack.setEnabled(false); // always disabled
    btnAddFilter.addListener(this);

    layout.addStyleName("findlayers");
    setCompositionRoot(layout);
}

From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java

License:Apache License

private void setupAddFilterWindow(Window window) {
    // General variables

    // Layouts//from w  w  w  .j  av  a  2 s . com
    GridLayout mainLayout = new GridLayout(1, 3);
    HorizontalLayout axisLayout = new HorizontalLayout();
    HorizontalLayout criteriaLayout = new HorizontalLayout();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    hznCriteria = criteriaLayout;

    // Buttons
    ExpressZipButton btnAdd = new ExpressZipButton("Add", Style.ACTION);
    btnAdd.setClickShortcut(KeyCode.ENTER);
    btnAdd.addStyleName("primary");
    ExpressZipButton btnCancel = new ExpressZipButton("Cancel", Style.ACTION);

    // Fields
    ComboBox cmbAxis = new ComboBox();
    cmbAxis.setTextInputAllowed(false);
    cmbAxis.setNullSelectionAllowed(false);

    // Labels
    Label lblAxis = new Label("Axis");

    btnAdd.addListener(filterButtonListener);
    btnCancel.addListener(filterButtonListener);

    for (Filter.AxisFilters f : Filter.axisArray) {
        cmbAxis.addItem(filter.getNameOfFilter(f));
    }
    cmbAxis.setImmediate(true);
    cmbAxis.addListener(axisSelectedListener);
    cmbAxis.setValue(filter.getNameOfFilter(Filter.axisArray[0]));

    mainLayout.addComponent(axisLayout, 0, 0);
    mainLayout.addComponent(criteriaLayout, 0, 1);
    mainLayout.addComponent(buttonLayout, 0, 2);
    mainLayout.setSpacing(true);

    axisLayout.setSpacing(true);

    axisLayout.addComponent(lblAxis);
    axisLayout.addComponent(cmbAxis);
    axisLayout.setExpandRatio(lblAxis, .2f);
    axisLayout.setExpandRatio(cmbAxis, .8f);
    axisLayout.setComponentAlignment(lblAxis, Alignment.MIDDLE_LEFT);
    axisLayout.setComponentAlignment(cmbAxis, Alignment.MIDDLE_LEFT);
    axisLayout.setSizeFull();

    criteriaLayout.setSizeFull();

    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(btnAdd);
    buttonLayout.addComponent(btnCancel);
    buttonLayout.setComponentAlignment(btnAdd, Alignment.BOTTOM_RIGHT);
    buttonLayout.setComponentAlignment(btnCancel, Alignment.BOTTOM_RIGHT);
    buttonLayout.setExpandRatio(btnAdd, 1f);
    buttonLayout.setExpandRatio(btnCancel, 0f);
    buttonLayout.setSizeFull();

    mainLayout.setRowExpandRatio(0, 1f);
    mainLayout.setRowExpandRatio(1, 1f);
    mainLayout.setRowExpandRatio(2, 1f);
    mainLayout.setSizeFull();

    window.addComponent(mainLayout);
    window.getContent().setSizeFull();
}

From source file:com.lizardtech.expresszip.vaadin.YesNoDialog.java

License:Apache License

public YesNoDialog(String caption, String question, Callback callback) {
    super(caption);

    setModal(true);//w w  w . j a va 2s .co m
    setWidth("350px");
    setHeight("150px");
    setClosable(false);
    setResizable(false);

    this.callback = callback;

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

    if (question != null) {
        layout.addComponent(new Label(question));
    }

    yes = new ExpressZipButton("Yes", ExpressZipButton.Style.ACTION, this);
    no = new ExpressZipButton("No", ExpressZipButton.Style.ACTION, this);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.addComponent(yes);
    hl.addComponent(no);
    layout.addComponent(hl);
    layout.setComponentAlignment(hl, Alignment.BOTTOM_RIGHT);

    setContent(layout);

}

From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    LspsUI ui = (LspsUI) getUI();/*from w  ww.j a va 2s.co  m*/
    Person user = ui.getUser().getPerson();
    userRights = user.getRights();

    setTitle(ui.getMessage(TITLE));

    Panel panel = new Panel();
    panel.addStyleName("l-border-none");
    setContent(panel);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    panel.setContent(layout);

    //user data and settings will be laid out next to each other
    HorizontalLayout topSection = new HorizontalLayout();
    topSection.setSpacing(true);
    topSection.setWidth("100%");
    layout.addComponent(topSection);

    VerticalLayout userData = createUserDataSection(ui, user);
    topSection.addComponent(userData);
    topSection.setExpandRatio(userData, 1);

    Label spacer = new Label();
    spacer.setWidth("20px");
    topSection.addComponent(spacer);

    VerticalLayout settings = createSettingsSection(ui);
    topSection.addComponent(settings);
    topSection.setExpandRatio(settings, 1);

    //substitution section
    VerticalLayout substitution = createSubstitutionSection(ui, user);
    layout.addComponent(substitution);

    Label spacer2 = new Label();
    spacer2.setHeight("10px");
    layout.addComponent(spacer2);

    //buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (save()) {
                if (requestReload) {
                    JavaScript.getCurrent().execute("window.location.reload()");
                } else {
                    close();
                }
            }
        }
    });
    saveButton.setData(BUTTON_TYPE_SAVE);
    buttons.addComponent(saveButton);
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
    layout.addComponent(buttons);
}

From source file:com.lst.deploymentautomation.vaadin.page.TodoListView.java

License:Open Source License

@SuppressWarnings("serial")
@Override//from   w  w w  . j ava  2s  .  c  om
protected Component createHeader(Component titleComponent) {
    LspsUI ui = (LspsUI) getUI();

    actionBtn = new MenuBar();
    actionBtn.addStyleName("menu-button-action");
    actionBtn.setVisible(false); //initially hidden
    MenuItem actions = actionBtn.addItem("", new ThemeResource("../icons/popup-menu.png"), null);

    final ViewAction refreshTodos = new ViewAction() {

        @Override
        public void invoke() {
            toggleSelectionMode(false);
            container.refresh();
        }
    };

    actions.addItem(ui.getMessage("action.lock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            lock();
        }
    });
    actions.addItem(ui.getMessage("action.annotate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoAnnotation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.unlock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            unlock();
        }
    });
    actions.addItem(ui.getMessage("action.reject") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoRejection(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.delegate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoDelegation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.escalate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoEscalation(getSelectedTodoIds(), refreshTodos));
        }
    });

    selectBtn = new Button(ui.getMessage("action.select"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(true);
        }
    });
    selectBtn.addStyleName("menu-button");

    cancelBtn = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(false);
        }
    });
    cancelBtn.setVisible(false); //initially hidden
    cancelBtn.addStyleName("menu-button");

    titleComponent.addStyleName("l-content-title");

    HorizontalLayout layout = new HorizontalLayout();
    HorizontalLayout btnLayout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.addComponent(titleComponent);
    layout.addComponent(btnLayout);
    layout.setSpacing(true);
    btnLayout.addComponent(actionBtn);
    btnLayout.addComponent(cancelBtn);
    btnLayout.addComponent(selectBtn);
    layout.setComponentAlignment(btnLayout, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoAnnotation.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();/*ww  w.j  a  v  a 2s.  co  m*/
    setCaption(ui.getMessage("todo.annotationTitle"));

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

    Label help = new Label(ui.getMessage("todo.annotationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    priorityField = new TextField(ui.getMessage("todo.priority"), priority);
    //TODO forbid negative priorities
    priorityField.setConverter(Integer.class);
    priorityField.setConversionError(ui.getMessage("app.invalidValueMessage"));
    priorityField.setNullRepresentation("");
    priorityField.setNullSettingAllowed(true);
    layout.addComponent(priorityField);

    TextArea notesField = new TextArea(ui.getMessage("todo.notes"), notes);
    notesField.setMaxLength(1024);
    notesField.setNullRepresentation("");
    priorityField.setNullSettingAllowed(true);
    notesField.setSizeFull();
    layout.addComponent(notesField);
    layout.setExpandRatio(notesField, 1);

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

    @SuppressWarnings("serial")
    Button submitButton = new Button(ui.getMessage("action.annotate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            annotate();
        }
    });
    buttons.addComponent(submitButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoDelegation.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();/*from  ww  w . ja  v  a 2s.c  om*/
    setCaption(ui.getMessage("todo.delegationTitle"));

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

    Label help = new Label(ui.getMessage("todo.delegationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    Collection<Person> allUsers = new ArrayList<Person>(
            personService.findPersons(new PersonCriteria()).getData());
    Set<Person> substitutes = ui.getUser().getPerson().getDirectSubstitutes();
    Set<String> substitutesIds = new HashSet<String>();
    for (Person p : substitutes) {
        substitutesIds.add(p.getId());
    }

    delegates = new OptionGroup(ui.getMessage("todo.delegates"));
    delegates.setMultiSelect(true);
    delegates.addStyleName("ui-spacing");
    delegates.setRequired(true);
    delegates.setSizeFull();
    for (Person p : allUsers) {
        delegates.addItem(p.getId());
        delegates.setItemCaption(p.getId(), p.getFullName());
    }
    delegates.setValue(substitutesIds);
    layout.addComponent(delegates);
    layout.setExpandRatio(delegates, 1);

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

    @SuppressWarnings("serial")
    Button delegateButton = new Button(ui.getMessage("action.delegate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            delegate();
        }
    });
    buttons.addComponent(delegateButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoEscalation.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();/*from w w w  .  j  av a 2s  .com*/
    setCaption(ui.getMessage("todo.escalationTitle"));

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

    Label help = new Label(ui.getMessage("todo.escalationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    reason = new TextArea(ui.getMessage("todo.escalationReason"));
    reason.setMaxLength(1024);
    reason.setRequired(true);
    reason.setSizeFull();
    layout.addComponent(reason);
    layout.setExpandRatio(reason, 1);

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

    @SuppressWarnings("serial")
    Button submitButton = new Button(ui.getMessage("action.escalate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            escalate();
        }
    });
    buttons.addComponent(submitButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoRejection.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();// ww  w  .  j  av  a 2s  .  com
    setCaption(ui.getMessage("todo.rejectionTitle"));

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

    Label help = new Label(ui.getMessage("todo.rejectionHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    reason = new TextArea(ui.getMessage("todo.rejectionReason"));
    reason.setMaxLength(1024);
    reason.setRequired(true);
    reason.setSizeFull();
    layout.addComponent(reason);
    layout.setExpandRatio(reason, 1);

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

    @SuppressWarnings("serial")
    Button rejectButton = new Button(ui.getMessage("action.reject"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            reject();
        }
    });
    buttons.addComponent(rejectButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}