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);
}
});
}
});
}
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;
});
}
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();
}
});
}
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));
}
}
});
}
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);
}
Aggregations