001: /*
002: * CoadunationAdmin: The admin frontend for coadunation.
003: * Copyright (C) 2007 - 2008 Rift IT Contracting
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
018: *
019: * WebServicePancle.java
020: */
021:
022: // package path
023: package com.rift.coad.web.admin.client;
024:
025: // imports
026: import com.google.gwt.user.client.Window;
027: import com.google.gwt.user.client.ui.AbstractImagePrototype;
028: import com.google.gwt.user.client.ui.Composite;
029: import com.google.gwt.user.client.ui.ImageBundle;
030: import com.google.gwt.user.client.ui.ScrollPanel;
031: import com.google.gwt.user.client.ui.VerticalPanel;
032: import com.google.gwt.user.client.ui.DockPanel;
033: import com.google.gwt.user.client.ui.HTML;
034: import com.google.gwt.user.client.ui.Label;
035: import com.google.gwt.user.client.ui.ClickListener;
036: import com.google.gwt.user.client.ui.Widget;
037: import com.google.gwt.core.client.GWT;
038: import com.google.gwt.user.client.rpc.AsyncCallback;
039: import com.google.gwt.user.client.rpc.ServiceDefTarget;
040:
041: /**
042: * This panel is responsible for displaying the web servicde information.
043: *
044: * @author brett chaldecott
045: */
046: public class WebServicePanel extends Composite implements
047: ObjectsListener, ClickListener {
048:
049: // private member variables
050: private DockPanel dockPanel = null;
051: private ObjectsPanel objectsPanel = null;
052: private WSDLPanel wsdlPanel = null;
053: private WebServiceManagerAsync service = null;
054: private String webService = null;
055: private Label help = null;
056:
057: /**
058: * Creates a new instance of WebServicePancle
059: */
060: public WebServicePanel() {
061: VerticalPanel lhs = new VerticalPanel();
062: lhs.setSpacing(2);
063: objectsPanel = new ObjectsPanel(this , 450);
064: lhs.add(objectsPanel);
065:
066: help = new Label("Help");
067: help.addClickListener(this );
068: help.setStyleName("click-Label");
069: help.setWidth("100%");
070: lhs.add(help);
071:
072: VerticalPanel rhs = new VerticalPanel();
073: rhs.setWidth("100%");
074: rhs.setSpacing(2);
075: wsdlPanel = new WSDLPanel();
076: wsdlPanel.setWidth("100%");
077: rhs.add(wsdlPanel);
078:
079: dockPanel = new DockPanel();
080: dockPanel.setWidth("100%");
081: dockPanel.add(lhs, DockPanel.WEST);
082: dockPanel.add(rhs, DockPanel.CENTER);
083: dockPanel.setSpacing(2);
084: dockPanel.setCellWidth(rhs, "100%");
085:
086: // init the daemon manager
087: initWebServiceManager();
088:
089: // Create an asynchronous callback to handle the result.
090: service.getServices(new AsyncCallback() {
091: public void onSuccess(Object result) {
092: objectsPanel.setObjects((String[]) result);
093: }
094:
095: public void onFailure(Throwable caught) {
096: Window.alert("Failed to load the list of objects : "
097: + caught.getMessage());
098: }
099: });
100:
101: // init the widget
102: initWidget(dockPanel);
103: }
104:
105: /**
106: * init the daemon manager
107: */
108: private void initWebServiceManager() {
109: // Create the client proxy. Note that although you are creating the
110: // service interface proper, you cast the result to the asynchronous
111: // version of
112: // the interface. The cast is always safe because the generated proxy
113: // implements the asynchronous interface automatically.
114: service = (WebServiceManagerAsync) GWT
115: .create(WebServiceManager.class);
116: // Specify the URL at which our service implementation is running.
117: // Note that the target URL must reside on the same domain and port from
118: // which the host page was served.
119: //
120: ServiceDefTarget endpoint = (ServiceDefTarget) service;
121: String moduleRelativeURL = GWT.getModuleBaseURL()
122: + "webservicemanager";
123: endpoint.setServiceEntryPoint(moduleRelativeURL);
124: }
125:
126: /**
127: * This method is called when a wsdl object is selected.
128: *
129: * @param key The selected key.
130: */
131: public void objectSelected(String key) {
132: webService = key;
133: // Create an asynchronous callback to handle the result.
134: service.getWebServiceDef(webService, new AsyncCallback() {
135: public void onSuccess(Object result) {
136: wsdlPanel.setWebServiceDef((WebServiceDef) result);
137: }
138:
139: public void onFailure(Throwable caught) {
140: Window.alert("Failed to load the list of objects :"
141: + caught.getMessage());
142: }
143: });
144: }
145:
146: /**
147: * This method is responsible for displaying the help information.
148: */
149: public void onClick(Widget widget) {
150: if (help == widget) {
151: HelpDialog
152: .getInstance()
153: .setContent(
154: "The Web Services Admin Panel enables users to view the "
155: + "<br>web service information for the Coadunation managed "
156: + "<br>web services."
157: + "<br>"
158: + "<br>Follow these steps to view the information for a "
159: + "<br>deployed web service."
160: + "<br>"
161: + "<br><b>Step 1:</b>"
162: + "<br>Select the web service by name from the objects panel."
163: + "<br><img src='images/WebServiceObjects.gif'/>"
164: + "<br>"
165: + "<br><b>Step 2:</b>"
166: + "<br>View the WSDL information displayed in the right hand "
167: + "<br>side panel."
168: + "<br><img src='images/WSDL.gif'/>");
169: //HelpDialog.getInstance().show();
170: }
171: }
172:
173: }
|