Package org.gwtoolbox.sample.widget.client.layout

Source Code of org.gwtoolbox.sample.widget.client.layout.CombinedLayoutSample

package org.gwtoolbox.sample.widget.client.layout;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.ui.*;
import org.gwtoolbox.ioc.core.client.annotation.Component;
import org.gwtoolbox.ioc.core.client.annotation.Order;
import org.gwtoolbox.sample.widget.client.SamplePanel;
import org.gwtoolbox.widget.client.panel.LayoutUtils;
import org.gwtoolbox.widget.client.panel.layout.DockLayout;
import org.gwtoolbox.widget.client.panel.layout.PanelLayout;
import org.gwtoolbox.widget.client.panel.layout.SplitLayout;
import org.gwtoolbox.widget.client.panel.layout.drawer.Drawer;
import org.gwtoolbox.widget.client.panel.layout.drawer.DrawerLayout;
import org.gwtoolbox.widget.client.panel.layout.tab.TabLayout;

/**
* @author Uri Boness
*/
@Component
@Order(100)
@LayoutSample
public class CombinedLayoutSample extends ResizeComposite implements SamplePanel {

    public CombinedLayoutSample() {
        final DockLayout main = new DockLayout();

        final DrawerLayout drawers = new DrawerLayout();

        PanelLayout navigation = new PanelLayout("Navigation");
        navigation.addCloseHandler(new CloseHandler<PanelLayout>() {
            public void onClose(CloseEvent<PanelLayout> event) {
                drawers.hideDrawer(DrawerLayout.Position.LEFT);
            }
        });
        Drawer navigationDrawer = new Drawer("Navigation", navigation, DrawerLayout.Position.LEFT);
        drawers.addDrawer(navigationDrawer);

        SplitLayout split = new SplitLayout();
        split.addNorth(createHTML("Top content", "#ffcccc"), 200);

        TabLayout tabs = new TabLayout();
        tabs.addTab("Tab 1", createHTML("Tab Content", "white"));
        split.add(tabs);
        LayoutUtils.fitParent(tabs);
       
        drawers.setContent(split);
        LayoutUtils.fitParent(split);

        main.addNorth(createHTML("Header", "#ccffcc"), 100);
        main.add(drawers);

        PanelLayout layout = new PanelLayout("Combined Layout");
        layout.setContent(main);
        layout.setCollapsable(true);
        LayoutUtils.fitParent(main);


        initWidget(layout);
    }

    public String getName() {
        return "Combined Layout";
    }

    public Widget getContentWidget() {
        return this;
    }

    public void reset() {
    }


    //================================================ Helper Methods ==================================================

    private static HTML createHTML(String text, String color) {
        HTML html = new HTML(text);
        html.getElement().getStyle().setBackgroundColor(color);
        html.setSize("100%", "100%");
        return html;
    }
   
}
TOP

Related Classes of org.gwtoolbox.sample.widget.client.layout.CombinedLayoutSample

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.