use of com.google.gwt.safehtml.shared.SafeHtml in project che by eclipse.
the class GithubImporterPageViewImpl method createRepositoriesTable.
/**
* Creates table what contains list of available repositories.
*
* @param resources
*/
private void createRepositoriesTable(final Resources resources, GitHubLocalizationConstant locale) {
repositories = new CellTable<>(15, resources);
Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(ProjectData item) {
return null;
}
};
Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(final ProjectData item) {
return SafeHtmlUtils.fromString(item.getName());
}
};
Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(final ProjectData item) {
return new SafeHtmlBuilder().appendHtmlConstant("<span>").appendEscaped(item.getDescription() == null ? "" : item.getDescription()).appendHtmlConstant("</span>").toSafeHtml();
}
};
repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX);
repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn());
repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn());
// don't show loading indicator
repositories.setLoadingIndicator(null);
final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
ProjectData selectedObject = selectionModel.getSelectedObject();
delegate.onRepositorySelected(selectedObject);
}
});
repositories.setSelectionModel(selectionModel);
}
use of com.google.gwt.safehtml.shared.SafeHtml in project che by eclipse.
the class SshKeyManagerPresenterTest method testOnDeleteClickedWhenDeleteKeyCanceled.
@Test
public void testOnDeleteClickedWhenDeleteKeyCanceled() {
SafeHtml safeHtml = mock(SafeHtml.class);
ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
when(constant.deleteSshKeyQuestion(anyString())).thenReturn(safeHtml);
when(safeHtml.asString()).thenReturn("");
when(dialogFactory.createConfirmDialog(anyString(), anyString(), (ConfirmCallback) anyObject(), (CancelCallback) anyObject())).thenReturn(confirmDialog);
presenter.onDeleteClicked(sshPairDto);
verify(dialogFactory).createConfirmDialog(anyString(), anyString(), (ConfirmCallback) anyObject(), cancelCallbackCaptor.capture());
CancelCallback cancelCallback = cancelCallbackCaptor.getValue();
cancelCallback.cancelled();
verify(confirmDialog).show();
verify(service, never()).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), anyString());
}
use of com.google.gwt.safehtml.shared.SafeHtml in project che by eclipse.
the class SshKeyManagerPresenterTest method testFailedRefreshKeysAfterSuccessfulDeleteKey.
@Test
public void testFailedRefreshKeysAfterSuccessfulDeleteKey() throws OperationException {
when(sshPairDto.getService()).thenReturn(SshKeyManagerPresenter.VCS_SSH_SERVICE);
when(sshPairDto.getName()).thenReturn(GITHUB_HOST);
SafeHtml safeHtml = mock(SafeHtml.class);
ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
List<SshPairDto> sshPairDtoArray = new ArrayList<>();
when(constant.deleteSshKeyQuestion(anyString())).thenReturn(safeHtml);
when(safeHtml.asString()).thenReturn("");
when(dialogFactory.createConfirmDialog(anyString(), anyString(), (ConfirmCallback) anyObject(), (CancelCallback) anyObject())).thenReturn(confirmDialog);
presenter.onDeleteClicked(sshPairDto);
verify(dialogFactory).createConfirmDialog(anyString(), anyString(), confirmCallbackCaptor.capture(), (CancelCallback) anyObject());
ConfirmCallback confirmCallback = confirmCallbackCaptor.getValue();
confirmCallback.accepted();
verify(voidPromise).then(operationVoidCapture.capture());
operationVoidCapture.getValue().apply(null);
verify(sshPairDTOsPromise).catchError(operationErrorCapture.capture());
operationErrorCapture.getValue().apply(JsPromiseError.create(""));
verify(confirmDialog).show();
verify(service).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), eq(GITHUB_HOST));
verify(service).getPairs(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE));
verify(view, never()).setPairs(eq(sshPairDtoArray));
verify(notificationManager).notify(anyString(), any(StatusNotification.Status.class), (DisplayMode) anyObject());
}
use of com.google.gwt.safehtml.shared.SafeHtml in project che by eclipse.
the class ResetFilesViewImpl method initColumns.
/** Initialize the columns of the grid. */
private void initColumns() {
indexFiles = new CellTable<IndexFile>();
// Create files column:
Column<IndexFile, String> filesColumn = new Column<IndexFile, String>(new TextCell()) {
@Override
public String getValue(IndexFile file) {
return file.getPath();
}
};
// Create column with checkboxes:
Column<IndexFile, Boolean> checkColumn = new Column<IndexFile, Boolean>(new CheckboxCell(false, true)) {
@Override
public Boolean getValue(IndexFile file) {
return !file.isIndexed();
}
};
// Create bean value updater:
FieldUpdater<IndexFile, Boolean> checkFieldUpdater = new FieldUpdater<IndexFile, Boolean>() {
@Override
public void update(int index, IndexFile file, Boolean value) {
file.setIndexed(!value);
}
};
checkColumn.setFieldUpdater(checkFieldUpdater);
filesColumn.setHorizontalAlignment(ALIGN_LEFT);
indexFiles.addColumn(checkColumn, new SafeHtml() {
@Override
public String asString() {
return " ";
}
});
indexFiles.setColumnWidth(checkColumn, 1, Style.Unit.PCT);
indexFiles.addColumn(filesColumn, FILES);
indexFiles.setColumnWidth(filesColumn, 35, Style.Unit.PCT);
indexFiles.addStyleName(resources.gitCSS().cells());
}
use of com.google.gwt.safehtml.shared.SafeHtml 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();
}
Aggregations