Package org.gwtoolbox.sample.widget.client.panel

Source Code of org.gwtoolbox.sample.widget.client.panel.ContentPanelSamplePane

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

import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import org.gwtoolbox.commons.ui.client.ggrowl.GGrowl;
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.commons.ui.client.event.custom.ToggleEvent;
import org.gwtoolbox.commons.ui.client.event.custom.ToggleHandler;
import org.gwtoolbox.widget.client.menu.Menu;
import org.gwtoolbox.widget.client.menu.MenuBuilder;
import org.gwtoolbox.widget.client.notification.DefaultNotifier;
import org.gwtoolbox.widget.client.panel.FitPanel;
import org.gwtoolbox.widget.client.panel.LayoutComposite;
import org.gwtoolbox.widget.client.panel.Scrolling;
import org.gwtoolbox.widget.client.panel.contentpanel.ContentPanel;
import org.gwtoolbox.widget.client.popup.dialog.ConfirmCallback;

/**
* @author Uri Boness
*/
@Component
@Order(1)
@PanelSample
public class ContentPanelSamplePane extends LayoutComposite implements SamplePanel {

    private ContentPanel contentPanel;

    public ContentPanelSamplePane() {

        Image image = new Image("images/gears.gif");
        contentPanel = new ContentPanel("Settings", image, true);
        contentPanel.setShowBorder(true);
        contentPanel.setCollapsable(true);
        contentPanel.setClosable(true);
        contentPanel.addCloseHandler(new CloseHandler<ContentPanel>() {
            public void onClose(CloseEvent<ContentPanel> contentPanelCloseEvent) {
                DefaultNotifier.getInstance().confirm("Confirm", "Are you sure you want to close this panel?", new ConfirmCallback() {
                    public void handle(Boolean confirmed) {
                        contentPanel.setVisible(!confirmed);
                    }
                });
            }
        });

        contentPanel.addMenuTool(ContentPanel.Tools.GEAR, new MenuBuilder() {
            public void build(Menu menu) {
                menu.addItem("Item 1", new Command() {
                    public void execute() {
                    }
                });
                menu.addItem("Item 2", new Command() {
                    public void execute() {
                    }
                });
                menu.addItem("Item 3", new Command() {
                    public void execute() {
                    }
                });
                Menu subMenu = new Menu(true);
                subMenu.addItem("Item 4", new Command() {
                    public void execute() {
                    }
                });
                subMenu.setAutoOpen(true);
                menu.addItem("Sub Menu", subMenu);
            }
        });

        contentPanel.addToggleTool(ContentPanel.ToggleTools.PIN, new ToggleHandler() {
            public void onToggle(ToggleEvent event) {
               GGrowl.showMessage("Message", "Pin " + (event.getState() ? "up" : "down"));
            }
        });

//        VerticalPanel content = new VerticalPanel();
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));
//        content.add(new Label("Some txt"));

        String text =
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>" +
                "Some text</br>";

        HTML content = new HTML(text);

//        CenterPanel content = new CenterPanel(new Label("This is the content of this panel"));
        content.setSize("100%", "100%");
        contentPanel.setContent(content);
        contentPanel.setContentVerticalScrolling(Scrolling.ALWAYS);

        FitPanel fp = new FitPanel(contentPanel);
        fp.setSize("400px", "500px");

        SimplePanel main = new SimplePanel();
        main.setWidget(fp);
        initWidget(main);
    }

    public String getName() {
        return "ContentPanel";
    }

    public Widget getContentWidget() {
        return this;
    }

    public void reset() {
        contentPanel.setVisible(true);
    }
}
TOP

Related Classes of org.gwtoolbox.sample.widget.client.panel.ContentPanelSamplePane

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.