コード例 #1
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);
   }
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
  protected final void doActionPerformed(ActionEvent evt) {
    try {
      ApplicationDiagram diag =
          (ApplicationDiagram) (ApplicationContext.getFocusManager().getFocusObject());
      Point clickPosition = getDiagramLocation(evt);
      if (clickPosition == null)
        clickPosition = GraphicUtil.rectangleGetCenter(diag.getMainView().getViewRect());
      java.awt.Image image = SRSystemClipboard.getClipboardImage();
      if (image == null) return;
      DbObject diagGo = diag.getDiagramGO();
      Db db = diagGo.getDb();

      ImageIcon icon = new ImageIcon(image);
      int imageHeigth = icon.getIconHeight();
      int imageWidth = icon.getIconWidth();

      db.beginTrans(Db.WRITE_TRANS, LocaleMgr.action.getString("pasteDiagramImage"));

      DbObject imageGo = diagGo.createComponent(DbGraphic.fImageGoDiagramImage.getMetaClass());
      imageGo.set(DbGraphic.fImageGoDiagramImage, image);
      imageGo.set(
          DbGraphic.fGraphicalObjectRectangle,
          new Rectangle(
              clickPosition.x - (imageWidth / 2),
              clickPosition.y - (imageHeigth / 2),
              imageWidth,
              imageHeigth));
      db.commitTrans();
    } catch (Exception e) {
      org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
          ApplicationContext.getDefaultMainFrame(), e);
    }
  }