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); } }
// 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); } }