Search in sources :

Example 6 with JsArray

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

the class LintManager method performCppLintServerRequest.

private void performCppLintServerRequest(final LintContext context) {
    cppCompletionContext_.cppCompletionOperation(new CppCompletionOperation() {

        @Override
        public void execute(String docPath, int line, int column) {
            server_.getCppDiagnostics(target_.getPath(), new ServerRequestCallback<JsArray<CppDiagnostic>>() {

                @Override
                public void onResponseReceived(JsArray<CppDiagnostic> diag) {
                    if (context.token.isInvalid())
                        return;
                    final JsArray<LintItem> cppLint = CppCompletionRequest.asLintArray(diag);
                    server_.lintRSourceDocument(target_.getId(), target_.getPath(), context.showMarkers, context.explicit, new ServerRequestCallback<JsArray<LintItem>>() {

                        @Override
                        public void onResponseReceived(JsArray<LintItem> rLint) {
                            if (context.token.isInvalid())
                                return;
                            JsArray<LintItem> allLint = JsArray.createArray().cast();
                            for (int i = 0; i < cppLint.length(); i++) allLint.push(cppLint.get(i));
                            for (int i = 0; i < rLint.length(); i++) allLint.push(rLint.get(i));
                            showLint(context, allLint);
                        }

                        @Override
                        public void onError(ServerError error) {
                            Debug.logError(error);
                        }
                    });
                }

                @Override
                public void onError(ServerError error) {
                    Debug.logError(error);
                }
            });
        }
    });
}
Also used : CppCompletionOperation(org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation) JsArray(com.google.gwt.core.client.JsArray) LintItem(org.rstudio.studio.client.workbench.views.output.lint.model.LintItem) CppDiagnostic(org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic) ServerError(org.rstudio.studio.client.server.ServerError) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

Example 7 with JsArray

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

the class FilesList method addColumnSortHandler.

private void addColumnSortHandler() {
    filesDataGrid_.addColumnSortHandler(new Handler() {

        @Override
        public void onColumnSort(ColumnSortEvent event) {
            ColumnSortList sortList = event.getColumnSortList();
            // insert the default initial sort order for size and modified
            if (!applyingProgrammaticSort_) {
                if (event.getColumn().equals(sizeColumn_) && forceSizeSortDescending) {
                    forceSizeSortDescending = false;
                    forceModifiedSortDescending = true;
                    sortList.insert(0, new com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo(event.getColumn(), false));
                } else if (event.getColumn().equals(modifiedColumn_) && forceModifiedSortDescending) {
                    forceModifiedSortDescending = false;
                    forceSizeSortDescending = true;
                    sortList.insert(0, new com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo(event.getColumn(), false));
                } else {
                    forceModifiedSortDescending = true;
                    forceSizeSortDescending = true;
                }
            }
            // record sort order and fire event to observer
            JsArray<ColumnSortInfo> sortOrder = newSortOrderArray();
            for (int i = 0; i < sortList.size(); i++) {
                // match the column index
                com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo sortInfo = sortList.get(i);
                Object column = sortInfo.getColumn();
                for (int c = 0; c < filesDataGrid_.getColumnCount(); c++) {
                    if (filesDataGrid_.getColumn(c).equals(column)) {
                        boolean ascending = sortInfo.isAscending();
                        sortOrder.push(ColumnSortInfo.create(c, ascending));
                        break;
                    }
                }
            }
            observer_.onColumnSortOrderChanaged(sortOrder);
            // record active sort column ascending state
            activeSortColumnAscending_ = event.isSortAscending();
            // delegate the sort
            sortHandler_.onColumnSort(event);
        }

        private final native JsArray<ColumnSortInfo> newSortOrderArray();

        private boolean forceSizeSortDescending = true;

        private boolean forceModifiedSortDescending = true;
    });
}
Also used : ColumnSortInfo(org.rstudio.core.client.cellview.ColumnSortInfo) JsArray(com.google.gwt.core.client.JsArray) Handler(com.google.gwt.user.cellview.client.ColumnSortEvent.Handler) ResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent) ColumnSortList(com.google.gwt.user.cellview.client.ColumnSortList)

Example 8 with JsArray

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

the class AceEditorWidget method removeMarkersAtCursorPosition.

public void removeMarkersAtCursorPosition() {
    // Defer this so other event handling can update anchors etc.
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            Position cursor = editor_.getCursorPosition();
            JsArray<AceAnnotation> newAnnotations = JsArray.createArray().cast();
            for (int i = 0; i < annotations_.size(); i++) {
                AnchoredAceAnnotation annotation = annotations_.get(i);
                int markerId = annotation.getMarkerId();
                Marker marker = editor_.getSession().getMarker(markerId);
                // a previous action.
                if (marker == null)
                    continue;
                Range range = marker.getRange();
                if (!range.contains(cursor))
                    newAnnotations.push(annotation.asAceAnnotation());
                else
                    editor_.getSession().removeMarker(markerId);
            }
            editor_.getSession().setAnnotations(newAnnotations);
            editor_.getRenderer().renderMarkers();
        }
    });
}
Also used : JsArray(com.google.gwt.core.client.JsArray) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) Marker(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Marker) Range(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range) AnchoredRange(org.rstudio.studio.client.workbench.views.source.editors.text.ace.AnchoredRange)

Example 9 with JsArray

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

the class TextEditingTarget method initStatusBar.

private void initStatusBar() {
    statusBar_ = view_.getStatusBar();
    docDisplay_.addCursorChangedHandler(new CursorChangedHandler() {

        public void onCursorChanged(CursorChangedEvent event) {
            updateStatusBarPosition();
            if (docDisplay_.isScopeTreeReady(event.getPosition().getRow()))
                updateCurrentScope();
        }
    });
    updateStatusBarPosition();
    updateStatusBarLanguage();
    // build file type menu dynamically (so it can change according
    // to whether e.g. knitr is installed)
    statusBar_.getLanguage().addMouseDownHandler(new MouseDownHandler() {

        @Override
        public void onMouseDown(MouseDownEvent event) {
            // build menu with all file types - also track whether we need
            // to add the current type (may be the case for types which we 
            // support but don't want to expose on the menu -- e.g. Rmd 
            // files when knitr isn't installed)
            boolean addCurrentType = true;
            final StatusBarPopupMenu menu = new StatusBarPopupMenu();
            TextFileType[] fileTypes = fileTypeCommands_.statusBarFileTypes();
            for (TextFileType type : fileTypes) {
                menu.addItem(createMenuItemForType(type));
                if (addCurrentType && type.equals(fileType_))
                    addCurrentType = false;
            }
            // add the current type if isn't on the menu 
            if (addCurrentType)
                menu.addItem(createMenuItemForType(fileType_));
            // show the menu
            menu.showRelativeToUpward((UIObject) statusBar_.getLanguage(), true);
        }
    });
    statusBar_.getScope().addMouseDownHandler(new MouseDownHandler() {

        public void onMouseDown(MouseDownEvent event) {
            // Unlike the other status bar elements, the function outliner
            // needs its menu built on demand
            JsArray<Scope> tree = docDisplay_.getScopeTree();
            final StatusBarPopupMenu menu = new StatusBarPopupMenu();
            MenuItem defaultItem = null;
            if (fileType_.isRpres()) {
                String path = docUpdateSentinel_.getPath();
                if (path != null) {
                    presentationHelper_.buildSlideMenu(docUpdateSentinel_.getPath(), dirtyState_.getValue(), TextEditingTarget.this, new CommandWithArg<StatusBarPopupRequest>() {

                        @Override
                        public void execute(StatusBarPopupRequest request) {
                            showStatusBarPopupMenu(request);
                        }
                    });
                }
            } else {
                defaultItem = addFunctionsToMenu(menu, tree, "", docDisplay_.getCurrentScope(), true);
                showStatusBarPopupMenu(new StatusBarPopupRequest(menu, defaultItem));
            }
        }
    });
}
Also used : UIObject(com.google.gwt.user.client.ui.UIObject) JsArray(com.google.gwt.core.client.JsArray) StatusBarPopupMenu(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu) MenuItem(com.google.gwt.user.client.ui.MenuItem) JsArrayString(com.google.gwt.core.client.JsArrayString) TextFileType(org.rstudio.studio.client.common.filetypes.TextFileType) StatusBarPopupRequest(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupRequest)

Example 10 with JsArray

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

the class Presentation method onPresentationSlideChanged.

private void onPresentationSlideChanged(final int index, final JavaScriptObject jsCmds) {
    // note the slide index and save it
    currentState_.setSlideIndex(index);
    indexPersister_.setIndex(index);
    handlerManager_.fireEvent(new SlideIndexChangedEvent(index));
    // execute commands if we stay on the slide for > 500ms
    new Timer() {

        @Override
        public void run() {
            // execute commands if we're still on the same slide
            if (index == currentState_.getSlideIndex()) {
                JsArray<JavaScriptObject> cmds = jsCmds.cast();
                for (int i = 0; i < cmds.length(); i++) dispatchCommand(cmds.get(i));
            }
        }
    }.schedule(500);
}
Also used : JsArray(com.google.gwt.core.client.JsArray) Timer(com.google.gwt.user.client.Timer) SlideIndexChangedEvent(org.rstudio.studio.client.common.presentation.events.SlideIndexChangedEvent)

Aggregations

JsArray (com.google.gwt.core.client.JsArray)39 ArrayList (java.util.ArrayList)14 ServerError (org.rstudio.studio.client.server.ServerError)12 JsArrayString (com.google.gwt.core.client.JsArrayString)7 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)5 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)4 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)4 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)4 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)4 HTML (com.google.gwt.user.client.ui.HTML)3 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)3 CommentInfo (com.google.gerrit.client.changes.CommentInfo)2 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)2 NativeString (com.google.gerrit.client.rpc.NativeString)2 Context (com.google.gwt.cell.client.Cell.Context)2