Example usage for com.google.gwt.user.client Window alert

List of usage examples for com.google.gwt.user.client Window alert

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window alert.

Prototype

public static void alert(String msg) 

Source Link

Usage

From source file:ch.unifr.pai.twice.comm.serverPush.client.RemoteEventing.java

License:Apache License

/**
 * Calculate the server time offset//w w  w .j a  v a 2  s. com
 */
private void updateServerTimeOffset() {
    ClientServerTimeOffset.getServerTimeOffset(new AsyncCallback<Long>() {

        @Override
        public void onSuccess(Long result) {
            serverTimeOffset = result;
        }

        @Override
        public void onFailure(Throwable caught) {
            Window.alert("Was not able to synchronize the clock with the server");
        }
    });
}

From source file:ch.unifr.pai.twice.dragndrop.standalone.client.DragNDropStandalone.java

License:Apache License

@Override
public void onModuleLoad() {

    // Enable multicursor support
    MultiCursorController c = GWT.create(MultiCursorController.class);
    c.start();// w ww . ja  v  a  2s.  c  o  m

    DockLayoutPanel mainpanel = new DockLayoutPanel(Unit.PX);
    final AbsolutePanel p = new AbsolutePanel();
    DraggableLabel l = new DraggableLabel();
    l.setText("DRAG ME");
    mainpanel.add(p);
    RootLayoutPanel.get().add(mainpanel);
    p.add(l);
    final FocusPanel drop = new FocusPanel();
    drop.setWidth("500px");
    drop.setHeight("400px");
    drop.getElement().getStyle().setBackgroundColor("green");
    p.add(drop);
    p.setWidgetPosition(drop, 400, 200);

    // define the green focus panel to be a drop target handler
    DragNDrop.setDropHandler(drop, new DropTargetHandler() {

        @Override
        public void onHoverEnd(String deviceId, Widget widget, Element dragProxy, Event event) {
            drop.getElement().getStyle().setBackgroundColor("yellow");

        }

        @Override
        public void onHover(String deviceId, Widget widget, Element dragProxy, Event event,
                Double intersectionPercentage, Double intersectionPercentageWithTarget) {
            drop.getElement().getStyle().setBackgroundColor("red");
        }

        @Override
        public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event,
                Double intersectionPercentage, Double intersectionPercentageWithTarget) {
            Window.alert("Dropped");
            return false;
        }

        @Override
        public Priority getPriority() {
            return Priority.NORMAL;
        }
    }, true);

    // Make the label draggable
    DragNDrop.makeDraggable(l, DragConfiguration.withProxy(new DragNDropHandler() {

        @Override
        public void onStartDrag(String deviceId, Widget draggedWidget) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onEndOfDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop,
                Event event) {
            // TODO Auto-generated method stub

        }

        @Override
        public boolean onDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop,
                Event event, DropTargetHandler dropTarget, boolean outOfBox) {
            p.setWidgetPosition(draggedWidget, dragProxyLeft - p.getAbsoluteLeft(),
                    dragProxyTop - p.getAbsoluteTop());
            return true;
        }
    }));
}

From source file:ch.unifr.pai.twice.layout.client.eclipseLayout.MiceSplitLayoutPanel.java

License:Apache License

/**
 * Removes a widget from the split layout panel. If the widget is not the center tab panel, it can be removed directly. Otherwise, it is checked if there
 * are other widgets in the split panel which can be used as the new center widget (because a layout panel always has to contain a center widget),
 * afterwards the tab panel can be removed. If no other tab panels are around which can be made the new center widget, the whole split layout panel is
 * removed from its parent unless it is the root split layout panel (what results in a warning)
 * //from w  w w.  ja v  a2  s  .c o m
 * @see com.google.gwt.user.client.ui.SplitLayoutPanel#remove(com.google.gwt.user.client.ui.Widget)
 */
@Override
public boolean remove(Widget child) {
    if (getWidgetDirection(child.getParent()) != Direction.CENTER) {
        setWidgetMinSize(child.getParent(), 0);
        setWidgetSize(child.getParent(), 0);
        return super.remove(child.getParent());
    } else {
        Widget lastNonCenterWidget = getLastNonCenterWidget();
        if (lastNonCenterWidget instanceof MiceLayoutTabPanel
                || lastNonCenterWidget instanceof MiceSplitLayoutPanel) {
            Widget originParent = lastNonCenterWidget.getParent();
            ((ResizeLayoutPanel) getCenter()).setWidget(lastNonCenterWidget);
            setWidgetSize(originParent, 0);
            setWidgetMinSize(originParent, 0);
            return super.remove(originParent);

        } else if (getParentMiceSplitLayoutPanel() != null) {
            return getParentMiceSplitLayoutPanel().remove(this);
        } else {
            Window.alert("You've tried to remove the last element - this is not allowed");
            return false;
        }

    }
}

From source file:ch.unifr.pai.twice.layout.client.mobile.MobileInterface.java

License:Apache License

/**
 * Switch to a specific component ({@link TWICEModule}). If the module has not been accessed yet, it is instantiated and the callback is invoked.
 * /*from  w ww.  ja  v a 2  s .  c o m*/
 * @param componentName
 */
void switchComponent(String componentName) {
    RootLayoutPanel.get().clear();
    if (componentName == null && components.keySet().size() > 0) {
        componentName = (String) components.keySet().toArray()[0];
    }
    // Is it a not yet instantiated module?
    final TWICEModule module = modules.get(componentName);
    if (module != null) {
        // Then instantiate it and add it to the components
        final String moduleComponentName = componentName;
        TWICEModuleController.instantiateModule(module, new AsyncCallback<Widget>() {

            @Override
            public void onSuccess(Widget result) {
                if (currentWidget != null)
                    TWICEModuleController.stop(currentWidget);
                components.put(moduleComponentName, result);
                modules.remove(moduleComponentName);
                AsyncCallback<Widget> callback = callbacks.get(moduleComponentName);
                if (callback != null) {
                    callback.onSuccess(result);
                }
                switchToWidget(moduleComponentName, result);
            }

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Was not able to initialize module " + moduleComponentName);
            }
        });
    } else {
        Widget w = components.get(componentName);
        if (w == null && components.size() > 0) {
            componentName = (String) components.keySet().toArray()[0];
            w = components.get(componentName);
        }
        switchToWidget(componentName, w);

    }
}

From source file:ch.unifr.pai.twice.layout.client.singlepointer.SinglePointerLayout.java

License:Apache License

@Override
public <W extends Widget> void addModule(final String name, TWICEModule<W> module,
        final AsyncCallback<W> callback) {
    // TODO do instantiate on demand - not at registration time

    final SimpleLayoutPanel placeHolder = new SimpleLayoutPanel();
    addWidget(name, placeHolder);// w w  w  .  j  ava  2 s  .  c o  m
    TWICEModuleController.instantiateModule(module, new AsyncCallback<Widget>() {

        @Override
        public void onFailure(Throwable caught) {
            Window.alert("Was not able to instantiate " + name);
        }

        @Override
        public void onSuccess(Widget result) {
            placeHolder.setWidget(result);
            callback.onSuccess((W) result);
            // TWICEModuleController.start(result);
        }
    });

}

From source file:ch.unifr.pai.twice.module.test.client.GenerationTestModule.java

License:Apache License

@Override
public void start(SomeClass instance) {
    Window.alert("Started");
}

From source file:ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl.java

License:Apache License

/**
 * actions on close of the web socket server
 *///from w  w  w. j  a va  2 s . c  om
private void onClose() {
    if (!opened) {
        Window.alert("The websocket server is not reachable!");
    } else {
        opened = false;
        // Window.alert("Stopping multi cursor control!");
    }
}

From source file:ch.unifr.pai.twice.multipointer.client.WebsocketControl.java

License:Apache License

private void onClose() {
    if (!opened) {
        Window.alert("The websocket server is not reachable!");
    } else {/*w w w.j av  a 2 s .  co m*/
        opened = false;
        // Window.alert("Stopping multi cursor control!");
    }
}

From source file:ch.unifr.pai.twice.multipointer.controller.client.TouchPadWidget.java

License:Apache License

/**
 * Request the server for available shared devices
 * /*  w ww.  j a v  a  2 s . co  m*/
 * @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:ch.unifr.pai.twice.multipointer.provider.client.MultiCursorController.java

License:Apache License

@Override
public void start() {

    if (!isInIFrame()) {
        initializeCursorList();/*www . j  a  va 2  s .  c  om*/
        if (r != null)
            r.removeHandler();
        r = Window.addResizeHandler(this);
        EventBus eventBus = CommunicationManager.getBidirectionalEventBus();
        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteMouseMoveEvent.TYPE, new RemoteMouseMoveEvent.Handler() {

                    @Override
                    public void onEvent(RemoteMouseMoveEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.move(event);
                    }
                }));
        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteMouseDownEvent.TYPE, new RemoteMouseDownEvent.Handler() {

                    @Override
                    public void onEvent(RemoteMouseDownEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.down(event);
                    }
                }));
        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteMouseUpEvent.TYPE, new RemoteMouseUpEvent.Handler() {

                    @Override
                    public void onEvent(RemoteMouseUpEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.up(event);
                    }
                }));

        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteKeyDownEvent.TYPE, new RemoteKeyDownEvent.Handler() {

                    @Override
                    public void onEvent(RemoteKeyDownEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.keyDown(event);
                    }
                }));

        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteKeyUpEvent.TYPE, new RemoteKeyUpEvent.Handler() {
                    @Override
                    public void onEvent(RemoteKeyUpEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.keyUp(event);
                    }
                }));

        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteKeyPressEvent.TYPE, new RemoteKeyPressEvent.Handler() {
                    @Override
                    public void onEvent(RemoteKeyPressEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.keyPress(event);
                    }
                }));

        MouseControllerServiceAsync svc = GWT.create(MouseControllerService.class);
        svc.registerAsMPProvider(UUID.get(), new AsyncCallback<Void>() {

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Not Registered");
                // TODO Auto-generated method stub

            }

            @Override
            public void onSuccess(Void result) {
                Window.alert("Registered");
                // ((ServerPushEventBus) CommunicationManager.getBidirectionalEventBus()).sendPingEvent();
            }
        });
    }
}