use of org.eclipse.kapua.app.console.shared.model.device.management.packages.GwtPackageDownloadOperation in project kapua by eclipse.
the class GwtDeviceManagementServiceImpl method getDownloadOperations.
public ListLoadResult<GwtPackageOperation> getDownloadOperations(String scopeShortId, String deviceShortId) throws GwtKapuaException {
List<GwtPackageOperation> gwtDeviceOperations = new ArrayList<GwtPackageOperation>();
try {
KapuaLocator locator = KapuaLocator.getInstance();
DevicePackageManagementService deviceManagementService = locator.getService(DevicePackageManagementService.class);
KapuaId scopeId = KapuaEid.parseShortId(scopeShortId);
KapuaId deviceId = KapuaEid.parseShortId(deviceShortId);
DevicePackageDownloadOperation downloadOperation = deviceManagementService.downloadStatus(scopeId, deviceId, null);
GwtPackageDownloadOperation gwtDownloadOperation = new GwtPackageDownloadOperation();
gwtDownloadOperation.setId(downloadOperation.getId().getShortId());
gwtDownloadOperation.setStatus(downloadOperation.getStatus().name());
gwtDownloadOperation.setSize(downloadOperation.getSize());
gwtDownloadOperation.setProgress(downloadOperation.getProgress());
gwtDeviceOperations.add(gwtDownloadOperation);
} catch (Throwable t) {
KapuaExceptionHandler.handle(t);
}
return new BaseListLoadResult<>(gwtDeviceOperations);
}
use of org.eclipse.kapua.app.console.shared.model.device.management.packages.GwtPackageDownloadOperation 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