use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.
the class ConnectionsPane method installConnectionExplorerToolbar.
private void installConnectionExplorerToolbar(final Connection connection) {
toolbar_.removeAllWidgets();
toolbar_.addLeftWidget(backToConnectionsButton_);
toolbar_.addLeftSeparator();
toolbar_.addLeftWidget(connectMenuButton_);
toolbar_.addLeftSeparator();
if (isConnected(connection.getId()) && connection.getActions() != null) {
// if we have any actions, create a toolbar button for each one
for (int i = 0; i < connection.getActions().length(); i++) {
final ConnectionAction action = connection.getActions().get(i);
// use the supplied base64 icon data if it was provided
Image icon = StringUtil.isNullOrEmpty(action.getIconData()) ? null : new Image(action.getIconData());
// force to 20x18
if (icon != null) {
icon.setWidth("20px");
icon.setHeight("18px");
}
ToolbarButton button = new ToolbarButton(action.getName(), // left image
icon, // right image
null, // invoke the action when the button is clicked
new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
fireEvent(new ExecuteConnectionActionEvent(connection.getId(), action.getName()));
}
});
// none was supplied
if (StringUtil.isNullOrEmpty(action.getIconData()))
button.getElement().getStyle().setMarginTop(-5, Unit.PX);
toolbar_.addLeftWidget(button);
toolbar_.addLeftSeparator();
}
}
toolbar_.addLeftWidget(commands_.disconnectConnection().createToolbarButton());
toolbar_.addRightWidget(commands_.removeConnection().createToolbarButton());
toolbar_.addRightWidget(commands_.refreshConnection().createToolbarButton());
connectionName_.setText(connection.getDisplayName());
setSecondaryToolbarVisible(true);
}
use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.
the class WorkbenchTabPanel method add.
private void add(final WorkbenchTab tab) {
if (tab.isSuppressed())
return;
tabs_.add(tab);
final Widget widget = tab.asWidget();
tabPanel_.add(widget, tab.getTitle(), false, !tab.closeable() ? null : new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
tab.confirmClose(new Command() {
@Override
public void execute() {
tab.ensureHidden();
}
});
}
}, tab instanceof ProvidesBusy ? (ProvidesBusy) tab : null);
tab.addEnsureVisibleHandler(new EnsureVisibleHandler() {
public void onEnsureVisible(EnsureVisibleEvent event) {
// First ensure that we ourselves are visible
fireEvent(new EnsureVisibleEvent(event.getActivate()));
if (event.getActivate())
tabPanel_.selectTab(widget);
}
});
tab.addEnsureHeightHandler(new EnsureHeightHandler() {
@Override
public void onEnsureHeight(EnsureHeightEvent event) {
fireEvent(event);
}
});
}
use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.
the class RPubsUploadDialog method createMainWidget.
@Override
protected Widget createMainWidget() {
Styles styles = RESOURCES.styles();
SimplePanel mainPanel = new SimplePanel();
mainPanel.addStyleName(styles.mainWidget());
VerticalPanel verticalPanel = new VerticalPanel();
HorizontalPanel headerPanel = new HorizontalPanel();
headerPanel.addStyleName(styles.headerPanel());
headerPanel.add(new Image(new ImageResource2x(RESOURCES.publishLarge2x())));
Label headerLabel = new Label("Publish to RPubs");
headerLabel.addStyleName(styles.headerLabel());
headerPanel.add(headerLabel);
headerPanel.setCellVerticalAlignment(headerLabel, HasVerticalAlignment.ALIGN_MIDDLE);
verticalPanel.add(headerPanel);
String msg;
if (!isPublished_ && uploadId_.isEmpty()) {
msg = "RPubs is a free service from RStudio for sharing " + "documents on the web. Click Publish to get " + "started.";
} else {
msg = "This document has already been published on RPubs. You can " + "choose to either update the existing RPubs document, or " + "create a new one.";
}
Label descLabel = new Label(msg);
descLabel.addStyleName(styles.descLabel());
verticalPanel.add(descLabel);
// if we have a generator then show title and comment UI
if (htmlGenerator_ != null) {
Label titleLabel = new Label("Title (optional):");
titleLabel.addStyleName(styles.fieldLabel());
verticalPanel.add(titleLabel);
titleTextBox_ = new TextBox();
titleTextBox_.addStyleName(styles.titleTextBox());
titleTextBox_.getElement().setAttribute("spellcheck", "false");
verticalPanel.add(titleTextBox_);
Label commentLabel = new Label("Comment (optional):");
commentLabel.addStyleName(styles.fieldLabel());
verticalPanel.add(commentLabel);
commentTextArea_ = new FixedTextArea(6);
commentTextArea_.addStyleName(styles.commentTextArea());
verticalPanel.add(commentTextArea_);
// not using either for now
titleLabel.setVisible(false);
titleTextBox_.setVisible(false);
commentLabel.setVisible(false);
commentTextArea_.setVisible(false);
previewButton_ = new ThemedButton("Preview");
previewButton_.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
htmlGenerator_.generateStaticHtml(titleTextBox_.getText().trim(), commentTextArea_.getText().trim(), new CommandWithArg<String>() {
@Override
public void execute(String rpubsFile) {
globalDisplay_.showHtmlFile(rpubsFile);
}
});
}
});
addLeftButton(previewButton_);
}
HTML warningLabel = new HTML("<strong>IMPORTANT: All documents published to RPubs are " + "publicly visible.</strong> You should " + "only publish documents that you wish to share publicly.");
warningLabel.addStyleName(styles.warningLabel());
verticalPanel.add(warningLabel);
ThemedButton cancelButton = createCancelButton(new Operation() {
@Override
public void execute() {
// if an upload is in progress then terminate it
if (uploader_.isUploadInProgress()) {
uploader_.terminateUpload();
}
}
});
continueButton_ = new ThemedButton("Publish", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
performUpload(false);
}
});
updateButton_ = new ThemedButton("Update Existing", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
performUpload(true);
}
});
createButton_ = new ThemedButton("Create New", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
performUpload(false);
}
});
if (!isPublished_ && uploadId_.isEmpty()) {
addOkButton(continueButton_);
addCancelButton(cancelButton);
} else {
addOkButton(updateButton_);
addButton(createButton_);
addCancelButton(cancelButton);
}
mainPanel.setWidget(verticalPanel);
return mainPanel;
}
use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.
the class RStudioAPI method showDialog.
private void showDialog(String caption, String message, final String url) {
VerticalPanel verticalPanel = new VerticalPanel();
verticalPanel.addStyleName(RES.styles().textInfoWidget());
SafeHtml safeMsg = DialogHtmlSanitizer.sanitizeHtml(message);
HTML msg = new HTML(safeMsg.asString());
msg.setWidth("100%");
verticalPanel.add(msg);
if (!StringUtil.isNullOrEmpty(url)) {
HyperlinkLabel link = new HyperlinkLabel(url, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
RStudioGinjector.INSTANCE.getGlobalDisplay().openWindow(url);
}
});
link.addStyleName(RES.styles().installLink());
verticalPanel.add(link);
}
MessageDialog dlg = new MessageDialog(MessageDialog.INFO, caption, verticalPanel);
dlg.addButton("OK", new Operation() {
@Override
public void execute() {
server_.showDialogCompleted(null, false, new SimpleRequestCallback<Void>());
}
}, true, false);
dlg.showModal();
}
use of com.google.gwt.event.dom.client.ClickEvent 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);
}
Aggregations