List of usage examples for com.google.gwt.user.client Window open
public static void open(String url, String name, String features)
From source file:org.openelis.modules.report.dataView1.client.DataViewScreenUI.java
License:Open Source License
/** * Calls a service method for generating a file and shows the file in the * front-end; the service method and type of file generated may vary *//* w ww .j av a 2 s. c o m*/ private void runReport() { reportScreen.runReport(data, new AsyncCallbackUI<ReportStatus>() { @Override public void success(ReportStatus result) { String url; hideStatus(); if (result.getStatus() == ReportStatus.Status.SAVED) { url = "/openelis/openelis/report?file=" + result.getMessage(); if (reportScreen.getAttachmentName() != null) url += "&attachment=" + reportScreen.getAttachmentName(); Window.open(URL.encode(url), reportScreen.getRunReportInterface(), null); reportScreen.getWindow().setDone("Generated file " + result.getMessage()); } else { reportScreen.getWindow().setDone(result.getMessage()); } } @Override public void notFound() { hideStatus(); reportScreen.getWindow().setDone(Messages.get().gen_noRecordsFound()); } @Override public void failure(Throwable caught) { hideStatus(); reportScreen.getWindow().setError("Failed"); Window.alert(caught.getMessage()); logger.log(Level.SEVERE, caught.getMessage(), caught); } }); }
From source file:org.openelis.modules.report.secondaryLabel.client.SecondaryLabelReportScreen.java
License:Open Source License
public void runReport(ArrayList<SecondaryLabelVO> labels) { window.setBusy(Messages.get().genReportMessage()); runReport(labels, new AsyncCallback<ReportStatus>() { public void onSuccess(ReportStatus status) { String url;/*from ww w. ja v a2 s . co m*/ if (status.getStatus() == ReportStatus.Status.SAVED) { url = "/openelis/openelis/report?file=" + status.getMessage(); if (attachmentName != null) url += "&attachment=" + attachmentName; Window.open(URL.encode(url), name, null); window.setDone("Generated file " + status.getMessage()); } else { window.setDone(status.getMessage()); } } public void onFailure(Throwable caught) { ValidationErrorsList e; StringBuilder sb; if (caught instanceof ValidationErrorsList) { e = (ValidationErrorsList) caught; sb = new StringBuilder(); /* * the method for printing labels in the back-end throws a * ValidationErrorsList if some labels have errors while * others can be printed; showErrors() is not used here * because the errors are shown in an alert which can't be * done with that method */ sb.append(Messages.get().secondaryLabel_errorsPrintingLabels()).append(":\n"); for (Exception ex : e.getErrorList()) sb.append(" * ").append(ex.getMessage()).append("\n"); Window.alert(sb.toString()); window.setError(Messages.get().secondaryLabel_errorsPrintingLabels()); } else { window.setError("Failed"); Window.alert(caught.getMessage()); } } }); }
From source file:org.openelis.portal.modules.dataView.client.DataViewScreen.java
License:Open Source License
/** * creates a popup that shows the progress of creating data view report *//*from ww w . j a va 2 s. c om*/ private void popup(DataView1VO data) { final PopupPanel statusPanel; if (statusScreen == null) statusScreen = new StatusBarPopupScreenUI(); statusScreen.setStatus(null); /* * initialize and show the popup screen */ statusPanel = new PopupPanel(); statusPanel.setSize("450px", "125px"); statusScreen.setSize("450px", "125px"); statusPanel.setWidget(statusScreen); statusPanel.setPopupPosition(this.getAbsoluteLeft() + 50, this.getAbsoluteTop() + 50); statusPanel.setModal(true); statusPanel.show(); /* * Create final reports. Hide popup when database is updated * successfully or error is thrown. */ DataViewService.get().runReportForPortal(data, new AsyncCallback<ReportStatus>() { @Override public void onSuccess(ReportStatus result) { if (result.getStatus() == ReportStatus.Status.SAVED) { String url = "/openelisweb/openelisweb/report?file=" + result.getMessage(); Window.open(URL.encode(url), "DataView", "resizable=yes"); } window.clearStatus(); statusPanel.hide(); statusScreen.setStatus(null); } @Override public void onFailure(Throwable caught) { window.clearStatus(); statusPanel.hide(); statusScreen.setStatus(null); if (caught instanceof NotFoundException) window.setError(Messages.get().dataView_error_noResults()); else Window.alert(caught.getMessage()); } }); /* * refresh the status of creating the reports every second, until the * process successfully completes or is aborted because of an error */ Timer timer = new Timer() { public void run() { ReportStatus status; try { status = DataViewService.get().getStatus(); /* * the status only needs to be refreshed while the status * panel is showing because once the job is finished, the * panel is closed */ if (statusPanel.isShowing()) { statusScreen.setStatus(status); this.schedule(50); } } catch (Exception e) { Window.alert(e.getMessage()); remote.log(Level.SEVERE, e.getMessage(), e); } } }; timer.schedule(50); }
From source file:org.openelis.ui.screen.ReportScreen.java
License:Open Source License
/** * Provides a more generic interface to run reports so that screens not * implementing ReportScreen can utilize this functionality too *//*from ww w .ja v a 2s . c om*/ public void runReport(T rpc) { window.setBusy("genReportMessage"); runReport(rpc, new AsyncCallback<ReportStatus>() { public void onSuccess(ReportStatus status) { String url; if (status.getStatus() == ReportStatus.Status.SAVED) { url = "/timetracker/report?file=" + status.getMessage(); if (attachmentName != null) url += "&attachment=" + attachmentName; Window.open(URL.encode(url), name, null); window.setDone("Generated file " + status.getMessage()); } else { window.setDone(status.getMessage()); } } public void onFailure(Throwable caught) { window.setError("Failed"); Window.alert(caught.getMessage()); } }); }
From source file:org.opennms.ipv6.summary.gui.client.Navigation.java
License:Open Source License
@UiHandler("m_link") public void linkTopOpenNMSClicked(ClickEvent event) { StringBuffer postData = new StringBuffer(); // note param pairs are separated by a '&' // and each key-value pair is separated by a '=' postData.append(URL.encode("j_username")).append("=").append(URL.encode("ipv6")); postData.append("&"); postData.append(URL.encode("j_password")).append("=").append(URL.encode("ipv6")); postData.append("&"); postData.append(URL.encode("Login")).append("=").append(URL.encode("login")); RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode("/opennms/j_spring_security_check")); builder.setHeader("Content-type", "application/x-www-form-urlencoded"); try {//from w w w. j av a 2 s .c o m builder.sendRequest(postData.toString(), new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { Window.open("/opennms/index.jsp", "_target", null); } else { Window.alert("Failed to login"); } } @Override public void onError(Request request, Throwable exception) { Window.alert("Problem Logging in"); } }); } catch (RequestException e) { // TODO Auto-generated catch block e.printStackTrace(); } //Window.alert("Cliking link to OpenNMS"); }
From source file:org.openremote.modeler.client.rpc.AsyncSuccessCallback.java
License:Open Source License
protected boolean checkTimeout(Throwable caught) { if (caught instanceof StatusCodeException) { StatusCodeException sce = (StatusCodeException) caught; if (sce.getStatusCode() == 401) { MessageBox.confirm("Timeout", "Your session has timeout, please login again. ", new Listener<MessageBoxEvent>() { @Override public void handleEvent(MessageBoxEvent be) { if (be.getButtonClicked().getItemId().equals(Dialog.YES)) { Window.open("login.jsp", "_self", ""); }/*from w w w . j ava 2 s . co m*/ } }); return true; } } return false; }
From source file:org.openremote.modeler.client.utils.ImageSourceValidator.java
License:Open Source License
public static String validate(String resultHtml) { String result = resultHtml;/*w w w. j a va 2s . c o m*/ if (resultHtml != null) { //remove unnecessary string for chrome browser. result = resultHtml.replaceAll("^<pre[^>]*>", "").replaceAll("</pre>$", ""); //Timeout if (!result.matches(".+?\\.(png|gif|jpg|jpeg|PNG|GIF|JPG|GPEG)") && result.contains("401")) { MessageBox.confirm("Timeout", "Your session has timeout, please login again. ", new Listener<MessageBoxEvent>() { @Override public void handleEvent(MessageBoxEvent be) { if (be.getButtonClicked().getItemId().equals(Dialog.YES)) { Window.open("login.jsp", "_self", ""); } } }); return ""; } } return result; }
From source file:org.openremote.modeler.client.view.ApplicationView.java
License:Open Source License
/** * Initialize.//from w w w. ja va2s. c om * * @see org.openremote.modeler.client.view.View#initialize() */ public void initialize() { Protocols.getInstance(); // get protocol definition from xml files viewport = new Viewport(); viewport.setLayout(new BorderLayout()); final AuthorityRPCServiceAsync auth = (AuthorityRPCServiceAsync) GWT.create(AuthorityRPCService.class); final ApplicationView that = this; auth.getAuthority(new AsyncCallback<Authority>() { public void onFailure(Throwable caught) { MessageBox.info("Info", caught.getMessage(), null); } public void onSuccess(Authority authority) { if (authority != null) { that.authority = authority; createNorth(); createCenter(authority); show(); } else { Window.open("login.jsp", "_self", null); } } }); }
From source file:org.openremote.modeler.client.view.ApplicationView.java
License:Open Source License
private void initSaveAndExportButtons() { saveButton = new Button(); saveButton.setIcon(icons.saveIcon()); saveButton.setToolTip("Save"); saveButton.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override//from w w w . j av a 2s. c o m public void componentSelected(ButtonEvent ce) { uiDesignerView.saveUiDesignerLayout(); } }); exportButton = new Button(); exportButton.setIcon(icons.exportAsZipIcon()); exportButton.setToolTip("Export as zip"); exportButton.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (!isExportedDataValid()) { MessageBox.info("Info", "Nothing to export.", null); return; } viewport.mask("Exporting, please wait."); UtilsProxy.exportFiles(IDUtil.currentID(), uiDesignerView.getAllPanels(), new AsyncSuccessCallback<String>() { @Override public void onSuccess(String exportURL) { viewport.unmask(); Window.open(exportURL, "_blank", ""); } }); } }); }
From source file:org.openremote.modeler.client.view.ApplicationView.java
License:Open Source License
private Button createLogoutButton() { String currentUserName = (this.authority == null) ? "" : "(" + this.authority.getUsername() + ")"; Button logoutButton = new Button(); logoutButton.setIcon(icons.logout()); logoutButton.setToolTip("Logout" + currentUserName); logoutButton.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override//from w w w.j ava 2 s. c o m public void componentSelected(ButtonEvent ce) { Window.open("j_security_logout", "_self", ""); } }); return logoutButton; }