Search in sources :

Example 1 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project cia by Hack23.

the class PartyDocumentChartDataManagerImpl method createDocumentHistoryPartyChart.

@Override
public void createDocumentHistoryPartyChart(final AbstractOrderedLayout content, final String org) {
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> allMap = getViewRiksdagenPartyDocumentDailySummaryMap();
    final List<ViewRiksdagenPartyDocumentDailySummary> itemList = allMap.get(org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());
    if (itemList != null) {
        final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> map = itemList.parallelStream().filter(Objects::nonNull).collect(Collectors.groupingBy(t -> StringUtils.defaultIfBlank(t.getEmbeddedId().getDocumentType(), NO_INFO)));
        addDocumentHistoryByPartyData(dataSeries, series, map);
    }
    addChart(content, DOCUMENT_HISTORY_PARTY, new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) StringUtils(org.apache.commons.lang.StringUtils) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) SimpleDateFormat(java.text.SimpleDateFormat) RiksdagenDocumentPartySummaryEmbeddedId(com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentPartySummaryEmbeddedId) Collectors(java.util.stream.Collectors) PartyDocumentChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyDocumentChartDataManager) Objects(java.util.Objects) DCharts(org.dussan.vaadin.dcharts.DCharts) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Locale(java.util.Locale) Service(org.springframework.stereotype.Service) Map(java.util.Map) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) Entry(java.util.Map.Entry) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts)

Example 2 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project linkki by linkki-framework.

the class ComponentFactory method addHorizontalSpacer.

/**
 * Creates a non-breaking space that keeps a horizontal space.
 * <p>
 * If you just want to skip one cell in a grid layout do not use this method but simply use
 * {@link GridLayout#space()}.
 *
 * @param layout the layout where the spacer should be added.
 * @return the Label that is used as spacer component
 */
public static Label addHorizontalSpacer(AbstractLayout layout) {
    if (layout instanceof AbstractOrderedLayout) {
        return addHorizontalFixedSizeSpacer((AbstractOrderedLayout) layout, -1);
    } else {
        Label spacer = createSpacer();
        layout.addComponent(spacer);
        return spacer;
    }
}
Also used : Label(com.vaadin.ui.Label) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 3 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project cuba by cuba-platform.

the class DefaultFormLayoutDropHandler method handleHTML5Drop.

@Override
protected void handleHTML5Drop(DragAndDropEvent event) {
    FormLayoutTargetDetails details = (FormLayoutTargetDetails) event.getTargetDetails();
    int idx = details.getOverIndex();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget();
    // Increase index if component is dropped after or above a
    // previous component
    VerticalDropLocation loc = details.getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }
    // Add component
    if (idx >= 0) {
        layout.addComponent(resolveComponentFromHTML5Drop(event), idx);
    } else {
        layout.addComponent(resolveComponentFromHTML5Drop(event));
    }
    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(resolveComponentFromHTML5Drop(event), dropAlignment);
    }
}
Also used : VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation) FormLayoutTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDFormLayout.FormLayoutTargetDetails) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 4 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project cuba by cuba-platform.

the class DefaultVerticalLayoutDropHandler method handleComponentReordering.

/**
 * Called when a component changed location within the layout
 *
 * @param event
 *            The drag and drop event
 */
@Override
protected void handleComponentReordering(DragAndDropEvent event) {
    // Component re-ordering
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event.getTargetDetails();
    AbstractOrderedLayout layout = (AbstractOrderedLayout) details.getTarget();
    Component comp = transferable.getComponent();
    int idx = details.getOverIndex();
    int oldIndex = layout.getComponentIndex(comp);
    if (idx == oldIndex) {
        // Index did not change
        return;
    }
    // Detach
    layout.removeComponent(comp);
    // Account for detachment if new index is bigger then old index
    if (idx > oldIndex) {
        idx--;
    }
    // Increase index if component is dropped after or above a previous
    // component
    VerticalDropLocation loc = details.getDropLocation();
    if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) {
        idx++;
    }
    // Add component
    if (idx >= 0) {
        layout.addComponent(comp, idx);
    } else {
        layout.addComponent(comp);
    }
    // Add component alignment if given
    if (dropAlignment != null) {
        layout.setComponentAlignment(comp, dropAlignment);
    }
}
Also used : VerticalLayoutTargetDetails(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDVerticalLayout.VerticalLayoutTargetDetails) VerticalDropLocation(com.vaadin.shared.ui.dd.VerticalDropLocation) LayoutBoundTransferable(com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable) Component(com.vaadin.ui.Component) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 5 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project cuba by cuba-platform.

the class WebGroupBox method add.

@Override
public void add(Component childComponent, int index) {
    if (childComponent.getParent() != null && childComponent.getParent() != this) {
        throw new IllegalStateException("Component already has parent");
    }
    AbstractOrderedLayout newContent = null;
    if (orientation == Orientation.VERTICAL && !(component.getContent() instanceof CubaVerticalActionsLayout)) {
        newContent = new CubaVerticalActionsLayout();
    } else if (orientation == Orientation.HORIZONTAL && !(component.getContent() instanceof CubaHorizontalActionsLayout)) {
        newContent = new CubaHorizontalActionsLayout();
    }
    if (newContent != null) {
        newContent.setStyleName("c-groupbox-inner");
        component.setContent(newContent);
        CubaOrderedActionsLayout currentContent = (CubaOrderedActionsLayout) component.getContent();
        newContent.setMargin(currentContent.getMargin());
        newContent.setSpacing(currentContent.isSpacing());
    }
    if (ownComponents.contains(childComponent)) {
        int existingIndex = getComponentContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent));
        if (index > existingIndex) {
            index--;
        }
        remove(childComponent);
    }
    com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent);
    getComponentContent().addComponent(vComponent, index);
    getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
    if (frame != null) {
        if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) {
            ((BelongToFrame) childComponent).setFrame(frame);
        } else {
            ((FrameImplementation) frame).registerComponent(childComponent);
        }
    }
    if (index == ownComponents.size()) {
        ownComponents.add(childComponent);
    } else {
        ownComponents.add(index, childComponent);
    }
    childComponent.setParent(this);
}
Also used : CubaVerticalActionsLayout(com.haulmont.cuba.web.widgets.CubaVerticalActionsLayout) FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) CubaHorizontalActionsLayout(com.haulmont.cuba.web.widgets.CubaHorizontalActionsLayout) CubaOrderedActionsLayout(com.haulmont.cuba.web.widgets.CubaOrderedActionsLayout)

Aggregations

AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)15 VerticalDropLocation (com.vaadin.shared.ui.dd.VerticalDropLocation)8 Component (com.vaadin.ui.Component)7 LayoutBoundTransferable (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable)5 DataContainer (com.hack23.cia.service.api.DataContainer)3 VerticalLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDVerticalLayout.VerticalLayoutTargetDetails)3 VerticalLayoutTargetDetails (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.v7.DDVerticalLayout.VerticalLayoutTargetDetails)3 ComponentContainer (com.vaadin.ui.ComponentContainer)3 SingleComponentContainer (com.vaadin.ui.SingleComponentContainer)3 SimpleDateFormat (java.text.SimpleDateFormat)3 List (java.util.List)3 Locale (java.util.Locale)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 Objects (java.util.Objects)3 Collectors (java.util.stream.Collectors)3 DCharts (org.dussan.vaadin.dcharts.DCharts)3 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)3 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)3 Series (org.dussan.vaadin.dcharts.options.Series)3