Search in sources :

Example 51 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.

the class FilesPane method onBeforeSelected.

@Override
public void onBeforeSelected() {
    if (needsInit) {
        needsInit = false;
        FileSystemItem home = FileSystemItem.home();
        observer_.onFileNavigation(home);
    } else {
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                filesList_.redraw();
            }
        });
    }
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 52 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.

the class RSConnectDeploy method populateDeploymentFiles.

private void populateDeploymentFiles(final ProgressIndicator indicator) {
    if (source_ == null)
        return;
    // dependencies; just inject it directly into the list.
    if (source_.isSelfContained() && source_.isStatic() && !source_.isWebsiteRmd()) {
        ArrayList<String> files = new ArrayList<String>();
        FileSystemItem selfContained = FileSystemItem.createFile(source_.getDeployFile());
        files.add(selfContained.getName());
        setFileList(files, null, null);
        setPrimaryFile(selfContained.getName());
        return;
    }
    // ternery operator maps to appropriate files to list for deployment:
    // website code    - website code directory 
    // static website  - website build directory
    // document        - R Markdown document
    // non-document    - Shiny app directory
    final String fileSource = source_.isDocument() ? source_.isWebsiteRmd() ? source_.isStatic() ? source_.getDeployDir() : source_.getWebsiteDir() : source_.getDeployFile() : source_.getDeployDir();
    indicator.onProgress("Collecting files...");
    server_.getDeploymentFiles(fileSource, asMultipleRmd_, new ServerRequestCallback<RSConnectDeploymentFiles>() {

        @Override
        public void onResponseReceived(RSConnectDeploymentFiles files) {
            if (files.getDirSize() > files.getMaxSize()) {
                indicator.onError("The item to be deployed (" + fileSource + ") " + "exceeds the maximum deployment size, which is " + StringUtil.formatFileSize(files.getMaxSize()) + "." + " Consider creating a new directory containing " + "only the content you wish to deploy.");
            } else {
                if (files.getDirList() == null || files.getDirList().length() == 0) {
                    indicator.onError("Could not determine the list of " + "files to deploy.");
                    indicator.onCompleted();
                }
                setFileList(JsArrayUtil.fromJsArrayString(files.getDirList()), fromPrevious_ != null ? fromPrevious_.getAdditionalFiles() : null, fromPrevious_ != null ? fromPrevious_.getIgnoredFiles() : null);
                if (!source_.isWebsiteRmd())
                    setPrimaryFile(FileSystemItem.createFile(source_.getDeployFile()).getName());
            }
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    indicator.clearProgress();
                }
            });
        }

        @Override
        public void onError(ServerError error) {
            // we need to have a list of files to deploy to proceed
            indicator.onError("Could not find files to deploy: \n\n" + error.getMessage());
            indicator.onCompleted();
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) RSConnectDeploymentFiles(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentFiles)

Example 53 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project GwtMobile by dennisjzh.

the class CheckBoxGroup method onClick.

@Override
public void onClick(ClickEvent e) {
    final EventTarget target = e.getNativeEvent().getEventTarget();
    String targetTagName = ((Element) target.cast()).getTagName().toUpperCase();
    Utils.Console("onClick target " + targetTagName);
    if (targetTagName.equals("LABEL")) {
        // if check box label is click, another (simulated) click event with
        return;
    // check box INPUT as target will fire after this one. So this click event
    // can be safely ignored.
    }
    Element div = Element.as(target);
    while (!div.getNodeName().toUpperCase().equals("SPAN") || div.getParentElement() != this.getElement()) {
        div = div.getParentElement();
        if (div == null) {
            Utils.Console("CheckBoxGroup onClick: span not found");
            return;
        }
    }
    final int index = DOM.getChildIndex(this.getElement(), (com.google.gwt.user.client.Element) div);
    com.google.gwt.user.client.ui.CheckBox checkbox = (com.google.gwt.user.client.ui.CheckBox) _panel.getWidget(index);
    Utils.Console("onClick " + checkbox.getValue());
    if (targetTagName.equals("INPUT")) {
        Utils.Console("onClick value changed");
        // if target is check box INPUT, check box value is 
        checkbox.setValue(checkbox.getValue());
    // already changed when click event is fired.
    // just need to set its current value back to the check box
    // to update style.
    } else {
        checkbox.setValue(!checkbox.getValue());
    }
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(index, target);
            fireEvent(selectionChangedEvent);
        }
    });
}
Also used : Element(com.google.gwt.dom.client.Element) SelectionChangedEvent(com.gwtmobile.ui.client.event.SelectionChangedEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) EventTarget(com.google.gwt.dom.client.EventTarget)

Example 54 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project blogwt by billy1380.

the class GalleryPlugin method emit.

/* (non-Javadoc)
	 * 
	 * @see org.markdown4j.Plugin#emit(java.lang.StringBuilder, java.util.List,
	 * java.util.Map) */
@Override
public void emit(StringBuilder out, final List<String> lines, final Map<String, String> params) {
    final String id = HTMLPanel.createUniqueId();
    out.append("<div id=\"");
    out.append(id);
    out.append("\"> Loading gallery...</div>");
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            if (manager != null) {
                manager.fireEvent(new PluginContentReadyEvent(GalleryPlugin.this, lines, params, id, "None"));
            }
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) PluginContentReadyEvent(org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent)

Example 55 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project che by eclipse.

the class PopupKeyDownListener method handleEvent.

@Override
public void handleEvent(final Event evt) {
    if (evt instanceof KeyboardEvent) {
        final KeyboardEvent keyEvent = (KeyboardEvent) evt;
        switch(keyEvent.getKeyCode()) {
            case KeyCodes.KEY_ESCAPE:
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        popupWidget.hide();
                    }
                });
                break;
            case KeyCodes.KEY_DOWN:
                focusNext();
                break;
            case KeyCodes.KEY_UP:
                focusPrevious();
                break;
            case KeyCodes.KEY_HOME:
                focusFirst();
                break;
            case KeyCodes.KEY_END:
                focusLast();
                break;
            case KeyCodes.KEY_ENTER:
                evt.preventDefault();
                evt.stopImmediatePropagation();
                validateItem();
                break;
            default:
        }
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) KeyboardEvent(elemental.events.KeyboardEvent)

Aggregations

ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)105 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)7 Element (com.google.gwt.dom.client.Element)6 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)6 JsArray (com.google.gwt.core.client.JsArray)5 Command (com.google.gwt.user.client.Command)5 ServerError (org.rstudio.studio.client.server.ServerError)5 JsArrayString (com.google.gwt.core.client.JsArrayString)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)4 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 Event (com.google.gwt.user.client.Event)3 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)3 Timer (com.google.gwt.user.client.Timer)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)3 ErrorDialog (com.google.gerrit.client.ErrorDialog)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2