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;
}
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();
}
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));
}
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);
}
}
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;
}
Aggregations