Search in sources :

Example 51 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project rstudio by rstudio.

the class RequestLogVisualization method addEntry.

private void addEntry(int i, final RequestLogEntry entry) {
    int top = totalHeight_ - (i + 1) * BAR_HEIGHT;
    int left = (int) ((entry.getRequestTime() - startTime_) * scaleMillisToPixels_);
    long endTime = entry.getResponseTime() != null ? entry.getResponseTime() : now_;
    int right = Math.max(0, (int) ((now_ - endTime) * scaleMillisToPixels_) - 1);
    boolean active = entry.getResponseType() == ResponseType.None;
    HTML html = new HTML();
    html.getElement().getStyle().setOverflow(Overflow.VISIBLE);
    html.getElement().getStyle().setProperty("whiteSpace", "nowrap");
    html.setText(entry.getRequestMethodName() + (active ? " (active)" : ""));
    if (active)
        html.getElement().getStyle().setFontWeight(FontWeight.BOLD);
    String color;
    switch(entry.getResponseType()) {
        case ResponseType.Error:
            color = "red";
            break;
        case ResponseType.None:
            color = "#f99";
            break;
        case ResponseType.Normal:
            color = "#88f";
            break;
        case ResponseType.Cancelled:
            color = "#E0E0E0";
            break;
        case ResponseType.Unknown:
        default:
            color = "yellow";
            break;
    }
    html.getElement().getStyle().setBackgroundColor(color);
    html.getElement().getStyle().setCursor(Cursor.POINTER);
    html.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            event.stopPropagation();
            detail_.clear();
            RequestLogDetail entryDetail = new RequestLogDetail(entry);
            entryDetail.setSize("100%", "100%");
            detail_.setWidget(entryDetail);
        }
    });
    overviewPanel_.add(html);
    overviewPanel_.setWidgetTopHeight(html, top, Unit.PX, BAR_HEIGHT, Unit.PX);
    overviewPanel_.setWidgetLeftRight(html, left, Unit.PX, right, Unit.PX);
    overviewPanel_.getWidgetContainerElement(html).getStyle().setOverflow(Overflow.VISIBLE);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 52 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project rstudio by rstudio.

the class WebApplicationHeader method initCommandsPanel.

private void initCommandsPanel(final SessionInfo sessionInfo) {
    // add username 
    if (sessionInfo.getShowIdentity()) {
        ToolbarLabel usernameLabel = new ToolbarLabel();
        usernameLabel.getElement().getStyle().setMarginRight(2, Unit.PX);
        if (!BrowseCap.isFirefox())
            usernameLabel.getElement().getStyle().setMarginTop(2, Unit.PX);
        String userIdentity = sessionInfo.getUserIdentity();
        usernameLabel.setTitle(userIdentity);
        userIdentity = userIdentity.split("@")[0];
        usernameLabel.setText(userIdentity);
        headerBarCommandsPanel_.add(usernameLabel);
        ToolbarButton signOutButton = new ToolbarButton(new ImageResource2x(RESOURCES.signOut2x()), new ClickHandler() {

            public void onClick(ClickEvent event) {
                eventBus_.fireEvent(new LogoutRequestedEvent());
            }
        });
        signOutButton.setTitle("Sign out");
        headerBarCommandsPanel_.add(signOutButton);
        headerBarCommandsPanel_.add(signOutSeparator_ = createCommandSeparator());
    }
    overlay_.addCommands(this);
    headerBarCommandsPanel_.add(commands_.quitSession().createToolbarButton());
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) LogoutRequestedEvent(org.rstudio.studio.client.application.events.LogoutRequestedEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ToolbarLabel(org.rstudio.core.client.widget.ToolbarLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 53 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project rstudio by rstudio.

the class CompilePanel method connectToolbar.

public void connectToolbar(Toolbar toolbar) {
    Commands commands = RStudioGinjector.INSTANCE.getCommands();
    ImageResource stopImage = commands.interruptR().getImageResource();
    stopButton_ = new ToolbarButton(stopImage, null);
    stopButton_.setVisible(false);
    toolbar.addRightWidget(stopButton_);
    showOutputButton_ = new LeftRightToggleButton("Output", "Issues", false);
    showOutputButton_.setVisible(false);
    showOutputButton_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showOutputButton_.setVisible(false);
            showErrorsButton_.setVisible(true);
            panel_.setWidget(outputDisplay_.asWidget());
            outputDisplay_.scrollToBottom();
        }
    });
    toolbar.addRightWidget(showOutputButton_);
    showErrorsButton_ = new LeftRightToggleButton("Output", "Issues", true);
    showErrorsButton_.setVisible(false);
    showErrorsButton_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showOutputButton_.setVisible(true);
            showErrorsButton_.setVisible(false);
            panel_.setWidget(errorList_);
        }
    });
    toolbar.addRightWidget(showErrorsButton_);
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ImageResource(com.google.gwt.resources.client.ImageResource) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Commands(org.rstudio.studio.client.workbench.commands.Commands) LeftRightToggleButton(org.rstudio.core.client.widget.LeftRightToggleButton)

Example 54 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project rstudio by rstudio.

the class SavePlotAsPdfDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    ExportPlotResources.Styles styles = ExportPlotResources.INSTANCE.styles();
    Grid grid = new Grid(7, 2);
    grid.setStylePrimaryName(styles.savePdfMainWidget());
    // paper size
    grid.setWidget(0, 0, new Label("PDF Size:"));
    // paper size label
    paperSizeEditor_ = new PaperSizeEditor();
    grid.setWidget(0, 1, paperSizeEditor_);
    // orientation
    grid.setWidget(1, 0, new Label("Orientation:"));
    HorizontalPanel orientationPanel = new HorizontalPanel();
    orientationPanel.setSpacing(kComponentSpacing);
    VerticalPanel orientationGroupPanel = new VerticalPanel();
    final String kOrientationGroup = new String("Orientation");
    portraitRadioButton_ = new RadioButton(kOrientationGroup, "Portrait");
    orientationGroupPanel.add(portraitRadioButton_);
    landscapeRadioButton_ = new RadioButton(kOrientationGroup, "Landscape");
    orientationGroupPanel.add(landscapeRadioButton_);
    orientationPanel.add(orientationGroupPanel);
    grid.setWidget(1, 1, orientationPanel);
    boolean haveCairoPdf = sessionInfo_.isCairoPdfAvailable();
    if (haveCairoPdf)
        grid.setWidget(2, 0, new Label("Options:"));
    HorizontalPanel cairoPdfPanel = new HorizontalPanel();
    String label = "Use cairo_pdf device";
    if (BrowseCap.isMacintoshDesktop())
        label = label + " (requires X11)";
    chkCairoPdf_ = new CheckBox(label);
    chkCairoPdf_.getElement().getStyle().setMarginLeft(kComponentSpacing, Unit.PX);
    cairoPdfPanel.add(chkCairoPdf_);
    chkCairoPdf_.setValue(haveCairoPdf && options_.getCairoPdf());
    if (haveCairoPdf)
        grid.setWidget(2, 1, cairoPdfPanel);
    grid.setWidget(3, 0, new HTML(" "));
    ThemedButton directoryButton = new ThemedButton("Directory...");
    directoryButton.setStylePrimaryName(styles.directoryButton());
    directoryButton.getElement().getStyle().setMarginLeft(-2, Unit.PX);
    grid.setWidget(4, 0, directoryButton);
    directoryButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            fileDialogs_.chooseFolder("Choose Directory", fileSystemContext_, FileSystemItem.createDir(directoryLabel_.getTitle().trim()), new ProgressOperationWithInput<FileSystemItem>() {

                public void execute(FileSystemItem input, ProgressIndicator indicator) {
                    if (input == null)
                        return;
                    indicator.onCompleted();
                    // update default
                    ExportPlotUtils.setDefaultSaveDirectory(input);
                    // set display
                    setDirectory(input);
                }
            });
        }
    });
    directoryLabel_ = new Label();
    setDirectory(defaultDirectory_);
    directoryLabel_.setStylePrimaryName(styles.savePdfDirectoryLabel());
    grid.setWidget(4, 1, directoryLabel_);
    Label fileNameLabel = new Label("File name:");
    fileNameLabel.setStylePrimaryName(styles.savePdfFileNameLabel());
    grid.setWidget(5, 0, fileNameLabel);
    fileNameTextBox_ = new TextBox();
    fileNameTextBox_.setText(defaultPlotName_);
    fileNameTextBox_.setStylePrimaryName(styles.savePdfFileNameTextBox());
    grid.setWidget(5, 1, fileNameTextBox_);
    // view after size
    viewAfterSaveCheckBox_ = new CheckBox("View plot after saving");
    viewAfterSaveCheckBox_.setStylePrimaryName(styles.savePdfViewAfterCheckbox());
    viewAfterSaveCheckBox_.setValue(options_.getViewAfterSave());
    grid.setWidget(6, 1, viewAfterSaveCheckBox_);
    // set default value
    if (options_.getPortrait())
        portraitRadioButton_.setValue(true);
    else
        landscapeRadioButton_.setValue(true);
    // return the widget
    return grid;
}
Also used : Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Label(com.google.gwt.user.client.ui.Label) HTML(com.google.gwt.user.client.ui.HTML) RadioButton(com.google.gwt.user.client.ui.RadioButton) TextBox(com.google.gwt.user.client.ui.TextBox) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) ThemedButton(org.rstudio.core.client.widget.ThemedButton) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ExportPlotResources(org.rstudio.studio.client.workbench.exportplot.ExportPlotResources) CheckBox(com.google.gwt.user.client.ui.CheckBox) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Example 55 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project gwt-test-utils by gwt-test-utils.

the class MyBeautifulApp method onModuleLoad.

public void onModuleLoad() {
    FlowPanel panel = new FlowPanel();
    b1 = new Button("Button1's HTML");
    b1.getElement().setId("button-1");
    panel.add(b1);
    b2 = new Button("Button2's HTML");
    b2.getElement().setId("button-2");
    panel.add(b2);
    l = new Label();
    l.setText("init");
    panel.add(l);
    t = new TextBox();
    panel.add(t);
    historyLabel = new Label();
    panel.add(historyLabel);
    invisibleTB = new TextBox();
    invisibleTB.setVisible(false);
    panel.add(invisibleTB);
    lb = new ListBox();
    lb.addItem("lbText0");
    lb.addItem("lbText1");
    lb.addItem("lbText2");
    panel.add(lb);
    RootPanel.get().add(panel);
    b1.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            l.setText("click on b1");
        }
    });
    b2.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            l.setText("click on b2");
        }
    });
    b3 = new Button("Button3's HTML");
    panel.add(b3);
    b3.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod(l.getText(), new AsyncCallback<String>() {

                public void onFailure(Throwable arg0) {
                    l.setText("error");
                }

                public void onSuccess(String arg0) {
                    l.setText(arg0);
                }
            });
        }
    });
    b4 = new Button("Button4's HTML");
    panel.add(b4);
    b4.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod2(new MyCustomObject("toto"), new AsyncCallback<MyCustomObject>() {

                public void onFailure(Throwable t) {
                    throw new RuntimeException(t);
                }

                public void onSuccess(MyCustomObject object) {
                    l.setText(object.myField + " " + object.myTransientField);
                }
            });
        }
    });
    b5 = new Button("Button5's HTML");
    panel.add(b5);
    b5.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod3(new AsyncCallback<Void>() {

                public void onFailure(Throwable arg0) {
                    l.setText("error");
                }

                public void onSuccess(Void arg0) {
                    l.setText("success");
                }
            });
        }
    });
    t.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            historyLabel.setText("t was filled with value \"" + t.getText() + "\"");
        }
    });
    invisibleTB.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            historyLabel.setText("invisibleTB was filled with value \"" + invisibleTB.getText() + "\"");
        }
    });
    myComposite = new MyComposite("myComposite Label", "MyComposite Button");
    panel.add(myComposite);
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Aggregations

ClickHandler (com.google.gwt.event.dom.client.ClickHandler)447 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)437 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)168 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)143 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)129 ArrayList (java.util.ArrayList)128 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)110 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)79 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)48 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)47 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)41 PerunError (cz.metacentrum.perun.webgui.model.PerunError)38 HashMap (java.util.HashMap)37 Button (com.google.gwt.user.client.ui.Button)35 HTML (com.google.gwt.user.client.ui.HTML)34 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)33 Button (org.gwtbootstrap3.client.ui.Button)33 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)31 Image (com.google.gwt.user.client.ui.Image)30 Map (java.util.Map)27