Search in sources :

Example 11 with GridLayout

use of com.vaadin.ui.GridLayout in project ANNIS by korpling.

the class RawTextVisualizer method createComponent.

@Override
public Panel createComponent(VisualizerInput visInput, VisualizationToggle visToggle) {
    // get config for alignment
    boolean vertical = Boolean.parseBoolean(visInput.getMappings().getProperty("vertical", "true"));
    // get the texts
    RawTextWrapper texts = visInput.getRawText();
    // create the main panel
    Panel p = new Panel();
    p.setSizeFull();
    // some layout configuration
    p.addStyleName(ChameleonTheme.PANEL_BORDERLESS);
    p.addStyleName(PANEL_CLASS);
    // enable webfonts
    p.addStyleName(Helper.CORPUS_FONT_FORCE);
    Layout l;
    // if no text available inform user and exit
    if (texts == null) {
        Label text = new Label(NO_TEXT);
        text.addStyleName(LABEL_CLASS);
        text.setSizeFull();
        p.setContent(text);
        return p;
    }
    if (texts.hasMultipleTexts()) {
        // set the aligmnent
        if (vertical) {
            l = new VerticalLayout();
        } else {
            l = new GridLayout(texts.getTexts().size(), 1);
        }
        // limit the size to the parent panel.
        l.setSizeFull();
        // add the texts to the layout
        for (int i = 0; i < texts.getTexts().size(); i++) {
            String s = texts.getTexts().get(i);
            Label lblText;
            // check if the text is empty
            if (s == null || hasOnlyWhiteSpace(s)) {
                lblText = new Label(NO_TEXT);
            } else {
                lblText = new Label(s, ContentMode.TEXT);
            }
            if (!Helper.isRTLDisabled() && CommonHelper.containsRTLText(s)) {
                lblText.addStyleName("rtl");
            }
            lblText.setCaption("text " + (i + 1));
            lblText.addStyleName(LABEL_CLASS);
            lblText.setWidth(98, Sizeable.Unit.PERCENTAGE);
            l.addComponent(lblText);
        }
        // apply the panel
        p.setContent(l);
        return p;
    }
    Label lblText;
    if (texts.hasTexts() && !hasOnlyWhiteSpace(texts.getFirstText())) {
        lblText = new Label(texts.getFirstText(), ContentMode.TEXT);
        if (!Helper.isRTLDisabled() && CommonHelper.containsRTLText(texts.getFirstText())) {
            lblText.addStyleName("rtl");
        }
    } else {
        lblText = new Label(NO_TEXT);
    }
    lblText.setSizeFull();
    lblText.addStyleName(LABEL_CLASS);
    p.setContent(lblText);
    return p;
}
Also used : Panel(com.vaadin.ui.Panel) GridLayout(com.vaadin.ui.GridLayout) VerticalLayout(com.vaadin.ui.VerticalLayout) Layout(com.vaadin.ui.Layout) GridLayout(com.vaadin.ui.GridLayout) RawTextWrapper(annis.service.objects.RawTextWrapper) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 12 with GridLayout

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

the class TestUiUtil method createSectionWith.

public static GridLayout createSectionWith(Object pmo, BindingContext bindingContext) {
    PmoBasedSectionFactory sectionFactory = new DefaultPmoBasedSectionFactory();
    AbstractSection section = sectionFactory.createSection(pmo, bindingContext);
    bindingContext.updateUI();
    Panel panel = (Panel) section.getComponent(1);
    return (GridLayout) panel.getContent();
}
Also used : Panel(com.vaadin.ui.Panel) GridLayout(com.vaadin.ui.GridLayout) DefaultPmoBasedSectionFactory(org.linkki.core.ui.section.DefaultPmoBasedSectionFactory) AbstractSection(org.linkki.core.ui.section.AbstractSection) DefaultPmoBasedSectionFactory(org.linkki.core.ui.section.DefaultPmoBasedSectionFactory) PmoBasedSectionFactory(org.linkki.core.ui.section.PmoBasedSectionFactory)

Example 13 with GridLayout

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

the class PmoNlsServiceSectionTest method setUp.

@Before
public void setUp() {
    BindingContext context = TestBindingContext.create();
    BaseSection section = new DefaultPmoBasedSectionFactory().createBaseSection(new SamplePmo(), context);
    HorizontalLayout header = (HorizontalLayout) section.getComponent(0);
    sectionHeader = (Label) header.getComponent(0);
    GridLayout sectionContent = (GridLayout) ((Panel) section.getComponent(1)).getContent();
    textfieldLabelWithTranslation = (Label) sectionContent.getComponent(0, 0);
    textfieldLabelWithoutTranslation = (Label) sectionContent.getComponent(0, 1);
    buttonLabelWithTranslation = (Label) sectionContent.getComponent(0, 2);
    buttonWithTranslatedCaption = (Button) sectionContent.getComponent(1, 2);
    invisibleButtonLabelWithTranslation = (Label) sectionContent.getComponent(0, 3);
    buttonWithoutTranslatedCaption = (Button) sectionContent.getComponent(1, 3);
    // test setup
    PmoNlsService.get();
    textfieldLabelTranslation = getLabelTranslation(SamplePmo.PROPERTY_TEXTFIELD);
    assertThat(textfieldLabelTranslation, is(not(SamplePmo.PMO_LABEL)));
    buttonLabelTranslation = getLabelTranslation(SamplePmo.PROPERTY_MYBUTTON);
    assertThat(buttonLabelTranslation, is(not(SamplePmo.PMO_LABEL)));
    buttonCaptionTranslation = getCaptionTranslation(SamplePmo.PROPERTY_MYBUTTON);
    assertThat(buttonCaptionTranslation, is(not(SamplePmo.PMO_CAPTION)));
    assertThat(getLabelTranslation(SamplePmo.PROPERTY_CBFIELD), is(SamplePmo.PMO_LABEL));
    assertThat(getLabelTranslation(SamplePmo.PROPERTY_MYBUTTON2), is(buttonLabelTranslation));
    assertThat(getCaptionTranslation(SamplePmo.PROPERTY_MYBUTTON2), is(SamplePmo.PMO_CAPTION));
}
Also used : SamplePmo(org.linkki.core.nls.pmo.sample.SamplePmo) BaseSection(org.linkki.core.ui.section.BaseSection) GridLayout(com.vaadin.ui.GridLayout) DefaultPmoBasedSectionFactory(org.linkki.core.ui.section.DefaultPmoBasedSectionFactory) BindingContext(org.linkki.core.binding.BindingContext) TestBindingContext(org.linkki.core.binding.TestBindingContext) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Before(org.junit.Before)

Example 14 with GridLayout

use of com.vaadin.ui.GridLayout in project Activiti by Activiti.

the class ProfilePanel method initContactSection.

protected void initContactSection() {
    Label header = createProfileHeader(infoPanelLayout, i18nManager.getMessage(Messages.PROFILE_CONTACT));
    header.addStyleName(ExplorerLayout.STYLE_H3);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    infoPanelLayout.addComponent(header);
    GridLayout contactLayout = createInfoSectionLayout(2, 4);
    // Email
    if (!editable && isDefined(user.getEmail())) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), user.getEmail());
    } else if (editable) {
        emailField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), emailField, user.getEmail());
    }
    // Phone
    if (!editable && isDefined(phone)) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phone);
    } else if (editable) {
        phoneField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phoneField, phone);
    }
    // Twitter
    if (!editable && isDefined(twitterName)) {
        Link twitterLink = new Link(twitterName, new ExternalResource("http://www.twitter.com/" + twitterName));
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterLink);
    } else if (editable) {
        twitterField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterField, twitterName);
    }
    // Skype
    if (!editable && isDefined(skypeId)) {
        // The skype entry shows the name + skype icon, laid out in a small grid
        GridLayout skypeLayout = new GridLayout(2, 1);
        skypeLayout.setSpacing(true);
        skypeLayout.setSizeUndefined();
        Label skypeIdLabel = new Label(skypeId);
        skypeIdLabel.setSizeUndefined();
        skypeLayout.addComponent(skypeIdLabel);
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeLayout);
    } else if (editable) {
        skypeField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeField, skypeId);
    }
}
Also used : GridLayout(com.vaadin.ui.GridLayout) Label(com.vaadin.ui.Label) TextField(com.vaadin.ui.TextField) ExternalResource(com.vaadin.terminal.ExternalResource) Link(com.vaadin.ui.Link)

Example 15 with GridLayout

use of com.vaadin.ui.GridLayout in project Activiti by Activiti.

the class ChartGenerator method createChart.

protected static Component createChart(JsonNode dataNode, String[] names, Number[] values) {
    String type = dataNode.get("type").textValue();
    JsonNode xAxisNode = dataNode.get("xaxis");
    String xAxis = null;
    if (xAxisNode != null) {
        xAxis = xAxisNode.textValue();
    }
    JsonNode yAxisNode = dataNode.get("yaxis");
    String yAxis = null;
    if (yAxisNode != null) {
        yAxis = yAxisNode.textValue();
    }
    Component chart = null;
    if (CHART_TYPE_BAR_CHART.equals(type)) {
        DataSeries dataSeries = new DataSeries().add((Object[]) values);
        SeriesDefaults seriesDefaults = new SeriesDefaults().setRenderer(SeriesRenderers.BAR);
        Axes axes = new Axes().addAxis(new XYaxis().setRenderer(AxisRenderers.CATEGORY).setTicks(new Ticks().add((Object[]) names)));
        Highlighter highlighter = new Highlighter().setShow(false);
        Options options = new Options().setSeriesDefaults(seriesDefaults).setAxes(axes).setHighlighter(highlighter);
        options.setAnimate(true);
        options.setAnimateReplot(true);
        chart = new DCharts().setDataSeries(dataSeries).setOptions(options);
    } else if (CHART_TYPE_PIE_CHART.equals(type)) {
        DataSeries dataSeries = new DataSeries().newSeries();
        for (int i = 0; i < names.length; i++) {
            dataSeries.add(names[i], values[i]);
        }
        SeriesDefaults seriesDefaults = new SeriesDefaults().setRenderer(SeriesRenderers.PIE);
        Options options = new Options().setSeriesDefaults(seriesDefaults);
        options.setAnimate(true);
        options.setAnimateReplot(true);
        Legend legend = new Legend().setShow(true).setPlacement(LegendPlacements.INSIDE);
        options.setLegend(legend);
        Highlighter highlighter = new Highlighter().setShow(true);
        options.setHighlighter(highlighter);
        chart = new DCharts().setDataSeries(dataSeries).setOptions(options);
    } else if (CHART_TYPE_LINE_CHART.equals(type)) {
        AxesDefaults axesDefaults = new AxesDefaults().setLabelRenderer(LabelRenderers.CANVAS);
        Axes axes = new Axes().addAxis(new XYaxis().setLabel(xAxis != null ? xAxis : "").setMin(names[0]).setMax(names[values.length - 1]).setDrawMajorTickMarks(true)).addAxis(new XYaxis(XYaxes.Y).setLabel(yAxis != null ? yAxis : "").setDrawMajorTickMarks(true));
        Options options = new Options().setAxesDefaults(axesDefaults).setAxes(axes);
        DataSeries dataSeries = new DataSeries().newSeries();
        for (int i = 0; i < names.length; i++) {
            //        if (parseLong(names[i]) != null) {
            //          dataSeries.add(parseLong(names[i]), values[i]);
            //        } else if (parseDouble(names[i]) != null) {
            //          dataSeries.add(parseDouble(names[i]), values[i]);
            //        } else {
            //          dataSeries.add(names[i], values[i]);
            //        }
            dataSeries.add(names[i], values[i]);
        }
        Series series = new Series().addSeries(new XYseries().setShowLine(true).setMarkerOptions(new MarkerRenderer().setShadow(true).setSize(7).setStyle(MarkerStyles.CIRCLE)));
        options.setSeries(series);
        options.setAnimate(true);
        options.setAnimateReplot(true);
        Highlighter highlighter = new Highlighter().setShow(true);
        options.setHighlighter(highlighter);
        chart = new DCharts().setDataSeries(dataSeries).setOptions(options);
    } else if (CHART_TYPE_LIST.equals(type)) {
        GridLayout grid = new GridLayout(2, names.length);
        grid.setSpacing(true);
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            Label nameLabel = new Label(name);
            nameLabel.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD);
            grid.addComponent(nameLabel, 0, i);
            Number value = values[i];
            Label valueLabel = new Label(value + "");
            grid.addComponent(valueLabel, 1, i);
        }
        chart = grid;
    }
    if (chart instanceof DCharts) {
        // Needed, otherwise the chart will not be shown
        ((DCharts) chart).show();
    }
    return chart;
}
Also used : Options(org.dussan.vaadin.dcharts.options.Options) MarkerRenderer(org.dussan.vaadin.dcharts.base.renderers.MarkerRenderer) Legend(org.dussan.vaadin.dcharts.options.Legend) Ticks(org.dussan.vaadin.dcharts.data.Ticks) Label(com.vaadin.ui.Label) JsonNode(com.fasterxml.jackson.databind.JsonNode) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) AxesDefaults(org.dussan.vaadin.dcharts.options.AxesDefaults) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) SeriesDefaults(org.dussan.vaadin.dcharts.options.SeriesDefaults) GridLayout(com.vaadin.ui.GridLayout) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Axes(org.dussan.vaadin.dcharts.options.Axes) DCharts(org.dussan.vaadin.dcharts.DCharts) Component(com.vaadin.ui.Component) XYaxis(org.dussan.vaadin.dcharts.base.elements.XYaxis) Highlighter(org.dussan.vaadin.dcharts.options.Highlighter)

Aggregations

GridLayout (com.vaadin.ui.GridLayout)36 Label (com.vaadin.ui.Label)21 Embedded (com.vaadin.ui.Embedded)9 HorizontalLayout (com.vaadin.ui.HorizontalLayout)9 TextField (com.vaadin.ui.TextField)7 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)6 Panel (com.vaadin.ui.Panel)4 Button (com.vaadin.ui.Button)3 PasswordField (com.vaadin.ui.PasswordField)3 VerticalLayout (com.vaadin.ui.VerticalLayout)3 ComboBox (com.vaadin.ui.ComboBox)2 Component (com.vaadin.ui.Component)2 DateField (com.vaadin.ui.DateField)2 Link (com.vaadin.ui.Link)2 TextArea (com.vaadin.ui.TextArea)2 Window (com.vaadin.ui.Window)2 Test (org.junit.Test)2 DefaultPmoBasedSectionFactory (org.linkki.core.ui.section.DefaultPmoBasedSectionFactory)2 CorpusBrowserPanel (annis.gui.CorpusBrowserPanel)1 MetaDataPanel (annis.gui.MetaDataPanel)1