use of com.extjs.gxt.ui.client.data.RpcProxy in project kapua by eclipse.
the class DevicesTable method initDevicesGrid.
private void initDevicesGrid() {
//
// Column Configuration
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig("status", MSGS.deviceTableStatus(), 50);
column.setAlignment(HorizontalAlignment.CENTER);
GridCellRenderer<GwtDevice> setStatusIcon = new GridCellRenderer<GwtDevice>() {
public String render(GwtDevice gwtDevice, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtDevice> deviceList, Grid<GwtDevice> grid) {
if (gwtDevice.getGwtDeviceStatus().compareTo("ENABLED") == 0) {
if (gwtDevice.getGwtDeviceConnectionStatus().compareTo("CONNECTED") == 0) {
return ImageUtils.toHTML(Resources.INSTANCE.greenBullet14(), MSGS.connected(), "10");
} else if (gwtDevice.getGwtDeviceConnectionStatus().compareTo("MISSING") == 0) {
return ImageUtils.toHTML(Resources.INSTANCE.redBullet14(), MSGS.missing(), "10");
} else if (gwtDevice.getGwtDeviceConnectionStatus().compareTo("DISCONNECTED") == 0) {
return ImageUtils.toHTML(Resources.INSTANCE.yellowBullet14(), MSGS.disconnected(), "10");
}
return gwtDevice.getGwtDeviceConnectionStatus();
} else {
if (gwtDevice.getGwtDeviceConnectionStatus().compareTo("CONNECTED") == 0) {
return ImageUtils.toHTML(Resources.INSTANCE.greenAndBlackBullet14(), MSGS.disabledButConnected(), "10");
}
return ImageUtils.toHTML(Resources.INSTANCE.blackBullet14(), MSGS.disabled(), "10");
}
}
};
column.setRenderer(setStatusIcon);
column.setAlignment(HorizontalAlignment.CENTER);
column.setSortable(false);
configs.add(column);
column = new ColumnConfig("clientId", MSGS.deviceTableClientID(), 175);
column.setSortable(true);
configs.add(column);
column = new ColumnConfig("displayName", MSGS.deviceTableDisplayName(), 150);
column.setSortable(true);
configs.add(column);
column = new ColumnConfig("lastEventOnFormatted", MSGS.deviceTableLastReportedDate(), 130);
column.setSortable(true);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("lastEventType", MSGS.deviceTableLastEventType(), 130);
column.setSortable(false);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("serialNumber", MSGS.deviceTableSerialNumber(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
//
// Device Management Certificate
column = new ColumnConfig("Device Management Certificate Status", "DM", 50);
column.setAlignment(HorizontalAlignment.CENTER);
GridCellRenderer<GwtDevice> setDmStatusIcon = new GridCellRenderer<GwtDevice>() {
public String render(GwtDevice gwtDevice, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtDevice> deviceList, Grid<GwtDevice> grid) {
if (gwtDevice.getSignedCertificateId() == null) {
// Device Management Communication is not signed
return ImageUtils.toHTML(Resources.INSTANCE.dmUnlock16(), MSGS.deviceTableCertificateDMTooltipStatusNotSigned(), "14");
} else {
// Device Management Communication is signed
return ImageUtils.toHTML(Resources.INSTANCE.lockGreen16(), MSGS.deviceTableCertificateDMTooltipStatusSigned(), "14");
}
}
};
column.setRenderer(setDmStatusIcon);
column.setAlignment(HorizontalAlignment.CENTER);
column.setSortable(false);
configs.add(column);
column = new ColumnConfig("applicationIdentifiers", MSGS.deviceTableApplications(), 100);
column.setSortable(false);
column.setHidden(false);
configs.add(column);
column = new ColumnConfig("esfKuraVersion", MSGS.deviceTableEsfKuraVersion(), 80);
column.setSortable(false);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("customAttribute1", MSGS.deviceTableCustomAttribute1(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("customAttribute2", MSGS.deviceTableCustomAttribute2(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("connectionIp", MSGS.deviceTableIpAddress(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("modelId", MSGS.deviceTableModelId(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("firmwareVersion", MSGS.deviceTableFirmwareVersion(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("biosVersion", MSGS.deviceTableBiosVersion(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("osVersion", MSGS.deviceTableOsVersion(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("jvmVersion", MSGS.deviceTableJvmVersion(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("osgiFrameworkVersion", MSGS.deviceTableOsgiVersion(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("imei", MSGS.deviceTableImei(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("imsi", MSGS.deviceTableImsi(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
column = new ColumnConfig("iccid", MSGS.deviceTableIccid(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
// signedCertificateId
column = new ColumnConfig("signedCertificateId", MSGS.deviceTableCertificate(), 100);
column.setSortable(false);
column.setHidden(true);
configs.add(column);
// loader and store
RpcProxy<PagingLoadResult<GwtDevice>> proxy = new RpcProxy<PagingLoadResult<GwtDevice>>() {
@Override
public void load(Object loadConfig, AsyncCallback<PagingLoadResult<GwtDevice>> callback) {
PagingLoadConfig pagingConfig = (BasePagingLoadConfig) loadConfig;
((BasePagingLoadConfig) pagingConfig).setLimit(DEVICE_PAGE_SIZE);
gwtDeviceService.findDevices(pagingConfig, m_currentSession.getSelectedAccount().getId(), m_filterPredicates, callback);
}
};
m_loader = new BasePagingLoader<PagingLoadResult<GwtDevice>>(proxy);
m_loader.setSortDir(SortDir.ASC);
m_loader.setSortField("clientId");
m_loader.setRemoteSort(true);
SwappableListStore<GwtDevice> store = new SwappableListStore<GwtDevice>(m_loader);
store.setKeyProvider(new ModelKeyProvider<GwtDevice>() {
public String getKey(GwtDevice device) {
return device.getScopeId() + ":" + device.getClientId();
}
});
m_devicesGrid = new Grid<GwtDevice>(store, new ColumnModel(configs));
m_devicesGrid.setBorders(false);
m_devicesGrid.setStateful(false);
m_devicesGrid.setLoadMask(true);
m_devicesGrid.setStripeRows(true);
m_devicesGrid.setAutoExpandColumn("displayName");
m_devicesGrid.getView().setAutoFill(true);
m_devicesGrid.getView().setEmptyText(MSGS.deviceTableNoDevices());
m_devicesGrid.disableTextSelection(false);
m_devicesGrid.addListener(Events.HeaderClick, new Listener<GridEvent<GwtDevice>>() {
@Override
public void handleEvent(GridEvent<GwtDevice> be) {
if (be.getColIndex() == 1) {
if (m_filterPredicates.getSortAttribute().equals(GwtDeviceQueryPredicates.GwtSortAttribute.CLIENT_ID.name())) {
if (m_filterPredicates.getSortOrderEnum().equals(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING)) {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.DESCENDING.name());
} else {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING.name());
}
} else {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING.name());
}
m_filterPredicates.setSortAttribute(GwtDeviceQueryPredicates.GwtSortAttribute.CLIENT_ID.name());
} else if (be.getColIndex() == 2) {
if (m_filterPredicates.getSortAttribute().equals(GwtDeviceQueryPredicates.GwtSortAttribute.DISPLAY_NAME.name())) {
if (m_filterPredicates.getSortOrderEnum().equals(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING)) {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.DESCENDING.name());
} else {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING.name());
}
} else {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING.name());
}
m_filterPredicates.setSortAttribute(GwtDeviceQueryPredicates.GwtSortAttribute.DISPLAY_NAME.name());
} else if (be.getColIndex() == 3) {
if (m_filterPredicates.getSortAttribute().equals(GwtDeviceQueryPredicates.GwtSortAttribute.LAST_EVENT_ON.name())) {
if (m_filterPredicates.getSortOrderEnum().equals(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING)) {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.DESCENDING.name());
} else {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING.name());
}
} else {
m_filterPredicates.setSortOrder(GwtDeviceQueryPredicates.GwtSortOrder.ASCENDING.name());
}
m_filterPredicates.setSortAttribute(GwtDeviceQueryPredicates.GwtSortAttribute.LAST_EVENT_ON.name());
} else {
return;
}
refresh(m_filterPredicates);
}
});
m_loader.addLoadListener(new DataLoadListener(m_devicesGrid));
m_pagingToolBar = new PagingToolBar(DEVICE_PAGE_SIZE);
m_pagingToolBar.bind(m_loader);
m_pagingToolBar.enable();
GridSelectionModel<GwtDevice> selectionModel = new GridSelectionModel<GwtDevice>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_devicesGrid.setSelectionModel(selectionModel);
m_devicesGrid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtDevice>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtDevice> se) {
m_selectedDevice = se.getSelectedItem();
if (m_selectedDevice != null) {
m_deleteDeviceButton.setEnabled(true);
m_devicesView.setDevice(m_selectedDevice);
} else {
// m_editDeviceButton.setEnabled(false);
m_deleteDeviceButton.setEnabled(false);
}
}
});
}
use of com.extjs.gxt.ui.client.data.RpcProxy in project kapua by eclipse.
the class UserView method getUserGrid.
private Grid<GwtUser> getUserGrid() {
//
// Columns
ColumnConfig column = null;
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
column = new ColumnConfig("status", 50);
column.setAlignment(HorizontalAlignment.CENTER);
GridCellRenderer<GwtUser> setStatusIcon = new GridCellRenderer<GwtUser>() {
public String render(GwtUser model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtUser> employeeList, Grid<GwtUser> grid) {
switch(GwtUser.GwtUserStatus.valueOf(model.getStatus())) {
case ENABLED:
return "<image src=\"eclipse/org/eclipse/kapua/app/console/icon/green.gif\" width=\"12\" height=\"12\" style=\"vertical-align: bottom\" title=\"" + MSGS.enabled() + "\"/>";
case DISABLED:
return "<image src=\"eclipse/org/eclipse/kapua/app/console/icon/yellow.gif\" width=\"12\" height=\"12\" style=\"vertical-align: bottom\" title=\"" + MSGS.disabled() + "\"/>";
}
return model.getStatus();
}
};
column.setRenderer(setStatusIcon);
configs.add(column);
column = new ColumnConfig("username", MSGS.userName(), 100);
column.setAlignment(HorizontalAlignment.LEFT);
configs.add(column);
column = new ColumnConfig("email", MSGS.userEmail(), 100);
column.setAlignment(HorizontalAlignment.LEFT);
configs.add(column);
column = new ColumnConfig("loginAttempts", MSGS.userLoginAttempts(), 100);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("loginAttemptsResetOnFormatted", MSGS.userLoginAttemptsResetOn(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("lockedOnFormatted", MSGS.userLockedOn(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("unlockOnFormatted", MSGS.userUnlockOn(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
CheckColumnConfig checkColumn = new CheckColumnConfig("administrator", MSGS.userAdministrator(), 45);
checkColumn.setAlignment(HorizontalAlignment.CENTER);
CellEditor checkBoxEditor = new CellEditor(new CheckBox());
checkBoxEditor.setEnabled(false);
checkColumn.setEditor(checkBoxEditor);
configs.add(checkColumn);
column = new ColumnConfig("sortedAccountPermissions", MSGS.userPermissions(), 300);
column.setAlignment(HorizontalAlignment.LEFT);
configs.add(column);
m_columnModel = new ColumnModel(configs);
// rpc data proxy
RpcProxy<ListLoadResult<GwtUser>> proxy = new RpcProxy<ListLoadResult<GwtUser>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtUser>> callback) {
gwtUserService.findAll(m_selectedAccount.getId(), callback);
}
};
// grid loader
m_usersLoader = new BaseListLoader<ListLoadResult<GwtUser>>(proxy);
SwappableListStore<GwtUser> store = new SwappableListStore<GwtUser>(m_usersLoader);
store.setKeyProvider(new ModelKeyProvider<GwtUser>() {
public String getKey(GwtUser gwtUser) {
return String.valueOf(gwtUser.getId());
}
});
//
// Grid
m_grid = new Grid<GwtUser>(store, m_columnModel);
m_grid.setBorders(false);
m_grid.setStateful(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.getView().setAutoFill(true);
m_grid.setAutoExpandColumn("permissions");
GridView gridView = m_grid.getView();
gridView.setEmptyText(MSGS.userTableNoUsers());
m_usersLoader.addLoadListener(new DataLoadListener(m_grid));
GridSelectionModel<GwtUser> selectionModel = new GridSelectionModel<GwtUser>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtUser>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtUser> se) {
if (se.getSelectedItem() != null) {
if (m_currentSession.hasUserUpdatePermission()) {
m_editButton.setEnabled(true);
}
if (m_currentSession.hasUserDeletePermission()) {
m_deleteButton.setEnabled(true);
}
} else {
m_editButton.setEnabled(false);
m_deleteButton.setEnabled(false);
}
}
});
//
// populate
refresh();
return m_grid;
}
use of com.extjs.gxt.ui.client.data.RpcProxy in project kapua by eclipse.
the class DeviceTabPackagesInProgress method onRender.
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
//
// Column Configuration
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
GridCellRenderer<GwtPackageOperation> renderer = new GridCellRenderer<GwtPackageOperation>() {
@Override
public Object render(GwtPackageOperation model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtPackageOperation> store, Grid<GwtPackageOperation> grid) {
String operation;
if (model instanceof GwtPackageDownloadOperation) {
operation = MSGS.deviceInstallTabInProgressTableOperationInstall();
} else {
operation = MSGS.deviceInstallTabInProgressTableOperationUnknow();
}
return operation;
}
};
ColumnConfig column = new ColumnConfig();
column.setId("operation");
column.setHeader(MSGS.deviceInstallTabInProgressTableOperation());
column.setAlignment(HorizontalAlignment.CENTER);
column.setWidth(60);
column.setRenderer(renderer);
configs.add(column);
column.setId("id");
column.setHeader(MSGS.deviceInstallTabInProgressTableOperationId());
column.setAlignment(HorizontalAlignment.CENTER);
column.setWidth(60);
column.setRenderer(renderer);
configs.add(column);
renderer = new GridCellRenderer<GwtPackageOperation>() {
@Override
public Object render(GwtPackageOperation model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtPackageOperation> store, Grid<GwtPackageOperation> grid) {
String sizeString;
if (model instanceof GwtPackageDownloadOperation) {
Integer size = ((GwtPackageDownloadOperation) model).getSize();
if (size > 1024) {
size /= 1024;
if (size > 1024) {
sizeString = (size / 1024) + " MB";
} else {
sizeString = size.toString() + " KB";
}
} else {
sizeString = size.toString() + " B";
}
} else {
sizeString = null;
}
return sizeString;
}
};
column = new ColumnConfig();
column.setId("size");
column.setHeader(MSGS.deviceInstallTabInProgressTableSize());
column.setWidth(200);
column.setRenderer(renderer);
configs.add(column);
column = new ColumnConfig();
column.setId("progress");
column.setHeader(MSGS.deviceInstallTabInProgressTableProgressPercentage());
column.setWidth(80);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
ColumnModel columnModel = new ColumnModel(configs);
RpcProxy<ListLoadResult<GwtPackageOperation>> proxy = new RpcProxy<ListLoadResult<GwtPackageOperation>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtPackageOperation>> callback) {
gwtDeviceManagementService.getDownloadOperations(getSelectedDevice().getScopeId(), getSelectedDevice().getId(), callback);
}
};
storeLoader = new BaseListLoader<ListLoadResult<GwtPackageOperation>>(proxy);
storeLoader.addLoadListener(new InProgressDataLoadListener());
ListStore<GwtPackageOperation> store = new ListStore<GwtPackageOperation>(storeLoader);
grid = new Grid<GwtPackageOperation>(store, columnModel);
grid.setBorders(false);
grid.setStateful(false);
grid.setLoadMask(true);
grid.setStripeRows(true);
grid.setTrackMouseOver(false);
grid.disableTextSelection(false);
grid.setAutoExpandColumn("statusMessage");
grid.getView().setAutoFill(true);
grid.getView().setEmptyText(MSGS.deviceInstallTabInProgressTableEmpty());
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtPackageOperation>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtPackageOperation> se) {
ModelData selectedItem = se.getSelectedItem();
}
});
ContentPanel rootContentPanel = new ContentPanel();
rootContentPanel.setLayout(new FitLayout());
rootContentPanel.setBorders(false);
rootContentPanel.setBodyBorder(false);
rootContentPanel.setHeaderVisible(false);
rootContentPanel.add(grid);
add(rootContentPanel);
componentInitialized = true;
}
Aggregations