// Called at the end of a cell edition, to process the edition result. public final void valueForPathChanged(TreePath path, Object newValue) { DynamicNode node = (DynamicNode) path.getLastPathComponent(); Object obj = node.getRealObject(); if (obj instanceof DbObject) { boolean editable = false; try { Db db = ((DbObject) obj).getDb(); if (db.isValid()) { db.beginReadTrans(); MetaField editableMetaField = getEditableMetaField((DbObject) obj); if (editableMetaField == null) editable = ApplicationContext.getSemanticalModel() .isNameEditable((DbObject) obj, Explorer.class); else editable = ApplicationContext.getSemanticalModel() .isEditable(editableMetaField, (DbObject) obj, Explorer.class); db.commitTrans(); } } catch (DbException ex) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), ex); editable = false; } if (!editable) return; } else { return; } DbObject semObj = (DbObject) obj; try { MetaField editableMetaField = getEditableMetaField(semObj); String transName = (editableMetaField == null ? LocaleMgr.action.getString("rename") : MessageFormat.format(kUpdate0, new Object[] {editableMetaField.getGUIName()})); semObj.getDb().beginTrans(Db.WRITE_TRANS, transName); if (editableMetaField == null) { if (semObj.getTransStatus() == Db.OBJ_REMOVED) return; semObj.setName((String) newValue); } else semObj.set(editableMetaField, (String) newValue); semObj.getDb().commitTrans(); nodeChanged(node); // in case it is a secondary node (only the // primary node is updated by the refresh // listener). } catch (Exception ex) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), ex); } }
/** * If CS application, create a root node with 2 subnodes: RAM and repository; the RAM subnode * contains the list of RAM projects as subnodes. If RAM application, create a root node with the * list of projects as subnodes. */ private DynamicNode createRootNode() { DynamicNode rootNode = null; DynamicNode RAMNode = null; try { RAMNode = new DynamicNode(DB_RAM); RAMNode.setDisplayText(DbRAM.DISPLAY_NAME); RAMNode.setIcon(kLocalIcon); loadChildren(RAMNode); Db[] dbs = Db.getDbs(); for (int i = 0; i < dbs.length; i++) { if (dbs[i] instanceof DbRAM) continue; if (rootNode == null) { rootNode = new DynamicNode(ROOT); rootNode.setHasLoaded(); rootNode.add(RAMNode); } DynamicNode dbNode = new DynamicNode(dbs[i]); dbNode.setDisplayText(dbs[i].getDBMSName()); dbNode.setIcon(kRepositoryIcon); rootNode.add(dbNode); loadChildren(dbNode); } } catch (DbException ex) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), ex); } return (rootNode != null ? rootNode : RAMNode); }