Search in sources :

Example 11 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class VCDocumentDbTreeModel method initOwners.

protected static synchronized TreeMap<String, BioModelNode> initOwners(VCDocumentInfo[] vcDocumentInfos, User loginUser, VCDocumentDbTreeModel subTreeParent, Method subTreeMethod) {
    // 
    // get list of users (owners)
    // 
    Vector<User> userList = new Vector<User>();
    userList.addElement(loginUser);
    for (int i = 0; i < vcDocumentInfos.length; i++) {
        VCDocumentInfo vcDocumentInfo = vcDocumentInfos[i];
        if (!userList.contains(vcDocumentInfo.getVersion().getOwner())) {
            userList.addElement(vcDocumentInfo.getVersion().getOwner());
        }
    }
    // 
    // for each user
    // 
    TreeMap<String, BioModelNode> treeMap = new TreeMap<String, BioModelNode>(new Comparator<String>() {

        public int compare(String o1, String o2) {
            return o1.compareToIgnoreCase(o2);
        }
    });
    for (int ownerIndex = 0; ownerIndex < userList.size(); ownerIndex++) {
        User owner = (User) userList.elementAt(ownerIndex);
        BioModelNode ownerNode = null;
        try {
            if (vcDocumentInfos instanceof BioModelInfo[]) {
                ownerNode = (BioModelNode) subTreeMethod.invoke(subTreeParent, new Object[] { owner, (BioModelInfo[]) vcDocumentInfos });
            } else if (vcDocumentInfos instanceof MathModelInfo[]) {
                ownerNode = (BioModelNode) subTreeMethod.invoke(subTreeParent, new Object[] { owner, (MathModelInfo[]) vcDocumentInfos });
            } else if (vcDocumentInfos instanceof GeometryInfo[]) {
                ownerNode = (BioModelNode) subTreeMethod.invoke(subTreeParent, new Object[] { owner, (GeometryInfo[]) vcDocumentInfos });
            } else {
                throw new Exception("Unimplemented VCDocumentInfo type=" + vcDocumentInfos.getClass().getName());
            }
        } catch (Exception e) {
            ownerNode = new BioModelNode("Error" + e.getMessage());
        }
        if (owner.equals(loginUser) || ownerNode.getChildCount() > 0) {
            treeMap.put(owner.getName(), ownerNode);
        }
    }
    return treeMap;
}
Also used : User(org.vcell.util.document.User) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) TreeMap(java.util.TreeMap) DataAccessException(org.vcell.util.DataAccessException) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) Vector(java.util.Vector)

Example 12 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelDbTreeModel method databaseDelete.

/**
 * @param event cbit.vcell.clientdb.DatabaseEvent
 */
public void databaseDelete(DatabaseEvent databaseEvent) {
    if (databaseEvent.getOldVersionInfo() instanceof BioModelInfo) {
        BioModelInfo removedBioModelInfo = (BioModelInfo) databaseEvent.getOldVersionInfo();
        BioModelNode removedNode = ((BioModelNode) getRoot()).findNodeByUserObject(removedBioModelInfo);
        if (removedNode != null) {
            if (removedNode.getParent() != null && removedNode.getSiblingCount() == 1) {
                // just this one version
                removedNode = (BioModelNode) removedNode.getParent();
            }
            removeNodeFromParent(removedNode);
        }
    }
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo)

Example 13 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelDbTreePanel method documentManager_DatabaseDelete.

/**
 * Comment
 */
protected void documentManager_DatabaseDelete(DatabaseEvent event) {
    if (event.getOldVersionInfo() instanceof BioModelInfo && getSelectedVersionInfo() instanceof BioModelInfo) {
        BioModelInfo selectedBMInfo = (BioModelInfo) getSelectedVersionInfo();
        BioModelInfo eventBMInfo = (BioModelInfo) event.getOldVersionInfo();
        if (eventBMInfo.getVersion().getVersionKey().equals(selectedBMInfo.getVersion().getVersionKey())) {
            setSelectedVersionInfo(null);
            getJTree1().getSelectionModel().clearSelection();
        }
    }
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo)

Example 14 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelDbTreePanel method actionsOnClick.

/**
 * Comment
 */
protected void actionsOnClick(MouseEvent mouseEvent) {
    if (mouseEvent.isPopupTrigger()) {
        if (!getPopupMenuDisabled()) {
            TreePath treePath = ((JTree) mouseEvent.getSource()).getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
            ((JTree) mouseEvent.getSource()).setSelectionPath(treePath);
            if (getSelectedVersionInfo() instanceof BioModelInfo) {
                Version version = getSelectedVersionInfo().getVersion();
                boolean isOwner = version.getOwner().compareEqual(getDocumentManager().getUser());
                configureArhivePublishMenuState(version, isOwner);
                getJMenuItemPermission().setEnabled(isOwner && !version.getFlag().compareEqual(VersionFlag.Published));
                getJMenuItemDelete().setEnabled(isOwner && !version.getFlag().compareEqual(VersionFlag.Archived) && !version.getFlag().compareEqual(VersionFlag.Published));
                compareWithMenuItemEnable(getSelectedVersionInfo());
                getBioModelPopupMenu().show(getJTree1(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
            }
        }
    } else {
        ifNeedsDoubleClickEvent(mouseEvent, BioModelInfo.class);
    }
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) Version(org.vcell.util.document.Version) BioModelInfo(org.vcell.util.document.BioModelInfo)

Example 15 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelDbTreePanel method compareWithMenuItemEnable.

/**
 * Comment
 */
private void compareWithMenuItemEnable(VersionInfo vInfo) {
    boolean bPreviousEditionMenuItem = false;
    boolean bLatestEditionMenuItem = false;
    boolean bAnotherEditionMenuItem = false;
    BioModelInfo thisBioModelInfo = (BioModelInfo) vInfo;
    // 
    try {
        BioModelInfo[] bioModelVersionsList = getBioModelVersionDates(thisBioModelInfo);
        if (bioModelVersionsList != null && bioModelVersionsList.length > 0) {
            bAnotherEditionMenuItem = true;
            // 
            // Obtaining the previous version of the current biomodel.
            // 
            BioModelInfo previousBioModelInfo = bioModelVersionsList[0];
            boolean bPrevious = false;
            for (int i = 0; i < bioModelVersionsList.length; i++) {
                if (bioModelVersionsList[i].getVersion().getDate().before(thisBioModelInfo.getVersion().getDate())) {
                    bPrevious = true;
                    previousBioModelInfo = bioModelVersionsList[i];
                } else {
                    break;
                }
            }
            if (previousBioModelInfo.equals(bioModelVersionsList[0]) && !bPrevious) {
                bPreviousEditionMenuItem = false;
            } else {
                bPreviousEditionMenuItem = true;
            }
            // 
            // Obtaining the latest version of the current biomodel
            // 
            BioModelInfo latestBioModelInfo = bioModelVersionsList[bioModelVersionsList.length - 1];
            for (int i = 0; i < bioModelVersionsList.length; i++) {
                if (bioModelVersionsList[i].getVersion().getDate().after(latestBioModelInfo.getVersion().getDate())) {
                    latestBioModelInfo = bioModelVersionsList[i];
                }
            }
            if (thisBioModelInfo.getVersion().getDate().after(latestBioModelInfo.getVersion().getDate())) {
                bLatestEditionMenuItem = false;
            } else {
                bLatestEditionMenuItem = true;
            }
        }
    } catch (DataAccessException e) {
        e.printStackTrace();
    }
    getJPreviousEditionMenuItem().setEnabled(bPreviousEditionMenuItem);
    getLatestEditionMenuItem().setEnabled(bLatestEditionMenuItem);
    getAnotherEditionMenuItem().setEnabled(bAnotherEditionMenuItem);
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

BioModelInfo (org.vcell.util.document.BioModelInfo)79 DataAccessException (org.vcell.util.DataAccessException)38 MathModelInfo (org.vcell.util.document.MathModelInfo)37 BioModel (cbit.vcell.biomodel.BioModel)25 GeometryInfo (cbit.vcell.geometry.GeometryInfo)22 KeyValue (org.vcell.util.document.KeyValue)18 SimulationContext (cbit.vcell.mapping.SimulationContext)17 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)15 BigString (org.vcell.util.BigString)14 User (org.vcell.util.document.User)14 Vector (java.util.Vector)13 Simulation (cbit.vcell.solver.Simulation)12 XmlParseException (cbit.vcell.xml.XmlParseException)12 SQLException (java.sql.SQLException)12 XMLSource (cbit.vcell.xml.XMLSource)10 MathModel (cbit.vcell.mathmodel.MathModel)9 Hashtable (java.util.Hashtable)9 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)9 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)8 Geometry (cbit.vcell.geometry.Geometry)7