use of com.google.gwt.user.cellview.client.TextColumn in project perun by CESNET.
the class TestDataGridTabItem method draw.
public Widget draw() {
// contentWidget.setSize("100%", "100%");
DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
contentWidget.setWidget(ft);
final DataGrid gridTable = new DataGrid();
gridTable.setSize("100%", "100%");
final ArrayList<VirtualOrganization> vosList = new ArrayList<VirtualOrganization>();
final GetVos getVos = new GetVos(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
vosList.addAll(new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso)));
gridTable.setRowData(vosList);
gridTable.redraw();
}
});
getVos.retrieveData();
gridTable.setSelectionModel(new MultiSelectionModel<VirtualOrganization>(new GeneralKeyProvider<VirtualOrganization>()));
final SelectionModel<VirtualOrganization> selectionModel = gridTable.getSelectionModel();
Column<VirtualOrganization, Boolean> checkBoxColumn = new Column<VirtualOrganization, Boolean>(new CheckboxCell(true, true)) {
@Override
public Boolean getValue(VirtualOrganization object) {
// Get the value from the selection model.
return selectionModel.isSelected(object);
}
};
checkBoxColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, Boolean>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, Boolean aBoolean) {
selectionModel.setSelected(virtualOrganization, aBoolean);
}
});
// Checkbox column header
CheckboxCell cb = new CheckboxCell();
Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {
public Boolean getValue() {
// return true to see a checked checkbox.
return false;
}
};
checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {
public void update(Boolean value) {
// sets selected to all, if value = true, unselect otherwise
for (VirtualOrganization obj : vosList) {
selectionModel.setSelected(obj, value);
}
}
});
gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
TextColumn<VirtualOrganization> idColumn = new TextColumn<VirtualOrganization>() {
@Override
public String getValue(VirtualOrganization object) {
return String.valueOf(object.getId());
}
};
gridTable.addColumn(idColumn, "Id", "Id");
gridTable.setColumnWidth(idColumn, "90px");
Column<VirtualOrganization, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<VirtualOrganization, String>() {
public String getValue(VirtualOrganization object) {
return object.getName();
}
}, new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
gridTable.addColumn(nameColumn, "Name", "Name");
TextColumn<VirtualOrganization> shortnameColumn = new TextColumn<VirtualOrganization>() {
@Override
public String getValue(VirtualOrganization object) {
return object.getShortName();
}
};
gridTable.addColumn(shortnameColumn, "Short name", "Short name");
shortnameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
idColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
nameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, String s) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
}
});
TabMenu tabMenu = new TabMenu();
// CREATE & DELETE ONLY WITH PERUN ADMIN
if (session.isPerunAdmin()) {
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
}
}));
final cz.metacentrum.perun.webgui.widgets.CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteVo());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(itemsToRemove)) {
VerticalPanel removePanel = new VerticalPanel();
removePanel.add(new Label("These VOs will be removed:"));
for (int i = 0; i < itemsToRemove.size(); i++) {
VirtualOrganization vo = itemsToRemove.get(i);
removePanel.add(new Label(" - " + vo.getName()));
}
// confirmation
Confirm c = new Confirm("Remove VOs", removePanel, new ClickHandler() {
public void onClick(ClickEvent event) {
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteVo request;
// if last, refresh
if (i == itemsToRemove.size() - 1) {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
} else {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteVo(itemsToRemove.get(i).getId(), false);
}
getVos.clearTableSelectedSet();
}
}, true);
c.show();
}
}
});
tabMenu.addWidget(removeButton);
}
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getVos.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterVo());
ft.addNorth(tabMenu, 50);
ft.add(gridTable);
return getWidget();
}
use of com.google.gwt.user.cellview.client.TextColumn in project platformlayer by platformlayer.
the class JettyServiceListViewImpl method populateColumns.
@Override
protected void populateColumns(BoundTable<JettyService> table) {
Column<JettyService, String> idColumn = new TextColumn<JettyService>() {
@Override
public String getValue(JettyService object) {
PlatformLayerKey key = object.getKey();
if (key == null) {
return "";
}
String id = key.getItemIdString();
if (id == null) {
return "";
}
return id;
}
};
table.addColumn(idColumn, "ID");
Column<JettyService, String> dnsName = JsTextColumn.build("dnsName");
table.addColumn(dnsName, "DNS Name");
}
use of com.google.gwt.user.cellview.client.TextColumn in project blogwt by billy1380.
the class UsersPage method createColumns.
/**
* create columns
*/
private void createColumns() {
Column<User, String> avatar = new Column<User, String>(UiHelper.IMAGE_PROTOTYPE) {
@Override
public String getValue(User object) {
return object.avatar + "?s=" + UserHelper.AVATAR_HEADER_SIZE + "&default=retro";
}
};
tblUsers.setColumnWidth(avatar, 20.0, Unit.PX);
TextColumn<User> username = new TextColumn<User>() {
@Override
public String getValue(User object) {
return object.username;
}
};
TextColumn<User> name = new TextColumn<User>() {
@Override
public String getValue(User object) {
return UserHelper.name(object);
}
};
Column<User, SafeHtml> email = new Column<User, SafeHtml>(UiHelper.SAFE_HTML_PROTOTYPE) {
@Override
public SafeHtml getValue(User object) {
return UsersPageTemplates.INSTANCE.emailLink(object.email, UserHelper.emailDescription(object));
}
};
TextColumn<User> lastLoggedIn = new TextColumn<User>() {
@Override
public String getValue(User object) {
return DateTimeHelper.ago(object.lastLoggedIn);
}
};
Column<User, SafeHtml> edit = new Column<User, SafeHtml>(UiHelper.SAFE_HTML_PROTOTYPE) {
@Override
public SafeHtml getValue(User object) {
return UiHelper.TEMPLATES.xsEdit(PageTypeHelper.asHref(PageType.ChangeDetailsPageType, "id", object.id.toString()));
}
};
tblUsers.setColumnWidth(edit, 1.0, Unit.PX);
Column<User, String> suspend = new Column<User, String>(UiHelper.ACTION_PROTOTYPE) {
@Override
public String getValue(User object) {
return UserHelper.isSuspended(object) ? "unsuspend" : "suspend";
}
};
suspend.setFieldUpdater(new FieldUpdater<User, String>() {
@Override
public void update(int index, User object, String value) {
boolean suspended = UserHelper.isSuspended(object);
if (suspended) {
UserController.get().unsuspendUser(object);
} else {
if (Window.confirm("Are you sure you want to suspend " + object.username + "'s account indefinitely?")) {
UserController.get().suspendUser(object);
}
}
}
});
tblUsers.setColumnWidth(suspend, 1.0, Unit.PX);
Column<User, String> admin = new Column<User, String>(UiHelper.ACTION_PROTOTYPE) {
@Override
public String getValue(User object) {
return "admin";
}
};
final Role adminRole = RoleHelper.createFullAdmin();
admin.setFieldUpdater(new FieldUpdater<User, String>() {
@Override
public void update(int index, User object, String value) {
if (Window.confirm("Are you sure you want to make " + object.username + " a " + adminRole.name + "?")) {
UserController.get().assignUserRoles(object, adminRole);
}
}
});
tblUsers.setColumnWidth(admin, 1.0, Unit.PX);
tblUsers.addColumn(avatar);
tblUsers.addColumn(username, "Username");
tblUsers.addColumn(name, "Name");
tblUsers.addColumn(email, "E-mail");
tblUsers.addColumn(lastLoggedIn, "Last seen");
tblUsers.addColumn(edit);
tblUsers.addColumn(admin);
tblUsers.addColumn(suspend);
}
use of com.google.gwt.user.cellview.client.TextColumn in project kie-wb-common by kiegroup.
the class ImportsWidgetViewImpl method setup.
private void setup() {
// Setup table
table.setStriped(true);
table.setCondensed(true);
table.setBordered(true);
table.setEmptyTableWidget(new Label(ImportConstants.INSTANCE.noImportsDefined()));
// Columns
final TextColumn<Import> importTypeColumn = new TextColumn<Import>() {
@Override
public String getValue(final Import importType) {
return importType.getType();
}
};
deleteImportColumn.setFieldUpdater((index, importType, value) -> {
if (isReadOnly) {
return;
}
final YesNoCancelPopup confirm = YesNoCancelPopup.newYesNoCancelPopup(ImportConstants.INSTANCE.remove(), ImportConstants.INSTANCE.promptForRemovalOfImport0(importType.getType()), () -> getRemoveImportCommand().execute(importType), () -> {
/*Nothing*/
}, null);
confirm.show();
});
table.addColumn(importTypeColumn, new TextHeader(ImportConstants.INSTANCE.importType()));
table.addColumn(deleteImportColumn, ImportConstants.INSTANCE.remove());
// Link data
getDataProvider().addDataDisplay(table);
getDataProvider().setList(importTypes);
}
use of com.google.gwt.user.cellview.client.TextColumn in project perun by CESNET.
the class GetAuditMessages method getTable.
public CellTable<AuditMessage> getTable() {
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<AuditMessage>(list);
// Cell table
table = new PerunTable<AuditMessage>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<AuditMessage> columnSortHandler = new ListHandler<AuditMessage>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AuditMessage>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("No audit messages found.");
if (checkable) {
// checkbox column column
table.addCheckBoxColumn();
}
table.addIdColumn("Message ID", null, 120);
// MESSAGE COLUMN
Column<AuditMessage, String> messageColumn = JsonUtils.addColumn(new CustomTextCell(), new JsonUtils.GetValue<AuditMessage, String>() {
public String getValue(AuditMessage msg) {
return msg.getActor() + ": " + msg.getMessage();
}
}, null);
messageColumn.setSortable(true);
columnSortHandler.setComparator(messageColumn, new Comparator<AuditMessage>() {
public int compare(AuditMessage o1, AuditMessage o2) {
return (o1.getActor() + ": " + o1.getMessage()).compareToIgnoreCase(o2.getActor() + ": " + o2.getMessage());
}
});
// TIME COLUMN
TextColumn<AuditMessage> timeColumn = new TextColumn<AuditMessage>() {
public String getValue(AuditMessage msg) {
return msg.getCreatedAt().substring(0, msg.getCreatedAt().indexOf("."));
}
};
timeColumn.setSortable(true);
columnSortHandler.setComparator(timeColumn, new Comparator<AuditMessage>() {
public int compare(AuditMessage o1, AuditMessage o2) {
return o1.getCreatedAt().compareToIgnoreCase(o2.getCreatedAt());
}
});
table.addColumn(timeColumn, "Created at");
table.setColumnWidth(timeColumn, "180px");
table.addColumn(messageColumn, "Message");
return table;
}
Aggregations