List of usage examples for com.google.gwt.user.client Command execute
void execute();
From source file:asquare.gwt.sb.client.util.CommandQueueBase.java
License:Apache License
protected void executeCommandImpl(Command command) { command.execute(); }
From source file:asquare.gwt.tk.uitest.alertdialog.client.Demo.java
License:Apache License
public void onModuleLoad() { Debug.enable();// w ww. ja v a2s .co m new DebugEventListener('x', Event.ONMOUSEDOWN, null) { @Override protected void doEvent(Event event) { Element target = DOM.eventGetTarget(event); Debug.println("target=" + DebugUtil.prettyPrintElement(target)); int screenX = DOM.eventGetScreenX(event); int screenY = DOM.eventGetScreenY(event); int clientX = DOM.eventGetClientX(event); int clientY = DOM.eventGetClientY(event); int absLeft = DOM.getAbsoluteLeft(target); int absTop = DOM.getAbsoluteTop(target); int offsetLeft = getOffsetLeft(target); int offsetTop = getOffsetTop(target); int docScrollX = Window.getScrollLeft(); int docScrollY = Window.getScrollTop(); Debug.println("screenX=" + screenX + ",screenY=" + screenY + ",clientX=" + clientX + ",clientY=" + clientY + ",absLeft=" + absLeft + ",absTop=" + absTop + ",offsetLeft=" + offsetLeft + ",offsetTop=" + offsetTop + ",docScrollX=" + docScrollX + ",docScrollY=" + docScrollY); } }.install(); new DebugEventListener('z', Event.ONMOUSEDOWN, "Offset hierarchy inspector") { @Override protected void doEvent(Event event) { Element target = DOM.eventGetTarget(event); printOffsetTopHierarchy(target); } }.install(); new DebugHierarchyInspector().install(); new DebugElementDumpInspector().install(); new DebugEventListener(Event.ONMOUSEDOWN | Event.ONMOUSEUP).install(); if (!GWT.isScript()) { DebugConsole.getInstance().disable(); } final Button button = new Button(); button.setText("Default Info dialog"); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final AlertDialog alert = AlertDialog.createInfo(new Command() { public void execute() { Debug.println("OK clicked"); } }, "Info Dialog", "this is a default info dialog"); alert.show(); } }); RootPanel.get().add(button); Command showDialog = new Command() { private AlertDialog m_dialog; public void execute() { if (m_dialog == null) { m_dialog = AlertDialog.createWarning(this, "Caption text", null); ScrollPanel message = new ScrollPanel(); message.setAlwaysShowScrollBars(true); message.setWidth("100%"); message.setHeight("100px"); message.setWidget(new Label( "These packages contain reference information about the main GWT user interface and utility classes. For higher-level explanations of how to take advantage of all this stuff, check out the Developer Guide. Among other things, there's a handy widget gallery and an explanation of how remote procedure calls work.These packages contain reference information about the main GWT user interface and utility classes. For higher-level explanations of how to take advantage of all this stuff, check out the Developer Guide. Among other things, there's a handy widget gallery and an explanation of how remote procedure calls work.")); m_dialog.setMessage(message); m_dialog.setSize("400px", "300px"); m_dialog.addController(new ControllerAdaptor(Controller.class, Event.ONMOUSEDOWN) { @Override public void onBrowserEvent(Widget widget, Event event) { int x = DomUtil.eventGetAbsoluteX(event) - DOM.getAbsoluteLeft(widget.getElement()); int y = DomUtil.eventGetAbsoluteY(event) - DOM.getAbsoluteTop(widget.getElement()); Debug.println("onMouseDown(" + x + "," + y + ")"); } }); } m_dialog.show(); } }; showDialog.execute(); }
From source file:ca.nanometrics.gflot.client.SimplePlot.java
License:Open Source License
private void onPlotCreated() { // Issue : 2/* w w w . j a va 2 s. c o m*/ assert plot != null : "A javascript error occurred while creating plot."; loaded = true; // retrieving the calculated options options = plot.getPlotOptions(); for (Command cmd : onLoadOperations) { cmd.execute(); } onLoadOperations.clear(); }
From source file:ch.unifr.pai.twice.comm.serverPush.client.ServerPush.java
License:Apache License
private ServerPush(AtmosphereGWTSerializer serializer, final Command onConnected) { this.connectionTimeout = new Timer() { @Override// ww w . java2 s.co m public void run() { if (!initialized) { onConnected.execute(); initialized = true; } } }; connectionTimeout.schedule(4000); this.atmosphereClient = new AtmosphereClient( GWT.getHostPageBaseURL() + Constants.BASEPATH + Constants.ATMOSPHERE, serializer, new AtmosphereListener() { @Override public void onConnected(int heartbeat, int connectionID) { GWT.log("comet.connected [" + heartbeat + ", " + connectionID + "]"); connectionTimeout.cancel(); if (!initialized) { onConnected.execute(); initialized = true; } } @Override public void onBeforeDisconnected() { GWT.log("comet.beforeDisconnected"); } @Override public void onDisconnected() { GWT.log("comet.disconnected"); } @Override public void onError(Throwable exception, boolean connected) { int statuscode = -1; if (exception instanceof StatusCodeException) { statuscode = ((StatusCodeException) exception).getStatusCode(); } GWT.log("comet.error [connected=" + connected + "] (" + statuscode + ")" + exception.getMessage()); } @Override public void onHeartbeat() { GWT.log("comet.heartbeat [" + atmosphereClient.getConnectionID() + "]"); } @Override public void onRefresh() { GWT.log("comet.refresh [" + atmosphereClient.getConnectionID() + "]"); } @Override public void onAfterRefresh() { GWT.log("comet.afterrefresh [" + atmosphereClient.getConnectionID() + "]"); } @Override public void onMessage(List<?> messages) { for (Object message : messages) { if (message instanceof Serializable) handleMessage((Serializable) message); } } }); this.atmosphereClient.start(); }
From source file:ch.unifr.pai.twice.dragndrop.client.factories.DropTargetHandlerFactory.java
License:Apache License
/** * @param com//from ww w. j a v a2 s . c o m * - the {@link Command} which is executed only if the dragged widget is intersecting fully with the drop target * @param resetPosition * @return a {@link DropTargetHandler} */ public static DropTargetHandler completeIntersection(final Command com, final boolean resetPosition) { return new DropTargetHandlerAdapter() { @Override public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event, Double intersectionPercentage, Double intersectionPercentageWithTarget) { if (intersectionPercentage > THRESHOLD_PERCENTAGE) com.execute(); return !resetPosition; } }; }
From source file:ch.unifr.pai.twice.dragndrop.client.factories.DropTargetHandlerFactory.java
License:Apache License
/** * A {@link DropTargetHandler} that executes the given command even if it is intersected only partially by the dragged widget * //from w w w .ja v a2s . c om * @param com * @param resetPosition * @return */ public static DropTargetHandler incompleteIntersection(final Command com, final boolean resetPosition) { return new DropTargetHandlerAdapter() { @Override public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event, Double intersectionPercentage, Double intersectionPercentageWithTarget) { com.execute(); return !resetPosition; } }; }
From source file:ch.unifr.pai.twice.mousecontrol.client.TouchPadWidget.java
License:Apache License
/** * Sends the given query to the mouse pointer controller servlet * /*from ww w . j av a2 s. c om*/ * @param query * @param callback */ protected void send(String query, final Command callback) { try { if (active) { new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + controlServlet + "?" + (query != null ? query : "a=x") + (getCurrentClient() != null ? "&targetUUID=" + getCurrentClient() : "") + (uuid != null ? "&uuid=" + uuid : "") + (host != null ? "&host=" + host : "") + (port != null ? "&port=" + port : "") + ("&user=" + Authentication.getUserName())) .sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() > 400) onError(request, null); String color = extractColor(response); if (response.getText().trim().isEmpty()) { label.setText("No connection available"); noConnection = true; } else { if (noConnection) { label.setText(""); noConnection = false; } if (color == null || color.isEmpty() || color.equals("#null")) color = null; extractLastAction(response); setColor(color); setScreenDimension(extractScreenDimensions(response)); if (callback != null) callback.execute(); } } @Override public void onError(Request request, Throwable exception) { setActive(false); } }); } } catch (Exception e) { e.printStackTrace(); } }
From source file:ch.unifr.pai.twice.mousecontrol.client.TouchPadWidget.java
License:Apache License
/** * Request the server for available shared devices * /*from ww w .j ava2s . c om*/ * @param callback */ private void getAvailableClients(final Command callback) { try { new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + controlServlet + "?a=g") .sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (response.getText() != null && !response.getText().isEmpty()) { availableClients = response.getText().split("\n"); } if (callback != null) callback.execute(); } @Override public void onError(Request request, Throwable exception) { GWT.log("Available clients request", exception); if (callback != null) callback.execute(); } }); } catch (RequestException e) { GWT.log("Request Exception", e); if (callback != null) callback.execute(); } }
From source file:ch.unifr.pai.twice.multipointer.controller.client.TouchPadWidget.java
License:Apache License
/** * Request the server for available shared devices * // w w w .ja v a 2 s .c om * @param callback */ private void getAvailableClients(final Command callback) { MouseControllerServiceAsync controller = GWT.create(MouseControllerService.class); controller.getMPProviders(new AsyncCallback<List<String>>() { @Override public void onSuccess(List<String> result) { if (result != null) { availableClients = result.toArray(new String[0]); } else { availableClients = new String[0]; } if (callback != null) callback.execute(); } @Override public void onFailure(Throwable caught) { Window.alert("SERVICE NOT FOUND"); } }); }
From source file:com.alkacon.acacia.client.EditorBase.java
License:Open Source License
/** * Loads the content definition for the given entity and executes the callback on success.<p> * /*from w w w . j a v a 2 s.com*/ * @param entityId the entity id * @param callback the callback */ public void loadContentDefinition(final String entityId, final Command callback) { AsyncCallback<ContentDefinition> asyncCallback = new AsyncCallback<ContentDefinition>() { public void onFailure(Throwable caught) { onRpcError(caught); } public void onSuccess(ContentDefinition result) { registerContentDefinition(result); callback.execute(); } }; getService().loadContentDefinition(entityId, asyncCallback); }