Search in sources :

Example 96 with ScheduledCommand

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

the class DraftBox method setEdit.

void setEdit(boolean edit) {
    UIObject.setVisible(summary, false);
    UIObject.setVisible(p_view, !edit);
    UIObject.setVisible(p_edit, edit);
    setRangeHighlight(edit);
    if (edit) {
        String msg = comment.message() != null ? comment.message() : "";
        editArea.setValue(msg);
        cancel.setVisible(!isNew());
        expandText();
        editAreaHeight = editArea.getOffsetHeight();
        final int len = msg.length();
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                editArea.setFocus(true);
                if (len > 0) {
                    editArea.setCursorPos(len);
                }
            }
        });
    } else {
        expandTimer.cancel();
        resizeTimer.cancel();
    }
    getCommentManager().setUnsaved(this, edit);
    getCommentGroup().resize();
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 97 with ScheduledCommand

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

the class DiffScreen method onGutterClick.

private GutterClickHandler onGutterClick(final CodeMirror cm) {
    return new GutterClickHandler() {

        @Override
        public void handle(CodeMirror instance, final int line, final String gutterClass, NativeEvent clickEvent) {
            if (Element.as(clickEvent.getEventTarget()).hasClassName(getLineNumberClassName()) && clickEvent.getButton() == NativeEvent.BUTTON_LEFT && !clickEvent.getMetaKey() && !clickEvent.getAltKey() && !clickEvent.getCtrlKey() && !clickEvent.getShiftKey()) {
                cm.setCursor(Pos.create(line));
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        getCommentManager().newDraftOnGutterClick(cm, gutterClass, line + 1);
                    }
                });
            }
        }
    };
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) GutterClickHandler(net.codemirror.lib.CodeMirror.GutterClickHandler) CodeMirror(net.codemirror.lib.CodeMirror) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 98 with ScheduledCommand

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

the class ReplyBox method onLoad.

@Override
protected void onLoad() {
    commentsPanel.setVisible(false);
    post.setEnabled(false);
    if (lc.hasReplyComment()) {
        message.setText(lc.getReplyComment());
        lc.removeReplyComment();
    }
    ChangeApi.drafts(psId.getParentKey().get()).get(new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {

        @Override
        public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
            displayComments(result);
            post.setEnabled(true);
        }

        @Override
        public void onFailure(Throwable caught) {
            post.setEnabled(true);
        }
    });
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            message.setFocus(true);
        }
    });
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            String t = message.getText();
            if (t != null) {
                message.setCursorPos(t.length());
            }
            return false;
        }
    }, 0);
}
Also used : JsArray(com.google.gwt.core.client.JsArray) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) CommentInfo(com.google.gerrit.client.changes.CommentInfo) JsArrayString(com.google.gwt.core.client.JsArrayString) NativeMap(com.google.gerrit.client.rpc.NativeMap)

Example 99 with ScheduledCommand

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

the class SearchStateManager method handleAutocompleteEvent.

public boolean handleAutocompleteEvent(final NativeEvent event) {
    final String eventType = event.getType();
    final int eventKeyCode = event.getKeyCode();
    LOG.info("handleAutocompleteEvent(" + m_state + "): received " + eventType + " (keyCode = " + eventKeyCode + ")");
    if ("keydown".equals(eventType)) {
        switch(eventKeyCode) {
            case KeyCodes.KEY_ESCAPE:
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        m_state = m_state.cancelSearching(SearchStateManager.this);
                    }
                });
                event.stopPropagation();
                break;
            case KeyCodes.KEY_ENTER:
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        m_state = m_state.currentEntrySelected(SearchStateManager.this);
                    }
                });
                event.stopPropagation();
                break;
        }
    } else if ("click".equals(eventType) || "touchstart".equals(eventType)) {
        // someone clicked on an entry
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                m_state = m_state.currentEntrySelected(SearchStateManager.this);
            }
        });
        event.stopPropagation();
        return true;
    } else {
        LOG.info("handleAutocompleteEvent(" + m_state + "): unhandled event: " + eventType);
        return true;
    }
    return false;
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 100 with ScheduledCommand

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

the class SearchStateManager method handleSearchIconEvent.

public void handleSearchIconEvent(final NativeEvent event) {
    final String eventType = event.getType();
    LOG.info("handleSearchIconEvent(" + m_state + "): received " + eventType + " (keyCode = " + event.getKeyCode() + ")");
    if ("click".equals(eventType) || "touchstart".equals(eventType)) {
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                m_state = m_state.finishedSearching(SearchStateManager.this);
            }
        });
    } else {
        LOG.info("handleSearchIconEvent(" + m_state + "): unhandled event: " + eventType);
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

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