use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class ManipulatorPopupPanel method update.
public void update(Manipulator manipulator) {
mainPanel_.clear();
if (manipulator != null && manipulator.getVariables() != null) {
// iterate over the variables
JsArrayString variables = manipulator.getVariables();
for (int i = 0; i < variables.length(); i++) {
String variable = variables.get(i);
try {
ManipulatorControl addedControl = null;
Manipulator.Control control = manipulator.getControl(variable);
switch(control.getType()) {
case Manipulator.Control.SLIDER:
Manipulator.Slider slider = control.cast();
addedControl = addSliderControl(variable, manipulator.getDoubleValue(variable), slider);
break;
case Manipulator.Control.PICKER:
Manipulator.Picker picker = control.cast();
addedControl = addPickerControl(variable, manipulator.getStringValue(variable), picker);
break;
case Manipulator.Control.CHECKBOX:
Manipulator.CheckBox checkBox = control.cast();
addedControl = addCheckBoxControl(variable, manipulator.getBooleanValue(variable), checkBox);
break;
case Manipulator.Control.BUTTON:
Manipulator.Button button = control.cast();
addedControl = addButtonControl(variable, button);
break;
}
// save reference to first control (for setting focus)
if (i == 0)
firstControl_ = addedControl;
} catch (Throwable e) {
Debug.log("WARNING: exception occurred during addition of " + "variable " + variable + ", " + e.getMessage());
}
}
}
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class Source method openProjectDocs.
private void openProjectDocs(final Session session) {
JsArrayString openDocs = session.getSessionInfo().getProjectOpenDocs();
if (openDocs.length() > 0) {
// set new tab pending for the duration of the continuation
newTabPending_++;
// create a continuation for opening the source docs
SerializedCommandQueue openCommands = new SerializedCommandQueue();
for (int i = 0; i < openDocs.length(); i++) {
String doc = openDocs.get(i);
final FileSystemItem fsi = FileSystemItem.createFile(doc);
openCommands.addCommand(new SerializedCommand() {
@Override
public void onExecute(final Command continuation) {
openFile(fsi, fileTypeRegistry_.getTextTypeForFile(fsi), new CommandWithArg<EditingTarget>() {
@Override
public void execute(EditingTarget arg) {
continuation.execute();
}
});
}
});
}
// decrement newTabPending and select first tab when done
openCommands.addCommand(new SerializedCommand() {
@Override
public void onExecute(Command continuation) {
newTabPending_--;
onFirstTab();
continuation.execute();
}
});
// execute the continuation
openCommands.run();
}
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class IgnoredUpdates method addIgnoredUpdate.
public final void addIgnoredUpdate(String update) {
JsArrayString newUpdateList = create().getIgnoredUpdates();
JsArrayString existingUpdateList = getIgnoredUpdates();
for (int i = 0; i < existingUpdateList.length(); i++) {
// we're about to add.
if (ApplicationUtils.compareVersions(update, existingUpdateList.get(i)) < 0) {
newUpdateList.push(existingUpdateList.get(i));
}
}
newUpdateList.push(update);
setIgnoredUpdates(newUpdateList);
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class TextEditingTarget method onExtractLocalVariable.
@Handler
void onExtractLocalVariable() {
if (!isCursorInRMode()) {
showRModeWarning("Extract Variable");
return;
}
docDisplay_.focus();
String initialSelection = docDisplay_.getSelectionValue();
final String refactoringName = "Extract local variable";
final String pleaseSelectCodeMessage = "Please select the code to " + "extract into a variable.";
if (checkSelectionAndAlert(refactoringName, pleaseSelectCodeMessage, initialSelection))
return;
docDisplay_.fitSelectionToLines(false);
final String code = docDisplay_.getSelectionValue();
if (checkSelectionAndAlert(refactoringName, pleaseSelectCodeMessage, code))
return;
// get the first line of the selection and calculate it's indentation
String firstLine = docDisplay_.getLine(docDisplay_.getSelectionStart().getRow());
final String indentation = extractIndentation(firstLine);
// used to parse the code
server_.detectFreeVars(code, new RefactorServerRequestCallback(refactoringName) {
@Override
void doExtract(JsArrayString response) {
globalDisplay_.promptForText(refactoringName, "Variable Name", "", new OperationWithInput<String>() {
public void execute(String input) {
final String extractedCode = indentation + input.trim() + " <- " + code + "\n";
InputEditorPosition insertPosition = docDisplay_.getSelection().extendToLineStart().getStart();
docDisplay_.replaceSelection(input.trim());
docDisplay_.insertCode(insertPosition, extractedCode);
}
});
}
});
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class TextEditingTarget method onExtractFunction.
@Handler
void onExtractFunction() {
if (!isCursorInRMode()) {
showRModeWarning("Extract Function");
return;
}
docDisplay_.focus();
String initialSelection = docDisplay_.getSelectionValue();
final String refactoringName = "Extract Function";
final String pleaseSelectCodeMessage = "Please select the code to " + "extract into a function.";
if (checkSelectionAndAlert(refactoringName, pleaseSelectCodeMessage, initialSelection))
return;
docDisplay_.fitSelectionToLines(false);
final String code = docDisplay_.getSelectionValue();
if (checkSelectionAndAlert(refactoringName, pleaseSelectCodeMessage, code))
return;
final String indentation = extractIndentation(code);
server_.detectFreeVars(code, new RefactorServerRequestCallback(refactoringName) {
@Override
void doExtract(final JsArrayString response) {
globalDisplay_.promptForText(refactoringName, "Function Name", "", new OperationWithInput<String>() {
public void execute(String input) {
String prefix;
if (docDisplay_.getSelectionOffset(true) == 0)
prefix = "";
else
prefix = "\n";
String args = response != null ? response.join(", ") : "";
docDisplay_.replaceSelection(prefix + indentation + input.trim() + " <- " + "function(" + args + ") {\n" + StringUtil.indent(code, " ") + "\n" + indentation + "}");
}
});
}
});
}
Aggregations