use of com.extjs.gxt.ui.client.widget.grid.GridView in project kura by eclipse.
the class BundlesTab method initBundles.
private void initBundles() {
RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtDeviceService.findBundles(token, new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {
public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
callback.onSuccess(pairs);
}
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
}
});
}
});
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
m_loader.addLoadListener(new DataLoadListener());
m_store = new ListStore<GwtGroupedNVPair>(m_loader);
ColumnConfig id = new ColumnConfig("id", MSGS.deviceBndId(), 10);
ColumnConfig name = new ColumnConfig("name", MSGS.deviceBndName(), 50);
ColumnConfig status = new ColumnConfig("statusLoc", MSGS.deviceBndState(), 20);
ColumnConfig version = new ColumnConfig("version", MSGS.deviceBndVersion(), 20);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(id);
config.add(name);
config.add(status);
config.add(version);
ColumnModel cm = new ColumnModel(config);
GridView view = new GridView();
view.setForceFit(true);
m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
m_grid.setView(view);
m_grid.setBorders(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
GridSelectionModel<GwtGroupedNVPair> selectionModel = new GridSelectionModel<GwtGroupedNVPair>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtGroupedNVPair>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtGroupedNVPair> se) {
GwtGroupedNVPair selectedEntry = se.getSelectedItem();
if (selectedEntry != null) {
if ("bndActive".equals(selectedEntry.getStatus())) {
m_startButton.disable();
m_stopButton.enable();
} else {
m_stopButton.disable();
m_startButton.enable();
}
} else {
m_startButton.setEnabled(false);
m_stopButton.setEnabled(false);
}
}
});
}
use of com.extjs.gxt.ui.client.widget.grid.GridView in project kapua by eclipse.
the class AccountView method getAccountsGrid.
private Grid<GwtAccount> getAccountsGrid() {
//
// Column Configuration
ColumnConfig column = null;
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
column = new ColumnConfig("status", 30);
column.setAlignment(HorizontalAlignment.CENTER);
GridCellRenderer<GwtAccount> setStatusIcon = new GridCellRenderer<GwtAccount>() {
public String render(GwtAccount model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtAccount> employeeList, Grid<GwtAccount> grid) {
return "<image src=\"eclipse/org/eclipse/kapua/app/console/icon/green.gif\" width=\"12\" height=\"12\" style=\"vertical-align: bottom\" title=\"" + MSGS.enabled() + "\"/>";
}
};
column.setRenderer(setStatusIcon);
configs.add(column);
column = new ColumnConfig("name", 120);
column.setHeader(MSGS.accountTableName());
column.setWidth(150);
configs.add(column);
column = new ColumnConfig("modifiedOnFormatted", MSGS.accountTableModifiedOn(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
m_columnModel = new ColumnModel(configs);
// rpc data proxy
RpcProxy<ListLoadResult<GwtAccount>> proxy = new RpcProxy<ListLoadResult<GwtAccount>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtAccount>> callback) {
gwtAccountService.findChildren(m_currentSession.getSelectedAccount().getId(), false, callback);
}
};
// grid loader
m_accountLoader = new BaseListLoader<ListLoadResult<GwtAccount>>(proxy);
SwappableListStore<GwtAccount> store = new SwappableListStore<GwtAccount>(m_accountLoader);
store.setKeyProvider(new ModelKeyProvider<GwtAccount>() {
public String getKey(GwtAccount gwtAccount) {
return String.valueOf(gwtAccount.getId());
}
});
//
// Grid
m_grid = new Grid<GwtAccount>(store, m_columnModel);
m_grid.setBorders(false);
m_grid.setStateful(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.setTrackMouseOver(false);
m_grid.setAutoExpandColumn("name");
m_grid.mask(MSGS.loading());
m_grid.getView().setAutoFill(true);
GridView gridView = m_grid.getView();
gridView.setEmptyText(MSGS.accountTableNoAccounts());
m_accountLoader.addLoadListener(new DataLoadListener(m_grid));
GridSelectionModel<GwtAccount> selectionModel = new GridSelectionModel<GwtAccount>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtAccount>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtAccount> se) {
// Manage buttons
if (se.getSelectedItem() != null) {
m_editButton.setEnabled(m_currentSession.hasAccountUpdatePermission());
m_deleteButton.setEnabled(m_currentSession.hasAccountDeletePermission());
} else {
m_editButton.setEnabled(false);
m_deleteButton.setEnabled(false);
}
// Set account on tabs
if (se.getSelectedItem() != null) {
m_accountTabs.setAccount(m_grid.getSelectionModel().getSelectedItem());
}
}
});
//
// populate with initial status
updateAccountGrid(null);
return m_grid;
}
use of com.extjs.gxt.ui.client.widget.grid.GridView in project kapua by eclipse.
the class DeviceTabBundles method initGrid.
private void initGrid() {
RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
if (m_selectedDevice != null) {
if (m_selectedDevice.isOnline()) {
gwtDeviceManagementService.findBundles(m_selectedDevice, callback);
} else {
m_grid.getStore().removeAll();
m_grid.unmask();
}
}
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
m_loader.addLoadListener(new DataLoadListener());
m_store = new ListStore<GwtGroupedNVPair>(m_loader);
ColumnConfig id = new ColumnConfig("id", MSGS.deviceBndId(), 10);
ColumnConfig name = new ColumnConfig("name", MSGS.deviceBndName(), 50);
ColumnConfig status = new ColumnConfig("statusLoc", MSGS.deviceBndState(), 20);
ColumnConfig version = new ColumnConfig("version", MSGS.deviceBndVersion(), 20);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(id);
config.add(name);
config.add(status);
config.add(version);
ColumnModel cm = new ColumnModel(config);
GridView view = new GridView();
view.setForceFit(true);
view.setEmptyText(MSGS.deviceNoDeviceSelectedOrOffline());
m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
m_grid.setView(view);
m_grid.setBorders(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
GridSelectionModel<GwtGroupedNVPair> selectionModel = new GridSelectionModel<GwtGroupedNVPair>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtGroupedNVPair>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtGroupedNVPair> se) {
if (m_grid.getSelectionModel().getSelectedItem() != null) {
GwtGroupedNVPair selectedBundle = m_grid.getSelectionModel().getSelectedItem();
if ("bndActive".equals(selectedBundle.getStatus())) {
m_startButton.disable();
m_stopButton.enable();
} else {
m_stopButton.disable();
m_startButton.enable();
}
}
}
});
}
use of com.extjs.gxt.ui.client.widget.grid.GridView 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;
}
Aggregations