use of com.vaadin.server.ExternalResource in project VaadinUtils by rlsutton1.
the class JasperReportLayout method getOptionsPanel.
private Component getOptionsPanel() {
VerticalLayout layout = new VerticalLayout();
layout.setId("OptionsPanel");
// layout.setMargin(new MarginInfo(false, false, false, false));
// layout.setSpacing(true);
layout.setSizeFull();
String buttonHeight = "" + BUTTON_WIDTH;
HorizontalLayout buttonBar = new HorizontalLayout();
buttonBar.setStyleName("njadmin-grey-colour");
buttonBar.setSpacing(true);
// buttonBar.setStyleName(Reindeer.LAYOUT_BLUE);
buttonBar.setWidth("100%");
buttonBar.setHeight("" + (BUTTON_WIDTH));
buttonBar.setMargin(new MarginInfo(false, false, false, false));
HorizontalLayout buttonContainer = new HorizontalLayout();
buttonContainer.setSizeFull();
buttonContainer.setWidth("280");
showButton = new Button();
Resource previewButtonIcon = reportProperties.getPreviewButtonIconResource();
if (previewButtonIcon == null) {
previewButtonIcon = new ExternalResource("images/seanau/Print preview.png");
}
showButton.setIcon(previewButtonIcon);
showButton.setDescription("Preview");
showButton.setWidth("" + BUTTON_WIDTH);
showButton.setHeight(buttonHeight);
showButton.setDisableOnClick(true);
showButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
showButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
addButtonListener(showButton, OutputFormat.HTML);
buttonContainer.addComponent(showButton);
printButton = new Button();
Resource pdfButtonIcon = reportProperties.getPdfButtonIconResource();
if (pdfButtonIcon == null) {
pdfButtonIcon = new ExternalResource("images/seanau/Print_32.png");
}
printButton.setIcon(pdfButtonIcon);
printButton.setDescription("Print (PDF)");
printButton.setWidth("" + BUTTON_WIDTH);
printButton.setHeight(buttonHeight);
printButton.setDisableOnClick(true);
printButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
printButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
addButtonListener(printButton, OutputFormat.PDF);
buttonContainer.addComponent(printButton);
exportButton = new Button();
Resource exportButtonIcon = reportProperties.getExportButtonIconResource();
if (exportButtonIcon == null) {
exportButtonIcon = new ExternalResource("images/exporttoexcel.png");
}
exportButton.setDescription("Export (Excel - CSV)");
exportButton.setIcon(exportButtonIcon);
exportButton.setWidth("" + BUTTON_WIDTH);
exportButton.setDisableOnClick(true);
exportButton.setHeight(buttonHeight);
exportButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
exportButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
addButtonListener(exportButton, OutputFormat.CSV);
buttonContainer.addComponent(exportButton);
createFavouriteButton(buttonHeight, buttonContainer);
createEmailButton(buttonHeight, buttonContainer);
createScheduleButton(buttonHeight, buttonContainer);
if (reportProperties instanceof JasperReportPopUp) {
// This is disabled because there are serious problems with
// transient (JasperReportProperties is not aware of them)
// parameters in drill
// downs, these can not currently be save or represented in the
// ReportEmailSchedule
emailButton.setEnabled(false);
scheduleButton.setEnabled(false);
}
buttonBar.addComponent(buttonContainer);
layout.addComponent(buttonBar);
components = builder.buildLayout(false);
if (components.size() > 0) {
VerticalLayout filterPanel = new VerticalLayout();
filterPanel.setMargin(new MarginInfo(false, false, true, false));
filterPanel.setSpacing(true);
filterPanel.setSizeFull();
Label filterLabel = new Label("<b>Filters</b>");
filterLabel.setStyleName(Reindeer.LABEL_H2);
filterLabel.setContentMode(ContentMode.HTML);
filterPanel.addComponent(filterLabel);
for (ExpanderComponent componet : components) {
filterPanel.addComponent(componet.getComponent());
if (componet.shouldExpand()) {
filterPanel.setExpandRatio(componet.getComponent(), 1);
}
}
layout.addComponent(filterPanel);
layout.setExpandRatio(filterPanel, 1.0f);
try {
ReportSave reportSave = UI.getCurrent().getSession().getAttribute(ReportSave.class);
if (reportSave != null) {
for (ReportParameter<?> rp : builder.getReportParameters()) {
for (String paramterName : rp.getParameterNames()) {
for (ReportSaveParameter saved : reportSave.getParameters()) {
if (saved.getParameterName().equals(rp.getLabel(paramterName))) {
try {
if (StringUtils.isNotBlank(saved.getMetaData())) {
rp.applySaveMetaData(saved.getMetaData());
} else {
rp.setValueAsString(saved.getParameterValue(), paramterName);
}
} catch (ReadOnlyException | ConversionException | ParseException e) {
ErrorWindow.showErrorWindow(e);
}
}
}
}
}
}
} catch (Exception e) {
logger.error(e, e);
}
}
// hidden frame for downloading csv
csv = new BrowserFrame();
csv.setVisible(true);
csv.setHeight("1");
csv.setWidth("1");
csv.setImmediate(true);
layout.addComponent(csv);
return layout;
}
use of com.vaadin.server.ExternalResource in project charts by vaadin.
the class ChartsDemoUI method init.
@Override
protected void init(VaadinRequest request) {
initGATracker();
tabSheet = new TabSheet();
tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {
@Override
public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
com.vaadin.ui.JavaScript.eval("setTimeout(function(){prettyPrint();},300);");
}
});
tabSheet.setSizeFull();
tabSheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
Link homepage = new Link("Home Page", new ExternalResource("https://vaadin.com/components/vaadin-charts"));
Link javadoc = new Link("JavaDoc", new ExternalResource("https://vaadin.com/api/com.vaadin/vaadin-charts/" + getVersion() + "/"));
Link manual = new Link("Manual", new ExternalResource("https://vaadin.com/docs/v8/charts/charts-overview.html"));
Link pricing = new Link("Pricing", new ExternalResource("https://vaadin.com/pricing"));
Label version = new Label("Version " + getVersion());
version.addStyleName("version");
HorizontalLayout links = new HorizontalLayout(homepage, pricing, javadoc, manual);
links.setSpacing(true);
links.addStyleName("links");
final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
horizontalSplitPanel.setSecondComponent(tabSheet);
horizontalSplitPanel.setSplitPosition(300, Unit.PIXELS);
horizontalSplitPanel.addStyleName("main-layout");
ChartOptions.get().setTheme(new ValoLightTheme());
themeSelector = new ComboBox("Charts Theme:");
themeSelector.addStyleName("theme-selector");
themeSelector.addStyleName(ValoTheme.COMBOBOX_SMALL);
themeSelector.setTextInputAllowed(false);
com.vaadin.addon.charts.model.style.Theme defaultTheme = new ValoLightTheme();
Map<com.vaadin.addon.charts.model.style.Theme, String> mapThemes = new HashMap<>();
com.vaadin.addon.charts.model.style.Theme[] themes = new com.vaadin.addon.charts.model.style.Theme[] { defaultTheme, new ValoDarkTheme(), new VaadinTheme(), new HighChartsDefaultTheme(), new GridTheme(), new GrayTheme(), new SkiesTheme() };
mapThemes.put(themes[0], "Valo Light");
mapThemes.put(themes[1], "Valo Dark");
mapThemes.put(themes[2], "Vaadin");
mapThemes.put(themes[3], "HighCharts");
mapThemes.put(themes[4], "Grid");
mapThemes.put(themes[5], "Gray");
mapThemes.put(themes[6], "Skies");
themeSelector.setEmptySelectionAllowed(false);
themeSelector.setItems(themes);
themeSelector.setSelectedItem(defaultTheme);
themeSelector.setItemCaptionGenerator(mapThemes::get);
themeSelector.addSelectionListener(e -> {
ChartOptions.get().setTheme(e.getValue());
});
final HierarchicalContainer container = getContainer();
VerticalLayout content = new VerticalLayout();
content.setSpacing(true);
content.setMargin(false);
Label logo = new Label("Vaadin Charts for Vaadin 8");
logo.setWidth("100%");
logo.addStyleName("h3");
logo.addStyleName("logo");
TextField filterField = new TextField();
filterField.setPlaceholder("Filter examples");
filterField.setIcon(FontAwesome.SEARCH);
filterField.addStyleName("filter");
filterField.setWidth("100%");
filterField.addValueChangeListener(e -> {
container.removeAllContainerFilters();
String text = e.getValue();
if (text != null && !text.isEmpty()) {
expandForFiltering();
container.addContainerFilter("searchName", text, true, false);
} else {
restoreExpandedStates();
}
});
tree = new Tree();
tree.setImmediate(true);
tree.setContainerDataSource(container);
tree.setItemCaptionPropertyId("displayName");
tree.setNullSelectionAllowed(false);
tree.setWidth("100%");
tree.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
Object value = event.getProperty().getValue();
if (value instanceof Class) {
updateTabSheet((Class) value);
} else {
tree.expandItemsRecursively(value);
}
}
});
Button trial = new Button("Start Free Trial");
trial.addStyleName(ValoTheme.BUTTON_PRIMARY);
trial.addStyleName(ValoTheme.BUTTON_TINY);
trial.addClickListener(e -> {
getUI().getPage().open("https://vaadin.com/trial", "_blank");
});
content.addComponents(logo, links, trial, filterField, tree, version);
content.setComponentAlignment(trial, Alignment.MIDDLE_CENTER);
horizontalSplitPanel.setFirstComponent(content);
selectItem();
Page.getCurrent().addUriFragmentChangedListener(new Page.UriFragmentChangedListener() {
@Override
public void uriFragmentChanged(Page.UriFragmentChangedEvent event) {
selectItem();
}
});
setContent(new CssLayout() {
{
setSizeFull();
addComponent(horizontalSplitPanel);
addComponent(themeSelector);
}
});
if (tracker != null) {
tracker.trackPageview("/charts");
}
}
use of com.vaadin.server.ExternalResource in project v-leaflet by mstahv.
the class AddOverlayBugTest method getTestComponent.
@Override
public Component getTestComponent() {
VerticalLayout lmapContainer = new VerticalLayout();
lmapContainer.setMargin(true);
// create leaflet map
lmap = new LMap();
lmap.setCenter(40.712216, -74.22655);
lmap.setWidth("500px");
lmap.setHeight("400px");
lmapContainer.addComponent(lmap);
// base laser 1 & 2 (dummy base layers)
LOpenStreetMapLayer osm1 = new LOpenStreetMapLayer();
osm1.setActive(false);
lmap.addBaseLayer(osm1, "Base Layer 1");
LTileLayer osm2 = new LTileLayer("https://a.tile.thunderforest.com/cycle/{z}/{x}/{y}.png");
osm2.setAttributionString("© OpenStreetMap contributors. Tiles courtesy of Andy Allan");
osm2.setActive(true);
lmap.addBaseLayer(osm2, "Base Layer 2");
// BUG: after removing/adding the base layer and also existing wms layers are duplicated
Button wmsLayerRemoveAddButton = new Button("Add");
wmsLayerRemoveAddButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ExternalResource url = new ExternalResource("https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg");
LImageOverlay imageOverlay = new LImageOverlay(url, new Bounds(new Point(40.712216, -74.22655), new Point(40.773941, -74.12544)));
imageOverlay.setOpacity(0.5);
imageOverlay.setAttribution("University of Texas");
lmap.addOverlay(imageOverlay, "imagelayer-" + System.currentTimeMillis());
// dummy wms layer
LWmsLayer result = new LWmsLayer();
result.setFormat("image/png");
result.setUrl("not/working/url/to/your/geoserver");
result.setLayers("layerselection");
// add new wms layer
lmap.addOverlay(result, "layer-" + System.currentTimeMillis());
}
});
lmapContainer.addComponent(wmsLayerRemoveAddButton);
return lmapContainer;
}
use of com.vaadin.server.ExternalResource in project v-leaflet by mstahv.
the class FontawesomeMarkerAndSVGInMarker method getTestComponent.
@Override
public Component getTestComponent() {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.setSizeFull();
// Getting my map.
LMap map = new LMap();
map.addComponent(new LOpenStreetMapLayer());
LMarker lMarker = new LMarker(61, 22);
lMarker.setIcon(FontAwesome.BEER);
lMarker.setPopup("FontAwesome marker popup with anchor beer");
lMarker.setPopupAnchor(new Point(0, -45));
lMarker.addStyleName("beer");
map.addComponent(lMarker);
LCircleMarker lCircleMarker = new LCircleMarker(61, 22, 2);
map.addComponent(lCircleMarker);
getPage().getStyles().add(".v-leaflet-custom-svg circle {stroke: blue;}");
LMarker lMarker2 = new LMarker(62, 23);
String svgCode = "<svg width=\"100\" height=\"100\">\n" + " <circle cx=\"50\" cy=\"50\" r=\"40\" stroke-width=\"4\" fill=\"yellow\" />\n" + "</svg>";
lMarker2.setIconSize(new Point(100, 100));
lMarker2.setIconAnchor(new Point(50, 50));
lMarker2.setPopup("Custom svg popup with anchor");
lMarker2.setPopupAnchor(new Point(0, -40));
lMarker2.addStyleName("v-leaflet-custom-svg");
lMarker2.setDivIcon(svgCode);
lMarker2.addClickListener(new LeafletClickListener() {
@Override
public void onClick(LeafletClickEvent event) {
Notification.show("Clicked " + event.getPoint().toString());
}
});
map.addComponent(lMarker2);
LCircleMarker lCircleMarker2 = new LCircleMarker(62, 23, 2);
map.addComponent(lCircleMarker2);
LMarker lMarker3 = new LMarker(60.1698560, 24.9383790);
lMarker3.setIcon(FontAwesome.GOOGLE);
lMarker3.setIconTextFill("#F00");
lMarker3.setIconPathFill("#666");
lMarker3.setIconPathStroke("#000");
lMarker3.setPopup("Configurable FontAwesome marker popup with anchor");
lMarker3.setPopupAnchor(new Point(0, -45));
map.addComponent(lMarker3);
LMarker characterAsIcon = new LMarker(60, 21);
characterAsIcon.setIcon("A1");
map.addComponent(characterAsIcon);
LMarker svgDataUrlMarker = new LMarker(62, 24);
// Note that styling is not easy this way as css don't hook into images
svgDataUrlMarker.addStyleName("red");
svgDataUrlMarker.setIcon(new ExternalResource("data:image/svg+xml;utf8," + svgMarker.replace("FILLCOLOR", "red")));
svgDataUrlMarker.setIconSize(new Point(50, 50));
svgDataUrlMarker.setIconAnchor(new Point(25, 50));
map.addComponent(svgDataUrlMarker);
map.zoomToContent();
layout.addComponent(map);
return layout;
}
use of com.vaadin.server.ExternalResource in project v-leaflet by mstahv.
the class ImageLayerOnOSM method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap.addLayer(new LOpenStreetMapLayer());
// Old map overlayed approximately over OSM map
ExternalResource url = new ExternalResource("https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg");
LImageOverlay imageOverlay = new LImageOverlay(url, new Bounds(new Point(40.712216, -74.22655), new Point(40.773941, -74.12544)));
imageOverlay.setOpacity(0.5);
// set true to emit mouse events
imageOverlay.setInteractive(true);
imageOverlay.setAttribution("University of Texas");
imageOverlay.addClickListener(new LeafletClickListener() {
@Override
public void onClick(LeafletClickEvent event) {
Notification.show("Image overlay clicked!");
}
});
imageOverlay.addContextMenuListener(new LeafletContextMenuListener() {
@Override
public void onContextMenu(LeafletContextMenuEvent event) {
Notification.show("Image overlay context clicked!");
}
});
imageOverlay.addMouseOverListener(new LeafletMouseOverListener() {
@Override
public void onMouseOver(LeafletMouseOverEvent event) {
Notification.show("Mouse over image overlay!");
}
});
imageOverlay.addMouseOutListener(new LeafletMouseOutListener() {
@Override
public void onMouseOut(LeafletMouseOutEvent event) {
Notification.show("Mouse out of image overlay");
}
});
leafletMap.addLayer(imageOverlay);
leafletMap.zoomToContent();
return leafletMap;
}
Aggregations