Example usage for com.vaadin.ui Accordion Accordion

List of usage examples for com.vaadin.ui Accordion Accordion

Introduction

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

Prototype

public Accordion() 

Source Link

Document

Creates an empty accordion.

Usage

From source file:org.jumpmind.metl.ui.views.design.EditFlowPalette.java

License:Open Source License

public EditFlowPalette(EditFlowPanel designFlowLayout, ApplicationContext context, String projectVersionId) {
    this.context = context;
    this.designFlowLayout = designFlowLayout;
    setHeight(100, Unit.PERCENTAGE);// w  w w .  j  a  v a  2s  .c o  m
    setWidth(150, Unit.PIXELS);

    setMargin(new MarginInfo(true, false, false, false));

    componentAccordian = new Accordion();
    componentAccordian.setSizeFull();
    addComponent(componentAccordian);
    setExpandRatio(componentAccordian, 1);

    populateComponentPalette(projectVersionId);

}

From source file:org.lucidj.browser.BrowserView.java

License:Apache License

private void build_sidebar() {
    acSidebar = new Accordion();
    acSidebar.setSizeFull();/*from  w w w .  j ava  2 s .  c  o m*/
    acSidebar.addStyleName("borderless");

    sidebar = new ComponentPalette(componentManager.newComponentSet());
    sidebar.setWidth(100, Unit.PERCENTAGE);
    sidebar.setHeightUndefined();
    sidebar.setPaletteClickListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent layoutClickEvent) {
            Component clicked = layoutClickEvent.getClickedComponent();
            String canonical_name = clicked != null ? clicked.getId() : null;

            log.info("layoutClick: DoubleClick clicked={} canonical_name={}", clicked, canonical_name);

            // Handle double-clicking a component inside the palette
            if (canonical_name != null && layoutClickEvent.isDoubleClick()) {
                log.info("layoutClick: DoubleClick clicked={} canonical_name={}", clicked, canonical_name);
                int cell_index = get_current_cell_index();
                Object new_object = insert_new_cell(canonical_name, cell_index + 1);
                update_cell_focus(new_object, true);
            }
        }
    });

    acSidebar.addTab(sidebar, "Components");

    acSidebar.addTab(new Label("Hello world"), "Visualization");
}

From source file:org.opennms.features.topology.app.internal.TopologyWidgetTestApplication.java

License:Open Source License

/**
 * Creates the west area layout including the
 * accordion and tree views.//  w  ww  .  j  a v  a2  s  . c  o  m
 * 
 * @return
 */
@SuppressWarnings("serial")
private Layout createWestLayout() {
    m_tree = createTree();

    final TextField filterField = new TextField("Filter");
    filterField.setTextChangeTimeout(200);

    final Button filterBtn = new Button("Filter");
    filterBtn.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            GCFilterableContainer container = m_tree.getContainerDataSource();
            container.removeAllContainerFilters();

            String filterString = (String) filterField.getValue();
            if (!filterString.equals("") && filterBtn.getCaption().toLowerCase().equals("filter")) {
                container.addContainerFilter(LABEL_PROPERTY, (String) filterField.getValue(), true, false);
                filterBtn.setCaption("Clear");
            } else {
                filterField.setValue("");
                filterBtn.setCaption("Filter");
            }

        }
    });

    HorizontalLayout filterArea = new HorizontalLayout();
    filterArea.addComponent(filterField);
    filterArea.addComponent(filterBtn);
    filterArea.setComponentAlignment(filterBtn, Alignment.BOTTOM_CENTER);

    m_treeAccordion = new Accordion();
    m_treeAccordion.addTab(m_tree, m_tree.getTitle());
    m_treeAccordion.setWidth("100%");
    m_treeAccordion.setHeight("100%");

    AbsoluteLayout absLayout = new AbsoluteLayout();
    absLayout.setWidth("100%");
    absLayout.setHeight("100%");
    absLayout.addComponent(filterArea, "top: 25px; left: 15px;");
    absLayout.addComponent(m_treeAccordion, "top: 75px; left: 15px; right: 15px; bottom:25px;");

    return absLayout;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.KscDashlet.java

License:Open Source License

@Override
public DashletComponent getDashboardComponent() {
    if (m_dashboardComponent == null) {
        m_dashboardComponent = new AbstractDashletComponent() {
            private VerticalLayout m_verticalLayout = new VerticalLayout();

            {// w  w w .  j  a v  a  2  s.  co  m
                m_verticalLayout.setCaption(getName());
                m_verticalLayout.setSizeFull();
            }

            @Override
            public void refresh() {
                m_verticalLayout.removeAllComponents();

                String kscReportName = getDashletSpec().getParameters().get("kscReport");

                if (kscReportName == null || "".equals(kscReportName)) {
                    return;
                }

                KSC_PerformanceReportFactory kscPerformanceReportFactory = KSC_PerformanceReportFactory
                        .getInstance();

                Map<Integer, String> reportsMap = kscPerformanceReportFactory.getReportList();

                int kscReportId = -1;

                for (Map.Entry<Integer, String> entry : reportsMap.entrySet()) {

                    if (kscReportName.equals(entry.getValue())) {
                        kscReportId = entry.getKey();
                        break;
                    }
                }

                if (kscReportId == -1) {
                    return;
                }

                Report kscReport = kscPerformanceReportFactory.getReportByIndex(kscReportId);

                Page.getCurrent().getStyles().add(
                        ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }");
                Page.getCurrent().getStyles().add(
                        ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }");
                Page.getCurrent().getStyles().add(".margin { margin:5px; }");

                Accordion accordion = new Accordion();
                accordion.setSizeFull();
                m_verticalLayout.addComponent(accordion);

                for (Graph graph : kscReport.getGraph()) {
                    Map<String, String> data = getDataForResourceId(graph.getNodeId(), graph.getResourceId());

                    Calendar beginTime = Calendar.getInstance();
                    Calendar endTime = Calendar.getInstance();

                    KSC_PerformanceReportFactory.getBeginEndTime(graph.getTimespan(), beginTime, endTime);

                    GraphContainer graphContainer = getGraphContainer(graph, beginTime.getTime(),
                            endTime.getTime());

                    VerticalLayout verticalLayout = new VerticalLayout();

                    HorizontalLayout horizontalLayout = new HorizontalLayout();
                    horizontalLayout.addStyleName("box");
                    horizontalLayout.setWidth("100%");
                    horizontalLayout.setHeight("42px");

                    VerticalLayout leftLayout = new VerticalLayout();
                    leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                    leftLayout.addStyleName("margin");

                    Label labelTitle;

                    if (graph.getTitle() == null || "".equals(graph.getTitle())) {
                        labelTitle = new Label("&nbsp;");
                        labelTitle.setContentMode(ContentMode.HTML);
                    } else {
                        labelTitle = new Label(graph.getTitle());
                    }

                    labelTitle.addStyleName("text");

                    Label labelFrom = new Label("From: " + beginTime.getTime().toString());
                    labelFrom.addStyleName("text");

                    Label labelTo = new Label("To: " + endTime.getTime().toString());
                    labelTo.addStyleName("text");

                    Label labelNodeLabel = new Label(data.get("nodeLabel"));
                    labelNodeLabel.addStyleName("text");

                    Label labelResourceLabel = new Label(
                            data.get("resourceTypeLabel") + ": " + data.get("resourceLabel"));
                    labelResourceLabel.addStyleName("text");

                    leftLayout.addComponent(labelTitle);
                    leftLayout.addComponent(labelFrom);
                    leftLayout.addComponent(labelTo);

                    VerticalLayout rightLayout = new VerticalLayout();
                    rightLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
                    rightLayout.addStyleName("margin");

                    rightLayout.addComponent(labelNodeLabel);
                    rightLayout.addComponent(labelResourceLabel);

                    horizontalLayout.addComponent(leftLayout);
                    horizontalLayout.addComponent(rightLayout);

                    horizontalLayout.setExpandRatio(leftLayout, 1.0f);
                    horizontalLayout.setExpandRatio(rightLayout, 1.0f);

                    verticalLayout.addComponent(horizontalLayout);
                    verticalLayout.addComponent(graphContainer);
                    verticalLayout.setWidth(DEFAULT_GRAPH_WIDTH_PX, Unit.PIXELS);

                    accordion.addTab(verticalLayout, data.get("nodeLabel") + "/" + data.get("resourceTypeLabel")
                            + ": " + data.get("resourceLabel"));

                    verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
                    verticalLayout.setComponentAlignment(graphContainer, Alignment.MIDDLE_CENTER);
                    verticalLayout.setMargin(true);
                }
            }

            @Override
            public Component getComponent() {
                return m_verticalLayout;
            }
        };
    }

    return m_dashboardComponent;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.RrdDashlet.java

License:Open Source License

@Override
public DashletComponent getDashboardComponent() {
    if (m_dashboardComponent == null) {
        m_dashboardComponent = new AbstractDashletComponent() {
            private VerticalLayout m_verticalLayout = new VerticalLayout();

            {/*from   w w  w .  j a va 2 s  . co m*/
                m_verticalLayout.setCaption(getName());
                m_verticalLayout.setSizeFull();
            }

            @Override
            public void refresh() {
                /**
                 * removing old components
                 */
                m_verticalLayout.removeAllComponents();

                /**
                 * iniatizing the parameters
                 */
                int columns = 0;
                int rows = 0;
                int width = 0;
                int height = 0;

                try {
                    columns = Integer.parseInt(getDashletSpec().getParameters().get("columns"));
                } catch (NumberFormatException numberFormatException) {
                    columns = 1;
                }

                try {
                    rows = Integer.parseInt(getDashletSpec().getParameters().get("rows"));
                } catch (NumberFormatException numberFormatException) {
                    rows = 1;
                }

                try {
                    width = Integer.parseInt(getDashletSpec().getParameters().get("width"));
                } catch (NumberFormatException numberFormatException) {
                    width = 400;
                }

                try {
                    height = Integer.parseInt(getDashletSpec().getParameters().get("height"));
                } catch (NumberFormatException numberFormatException) {
                    height = 100;
                }

                /**
                 * getting the timeframe values
                 */
                int timeFrameValue;
                int timeFrameType;

                try {
                    timeFrameValue = Integer.parseInt(getDashletSpec().getParameters().get("timeFrameValue"));
                } catch (NumberFormatException numberFormatException) {
                    timeFrameValue = 1;
                }

                try {
                    timeFrameType = Integer.parseInt(getDashletSpec().getParameters().get("timeFrameType"));
                } catch (NumberFormatException numberFormatException) {
                    timeFrameType = Calendar.HOUR;
                }

                int i = 0;

                Page.getCurrent().getStyles().add(
                        ".box { margin: 5px; background-color: #444; border: 1px solid #999; border-top: 0; overflow: auto; }");
                Page.getCurrent().getStyles().add(
                        ".text { color:#ffffff; line-height: 11px; font-size: 9px; font-family: 'Lucida Grande', Verdana, sans-serif; font-weight: bold; }");
                Page.getCurrent().getStyles().add(".margin { margin:5px; }");

                Accordion accordion = new Accordion();
                accordion.setSizeFull();

                /**
                 * adding the components
                 */
                for (int y = 0; y < rows; y++) {
                    for (int x = 0; x < columns; x++) {
                        String graphUrl = getDashletSpec().getParameters().get("graphUrl" + i);

                        if (graphUrl != null && !"".equals(graphUrl)) {
                            accordion.addTab(getGraphComponent(i, width, height, timeFrameType, timeFrameValue),
                                    getDashletSpec().getParameters().get("nodeLabel" + i) + "/"
                                            + getDashletSpec().getParameters().get("resourceTypeLabel" + i)
                                            + ": " + getDashletSpec().getParameters().get("resourceLabel" + i));
                        }
                        i++;
                    }
                }

                m_verticalLayout.addComponent(accordion);
            }

            @Override
            public Component getComponent() {
                return m_verticalLayout;
            }
        };
    }

    return m_dashboardComponent;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java

License:Open Source License

@Override
public DashletComponent getDashboardComponent() {
    if (m_dashboardComponent == null) {
        m_dashboardComponent = new AbstractDashletComponent() {
            private HorizontalLayout m_horizontalLayout = new HorizontalLayout();

            {//from  w  w w  .j  a  va2s .  co  m
                m_horizontalLayout.setCaption(getName());
                m_horizontalLayout.setSizeFull();
            }

            /**
             * Injects CSS styles in the current page
             */
            private void injectDashboardStyles() {
                Page.getCurrent().getStyles()
                        .add(".summary.cleared { background: #000000; border-left: 8px solid #858585; }");
                Page.getCurrent().getStyles()
                        .add(".summary.normal { background: #000000; border-left: 8px solid #336600; }");
                Page.getCurrent().getStyles()
                        .add(".summary.indeterminate {  background: #000000; border-left: 8px solid #999; }");
                Page.getCurrent().getStyles()
                        .add(".summary.warning { background: #000000; border-left: 8px solid #FFCC00; }");
                Page.getCurrent().getStyles()
                        .add(".summary.minor { background: #000000;  border-left: 8px solid #FF9900; }");
                Page.getCurrent().getStyles()
                        .add(".summary.major { background: #000000; border-left: 8px solid #FF3300; }");
                Page.getCurrent().getStyles()
                        .add(".summary.critical { background: #000000; border-left: 8px solid #CC0000; }");
                Page.getCurrent().getStyles()
                        .add(".summary.global { background: #000000; border-left: 8px solid #000000; }");
                Page.getCurrent().getStyles().add(".summary { padding: 5px 5px; margin: 1px; }");
                Page.getCurrent().getStyles().add(
                        ".summary-font { font-size: 17px; line-height: normal; text-align: right; color: #3ba300; }");
                Page.getCurrent().getStyles().add(
                        ".summary-font-legend { font-size: 9px; line-height: normal; text-align: right; color: #3ba300; }");
            }

            @Override
            public void refresh() {
                m_timeslot = 3600;

                try {
                    m_timeslot = Math.max(1,
                            Integer.parseInt(getDashletSpec().getParameters().get("timeslot")));
                } catch (NumberFormatException numberFormatException) {
                    /**
                     * Just ignore
                     */
                }

                m_horizontalLayout.removeAllComponents();

                Accordion accordion = new Accordion();
                accordion.setSizeFull();

                injectDashboardStyles();

                Component severity = getComponentSeverity(16);
                Component uei = getComponentUei(16);

                VerticalLayout v1 = new VerticalLayout(severity);
                v1.setSizeFull();
                v1.setComponentAlignment(severity, Alignment.MIDDLE_CENTER);
                v1.setMargin(true);
                accordion.addTab(v1, "by Severity");

                VerticalLayout v2 = new VerticalLayout(uei);
                v2.setSizeFull();
                v2.setComponentAlignment(uei, Alignment.MIDDLE_CENTER);
                v2.setMargin(true);
                accordion.addTab(v2, "by Uei");

                m_horizontalLayout.addComponent(accordion);
            }

            @Override
            public Component getComponent() {
                return m_horizontalLayout;
            }

            @Override
            public boolean isBoosted() {
                return SummaryDashlet.this.m_boosted;
            }
        };
    }

    return m_dashboardComponent;
}

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

License:Mozilla Public License

@Override
protected void init(VaadinRequest request) {
    String configClass = null;//from   ww  w  . j av a2s  .  com
    moduleConfigLists.clear();

    // retrieve module config
    try {
        Properties initParams = request.getService().getDeploymentConfiguration().getInitParameters();
        String moduleID = initParams.getProperty(AdminUIModule.SERVLET_PARAM_MODULE_ID);
        uiConfig = (AdminUIConfig) SensorHub.getInstance().getModuleRegistry().getModuleById(moduleID)
                .getConfiguration();
    } catch (Exception e) {
        throw new RuntimeException("Cannot get UI module configuration", e);
    }

    try {
        // load default form builders
        customForms.put(HttpServerConfig.class.getCanonicalName(), HttpServerConfigForm.class);
        customForms.put(StreamStorageConfig.class.getCanonicalName(), GenericStorageConfigForm.class);
        customForms.put(CommConfig.class.getCanonicalName(), CommConfigForm.class);
        customForms.put(SOSConfigForm.SOS_PACKAGE + "SOSServiceConfig", SOSConfigForm.class);
        customForms.put(SOSConfigForm.SOS_PACKAGE + "SOSProviderConfig", SOSConfigForm.class);

        // load custom form builders defined in config
        for (CustomUIConfig customForm : uiConfig.customForms) {
            configClass = customForm.configClass;
            Class<?> clazz = Class.forName(customForm.uiClass);
            customForms.put(configClass, (Class<IModuleConfigForm>) clazz);
            log.debug("Loaded custom form for " + configClass);
        }
    } catch (Exception e) {
        log.error("Error while instantiating form builder for config class " + configClass, e);
    }

    try {
        // load default panel builders
        customPanels.put(SensorConfig.class.getCanonicalName(), SensorAdminPanel.class);
        customPanels.put(StorageConfig.class.getCanonicalName(), StorageAdminPanel.class);

        // load custom panel builders defined in config
        for (CustomUIConfig customPanel : uiConfig.customPanels) {
            configClass = customPanel.configClass;
            Class<?> clazz = Class.forName(customPanel.uiClass);
            customPanels.put(configClass, (Class<IModuleAdminPanel<?>>) clazz);
            log.debug("Loaded custom panel for " + configClass);
        }
    } catch (Exception e) {
        log.error("Error while instantiating panel builder for config class " + configClass, e);
    }

    // register new field converter for interger numbers
    @SuppressWarnings("serial")
    ConverterFactory converterFactory = new DefaultConverterFactory() {
        @Override
        protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter(
                Class<PRESENTATION> presentationType, Class<MODEL> modelType) {
            // Handle String <-> Integer/Short/Long
            if (presentationType == String.class
                    && (modelType == Long.class || modelType == Integer.class || modelType == Short.class)) {
                return (Converter<PRESENTATION, MODEL>) new StringToIntegerConverter() {
                    @Override
                    protected NumberFormat getFormat(Locale locale) {
                        NumberFormat format = super.getFormat(Locale.US);
                        format.setGroupingUsed(false);
                        return format;
                    }
                };
            }
            // Let default factory handle the rest
            return super.findConverter(presentationType, modelType);
        }
    };
    VaadinSession.getCurrent().setConverterFactory(converterFactory);

    // init main panels
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.setMinSplitPosition(300.0f, Unit.PIXELS);
    splitPanel.setMaxSplitPosition(30.0f, Unit.PERCENTAGE);
    splitPanel.setSplitPosition(350.0f, Unit.PIXELS);
    setContent(splitPanel);

    // build left pane
    VerticalLayout leftPane = new VerticalLayout();
    leftPane.setSizeFull();

    // header image and title
    Component header = buildHeader();
    leftPane.addComponent(header);
    leftPane.setExpandRatio(header, 0);

    // toolbar
    Component toolbar = buildToolbar();
    leftPane.addComponent(toolbar);
    leftPane.setExpandRatio(toolbar, 0);

    // accordion with several sections
    Accordion stack = new Accordion();
    stack.setSizeFull();
    VerticalLayout layout;
    Tab tab;

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Sensors");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, SensorConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Storage");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, StorageConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Processing");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, ProcessConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Services");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, ServiceConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Clients");
    tab.setIcon(ACC_TAB_ICON);
    buildModuleList(layout, ClientConfig.class);

    layout = new VerticalLayout();
    tab = stack.addTab(layout, "Network");
    tab.setIcon(ACC_TAB_ICON);
    buildNetworkConfig(layout);

    leftPane.addComponent(stack);
    leftPane.setExpandRatio(stack, 1);
    splitPanel.addComponent(leftPane);

    // init config area
    configArea = new VerticalLayout();
    configArea.setMargin(true);
    splitPanel.addComponent(configArea);
}

From source file:org.vaadin.peholmst.samples.dddwebinar.ui.appointments.BillingSection.java

@PostConstruct
void init() {//from w w  w.j  a  va  2s .  c o m
    setSpacing(true);
    setMargin(false);
    setSizeFull();
    Label title = new Label("Billing");
    title.addStyleName(ValoTheme.LABEL_H2);
    addComponent(title);

    ledgerContainer = new BeanItemContainer<>(LedgerEntry.class);
    ledger = new Grid("Ledger", ledgerContainer);
    ledger.setSizeFull();
    ledger.setSelectionMode(Grid.SelectionMode.NONE);
    ledger.setColumns("entryDate", "entryDescription", "entryAmount");
    ledger.getColumn("entryDate").setHeaderCaption("Date");
    ledger.getColumn("entryDescription").setHeaderCaption("Description");
    ledger.getColumn("entryAmount").setHeaderCaption("Amount").setConverter(new MoneyConverter());
    ledger.addFooterRowAt(0).getCell("entryDescription").setText("Outstanding");
    addComponent(ledger);
    setExpandRatio(ledger, 1.0f);

    Accordion receivables = new Accordion();
    receivables.setSizeFull();
    addComponent(receivables);
    setExpandRatio(receivables, 1.0f);

    claimSubSection = new ClaimSubSection();
    receivables.addTab(claimSubSection, "Insurance Claim");

    invoiceSubSection = new InvoiceSubSection();
    receivables.addTab(invoiceSubSection, "Invoice");

    model.addObserver(this); // Same scope, no need to remove afterwards
}

From source file:org.vaadin.spring.sidebar.components.AccordionSideBar.java

License:Apache License

@Override
protected Accordion createCompositionRoot() {
    Accordion accordion = new Accordion();
    accordion.setSizeFull();
    return accordion;
}