public void onModuleLoad() {
org.geomajas.gwt.client.i18n.I18nProvider.setLookUp(GWT.<ConstantsWithLookup>create(Samples.class));
// Setup the overall layout:
VLayout main = new VLayout();
main.setWidth100();
main.setHeight100();
main.setStyleName("tabSetContainer");
// Top bar:
ToolStrip topBar = new ToolStrip();
topBar.setHeight(33);
topBar.setWidth100();
topBar.addSpacer(6);
Img icon = new Img("[ISOMORPHIC]/geomajas/geomajas_desktopicon_small.png");
icon.setSize(24);
topBar.addMember(icon);
Label title = new Label("Geomajas GWT Showcase");
title.setStyleName("sgwtTitle");
title.setWidth(300);
topBar.addMember(title);
topBar.addFill();
ToolStripButton devConsoleButton = new ToolStripButton();
devConsoleButton.setTitle("Developer Console");
devConsoleButton.setIcon("[ISOMORPHIC]/geomajas/silk/bug.png");
devConsoleButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
SC.showConsole();
}
});
topBar.addButton(devConsoleButton);
topBar.addSeparator();
// Skin select:
SelectItem selectItem = new SelectItem();
selectItem.setHeight(21);
selectItem.setWidth(130);
LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
valueMap.put("Graphite", "Graphite");
valueMap.put("EnterpriseBlue", "Enterprise Blue");
valueMap.put("Enterprise", "Enterprise Gray");
selectItem.setValueMap(valueMap);
String currentSkin = Cookies.getCookie("skin_name");
if (currentSkin == null) {
currentSkin = "Graphite";
}
selectItem.setDefaultValue(currentSkin);
selectItem.setShowTitle(false);
selectItem.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
Cookies.setCookie("skin_name", (String) event.getValue());
com.google.gwt.user.client.Window.Location.reload();
}
});
topBar.addFormItem(selectItem);
main.addMember(topBar);
// Horizontal layout:
HLayout hLayout = new HLayout();
hLayout.setWidth100();
hLayout.setHeight100();
hLayout.setLayoutMargin(5);
VLayout leftTreeLayout = new VLayout();
leftTreeLayout.setHeight100();
leftTreeLayout.setWidth(200);
leftTreeLayout.setShowResizeBar(true);
leftTreeLayout.setMembersMargin(1);
SampleTree sampleTree = new SampleTree();
sampleTree.addLeafClickHandler(new LeafClickHandler() {
public void onLeafClick(LeafClickEvent event) {
TreeNode node = event.getLeaf();
prepareSample(node);
}
});
leftTreeLayout.addMember(sampleTree);
// Show a user label:
final Label userLabel = new Label();
userLabel.setHeight(20);
userLabel.setWidth100();
userLabel.setPadding(3);
userLabel.setBorder("1px solid #A0A0A0");
Authentication.getInstance().addLoginHandler(new LoginHandler() {
public void onLoginFailure(LoginFailureEvent event) {
}
public void onLoginSuccess(LoginSuccessEvent event) {
userLabel.setContents("Logged in with: " + Authentication.getInstance().getUserId());
}
});
Authentication.getInstance().addLogoutHandler(new LogoutHandler() {
public void onLogoutFailure(LogoutFailureEvent event) {
}
public void onLogoutSuccess(LogoutSuccessEvent event) {
userLabel.setContents("No user is logged in.");
}
});
Authentication.getInstance().login("luc", "luc", null);
leftTreeLayout.addMember(userLabel);
// Show an ActivityMonitor:
ActivityMonitor monitor = new ActivityMonitor();
leftTreeLayout.addMember(monitor);
hLayout.addMember(leftTreeLayout);
mainTabSet = new TabSet();
mainTabSet.setWidth100();