package org.gwtoolbox.sample.widget.client;
import com.google.gwt.core.client.GWT;
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.Window;
import com.google.gwt.user.client.ui.*;
import org.gwtoolbox.commons.ui.client.event.custom.ToggleHandler;
import org.gwtoolbox.ioc.core.client.ComponentContainer;
import org.gwtoolbox.ioc.core.client.support.AbstractComponentContainerEntryPoint;
import org.gwtoolbox.sample.widget.client.layout.SplitLayoutSample;
import org.gwtoolbox.commons.ui.client.event.custom.ToggleEvent;
import org.gwtoolbox.widget.client.panel.LayoutUtils;
import org.gwtoolbox.widget.client.panel.layout.CompletionCallback;
import org.gwtoolbox.widget.client.panel.layout.PanelLayout;
import org.gwtoolbox.widget.client.panel.layout.SplitLayout;
import org.gwtoolbox.widget.client.panel.layout.animation.FixedAnimationDurationFunction;
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;
import org.gwtoolbox.widget.client.panel.layout.tab.TabSpec;
/**
* @author Uri Boness
*/
public class WidgetExplorer extends AbstractComponentContainerEntryPoint {
//public class WidgetExplorer implements EntryPoint {
// public void onModuleLoad() {
//
//// Widget main = createMain1();
//// Widget main = createMain2();
//// Widget main = createMain3();
// Widget main = createMain4();
//
// RootLayoutPanel.get().add(main);
// }
private Widget createMain1() {
// DockLayoutPanel p = new DockLayoutPanel(Style.Unit.EM);
// p.addNorth(new HTML("header"), 2);
// p.addSouth(new HTML("footer"), 2);
// p.addWest(new HTML("navigation"), 10);
// p.add(new HTML("bla balfalkdj alkdsfja;lsdk jfalksdjf alskdjfalsdjfalsdjkflaksdjf alskdjf alsdkjf alsdkjf a;lsdkjfasdfasdf" +
// "asdflaksdfjlaksdjf;alksdjf;alsdkjfa;lsdkfja;slkdjf alksdfj alskdfj a;ldskfj aslkdf" +
// "asdlfkajsdf;lkajsdf lakjsdf ;lakjdf;laskdjf" +
// "adslaksdfj;alksjdf;lakjsdfasdf"));
final SplitLayout p = new SplitLayout();
final HTML header = new HTML("header");
p.addNorth(header, 50);
final HTML footer = new HTML("footer");
p.addSouth(footer, 25);
final PanelLayout navigation = new PanelLayout("Navigation");
navigation.setClosable(true);
navigation.addCloseHandler(new CloseHandler<PanelLayout>() {
public void onClose(CloseEvent<PanelLayout> event) {
p.setWidgetVisible(navigation, false);
}
});
p.addWest(navigation, 200);
LayoutUtils.fitParent(navigation);
final HTML properties = new HTML("properties");
p.addEast(properties, 200);
FlowPanel panel = new FlowPanel();
ToggleButton button = new ToggleButton("Hide header", "Show header");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
p.setWidgetVisible(header, !((ToggleButton) clickEvent.getSource()).isDown());
}
});
panel.add(button);
button = new ToggleButton("Hide navigation", "Show navigation");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
p.setWidgetVisible(navigation, !((ToggleButton) clickEvent.getSource()).isDown());
}
});
panel.add(button);
button = new ToggleButton("Hide properties", "Show properties");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
p.setWidgetVisible(properties, !((ToggleButton) clickEvent.getSource()).isDown());
}
});
panel.add(button);
button = new ToggleButton("Hide footer", "Show footer");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
p.setWidgetVisible(footer, !((ToggleButton) clickEvent.getSource()).isDown());
}
});
panel.add(button);
PanelLayout cp = new PanelLayout("Test");
LayoutUtils.fitParent(cp);
cp.setContent(new Label("Content"));
cp.setCollapsable(true);
TabLayout tabs = new TabLayout();
tabs.setHideTabBarWithSingleTab(false);
tabs.addTab("Buttons", panel);
tabs.addTab("Tab1", new HTML("Tab1 Content"));
// tabs.addTab("Tab2", new CenterLayout(new HTML("Tab2 Content")));
tabs.addTab(new TabSpec("contentPanel", "Content Panel", null, cp, true));
// tabs.add(new HTML("Tab2 Content"), "Tab2");
// tabs.add(new HTML("Tab3 Content"), "Tab3");
// tabs.add(new HTML("Tab4 Content"), "Tab4");
// tabs.add(new HTML("Tab5 Content"), "Tab5");
// tabs.add(new HTML("Tab6 Content"), "Tab6");
// tabs.add(new HTML("Tab7 Content"), "Tab7");
// tabs.add(new HTML("Tab8 Content"), "Tab8");
// tabs.add(new HTML("Tab9 Content"), "Tab9");
// tabs.add(new HTML("Tab10 Content"), "Tab10");
// tabs.add(new HTML("Tab11 Content"), "Tab11");
p.add(tabs);
return p;
}
private Widget createMain2() {
final DrawerLayout layout = new DrawerLayout();
layout.setAnimationDurationFunction(new FixedAnimationDurationFunction(200));
Drawer drawer;
final PanelLayout navigation = new PanelLayout("Navigation");
navigation.setContent(new HTML("Navigation"));
navigation.setClosable(true);
navigation.addCloseHandler(new CloseHandler<PanelLayout>() {
public void onClose(CloseEvent<PanelLayout> event) {
layout.hideDrawer(DrawerLayout.Position.LEFT);
}
});
navigation.getElement().setId("navigation");
drawer = new Drawer("Properties", new HTML("Properties"), DrawerLayout.Position.RIGHT);
drawer.setMinSize(500);
layout.addDrawer(drawer);
drawer = new Drawer("Navigation", navigation, DrawerLayout.Position.LEFT);
layout.addDrawer(drawer);
drawer = new Drawer("Navigation 2", new HTML("Navigation 2"), DrawerLayout.Position.LEFT);
layout.addDrawer(drawer);
Button button = new Button("Close Navigation");
drawer = new Drawer("Console", button, DrawerLayout.Position.BOTTOM);
layout.addDrawer(drawer);
HTML console2 = new HTML("Console 2");
console2.getElement().setId("console2");
drawer = new Drawer("Console2", console2, DrawerLayout.Position.BOTTOM);
drawer.setButtonless(true);
layout.addDrawer(drawer);
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
layout.hideDrawer(DrawerLayout.Position.LEFT, new CompletionCallback() {
@Override
public void onComplete() {
layout.showDrawer("Console2");
}
});
}
});
button.getElement().setId("console1");
// drawer = new Drawer("Console", new HTML("Console"), DrawerLayout.Position.BOTTOM);
// layout.addDrawer(drawer);
return layout;
}
private Widget createMain3() {
PanelLayout layout = new PanelLayout("Test", WidgetExplorerImages.Instance.get().formGroup().createImage());
Widget content = createMain1();
layout.setContent(content);
LayoutUtils.fitParent(content);
layout.setCollapsable(true);
layout.setClosable(true);
layout.addTool(PanelLayout.Tools.GEAR, new ClickHandler() {
public void onClick(ClickEvent event) {
Window.alert("gear clicked");
}
});
layout.addToggleTool(PanelLayout.ToggleTools.PIN, new ToggleHandler() {
public void onToggle(ToggleEvent event) {
Window.alert("Pin is " + (event.getState() ? "down" : "up"));
}
});
layout.addCloseHandler(new CloseHandler<PanelLayout>() {
public void onClose(CloseEvent<PanelLayout> panelLayoutCloseEvent) {
Window.alert("Close");
}
});
return layout;
}
private Widget createMain4() {
return new SplitLayoutSample();
}
protected ComponentContainer createComponentContainer() {
return GWT.create(WidgetExplorerContainer.class);
}
}