Package org.cafesip.jiplet.console.client

Source Code of org.cafesip.jiplet.console.client.FormsPanel

/*
* Created on Jul 19, 2006
*
* Copyright 2005 CafeSip.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.cafesip.jiplet.console.client;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

/**
* @author Amit Chatterjee
*
*/
public class FormsPanel extends ScrollPanel
{
    private static FormsPanel instance = null;

    private SimplePanel panel;

    /**
     * A constructor for this class.
     *
     */
    public FormsPanel()
    {
        super();
        setSize("100%", "100%");
        setStyleName("jiplet-FormsPanel");

        panel = new SimplePanel();
        setWidget(panel);

        showHomePage();
        instance = this;
    }

    public static FormsPanel getInstance()
    {
        if (instance == null)
        {
            new FormsPanel();
        }

        return instance;
    }

    public void showHomePage()
    {
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
                "home.jsp");
        builder.setCallback(new RequestCallback() {

            public void onError(Request request, Throwable exception)
            {
                Window.alert("An error occured while requesting the home page" +
                    " from the server. " + exception.getMessage());               
            }

            public void onResponseReceived(Request request, Response response)
            {
                HTMLPanel p = new HTMLPanel(response.getText());
                p.setStyleName("jiplet-Form");
                setCurrentPanel(p);
               
            }});

        try
        {
            builder.send();
        }
        catch (RequestException e)
        {
            Window.alert("An error occured while requesting the home page" +
                    " from the server. " + e.getMessage());
        }
    }

    public void setCurrentPanel(Widget w)
    {
        panel.setWidget(w);
        panel.setStyleName("jiplet-Form");
    }

    public Widget getCurrentPanel()
    {
        return panel.getWidget();
    }

}
TOP

Related Classes of org.cafesip.jiplet.console.client.FormsPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.