/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.util.Map; import java.util.HashMap; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.callbacks.LoadProjectCallback; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.rpc.LoadProjectSettings; import com.smartgwt.client.rpc.Project; import com.smartgwt.client.rpc.RPCManager; import com.smartgwt.client.rpc.RPCResponse; import com.smartgwt.client.tools.Reify; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ButtonItem; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.sample.showcase.client.data.ExtraFieldSupplyItemXmlDS; import com.google.gwt.core.client.EntryPoint; public class VerifyingScreensReifySample implements EntryPoint { public void onModuleLoad() { final DataSource ds = ExtraFieldSupplyItemXmlDS.getInstance(); final VLayout container = new VLayout(); container.setWidth100(); container.setHeight100(); container.setMembersMargin(20); final IButton button = new IButton(); button.setTitle("Load Project"); button.setWidth(100); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { LoadProjectSettings settings = new LoadProjectSettings(); settings.setUserName("reifySample"); settings.setPassword("tryReify"); settings.setServerURL("https://create.reify.com"); settings.setWillHandleError(true); settings.setVerifyAsError(true); settings.setVerifyDataSources(true); Map
componentsMap = new HashMap
(); componentsMap.put("simpleForm.saveDataButton", "ButtonItem"); settings.setVerifyComponents(componentsMap); Reify.loadProject("Incompatible Simple Form", new LoadProjectCallback() { @Override public void execute(Project project, Project[] projects, RPCResponse rpcResponse) { String message = RPCManager.getLoadProjectErrorMessage(rpcResponse); if (message != null) { SC.warn(message); return; } if (rpcResponse.getStatus() == 0) { Canvas screen = project.createScreen((project.getScreenNames()[0])); final DynamicForm saveForm = (DynamicForm)screen.getByLocalId("simpleForm"); ButtonItem saveButton = (ButtonItem)saveForm.getField("saveDataButton"); if (saveButton != null) { saveButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { Map values = saveForm.getValues(); if (!Boolean.TRUE.equals((Boolean)values.get("inStock")) && values.get("nextShipment") == null) { SC.warn("New stock items which are not already stocked must have a Stock Date"); } } }); } Canvas target = container.getMember(1); if (target != null) container.replaceMember(target, screen); else container.addMember(screen); } } }, settings); } }); container.addMember(button); container.draw(); } @Override protected boolean isTopIntro() { return true; } }