private void BuildContainerview() { setSizeFull(); addStyleName("main-view"); BuildMenu(); BuildMenuBar(); BuildSettings("J. Rodrigues"); BuildBranding(); addComponent(menuBar); addComponent(content); content.setSizeFull(); content.addStyleName("view-content"); setExpandRatio(content, 1); }
private void initContent() { addStyleName("timings-view"); setSizeFull(); setLocale(Locale.US); VerticalLayout row = new VerticalLayout(); row.setSizeFull(); row.setMargin(new MarginInfo(false, true, false, true)); row.setSpacing(false); addComponent(row); setExpandRatio(row, 2); CssLayout panel = new CssLayout(); panel.addStyleName("layout-panel"); panel.setSizeFull(); row.addComponent(panel); content = new VerticalLayout(); panel.addComponent(content); }
private void showNonMobileNotification() { try { URL appUrl = Page.getCurrent().getLocation().toURL(); String myIp = Inet4Address.getLocalHost().getHostAddress(); final String qrCodeUrl = appUrl.toString().replaceAll("localhost", myIp); Label info = new Label( "You appear to be running this demo on a non-portable device. " + "Parking is intended for touch devices primarily. " + "Please read the QR code on your touch device to access the demo."); info.setWidth("310px"); Image qrCode = new Image(); qrCode.addStyleName("qrcode-image"); StreamResource resource = new StreamResource( new StreamSource() { @Override public InputStream getStream() { InputStream result = null; try { final Map<EncodeHintType, ErrorCorrectionLevel> hintMap = Maps.newHashMap(); hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); final QRCodeWriter qrCodeWriter = new QRCodeWriter(); final BitMatrix byteMatrix = qrCodeWriter.encode(qrCodeUrl, BarcodeFormat.QR_CODE, 150, 150, hintMap); final int width = byteMatrix.getWidth(); final BufferedImage image = new BufferedImage(width, width, BufferedImage.TYPE_INT_RGB); image.createGraphics(); final Graphics2D graphics = (Graphics2D) image.getGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, width, width); graphics.setColor(Color.BLACK); for (int i = 0; i < width; i++) { for (int j = 0; j < width; j++) { if (byteMatrix.get(i, j)) { graphics.fillRect(i, j, 1, 1); } } } final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ImageIO.write(image, "png", baos); } catch (final IOException e) { e.printStackTrace(); } result = new ByteArrayInputStream(baos.toByteArray()); } catch (WriterException e) { e.printStackTrace(); } return result; } }, "qrcode-" + new Date().getTime() + ".png"); resource.setCacheTime(0); qrCode.setSource(resource); CssLayout qrCodeLayout = new CssLayout(qrCode, info); qrCodeLayout.setSizeFull(); Window window = new Window(null, qrCodeLayout); window.setWidth(500.0f, Unit.PIXELS); window.setHeight(200.0f, Unit.PIXELS); window.addStyleName("qr-code"); window.setModal(true); window.setResizable(false); window.setDraggable(false); addWindow(window); window.center(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (UnknownHostException e) { e.printStackTrace(); } }
public void setItem(InstanceDto instanceDto) { int line = 0; if (instanceDto != null) { Instance instance = instanceDto.getInstance(); // hostName = new Label(instance.getInstanceName(), Label.CONTENT_TEXT); // layout.removeComponent( 1, line ); // layout.addComponent(hostName , 1, line++ ); fqdn = new Label(instance.getFqdn(), Label.CONTENT_TEXT); layout.removeComponent(1, line); layout.addComponent(fqdn, 1, line++); ipAddress = new Label(instance.getPublicIp(), Label.CONTENT_TEXT); layout.removeComponent(1, line); layout.addComponent(ipAddress, 1, line++); // プラットフォームの表示 PlatformDto platformDto = instanceDto.getPlatform(); // TODO: アイコン名の取得ロジックのリファクタリング Icons icon = Icons.NONE; if ("aws".equals(platformDto.getPlatform().getPlatformType())) { if (platformDto.getPlatformAws().getEuca()) { icon = Icons.EUCALYPTUS; } else { icon = Icons.AWS; } } else if ("vmware".equals(platformDto.getPlatform().getPlatformType())) { icon = Icons.VMWARE; } else if ("nifty".equals(platformDto.getPlatform().getPlatformType())) { icon = Icons.NIFTY; } else if ("cloudstack".equals(platformDto.getPlatform().getPlatformType())) { icon = Icons.CLOUD_STACK; } String description = platformDto.getPlatform().getPlatformNameDisp(); platform = new Label( "<img src=\"" + VaadinUtils.getIconPath(ServerDescBasic.this, icon) + "\"><div>" + description + "</div>", Label.CONTENT_XHTML); layout.removeComponent(1, line); layout.addComponent(platform, 1, line++); // OS名の表示 ImageDto imageDto = instanceDto.getImage(); // TODO: アイコン名取得ロジックのリファクタリング String os = imageDto.getImage().getOsDisp(); Icons osIcon = Icons.NONE; if (imageDto.getImage().getOs().startsWith("centos")) { osIcon = Icons.CENTOS; } else if (imageDto.getImage().getOs().startsWith("windows")) { osIcon = Icons.WINDOWS; } layoutOsType = new CssLayout(); ostype = new Label( "<img src=\"" + VaadinUtils.getIconPath(ServerDescBasic.this, osIcon) + "\"><div>" + os + "</div>", Label.CONTENT_XHTML); layoutOsType.setSizeFull(); layoutOsType.setMargin(false); layoutOsType.addComponent(ostype); // OSがWindowsの場合パスワード取得ボタンを表示 if (imageDto.getImage().getOs().startsWith("windows")) { // ただしEUCALYPTUSは除外 if (platformDto.getPlatformAws() == null || platformDto.getPlatformAws().getEuca() == false) { InstanceStatus instanceStatus = InstanceStatus.fromStatus(instance.getStatus()); if (instanceStatus == InstanceStatus.RUNNING) { getPassword.setEnabled(true); getPassword.setData(instance.getInstanceNo()); } else { getPassword.setEnabled(false); } layoutOsType.addComponent(getPassword); layoutOsType.setHeight("60px"); } } layout.removeComponent(1, line); layout.addComponent(layoutOsType, 1, line++); // ステータスの表示 String stat = instance.getStatus().substring(0, 1).toUpperCase() + instance.getStatus().substring(1).toLowerCase(); Icons icon2 = Icons.fromName(stat); status = new Label( "<img src=\"" + VaadinUtils.getIconPath(ServerDescBasic.this, icon2) + "\"><div>" + stat + "</div>", Label.CONTENT_XHTML); layout.removeComponent(1, line); layout.addComponent(status, 1, line++); // コメント comment = new Label(instance.getComment(), Label.CONTENT_XHTML); layout.removeComponent(1, line); layout.addComponent(comment, 1, line++); } else { // hostName = new Label("", Label.CONTENT_TEXT); // layout.removeComponent( 1, line ); // layout.addComponent(hostName , 1, line++ ); fqdn = new Label("", Label.CONTENT_TEXT); layout.removeComponent(1, line); layout.addComponent(fqdn, 1, line++); ipAddress = new Label("", Label.CONTENT_TEXT); layout.removeComponent(1, line); layout.addComponent(ipAddress, 1, line++); // プラットフォームの表示 platform = new Label("", Label.CONTENT_XHTML); layout.removeComponent(1, line); layout.addComponent(platform, 1, line++); // OS名の表示 layoutOsType = new CssLayout(); ostype = new Label("", Label.CONTENT_XHTML); layoutOsType.setSizeFull(); layoutOsType.setMargin(false); layoutOsType.addComponent(ostype); layout.removeComponent(1, line); layout.addComponent(layoutOsType, 1, line++); // ステータスの表示 status = new Label("", Label.CONTENT_XHTML); layout.removeComponent(1, line); layout.addComponent(status, 1, line++); // コメント comment = new Label("", Label.CONTENT_XHTML); layout.removeComponent(1, line); layout.addComponent(comment, 1, line++); } }
@Override protected void init(VaadinRequest request) { CssLayout rootLayout = new CssLayout(); rootLayout.setSizeFull(); setContent(rootLayout); TabSheet tabs = new TabSheet(); tabs.setSizeFull(); rootLayout.addComponent(tabs); VerticalLayout mapContent = new VerticalLayout(); mapContent.setSizeFull(); tabs.addTab(mapContent, "The map map"); tabs.addTab(new Label("An another tab"), "The other tab"); googleMap = new GoogleMap(null, null, null); googleMap.setCenter(new LatLon(60.440963, 22.25122)); googleMap.setZoom(10); googleMap.setSizeFull(); kakolaMarker.setAnimationEnabled(false); googleMap.addMarker(kakolaMarker); googleMap.addMarker( "DRAGGABLE: Paavo Nurmi Stadion", new LatLon(60.442423, 22.26044), true, "VAADIN/1377279006_stadium.png"); googleMap.addMarker( "NOT DRAGGABLE: Iso-Heikkilä", new LatLon(60.450403, 22.230399), false, null); googleMap.setMinZoom(4); googleMap.setMaxZoom(16); kakolaInfoWindow.setWidth("400px"); kakolaInfoWindow.setHeight("500px"); mapContent.addComponent(googleMap); mapContent.setExpandRatio(googleMap, 1.0f); Panel console = new Panel(); console.setHeight("100px"); final CssLayout consoleLayout = new CssLayout(); console.setContent(consoleLayout); mapContent.addComponent(console); HorizontalLayout buttonLayoutRow1 = new HorizontalLayout(); buttonLayoutRow1.setHeight("26px"); mapContent.addComponent(buttonLayoutRow1); HorizontalLayout buttonLayoutRow2 = new HorizontalLayout(); buttonLayoutRow2.setHeight("26px"); mapContent.addComponent(buttonLayoutRow2); OpenInfoWindowOnMarkerClickListener infoWindowOpener = new OpenInfoWindowOnMarkerClickListener(googleMap, kakolaMarker, kakolaInfoWindow); googleMap.addMarkerClickListener(infoWindowOpener); googleMap.addMarkerClickListener( new MarkerClickListener() { @Override public void markerClicked(GoogleMapMarker clickedMarker) { Label consoleEntry = new Label( "Marker \"" + clickedMarker.getCaption() + "\" at (" + clickedMarker.getPosition().getLat() + ", " + clickedMarker.getPosition().getLon() + ") clicked."); consoleLayout.addComponent(consoleEntry, 0); } }); googleMap.addMapMoveListener( new MapMoveListener() { @Override public void mapMoved(int zoomLevel, LatLon center, LatLon boundsNE, LatLon boundsSW) { Label consoleEntry = new Label( "Map moved to (" + center.getLat() + ", " + center.getLon() + "), zoom " + zoomLevel + ", boundsNE: (" + boundsNE.getLat() + ", " + boundsNE.getLon() + "), boundsSW: (" + boundsSW.getLat() + ", " + boundsSW.getLon() + ")"); consoleLayout.addComponent(consoleEntry, 0); } }); googleMap.addMapClickListener( new MapClickListener() { @Override public void mapClicked(LatLon position) { Label consoleEntry = new Label("Map click to (" + position.getLat() + ", " + position.getLon() + ")"); consoleLayout.addComponent(consoleEntry, 0); } }); googleMap.addMarkerDragListener( new MarkerDragListener() { @Override public void markerDragged(GoogleMapMarker draggedMarker, LatLon oldPosition) { Label consoleEntry = new Label( "Marker \"" + draggedMarker.getCaption() + "\" dragged from (" + oldPosition.getLat() + ", " + oldPosition.getLon() + ") to (" + draggedMarker.getPosition().getLat() + ", " + draggedMarker.getPosition().getLon() + ")"); consoleLayout.addComponent(consoleEntry, 0); } }); googleMap.addInfoWindowClosedListener( new InfoWindowClosedListener() { @Override public void infoWindowClosed(GoogleMapInfoWindow window) { Label consoleEntry = new Label("InfoWindow \"" + window.getContent() + "\" closed"); consoleLayout.addComponent(consoleEntry, 0); } }); Button moveCenterButton = new Button( "Move over Luonnonmaa (60.447737, 21.991668), zoom 12", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.setCenter(new LatLon(60.447737, 21.991668)); googleMap.setZoom(12); } }); buttonLayoutRow1.addComponent(moveCenterButton); Button limitCenterButton = new Button( "Limit center between (60.619324, 22.712753), (60.373484, 21.945083)", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.setCenterBoundLimits( new LatLon(60.619324, 22.712753), new LatLon(60.373484, 21.945083)); event.getButton().setEnabled(false); } }); buttonLayoutRow1.addComponent(limitCenterButton); Button limitVisibleAreaButton = new Button( "Limit visible area between (60.494439, 22.397835), (60.373484, 21.945083)", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.setVisibleAreaBoundLimits( new LatLon(60.494439, 22.397835), new LatLon(60.420632, 22.138626)); event.getButton().setEnabled(false); } }); buttonLayoutRow1.addComponent(limitVisibleAreaButton); Button zoomToBoundsButton = new Button( "Zoom to bounds", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.fitToBounds( new LatLon(60.45685853323144, 22.320034754486073), new LatLon(60.4482979242303, 22.27887893936156)); } }); buttonLayoutRow1.addComponent(zoomToBoundsButton); Button addPolyOverlayButton = new Button( "Add overlay over Luonnonmaa", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ArrayList<LatLon> points = new ArrayList<LatLon>(); points.add(new LatLon(60.484715, 21.923706)); points.add(new LatLon(60.446636, 21.941387)); points.add(new LatLon(60.422496, 21.99546)); points.add(new LatLon(60.427326, 22.06464)); points.add(new LatLon(60.446467, 22.064297)); GoogleMapPolygon overlay = new GoogleMapPolygon(points, "#ae1f1f", 0.8, "#194915", 0.5, 3); googleMap.addPolygonOverlay(overlay); event.getButton().setEnabled(false); } }); buttonLayoutRow2.addComponent(addPolyOverlayButton); Button addPolyLineButton = new Button( "Draw line from Turku to Raisio", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ArrayList<LatLon> points = new ArrayList<LatLon>(); points.add(new LatLon(60.448118, 22.253738)); points.add(new LatLon(60.455144, 22.24198)); points.add(new LatLon(60.460222, 22.211939)); points.add(new LatLon(60.488224, 22.174602)); points.add(new LatLon(60.486025, 22.169195)); GoogleMapPolyline overlay = new GoogleMapPolyline(points, "#d31717", 0.8, 10); googleMap.addPolyline(overlay); event.getButton().setEnabled(false); } }); buttonLayoutRow2.addComponent(addPolyLineButton); Button addPolyLineButton2 = new Button( "Draw line from Turku to Raisio2", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ArrayList<LatLon> points2 = new ArrayList<LatLon>(); points2.add(new LatLon(60.448118, 22.253738)); points2.add(new LatLon(60.486025, 22.169195)); GoogleMapPolyline overlay2 = new GoogleMapPolyline(points2, "#d31717", 0.8, 10); googleMap.addPolyline(overlay2); event.getButton().setEnabled(false); } }); buttonLayoutRow2.addComponent(addPolyLineButton2); Button changeToTerrainButton = new Button( "Change to terrain map", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.setMapType(GoogleMap.MapType.Terrain); event.getButton().setEnabled(false); } }); buttonLayoutRow2.addComponent(changeToTerrainButton); Button changeControls = new Button( "Remove street view control", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.removeControl(GoogleMapControl.StreetView); event.getButton().setEnabled(false); } }); buttonLayoutRow2.addComponent(changeControls); Button addInfoWindowButton = new Button( "Add InfoWindow to Kakola marker", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.openInfoWindow(kakolaInfoWindow); } }); buttonLayoutRow2.addComponent(addInfoWindowButton); Button moveMarkerButton = new Button( "Move kakola marker", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { kakolaMarker.setPosition(new LatLon(60.3, 22.242415)); googleMap.addMarker(kakolaMarker); } }); buttonLayoutRow2.addComponent(moveMarkerButton); Button addKmlLayerButton = new Button( "Add KML layer", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { googleMap.addKmlLayer( new GoogleMapKmlLayer( "http://maps.google.it/maps/" + "ms?authuser=0&ie=UTF8&hl=it&oe=UTF8&msa=0&" + "output=kml&msid=212897908682884215672.0004ecbac547d2d635ff5")); } }); buttonLayoutRow2.addComponent(addKmlLayerButton); Button clearMarkersButton = new Button( "Remove all markers", new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { googleMap.clearMarkers(); } }); buttonLayoutRow2.addComponent(clearMarkersButton); }
public Component createComponent() { CssLayout renderingContent = new CssLayout(); renderingContent.setSizeFull(); // build the view model // ...> yView // ......> yLayout // .........> yText1 // .........> yText2 // .........> yText3 // .........> yText4 // .........> yText5 // .........> yText6 // .........> yText7 // .........> yText8 // .........> yText9 // .........> yText10 YView yView = factory.createView(); yView.setCssClass("horizontalLayoutExample"); // create the layout YHorizontalLayout yLayout = factory.createHorizontalLayout(); yLayout.setCssClass("horizontalLayout"); yView.setContent(yLayout); yLayout.setSpacing(true); yLayout.setMargin(true); // add label for textfields YLabel yLabel1 = newLabel("Textfields"); yLayout.getElements().add(yLabel1); // add some text fields // YTextField yText1 = newText("Text1"); yLayout.getElements().add(yText1); YTextField yText2 = newText("Text2"); yLayout.getElements().add(yText2); YTextField yText3 = newText("Text3"); yLayout.getElements().add(yText3); YTextField yText4 = newText("Text4"); yLayout.getElements().add(yText4); YTextField yText5 = newText("Text5"); yLayout.getElements().add(yText5); YTextField yText6 = newText("Text6"); yLayout.getElements().add(yText6); YTextField yText7 = newText("Text7"); yLayout.getElements().add(yText7); YTextField yText8 = newText("Text8"); yLayout.getElements().add(yText8); YTextField yText9 = newText("Text9"); yLayout.getElements().add(yText9); YTextField yText10 = newText("Text10"); yLayout.getElements().add(yText10); // add label for textAreas YLabel yLabel2 = newLabel("TextAreas"); yLayout.getElements().add(yLabel2); // add some text areas // YTextArea yTextArea1 = newTextArea("TextArea1"); yLayout.getElements().add(yTextArea1); // add label for check boxes YLabel yLabel3 = newLabel("CheckBoxes"); yLayout.getElements().add(yLabel3); // add some check boxes // YCheckBox yCheckBox1 = newCheckBox("CheckBox1"); yLayout.getElements().add(yCheckBox1); // add label for combo boxes YLabel yLabel4 = newLabel("ComboBoxes"); yLayout.getElements().add(yLabel4); // add some combo boxes // YComboBox yComboBox1 = newComboBox("ComboBox1"); yLayout.getElements().add(yComboBox1); // add label for lists YLabel yLabel5 = newLabel("Lists"); yLayout.getElements().add(yLabel5); // add some lists // YList yList1 = newList("List1"); yLayout.getElements().add(yList1); // add label for tables YLabel yLabel6 = newLabel("Tables"); yLayout.getElements().add(yLabel6); // add some tables // YTable ytable1 = newTable("Table1"); yLayout.getElements().add(ytable1); // create the styling information // // // label 1 -> alignment YHorizontalLayoutCellStyle yStyleLabel1 = createCellStyle(yLayout, yLabel1); yStyleLabel1.setAlignment(YAlignment.TOP_LEFT); // // text 1 -> alignment YHorizontalLayoutCellStyle yStyle1 = createCellStyle(yLayout, yText1); yStyle1.setAlignment(YAlignment.TOP_LEFT); // text 2 -> alignment YHorizontalLayoutCellStyle yStyle2 = createCellStyle(yLayout, yText2); yStyle2.setAlignment(YAlignment.MIDDLE_CENTER); // text 3 -> alignment YHorizontalLayoutCellStyle yStyle3 = createCellStyle(yLayout, yText3); yStyle3.setAlignment(YAlignment.BOTTOM_RIGHT); // text 4 -> alignment YHorizontalLayoutCellStyle yStyle4 = createCellStyle(yLayout, yText4); yStyle4.setAlignment(YAlignment.FILL_LEFT); // text 5 -> alignment YHorizontalLayoutCellStyle yStyle5 = createCellStyle(yLayout, yText5); yStyle5.setAlignment(YAlignment.MIDDLE_FILL); // text 6 -> alignment YHorizontalLayoutCellStyle yStyle6 = createCellStyle(yLayout, yText6); yStyle6.setAlignment(YAlignment.MIDDLE_FILL); // text 7 -> alignment YHorizontalLayoutCellStyle yStyle7 = createCellStyle(yLayout, yText7); yStyle7.setAlignment(YAlignment.FILL_FILL); // text 8 -> alignment YHorizontalLayoutCellStyle yStyle8 = createCellStyle(yLayout, yText8); yStyle8.setAlignment(YAlignment.BOTTOM_LEFT); // label 2 -> alignment YHorizontalLayoutCellStyle yStyleLabel2 = createCellStyle(yLayout, yLabel2); yStyleLabel2.setAlignment(YAlignment.BOTTOM_CENTER); // textArea 1 -> alignment YHorizontalLayoutCellStyle yStyleArea1 = createCellStyle(yLayout, yTextArea1); yStyleArea1.setAlignment(YAlignment.BOTTOM_LEFT); // label 3 -> alignment YHorizontalLayoutCellStyle yStyleLabel3 = createCellStyle(yLayout, yLabel3); yStyleLabel3.setAlignment(YAlignment.BOTTOM_CENTER); // checkBox 1 -> alignment YHorizontalLayoutCellStyle yStyleChBox1 = createCellStyle(yLayout, yCheckBox1); yStyleChBox1.setAlignment(YAlignment.BOTTOM_LEFT); // label 4 -> alignment YHorizontalLayoutCellStyle yStyleLabel4 = createCellStyle(yLayout, yLabel4); yStyleLabel4.setAlignment(YAlignment.BOTTOM_CENTER); // comboBox 1 -> alignment YHorizontalLayoutCellStyle yStyleComboBox1 = createCellStyle(yLayout, yComboBox1); yStyleComboBox1.setAlignment(YAlignment.BOTTOM_LEFT); // label 5 -> alignment YHorizontalLayoutCellStyle yStyleLabel5 = createCellStyle(yLayout, yLabel5); yStyleLabel5.setAlignment(YAlignment.BOTTOM_CENTER); // list 1 -> alignment YHorizontalLayoutCellStyle yStyleList1 = createCellStyle(yLayout, yList1); yStyleList1.setAlignment(YAlignment.BOTTOM_LEFT); // label 6 -> alignment YHorizontalLayoutCellStyle yStyleLabel6 = createCellStyle(yLayout, yLabel6); yStyleLabel6.setAlignment(YAlignment.BOTTOM_CENTER); // comboBox 1 -> alignment YHorizontalLayoutCellStyle yStyleTable1 = createCellStyle(yLayout, ytable1); yStyleTable1.setAlignment(YAlignment.BOTTOM_LEFT); try { VaadinRenderer renderer = new VaadinRenderer(); renderer.render(renderingContent, yView, null); } catch (ContextException e) { logger.error("{}", e); } return renderingContent; }