List of usage examples for com.google.gwt.core.client JsArrayString get
public final native String get(int index) ;
From source file:org.rstudio.core.client.js.JsUtil.java
License:Open Source License
public static boolean areEqual(JsArrayString a, JsArrayString b) { if (a == null && b == null) return true; else if (a == null && b != null) return false; else if (a != null && b == null) return false; else if (a.length() != b.length()) return false; else {/*from w ww .j a v a 2s .co m*/ for (int i = 0; i < a.length(); i++) { if (!a.get(i).equals(b.get(i))) return false; } return true; } }
From source file:org.rstudio.core.client.js.JsUtil.java
License:Open Source License
public static String[] toStringArray(JsArrayString strings) { String[] result = new String[strings.length()]; for (int i = 0; i < strings.length(); i++) result[i] = strings.get(i); return result; }
From source file:org.rstudio.core.client.JsArrayUtil.java
License:Open Source License
public static boolean jsArrayStringContains(JsArrayString haystack, String needle) { for (int i = 0; i < haystack.length(); i++) { if (haystack.get(i).equals(needle)) return true; }/* w w w .j a v a 2 s . c o m*/ return false; }
From source file:org.rstudio.core.client.JsArrayUtil.java
License:Open Source License
public static ArrayList<String> fromJsArrayString(JsArrayString in) { ArrayList<String> out = new ArrayList<String>(); for (int i = 0; i < in.length(); i++) { out.add(in.get(i)); }/* w w w . j a va2s .co m*/ return out; }
From source file:org.rstudio.core.client.ListUtil.java
License:Open Source License
public static List<String> create(JsArrayString array) { List<String> list = new ArrayList<String>(); for (int i = 0, n = array.length(); i < n; i++) list.add(array.get(i)); return list;//from w ww .ja va 2s .c o m }
From source file:org.rstudio.core.client.widget.ModifyKeyboardShortcutsWidget.java
License:Open Source License
private void collectShortcuts() { final List<KeyboardShortcutEntry> bindings = new ArrayList<KeyboardShortcutEntry>(); SerializedCommandQueue queue = new SerializedCommandQueue(); // Load addins discovered as part of package exports. This registers // the addin, with the actual keybinding to be registered later, // if discovered. queue.addCommand(new SerializedCommand() { @Override/* w w w. j av a2 s.c o m*/ public void onExecute(final Command continuation) { RAddins rAddins = addins_.getRAddins(); for (String key : JsUtil.asIterable(rAddins.keys())) { RAddin addin = rAddins.get(key); bindings.add(new KeyboardShortcutEntry(addin.getPackage() + "::" + addin.getBinding(), addin.getName(), new KeySequence(), KeyboardShortcutEntry.TYPE_ADDIN, false, AppCommand.Context.Addin)); } continuation.execute(); } }); // Load saved addin bindings queue.addCommand(new SerializedCommand() { @Override public void onExecute(final Command continuation) { addins_.loadBindings(new CommandWithArg<EditorKeyBindings>() { @Override public void execute(EditorKeyBindings addinBindings) { for (String commandId : addinBindings.iterableKeys()) { EditorKeyBinding addinBinding = addinBindings.get(commandId); for (KeyboardShortcutEntry binding : bindings) { if (binding.getId() == commandId) { List<KeySequence> keys = addinBinding.getKeyBindings(); if (keys.size() >= 1) binding.setDefaultKeySequence(keys.get(0)); if (keys.size() >= 2) { for (int i = 1; i < keys.size(); i++) { bindings.add( new KeyboardShortcutEntry(binding.getId(), binding.getName(), keys.get(i), KeyboardShortcutEntry.TYPE_ADDIN, false, AppCommand.Context.Addin)); } } } } } continuation.execute(); } }); } }); // Ace loading command queue.addCommand(new SerializedCommand() { @Override public void onExecute(final Command continuation) { // Ace Commands JsArray<AceCommand> aceCommands = editorCommands_.getCommands(); for (int i = 0; i < aceCommands.length(); i++) { AceCommand command = aceCommands.get(i); JsArrayString shortcuts = command.getBindingsForCurrentPlatform(); if (shortcuts != null) { String id = command.getInternalName(); String name = command.getDisplayName(); boolean custom = command.isCustomBinding(); for (int j = 0; j < shortcuts.length(); j++) { String shortcut = shortcuts.get(j); KeySequence keys = KeySequence.fromShortcutString(shortcut); int type = KeyboardShortcutEntry.TYPE_EDITOR_COMMAND; bindings.add(new KeyboardShortcutEntry(id, name, keys, type, custom, AppCommand.Context.Editor)); } } } continuation.execute(); } }); // RStudio commands queue.addCommand(new SerializedCommand() { @Override public void onExecute(final Command continuation) { // RStudio Commands appCommands_.loadBindings(new CommandWithArg<EditorKeyBindings>() { @Override public void execute(final EditorKeyBindings customBindings) { Map<String, AppCommand> commands = commands_.getCommands(); for (Map.Entry<String, AppCommand> entry : commands.entrySet()) { AppCommand command = entry.getValue(); if (isExcludedCommand(command)) continue; String id = command.getId(); String name = getAppCommandName(command); int type = KeyboardShortcutEntry.TYPE_RSTUDIO_COMMAND; boolean isCustom = customBindings.hasKey(id); List<KeySequence> keySequences = new ArrayList<KeySequence>(); if (isCustom) keySequences = customBindings.get(id).getKeyBindings(); else keySequences.add(command.getKeySequence()); for (KeySequence keys : keySequences) { KeyboardShortcutEntry binding = new KeyboardShortcutEntry(id, name, keys, type, isCustom, command.getContext()); bindings.add(binding); } } continuation.execute(); } }); } }); // Sort and finish up queue.addCommand(new SerializedCommand() { @Override public void onExecute(final Command continuation) { Collections.sort(bindings, new Comparator<KeyboardShortcutEntry>() { @Override public int compare(KeyboardShortcutEntry o1, KeyboardShortcutEntry o2) { if (o1.getContext() != o2.getContext()) return o1.getContext().compareTo(o2.getContext()); return o1.getName().compareTo(o2.getName()); } }); originalBindings_ = bindings; updateData(bindings); continuation.execute(); } }); queue.addCommand(new SerializedCommand() { @Override public void onExecute(Command continuation) { if (initialFilterText_ != null) { filterWidget_.setText(initialFilterText_); filter(); } continuation.execute(); } }); // Exhaust the queue queue.run(); }
From source file:org.rstudio.studio.client.application.IgnoredUpdates.java
License:Open Source License
public final void addIgnoredUpdate(String update) { JsArrayString newUpdateList = create().getIgnoredUpdates(); JsArrayString existingUpdateList = getIgnoredUpdates(); for (int i = 0; i < existingUpdateList.length(); i++) { // We want to discard any updates we're ignoring that are older than // the one we're ignoring now--i.e. if we're currently ignoring // { 0.98.407, 0.99.440 }, and we were just asked to ignore // 0.98.411, the new set should be { 0.98.411, 0.99.440 }. Do this by // only keeping updates in the list that are newer than the update // we're about to add. if (compareVersions(update, existingUpdateList.get(i)) < 0) { newUpdateList.push(existingUpdateList.get(i)); }//from w w w. j a v a 2 s . c o m } newUpdateList.push(update); setIgnoredUpdates(newUpdateList); }
From source file:org.rstudio.studio.client.application.ui.impl.DesktopApplicationHeader.java
License:Open Source License
private void respondToUpdateCheck(final UpdateCheckResult result, boolean manual) { boolean ignoredUpdate = false; if (result.getUpdateVersion().length() > 0) { JsArrayString ignoredUpdates = ignoredUpdates_.getIgnoredUpdates(); for (int i = 0; i < ignoredUpdates.length(); i++) { if (ignoredUpdates.get(i).equals(result.getUpdateVersion())) { ignoredUpdate = true;/*from w w w. j a va 2 s . c om*/ } } } if (result.getUpdateVersion().length() > 0 && !ignoredUpdate) { ArrayList<String> buttonLabels = new ArrayList<String>(); ArrayList<Operation> buttonOperations = new ArrayList<Operation>(); buttonLabels.add("Quit and Download..."); buttonOperations.add(new Operation() { @Override public void execute() { appQuit_.prepareForQuit("Update RStudio", new QuitContext() { @Override public void onReadyToQuit(boolean saveChanges) { Desktop.getFrame().browseUrl(result.getUpdateUrl()); appQuit_.performQuit(saveChanges, null); } }); } }); buttonLabels.add("Remind Later"); buttonOperations.add(new Operation() { @Override public void execute() { // Don't do anything here; the prompt will re-appear the next // time we do an update check } }); // Only provide the option to ignore the update if it's not urgent. if (result.getUpdateUrgency() == 0) { buttonLabels.add("Ignore Update"); buttonOperations.add(new Operation() { @Override public void execute() { ignoredUpdates_.addIgnoredUpdate(result.getUpdateVersion()); ignoredUpdatesDirty_ = true; } }); } globalDisplay_.showGenericDialog(GlobalDisplay.MSG_QUESTION, "Update Available", result.getUpdateMessage(), buttonLabels, buttonOperations, 0); } else if (manual) { globalDisplay_.showMessage(GlobalDisplay.MSG_INFO, "No Update Available", "You're using the newest version of RStudio."); } }
From source file:org.rstudio.studio.client.common.JSONArrayBuilder.java
License:Open Source License
public final JSONArrayBuilder add(JsArrayString value) { JSONArray array = new JSONArray(); for (int i = 0, n = value.length(); i < n; i++) array.set(i, fromString(value.get(i))); append(array);//from w w w .j a v a2 s . c o m return this; }
From source file:org.rstudio.studio.client.common.latex.LatexProgramRegistry.java
License:Open Source License
public ArrayList<String> getTypes() { if (latexProgramTypes_ == null) { JsArrayString types = pSession_.get().getSessionInfo().getLatexProgramTypes(); latexProgramTypes_ = new ArrayList<String>(); for (int i = 0; i < types.length(); i++) latexProgramTypes_.add(types.get(i)); }/*from ww w. j av a 2s . co m*/ return latexProgramTypes_; }