Example usage for com.vaadin.ui Alignment BOTTOM_LEFT

List of usage examples for com.vaadin.ui Alignment BOTTOM_LEFT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment BOTTOM_LEFT.

Prototype

Alignment BOTTOM_LEFT

To view the source code for com.vaadin.ui Alignment BOTTOM_LEFT.

Click 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  ww w. j  ava2 s.c  o  m

    /**
     * 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);//w  w  w. ja  v a  2s .  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.SetupMapViewComponent.java

License:Apache License

public SetupMapViewComponent() {

    listeners = new ArrayList<SetupMapViewListener>();
    cmbProjection = new ComboBox();
    cmbProjection.setTextInputAllowed(false);
    HorizontalLayout projectionLayout = new HorizontalLayout();
    projectionLayout.addComponent(cmbProjection);
    projectionLayout.setWidth(100f, UNITS_PERCENTAGE);

    setSizeFull();/*w w  w  . j  a  v  a2 s.c  o m*/

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

    // instruction banner
    Label step = new Label("Step 2: Select Export Region");
    step.addStyleName("step");
    layout.addComponent(step);

    //
    // setup tree data source
    //
    treeHier = new HierarchicalContainer();
    treeHier.addContainerProperty(ExpressZipTreeTable.LAYER, ExpressZipLayer.class, null);
    treeHier.addContainerProperty(DRAG_PROPERTY, Embedded.class, null);

    // table holding layers
    treeTable = new ExpressZipTreeTable();
    treeTable.setContainerDataSource(treeHier);

    treeTable.setDragMode(TableDragMode.ROW);
    treeTable.setColumnHeaders(new String[] { ExpressZipTreeTable.LAYER, "" });
    treeTable.setColumnExpandRatio(ExpressZipTreeTable.LAYER, 1);
    treeTable.setColumnWidth(DRAG_PROPERTY, 23);

    // upload shape file
    btnUploadShapeFile.setFieldType(FieldType.BYTE_ARRAY);
    btnUploadShapeFile.setButtonCaption("");
    btnUploadShapeFile.setSizeUndefined();
    btnUploadShapeFile.addStyleName("shapefile");

    // remove shape file
    btnRemoveShapeFile.addListener(this);
    btnRemoveShapeFile.setSizeUndefined();
    btnRemoveShapeFile.setVisible(false);
    btnRemoveShapeFile.setIcon(new ThemeResource("img/RemoveShapefileStandard23px.png"));
    btnRemoveShapeFile.setStyleName(BaseTheme.BUTTON_LINK);
    btnRemoveShapeFile.addStyleName("shapefile");
    HorizontalLayout hznUpload = new HorizontalLayout();

    Panel coordPanel = new Panel("Export Extent");

    layout.addComponent(treeTable);
    layout.addComponent(new Panel(PROJECTION, projectionLayout));
    layout.addComponent(new Panel(SHAPEFILE_UPLOAD, hznUpload));
    layout.addComponent(coordPanel);

    layout.setSpacing(true);

    hznUpload.addComponent(btnUploadShapeFile);
    hznUpload.addComponent(btnRemoveShapeFile);
    hznUpload.addComponent(lblCurrentShapeFile);
    hznUpload.setExpandRatio(lblCurrentShapeFile, 1f);
    hznUpload.setComponentAlignment(lblCurrentShapeFile, Alignment.MIDDLE_LEFT);
    hznUpload.setWidth("100%");

    cmbProjection.setWidth("100%");

    topTextField.setWidth(150, UNITS_PIXELS);
    topTextField.setImmediate(true);
    topTextField.setRequired(true);
    topTextField.addListener(topListener);

    leftTextField.setWidth(150, UNITS_PIXELS);
    leftTextField.setImmediate(true);
    leftTextField.setRequired(true);
    leftTextField.addListener(leftListener);

    bottomTextField.setWidth(150, UNITS_PIXELS);
    bottomTextField.setImmediate(true);
    bottomTextField.setRequired(true);
    bottomTextField.addListener(bottomListener);

    rightTextField.setWidth(150, UNITS_PIXELS);
    rightTextField.setImmediate(true);
    rightTextField.setRequired(true);
    rightTextField.addListener(rightListener);

    VerticalLayout coordLayout = new VerticalLayout();
    coordLayout.setSizeFull();
    coordPanel.setContent(coordLayout);
    coordLayout.addComponent(topTextField);

    HorizontalLayout leftRightLayout = new HorizontalLayout();
    leftRightLayout.setWidth("100%");
    leftRightLayout.addComponent(leftTextField);
    leftRightLayout.addComponent(rightTextField);
    leftRightLayout.setComponentAlignment(leftTextField, Alignment.MIDDLE_LEFT);
    leftRightLayout.setComponentAlignment(rightTextField, Alignment.MIDDLE_RIGHT);
    coordLayout.addComponent(leftRightLayout);

    coordLayout.addComponent(bottomTextField);
    coordLayout.setComponentAlignment(topTextField, Alignment.TOP_CENTER);
    coordLayout.setComponentAlignment(bottomTextField, Alignment.BOTTOM_CENTER);

    btnNext = new ExpressZipButton("Next", Style.STEP, this);
    btnBack = new ExpressZipButton("Back", Style.STEP, this);

    HorizontalLayout backNextLayout = new HorizontalLayout();
    backNextLayout.addComponent(btnBack);
    backNextLayout.addComponent(btnNext);
    btnNext.setEnabled(false);

    backNextLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_LEFT);
    backNextLayout.setComponentAlignment(btnNext, Alignment.BOTTOM_RIGHT);
    backNextLayout.setWidth("100%");

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

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

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

    layout.setExpandRatio(treeTable, 1.0f);
    setCompositionRoot(layout);

    // notify when selection changes
    treeTable.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            for (SetupMapViewListener listener : listeners) {
                listener.layersSelectedEvent((Set<ExpressZipLayer>) treeTable.getValue());
            }

        }
    });
    treeTable.addActionHandler(this);
    treeHier.removeAllItems();

    //
    // drag n' drop behavior
    //
    treeTable.setDropHandler(new DropHandler() {
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        // Make sure the drag source is the same tree
        public void drop(DragAndDropEvent event) {
            // Wrapper for the object that is dragged
            Transferable t = event.getTransferable();

            // Make sure the drag source is the same tree
            if (t.getSourceComponent() != treeTable)
                return;

            AbstractSelectTargetDetails target = (AbstractSelectTargetDetails) event.getTargetDetails();

            // Get ids of the dragged item and the target item
            Object sourceItemId = t.getData("itemId");
            Object targetItemId = target.getItemIdOver();

            // if we drop on ourselves, ignore
            if (sourceItemId == targetItemId)
                return;

            // On which side of the target the item was dropped
            VerticalDropLocation location = target.getDropLocation();

            // place source after target
            treeHier.moveAfterSibling(sourceItemId, targetItemId);

            // if top, switch them
            if (location == VerticalDropLocation.TOP) {
                treeHier.moveAfterSibling(targetItemId, sourceItemId);
            }

            Collection<ExpressZipLayer> layers = (Collection<ExpressZipLayer>) treeHier.rootItemIds();
            for (SetupMapViewListener listener : listeners)
                listener.layerMovedEvent(layers);
        }
    });

    cmbProjection.setImmediate(true);
    cmbProjection.setNullSelectionAllowed(false);
    cmbProjection.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -5188369735622627751L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (cmbProjection.getValue() != null) {
                selectedEpsg = (String) cmbProjection.getValue();
                String currentProjection = ((ExpressZipWindow) getApplication().getMainWindow())
                        .getExportProps().getMapProjection();
                if (!selectedEpsg.equals(currentProjection))
                    for (SetupMapViewListener listener : new ArrayList<SetupMapViewListener>(listeners))
                        listener.projectionChangedEvent(selectedEpsg);
            }
        }
    });
}

From source file:com.mechanicshop.components.TableLayout.java

private void buildLayout() {
    HorizontalLayout layoutTitle = new HorizontalLayout();
    layoutTitle.setSizeUndefined();//from   www.  ja  v a2  s.com
    layoutTitle.setWidth("100%");
    layoutTitle.setSpacing(false);
    layoutTitle.setMargin(false);
    titleLabel.addStyleName(ValoTheme.LABEL_H2);
    titleLabel.addStyleName(ValoTheme.LABEL_COLORED);
    titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    titleLabel.setSizeUndefined();

    layoutTitle.addComponent(titleLabel);
    layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout layoutTable = new VerticalLayout();

    layoutTable.addComponent(table);
    layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER);
    layoutTable.setSizeFull();

    layoutTable.setSpacing(true);
    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    layoutButtons.setSpacing(true);
    layoutButtons.setSizeUndefined();
    layoutButtons.setWidth("100%");
    Button addBtn = new Button("Add new Car");
    addBtn.addClickListener(addBtnListener);
    addBtn.setImmediate(true);
    addBtn.setStyleName(ValoTheme.BUTTON_TINY);
    addBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button deleteBtn = new Button("Delete Selected");
    deleteBtn.setStyleName(ValoTheme.BUTTON_TINY);
    deleteBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    deleteBtn.setImmediate(true);
    deleteBtn.addClickListener(removeListener);

    btnSendSMS.setStyleName(ValoTheme.BUTTON_TINY);
    btnSendSMS.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    btnSendSMS.setImmediate(true);
    btnSendSMS.addClickListener(sendSMSBtnListener);

    searchTextField.setImmediate(true);
    searchTextField.addStyleName(ValoTheme.TEXTFIELD_TINY);
    searchTextField.addTextChangeListener(filterChangeListener);
    Label lbSearch = new Label("Search");
    lbSearch.addStyleName(ValoTheme.LABEL_TINY);
    lbSearch.setSizeUndefined();
    layoutButtons.addComponents(lbSearch, searchTextField, addBtn, deleteBtn, btnSendSMS);

    layoutButtons.setComponentAlignment(lbSearch, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(searchTextField, Alignment.BOTTOM_LEFT);
    layoutButtons.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT);
    layoutButtons.setComponentAlignment(deleteBtn, Alignment.BOTTOM_RIGHT);
    layoutButtons.setComponentAlignment(btnSendSMS, Alignment.BOTTOM_RIGHT);
    layoutButtons.setExpandRatio(addBtn, 3);
    addComponent(layoutTitle);
    addComponent(layoutTable);
    layoutTable.addComponent(layoutButtons);
    layoutTable.setExpandRatio(table, 3);
    setComponentAlignment(layoutTitle, Alignment.TOP_CENTER);
    setComponentAlignment(layoutTable, Alignment.TOP_CENTER);
    setExpandRatio(layoutTable, 3);
    setSpacing(true);
    setMargin(true);

}

From source file:com.mycollab.community.shell.view.components.AboutWindow.java

License:Open Source License

public AboutWindow() {

    MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
    this.setContent(content);

    Image about = new Image("",
            new ExternalResource(StorageFactory.generateAssetRelativeLink(WebResourceIds._about)));
    MVerticalLayout rightPanel = new MVerticalLayout();
    ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion()));
    Label javaNameLbl = new Label(String.format("%s, %s", System.getProperty("java.vm.name"),
            System.getProperty("java.runtime.version")));
    Label homeFolderLbl = new Label("Home folder: " + FileUtils.getHomeFolder().getAbsolutePath());
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    Label osLbl = new Label(
            String.format("%s, %s", System.getProperty("os.name"), browser.getBrowserApplication()));
    osLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    Div licenseDiv = new Div().appendChild(new Text("Powered by: "))
            .appendChild(new A("https://www.mycollab.com").appendText("MyCollab"))
            .appendChild(new Text(". Open source under GPL license"));
    Label licenseLbl = new Label(licenseDiv.write(), ContentMode.HTML);
    Label copyRightLbl = new Label(String.format("&copy; %s - %s MyCollab Ltd. All rights reserved", "2011",
            new GregorianCalendar().get(Calendar.YEAR) + ""), ContentMode.HTML);
    rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl)
            .withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
    content.with(about, rightPanel).expand(rightPanel);
}

From source file:com.mycollab.module.crm.view.CrmModule.java

License:Open Source License

@Override
public MHorizontalLayout buildMenu() {
    if (serviceMenuContainer == null) {
        serviceMenuContainer = new MHorizontalLayout();
        serviceMenu = new ServiceMenu();
        serviceMenu.addService(CrmTypeConstants.DASHBOARD,
                UserUIContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DASHBOARD_HEADER),
                clickEvent -> EventBusFactory.getInstance().post(new CrmEvent.GotoHome(this, null)));

        serviceMenu.addService(CrmTypeConstants.ACCOUNT, UserUIContext.getMessage(AccountI18nEnum.LIST),
                clickEvent -> EventBusFactory.getInstance().post(new AccountEvent.GotoList(this, null)));

        serviceMenu.addService(CrmTypeConstants.CONTACT, UserUIContext.getMessage(ContactI18nEnum.LIST),
                clickEvent -> EventBusFactory.getInstance().post(new ContactEvent.GotoList(this, null)));

        serviceMenu.addService(CrmTypeConstants.LEAD, UserUIContext.getMessage(LeadI18nEnum.LIST),
                clickEvent -> EventBusFactory.getInstance().post(new LeadEvent.GotoList(this, null)));

        serviceMenu.addService(CrmTypeConstants.CAMPAIGN, UserUIContext.getMessage(CampaignI18nEnum.LIST),
                clickEvent -> EventBusFactory.getInstance().post(new CampaignEvent.GotoList(this, null)));

        serviceMenu.addService(CrmTypeConstants.OPPORTUNITY, UserUIContext.getMessage(OpportunityI18nEnum.LIST),
                clickEvent -> EventBusFactory.getInstance().post(new OpportunityEvent.GotoList(this, null)));

        serviceMenu.addService(CrmTypeConstants.CASE, UserUIContext.getMessage(CaseI18nEnum.LIST),
                clickEvent -> EventBusFactory.getInstance().post(new CaseEvent.GotoList(this, null)));

        serviceMenuContainer.with(serviceMenu);

        Button.ClickListener listener = new CreateItemListener();

        addPopupMenu = new PopupButton(UserUIContext.getMessage(GenericI18Enum.ACTION_NEW));
        addPopupMenu.setIcon(FontAwesome.PLUS_CIRCLE);
        addPopupMenu.addStyleName("add-btn-popup");
        addPopupMenu.setDirection(Alignment.BOTTOM_LEFT);
        OptionPopupContent popupButtonsControl = new OptionPopupContent();

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_ACCOUNT)) {
            Button newAccountBtn = new Button(UserUIContext.getMessage(AccountI18nEnum.SINGLE), listener);
            newAccountBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT));
            popupButtonsControl.addOption(newAccountBtn);
        }//  w  w w  . j av  a  2  s.  c  o m

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_CONTACT)) {
            Button newContactBtn = new Button(UserUIContext.getMessage(ContactI18nEnum.SINGLE), listener);
            newContactBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
            popupButtonsControl.addOption(newContactBtn);
        }

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_CAMPAIGN)) {
            Button newCampaignBtn = new Button(UserUIContext.getMessage(CampaignI18nEnum.SINGLE), listener);
            newCampaignBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CAMPAIGN));
            popupButtonsControl.addOption(newCampaignBtn);
        }

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY)) {
            Button newOpportunityBtn = new Button(UserUIContext.getMessage(OpportunityI18nEnum.SINGLE),
                    listener);
            newOpportunityBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
            popupButtonsControl.addOption(newOpportunityBtn);
        }

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_LEAD)) {
            Button newLeadBtn = new Button(UserUIContext.getMessage(LeadI18nEnum.SINGLE), listener);
            newLeadBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD));
            popupButtonsControl.addOption(newLeadBtn);
        }

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_CASE)) {
            Button newCaseBtn = new Button(UserUIContext.getMessage(CaseI18nEnum.SINGLE), listener);
            newCaseBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CASE));
            popupButtonsControl.addOption(newCaseBtn);
        }

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_TASK)) {
            Button newTaskBtn = new Button(UserUIContext.getMessage(TaskI18nEnum.SINGLE), listener);
            newTaskBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK));
            popupButtonsControl.addOption(newTaskBtn);
        }

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_CALL)) {
            Button newCallBtn = new Button(UserUIContext.getMessage(CallI18nEnum.SINGLE), listener);
            newCallBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL));
            popupButtonsControl.addOption(newCallBtn);
        }

        if (UserUIContext.canWrite(RolePermissionCollections.CRM_MEETING)) {
            Button newMeetingBtn = new Button(UserUIContext.getMessage(MeetingI18nEnum.SINGLE), listener);
            newMeetingBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING));
            popupButtonsControl.addOption(newMeetingBtn);
        }

        if (popupButtonsControl.getComponentCount() > 0) {
            addPopupMenu.setContent(popupButtonsControl);
            serviceMenuContainer.with(addPopupMenu).withAlign(addPopupMenu, Alignment.MIDDLE_LEFT);
        }
    }
    return serviceMenuContainer;
}

From source file:com.mycollab.module.crm.view.setting.CrmNotificationSettingViewImpl.java

License:Open Source License

@Override
public void showNotificationSettings(final CrmNotificationSetting notification) {
    this.removeAllComponents();

    MVerticalLayout bodyWrapper = new MVerticalLayout();
    bodyWrapper.setSizeFull();/*  ww  w  .  ja va2 s. c o  m*/

    MVerticalLayout body = new MVerticalLayout().withMargin(new MarginInfo(true, false, false, false));

    final OptionGroup optionGroup = new OptionGroup(null);
    optionGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);

    optionGroup.addItem(NotificationType.Default.name());
    optionGroup.setItemCaption(NotificationType.Default.name(),
            UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING));

    optionGroup.addItem(NotificationType.None.name());
    optionGroup.setItemCaption(NotificationType.None.name(),
            UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING));

    optionGroup.addItem(NotificationType.Minimal.name());
    optionGroup.setItemCaption(NotificationType.Minimal.name(),
            UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING));

    optionGroup.addItem(NotificationType.Full.name());
    optionGroup.setItemCaption(NotificationType.Full.name(),
            UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING));

    optionGroup.setHeight("100%");

    body.with(optionGroup).withAlign(optionGroup, Alignment.MIDDLE_LEFT).expand(optionGroup);

    String levelVal = notification.getLevel();
    if (levelVal == null) {
        optionGroup.select(NotificationType.Default.name());
    } else {
        optionGroup.select(levelVal);
    }

    Button updateBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_UPDATE_LABEL), clickEvent -> {
        try {
            notification.setLevel((String) optionGroup.getValue());
            CrmNotificationSettingService crmNotificationSettingService = AppContextUtil
                    .getSpringBean(CrmNotificationSettingService.class);
            if (notification.getId() == null) {
                crmNotificationSettingService.saveWithSession(notification, UserUIContext.getUsername());
            } else {
                crmNotificationSettingService.updateWithSession(notification, UserUIContext.getUsername());
            }
            NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_CONGRATS),
                    UserUIContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS));
        } catch (Exception e) {
            throw new MyCollabException(e);
        }
    }).withIcon(FontAwesome.REFRESH).withStyleName(WebThemes.BUTTON_ACTION);
    body.with(updateBtn).withAlign(updateBtn, Alignment.BOTTOM_LEFT);

    bodyWrapper.addComponent(body);
    this.addComponent(bodyWrapper);
}

From source file:com.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java

License:Open Source License

private void buildShortcutIconPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    Label logoDesc = new Label(UserUIContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION));
    leftPanel.with(logoDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    final Image favIconRes = new Image("", new ExternalResource(
            StorageFactory.getFavIconPath(billingAccount.getId(), billingAccount.getFaviconpath())));

    MHorizontalLayout buttonControls = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
    final UploadField favIconUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override//from  w  ww .  ja  v  a  2  s . c om
        protected void updateDisplay() {
            byte[] imageData = (byte[]) this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(
                            UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                try {
                    AccountFavIconService favIconService = AppContextUtil
                            .getSpringBean(AccountFavIconService.class);
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData));
                    String newFavIconPath = favIconService.upload(UserUIContext.getUsername(), image,
                            MyCollabUI.getAccountId());
                    favIconRes.setSource(new ExternalResource(
                            StorageFactory.getFavIconPath(billingAccount.getId(), newFavIconPath)));
                    Page.getCurrent().getJavaScript().execute("window.location.reload();");
                } catch (IOException e) {
                    throw new MyCollabException(e);
                }
            } else {
                throw new UserInvalidInputException(
                        UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    favIconUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    favIconUploadField.addStyleName("upload-field");
    favIconUploadField.setSizeUndefined();
    favIconUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY);
    favIconUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccount.setFaviconpath(null);
        billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername());
        Page.getCurrent().getJavaScript().execute("window.location.reload();");
    }).withStyleName(WebThemes.BUTTON_OPTION);
    resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    buttonControls.with(resetButton, favIconUploadField);
    rightPanel.with(favIconRes, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Favicon", layout);
    this.with(formContainer);
}

From source file:com.mycollab.shell.view.AbstractMainView.java

License:Open Source License

private CustomLayout createTopMenu() {
    headerLayout = CustomLayoutExt.createLayout("topNavigation");
    headerLayout.setStyleName("topNavigation");
    headerLayout.setHeight("45px");
    headerLayout.setWidth("100%");

    final PopupButton modulePopup = new PopupButton("");
    modulePopup.setIcon(/*from   www . j a v a  2s  . co m*/
            AccountAssetsResolver.createLogoResource(MyCollabUI.getBillingAccount().getLogopath(), 150));
    modulePopup.setHeightUndefined();
    modulePopup.setDirection(Alignment.BOTTOM_LEFT);
    OptionPopupContent modulePopupContent = new OptionPopupContent();
    modulePopup.setContent(modulePopupContent);

    MButton projectModuleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            clickEvent -> {
                modulePopup.setPopupVisible(false);
                EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
            }).withIcon(VaadinIcons.TASKS);
    modulePopupContent.addOption(projectModuleBtn);

    MButton crmModuleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
    }).withIcon(VaadinIcons.MONEY);
    modulePopupContent.addOption(crmModuleBtn);

    /*MButton fileModuleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), clickEvent -> {
    modulePopup.setPopupVisible(false);
    EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
    }).withIcon(VaadinIcons.SUITCASE);
    modulePopupContent.addOption(fileModuleBtn);*/

    MButton peopleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_PEOPLE), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
    }).withIcon(VaadinIcons.USERS);
    modulePopupContent.addOption(peopleBtn);

    headerLayout.addComponent(
            new MHorizontalLayout(modulePopup).alignAll(Alignment.MIDDLE_LEFT).withFullHeight(), "mainLogo");

    accountLayout = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, false))
            .withHeight("45px");
    accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buildAccountMenuLayout();

    headerLayout.addComponent(accountLayout, "accountMenu");
    return headerLayout;
}

From source file:com.mycollab.shell.view.MainViewImpl.java

License:Open Source License

private CustomLayout createTopMenu() {
    headerLayout = CustomLayoutExt.createLayout("topNavigation");
    headerLayout.setStyleName("topNavigation");
    headerLayout.setHeight("45px");
    headerLayout.setWidth("100%");

    final PopupButton modulePopup = new PopupButton("");

    modulePopup.setHeightUndefined();//from ww  w .  j a  va  2s  . co m
    modulePopup.setDirection(Alignment.BOTTOM_LEFT);
    modulePopup.setIcon(
            AccountAssetsResolver.createLogoResource(AppContext.getBillingAccount().getLogopath(), 150));
    OptionPopupContent modulePopupContent = new OptionPopupContent();
    modulePopup.setContent(modulePopupContent);

    MButton projectModuleBtn = new MButton(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
    }).withIcon(VaadinIcons.TASKS);
    modulePopupContent.addOption(projectModuleBtn);

    MButton crmModuleBtn = new MButton(AppContext.getMessage(GenericI18Enum.MODULE_CRM), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
    }).withIcon(VaadinIcons.MONEY);
    modulePopupContent.addOption(crmModuleBtn);

    MButton fileModuleBtn = new MButton(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
    }).withIcon(VaadinIcons.SUITCASE);
    modulePopupContent.addOption(fileModuleBtn);

    MButton peopleBtn = new MButton(AppContext.getMessage(GenericI18Enum.MODULE_PEOPLE), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
    }).withIcon(VaadinIcons.USERS);
    modulePopupContent.addOption(peopleBtn);

    headerLayout.addComponent(
            new MHorizontalLayout().with(modulePopup).withAlign(modulePopup, Alignment.MIDDLE_LEFT),
            "mainLogo");

    accountLayout = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, false))
            .withHeight("45px");
    accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buildAccountMenuLayout();

    headerLayout.addComponent(accountLayout, "accountMenu");
    return headerLayout;
}