Example usage for com.google.gwt.user.client.ui CheckBox addValueChangeHandler

List of usage examples for com.google.gwt.user.client.ui CheckBox addValueChangeHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui CheckBox addValueChangeHandler.

Prototype

@Override
    public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler) 

Source Link

Usage

From source file:org.roda.wui.client.ingest.process.PluginParameterPanel.java

private void createBooleanLayout() {
    CheckBox checkBox = new CheckBox(parameter.getName());
    checkBox.setValue("true".equals(parameter.getDefaultValue()));
    value = "true".equals(parameter.getDefaultValue()) ? "true" : "false";
    checkBox.setEnabled(!parameter.isReadonly());
    checkBox.getElement().setTitle("checkbox");

    layout.add(checkBox);//w ww .j a  v a  2  s. c  o m
    addHelp();

    checkBox.addStyleName("form-checkbox");

    checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            value = event.getValue() ? "true" : "false";
        }
    });
}

From source file:org.roda.wui.client.process.CreateDefaultJob.java

public void configurePlugins() {
    List<String> categoriesOnListBox = new ArrayList<>();

    if (plugins != null) {
        PluginUtils.sortByName(plugins);

        for (int p = 0; p < plugins.size(); p++) {
            PluginInfo pluginInfo = plugins.get(p);

            if (pluginInfo != null) {
                List<String> pluginCategories = pluginInfo.getCategories();

                if (pluginCategories != null
                        && !pluginCategories.contains(RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)) {
                    for (String category : pluginCategories) {
                        if (!categoriesOnListBox.contains(category)) {

                            CheckBox box = new CheckBox();
                            box.setText(messages.showPluginCategories(category));
                            box.setName(category);
                            box.addStyleName("form-checkbox-job");

                            box.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> event) {
                                    workflowList.clear();
                                    boolean noChecks = true;

                                    if (plugins != null) {
                                        PluginUtils.sortByName(plugins);
                                        List<String> pluginsAdded = new ArrayList<>();

                                        for (int p = 0; p < plugins.size(); p++) {
                                            PluginInfo pluginInfo = plugins.get(p);
                                            if (pluginInfo != null) {
                                                List<String> categories = pluginInfo.getCategories();

                                                if (categories != null) {
                                                    for (int i = 0; i < workflowCategoryList
                                                            .getWidgetCount(); i++) {
                                                        CheckBox checkbox = (CheckBox) workflowCategoryList
                                                                .getWidget(i);

                                                        if (checkbox.getValue().booleanValue()) {
                                                            noChecks = false;

                                                            if (categories.contains(checkbox.getName())
                                                                    && !categories.contains(
                                                                            RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)
                                                                    && !pluginsAdded
                                                                            .contains(pluginInfo.getId())) {
                                                                Widget pluginItem = addPluginItemWidgetToWorkflowList(
                                                                        pluginInfo);
                                                                if (pluginsAdded.isEmpty()) {
                                                                    CreateDefaultJob.this.selectedPlugin = lookupPlugin(
                                                                            pluginInfo.getId());
                                                                    pluginItem.addStyleName(
                                                                            "plugin-list-item-selected");
                                                                }
                                                                pluginsAdded.add(pluginInfo.getId());
                                                            }
                                                        }
                                                    }

                                                    if (noChecks) {
                                                        if (!pluginInfo.getCategories().contains(
                                                                RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)) {
                                                            Widget pluginItem = addPluginItemWidgetToWorkflowList(
                                                                    pluginInfo);
                                                            if (p == 0) {
                                                                CreateDefaultJob.this.selectedPlugin = lookupPlugin(
                                                                        pluginInfo.getId());
                                                                pluginItem.addStyleName(
                                                                        "plugin-list-item-selected");
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }//  w  w w  .  j a v  a  2  s . c  o  m

                                    updateWorkflowOptions();
                                }
                            });

                            workflowCategoryList.add(box);
                            categoriesOnListBox.add(category);
                        }
                    }

                    if (!pluginCategories.contains(RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)) {
                        Widget pluginItem = addPluginItemWidgetToWorkflowList(pluginInfo);
                        if (p == 0) {
                            CreateDefaultJob.this.selectedPlugin = lookupPlugin(pluginInfo.getId());
                            pluginItem.addStyleName("plugin-list-item-selected");
                        }
                    }
                }

            }
        }

        updateWorkflowOptions();
    }
}

From source file:org.roda.wui.client.process.CreateSelectedJob.java

public void configurePlugins(final String selectedClass) {
    List<String> categoriesOnListBox = new ArrayList<>();

    if (plugins != null) {
        PluginUtils.sortByName(plugins);

        int pluginAdded = 0;
        for (PluginInfo pluginInfo : plugins) {

            if (pluginInfo != null) {
                List<String> pluginCategories = pluginInfo.getCategories();

                if (pluginCategories != null) {
                    for (String category : pluginCategories) {
                        if (!categoriesOnListBox.contains(category)
                                && !category.equals(RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)
                                && ((!isSelectedEmpty() && pluginInfo.hasObjectClass(selectedClass))
                                        || (isSelectedEmpty()
                                                && pluginInfo.hasObjectClass(listSelectedClass)))) {

                            CheckBox box = new CheckBox();
                            box.setText(messages.showPluginCategories(category));
                            box.setName(category);
                            box.addStyleName("form-checkbox-job");

                            box.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> event) {
                                    workflowList.clear();
                                    boolean noChecks = true;

                                    if (plugins != null) {
                                        PluginUtils.sortByName(plugins);
                                        List<String> pluginsAdded = new ArrayList<>();

                                        for (PluginInfo pluginInfo : plugins) {
                                            if (pluginInfo != null) {
                                                List<String> categories = pluginInfo.getCategories();

                                                if (categories != null) {
                                                    for (int i = 0; i < workflowCategoryList
                                                            .getWidgetCount(); i++) {
                                                        CheckBox checkbox = (CheckBox) workflowCategoryList
                                                                .getWidget(i);

                                                        if (checkbox.getValue()) {
                                                            noChecks = false;

                                                            if (categories.contains(checkbox.getName())
                                                                    && !categories.contains(
                                                                            RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)
                                                                    && ((!isSelectedEmpty() && pluginInfo
                                                                            .hasObjectClass(selectedClass))
                                                                            || (isSelectedEmpty() && pluginInfo
                                                                                    .hasObjectClass(
                                                                                            listSelectedClass)))
                                                                    && !pluginsAdded
                                                                            .contains(pluginInfo.getId())) {
                                                                Widget pluginItem = addPluginItemWidgetToWorkflowList(
                                                                        pluginInfo);

                                                                if (pluginsAdded.isEmpty()) {
                                                                    CreateSelectedJob.this.selectedPlugin = lookupPlugin(
                                                                            pluginInfo.getId());
                                                                    pluginItem.addStyleName(
                                                                            "plugin-list-item-selected");
                                                                }

                                                                pluginsAdded.add(pluginInfo.getId());
                                                            }

                                                        }
                                                    }

                                                    if (noChecks) {
                                                        if (!pluginInfo.getCategories().contains(
                                                                RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)
                                                                && ((!isSelectedEmpty() && pluginInfo
                                                                        .hasObjectClass(selectedClass))
                                                                        || (isSelectedEmpty()
                                                                                && pluginInfo.hasObjectClass(
                                                                                        listSelectedClass)))) {
                                                            Widget pluginItem = addPluginItemWidgetToWorkflowList(
                                                                    pluginInfo);
                                                            if (pluginsAdded.isEmpty()) {
                                                                CreateSelectedJob.this.selectedPlugin = lookupPlugin(
                                                                        pluginInfo.getId());
                                                                pluginItem.addStyleName(
                                                                        "plugin-list-item-selected");
                                                            }

                                                            pluginsAdded.add(pluginInfo.getId());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }/*from   ww w  .j  a v a  2s .  c om*/

                                    updateWorkflowOptions();
                                }

                            });

                            workflowCategoryList.add(box);
                            categoriesOnListBox.add(category);
                        }
                    }

                    if (!pluginCategories.contains(RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)
                            && ((!isSelectedEmpty() && pluginInfo.hasObjectClass(selectedClass))
                                    || (isSelectedEmpty() && pluginInfo.hasObjectClass(listSelectedClass)))) {
                        Widget pluginItem = addPluginItemWidgetToWorkflowList(pluginInfo);
                        if (pluginAdded == 0) {
                            CreateSelectedJob.this.selectedPlugin = lookupPlugin(pluginInfo.getId());
                            pluginItem.addStyleName("plugin-list-item-selected");
                            pluginAdded++;
                        }
                    }
                }

            }
        }

        updateWorkflowOptions();
    }
}

From source file:org.roda.wui.common.client.tools.FacetUtils.java

private static <T extends IsIndexed> void updateFacetPanels(final AsyncTableCell<T, ?> list,
        final Map<String, FlowPanel> facetPanels, final List<FacetFieldResult> facetResults,
        final boolean hideDisabled) {

    for (FacetFieldResult facetResult : facetResults) {
        final String facetField = facetResult.getField();
        FlowPanel facetPanel = facetPanels.get(facetResult.getField());
        if (facetPanel != null) {
            facetPanel.clear();/*from ww w. j a v  a  2 s .  c om*/
            if (facetResult.getTotalCount() == 0) {
                facetPanel.getParent().addStyleName("facet-empty");
            } else {
                facetPanel.getParent().removeStyleName("facet-empty");
            }

            for (FacetValue facetValue : facetResult.getValues()) {
                final String value = facetValue.getValue();
                final String label = facetValue.getLabel();
                long count = facetValue.getCount();
                boolean selected = facetResult.getSelectedValues().contains(value);
                StringBuilder checkboxLabel = new StringBuilder();
                checkboxLabel.append(label);
                if (count > 0 || facetResult.getSelectedValues().isEmpty() || selected) {
                    checkboxLabel.append(" (").append(count).append(")");
                }

                CheckBox facetValuePanel = new CheckBox(checkboxLabel.toString());
                facetValuePanel.setTitle(checkboxLabel.toString());
                facetValuePanel.addStyleName("sidebar-facet-label");
                facetValuePanel.addStyleName("fade-out");

                boolean enabled = count > 0 || !facetResult.getSelectedValues().isEmpty();
                facetValuePanel.setEnabled(enabled);
                if (hideDisabled) {
                    facetValuePanel.setVisible(enabled);
                }

                facetPanel.add(facetValuePanel);
                facetValuePanel.setValue(selected);

                facetValuePanel.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                    @Override
                    public void onValueChange(ValueChangeEvent<Boolean> event) {
                        Facets facets = list.getFacets();
                        FacetParameter selectedFacetParameter = facets.getParameters().get(facetField);

                        if (selectedFacetParameter != null) {
                            if (event.getValue()) {
                                selectedFacetParameter.getValues().add(value);
                            } else {
                                selectedFacetParameter.getValues().remove(value);
                            }
                        } else {
                            LOGGER.warn("Haven't found the facet parameter: " + facetField);
                        }
                        list.setFacets(facets);

                    }
                });
            }

        } else {
            LOGGER.warn("Got a facet but haven't got a panel for it");
        }
    }
}

From source file:org.rstudio.studio.client.workbench.prefs.views.EditingPreferencesPane.java

License:Open Source License

@Inject
public EditingPreferencesPane(UIPrefs prefs, PreferencesDialogResources res) {
    prefs_ = prefs;/*w w  w  .  j a  va 2 s.c  om*/
    PreferencesDialogBaseResources baseRes = PreferencesDialogBaseResources.INSTANCE;

    VerticalPanel editingPanel = new VerticalPanel();
    editingPanel.add(headerLabel("General"));
    editingPanel.add(tight(spacesForTab_ = checkboxPref("Insert spaces for tab", prefs.useSpacesForTab())));
    editingPanel.add(indent(tabWidth_ = numericPref("Tab width", prefs.numSpacesForTab())));
    editingPanel.add(checkboxPref("Insert matching parens/quotes", prefs_.insertMatching()));
    editingPanel.add(checkboxPref("Auto-indent code after paste", prefs_.reindentOnPaste()));
    editingPanel.add(
            checkboxPref("Vertically align arguments in auto-indent", prefs_.verticallyAlignArgumentIndent()));
    editingPanel.add(checkboxPref("Soft-wrap R source files", prefs_.softWrapRFiles()));
    editingPanel.add(checkboxPref("Ensure that source files end with newline", prefs_.autoAppendNewline()));
    editingPanel.add(
            checkboxPref("Strip trailing horizontal whitespace when saving", prefs_.stripTrailingWhitespace()));
    editingPanel.add(checkboxPref("Focus console after executing from source", prefs_.focusConsoleAfterExec()));
    editingPanel.add(checkboxPref("Continue comment when inserting new line",
            prefs_.continueCommentsOnNewline(),
            "When enabled, pressing enter will continue comments on new lines. Press Shift + Enter to exit a comment."));
    editingPanel.add(checkboxPref("Enable vim editing mode", prefs_.useVimMode()));

    Label snippetsLabel = headerLabel("Snippets");
    snippetsLabel.getElement().getStyle().setMarginTop(8, Unit.PX);
    editingPanel.add(snippetsLabel);

    HorizontalPanel panel = new HorizontalPanel();
    CheckBox enableSnippets = checkboxPref("Enable code snippets", prefs_.enableSnippets());
    panel.add(enableSnippets);

    SmallButton editSnippets = new SmallButton("Edit Snippets...");
    editSnippets.getElement().getStyle().setMarginTop(1, Unit.PX);
    editSnippets.getElement().getStyle().setMarginLeft(5, Unit.PX);
    editSnippets.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            new EditSnippetsDialog().showModal();
        }
    });
    panel.add(editSnippets);

    HelpButton snippetHelp = new HelpButton("code_snippets");
    snippetHelp.getElement().getStyle().setMarginTop(2, Unit.PX);
    snippetHelp.getElement().getStyle().setMarginLeft(6, Unit.PX);
    panel.add(snippetHelp);

    editingPanel.add(panel);

    VerticalPanel displayPanel = new VerticalPanel();
    displayPanel.add(checkboxPref("Highlight selected word", prefs.highlightSelectedWord()));
    displayPanel.add(checkboxPref("Highlight selected line", prefs.highlightSelectedLine()));
    displayPanel.add(checkboxPref("Show line numbers", prefs.showLineNumbers()));
    displayPanel.add(tight(showMargin_ = checkboxPref("Show margin", prefs.showMargin())));
    displayPanel.add(indent(marginCol_ = numericPref("Margin column", prefs.printMarginColumn())));
    displayPanel.add(checkboxPref("Show whitespace characters", prefs_.showInvisibles()));
    displayPanel.add(checkboxPref("Show indent guides", prefs_.showIndentGuides()));
    displayPanel.add(checkboxPref("Blinking cursor", prefs_.blinkingCursor()));
    displayPanel.add(checkboxPref("Show syntax highlighting in console input", prefs_.syntaxColorConsole()));

    VerticalPanel completionPanel = new VerticalPanel();

    completionPanel.add(headerLabel("R and C/C++"));

    showCompletions_ = new SelectWidget("Show code completions:",
            new String[] { "Automatically", "When Triggered ($, ::)", "Manually (Tab)" },
            new String[] { UIPrefsAccessor.COMPLETION_ALWAYS, UIPrefsAccessor.COMPLETION_WHEN_TRIGGERED,
                    UIPrefsAccessor.COMPLETION_MANUAL },
            false, true, false);

    spaced(showCompletions_);
    completionPanel.add(showCompletions_);

    final CheckBox alwaysCompleteInConsole = checkboxPref("Allow automatic completions in console",
            prefs.alwaysCompleteInConsole());
    completionPanel.add(alwaysCompleteInConsole);

    showCompletions_.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            alwaysCompleteInConsole
                    .setVisible(showCompletions_.getValue().equals(UIPrefsAccessor.COMPLETION_ALWAYS));

        }
    });

    final CheckBox insertParensAfterFunctionCompletionsCheckbox = checkboxPref(
            "Insert parentheses after function completions", prefs.insertParensAfterFunctionCompletion());

    final CheckBox showSignatureTooltipsCheckbox = checkboxPref("Show help tooltip after function completions",
            prefs.showSignatureTooltips());

    addEnabledDependency(insertParensAfterFunctionCompletionsCheckbox, showSignatureTooltipsCheckbox);

    completionPanel.add(insertParensAfterFunctionCompletionsCheckbox);
    completionPanel.add(showSignatureTooltipsCheckbox);

    completionPanel.add(checkboxPref("Insert spaces around equals for argument completions",
            prefs.insertSpacesAroundEquals()));
    completionPanel
            .add(checkboxPref("Use tab for multiline autocompletions", prefs.allowTabMultilineCompletion()));

    Label otherLabel = headerLabel("Other Languages");
    otherLabel.getElement().getStyle().setMarginTop(8, Unit.PX);
    completionPanel.add(otherLabel);

    showCompletionsOther_ = new SelectWidget("Show code completions:",
            new String[] { "Automatically", "Manually (Ctrl+Space) " },
            new String[] { UIPrefsAccessor.COMPLETION_ALWAYS, UIPrefsAccessor.COMPLETION_MANUAL }, false, true,
            false);
    completionPanel.add(showCompletionsOther_);

    Label otherTip = new Label("Keyword and text-based completions are supported for several other "
            + "languages including JavaScript, HTML, CSS, Python, and SQL.");
    otherTip.addStyleName(baseRes.styles().infoLabel());
    completionPanel.add(nudgeRightPlus(otherTip));

    Label delayLabel = headerLabel("Completion Delay");
    delayLabel.getElement().getStyle().setMarginTop(14, Unit.PX);
    completionPanel.add(delayLabel);

    completionPanel
            .add(nudgeRightPlus(alwaysCompleteChars_ = numericPref("Show completions after characters entered:",
                    prefs.alwaysCompleteCharacters())));
    completionPanel.add(
            nudgeRightPlus(alwaysCompleteDelayMs_ = numericPref("Show completions after keyboard idle (ms):",
                    prefs.alwaysCompleteDelayMs())));

    VerticalPanel diagnosticsPanel = new VerticalPanel();
    Label rLabel = headerLabel("R Diagnostics");
    diagnosticsPanel.add(spacedBefore(rLabel));
    final CheckBox chkShowRDiagnostics = checkboxPref("Show diagnostics for R", prefs.showDiagnosticsR());
    diagnosticsPanel.add(chkShowRDiagnostics);

    final VerticalPanel rOptionsPanel = new VerticalPanel();
    rOptionsPanel.add(
            checkboxPref("Enable diagnostics within R function calls", prefs.diagnosticsInRFunctionCalls()));
    rOptionsPanel.add(spaced(
            checkboxPref("Check arguments to R function calls", prefs.checkArgumentsToRFunctionCalls())));
    rOptionsPanel.add(spaced(checkboxPref("Warn if variable used has no definition in scope",
            prefs.warnIfNoSuchVariableInScope())));
    rOptionsPanel.add(spaced(
            checkboxPref("Warn if variable is defined but not used", prefs.warnIfVariableDefinedButNotUsed())));
    rOptionsPanel.add(spaced(
            checkboxPref("Provide R style diagnostics (e.g. whitespace)", prefs.enableStyleDiagnostics())));
    rOptionsPanel.setVisible(prefs.showDiagnosticsR().getValue());
    chkShowRDiagnostics.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            rOptionsPanel.setVisible(event.getValue());
        }
    });

    diagnosticsPanel.add(rOptionsPanel);

    Label diagOtherLabel = headerLabel("Other Languages");
    diagnosticsPanel.add(spacedBefore(diagOtherLabel));
    diagnosticsPanel.add(checkboxPref("Show diagnostics for C/C++", prefs.showDiagnosticsCpp()));
    diagnosticsPanel
            .add(checkboxPref("Show diagnostics for JavaScript, HTML, and CSS", prefs.showDiagnosticsOther()));

    Label diagShowLabel = headerLabel("Show Diagnostics");
    diagnosticsPanel.add(spacedBefore(diagShowLabel));
    diagnosticsPanel
            .add(checkboxPref("Show diagnostics whenever source files are saved", prefs.diagnosticsOnSave()));
    diagnosticsPanel.add(tight(checkboxPref("Show diagnostics after keyboard is idle for a period of time",
            prefs.enableBackgroundDiagnostics())));
    diagnosticsPanel.add(indent(backgroundDiagnosticsDelayMs_ = numericPref("Keyboard idle time (ms):",
            prefs.backgroundDiagnosticsDelayMs())));

    DialogTabLayoutPanel tabPanel = new DialogTabLayoutPanel();
    tabPanel.setSize("435px", "498px");
    tabPanel.add(editingPanel, "Editing");
    tabPanel.add(displayPanel, "Display");
    tabPanel.add(completionPanel, "Completion");
    tabPanel.add(diagnosticsPanel, "Diagnostics");
    tabPanel.selectTab(0);
    add(tabPanel);
}

From source file:org.rstudio.studio.client.workbench.prefs.views.EditingPreferencesPane.java

License:Open Source License

private void addEnabledDependency(final CheckBox speaker, final CheckBox listener) {
    if (speaker.getValue() == false)
        disable(listener);//w w w . j ava2 s .  c  o  m

    speaker.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue() == false)
                disable(listener);
            else
                enable(listener);
        }
    });
}

From source file:org.rstudio.studio.client.workbench.prefs.views.PackagesPreferencesPane.java

License:Open Source License

@Inject
public PackagesPreferencesPane(PreferencesDialogResources res, GlobalDisplay globalDisplay, UIPrefs uiPrefs,
        Session session, final DefaultCRANMirror defaultCRANMirror) {
    res_ = res;/* ww  w .j a  v a  2  s . c  om*/
    globalDisplay_ = globalDisplay;

    add(headerLabel("Package management"));

    cranMirrorTextBox_ = new TextBoxWithButton("CRAN mirror:", "Change...", new ClickHandler() {
        public void onClick(ClickEvent event) {
            defaultCRANMirror.choose(new OperationWithInput<CRANMirror>() {
                @Override
                public void execute(CRANMirror cranMirror) {
                    cranMirror_ = cranMirror;
                    cranMirrorTextBox_.setText(cranMirror_.getDisplay());
                }
            });

        }
    });
    nudgeRight(cranMirrorTextBox_);
    textBoxWithChooser(cranMirrorTextBox_);
    cranMirrorTextBox_.setText("");
    if (session.getSessionInfo().getAllowCRANReposEdit()) {
        lessSpaced(cranMirrorTextBox_);
        add(cranMirrorTextBox_);
    }

    CheckBox chkEnablePackages = checkboxPref("Enable packages pane", uiPrefs.packagesPaneEnabled());
    chkEnablePackages.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            reloadRequired_ = true;
        }
    });
    if (!session.getSessionInfo().getDisablePackages())
        add(chkEnablePackages);

    useInternet2_ = new CheckBox("Use Internet Explorer library/proxy for HTTP", true);
    if (BrowseCap.isWindowsDesktop()) {
        lessSpaced(chkEnablePackages);
        spaced(useInternet2_);
        add(useInternet2_);
    } else {
        spaced(chkEnablePackages);
        chkEnablePackages.getElement().getStyle().setMarginBottom(12, Unit.PX);
    }

    add(headerLabel("Package development"));

    useDevtools_ = new CheckBox("Use devtools package functions if available");
    lessSpaced(useDevtools_);
    add(useDevtools_);

    add(checkboxPref("Save all files prior to building packages", uiPrefs.saveAllBeforeBuild()));
    add(checkboxPref("Automatically navigate editor to build errors", uiPrefs.navigateToBuildError()));

    hideObjectFiles_ = new CheckBox("Hide object files in package src directory");
    lessSpaced(hideObjectFiles_);
    add(hideObjectFiles_);

    cleanupAfterCheckSuccess_ = new CheckBox("Cleanup output after successful R CMD check");
    lessSpaced(cleanupAfterCheckSuccess_);
    add(cleanupAfterCheckSuccess_);

    viewDirAfterCheckFailure_ = new CheckBox("View Rcheck directory after failed R CMD check");
    lessSpaced(viewDirAfterCheckFailure_);
    add(viewDirAfterCheckFailure_);

    add(checkboxPref("Use Rcpp template when creating C++ files", uiPrefs.useRcppTemplate()));

    HelpLink packagesHelpLink = new PackagesHelpLink();
    packagesHelpLink.getElement().getStyle().setMarginTop(12, Unit.PX);
    nudgeRight(packagesHelpLink);
    add(packagesHelpLink);

    cranMirrorTextBox_.setEnabled(false);
    useInternet2_.setEnabled(false);
    cleanupAfterCheckSuccess_.setEnabled(false);
    viewDirAfterCheckFailure_.setEnabled(false);
    hideObjectFiles_.setEnabled(false);
    useDevtools_.setEnabled(false);
}

From source file:org.rstudio.studio.client.workbench.prefs.views.PublishingPreferencesPane.java

License:Open Source License

@Inject
public PublishingPreferencesPane(GlobalDisplay globalDisplay, RSConnectServerOperations server,
        RSAccountConnector connector, UIPrefs prefs, DependencyManager deps) {
    reloadRequired_ = false;/*from   w  ww .j ava  2  s.  c o m*/
    display_ = globalDisplay;
    uiPrefs_ = prefs;
    server_ = server;
    connector_ = connector;
    deps_ = deps;

    VerticalPanel accountPanel = new VerticalPanel();
    Label accountLabel = headerLabel("Publishing Accounts");
    HorizontalPanel hpanel = new HorizontalPanel();

    accountPanel.add(accountLabel);

    accountList_ = new RSConnectAccountList(server, globalDisplay, true);
    accountList_.setHeight("200px");
    accountList_.setWidth("300px");
    accountList_.getElement().getStyle().setMarginBottom(15, Unit.PX);
    accountList_.getElement().getStyle().setMarginLeft(3, Unit.PX);
    hpanel.add(accountList_);

    accountList_.setOnRefreshCompleted(new Operation() {
        @Override
        public void execute() {
            setDisconnectButtonEnabledState();
        }
    });

    VerticalPanel vpanel = new VerticalPanel();
    hpanel.add(vpanel);

    connectButton_ = new ThemedButton("Connect...");
    connectButton_.getElement().getStyle().setMarginBottom(5, Unit.PX);
    connectButton_.setWidth("100%");
    connectButton_.setWrapperWidth("100%");
    connectButton_.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            onConnect();
        }
    });
    vpanel.add(connectButton_);
    disconnectButton_ = new ThemedButton("Disconnect");
    disconnectButton_.setWidth("100%");
    disconnectButton_.setWrapperWidth("100%");
    disconnectButton_.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            onDisconnect();
        }
    });
    vpanel.add(disconnectButton_);
    setDisconnectButtonEnabledState();

    accountPanel.add(hpanel);
    add(accountPanel);

    add(headerLabel("Settings"));
    CheckBox chkEnablePublishing = checkboxPref("Enable publishing apps and documents",
            uiPrefs_.showPublishUi());
    chkEnablePublishing.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            reloadRequired_ = true;
        }
    });
    add(chkEnablePublishing);
}

From source file:org.rstudio.studio.client.workbench.views.environment.view.CallFramePanel.java

License:Open Source License

public CallFramePanel(EnvironmentObjectsObserver observer, CallFramePanelHost panelHost) {
    final ThemeStyles globalStyles = ThemeResources.INSTANCE.themeStyles();
    panelHost_ = panelHost;//from   ww  w.j  av a  2s.  co  m

    // import the minimize button from the global theme resources
    HTML minimize = new HTML();
    minimize.setStylePrimaryName(globalStyles.minimize());
    minimize.addStyleName(ThemeStyles.INSTANCE.handCursor());
    minimize.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (isMinimized_) {
                callFramePanelHeader.removeStyleName(globalStyles.minimizedWindow());
                panelHost_.restoreCallFramePanel();
                isMinimized_ = false;
            } else {
                callFramePanelHeader.addStyleName(globalStyles.minimizedWindow());
                panelHost_.minimizeCallFramePanel();
                isMinimized_ = true;
            }
        }
    });

    initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this));

    Label tracebackTitle = new Label("Traceback");
    tracebackTitle.addStyleName(style.tracebackHeader());

    callFramePanelHeader.addStyleName(globalStyles.windowframe());
    callFramePanelHeader.add(tracebackTitle);
    CheckBox showInternals = new CheckBox("Show internals");
    showInternals.setValue(panelHost_.getShowInternalFunctions());
    showInternals.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            panelHost_.setShowInternalFunctions(event.getValue());
            // Ignore the function on the top of the stack; we always
            // want to show it since it's the execution point
            for (int i = 1; i < callFrameItems_.size(); i++) {
                CallFrameItem item = callFrameItems_.get(i);
                if (!item.isNavigable() && !item.isHidden()) {
                    item.setVisible(event.getValue());
                }
            }
        }
    });
    showInternals.setStylePrimaryName(style.toggleHide());

    callFramePanelHeader.add(showInternals);
    callFramePanelHeader.setWidgetRightWidth(showInternals, 28, Style.Unit.PX, 30, Style.Unit.PCT);
    callFramePanelHeader.add(minimize);
    callFramePanelHeader.setWidgetRightWidth(minimize, 14, Style.Unit.PX, 14, Style.Unit.PX);

    observer_ = observer;
    callFrameItems_ = new ArrayList<CallFrameItem>();
}

From source file:org.rstudio.studio.client.workbench.views.files.ui.FilePathToolbar.java

License:Open Source License

public FilePathToolbar(Files.Display.NavigationObserver navigationObserver) {
    LayoutPanel layout = new LayoutPanel();
    layout.setSize("100%", "21px");
    initWidget(layout);//w w w .j a  va  2 s  .  c  om
    setStyleName(ThemeStyles.INSTANCE.secondaryToolbar());

    navigationObserver_ = navigationObserver;

    // select all check box
    CheckBox selectAllCheckBox = new CheckBox();
    selectAllCheckBox.addStyleDependentName("FilesSelectAll");
    selectAllCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            navigationObserver_.onSelectAllValueChanged(event.getValue().booleanValue());
        }
    });

    layout.add(selectAllCheckBox);
    layout.setWidgetTopBottom(selectAllCheckBox, 0, Unit.PX, 0, Unit.PX);
    layout.setWidgetLeftWidth(selectAllCheckBox, 0, Unit.PX, 20, Unit.PX);

    // breadcrumb widget
    fileSystemContext_ = new FileSystemContextImpl();
    fileSystemContext_.setCallbacks(new Callbacks() {
        public void onNavigated() {
            navigationObserver_.onFileNavigation(fileSystemContext_.pwdItem());
        }

        public void onError(String errorMessage) {
            assert false : "Not implemented";
        }

        public void onDirectoryCreated(FileSystemItem directory) {
            assert false : "Not implemented";
        }
    });
    pathBreadcrumbWidget_ = new PathBreadcrumbWidget(fileSystemContext_);
    pathBreadcrumbWidget_.addStyleDependentName("filepane");
    pathBreadcrumbWidget_.addSelectionCommitHandler(new SelectionCommitHandler<FileSystemItem>() {
        public void onSelectionCommit(SelectionCommitEvent<FileSystemItem> e) {
            fileSystemContext_.cd(e.getSelectedItem().getPath());
        }
    });

    layout.add(pathBreadcrumbWidget_);
    layout.setWidgetTopBottom(pathBreadcrumbWidget_, 0, Unit.PX, 0, Unit.PX);
    layout.setWidgetLeftRight(pathBreadcrumbWidget_, 21, Unit.PX, 0, Unit.PX);
}