public class Main { public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { InfoWindow infoWindow = new InfoWindow(); infoWindow.setVisible(true); infoWindow.refresh("a", "b"); } }); } }
public InfoWindow(final URL embeddedURL, LabelCreator labelCreator) { infoBrowser = new Embedded("", new ExternalResource(embeddedURL)); String label = labelCreator == null ? "" : labelCreator.getLabel(); setCaption(label); setImmediate(true); setResizable(false); setModal(true); /*Adds the browser to the main layout*/ VerticalLayout layout = new VerticalLayout(); layout.addComponent(infoBrowser); setContent(layout); }
@Override public void attach() { super.attach(); int width = getUI().getPage().getBrowserWindowWidth(); int height = getUI().getPage().getBrowserWindowHeight(); /*Sets the browser and window sizes based on the main window*/ int browserWidth = (int)(sizePercentage * width), browserHeight = (int)(sizePercentage * height); int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion; setWidth(windowWidth, Unit.PIXELS); setHeight(windowHeight, Unit.PIXELS); setPositionX((width - windowWidth)/2); setPositionY((height - windowHeight)/2); /*Sets the size of the browser to fit within the sub-window*/ infoBrowser.setType(Embedded.TYPE_BROWSER); infoBrowser.setWidth(browserWidth, Unit.PIXELS); infoBrowser.setHeight(browserHeight, Unit.PIXELS); } }
@Override public void buttonClick(ClickEvent event) { // try if alarm is there, otherwise show information dialog OnmsAlarm alarm = alarmDao.get(alarmId); if (alarm == null) { new DialogWindow(source.getUI(), "Alarm does not exist!", "The alarm information cannot be shown. \nThe alarm does not exist anymore. \n\nPlease refresh the Alarm Table."); return; } // alarm still exists, show alarm details final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarmId; LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarmId, currentLocation, redirectFragment); try { source.getUI().addWindow( new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new LabelCreator() { @Override public String getLabel() { return "Alarm Info " + alarmId; } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } });
@Override public void attach() { super.attach(); int width = getUI().getPage().getBrowserWindowWidth(); int height = getUI().getPage().getBrowserWindowHeight(); /*Sets the browser and window sizes based on the main window*/ int browserWidth = (int)(sizePercentage * width), browserHeight = (int)(sizePercentage * height); int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion; setWidth(windowWidth, Unit.PIXELS); setHeight(windowHeight, Unit.PIXELS); setPositionX((width - windowWidth)/2); setPositionY((height - windowHeight)/2); /*Sets the size of the browser to fit within the sub-window*/ infoBrowser.setType(Embedded.TYPE_BROWSER); infoBrowser.setWidth(browserWidth, Unit.PIXELS); infoBrowser.setHeight(browserHeight, Unit.PIXELS); } }
@Override public void buttonClick(ClickEvent event) { // try if alarm is there, otherwise show information dialog OnmsAlarm alarm = alarmDao.get(alarmId); if (alarm == null) { new DialogWindow(source.getUI(), "Alarm does not exist!", "The alarm information cannot be shown. \nThe alarm does not exist anymore. \n\nPlease refresh the Alarm Table."); return; } // alarm still exists, show alarm details final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarmId; LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarmId, currentLocation, redirectFragment); try { source.getUI().addWindow( new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new LabelCreator() { @Override public String getLabel() { return "Alarm Info " + alarmId; } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } });
public InfoWindow(final URL embeddedURL, LabelCreator labelCreator) { infoBrowser = new Embedded("", new ExternalResource(embeddedURL)); String label = labelCreator == null ? "" : labelCreator.getLabel(); setCaption(label); setImmediate(true); setResizable(false); setModal(true); /*Adds the browser to the main layout*/ VerticalLayout layout = new VerticalLayout(); layout.addComponent(infoBrowser); setContent(layout); }
@Override public void attach() { super.attach(); int width = getUI().getPage().getBrowserWindowWidth(); int height = getUI().getPage().getBrowserWindowHeight(); /*Sets the browser and window sizes based on the main window*/ int browserWidth = (int)(sizePercentage * width), browserHeight = (int)(sizePercentage * height); int windowWidth = browserWidth + widthCushion, windowHeight = browserHeight + heightCushion; setWidth(windowWidth, Unit.PIXELS); setHeight(windowHeight, Unit.PIXELS); setPositionX((width - windowWidth)/2); setPositionY((height - windowHeight)/2); /*Sets the size of the browser to fit within the sub-window*/ infoBrowser.setType(Embedded.TYPE_BROWSER); infoBrowser.setWidth(browserWidth, Unit.PIXELS); infoBrowser.setHeight(browserHeight, Unit.PIXELS); } }
public InfoWindow(final URL embeddedURL, LabelCreator labelCreator) { infoBrowser = new Embedded("", new ExternalResource(embeddedURL)); String label = labelCreator == null ? "" : labelCreator.getLabel(); setCaption(label); setResizable(false); setModal(true); /*Adds the browser to the main layout*/ VerticalLayout layout = new VerticalLayout(); layout.addComponent(infoBrowser); setContent(layout); }