/*
 * GWT-Ext Widget Library
 * Copyright 2007 - 2008, GWT-Ext LLC., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
 
package com.gwtext.sample.showcase2.client.panel;

import com.google.gwt.user.client.ui.HorizontalPanel;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Function;
import com.gwtext.client.dd.DD;
import com.gwtext.client.widgets.*;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.layout.FitLayout;
import com.gwtext.client.widgets.layout.VerticalLayout;
import com.gwtext.sample.showcase2.client.SampleData;
import com.gwtext.sample.showcase2.client.ShowcasePanel;

public class PanelsSample extends ShowcasePanel {

    public String getSourceUrl() {
        return "source/panel/PanelsSample.java.html";
    }

    public String getCssUrl() {
        return "source/panel/PanelsSample.css.html";
    }

    public Panel getViewPanel() {
        if (panel == null) {
            panel = new Panel();

            HorizontalPanel horizontalPanel = new HorizontalPanel();
            horizontalPanel.setSpacing(15);

            Panel collapsiblePanel = new Panel();
            collapsiblePanel.setTitle("Collapsible Panel");
            collapsiblePanel.setWidth(200);
            collapsiblePanel.setCollapsible(true);
            collapsiblePanel.setHtml(SampleData.getShortBogusMarkup());

            Panel iconPanel = new Panel();
            iconPanel.setTitle("Icon Panel");
            iconPanel.setIconCls("paste-icon");
            iconPanel.setWidth(200);
            iconPanel.setHtml(SampleData.getShortBogusMarkup());
            iconPanel.setShadow(true);

            HorizontalPanel horizontalPanel2 = new HorizontalPanel();
            horizontalPanel2.setSpacing(15);

            Panel draggablePanel = new Panel();
            draggablePanel.setTitle("Draggable Panel");
            draggablePanel.setDraggable(true);
            draggablePanel.setWidth(200);
            draggablePanel.setHtml(SampleData.getShortBogusMarkup());
            draggablePanel.setShadow(true);
            DD dd = new DD(draggablePanel);

            Panel toolsPanel = new Panel();
            toolsPanel.setTitle("Tools Panel");
            toolsPanel.setIconCls("paste-icon");
            toolsPanel.setWidth(200);
            toolsPanel.setHtml(SampleData.getShortBogusMarkup());
            toolsPanel.setShadow(true);
            toolsPanel.addTool(new Tool(Tool.GEAR, new Function() {
                public void execute() {
                    MessageBox.alert("Settings", "The Settings tool was clicked");
                }
            }, "Settings"));
            toolsPanel.addTool(new Tool(Tool.SEARCH, new Function() {
                public void execute() {
                    MessageBox.alert("Search", "The Search tool was clicked");
                }
            }, "Search"));

            Panel windowPanel = new Panel();
            windowPanel.setHtml(SampleData.getShortBogusMarkup());
            windowPanel.setShadow(true);

            final Window window = new Window();
            window.setTitle("Window Panel");
            window.setIconCls("paste-icon");
            window.setMaximizable(true);
            window.setResizable(true);
            window.setLayout(new FitLayout());
            window.setWidth(200);
            window.setModal(false);

            window.addTool(new Tool(Tool.REFRESH, new Function() {
                public void execute() {
                    MessageBox.alert("Refresh", "The Refresh tool was clicked");
                }
            }, "Refresh"));
            window.addTool(new Tool(Tool.PIN, new Function() {
                public void execute() {
                    MessageBox.alert("Pin", "The Pin tool was clicked");
                }
            }, "Pin"));
            window.add(windowPanel);

            Button button = new Button("Show Window Panel", new ButtonListenerAdapter() {
                public void onClick(Button button, EventObject e) {
                    window.show();
                }
            });

            window.setAnimateTarget(button.getId());

            horizontalPanel.add(collapsiblePanel);
            horizontalPanel.add(toolsPanel);
            horizontalPanel2.add(draggablePanel);
            horizontalPanel2.add(button);

            Panel verticalPanel = new Panel();
            verticalPanel.setLayout(new VerticalLayout(15));
            verticalPanel.add(horizontalPanel);
            verticalPanel.add(horizontalPanel2);

            panel.add(verticalPanel);
        }
        return panel;
    }

    public String getIntro() {
        return "A demonstration of basic Panel styles and configurations.";
    }
}