Example usage for com.google.gwt.user.client DeferredCommand add

List of usage examples for com.google.gwt.user.client DeferredCommand add

Introduction

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

Prototype

@Deprecated
public static void add(Command cmd) 

Source Link

Document

Enqueues a Command to be fired after all current events have been handled.

Usage

From source file:com.dimdim.conference.ui.common.client.util.FlashCallbackHandler.java

License:Open Source License

public void handleCallFromJS2(String data1, String data2) {
    final String streamName = data1;
    final String eventName = data2;
    //       DebugPanel.getDebugPanel().addDebugMessage("Flash callback event:"+streamName+":"+eventName);
    //      Window.alert("Call from flash- "+streamName+":"+eventName);
    final FlashStreamHandler streamHandler = (FlashStreamHandler) this.streamHandlers.get(streamName);
    if (streamHandler != null) {
        //         Window.alert("Have a stream handler");
        DeferredCommand.add(new Command() {
            public void execute() {
                streamHandler.handleEvent(eventName);
            }/*w  ww. jav a 2  s. co  m*/
        });
        //         streamHandler.handleEvent(eventName);
        //         Window.alert("Flash callback handler complete");
    } else {
        DebugPanel.getDebugPanel().addDebugMessage("Flash callback event: no handler for the stream");
    }
}

From source file:com.dimdim.conference.ui.common.client.util.FlashCallbackHandler.java

License:Open Source License

public void onClick(Widget w) {
    String streamName = getStreamNameFromFlash();
    final String eventName = getEventNameFromFlash();
    //      Window.alert("Call from flash- "+streamName+":"+eventName);
    final FlashStreamHandler streamHandler = (FlashStreamHandler) this.streamHandlers.get(streamName);
    if (streamHandler != null) {
        //         Window.alert("Have a stream handler");
        DeferredCommand.add(new Command() {
            public void execute() {
                streamHandler.handleEvent(eventName);
            }/* w w  w. j av a2s .co m*/
        });
        //         streamHandler.handleEvent(eventName);
        //         Window.alert("Flash callback handler complete");
    }
}

From source file:com.dimdim.conference.ui.envcheck.client.main.CommandProcessor.java

License:Open Source License

public CommandProcessor(String actionId, String browserType, String osType) {
    this.actionId = actionId;
    this.browserType = browserType;
    this.osType = osType;
    this.totalNumberOfChecks = EnvGlobals.getTotalNumberOfChecks();

    this.osCheck = new OSCheck(getOSType());
    this.browserTypeCheck = new BrowserTypeCheck(getBrowserType());
    this.flashVersionCheck = new FlashVersionCheck(getOSType(), getBrowserType());
    this.flashVersionCheck.setPanelWidth(300);
    this.publisherCheck = new PublisherCheck(getOSType());
    this.publisherCheck.setPanelWidth(300);

    this.checksPanel = new EnvChecksPanel(actionId, browserType, osType, 300);
    this.currentCommand = UserCommandFactory.getFactory().getUserCommand(actionId);

    this.checkTimer = new Timer() {
        public void run() {
            try {
                DeferredCommand.add(new Command() {
                    public void execute() {
                        runCheck();/*from w  ww.jav a 2  s  .c o  m*/
                    }
                });
            } catch (Exception e) {

            }
        }
    };

}

From source file:com.dimdim.conference.ui.envcheck.client.main.CommandProcessor.java

License:Open Source License

/**
 * Check the form state with the command and process the new 
 *///from  www .  ja va 2 s  .co m
public void startChecks() {
    //   Check if the current command requires any checks at all. The schedule
    //   meeting command does not require any checks and it will be better to
    //   avoid showing the checks panel at all.
    //Window.alert("start checks...");
    if (this.currentCommand.anyCheckApplicable()) {
        if (numberOfPassedChecks < this.totalNumberOfChecks) {
            this.currentCheckIndex = 0;
            //            this.formContainer.remove(0);

            DeferredCommand.add(new Command() {
                public void execute() {
                    runCheck();
                }
            });
        } else {
            this.allChecksSuccessful();
        }
    } else {
        this.allChecksSuccessful();
    }
}

From source file:com.dimdim.conference.ui.layout.client.main.NewLayout.java

License:Open Source License

protected void loadConsole() {
    DebugPanel.getDebugPanel().addDebugMessage("Initializing Console");
    //   Now once the environment i initialized the client model can be
    //   created which depends on it.

    //      String getEventsURL = ConferenceGlobals.webappRoot+
    //         "GetEvents.action?sessionKey="+ConferenceGlobals.sessionKey;
    String getEventsURL = ConferenceGlobals.webappRoot + "GetEvents.action?sessionKey="
            + ConferenceGlobals.sessionKey;
    String serverPingURL = ConferenceGlobals.webappRoot + "PingServer.action";
    ClientModel.createClientModel();/*w  ww . java 2 s. co  m*/
    DebugPanel.getDebugPanel().addDebugMessage("Client model creation complete");

    Window.setMargin("0px");

    try {
        UIRosterEntry currentUser = ClientModel.getClientModel().getRosterModel().getCurrentUser();
        fullPanel = new ConsoleFullPanel(this, currentUser);
        //RootPanel.get("MainConsole").remove(this.lmm);
        //RootPanel.get("MainConsole").add(fullPanel);

        //RootPanel.get("MainConsole").add(fullPanel.getTopPanel())
        //this.meetingAssistent = new MeetingAssistentDialog(this.workspaceClickListener);
    } catch (Exception e) {
        Window.alert(e.getMessage());
    }
    DebugPanel.getDebugPanel().addDebugMessage("Fetching initial data");
    ClientModel.getClientModel().getClientStateModel().addListener(this.fullPanel.getMiddlePanel());
    ClientModel.getClientModel().getRosterModel()
            .addListener(this.fullPanel.getMiddlePanel().getRosterModelListener());

    UIParams uiParams = UIParams.getUIParams();
    EventsJsonHandler eventsHandler = EventsJsonHandler.getHandler();
    eventsHandler.setEventsTracker(DebugPanel.getDebugPanel());
    gerth = new GetEventResponseTextHandler(eventsHandler, uiParams.getRegularEventPollIntervalMillis(),
            uiParams.getMaxEventPollErrors());
    gerth.setServerPingURL(serverPingURL);
    eventsReadingTimer = new JSONurlReadingTimer(getEventsURL, getConfKey(),
            uiParams.getInitialEventPollDelayMillis(), gerth);
    gerth.setServerStatusListener(this.eventsReadingTimer);
    eventsReadingTimer.start();

    Window.addWindowResizeListener(this);
    DeferredCommand.add(new Command() {
        public void execute() {
            onWindowResized(Window.getClientWidth(), Window.getClientHeight());
            continueLoading();
        }
    });

    ClientModel.getClientModel().getRosterModel().reportConsoleLoaded();

    //      ConsoleDataReader dataReader = new ConsoleDataReader(this);
    //      dataReader.readConsoleData();
    DebugPanel.getDebugPanel().addDebugMessage("Console initialization complete.");
    showConsole();

    //      linking meeting assistant dialog listener
    meetingAssistent = new MeetingAssistentDialog(fullPanel.getMiddlePanel().getLeftPanel());
    fullPanel.getTopPanel().getLinksPanel().getAssistantLabel().addClickListener(this);
}

From source file:com.dimdim.conference.ui.popout.client.PopoutWindow.java

License:Open Source License

/**
 * //from   w  w  w. j ava  2  s . c  o m
 * 
 */
public PopoutWindow(final String windowId, String panelId, PopoutWindowContent popoutWindowContent) {
    this.windowId = windowId;
    this.panelId = panelId;
    this.popoutWindowContent = popoutWindowContent;

    ClientModel.createClientModel();
    //      Window.alert("1");
    Window.addWindowCloseListener(this);
    resizeListener = new PopoutResizeListener();
    Window.addWindowResizeListener(resizeListener);

    popoutWindowContent.preparePopoutWindowContent();

    //      Window.alert("2");
    this.eventsTextHandler = new PopoutPageEventTextHandler(EventsJsonHandler.getHandler());
    //      Window.alert("3");
    this.dataTextHandler = new PopoutPageDataTextHandler(windowId, popoutWindowContent, this.eventsTextHandler);

    //      Window.alert("4");
    this.dataReader = new PopoutPageDataReader(100, this.dataTextHandler);
    //      Window.alert("5");
    //      this.dataReader.start();

    //      Window.alert("6");
    this.eventsReader = new PopoutPageEventsReader(1000, this.eventsTextHandler);
    //      Window.alert("7");
    //      this.eventsReader.start();

    //      Window.alert("8");
    //      Window.alert("9");
    DeferredCommand.add(new Command() {
        public void execute() {
            resizeListener.onWindowResized(Window.getClientWidth(), Window.getClientHeight());

            String popoutLoadedMessage = "{objClass:\"PopoutPanelData\",windowId:\"" + windowId
                    + "\",panelId:\"" + windowId + "\",dataText:\"POPOUT_LOADED\"}";
            reportPopoutLoadedToConsole(popoutLoadedMessage);
        }
    });
    //      Window.alert("10");
}

From source file:edu.caltech.ipac.firefly.ui.background.BackgroundManager.java

public void animateToManager(final int startX, final int startY, final int mills) {
    WebEventManager.getAppEvManager().fireEvent(new WebEvent(this, Name.BG_MANAGER_PRE_ANIMATE));
    DeferredCommand.add(new Command() {
        public void execute() {
            if (BrowserUtil.canSupportAnimation()) {
                animationIconCSS(mills, startX, startY);
            } else {
                BackAnimation ani = new BackAnimation(startX, startY);
                ani.run(mills);//from  w  w  w  .ja v  a2s. co m
            }

        }
    });
}

From source file:edu.caltech.ipac.firefly.visualize.FloatingStatusBar.java

public FloatingStatusBar(PlotWidgetGroup group, Widget alignWidget) {
    this.group = group;
    IconCreator _ic = IconCreator.Creator.getInstance();
    HorizontalPanel panel = new HorizontalPanel();
    popup = new PopupPane("", panel, PopupType.LOW_PROFILE, false, false, false, PopupPane.HeaderType.NONE);
    updateAlignWidget(alignWidget);//ww w  .  jav a 2s  .  c  o m
    popup.setDoRegionChangeHide(false);
    panel.setSpacing(3);
    panel.add(status);

    WebEventManager.getAppEvManager().addListener(Name.DROPDOWN_CLOSE, new WebEventListener() {
        public void eventNotify(WebEvent ev) {
            DeferredCommand.add(new Command() {
                public void execute() {
                    dropClosed = true;
                    if (showing)
                        popup.show();
                }
            });
        }
    });

    WebEventManager.getAppEvManager().addListener(Name.DROPDOWN_OPEN, new WebEventListener() {
        public void eventNotify(WebEvent ev) {
            DeferredCommand.add(new Command() {
                public void execute() {
                    dropClosed = false;
                    if (showing)
                        popup.hide();
                }
            });
        }
    });
}

From source file:edu.caltech.ipac.firefly.visualize.FloatingVisBar.java

public FloatingVisBar(PlotWidgetGroup group, Widget alignWidget) {

    _group = group;//from   w  ww. j  a v  a2s.  co  m
    IconCreator _ic = IconCreator.Creator.getInstance();
    VerticalPanel panel = new VerticalPanel();
    _popup = new PopupPane("", panel, PopupType.LOW_PROFILE, false, false, false, PopupPane.HeaderType.NONE);
    updateAlignWidget(alignWidget);
    _popup.setDoRegionChangeHide(false);

    Widget popoutButton = GwtUtil.makeImageButton(new Image(_ic.getExpandIcon()),
            "Expand this panel to take up a larger area", new ClickHandler() {
                public void onClick(ClickEvent event) {
                    expand();
                }
            });

    //        Image im = new Image(IconCreator.Creator.getInstance().getToolsIcon());
    //        Widget toolsButton = GwtUtil.makeImageButton(im, "Show tools for more image operations", new ClickHandler() {
    //            public void onClick(ClickEvent event) {
    //                ensureSelected();
    //                AllPlots ap = AllPlots.getInstance();
    //                ap.setSelectedWidget(ap.getMiniPlotWidget(), true);
    //            }
    //        });

    Widget pdfButton = GwtUtil.makeImageButton(new Image(_ic.getPdf()), "Download PDF", new ClickHandler() {
        public void onClick(ClickEvent event) {
            downloadPDF();
        }
    });

    //        Widget layerButton = GwtUtil.makeImageButton(
    //                new Image(_ic.getPlotLayers()),
    //                "Plot Layers",
    //                new ClickHandler() {
    //                    public void onClick(ClickEvent event) {
    //                        doPlotLayers();
    //                    }
    //                }
    //        );
    ValueChangeHandler<Boolean> vc = new ValueChangeHandler<Boolean>() {
        public void onValueChange(ValueChangeEvent<Boolean> ev) {
            if (_enableAllCheckEvent)
                _group.setAllChecked(ev.getValue(), false);
        }
    };

    SimplePanel sp = new SimplePanel();
    _allCheckCB.addValueChangeHandler(vc);
    GwtUtil.setStyle(sp, "padding", "5px 0 3px 0");
    sp.setWidget(_allCheckCB);

    panel.setSpacing(3);
    //        panel.add(toolsButton);
    panel.add(popoutButton);

    boolean showAllCB = true;
    boolean showPdfDownload = false;
    boolean showDrawingLayers = false;
    //only "hide" _allCheckCB if getEnableChecking()==false
    if (_group != null && _group.getAllActive() != null && !_group.getAllActive().isEmpty()) {
        showAllCB = _group.getEnableChecking();
        showPdfDownload = _group.getEnablePdfDownload();
        //            showDrawingLayers = _group.getShowDrawingLayers();
    }
    //        if (showDrawingLayers) {
    //            panel.add(layerButton);
    //        }
    if (showPdfDownload) {
        panel.add(pdfButton);
    }
    if (showAllCB)
        panel.add(sp);

    WebEventManager.getAppEvManager().addListener(Name.DROPDOWN_CLOSE, new WebEventListener() {
        public void eventNotify(WebEvent ev) {
            DeferredCommand.add(new Command() {
                public void execute() {
                    _dropClosed = true;
                    if (_showing)
                        _popup.show();
                }
            });
        }
    });

    WebEventManager.getAppEvManager().addListener(Name.DROPDOWN_OPEN, new WebEventListener() {
        public void eventNotify(WebEvent ev) {
            DeferredCommand.add(new Command() {
                public void execute() {
                    _dropClosed = false;
                    if (_showing)
                        _popup.hide();
                }
            });
        }
    });

    AllPlots.getInstance().addListener(Name.CHECKED_PLOT_CHANGE, new WebEventListener<Boolean>() {
        public void eventNotify(WebEvent<Boolean> ev) {
            MiniPlotWidget mpw = (MiniPlotWidget) ev.getSource();
            if (!mpw.isChecked()) {
                if (_allCheckCB.getValue()) {
                    _enableAllCheckEvent = false;
                    _allCheckCB.setValue(false);
                    _enableAllCheckEvent = true;
                }

            }
        }
    });

}

From source file:liber.browse.client.WysiwymMenuBar.java

License:Apache License

/**
 * Performs the action associated with the given menu item. If the item has a
 * popup associated with it, the popup will be shown. If it has a command
 * associated with it, and 'fireCommand' is true, then the command will be
 * fired. Popups associated with other items will be hidden.
 *
 * @param item the item whose popup is to be shown. @param fireCommand <code>true</code>
 * if the item's command should be fired, <code>false</code> otherwise.
 *//*from  w w w. j  av a  2  s.co m*/
void doItemAction(final WysiwymMenuItem item, boolean fireCommand) {
    // If the given item is already showing its menu, we're done.
    if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) {
        return;
    }

    // If another item is showing its menu, then hide it.
    if (shownChildMenu != null) {
        shownChildMenu.onHide();
        popup.hide();
    }

    // If the item has no popup, optionally fire its command.
    if (item.getSubMenu() == null) {
        if (fireCommand) {
            // Close this menu and all of its parents.
            closeAllParents();

            // Fire the item's command.
            Command cmd = item.getCommand();
            if (cmd != null) {
                DeferredCommand.add(cmd);
            }
        }
        return;
    }

    // Ensure that the item is selected.
    selectItem(item);

    // Create a new popup for this item, and position it next to
    // the item (below if this is a horizontal menu bar, to the
    // right if it's a vertical bar).
    popup = new PopupPanel(true) {
        {
            setWidget(item.getSubMenu());
            item.getSubMenu().onShow();
        }

        public boolean onEventPreview(Event event) {
            // Hook the popup panel's event preview. We use this to keep it from
            // auto-hiding when the parent menu is clicked.
            switch (DOM.eventGetType(event)) {
            case Event.ONCLICK:
                // If the event target is part of the parent menu, suppress the
                // event altogether.
                Element target = DOM.eventGetTarget(event);
                Element parentMenuElement = item.getParentMenu().getElement();
                if (DOM.isOrHasChild(parentMenuElement, target)) {
                    return false;
                }
                break;
            }

            return super.onEventPreview(event);
        }
    };
    popup.addPopupListener(this);

    /** ADDED TO ENSURE THAT POPUP-MENUS DO NOT RUN OFF SCREEN */
    if ((item.getAbsoluteLeft() + item.getOffsetWidth() + 150) > Window.getClientWidth()) //don't let the menu run off the page
        popup.setPopupPosition(item.getAbsoluteLeft() - 120, item.getAbsoluteTop());
    else
        popup.setPopupPosition(item.getAbsoluteLeft() + item.getOffsetWidth(), item.getAbsoluteTop());

    shownChildMenu = item.getSubMenu();
    item.getSubMenu().parentMenu = this;

    // Show the popup, ensuring that the WysiwymMenuBar's event preview remains on top
    // of the popup's.
    popup.show();
}