package org.onemind.swingweb.client;
import org.onemind.swingweb.client.gwt.GwtClient;
import org.onemind.swingweb.client.gwt.ui.*;
import org.onemind.swingweb.client.gwt.util.Location;
import org.onemind.swingweb.client.gwt.util.WindowUtils;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class GwtClientStarter implements EntryPoint
{
/**
* This is the entry point method.
*/
public void onModuleLoad()
{
RootPanel consoleArea = RootPanel.get("console");
RootPanel appURL = RootPanel.get("sw-app-url");
if (appURL == null)
{
RootPanel.get().add(new Label("sw-app-url element must be defined"));
} else
{
String url = DOM.getAttribute(appURL.getElement(), "content");
if (url == null)
{
RootPanel.get().add(new Label("sw-app-url element must be defined"));
} else
{
if (url.startsWith("/"))
{
Location loc = WindowUtils.getLocation();
url = "http://" + loc.getHost() + url;
}
GwtClient client = new GwtClient(url);
initHandlers(client);
if (consoleArea != null)
{
consoleArea.add(client.getConsole());
}
}
}
}
public void initHandlers(GwtClient client)
{
client.addHandler(new ButtonUIHandler(client));
client.addHandler(new CheckboxUIHandler(client));
client.addHandler(new CheckboxUIHandler(client));
client.addHandler(new ChoiceUIHandler(client));
client.addHandler(new ComponentUIHandler(client));
client.addHandler(new ContainerUIHandler(client));
client.addHandler(new DesktopPaneUIHandler(client));//TODO use desktoppane handler
client.addHandler(new DialogUIHandler(client));
client.addHandler(new FileChooserUIHandler(client));
client.addHandler(new FileDialogUIHandler(client));
client.addHandler(new FillerUIHandler(client));
client.addHandler(new FrameUIHandler(client));
client.addHandler(new EditorPaneUIHandler(client));
client.addHandler(new TabbedPaneUIHandler(client));
client.addHandler(new TableUIHandler(client));
client.addHandler(new ToolBarUIHandler(client));
client.addHandler(new LabelUIHandler(client));
client.addHandler(new ListUIHandler(client));
client.addHandler(new MenuBarUIHandler(client));
client.addHandler(new MenuItemUIHandler(client));
client.addHandler(new MenuUIHandler(client));
client.addHandler(new PasswordFieldUIHandler(client));
client.addHandler(new RadioButtonUIHandler(client));
client.addHandler(new ScrollPaneUIHandler(client));
client.addHandler(new SliderUIHandler(client));
client.addHandler(new SplitPaneUIHandler(client));
client.addHandler(new TextAreaUIHandler(client));
client.addHandler(new TextFieldUIHandler(client));
client.addHandler(new TitleBarUIHandler(client));
client.addHandler(new ToggleButtonUIHandler(client));
client.addHandler(new TreeUIHandler(client));
client.addHandler(new ProgressBarUIHandler(client));
/*
client.addHandler("java.awt.CheckboxMenuItem", new CheckboxMenuItemUIHandler(client));
client.addHandler("java.awt.Choice", new ChoiceUIHandler(client));
client.addHandler("java.awt.Window", new WindowUIHandler(client));
client.addHandler("java.awt.Scrollbar", new ScrollbarUIHandler(client));
*/
//client.addHandler("javax.swing.JRadioButton", new RadioButtonUIHandler(client));
}
}