/*
  * retourne le nom à afficher
  */
 private String getDisplayName(DbObject dbo) throws DbException {
   String dboDisplayName = null;
   if (dbo.getName() != null) {
     if (dbo.getName().length() != 0) dboDisplayName = dbo.getName();
     else {
       dboDisplayName =
           ApplicationContext.getSemanticalModel().getDisplayText(dbo, Explorer.class);
     }
   } else {
     dboDisplayName = ApplicationContext.getSemanticalModel().getDisplayText(dbo, Explorer.class);
   }
   return dboDisplayName;
 } // end getDisplayName
Exemplo n.º 2
0
 // 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);
   }
 }
Exemplo n.º 3
0
 // This method updates the explorer for changes in a relation N where all
 // children are secondary nodes.
 // IMPORTANT: a node whose children are secondary nodes cannot have grouping
 // nodes.
 protected final void updateSecondaryChildren(DbUpdateEvent evt) throws DbException {
   if (!ApplicationContext.getSemanticalModel()
       .isVisibleOnScreen(evt.dbo, evt.neighbor, Explorer.class)) return;
   DynamicNode parentNode = getDynamicNode(evt.dbo, false);
   if (parentNode == null || !parentNode.hasLoaded()) return;
   DynamicNode childNode = null;
   int nb = getChildCount(parentNode);
   for (int i = 0; i < nb; i++) {
     DynamicNode node = (DynamicNode) getChild(parentNode, i);
     if (((DynamicNode) node.getUserObject()).getUserObject() == evt.neighbor) {
       childNode = node;
       break;
     }
   }
   if (evt.op == Db.REMOVE_FROM_RELN) {
     if (childNode != null) removeNodeFromParent(childNode);
   } else if (evt.op == Db.ADD_TO_RELN) {
     if (childNode == null) {
       childNode = createSecondaryNode(evt.dbo, evt.neighbor);
       int index = getInsertionIndex(evt.dbo, evt.neighbor, parentNode, childNode);
       insertNodeInto(childNode, parentNode, index);
     }
   } else { // Db.REINSERT_IN_RELN
     if (!childrenAreSorted(evt.dbo) && childNode != null) {
       removeNodeFromParent(childNode);
       int index = getInsertionIndex(evt.dbo, evt.neighbor, parentNode, childNode);
       insertNodeInto(childNode, parentNode, index);
     }
   }
 }
Exemplo n.º 4
0
  public final DynamicNode getDynamicNode(DbObject dbo, int which, boolean load)
      throws DbException {
    SrVector path = new SrVector(10);
    Db db = dbo.getDb();
    db.beginTrans(Db.READ_TRANS);
    while (dbo != null && !(dbo instanceof DbRoot)) {
      path.addElement(dbo);
      dbo = getDbParent(dbo, which);
    }
    if (db instanceof DbRAM) {
      if (DB_RAM != ((DynamicNode) getRoot()).getUserObject()) path.addElement(DB_RAM);
    } else path.addElement(db);

    DynamicNode nodeFound = (DynamicNode) getRoot();
    for (int i = path.size(); --i >= 0; ) {
      if (load) loadChildren(nodeFound);
      Object userObj = path.elementAt(i);
      dbo = null;
      DbObject dbParent = null;
      GroupParams group = GroupParams.defaultGroupParams;
      DynamicNode groupNode = null;
      DynamicNode node = null;
      if (userObj instanceof DbObject) {
        dbo = (DbObject) userObj;
        dbParent = getDbParent(dbo, which);
        group = getGroupParams(dbParent, dbo);
      }
      if (group.name == null) {
        node = getDynamicNode(nodeFound, userObj, 0);
      } else {
        groupNode = getGroupNode(nodeFound, group, 0);
        if (groupNode != null) node = getDynamicNode(groupNode, userObj, 0);
      }
      if (node == null && nodeFound.hasLoaded() && !nodeFound.isLeaf() && which == Db.NEW_VALUE) {

        SemanticalModel model = ApplicationContext.getSemanticalModel();
        boolean visible = model.isVisibleOnScreen(dbParent, dbo, Explorer.class);

        if (visible) {
          node = createPrimaryNode(dbParent, dbo);
          if (group.name == null) {
            insertNodeInto(node, nodeFound, getInsertionIndex(dbParent, dbo, nodeFound, node));
          } else {
            if (groupNode == null) {
              groupNode = createGroupNode(group);
              insertNodeInto(groupNode, nodeFound, getSortedIndex(nodeFound, groupNode));
            }
            insertNodeInto(node, groupNode, getInsertionIndex(dbParent, dbo, groupNode, node));
          }
        }
      }
      nodeFound = node;
      if (nodeFound == null) break;
    }
    db.commitTrans();
    return nodeFound;
  }
Exemplo n.º 5
0
  // Overridden
  protected void insertComponents(SrVector children, DbObject dbParent) throws DbException {
    SemanticalModel model = ApplicationContext.getSemanticalModel();

    DbEnumeration dbEnum = dbParent.getComponents().elements();
    while (dbEnum.hasMoreElements()) {
      DbObject dbo = dbEnum.nextElement();
      boolean isVisible = model.isVisibleOnScreen(dbParent, dbo, Explorer.class);
      if (isVisible) {
        children.addElement(createPrimaryNode(dbParent, dbo));
      } // end if
    } // end while
    dbEnum.close();
  } // end insertComponents()
Exemplo n.º 6
0
 protected String getDisplayText(DbObject dbParent, DbObject dbo) throws DbException {
   return ApplicationContext.getSemanticalModel().getDisplayText(dbo, Explorer.class);
 }