public CachedClassVoCollection getCachedClasses() { List l = this.getDomainFactory().find("from CachedClass"); CachedClassVoCollection ret = new CachedClassVoCollection(); for (int i = 0; i < l.size(); i++) { CachedClass cc = (CachedClass)l.get(i); CachedClassVo vo = new CachedClassVo(); vo.setClassName(cc.getBoClassName()); LookupInstance lki = cc.getCacheUsage(); vo.setCacheUsage(new CacheUsage(lki.getId(), lki.getText(), lki.isActive(), null, new ImagePath(lki.getImage().getImageId(), lki.getImage().getImagePath()), lki.getColor())); vo.setIsCollection(new Boolean(cc.isCollection())); ret.add(vo); } return ret; }
protected void onBtnSaveClick() throws ims.framework.exceptions.PresentationLogicException { CachedClassVoCollection cachedClasses = new CachedClassVoCollection(); int size = form.grdObjectList().getRows().size(); for (int i = 0; i < size; i++) { String className = form.grdObjectList().getRows().get(i).getValue(); CacheUsage usage = form.grdObjectList().getRows().get(i).getCacheUsage(); CachedClassVo vo = new CachedClassVo(); vo.setClassName(className); vo.setCacheUsage(usage); vo.setIsCollection(Boolean.FALSE); cachedClasses.add(vo); addChildRowInstances(form.grdObjectList().getRows().get(i), cachedClasses); } try { domain.saveCacheConfig(cachedClasses); } catch (StaleObjectException e) { engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); } onBtnApplyClick(); setFormMode(FormMode.VIEW); }
private void addChildRowInstances(grdObjectListRow row, CachedClassVoCollection cachedClasses) { int size = row.getRows().size(); for (int i = 0; i < size; i++) { String className = row.getRows().get(i).getValue(); CacheUsage usage = row.getRows().get(i).getCacheUsage(); CachedClassVo vo = new CachedClassVo(); vo.setClassName(className); vo.setCacheUsage(usage); vo.setIsCollection(Boolean.TRUE); cachedClasses.add(vo); } }
private void populateGrid(HashMap rootClasses, CachedClassVoCollection cachedClasses) { form.grdObjectList().getRows().clear(); grdObjectListRow row; grdObjectListRow childRow; Set keysSet = rootClasses.keySet(); String[] keys = new String[keysSet.size()]; keysSet.toArray(keys); //Arrays.sort(keys); int totalCount = 0; for (int i = 0; i < keys.length; i++) { totalCount++; String fullName = keys[i]; String shortName = fullName.substring(fullName.lastIndexOf('.') + 1); String[] collFields = (String[])rootClasses.get(fullName); row = form.grdObjectList().getRows().newRow(); row.setClassName(shortName); row.setValue(fullName); row.setTooltip(fullName); row.setSelectable(true); CachedClassVo vo = getCachedClassVo(fullName, cachedClasses); if (vo != null) { row.setCacheUsage(vo.getCacheUsage()); if (row.getCacheUsage().equals(CacheUsage.READ_ONLY)) row.setBackColor(Color.Beige); else if (row.getCacheUsage().equals(CacheUsage.READ_WRITE)) row.setBackColor(Color.BlanchedAlmond); else if (row.getCacheUsage().equals(CacheUsage.NONSTRICT_READ_WRITE)) row.setBackColor(Color.Bisque); else if (row.getCacheUsage().equals(CacheUsage.TRANSACTIONAL)) row.setBackColor(Color.Azure); } for (int j = 0; j < collFields.length; j++) { totalCount++; String field = collFields[j]; String role = fullName + "." + field; childRow = row.getRows().newRow(); childRow.setClassName(field); childRow.setValue(role); childRow.setTooltip(role); childRow.setSelectable(false); CachedClassVo cachedCollField = getCachedClassVo(role, cachedClasses); if (cachedCollField != null) { childRow.setCacheUsage(cachedCollField.getCacheUsage()); if (childRow.getCacheUsage().equals(CacheUsage.READ_ONLY)) childRow.setBackColor(Color.Beige); else if (childRow.getCacheUsage().equals(CacheUsage.READ_WRITE)) childRow.setBackColor(Color.BlanchedAlmond); else if (childRow.getCacheUsage().equals(CacheUsage.NONSTRICT_READ_WRITE)) childRow.setBackColor(Color.Bisque); else if (childRow.getCacheUsage().equals(CacheUsage.TRANSACTIONAL)) childRow.setBackColor(Color.Azure); } } } form.lblTotal().setValue("Total : " + totalCount); form.grdObjectList().expandAll(); }