Example usage for com.google.gwt.user.client.ui Widget addStyleName

List of usage examples for com.google.gwt.user.client.ui Widget addStyleName

Introduction

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

Prototype

public void addStyleName(String style) 

Source Link

Document

Adds a secondary or dependent style name to this object.

Usage

From source file:org.rstudio.core.client.prefs.PreferencesDialogPaneBase.java

License:Open Source License

protected Widget spacedBefore(Widget widget) {
    widget.addStyleName(res_.styles().spacedBefore());
    return widget;
}

From source file:org.rstudio.core.client.prefs.PreferencesDialogPaneBase.java

License:Open Source License

protected Widget spaced(Widget widget) {
    widget.addStyleName(res_.styles().spaced());
    return widget;
}

From source file:org.rstudio.core.client.prefs.PreferencesDialogPaneBase.java

License:Open Source License

protected Widget extraSpaced(Widget widget) {
    widget.addStyleName(res_.styles().extraSpaced());
    return widget;
}

From source file:org.rstudio.core.client.prefs.PreferencesDialogPaneBase.java

License:Open Source License

protected Widget nudgeRight(Widget widget) {
    widget.addStyleName(res_.styles().nudgeRight());
    return widget;
}

From source file:org.rstudio.core.client.prefs.PreferencesDialogPaneBase.java

License:Open Source License

protected Widget nudgeRightPlus(Widget widget) {
    widget.addStyleName(res_.styles().nudgeRightPlus());
    return widget;
}

From source file:org.rstudio.core.client.prefs.PreferencesDialogPaneBase.java

License:Open Source License

protected Widget textBoxWithChooser(Widget widget) {
    widget.addStyleName(res_.styles().textBoxWithChooser());
    return widget;
}

From source file:org.rstudio.studio.client.common.shell.ShellWidget.java

License:Open Source License

public ShellWidget(AceEditor editor, EventBus events) {
    styles_ = ConsoleResources.INSTANCE.consoleStyles();
    events_ = events;/*from www .  j av  a  2s  . c om*/

    SelectInputClickHandler secondaryInputHandler = new SelectInputClickHandler();

    output_ = new PreWidget();
    output_.setStylePrimaryName(styles_.output());
    output_.addClickHandler(secondaryInputHandler);
    ElementIds.assignElementId(output_.getElement(), ElementIds.CONSOLE_OUTPUT);
    output_.addPasteHandler(secondaryInputHandler);

    pendingInput_ = new PreWidget();
    pendingInput_.setStyleName(styles_.output());
    pendingInput_.addClickHandler(secondaryInputHandler);

    prompt_ = new HTML();
    prompt_.setStylePrimaryName(styles_.prompt());
    prompt_.addStyleName(KEYWORD_CLASS_NAME);

    input_ = editor;
    input_.setShowLineNumbers(false);
    input_.setShowPrintMargin(false);
    if (!Desktop.isDesktop())
        input_.setNewLineMode(NewLineMode.Unix);
    input_.setUseWrapMode(true);
    input_.setPadding(0);
    input_.autoHeight();
    final Widget inputWidget = input_.asWidget();
    ElementIds.assignElementId(inputWidget.getElement(), ElementIds.CONSOLE_INPUT);
    input_.addClickHandler(secondaryInputHandler);
    inputWidget.addStyleName(styles_.input());
    input_.addCursorChangedHandler(new CursorChangedHandler() {
        public void onCursorChanged(CursorChangedEvent event) {
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override
                public void execute() {
                    input_.scrollToCursor(scrollPanel_, 8, 60);
                }
            });
        }
    });
    input_.addCapturingKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            // If the user hits Page-Up from inside the console input, we need
            // to simulate pageup because focus is not contained in the scroll
            // panel (it's in the hidden textarea that Ace uses under the
            // covers).

            int keyCode = event.getNativeKeyCode();
            switch (keyCode) {
            case KeyCodes.KEY_PAGEUP:
                event.stopPropagation();
                event.preventDefault();

                // Can't scroll any further up. Return before we change focus.
                if (scrollPanel_.getVerticalScrollPosition() == 0)
                    return;

                scrollPanel_.focus();
                int newScrollTop = scrollPanel_.getVerticalScrollPosition() - scrollPanel_.getOffsetHeight()
                        + 40;
                scrollPanel_.setVerticalScrollPosition(Math.max(0, newScrollTop));
                break;
            }
        }
    });

    inputLine_ = new DockPanel();
    inputLine_.setHorizontalAlignment(DockPanel.ALIGN_LEFT);
    inputLine_.setVerticalAlignment(DockPanel.ALIGN_TOP);
    inputLine_.add(prompt_, DockPanel.WEST);
    inputLine_.setCellWidth(prompt_, "1");
    inputLine_.add(input_.asWidget(), DockPanel.CENTER);
    inputLine_.setCellWidth(input_.asWidget(), "100%");
    inputLine_.setWidth("100%");

    verticalPanel_ = new VerticalPanel();
    verticalPanel_.setStylePrimaryName(styles_.console());
    verticalPanel_.addStyleName("ace_text-layer");
    verticalPanel_.addStyleName("ace_line");
    FontSizer.applyNormalFontSize(verticalPanel_);
    verticalPanel_.add(output_);
    verticalPanel_.add(pendingInput_);
    verticalPanel_.add(inputLine_);
    verticalPanel_.setWidth("100%");

    scrollPanel_ = new ClickableScrollPanel();
    scrollPanel_.setWidget(verticalPanel_);
    scrollPanel_.addStyleName("ace_editor");
    scrollPanel_.addStyleName("ace_scroller");
    scrollPanel_.addClickHandler(secondaryInputHandler);
    scrollPanel_.addKeyDownHandler(secondaryInputHandler);

    secondaryInputHandler.setInput(editor);

    scrollToBottomCommand_ = new TimeBufferedCommand(5) {
        @Override
        protected void performAction(boolean shouldSchedulePassive) {
            if (!DomUtils.selectionExists())
                scrollPanel_.scrollToBottom();
        }
    };

    initWidget(scrollPanel_);

    addCopyHook(getElement());
}

From source file:org.rstudio.studio.client.common.StyleUtils.java

License:Open Source License

public static void forceMacScrollbars(Widget widget) {
    if (!Desktop.isDesktop() && BrowseCap.isMacintosh() && !BrowseCap.isFirefox()) {
        widget.addStyleName(ThemeStyles.INSTANCE.forceMacScrollbars());
    }// ww w  . j  av  a 2  s  . co m
}

From source file:org.rstudio.studio.client.projects.ui.newproject.NewProjectWizardPage.java

License:Open Source License

protected void addWidget(Widget widget) {
    widget.addStyleName(NewProjectResources.INSTANCE.styles().wizardWidget());
    flowPanel_.add(widget);
}

From source file:org.rstudio.studio.client.workbench.views.console.shell.ShellPane.java

License:Open Source License

@Inject
public ShellPane(final AceEditor editor, UIPrefs uiPrefs, EventBus events) {
    super(editor, events);

    editor.setDisableOverwrite(true);/*from ww w  .j av  a2s. c  o m*/

    editor.setFileType(FileTypeRegistry.R, true);
    // Setting file type to R changes the wrap mode to false. We want it to
    // be true so that the console input can wrap.
    editor.setUseWrapMode(true);

    uiPrefs.syntaxColorConsole().bind(new CommandWithArg<Boolean>() {
        public void execute(Boolean arg) {
            Widget inputWidget = editor.getWidget();
            if (arg)
                inputWidget.removeStyleName("nocolor");
            else
                inputWidget.addStyleName("nocolor");
        }
    });

    uiPrefs.blinkingCursor().bind(new CommandWithArg<Boolean>() {
        public void execute(Boolean arg) {
            editor.setBlinkingCursor(arg);
        }
    });
}