Search in sources :

Example 6 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class ProjectTemplateWidget method checkBoxInput.

private ProjectTemplateWidgetItem checkBoxInput(final ProjectTemplateWidgetDescription description) {
    final CheckBox widget = new CheckBox(description.getLabel());
    // set default value
    String defaultValue = description.getDefault();
    if (!StringUtil.isNullOrEmpty(defaultValue))
        widget.setValue(isTruthy(defaultValue));
    return new ProjectTemplateWidgetItem(widget, new Collector() {

        @Override
        public void collectInput(JsObject receiver) {
            boolean value = widget.getValue();
            receiver.setBoolean(description.getParameter(), value);
        }
    });
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) CheckBox(com.google.gwt.user.client.ui.CheckBox) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 7 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class JsArrayUtil method deepCopy.

@SuppressWarnings("unchecked")
public static final <T extends JavaScriptObject> JsArray<T> deepCopy(JsArray<T> array) {
    JsObject original = (JsObject) array.cast();
    JsObject clone = original.clone();
    JsArray<T> cloneArray = (JsArray<T>) clone.cast();
    return cloneArray;
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JsArray(com.google.gwt.core.client.JsArray)

Example 8 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class AceCommandManager method getRelevantCommands.

public final JsArray<AceCommand> getRelevantCommands() {
    JsObject allCommands = getCommands();
    JsArray<AceCommand> filtered = JavaScriptObject.createArray().cast();
    JsArrayString keys = allCommands.keys();
    for (String key : JsUtil.asIterable(keys)) {
        AceCommand command = allCommands.getObject(key);
        String name = command.getInternalName();
        if (!EXCLUDED_COMMANDS_MAP.hasKey(name)) {
            filtered.push(command);
        }
    }
    return sorted(filtered);
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 9 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class SetupChunkOptionsPopupPanel method initOptions.

@Override
protected void initOptions(final Command afterInit) {
    String chunkText = getChunkText();
    server_.extractChunkOptions(chunkText, new ServerRequestCallback<JsObject>() {

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

        @Override
        public void onResponseReceived(JsObject object) {
            JsArrayString keys = object.keys();
            for (String key : JsUtil.asIterable(keys)) chunkOptions_.put(key, object.getAsString(key));
            afterInit.execute();
        }
    });
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) ServerError(org.rstudio.studio.client.server.ServerError) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 10 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class DesktopApplicationHeader method initialize.

@Inject
public void initialize(final Commands commands, EventBus events, final Session session, ApplicationServerOperations server, Provider<DesktopHooks> pDesktopHooks, Provider<CodeSearch> pCodeSearch, Provider<UIPrefs> pUIPrefs, ErrorManager errorManager, GlobalDisplay globalDisplay, ApplicationQuit appQuit) {
    session_ = session;
    eventBus_ = events;
    pUIPrefs_ = pUIPrefs;
    globalDisplay_ = globalDisplay;
    ignoredUpdates_ = IgnoredUpdates.create();
    server_ = server;
    appQuit_ = appQuit;
    binder_.bind(commands, this);
    commands.mainMenu(new DesktopMenuCallback());
    pDesktopHooks.get();
    commands.uploadFile().remove();
    commands.exportFiles().remove();
    commands.updateCredentials().remove();
    commands.checkForUpdates().setVisible(true);
    commands.showLogFiles().setVisible(true);
    commands.diagnosticsReport().setVisible(true);
    commands.showFolder().setVisible(true);
    events.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {

        public void onSessionInit(SessionInitEvent sie) {
            final SessionInfo sessionInfo = session.getSessionInfo();
            toolbar_.completeInitialization(sessionInfo);
            new JSObjectStateValue("updates", "ignoredUpdates", ClientState.PERSISTENT, session_.getSessionInfo().getClientState(), false) {

                @Override
                protected void onInit(JsObject value) {
                    if (value != null)
                        ignoredUpdates_ = value.cast();
                }

                @Override
                protected JsObject getValue() {
                    ignoredUpdatesDirty_ = false;
                    return ignoredUpdates_.cast();
                }

                @Override
                protected boolean hasChanged() {
                    return ignoredUpdatesDirty_;
                }
            };
            Scheduler.get().scheduleFinally(new ScheduledCommand() {

                public void execute() {
                    Desktop.getFrame().onWorkbenchInitialized(sessionInfo.getScratchDir());
                    if (sessionInfo.getDisableCheckForUpdates())
                        commands.checkForUpdates().remove();
                    if (!sessionInfo.getDisableCheckForUpdates() && pUIPrefs_.get().checkForUpdates().getValue()) {
                        checkForUpdates(false);
                    }
                }
            });
        }
    });
    events.addHandler(ShowFolderEvent.TYPE, new ShowFolderHandler() {

        public void onShowFolder(ShowFolderEvent event) {
            Desktop.getFrame().showFolder(event.getPath().getPath());
        }
    });
    toolbar_ = new GlobalToolbar(commands, events, pCodeSearch);
    ThemeStyles styles = ThemeResources.INSTANCE.themeStyles();
    toolbar_.addStyleName(styles.desktopGlobalToolbar());
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) SessionInitEvent(org.rstudio.studio.client.workbench.events.SessionInitEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) DesktopMenuCallback(org.rstudio.core.client.command.impl.DesktopMenuCallback) ShowFolderEvent(org.rstudio.studio.client.workbench.views.files.events.ShowFolderEvent) GlobalToolbar(org.rstudio.studio.client.application.ui.GlobalToolbar) ThemeStyles(org.rstudio.core.client.theme.res.ThemeStyles) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) SessionInitHandler(org.rstudio.studio.client.workbench.events.SessionInitHandler) JSObjectStateValue(org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue) ShowFolderHandler(org.rstudio.studio.client.workbench.views.files.events.ShowFolderHandler) Inject(com.google.inject.Inject)

Aggregations

JsObject (org.rstudio.core.client.js.JsObject)19 JsArrayString (com.google.gwt.core.client.JsArrayString)9 JSObjectStateValue (org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue)4 JsArray (com.google.gwt.core.client.JsArray)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 SessionInfo (org.rstudio.studio.client.workbench.model.SessionInfo)3 WindowEx (org.rstudio.core.client.dom.WindowEx)2 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)2 FileChooserTextBox (org.rstudio.core.client.widget.FileChooserTextBox)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 Grid (com.google.gwt.user.client.ui.Grid)1 Label (com.google.gwt.user.client.ui.Label)1 TextBox (com.google.gwt.user.client.ui.TextBox)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 DesktopMenuCallback (org.rstudio.core.client.command.impl.DesktopMenuCallback)1 ThemeStyles (org.rstudio.core.client.theme.res.ThemeStyles)1 SelectWidget (org.rstudio.core.client.widget.SelectWidget)1 EventBus (org.rstudio.studio.client.application.events.EventBus)1