use of org.rstudio.studio.client.workbench.views.connections.model.ConnectionAction 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);
}
Aggregations