use of com.google.gwt.user.client.ui.ListBox in project rstudio by rstudio.
the class ChooseMirrorDialog method createMainWidget.
@Override
protected Widget createMainWidget() {
// create progress container
final SimplePanelWithProgress panel = new SimplePanelWithProgress(ProgressImages.createLargeGray());
panel.setStylePrimaryName(RESOURCES.styles().mainWidget());
// show progress (with delay)
panel.showProgress(200);
// query data source for packages
mirrorSource_.requestData(new SimpleRequestCallback<JsArray<T>>() {
@Override
public void onResponseReceived(JsArray<T> mirrors) {
// keep internal list of mirrors
boolean haveInsecureMirror = false;
mirrors_ = new ArrayList<T>(mirrors.length());
// create list box and select default item
listBox_ = new ListBox();
listBox_.setMultipleSelect(false);
// all
listBox_.setVisibleItemCount(18);
listBox_.setWidth("100%");
if (mirrors.length() > 0) {
for (int i = 0; i < mirrors.length(); i++) {
T mirror = mirrors.get(i);
if (mirrorSource_.getLabel(mirror).startsWith("0-Cloud"))
continue;
mirrors_.add(mirror);
String item = mirrorSource_.getLabel(mirror);
String value = mirrorSource_.getURL(mirror);
if (!value.startsWith("https"))
haveInsecureMirror = true;
listBox_.addItem(item, value);
}
listBox_.setSelectedIndex(0);
enableOkButton(true);
}
// set it into the panel
panel.setWidget(listBox_);
// set caption
String protocolQualifer = !haveInsecureMirror ? " HTTPS" : "";
setText("Choose" + protocolQualifer + " CRAN Mirror");
// update ok button on changed
listBox_.addDoubleClickHandler(new DoubleClickHandler() {
@Override
public void onDoubleClick(DoubleClickEvent event) {
clickOkButton();
}
});
// if the list box is larger than the space we initially allocated
// then increase the panel height
final int kDefaultPanelHeight = 285;
if (listBox_.getOffsetHeight() > kDefaultPanelHeight)
panel.setHeight(listBox_.getOffsetHeight() + "px");
// set focus
FocusHelper.setFocusDeferred(listBox_);
}
@Override
public void onError(ServerError error) {
closeDialog();
super.onError(error);
}
});
return panel;
}
use of com.google.gwt.user.client.ui.ListBox in project rstudio by rstudio.
the class InstallPackageDialog method createMainWidget.
@Override
protected Widget createMainWidget() {
// vertical panel
VerticalPanel mainPanel = new VerticalPanel();
mainPanel.setSpacing(2);
mainPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
// source type
reposCaption_ = new CaptionWithHelp("Install from:", "Configuring Repositories", "configuring_repositories");
reposCaption_.setIncludeVersionInfo(false);
reposCaption_.setWidth("100%");
mainPanel.add(reposCaption_);
packageSourceListBox_ = new ListBox();
packageSourceListBox_.setStylePrimaryName(RESOURCES.styles().packageSourceListBox());
packageSourceListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
JsArrayString repos = installContext_.selectedRepositoryNames();
if (repos.length() == 1) {
packageSourceListBox_.addItem("Repository (" + repos.get(0) + ")");
} else {
StringBuilder reposItem = new StringBuilder();
reposItem.append("Repository (");
for (int i = 0; i < repos.length(); i++) {
if (i != 0)
reposItem.append(", ");
reposItem.append(repos.get(i));
}
reposItem.append(")");
packageSourceListBox_.addItem(reposItem.toString());
}
packageSourceListBox_.addItem("Package Archive File (" + installContext_.packageArchiveExtension() + ")");
mainPanel.add(packageSourceListBox_);
// source panel container
sourcePanel_ = new SimplePanel();
sourcePanel_.setStylePrimaryName(RESOURCES.styles().packageSourcePanel());
// repos source panel
reposSourcePanel_ = new FlowPanel();
Label packagesLabel = new Label("Packages (separate multiple with space or comma):");
packagesLabel.setStylePrimaryName(RESOURCES.styles().packagesLabel());
reposSourcePanel_.add(packagesLabel);
packagesTextBox_ = new MultipleItemSuggestTextBox();
packagesSuggestBox_ = new SuggestBox(new PackageOracle(), packagesTextBox_);
packagesSuggestBox_.setWidth("100%");
packagesSuggestBox_.setLimit(20);
packagesSuggestBox_.addStyleName(RESOURCES.styles().extraBottomPad());
reposSourcePanel_.add(packagesSuggestBox_);
sourcePanel_.setWidget(reposSourcePanel_);
mainPanel.add(sourcePanel_);
// archive source panel
packageArchiveFile_ = new TextBoxWithButton("Package archive:", "Browse...", browseForArchiveClickHandler_);
// create check box here because manageUIState accesses it
installDependenciesCheckBox_ = new CheckBox();
if (defaultInstallOptions_.getInstallFromRepository())
packageSourceListBox_.setSelectedIndex(0);
else
packageSourceListBox_.setSelectedIndex(1);
manageUIState();
packageSourceListBox_.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
manageUIState();
if (!installFromRepository())
packageArchiveFile_.click();
}
});
mainPanel.add(new Label("Install to Library:"));
// library list box
libraryListBox_ = new ListBox();
libraryListBox_.setWidth("100%");
libraryListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
JsArrayString libPaths = installContext_.getWriteableLibraryPaths();
int selectedIndex = 0;
for (int i = 0; i < libPaths.length(); i++) {
String libPath = libPaths.get(i);
if (!installContext_.isDevModeOn()) {
if (defaultInstallOptions_.getLibraryPath().equals(libPath))
selectedIndex = i;
}
if (libPath.equals(installContext_.getDefaultLibraryPath()))
libPath = libPath + " [Default]";
libraryListBox_.addItem(libPath);
}
libraryListBox_.setSelectedIndex(selectedIndex);
mainPanel.add(libraryListBox_);
// install dependencies check box
installDependenciesCheckBox_.addStyleName(RESOURCES.styles().installDependenciesCheckBox());
installDependenciesCheckBox_.setText("Install dependencies");
installDependenciesCheckBox_.setValue(defaultInstallOptions_.getInstallDependencies());
mainPanel.add(installDependenciesCheckBox_);
mainPanel.add(new HTML("<br/>"));
return mainPanel;
}
use of com.google.gwt.user.client.ui.ListBox in project perun by CESNET.
the class GetGroupRichMembers method getTable.
/**
* Returns the table with rich members of group
*
* @return table widget
*/
public CellTable<RichMember> getTable() {
// retrieves data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<RichMember>(list);
// Cell table
table = new PerunTable<RichMember>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// Table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
// Set empty content & loader
table.setEmptyTableWidget(loaderImage);
// Checkbox column column
table.addCheckBoxColumn();
// Status column
Column<RichMember, String> statusColumn = new Column<RichMember, String>(new PerunStatusCell()) {
@Override
public String getValue(RichMember object) {
return object.getStatus();
}
};
// own onClick tab for changing member's status
statusColumn.setFieldUpdater(new FieldUpdater<RichMember, String>() {
public void update(int index, final RichMember object, String value) {
FlexTable widget = new FlexTable();
final ListBox lb = new ListBox(false);
lb.addItem("VALID", "VALID");
lb.addItem("INVALID", "INVALID");
lb.addItem("SUSPENDED", "SUSPENDED");
lb.addItem("EXPIRED", "EXPIRED");
lb.addItem("DISABLED", "DISABLED");
widget.setHTML(0, 0, "<strong>Status: </strong>");
widget.setWidget(0, 1, lb);
// pick which one is already set
for (int i = 0; i < lb.getItemCount(); i++) {
if (lb.getItemText(i).equalsIgnoreCase(object.getStatus())) {
lb.setSelectedIndex(i);
}
}
Confirm conf = new Confirm("Change member's status: " + object.getUser().getFullName(), widget, true);
conf.setCancelButtonText("Cancel");
conf.setOkButtonText("Change status");
conf.setOkClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
SetStatus call = new SetStatus(object.getId(), new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
clearTable();
retrieveData();
}
public void onError(PerunError error) {
clearTable();
retrieveData();
}
});
call.setStatus(lb.getValue(lb.getSelectedIndex()));
}
});
conf.show();
}
});
// status column sortable
statusColumn.setSortable(true);
columnSortHandler.setComparator(statusColumn, new GeneralComparator<RichMember>(GeneralComparator.Column.STATUS));
table.addColumn(statusColumn, "Status");
table.setColumnWidth(statusColumn, 20, Unit.PX);
// Create member ID column.
Column<RichMember, String> memberIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<RichMember, String>() {
public String getValue(RichMember object) {
return String.valueOf(object.getId());
}
}, this.tableFieldUpdater);
// Create User ID column.
Column<RichMember, String> userIdColumn = JsonUtils.addColumn(new JsonUtils.GetValue<RichMember, String>() {
public String getValue(RichMember object) {
return String.valueOf(object.getUser().getId());
}
}, this.tableFieldUpdater);
columnSortHandler.setComparator(memberIdColumn, new RichMemberComparator(RichMemberComparator.Column.MEMBER_ID));
memberIdColumn.setSortable(true);
userIdColumn.setSortable(true);
columnSortHandler.setComparator(userIdColumn, new RichMemberComparator(RichMemberComparator.Column.USER_ID));
table.setColumnWidth(memberIdColumn, 110.0, Unit.PX);
table.setColumnWidth(userIdColumn, 110.0, Unit.PX);
// headers
if (JsonUtils.isExtendedInfoVisible()) {
table.addColumn(memberIdColumn, "Member ID");
table.addColumn(userIdColumn, "User ID");
}
table.addNameColumn(tableFieldUpdater);
return table;
}
use of com.google.gwt.user.client.ui.ListBox in project perun by CESNET.
the class GetApplicationForm method createWidget.
/**
* Create approval style change widget
*
* @param form
*/
private void createWidget(final ApplicationForm form) {
final CustomButton button = TabMenu.getPredefinedButton(ButtonType.SETTINGS, ButtonTranslation.INSTANCE.changeAppFormSettings());
if (form != null) {
// create click handler
ClickHandler ch = new ClickHandler() {
public void onClick(ClickEvent event) {
// layout
FlexTable ft = new FlexTable();
ft.setCellSpacing(10);
ft.setHTML(0, 0, "<strong>INITIAL: </strong>");
ft.setHTML(1, 0, "<strong>EXTENSION: </strong>");
ft.setHTML(2, 0, "<strong>Module name: </strong>");
// widgets
final ListBox lbInit = new ListBox();
final ListBox lbExt = new ListBox();
final TextBox className = new TextBox();
lbInit.addItem("Automatic", "true");
lbInit.addItem("Manual", "false");
lbExt.addItem("Automatic", "true");
lbExt.addItem("Manual", "false");
if (form.getAutomaticApproval() == true) {
lbInit.setSelectedIndex(0);
} else {
lbInit.setSelectedIndex(1);
}
if (form.getAutomaticApprovalExtension() == true) {
lbExt.setSelectedIndex(0);
} else {
lbExt.setSelectedIndex(1);
}
className.setText(form.getModuleClassName());
ft.setWidget(0, 1, lbInit);
ft.setWidget(1, 1, lbExt);
ft.setWidget(2, 1, className);
// click on save
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
// switch and send request
UpdateForm request = new UpdateForm(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// recreate same widget
content.clear();
ApplicationForm newForm = jso.cast();
createWidget(newForm);
}
;
});
form.setAutomaticApproval(Boolean.parseBoolean(lbInit.getValue(lbInit.getSelectedIndex())));
form.setAutomaticApprovalExtension(Boolean.parseBoolean(lbExt.getValue(lbExt.getSelectedIndex())));
form.setModuleClassName(className.getText().trim());
request.updateForm(form);
}
};
Confirm c = new Confirm("Change application form settings", ft, click, true);
c.show();
}
};
button.addClickHandler(ch);
String appStyle = "<strong>Approval style: </strong>";
String module = "</br><strong>Module name: </strong>" + form.getModuleClassName();
if (form.getAutomaticApproval() == true) {
appStyle = appStyle + "<span style=\"color:red;\">Automatic</span> (INITIAL)";
} else {
appStyle = appStyle + "<span style=\"color:red;\">Manual</span> (INITIAL)";
}
if (form.getAutomaticApprovalExtension() == true) {
appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EXTENSION)";
} else {
appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EXTENSION)";
}
if (form.getGroup() == null && !session.isVoAdmin(form.getVo().getId()))
button.setEnabled(false);
if (form.getGroup() != null && (!session.isGroupAdmin(form.getGroup().getId()) && !session.isVoAdmin(form.getVo().getId())))
button.setEnabled(false);
content.setHTML(0, 0, appStyle + module);
content.setWidget(0, 1, button);
content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
} else {
button.setEnabled(false);
String appStyle = "<strong>Approval style: </strong> Form doesn't exists.";
String module = "</br><strong>Module name: </strong> Form doesn't exists.";
content.setHTML(0, 0, appStyle + module);
content.setWidget(0, 1, button);
content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
}
}
use of com.google.gwt.user.client.ui.ListBox in project che by eclipse.
the class ResolveViewImpl method addConflictingFile.
@Override
public void addConflictingFile(String filePath) {
Label filePathLabel = new Label(filePath);
filePathLabel.getElement().getStyle().setFloat(Float.LEFT);
filePathLabel.getElement().getStyle().setMarginRight(1, Unit.EM);
ListBox conflictResolutionActions = new ListBox();
for (ConflictResolutionAction action : conflictActions) {
conflictResolutionActions.addItem(action.getText());
}
filesResolutionActions.put(filePath, conflictResolutionActions);
Element resolutionDiv = DOM.createDiv();
resolutionDiv.getStyle().setMarginLeft(1, Unit.EM);
resolutionDiv.getStyle().setMarginRight(1, Unit.EM);
resolutionDiv.getStyle().setMarginBottom(1, Unit.EM);
resolutionDiv.getStyle().setTextAlign(TextAlign.RIGHT);
resolutionDiv.appendChild(filePathLabel.getElement());
resolutionDiv.appendChild(conflictResolutionActions.getElement());
mainPanel.getElement().appendChild(resolutionDiv);
}
Aggregations