Example usage for com.vaadin.ui Panel setContent

List of usage examples for com.vaadin.ui Panel setContent

Introduction

In this page you can find the example usage for com.vaadin.ui Panel setContent.

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:org.rubicone.poc.vpush.uil.sending.SendingUI.java

License:Apache License

private Panel createSentMessagesPanel() {
    Panel sentMessagesPanel = new Panel("sent messages");

    this.sentMessages = new VerticalLayout();

    sentMessagesPanel.setContent(this.sentMessages);

    return sentMessagesPanel;
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.WorkbenchWindowRenderer.java

License:Open Source License

@Override
public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
    if (element instanceof MWindow) {
        final MWindow mWindow = (MWindow) element;
        Component currentMainWindow = vaadinUI.getContent();
        if (element.getTags().contains(Tags.MAIN_WINDOW)) {
            Panel window = new Panel();
            window.setContent(new TrimmedWindowContent());
            vaadinUI.getPage().setTitle(mWindow.getLocalizedLabel());
            element.setWidget(window);//from  w ww . ja v a 2s .  co m
            ((MWindow) element).getContext().set(Panel.class, window);
            window.setSizeFull();

            vaadinUI.setContent(window);

            app.setSelectedElement(mWindow);
            mWindow.getContext().activate();
        } else {// case child windows
            if (currentMainWindow != null) {
                Window window = new Window();
                window.setContent(new TrimmedWindowContent());
                window.setImmediate(true);
                window.setPositionX(mWindow.getX());
                window.setPositionY(mWindow.getY());
                window.setWidth(mWindow.getWidth(), Unit.PIXELS);
                window.setHeight(mWindow.getHeight(), Unit.PIXELS);
                window.setCaption(mWindow.getLocalizedLabel());
                element.setWidget(window);
                ((MWindow) element).getContext().set(Panel.class, window);
                vaadinUI.addWindow(window);
            } else {
                throw new IllegalStateException(
                        "Can not add child window because application has not main window");
            }
        }

        IEclipseContext localContext = getContext(element);
        localContext.set(ISaveHandler.class, new ISaveHandler() {
            public Save promptToSave(MPart dirtyPart) {
                // Object[] elements =
                // promptForSave(Collections.singleton(dirtyPart));
                // if (elements == null) {
                // return Save.CANCEL;
                // }
                // return elements.length == 0 ? Save.NO : Save.YES;

                if (saveCandidate == null) {
                    saveCandidate = dirtyPart;

                    PartRenderer partRenderer = (PartRenderer) saveCandidate.getRenderer();
                    SavePromptSetup setup = partRenderer.getSavePromptSetup(saveCandidate);
                    String caption = setup.getCaption() != null ? setup.getCaption() : "Save";
                    String msg = setup.getMessage() != null ? setup.getMessage()
                            : String.format("%s has been modified. Save changes?",
                                    saveCandidate instanceof MInputPart
                                            ? ((MInputPart) saveCandidate).getInputURI()
                                            : "Data");

                    OptionDialog.show(vaadinUI, caption, msg, new String[] { "Yes", "No", "Cancel" }, 400, 80,
                            Component.UNITS_PIXELS, new OptionDialog.OptionListener() {

                                @Override
                                public void optionSelected(OptionDialog dlg, int optionId) {
                                    switch (optionId) {
                                    case 0:
                                        s = Save.YES;
                                        break;
                                    case 1:
                                        s = Save.NO;
                                        break;
                                    case 2:
                                        s = Save.CANCEL;
                                        break;

                                    default:
                                        s = null;
                                    }

                                    if (partService.savePart(saveCandidate, true)) {
                                        partService.hidePart(saveCandidate);
                                    }
                                    saveCandidate = null;
                                    dlg.close();
                                }
                            });

                    return Save.CANCEL;
                } else {
                    return s;
                }

            }

            public Save[] promptToSave(Collection<MPart> dirtyParts) {
                // List<MPart> parts = new ArrayList<MPart>(dirtyParts);
                //
                // Save[] response = new Save[dirtyParts.size()];
                // Object[] elements = promptForSave(parts);
                // if (elements == null) {
                // Arrays.fill(response, Save.CANCEL);
                // } else {
                // Arrays.fill(response, Save.NO);
                // for (int i = 0; i < elements.length; i++) {
                // response[parts.indexOf(elements[i])] = Save.YES;
                // }
                // }
                // return response;

                throw new RuntimeException("Multiple saving is not implemented yet");
            }
        });
    }
}

From source file:org.sensorhub.ui.DefaultModulePanelBuilder.java

License:Mozilla Public License

@Override
public Component buildPanel(MyBeanItem<ModuleConfig> beanItem, IModule<?> module,
        IModuleConfigFormBuilder formBuilder) {
    // create panel with module name
    String moduleType = formBuilder.getTitle(beanItem.getBean());
    Panel panel = new Panel(moduleType);

    // add generated form
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeUndefined();/*from  w w  w .  ja v  a2 s  .  c  om*/
    layout.setWidth(100.0f, Unit.PERCENTAGE);
    layout.setMargin(true);

    Component form = formBuilder.buildForm(new FieldGroup(beanItem));
    layout.addComponent(form);

    panel.setContent(layout);
    return panel;
}

From source file:org.sensorhub.ui.SensorAdminPanel.java

License:Mozilla Public License

protected Panel newPanel(String title) {
    Panel panel = new Panel(title);
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//  w  ww.j a v  a  2  s  . c  o m
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    panel.setContent(layout);
    return panel;
}

From source file:org.sensorhub.ui.SensorPanelBuilder.java

License:Mozilla Public License

@Override
public Component buildPanel(MyBeanItem<ModuleConfig> beanItem, IModule<?> module,
        IModuleConfigFormBuilder formBuilder) {
    ModuleConfig moduleConfig = beanItem.getBean();

    // create panel with module name
    String moduleName = beanItem.getBean().name + " (" + beanItem.getBean().moduleClass + ")";
    Panel panel = new Panel(moduleName);

    // add generated form
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeUndefined();/*w ww .j a v  a  2 s .  c  o m*/
    layout.setMargin(true);

    Component form = formBuilder.buildForm(new FieldGroup(beanItem));
    layout.addComponent(form);

    // only if module is loaded and started
    if (module != null && module.isEnabled()) {

    }

    panel.setContent(layout);
    return panel;
}

From source file:org.sensorhub.ui.StorageAdminPanel.java

License:Mozilla Public License

protected Panel newPanel(String title) {
    Panel panel = new Panel(title);
    GridLayout layout = new GridLayout(2, 2);
    layout.setWidth(100.0f, Unit.PERCENTAGE);
    layout.setMargin(true);//from   www . j  a v  a2 s .c  o m
    layout.setSpacing(true);
    layout.setColumnExpandRatio(0, 0.2f);
    layout.setColumnExpandRatio(1, 0.8f);
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    panel.setContent(layout);
    return panel;
}

From source file:org.sensorhub.ui.SWECommonFormBuilder.java

License:Mozilla Public License

public Panel buildForm(DataComponent dataComponent) {
    FormLayout layout = new FormLayout();

    for (int i = 0; i < dataComponent.getComponentCount(); i++) {
        DataComponent c = dataComponent.getComponent(i);
        Component w = buildWidget(c);
        if (w != null)
            layout.addComponent(w);//from   www .jav  a 2  s. com
    }

    Panel panel = new Panel();
    panel.setContent(layout);
    return panel;
}

From source file:org.sensorhub.ui.SWECommonFormBuilder.java

License:Mozilla Public License

protected Component buildWidget(DataComponent dataComponent) {
    if (dataComponent instanceof DataRecord) {
        DataRecord dataRecord = (DataRecord) dataComponent;
        FormLayout layout = new FormLayout();

        for (int i = 0; i < dataRecord.getComponentCount(); i++) {
            DataComponent c = dataRecord.getComponent(i);
            Component w = buildWidget(c);
            if (w != null)
                layout.addComponent(w);/*from w  w w  .j  a v a 2  s. c om*/
        }

        Panel panel = new Panel();
        panel.setCaption(getPrettyName(dataComponent));
        panel.setContent(layout);
        return panel;
    }

    else if (dataComponent instanceof DataArray) {
        DataArray dataArray = (DataArray) dataComponent;
        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(new Label(getPrettyName(dataArray)));
        layout.addComponent(buildWidget(dataArray.getElementType()));
        return layout;
    }

    else if (dataComponent instanceof DataChoice) {

    }

    else if (dataComponent instanceof Quantity) {
        Label c = new Label();
        c.setCaption(getPrettyName(dataComponent));
        c.setDescription(dataComponent.getDescription());
        return c;
    }

    return null;
}

From source file:org.tltv.gantt.demo.DemoUI.java

License:Apache License

private Panel createControls() {
    Panel panel = new Panel();
    panel.setWidth(100, Unit.PERCENTAGE);

    controls = new HorizontalLayout();
    controls.setSpacing(true);/*from  ww w .jav  a  2 s  .com*/
    controls.setMargin(true);
    panel.setContent(controls);

    start = createStartDateField();
    end = createEndDateField();

    Button createStep = new Button("Create New Step...", createStepClickListener);

    HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt),
            Util.createHeightUnitEditor(gantt));

    HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt),
            Util.createWidthUnitEditor(gantt));

    reso = new NativeSelect("Resolution");
    reso.setNullSelectionAllowed(false);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Day);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Week);
    reso.setValue(gantt.getResolution());
    reso.setImmediate(true);
    reso.addValueChangeListener(resolutionValueChangeListener);

    localeSelect = new NativeSelect("Locale") {
        @Override
        public void attach() {
            super.attach();

            if (getValue() == null) {
                // use default locale
                setValue(gantt.getLocale());
                addValueChangeListener(localeValueChangeListener);
            }
        }
    };
    localeSelect.setNullSelectionAllowed(false);
    for (Locale l : Locale.getAvailableLocales()) {
        localeSelect.addItem(l);
        localeSelect.setItemCaption(l, l.getDisplayName(getLocale()));
    }
    localeSelect.setImmediate(true);

    String[] zones = new String[] { "GMT-0", "GMT-1", "GMT-2", "GMT-3", "GMT-4", "GMT-5", "GMT-6", "GMT-7",
            "GMT-8", "GMT-9", "GMT-10", "GMT-11", "GMT-12", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5",
            "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11", "GMT+12", "GMT+13", "GMT+14" };
    NativeSelect timezoneSelect = new NativeSelect("Timezone");
    timezoneSelect.setNullSelectionAllowed(false);
    timezoneSelect.addItem("Default");
    timezoneSelect.setItemCaption("Default", "Default (" + TimeZone.getDefault().getDisplayName() + ")");
    for (String timezoneId : zones) {
        TimeZone tz = TimeZone.getTimeZone(timezoneId);
        timezoneSelect.addItem(timezoneId);
        timezoneSelect.setItemCaption(timezoneId, tz.getDisplayName(getLocale()));
    }
    timezoneSelect.setValue("Default");
    timezoneSelect.setImmediate(true);
    timezoneSelect.addValueChangeListener(timezoneValueChangeListener);

    controls.addComponent(start);
    controls.addComponent(end);
    controls.addComponent(reso);
    controls.addComponent(localeSelect);
    controls.addComponent(timezoneSelect);
    controls.addComponent(heightAndUnit);
    controls.addComponent(widthAndUnit);
    controls.addComponent(createStep);
    controls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT);

    return panel;
}

From source file:org.vaadin.addons.criteriacontainersample.AbstractBeanTupleApplication.java

License:Apache License

/**
 * @param mainWindow the window in which the panel should appear
 * @param filterPanel the panel with an input field and a button.
 *//*from  w  w  w  .  j  a v a  2  s .com*/
private void createTopPanel(Window mainWindow, Panel filterPanel) {
    filterPanel.addStyleName(Runo.PANEL_LIGHT);
    HorizontalLayout filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);
    filterLayout.setSpacing(true);
    filterPanel.setContent(filterLayout);
    mainWindow.addComponent(filterPanel);

    Panel buttonPanel = new Panel();
    buttonPanel.addStyleName(Runo.PANEL_LIGHT);
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setMargin(false);
    buttonLayout.setSpacing(true);
    buttonPanel.setContent(buttonLayout);
    mainWindow.addComponent(buttonPanel);

    Panel buttonPanel2 = new Panel();
    buttonPanel2.addStyleName(Runo.PANEL_LIGHT);
    HorizontalLayout buttonLayout2 = new HorizontalLayout();
    buttonLayout2.setMargin(false);
    buttonLayout2.setSpacing(true);
    buttonPanel2.setContent(buttonLayout2);
    mainWindow.addComponent(buttonPanel2);

    nameFilterField = new TextField("Name");
    filterPanel.addComponent(nameFilterField);

    refreshButton = new Button("Refresh");
    refreshButton.addListener(this);
    buttonPanel.addComponent(refreshButton);

    editButton = new Button("Edit");
    editButton.addListener(this);
    buttonPanel.addComponent(editButton);

    saveButton = new Button("Save");
    saveButton.addListener(this);
    saveButton.setEnabled(false);
    buttonPanel2.addComponent(saveButton);

    cancelButton = new Button("Cancel");
    cancelButton.addListener(this);
    cancelButton.setEnabled(false);
    buttonPanel2.addComponent(cancelButton);
}