Search in sources :

Example 1 with CurateSpec

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

the class ClientRequestManager method curateDocument.

/**
 * Insert the method's description here.
 * Creation date: (6/22/2004 10:50:34 PM)
 * @param documentInfo cbit.vcell.document.VCDocumentInfo
 */
public void curateDocument(final VCDocumentInfo documentInfo, final int curateType, final TopLevelWindowManager requester) {
    if (documentInfo != null) {
        // see if we have this open
        String documentID = documentInfo.getVersion().getVersionKey().toString();
        if (getMdiManager().haveWindow(documentID)) {
            // already open, refuse
            PopupGenerator.showErrorDialog(requester, "Selected edition is open, cannot " + CurateSpec.CURATE_TYPE_NAMES[curateType]);
            return;
        } else {
            // don't have it open, try to CURATE it
            int confirm = PopupGenerator.showComponentOKCancelDialog(requester.getComponent(), new JTextArea(CurateSpec.CURATE_TYPE_ACTIONS[curateType] + " cannot be undone without VCELL administrative assistance.\n" + CurateSpec.CURATE_TYPE_STATES[curateType] + " versions of documents cannot be deleted without VCELL administrative assistance.\n" + (curateType == CurateSpec.PUBLISH ? CurateSpec.CURATE_TYPE_STATES[curateType] + " versions of documents MUST remain publically accessible to other VCELL users.\n" : "") + "Do you want to " + CurateSpec.CURATE_TYPE_NAMES[curateType] + " document '" + documentInfo.getVersion().getName() + "'" + "\nwith version date '" + documentInfo.getVersion().getDate().toString() + "'?"), "WARNING -- " + CurateSpec.CURATE_TYPE_ACTIONS[curateType] + " operation cannot be undone");
            if (confirm == JOptionPane.OK_OPTION) {
                AsynchClientTask task1 = new AsynchClientTask(CurateSpec.CURATE_TYPE_ACTIONS[curateType] + " document...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    @Override
                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        if (documentInfo instanceof BioModelInfo) {
                            getDocumentManager().curate(new CurateSpec((BioModelInfo) documentInfo, curateType));
                        } else if (documentInfo instanceof MathModelInfo) {
                            getDocumentManager().curate(new CurateSpec((MathModelInfo) documentInfo, curateType));
                        } else {
                            throw new RuntimeException(CurateSpec.CURATE_TYPE_ACTIONS[curateType] + " not supported for VCDocumentInfo type " + documentInfo.getClass().getName());
                        }
                    }
                };
                ClientTaskDispatcher.dispatch(requester.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
            } else {
                // user canceled
                return;
            }
        }
    } else {
        // nothing selected
        return;
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) JTextArea(javax.swing.JTextArea) Hashtable(java.util.Hashtable) CurateSpec(org.vcell.util.document.CurateSpec) BioModelInfo(org.vcell.util.document.BioModelInfo) CSGObject(cbit.vcell.geometry.CSGObject) MathModelInfo(org.vcell.util.document.MathModelInfo)

Aggregations

AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 CSGObject (cbit.vcell.geometry.CSGObject)1 Hashtable (java.util.Hashtable)1 JTextArea (javax.swing.JTextArea)1 BioModelInfo (org.vcell.util.document.BioModelInfo)1 CurateSpec (org.vcell.util.document.CurateSpec)1 MathModelInfo (org.vcell.util.document.MathModelInfo)1