Search in sources :

Example 1 with JsArrayNumber

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

the class History method onHistoryRemoveEntries.

@Handler
void onHistoryRemoveEntries() {
    // get selected indexes (bail if there is no selection)
    final ArrayList<Integer> selectedRowIndexes = view_.getRecentCommandsSelectedRowIndexes();
    if (selectedRowIndexes.size() < 1) {
        globalDisplay_.showErrorMessage("Error", "No history entries currently selected.");
        return;
    }
    // bring view to front
    view_.bringToFront();
    globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Confirm Remove Entries", "Are you sure you want to remove the selected entries from " + "the history?", new ProgressOperation() {

        public void execute(final ProgressIndicator indicator) {
            indicator.onProgress("Removing items...");
            // for each selected row index we need to calculate
            // the offset from the bottom
            int rowCount = view_.getRecentCommandsRowsDisplayed();
            JsArrayNumber bottomIndexes = (JsArrayNumber) JsArrayNumber.createArray();
            for (int i = 0; i < selectedRowIndexes.size(); i++) bottomIndexes.push(rowCount - selectedRowIndexes.get(i) - 1);
            server_.removeHistoryItems(bottomIndexes, new VoidServerRequestCallback(indicator));
        }
    }, true);
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) JsArrayNumber(com.google.gwt.core.client.JsArrayNumber) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 2 with JsArrayNumber

use of com.google.gwt.core.client.JsArrayNumber in project playn by threerings.

the class ArrayUtils method toJsArray.

public static JsArrayNumber toJsArray(float[] data) {
    JsArrayNumber jsan = (JsArrayNumber) JsArrayNumber.createArray();
    int len = data.length;
    for (int i = len - 1; i >= 0; i--) {
        jsan.set(i, data[i]);
    }
    return jsan;
}
Also used : JsArrayNumber(com.google.gwt.core.client.JsArrayNumber)

Example 3 with JsArrayNumber

use of com.google.gwt.core.client.JsArrayNumber in project libgdx by libgdx.

the class GwtControllers method onGamepadUpdated.

@Override
public void onGamepadUpdated(int index) {
    Gamepad gamepad = Gamepad.getGamepad(index);
    GwtController controller = controllerMap.get(index);
    if (gamepad != null && controller != null) {
        // Determine what changed
        JsArrayNumber axes = gamepad.getAxes();
        JsArrayNumber buttons = gamepad.getButtons();
        synchronized (eventQueue) {
            for (int i = 0, j = axes.length(); i < j; i++) {
                float oldAxis = controller.getAxis(i);
                float newAxis = (float) axes.get(i);
                if (oldAxis != newAxis) {
                    GwtControllerEvent event = eventPool.obtain();
                    event.type = GwtControllerEvent.AXIS;
                    event.controller = controller;
                    event.code = i;
                    event.amount = newAxis;
                    eventQueue.add(event);
                }
            }
            for (int i = 0, j = buttons.length(); i < j; i++) {
                float oldButton = controller.getButtonAmount(i);
                float newButton = (float) buttons.get(i);
                if (oldButton != newButton) {
                    if ((oldButton < 0.5f && newButton < 0.5f) || (oldButton >= 0.5f && newButton >= 0.5f)) {
                        controller.buttons.put(i, newButton);
                        continue;
                    }
                    GwtControllerEvent event = eventPool.obtain();
                    event.type = newButton >= 0.5f ? GwtControllerEvent.BUTTON_DOWN : GwtControllerEvent.BUTTON_UP;
                    event.controller = controller;
                    event.code = i;
                    event.amount = newButton;
                    eventQueue.add(event);
                }
            }
        }
    }
}
Also used : Gamepad(com.badlogic.gdx.controllers.gwt.support.Gamepad) JsArrayNumber(com.google.gwt.core.client.JsArrayNumber)

Example 4 with JsArrayNumber

use of com.google.gwt.core.client.JsArrayNumber in project playn by threerings.

the class ArrayUtils method toJsArray.

public static JsArrayNumber toJsArray(double[] data) {
    JsArrayNumber jsan = (JsArrayNumber) JsArrayNumber.createArray();
    int len = data.length;
    for (int i = len - 1; i >= 0; i--) {
        jsan.set(i, data[i]);
    }
    return jsan;
}
Also used : JsArrayNumber(com.google.gwt.core.client.JsArrayNumber)

Aggregations

JsArrayNumber (com.google.gwt.core.client.JsArrayNumber)4 Gamepad (com.badlogic.gdx.controllers.gwt.support.Gamepad)1 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 Handler (org.rstudio.core.client.command.Handler)1 SelectionCommitHandler (org.rstudio.core.client.events.SelectionCommitHandler)1 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)1 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)1 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)1 ConsoleResetHistoryHandler (org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler)1 FetchCommandsHandler (org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler)1 HistoryEntriesAddedHandler (org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler)1