Example usage for com.vaadin.ui VerticalLayout setSizeFull

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

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:eu.lod2.stat.dsdrepo.DSDRepoComponentWrapper.java

private void refresh() {
    mainContainer.removeAllComponents();
    String currentGraph = state.getCurrentGraph();
    if (currentGraph == null || currentGraph.isEmpty()) {
        VerticalLayout l = new VerticalLayout();
        l.setSizeFull();
        mainContainer.addComponent(l);//from ww  w .  jav  a2s  .  c  om
        Label message = new Label("No graph is currently selected. You can select one below:");
        l.addComponent(message);
        l.setExpandRatio(message, 0.0f);
        ConfigurationTab config = new ConfigurationTab(this.state);
        l.addComponent(config);
        l.setExpandRatio(config, 2.0f);
        l.setComponentAlignment(message, Alignment.TOP_LEFT);
        l.setComponentAlignment(config, Alignment.TOP_LEFT);

        return;
    }

    mainContainer.addComponent(new DSDRepoComponent(state.getRdfStore(), currentGraph));
}

From source file:eu.maxschuster.vaadin.buttonlink.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout wrapper = new VerticalLayout();
    wrapper.setSizeFull();
    setContent(wrapper);/*ww  w  . ja  v  a  2  s  .  c  o  m*/

    // Show it in the middle of the screen
    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeUndefined();
    wrapper.addComponent(layout);
    wrapper.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

    final Label themeName = new Label();
    themeName.setCaption("Current Theme:");
    themeName.addStyleName("h1");
    layout.addComponent(themeName);

    Label waring = new Label("<strong>Attention:</strong><br />\nChanging the theme may take a few seconds!");
    waring.setContentMode(ContentMode.HTML);
    layout.addComponent(waring);

    getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {

        @Override
        public void uriFragmentChanged(UriFragmentChangedEvent event) {
            String fragment = event.getUriFragment().replace("!", "");
            if (fragment.isEmpty()) {
                fragment = defaultTheme;
            }
            loadTheme(fragment);
        }
    });

    themeSelect.setSizeFull();
    themeSelect.setNullSelectionAllowed(false);
    themeSelect.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            String fragment = "!" + themeSelect.getValue();
            getPage().setUriFragment(fragment);
        }
    });
    layout.addComponent(themeSelect);
    layout.setComponentAlignment(themeSelect, Alignment.BOTTOM_CENTER);

    final CheckBox useIcon = new CheckBox("Use icons");
    useIcon.setValue(false);
    layout.addComponent(useIcon);

    final HorizontalLayout comparsionLayout = new HorizontalLayout();
    comparsionLayout.setSpacing(true);
    layout.addComponent(comparsionLayout);
    layout.setComponentAlignment(comparsionLayout, Alignment.TOP_CENTER);

    final Button button = new Button("This is a \"normal\" Button", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("Hello World!");
        }
    });
    comparsionLayout.addComponent(button);
    comparsionLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

    // Initialize our new UI component
    final ButtonLink buttonLink = new ButtonLink("This is a ButtonLink",
            new ExternalResource("https://vaadin.com"));
    buttonLink.setTargetName("_blank");
    buttonLink.setDescription("Visit vaadin.com in a new tab or window.");
    buttonLink.addStyleName("test-stylename");
    comparsionLayout.addComponent(buttonLink);
    comparsionLayout.setComponentAlignment(buttonLink, Alignment.MIDDLE_LEFT);

    themeName.setPropertyDataSource(themeSelect);

    useIcon.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean b = (Boolean) event.getProperty().getValue();
            if (b) {
                button.setIcon(vaadinIcon, "Vaadin Logo");
                buttonLink.setIcon(vaadinIcon, "Vaadin Logo");
            } else {
                button.setIcon(null);
                buttonLink.setIcon(null);
            }
        }
    });

    String fragment = getPage().getUriFragment();

    loadTheme(
            fragment == null || fragment.replace("!", "").isEmpty() ? defaultTheme : fragment.replace("!", ""));
}

From source file:eu.maxschuster.vaadin.localstorage.test.LocalStorageUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    final LocalStorageItemCallback callback = new LocalStorageItemCallback() {

        /*//from  w  ww.  ja  v a2  s. c  om
         * (non-Javadoc)
         * @see eu.maxschuster.vaadin.localstorage.shared.LocalStorageItemCallback#onSussess(java.lang.String, java.lang.String, java.lang.String)
         */
        @Override
        public void onSuccess(LocalStorageItem item) {
            appendToLog("Success:\n" + item);
        }

        /*
         * (non-Javadoc)
         * @see eu.maxschuster.vaadin.localstorage.shared.LocalStorageItemCallback#onError()
         */
        @Override
        public void onError(String key) {
            appendToLog("ERROR for item \"" + key + "\" (simulateNotSupported="
                    + LocalStorage.getCurrent().isSimulateNotSupported() + ")");
        }

    };

    final ItemUpdateListener itemUpdateListener = new ItemUpdateListener() {

        @Override
        public void onUpdate(ItemUpdateEvent event) {
            appendToLog("Update (type=" + event.getType() + "):\n" + event.getItem());
        }

    };

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

    final HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    layout.addComponent(topLayout);
    layout.setExpandRatio(topLayout, 0);

    Button button = new Button("Start", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            appendToLog("Start localStorage test:");

            LocalStorage localStorage = LocalStorage.getCurrent();

            localStorage.setItem("remove", "REMOVE ME!");

            localStorage.setItem("test", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", callback);

            localStorage.removeItem("remove");

            localStorage.setItem("test", "Duis commodo.", callback);

            localStorage.getItem("test", callback);

            localStorage.getItem("remove", callback);

        }
    });
    topLayout.addComponent(button);

    Button clearButton = new Button("Clear localStorage", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            LocalStorage.getCurrent().clear(callback);
        }

    });

    CheckBox fireUpdateCheckBox = new CheckBox("Fire update events");
    fireUpdateCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            if (value)
                LocalStorage.getCurrent().addItemUpdateListener(itemUpdateListener);
            else
                LocalStorage.getCurrent().removeItemUpdateListener(itemUpdateListener);
        }

    });

    CheckBox simulateNotSupportedCheckbox = new CheckBox("Simulate not supported");
    simulateNotSupportedCheckbox.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            LocalStorage.getCurrent().setSimulateNotSupported((Boolean) event.getProperty().getValue());
        }
    });

    topLayout.addComponents(clearButton, fireUpdateCheckBox, simulateNotSupportedCheckbox);

    log.setSizeFull();
    log.setReadOnly(true);
    layout.addComponent(log);
    layout.setExpandRatio(log, 1);

}

From source file:eu.maxschuster.vaadin.signaturefield.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    getPage().setTitle(pageTitle);/* w  w  w .  ja v a2  s .c  om*/

    final VerticalLayout margin = new VerticalLayout();
    setContent(margin);

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("658px");
    margin.addComponent(layout);
    margin.setComponentAlignment(layout, Alignment.TOP_CENTER);

    final Label header1 = new Label(pageTitle);
    header1.addStyleName("h1");
    header1.setSizeUndefined();
    layout.addComponent(header1);
    layout.setComponentAlignment(header1, Alignment.TOP_CENTER);

    final TabSheet tabSheet = new TabSheet();
    tabSheet.setWidth("100%");
    layout.addComponent(tabSheet);
    layout.setComponentAlignment(tabSheet, Alignment.TOP_CENTER);

    final Panel signaturePanel = new Panel();
    signaturePanel.addStyleName("signature-panel");
    signaturePanel.setWidth("100%");
    tabSheet.addTab(signaturePanel, "Demo");

    final VerticalLayout signatureLayout = new VerticalLayout();
    signatureLayout.setMargin(true);
    signatureLayout.setSpacing(true);
    signatureLayout.setSizeFull();
    signaturePanel.setContent(signatureLayout);

    final SignatureField signatureField = new SignatureField();
    signatureField.setWidth("100%");
    signatureField.setHeight("318px");
    signatureField.setPenColor(Color.ULTRAMARINE);
    signatureField.setBackgroundColor("white");
    signatureField.setConverter(new StringToDataUrlConverter());
    signatureField.setPropertyDataSource(dataUrlProperty);
    signatureField.setVelocityFilterWeight(0.7);
    signatureLayout.addComponent(signatureField);
    signatureLayout.setComponentAlignment(signatureField, Alignment.MIDDLE_CENTER);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");
    signatureLayout.addComponent(buttonLayout);

    final Button clearButton = new Button("Clear", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            signatureField.clear();
        }
    });
    buttonLayout.addComponent(clearButton);
    buttonLayout.setComponentAlignment(clearButton, Alignment.MIDDLE_LEFT);

    final Label message = new Label("Sign above");
    message.setSizeUndefined();
    buttonLayout.addComponent(message);
    buttonLayout.setComponentAlignment(message, Alignment.MIDDLE_CENTER);

    final ButtonLink saveButtonLink = new ButtonLink("Save", null);
    saveButtonLink.setTargetName("_blank");
    buttonLayout.addComponent(saveButtonLink);
    buttonLayout.setComponentAlignment(saveButtonLink, Alignment.MIDDLE_RIGHT);

    final Panel optionsPanel = new Panel();
    optionsPanel.setSizeFull();
    tabSheet.addTab(optionsPanel, "Options");

    final FormLayout optionsLayout = new FormLayout();
    optionsLayout.setMargin(true);
    optionsLayout.setSpacing(true);
    optionsPanel.setContent(optionsLayout);

    final ComboBox mimeTypeComboBox = new ComboBox(null, mimeTypeContainer);
    optionsLayout.addComponent(mimeTypeComboBox);
    mimeTypeComboBox.setItemCaptionPropertyId("mimeType");
    mimeTypeComboBox.setNullSelectionAllowed(false);
    mimeTypeComboBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            MimeType mimeType = (MimeType) event.getProperty().getValue();
            signatureField.setMimeType(mimeType);
        }
    });
    mimeTypeComboBox.setValue(MimeType.PNG);
    mimeTypeComboBox.setCaption("Result MIME-Type");

    final CheckBox immediateCheckBox = new CheckBox("immediate", false);
    optionsLayout.addComponent(immediateCheckBox);
    immediateCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean immediate = (Boolean) event.getProperty().getValue();
            signatureField.setImmediate(immediate);
        }
    });

    final CheckBox readOnlyCheckBox = new CheckBox("readOnly", false);
    optionsLayout.addComponent(readOnlyCheckBox);
    readOnlyCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean readOnly = (Boolean) event.getProperty().getValue();
            signatureField.setReadOnly(readOnly);
            mimeTypeComboBox.setReadOnly(readOnly);
            clearButton.setEnabled(!readOnly);
        }
    });

    final CheckBox requiredCheckBox = new CheckBox("required (causes bug that clears field)", false);
    optionsLayout.addComponent(requiredCheckBox);
    requiredCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean required = (Boolean) event.getProperty().getValue();
            signatureField.setRequired(required);
        }
    });

    final CheckBox clearButtonEnabledButton = new CheckBox("clearButtonEnabled", false);
    optionsLayout.addComponent(clearButtonEnabledButton);
    clearButtonEnabledButton.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean clearButtonEnabled = (Boolean) event.getProperty().getValue();
            signatureField.setClearButtonEnabled(clearButtonEnabled);
        }
    });

    final Panel resultPanel = new Panel("Results:");
    resultPanel.setWidth("100%");
    layout.addComponent(resultPanel);

    final VerticalLayout resultLayout = new VerticalLayout();
    resultLayout.setMargin(true);
    resultPanel.setContent(resultLayout);

    final Image stringPreviewImage = new Image("String preview image:");
    stringPreviewImage.setWidth("500px");
    resultLayout.addComponent(stringPreviewImage);

    final Image dataUrlPreviewImage = new Image("DataURL preview image:");
    dataUrlPreviewImage.setWidth("500px");
    resultLayout.addComponent(dataUrlPreviewImage);

    final TextArea textArea = new TextArea("DataURL:");
    textArea.setWidth("100%");
    textArea.setHeight("300px");
    resultLayout.addComponent(textArea);

    final Label emptyLabel = new Label();
    emptyLabel.setCaption("Is Empty:");
    emptyLabel.setValue(String.valueOf(signatureField.isEmpty()));
    resultLayout.addComponent(emptyLabel);

    signatureField.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            String signature = (String) event.getProperty().getValue();
            stringPreviewImage.setSource(signature != null ? new ExternalResource(signature) : null);
            textArea.setValue(signature);
            emptyLabel.setValue(String.valueOf(signatureField.isEmpty()));
        }
    });
    dataUrlProperty.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            try {
                final DataUrl signature = (DataUrl) event.getProperty().getValue();
                dataUrlPreviewImage.setSource(
                        signature != null ? new ExternalResource(serializer.serialize(signature)) : null);
                StreamResource streamResource = null;
                if (signature != null) {
                    StreamSource streamSource = new StreamSource() {

                        @Override
                        public InputStream getStream() {
                            return new ByteArrayInputStream(signature.getData());
                        }
                    };
                    MimeType mimeType = MimeType.valueOfMimeType(signature.getMimeType());
                    String extension = null;

                    switch (mimeType) {
                    case JPEG:
                        extension = "jpg";
                        break;
                    case PNG:
                        extension = "png";
                        break;
                    }

                    streamResource = new StreamResource(streamSource, "signature." + extension);
                    streamResource.setMIMEType(signature.getMimeType());
                    streamResource.setCacheTime(0);
                }
                saveButtonLink.setResource(streamResource);
            } catch (MalformedURLException e) {
                logger.error(e.getMessage(), e);
            }
        }
    });
}

From source file:fi.jasoft.draganddrop.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    Panel showcase = new Panel();
    showcase.setSizeUndefined();/* w  w  w .  java  2  s  .co m*/

    navigator = new Navigator(this, showcase);

    for (DemoView view : views) {
        navigator.addView(view.getViewPath(), view);
    }

    // default
    openView(views.get(0));

    MenuBar demos = new MenuBar();
    demos.setStyleName(ValoTheme.MENUBAR_BORDERLESS);

    for (final DemoView view : views) {
        demos.addItem(view.getViewCaption(), new Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {
                openView(view);
            }
        });
    }

    VerticalLayout root = new VerticalLayout(demos, showcase);
    root.setSizeFull();
    root.setExpandRatio(showcase, 1);
    root.setComponentAlignment(showcase, Alignment.MIDDLE_CENTER);
    setContent(root);

    HorizontalLayout sourceWrapperLayout = new HorizontalLayout();
    Label caption = new Label("Source code for example");
    caption.setStyleName("source-caption");
    sourceWrapperLayout.addComponent(caption);

    Panel sourceWrapper = new Panel(codeLabel);
    sourceWrapper.setStyleName(ValoTheme.PANEL_BORDERLESS);
    sourceWrapper.setHeight(getPage().getBrowserWindowHeight() + "px");
    sourceWrapperLayout.addComponent(sourceWrapper);
    sourceWrapperLayout.setExpandRatio(sourceWrapper, 1);

    Toolbox sourceBox = new Toolbox();
    sourceBox.setOrientation(ORIENTATION.RIGHT_CENTER);
    sourceBox.setContent(sourceWrapperLayout);
    sourceBox.setOverflowSize(30);
    root.addComponent(sourceBox);
}

From source file:fi.jasoft.dragdroplayouts.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();
    setContent(content);/*from  w  w w  .  j a v a2 s.  c  o  m*/

    Label header = new Label("DragDropLayouts for Vaadin 8");
    header.setStyleName(ValoTheme.LABEL_H1);
    content.addComponent(header);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeFull();
    content.addComponent(hl);
    content.setExpandRatio(hl, 1);

    VerticalSplitPanel split = new VerticalSplitPanel();
    hl.addComponent(split);
    hl.setExpandRatio(split, 1);

    CssLayout placeHolder = new CssLayout(new Label("No view selected."));
    placeHolder.setSizeFull();
    split.setFirstComponent(placeHolder);

    Panel codePanel = new Panel(codeLabel);
    codePanel.setSizeFull();
    split.setSecondComponent(codePanel);

    navigator = new Navigator(this, placeHolder);

    navigator.addViewChangeListener(new ViewChangeListener() {

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
            DemoView view = (DemoView) event.getNewView();
            selection.getSelectionModel().select(view);
            codeLabel.setValue(getFormattedSourceCode(view.getSource()));
            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
            // TODO Auto-generated method stub

        }
    });

    try {
        addView(new DragdropAbsoluteLayoutDemo(navigator));
        addView(new DragdropVerticalLayoutDemo(navigator));
        addView(new DragdropHorizontalLayoutDemo(navigator));
        addView(new DragdropGridLayoutDemo(navigator));
        addView(new DragdropCssLayoutDemo(navigator));
        addView(new DragdropFormLayoutDemo(navigator));
        addView(new DragdropPanelDemo(navigator));

        addView(new DragdropLayoutDraggingDemo(navigator));
        addView(new DragdropHorizontalSplitPanelDemo(navigator));
        addView(new DragdropVerticalSplitPanelDemo(navigator));
        addView(new DragdropTabsheetDemo(navigator));
        addView(new DragdropAccordionDemo(navigator));

        addView(new DragdropDragFilterDemo(navigator));
        addView(new DragdropCaptionModeDemo(navigator));

        addView(new DragdropV7VerticalLayoutDemo(navigator));
        addView(new DragdropV7HorizontalLayoutDemo(navigator));

        // addView(new DragdropIframeDragging(navigator));

    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    hl.addComponent(selection = createViewSelection(), 0);

    String fragment = Page.getCurrent().getUriFragment();
    if (fragment == null || fragment.equals("")) {
        navigator.navigateTo(DragdropAbsoluteLayoutDemo.NAME);
    }
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropAccordionDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    v.setSpacing(true);//from   w ww  .  ja  va  2  s . co  m

    Label lb = new Label(
            "This demo shows you how you can drag components into a Accordion and reorder the tabs. "
                    + "Try dragging some Buttons on to the accordion to add them as tabs. You can "
                    + "reorder the tabs by dragging on them");
    v.addComponent(lb);

    // Add some buttons to a vertical layout with dragging enabled
    final DDHorizontalLayout btns = new DDHorizontalLayout();
    btns.setSpacing(true);
    btns.setDragMode(LayoutDragMode.CLONE);
    btns.addComponent(new Button("One Button"));
    btns.addComponent(new Button("Second Button"));
    btns.addComponent(new Button("Third Button"));
    btns.addComponent(new Button("Fourth Button"));
    btns.addComponent(new Button("Fifth Button"));
    v.addComponent(btns);

    // Create an Accordion
    final DDAccordion acc = new DDAccordion();
    acc.setSizeFull();

    acc.setDragMode(LayoutDragMode.CLONE);

    acc.setComponentVerticalDropRatio(EQUAL_DROP_RATIO);

    acc.setDropHandler(new DefaultAccordionDropHandler());

    // Add a tab to the accordion
    VerticalLayout layout = new VerticalLayout();
    layout.setCaption("Tab 1");
    layout.addComponent(new Label("This is an example tab already in the accordion."));
    acc.addComponent(layout);

    layout = new VerticalLayout();
    layout.setCaption("Tab 2");
    layout.addComponent(new Label("This is an example tab already in the accordion."));
    acc.addComponent(layout);

    layout = new VerticalLayout();
    layout.setCaption("Tab 3");
    layout.addComponent(new Label("This is an example tab already in the accordion."));
    acc.addComponent(layout);

    v.addComponent(acc);
    v.setExpandRatio(acc, 1);

    // end-source
    return v;
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropTabsheetDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    v.setSpacing(true);//from  w  w w  . j av a2  s . co  m

    Label lb = new Label(
            "This demo shows you how you can drag components into a tabsheet and reorder the tabs. "
                    + "Try dragging some Buttons into the tab area to add them as tabs. You can then "
                    + "reorder the tabs by dragging on them");
    v.addComponent(lb);

    // Add some buttons to a vertical layout with dragging enabled
    final DDHorizontalLayout btns = new DDHorizontalLayout();
    btns.setSpacing(true);
    btns.setDragMode(LayoutDragMode.CLONE);
    btns.addComponent(new Button("One Button"));
    btns.addComponent(new Button("Second Button"));
    btns.addComponent(new Button("Third Button"));
    btns.addComponent(new Button("Fourth Button"));
    btns.addComponent(new Button("Fifth Button"));
    v.addComponent(btns);

    // Create a tabsheet
    final DDTabSheet tabSheet = new DDTabSheet();
    tabSheet.setSizeFull();

    // Add a tab
    VerticalLayout layout = new VerticalLayout();
    layout.setCaption("Example");
    layout.addComponent(new Label("This is an example tab already in the tabsheet."));
    tabSheet.addComponent(layout);

    // Enable dragging
    tabSheet.setDragMode(LayoutDragMode.CLONE);

    // Enable dropping
    tabSheet.setDropHandler(new DefaultTabSheetDropHandler());

    v.addComponent(tabSheet);
    v.setExpandRatio(tabSheet, 1);
    // end-source
    return v;
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropVerticalSplitPanelDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    VerticalLayout root = new VerticalLayout();
    root.setSpacing(true);// ww w  .  ja v  a  2 s .  co  m
    root.setSizeFull();

    Label lbl = new Label("On top are some buttons, and below them is a vertical split panel. "
            + "Try dragging the buttons on to the splitpanel. If a component already exists in the SplitPanel it is replaced with the dragged one.");
    root.addComponent(lbl);

    // Add some buttons to a vertical layout with dragging enabled
    final DDHorizontalLayout btns = new DDHorizontalLayout();
    btns.setSpacing(true);
    btns.setDragMode(LayoutDragMode.CLONE);
    String caption = "Button ";
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    root.addComponent(btns);

    // Create a drag & drop horizontal split panel
    final DDVerticalSplitPanel panel = new DDVerticalSplitPanel();
    panel.setSizeFull();

    root.addComponent(panel);
    root.setExpandRatio(panel, 1);

    // Enable dragging
    panel.setDragMode(LayoutDragMode.CLONE);

    // Enable dropping
    panel.setDropHandler(new DefaultVerticalSplitPanelDropHandler());
    // end-source
    return root;
}

From source file:fi.jasoft.feedreader.ui.AddFeedWindow.java

License:Apache License

/**
 * Default constructor// w w w. j  a  v  a  2  s.co m
 */
public AddFeedWindow() {
    setModal(true);
    setWidth("300px");
    setHeight("100px");
    setResizable(false);
    setDraggable(false);
    setCaption("Add RSS/Atom Feed");

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

    url = new TextField("Feed url");
    url.setWidth("100%");
    windowContent.addComponent(url);
    windowContent.setComponentAlignment(url, Alignment.MIDDLE_CENTER);

    HorizontalLayout buttons = new HorizontalLayout();

    buttons.addComponent(new Button("Add", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (validateUrl(url.getValue())) {
                close();
            } else {
                Notification.show("URL not valid");
            }
        }
    }));

    buttons.addComponent(new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            url.setValue(null);
            close();
        }
    }));

    windowContent.addComponent(buttons);
    windowContent.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

    windowContent.setExpandRatio(url, 1);
}