List of usage examples for com.google.gwt.http.client URL encode
public static String encode(String decodedURL)
From source file:org.openxdata.sharedlib.client.widget.RuntimeGroupWidget.java
private int loadWidget(FormDef formDef, Element node, HashMap<Integer, RuntimeWidgetWrapper> widgets, List<RuntimeWidgetWrapper> externalSourceWidgets, HashMap<QuestionDef, List<QuestionDef>> calcQtnMappings, HashMap<QuestionDef, List<RuntimeWidgetWrapper>> calcWidgetMap, HashMap<QuestionDef, RuntimeWidgetWrapper> filtDynOptWidgetMap) { RuntimeWidgetWrapper parentWrapper = null; String s = node.getAttribute(WidgetEx.WIDGET_PROPERTY_WIDGETTYPE); int tabIndex = (node.getAttribute(WidgetEx.WIDGET_PROPERTY_TABINDEX) != null ? Integer.parseInt(node.getAttribute(WidgetEx.WIDGET_PROPERTY_TABINDEX)) : 0);/*from w ww .ja va2 s . c o m*/ QuestionDef questionDef = null; String binding = node.getAttribute(WidgetEx.WIDGET_PROPERTY_BINDING); String parentBinding = node.getAttribute(WidgetEx.WIDGET_PROPERTY_PARENTBINDING); if (isRepeated) { if (binding != null && binding.trim().length() > 0 && repeatQtnsDef != null) { questionDef = repeatQtnsDef.getQuestion(binding); if (questionDef != null) questionDef.setAnswer(questionDef.getDefaultValue()); //Just incase we are refreshing and had already set the answer } } else { if (binding != null && binding.trim().length() > 0) { questionDef = formDef.getQuestion(binding); if (questionDef != null) questionDef.setAnswer(questionDef.getDefaultValue()); //Just incase we are refreshing and had already set the answer } } RuntimeWidgetWrapper wrapper = null; boolean wrapperSet = false; Widget widget = null; if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_RADIOBUTTON)) { /*widget = new RadioButton(parentBinding,node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT)); parentWrapper = getParentWrapper(widget,node); ((RadioButton)widget).setTabIndex(tabIndex);*/ widget = new RadioButtonWidget(parentBinding, node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT)); if (widgetMap.get(parentBinding) == null) wrapperSet = true; parentWrapper = getParentWrapper(widget, node, parentBinding); ((RadioButton) widget).setTabIndex(tabIndex); if (wrapperSet) { wrapper = parentWrapper; questionDef = formDef.getQuestion(parentBinding); } } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_CHECKBOX)) { /*widget = new CheckBox(node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT)); parentWrapper = getParentWrapper(widget,node); ((CheckBox)widget).setTabIndex(tabIndex);*/ widget = new CheckBoxWidget(node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT)); if (widgetMap.get(parentBinding) == null) wrapperSet = true; parentWrapper = getParentWrapper(widget, node, parentBinding); ((CheckBox) widget).setTabIndex(tabIndex); String defaultValue = parentWrapper.getQuestionDef().getDefaultValue(); if (defaultValue != null && defaultValue.contains(binding)) ((CheckBox) widget).setValue(true); if (wrapperSet) { wrapper = parentWrapper; questionDef = formDef.getQuestion(parentBinding); } } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_BUTTON)) { widget = new Button(node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT)); ((Button) widget).setTabIndex(tabIndex); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_LISTBOX)) { widget = new ListBoxWidget(false); ((ListBox) widget).setTabIndex(tabIndex); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_TEXTAREA)) { widget = new TextArea(); ((TextArea) widget).setTabIndex(tabIndex); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_DATEPICKER)) { widget = new DatePickerWidget(); ((DatePickerEx) widget).setTabIndex(tabIndex); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_DATETIME)) { widget = new DateTimeWidget(); ((DateTimeWidget) widget).setTabIndex(tabIndex); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_TIME)) { widget = new TimeWidget(); ((TimeWidget) widget).setTabIndex(tabIndex); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_TEXTBOX)) { widget = new TextBox(); if (questionDef != null && (questionDef.getDataType() == QuestionType.NUMERIC || questionDef.getDataType() == QuestionType.DECIMAL)) FormUtil.allowNumericOnly((TextBox) widget, questionDef.getDataType() == QuestionType.DECIMAL); ((TextBox) widget).setTabIndex(tabIndex); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_LABEL)) { String text = node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT); if (text == null) text = "No Label Text"; widget = new Label(text); int pos1 = text.indexOf("${"); int pos2 = text.indexOf("}$"); if (pos1 > -1 && pos2 > -1 && (pos2 > pos1)) { String varname = text.substring(pos1 + 2, pos2); labelText.put((Label) widget, text); labelReplaceText.put((Label) widget, "${" + varname + "}$"); ((Label) widget).setText(text.replace("${" + varname + "}$", "")); if (varname.startsWith("/" + formDef.getBinding() + "/")) varname = varname.substring(("/" + formDef.getBinding() + "/").length(), varname.length()); QuestionDef qtnDef = formDef.getQuestion(varname); List<Label> labels = labelMap.get(qtnDef); if (labels == null) { labels = new ArrayList<Label>(); labelMap.put(qtnDef, labels); } labels.add((Label) widget); } } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_IMAGE)) { widget = new Image(); String xpath = binding; if (!xpath.startsWith(formDef.getBinding())) xpath = "/" + formDef.getBinding() + "/" + binding; ((Image) widget).setUrl(URL.encode(FormUtil.getMultimediaUrl() + "?formId=" + formDef.getId() + "&xpath=" + xpath + "&time=" + new java.util.Date().getTime())); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_VIDEO_AUDIO) && questionDef != null) { widget = new HTML(); String xpath = binding; if (!xpath.startsWith(formDef.getBinding())) xpath = "/" + formDef.getBinding() + "/" + binding; String extension = "";//.3gp ".mpeg"; String contentType = "&contentType=video/3gpp"; if (questionDef.getDataType() == QuestionType.AUDIO) contentType = "&contentType=audio/3gpp"; //"&contentType=audio/x-wav"; //extension = ".wav"; contentType += "&name=" + questionDef.getBinding() + ".3gp"; ((HTML) widget).setHTML("<a href=" + URL.encode(FormUtil.getMultimediaUrl() + extension + "?formId=" + formDef.getId() + "&xpath=" + xpath + contentType + "&time=" + new java.util.Date().getTime()) + ">" + node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT) + "</a>"); String answer = questionDef.getAnswer(); if (answer == null || answer.trim().length() == 0) ((HTML) widget).setVisible(false); } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_GROUPBOX) || s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_REPEATSECTION)) { RepeatQtnsDef repeatQtnsDef = null; if (questionDef != null) repeatQtnsDef = questionDef.getRepeatQtnsDef(); boolean repeated = false; String value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_REPEATED); if (value != null && value.trim().length() > 0) repeated = (value.equals(WidgetEx.REPEATED_TRUE_VALUE)); widget = new RuntimeGroupWidget(images, formDef, repeatQtnsDef, editListener, repeated); ((RuntimeGroupWidget) widget).loadWidgets(formDef, node.getChildNodes(), externalSourceWidgets, calcQtnMappings, calcWidgetMap, filtDynOptWidgetMap); /*getLabelMap(((RuntimeGroupWidget)widget).getLabelMap()); getLabelText(((RuntimeGroupWidget)widget).getLabelText()); getLabelReplaceText(((RuntimeGroupWidget)widget).getLabelReplaceText()); getCheckBoxGroupMap(((RuntimeGroupWidget)widget).getCheckBoxGroupMap());*/ } /*else if(s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_REPEATSECTION)){ //Not dealing with nested repeats //widget = new RunTimeGroupWidget(); //((RunTimeGroupWidget)widget).setTabIndex(tabIndex); }*/ else return tabIndex; if (!wrapperSet) { wrapper = new RuntimeWidgetWrapper(widget, images.error(), editListener); if (parentWrapper != null) { //Check box or radio button if (!parentWrapper.getQuestionDef().isVisible()) wrapper.setVisible(false); if (!parentWrapper.getQuestionDef().isEnabled()) wrapper.setEnabled(false); if (parentWrapper.getQuestionDef().isLocked()) wrapper.setLocked(true); } } //RuntimeWidgetWrapper wrapper = new RuntimeWidgetWrapper(widget,images.error(),editListener); boolean loadWidget = true; String value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_HELPTEXT); if (value != null && value.trim().length() > 0) wrapper.setTitle(value); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_WIDTH); if (value != null && value.trim().length() > 0) wrapper.setWidth(value); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_HEIGHT); if (value != null && value.trim().length() > 0) wrapper.setHeight(value); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_EXTERNALSOURCE); if (value != null && value.trim().length() > 0) wrapper.setExternalSource(value); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_DISPLAYFIELD); if (value != null && value.trim().length() > 0) wrapper.setDisplayField(value); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_FILTERFIELD); if (value != null && value.trim().length() > 0) wrapper.setFilterField(value); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_ID); if (value != null && value.trim().length() > 0) wrapper.setId(value); if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_VIDEO_AUDIO) || s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_IMAGE)) { if (binding != null && binding.trim().length() > 0) { questionDef = formDef.getQuestion(binding); if (questionDef != null) questionDef.setAnswer(questionDef.getDefaultValue()); //Just incase we are refreshing and had already set the answer } } if (questionDef != null) { if (questionDef.getDataType() == QuestionType.LIST_EXCLUSIVE_DYNAMIC) { questionDef.setOptions(null); //may have been set by the preview //if(wrapper.getWrappedWidget() instanceof ListBox || wrapper.getWrappedWidget() instanceof TextBox) if (wrapper.getFilterField() != null && wrapper.getFilterField().trim().length() > 0) filtDynOptWidgetMap.put(questionDef, wrapper); } wrapper.setQuestionDef(questionDef, false); ValidationRule validationRule = formDef.getValidationRule(questionDef); wrapper.setValidationRule(validationRule); } if (parentBinding != null) wrapper.setParentBinding(parentBinding); if (binding != null) wrapper.setBinding(binding); if (parentWrapper != null) parentWrapper.addChildWidget(wrapper); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_VALUEFIELD); if (value != null && value.trim().length() > 0) { wrapper.setValueField(value); if (externalSourceWidgets != null && wrapper.getExternalSource() != null && wrapper.getDisplayField() != null && (wrapper.getWrappedWidget() instanceof TextBox || wrapper.getWrappedWidget() instanceof ListBox) && questionDef != null && (wrapper.getQuestionDef().getDataType() == QuestionType.LIST_EXCLUSIVE || wrapper.getQuestionDef().getDataType() == QuestionType.LIST_MULTIPLE)) { externalSourceWidgets.add(wrapper); loadWidget = false; } } if (loadWidget) wrapper.loadQuestion(); wrapper.setExternalSourceDisplayValue(); value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_HEIGHT); if (value != null && value.trim().length() > 0) wrapper.setHeight(value); String left = node.getAttribute(WidgetEx.WIDGET_PROPERTY_LEFT); if (left != null && left.trim().length() > 0) wrapper.setLeft(left); String top = node.getAttribute(WidgetEx.WIDGET_PROPERTY_TOP); if (top != null && top.trim().length() > 0) wrapper.setTop(top); //if(wrapper.getWrappedWidget() instanceof Label) WidgetEx.loadLabelProperties(node, wrapper); wrapper.setTabIndex(tabIndex); //wrapper.setParentBinding(parentBinding); if (tabIndex > 0 && !(wrapper.getWrappedWidget() instanceof Button)) widgets.put(new Integer(tabIndex), wrapper); else addWidget(wrapper); if (wrapperSet) ;//FormUtil.setWidgetPosition(wrapper,left,top); if (widget instanceof Button && binding != null) { //wrapper.setParentBinding(parentBinding); if (binding.equals("addnew") || binding.equals("remove") || binding.equals("submit") || binding.equals("browse") || binding.equals("clear") || binding.equals("cancel") || binding.equals("search")) { ((Button) widget).addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { execute((Widget) event.getSource()); } }); } } if (wrapper.isEditable() && questionDef != null) FormRunnerView.updateCalcWidgetMapping(wrapper, calcQtnMappings, calcWidgetMap); return tabIndex; }
From source file:org.openxdata.sharedlib.client.widget.RuntimeGroupWidget.java
public void onSetFileContents(String contents) { if (contents != null && contents.trim().length() > 0) { contents = contents.replace("<pre>", ""); contents = contents.replace("</pre>", ""); RuntimeWidgetWrapper widgetWrapper = null; if (image != null) widgetWrapper = (RuntimeWidgetWrapper) image.getParent().getParent(); else/*from www . ja v a2 s . c o m*/ widgetWrapper = (RuntimeWidgetWrapper) html.getParent().getParent(); String xpath = widgetWrapper.getBinding(); if (!xpath.startsWith(formDef.getBinding())) xpath = "/" + formDef.getBinding() + "/" + widgetWrapper.getBinding(); if (image != null) image.setUrl(FormUtil.getMultimediaUrl() + "?action=recentbinary&time=" + new java.util.Date().getTime() + "&formId=" + formDef.getId() + "&xpath=" + xpath); else { String extension = "";//.3gp ".mpeg"; String contentType = "&contentType=video/3gpp"; if (widgetWrapper.getQuestionDef().getDataType() == QuestionType.AUDIO) contentType = "&contentType=audio/3gpp"; //"&contentType=audio/x-wav"; //extension = ".wav"; contentType += "&name=" + widgetWrapper.getQuestionDef().getBinding() + ".3gp"; html.setVisible(true); html.setHTML("<a href=" + URL.encode(FormUtil.getMultimediaUrl() + extension + "?formId=" + formDef.getId() + "&xpath=" + xpath + contentType + "&time=" + new java.util.Date().getTime()) + ">" + html.getText() + "</a>"); } widgetWrapper.getQuestionDef().setAnswer(contents); } }
From source file:org.oscim.web.client.SearchBox.java
License:Open Source License
public SearchBox(final Map map) { final Button searchButton = new Button("Search"); final TextBox searchField = new TextBox(); //searchField.setText("Bremen"); final PathLayer mOverlay = new PathLayer(map, 0xCC0000FF); map.layers().add(mOverlay);//from w w w . j ava 2 s. com // We can add style names to widgets searchButton.addStyleName("sendButton"); RootPanel.get("nameFieldContainer").add(searchField); RootPanel.get("sendButtonContainer").add(searchButton); // Focus the cursor on the name field when the app loads searchField.setFocus(true); searchField.selectAll(); // Create a cell to render each value in the list. PoiCell poiCell = new PoiCell(); // Create a CellList that uses the cell. final CellList<PoiData> cellList = new CellList<PoiData>(poiCell, PoiData.KEY_PROVIDER); final SingleSelectionModel<PoiData> selectionModel = new SingleSelectionModel<PoiData>( PoiData.KEY_PROVIDER); cellList.setSelectionModel(selectionModel); final ScrollPanel scroller = new ScrollPanel(cellList); RootPanel.get("listContainer").add(scroller); scroller.setSize("350px", "300px"); RootPanel.get("search").getElement().getStyle().setVisibility(Visibility.VISIBLE); scroller.setVisible(false); searchField.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { scroller.setVisible(true); } }); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { final PoiData d = selectionModel.getSelectedObject(); mOverlay.clearPath(); //log.debug("selected " + d.getName() + " " + d.getLatitude() + " " // + d.getLongitude()); BoundingBox b = d.getBoundingBox(); if (b != null) { if (b.maxLatitudeE6 - b.minLatitudeE6 < 100 && b.maxLongitudeE6 - b.minLongitudeE6 < 100) // for small bbox use zoom=16 to get an overview map.animator().animateTo(500, b.getCenterPoint(), 1 << 16, false); else map.animator().animateTo(b); if (d instanceof NominatimData && ((NominatimData) d).getWkt() != null) { String wkt = ((NominatimData) d).getWkt(); WKTReader r = new WKTReader(); GeometryBuffer g = new GeometryBuffer(1024, 10); try { r.parse(wkt, g); } catch (Exception e) { log.debug(wkt); } //FIXME mOverlay.setGeom(g); //log.debug("add polygon " + p.length()); } else { mOverlay.addPoint(b.maxLatitudeE6, b.minLongitudeE6); mOverlay.addPoint(b.maxLatitudeE6, b.maxLongitudeE6); mOverlay.addPoint(b.minLatitudeE6, b.maxLongitudeE6); mOverlay.addPoint(b.minLatitudeE6, b.minLongitudeE6); mOverlay.addPoint(b.maxLatitudeE6, b.minLongitudeE6); } // hide overlay after 5 seconds map.postDelayed(new Runnable() { @Override public void run() { mOverlay.clearPath(); } }, 5000); } else { MapPosition pos = new MapPosition(); map.viewport().setTilt(0); map.viewport().setRotation(0); pos.setZoomLevel(13); pos.setPosition(d.getLatitude(), d.getLongitude()); map.setMapPosition(pos); } scroller.setVisible(false); } }); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendRequest(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendRequest(); } } /** * Send the name from the nameField to the server and wait for a * response. */ private void sendRequest() { String textToServer = searchField.getText(); searchButton.setEnabled(false); String url = URL.encode(NOMINATIM_GLOBAL + textToServer); JsonpRequestBuilder builder = new JsonpRequestBuilder(); builder.setCallbackParam("json_callback"); builder.requestObject(url, new AsyncCallback<JsArray<NominatimData>>() { public void onFailure(Throwable caught) { log.debug("request failed"); searchButton.setEnabled(true); } public void onSuccess(JsArray<NominatimData> data) { List<PoiData> items = new ArrayList<PoiData>(); for (int i = 0, n = data.length(); i < n; i++) { NominatimData d = data.get(i); items.add(d); } cellList.setRowCount(items.size(), true); cellList.setRowData(0, items); scroller.setVisible(true); searchButton.setEnabled(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); searchButton.addClickHandler(handler); searchField.addKeyUpHandler(handler); }
From source file:org.otalo.ao.client.JSONRequest.java
License:Apache License
public void doFetchURL(String fetchURL, JSONRequester requester) { this.requester = requester; // RequestBuilder used to issue HTTP GET requests. RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, URL.encode(BASE_URL + fetchURL)); try {//from w ww .ja va 2s . c om requestBuilder.sendRequest(null, new JSONResponseTextHandler()); } catch (RequestException ex) { // TODO } }
From source file:org.otalo.ao.client.JSONRequest.java
License:Apache License
public void doPost(String fetchURL, String postData, JSONRequester requester) { this.requester = requester; // RequestBuilder used to issue HTTP GET requests. RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, URL.encode(BASE_URL + fetchURL)); requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded"); try {/* www .j a va2 s .c om*/ requestBuilder.sendRequest(postData, new JSONResponseTextHandler()); } catch (RequestException ex) { // TODO } }
From source file:org.ow2.proactive_grid_cloud_portal.common.client.LoginPage.java
License:Open Source License
/** * Creates the layout and add it to the page *//*from ww w. ja va2 s . com*/ private void buildAndShow() { Img logo = new Img(controller.getLogo350Url(), 349, 75); // contains the forms for authentication final VLayout auth = new VLayout(); auth.setBackgroundColor("#f0f0f0"); auth.setBorder("1px solid #ccc"); auth.setWidth(350); auth.setHeight(140); auth.setAlign(VerticalAlignment.CENTER); auth.setPadding(10); authSelLayout = new HLayout(); authSelLayout.setAlign(Alignment.CENTER); //authSel.setMargin(5); authSelLayout.setWidth100(); authSelLayout.setHeight(20); final SelectItem sl = new SelectItem("Mode"); sl.setValueMap("Basic", "Credentials"); sl.setValue("Basic"); authTypeSelectForm = new DynamicForm(); authTypeSelectForm.setNumCols(1); authTypeSelectForm.setFields(sl); authSelLayout.addMember(authTypeSelectForm); authSelLayout.setVisible(false); optsLabel = new Label( "<nobr style='color:#003168;font-size: 1.2em;cursor:pointer'>" + "more options</nobr>"); optsLabel.setHeight(30); optsLabel.setIcon(Images.instance.expand_16().getSafeUri().asString()); optsLabel.setAlign(Alignment.RIGHT); optsLabel.setValign(VerticalAlignment.TOP); optsLabel.setWidth100(); final Layout plainLayout = getPlainAuth(); final Layout credLayout = getCredAuth(); credLayout.hide(); Label label = new Label("<nobr style='color:#003168;font-size:1.2em;'><strong>" + Config.get().getApplicationName() + "</strong> login</nobr>"); label.setHeight(30); label.setValign(VerticalAlignment.TOP); Canvas filler = new Canvas(); filler.setWidth100(); HLayout labelLayout = new HLayout(); labelLayout.setWidth100(); labelLayout.setHeight(30); labelLayout.setMembers(label, optsLabel); motdCanvas = new HLayout(); motdCanvas.setPadding(5); motdCanvas.setMembersMargin(5); //motdCanvas.setBackgroundColor("#ddd"); Img img = new Img(Images.instance.info_32().getSafeUri().asString(), 32, 32); img.setLayoutAlign(Alignment.CENTER); motdLabel = new Label("wait"); motdLabel.setBackgroundColor("#e8e8e8"); motdLabel.setWidth100(); motdCanvas.addMember(img); //motdCanvas.addMember(separator); motdCanvas.addMember(motdLabel); motdMargin = new Canvas(); motdMargin.setHeight(10); motdCanvas.setVisible(false); motdMargin.setVisible(false); auth.addMember(motdCanvas); auth.addMember(motdMargin); String motdUrl = URL.encode(GWT.getModuleBaseURL() + "motd"); RequestBuilder rqb = new RequestBuilder(RequestBuilder.GET, motdUrl); try { rqb.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { String content; if (response.getStatusCode() == 200) { content = response.getText(); if (content.trim().length() == 0) { return; } } else if (response.getStatusCode() == 0) { return; } else { content = "Failed to get MOTD (" + response.getStatusCode() + " " + response.getStatusText() + ")"; } motdLabel.setContents( "<div style='color:#003168;font-size: 1.2em;border-left:5px solid #ccc;padding-left:5px'>" + content + "</div>"); motdCanvas.setVisible(true); motdMargin.setVisible(true); } @Override public void onError(Request request, Throwable exception) { System.out.println(exception); } }); } catch (RequestException e) { // not much we can do here... // not really important enough to display a trace on screen } auth.addMember(labelLayout); auth.addMember(authSelLayout); auth.addMember(plainLayout); auth.addMember(credLayout); switchPlainCredForm = new Runnable() { @Override public void run() { if (sl.getValueAsString().equals("Basic")) { plainLayout.animateShow(AnimationEffect.FLY); credLayout.animateHide(AnimationEffect.FLY); } else { credLayout.animateShow(AnimationEffect.FLY); plainLayout.animateHide(AnimationEffect.FLY); } } }; sl.addChangedHandler(new ChangedHandler() { public void onChanged(ChangedEvent event) { switchPlainCredForm.run(); } }); this.errorLabel = new Label(); errorLabel.setBorder("1px solid red"); errorLabel.setBackgroundColor("#fff0f0"); //errorLabel.setMargin(5); errorLabel.setPadding(5); errorLabel.setHeight(30); errorLabel.setAlign(Alignment.CENTER); // contains the logo and the forms VLayout vlayout = new VLayout(); vlayout.setMembersMargin(15); // 350(auth) + 2*10(padding) = 370 vlayout.setWidth(370); // 140(auth) + 15(membersMargin) + 88(logo) + 2*10(padding) = 263 vlayout.setHeight(263); vlayout.setPadding(10); vlayout.setBackgroundColor("#fafafa"); vlayout.setBorder("1px solid #ccc"); vlayout.setShowShadow(true); vlayout.setShadowSoftness(8); vlayout.setShadowOffset(3); vlayout.addMember(logo); vlayout.addMember(errorLabel); vlayout.addMember(auth); vlayout.hideMember(errorLabel); // dummy box for horizontal centering HLayout hlayout = new HLayout(); hlayout.setWidth100(); hlayout.setHeight(263); hlayout.setAlign(Alignment.CENTER); hlayout.addMember(vlayout); // dummy box for vertical centering this.layout = new VLayout(); this.layout.setHeight100(); this.layout.setWidth100(); this.layout.setAlign(VerticalAlignment.CENTER); this.layout.addMember(hlayout); this.layout.draw(); }
From source file:org.pentaho.mantle.client.commands.ExecuteUrlInNewTabCommand.java
License:Open Source License
protected void performOperation() { MantleTabPanel contentTabPanel = SolutionBrowserPanel.getInstance().getContentTabPanel(); contentTabPanel.showNewURLTab(this.tabName, this.tabToolTip, "about:blank", false); //$NON-NLS-1$ NamedFrame namedFrame = ((IFrameTabPanel) contentTabPanel.getSelectedTab().getContent()).getFrame(); final FormPanel form = new FormPanel(namedFrame); RootPanel.get().add(form);//from w w w . j a va 2 s. com form.setMethod(FormPanel.METHOD_POST); form.setAction(url); form.add(new Hidden("reportXml", URL.encode(xml))); //$NON-NLS-1$ form.submit(); ((IFrameTabPanel) contentTabPanel.getSelectedTab().getContent()).setForm(form); }
From source file:org.pentaho.mantle.client.commands.ExecuteWAQRPreviewCommand.java
License:Open Source License
protected void performOperation() { MantleTabPanel contentTabPanel = SolutionBrowserPerspective.getInstance().getContentTabPanel(); contentTabPanel.showNewURLTab(Messages.getString("preview"), Messages.getString("adhocPreview"), //$NON-NLS-1$//$NON-NLS-2$ "about:blank", false); //$NON-NLS-1$ NamedFrame namedFrame = ((IFrameTabPanel) contentTabPanel.getSelectedTab().getContent()).getFrame(); final FormPanel form = new FormPanel(namedFrame); RootPanel.get().add(form);//from w w w .j a va 2 s . c om form.setMethod(FormPanel.METHOD_POST); form.setAction(url); form.add(new Hidden("reportXml", URL.encode(xml))); //$NON-NLS-1$ form.submit(); ((IFrameTabPanel) contentTabPanel.getSelectedTab().getContent()).setForm(form); }
From source file:org.pentaho.platform.dataaccess.datasource.ui.importing.AnalysisImportDialogController.java
License:Open Source License
private void reloadConnections() { RequestBuilder listConnectionBuilder = new RequestBuilder(RequestBuilder.GET, URL.encode(getBaseURL() + "list")); listConnectionBuilder.setHeader("Content-Type", "application/json"); try {/*w w w .ja v a 2s .c o m*/ listConnectionBuilder.sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable exception) { exception.printStackTrace(); MessageHandler.getInstance().showErrorDialog(exception.getMessage()); } @Override public void onResponseReceived(Request request, Response response) { AutoBean<IDatabaseConnectionList> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnectionList.class, response.getText()); importDialogModel.setConnectionList(bean.as().getDatabaseConnections()); } }); } catch (RequestException e) { MessageHandler.getInstance().showErrorDialog(MessageHandler.getString("ERROR"), "DatasourceEditor.ERROR_0004_CONNECTION_SERVICE_NULL"); } }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController.java
License:Open Source License
public static String getServiceURL(String action) { return URL.encode(getBaseURL() + action); }