use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class DatabaseWindowManager method accessPermissions.
/**
* Insert the method's description here.
* Creation date: (5/14/2004 5:35:55 PM)
*/
public void accessPermissions(final Component requester, final VersionInfo selectedVersionInfo) {
final GroupAccess groupAccess = selectedVersionInfo.getVersion().getGroupAccess();
final DocumentManager docManager = getRequestManager().getDocumentManager();
AsynchClientTask task1 = new AsynchClientTask("show dialog", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
getAclEditor().clearACLList();
getAclEditor().setACLState(new ACLEditor.ACLState(groupAccess));
Object choice = showAccessPermissionDialog(getAclEditor(), requester);
if (choice != null) {
hashTable.put("choice", choice);
}
}
};
AsynchClientTask task2 = new AsynchClientTask("access permission", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Object choice = hashTable.get("choice");
if (choice != null && choice.equals("OK")) {
ACLEditor.ACLState aclState = getAclEditor().getACLState();
if (aclState != null) {
if (aclState.isAccessPrivate() || (aclState.getAccessList() != null && aclState.getAccessList().length == 0)) {
VersionInfo vInfo = null;
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.setGroupPrivate((BioModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.setGroupPrivate((MathModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.setGroupPrivate((GeometryInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.setGroupPrivate((VCImageInfo) selectedVersionInfo);
}
} else if (aclState.isAccessPublic()) {
VersionInfo vInfo = null;
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.setGroupPublic((BioModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.setGroupPublic((MathModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.setGroupPublic((GeometryInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.setGroupPublic((VCImageInfo) selectedVersionInfo);
}
} else {
String[] aclUserNames = aclState.getAccessList();
String[] originalGroupAccesNames = new String[0];
// Turn User[] into String[]
if (groupAccess instanceof GroupAccessSome) {
GroupAccessSome gas = (GroupAccessSome) groupAccess;
User[] originalUsers = gas.getNormalGroupMembers();
for (int i = 0; i < originalUsers.length; i += 1) {
originalGroupAccesNames = (String[]) BeanUtils.addElement(originalGroupAccesNames, originalUsers[i].getName());
}
}
// Determine users needing adding
String[] needToAddUsers = new String[0];
for (int i = 0; i < aclUserNames.length; i += 1) {
if (!BeanUtils.arrayContains(originalGroupAccesNames, aclUserNames[i])) {
System.out.println("Added user=" + aclUserNames[i]);
needToAddUsers = (String[]) BeanUtils.addElement(needToAddUsers, aclUserNames[i]);
}
}
// Determine users needing removing
String[] needToRemoveUsers = new String[0];
for (int i = 0; i < originalGroupAccesNames.length; i += 1) {
if (!BeanUtils.arrayContains(aclUserNames, originalGroupAccesNames[i])) {
System.out.println("Removed user=" + originalGroupAccesNames[i]);
needToRemoveUsers = (String[]) BeanUtils.addElement(needToRemoveUsers, originalGroupAccesNames[i]);
}
}
VersionInfo vInfo = null;
String errorNames = "";
// Add Users to Group Access List
for (int i = 0; i < needToAddUsers.length; i++) {
try {
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.addUserToGroup((BioModelInfo) selectedVersionInfo, needToAddUsers[i]);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.addUserToGroup((MathModelInfo) selectedVersionInfo, needToAddUsers[i]);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.addUserToGroup((GeometryInfo) selectedVersionInfo, needToAddUsers[i]);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.addUserToGroup((VCImageInfo) selectedVersionInfo, needToAddUsers[i]);
}
} catch (ObjectNotFoundException e) {
errorNames += "Error changing permissions.\n" + selectedVersionInfo.getVersionType().getTypeName() + " \"" + selectedVersionInfo.getVersion().getName() + "\" edition (" + selectedVersionInfo.getVersion().getDate() + ")\nnot found, " + "your model list may be out of date, please go to menu Server->Reconnect to refresh the model list" + "\n";
break;
} catch (DataAccessException e) {
errorNames += "Error adding user '" + needToAddUsers[i] + "' : " + e.getMessage() + "\n";
}
}
// Remove users from Group Access List
for (int i = 0; i < needToRemoveUsers.length; i++) {
try {
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.removeUserFromGroup((BioModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.removeUserFromGroup((MathModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.removeUserFromGroup((GeometryInfo) selectedVersionInfo, needToRemoveUsers[i]);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.removeUserFromGroup((VCImageInfo) selectedVersionInfo, needToRemoveUsers[i]);
}
} catch (DataAccessException e) {
errorNames += "Error Removing user '" + needToRemoveUsers[i] + "'\n -----" + e.getMessage() + "\n";
}
}
if (errorNames.length() > 0) {
if (DatabaseWindowManager.this.getComponent() != null) {
PopupGenerator.showErrorDialog(DatabaseWindowManager.this, errorNames);
} else {
DialogUtils.showErrorDialog(requester, errorNames);
}
accessPermissions(requester, selectedVersionInfo);
}
}
}
}
}
};
ClientTaskDispatcher.dispatch(requester, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class DocumentWindowManager method openGeometryDocumentWindow.
/**
* Insert the method's description here.
* Creation date: (1/21/2006 10:45:13 AM)
*/
public void openGeometryDocumentWindow(final Geometry geom) {
AsynchClientTask task1 = new AsynchClientTask("opening geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
try {
GeometryInfo geomInfo = getRequestManager().getDocumentManager().getGeometryInfo(geom.getVersion().getVersionKey());
hashTable.put("geomInfo", geomInfo);
} catch (ObjectNotFoundException e) {
if (getVCDocument().getVersion() != null && !getVCDocument().getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
throw new RuntimeException("Opening a geometry document window for '" + geom.getName() + "' from\n" + "Model '" + getVCDocument().getName() + "' owned by user (" + getVCDocument().getVersion().getOwner().getName() + ")\n" + "FAILED because user (" + getRequestManager().getDocumentManager().getUser().getName() + ") does not have permission.\n" + "Save Model '" + getVCDocument().getName() + "' to your account to have full access to the geometry.");
} else {
throw e;
}
}
}
};
AsynchClientTask task2 = new AsynchClientTask("opening geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
GeometryInfo geomInfo = (GeometryInfo) hashTable.get("geomInfo");
getRequestManager().openDocument(geomInfo, DocumentWindowManager.this, true);
}
};
ClientTaskDispatcher.dispatch(this.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class MathModelWindowManager method actionPerformed.
/**
* Invoked when an action occurs.
*/
public void actionPerformed(java.awt.event.ActionEvent e) {
String actionCommand = e.getActionCommand();
final Object source = e.getSource();
if (source instanceof GeometryViewer && actionCommand.equals(GuiConstants.ACTIONCMD_CREATE_GEOMETRY) || actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY)) {
AsynchClientTask geomRegionsTask = new AsynchClientTask("Update Geometric regions", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
ClientRequestManager.continueAfterMathModelGeomChangeWarning(MathModelWindowManager.this, newGeom);
newGeom.precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
AsynchClientTask applyGeomTask = new AsynchClientTask("Apply Geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
if (newGeom.getName() == null) {
newGeom.setName(getMathModel().getName() + "_" + BeanUtils.generateDateTimeString());
}
((MathModel) getVCDocument()).getMathDescription().setGeometry(newGeom);
}
};
createGeometry(getMathModel().getMathDescription().getGeometry(), new AsynchClientTask[] { /*editSelectTask,*/
geomRegionsTask, applyGeomTask }, TopLevelWindowManager.DEFAULT_CREATEGEOM_SELECT_DIALOG_TITLE, TopLevelWindowManager.APPLY_GEOMETRY_BUTTON_TEXT, (actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY) ? new DocumentWindowManager.GeometrySelectionInfo() : null));
}
if (source instanceof GeometryViewer && actionCommand.equals(GuiConstants.ACTIONCMD_CHANGE_GEOMETRY)) {
getRequestManager().changeGeometry(this, null);
}
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class PdeTimePlotMultipleVariablesPanel method showTimePlot.
public void showTimePlot() {
if ((plotChangeTimer = ClientTaskDispatcher.getBlockingTimer(this, multiTimePlotHelper.getPdeDatacontext(), null, plotChangeTimer, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e2) {
showTimePlot();
}
}, "PdeTimePlotMultipleVariablesPanel update...")) != null) {
return;
}
VariableType varType = multiTimePlotHelper.getVariableType();
Object[] selectedValues = variableJList.getSelectedValues();
DataIdentifier[] selectedDataIdentifiers = new DataIdentifier[selectedValues.length];
System.arraycopy(selectedValues, 0, selectedDataIdentifiers, 0, selectedValues.length);
if (selectedDataIdentifiers.length > 1) {
for (DataIdentifier selectedDataIdentifier : selectedDataIdentifiers) {
if (!selectedDataIdentifier.getVariableType().getVariableDomain().equals(varType.getVariableDomain())) {
PopupGenerator.showErrorDialog(this, "Please choose VOLUME variables or MEMBRANE variables only");
variableJList.clearSelection();
variableJList.setSelectedValue(multiTimePlotHelper.getPdeDatacontext().getVariableName(), true);
return;
}
}
}
try {
final int numSelectedVariables = selectedDataIdentifiers.length;
final int numSelectedSpatialPoints = pointVector.size();
int[][] indices = new int[numSelectedVariables][numSelectedSpatialPoints];
//
for (int i = 0; i < numSelectedSpatialPoints; i++) {
for (int v = 0; v < numSelectedVariables; v++) {
if (selectedDataIdentifiers[v].getVariableType().equals(varType)) {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector.get(i);
indices[v][i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector.get(i);
indices[v][i] = ssm.getIndex(0);
}
} else {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) pointVector2.get(i);
indices[v][i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) pointVector2.get(i);
indices[v][i] = ssm.getIndex(0);
}
}
}
}
final String[] selectedVarNames = new String[numSelectedVariables];
for (int i = 0; i < selectedVarNames.length; i++) {
selectedVarNames[i] = selectedDataIdentifiers[i].getName();
}
final double[] timePoints = multiTimePlotHelper.getPdeDatacontext().getTimePoints();
TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(selectedVarNames, indices, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(multiTimePlotHelper.getUser(), true));
if (!tsjs.getVcDataJobID().isBackgroundTask()) {
throw new RuntimeException("Use getTimeSeries(...) if not a background job");
}
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(PDEDataViewer.StringKey_timeSeriesJobSpec, tsjs);
AsynchClientTask task1 = new PDEDataViewer.TimeSeriesDataRetrievalTask("Retrieving Data", multiTimePlotHelper, multiTimePlotHelper.getPdeDatacontext());
AsynchClientTask task2 = new AsynchClientTask("showing time plot", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobResults);
int plotCount = numSelectedVariables * numSelectedSpatialPoints;
SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
String[] plotNames = new String[plotCount];
double[][] plotDatas = new double[1 + plotCount][];
plotDatas[0] = timePoints;
int plotIndex = 0;
for (int v = 0; v < numSelectedVariables; v++) {
String varName = selectedVarNames[v];
double[][] data = tsJobResultsNoStats.getTimesAndValuesForVariable(varName);
for (int i = 1; i < data.length; i++) {
symbolTableEntries[plotIndex] = multiTimePlotHelper.getsimulation().getMathDescription().getEntry(varName);
plotNames[plotIndex] = varName + " at P[" + (i - 1) + "]";
plotDatas[plotIndex + 1] = data[i];
plotIndex++;
}
}
Plot2D plot2D = new SingleXPlot2D(symbolTableEntries, multiTimePlotHelper.getDataSymbolMetadataResolver(), ReservedVariable.TIME.getName(), plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
plotPane.setPlot2D(plot2D);
}
};
ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, task2 }, false, true, true, null, false);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.client.task.AsynchClientTask in project vcell by virtualcell.
the class DBReactionWizardPanel method searchUserReactions.
/**
* Insert the method's description here.
* Creation date: (7/12/2003 2:45:44 PM)
*/
private void searchUserReactions(final ReactionQuerySpec reactionQuerySpec) {
if (getDocumentManager() != null) {
final DocumentManager docManager = getDocumentManager();
final JList jlist = getReactionsJList();
//
final String RXSTRING_VALUE_KEY = "rxString";
//
AsynchClientTask searchReactions = new AsynchClientTask("searching reactions", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) {
try {
mapRXStringtoRXIDs.clear();
//
ReactionDescription[] dbrd = docManager.getUserReactionDescriptions(reactionQuerySpec);
//
if (dbrd != null && !(getStructure() instanceof Membrane)) {
Vector<ReactionDescription> noflux = new Vector<ReactionDescription>();
for (int i = 0; i < dbrd.length; i += 1) {
if (!dbrd[i].isFluxReaction()) {
noflux.add(dbrd[i]);
}
}
if (noflux.size() > 0) {
dbrd = new ReactionDescription[noflux.size()];
noflux.copyInto(dbrd);
}
}
//
String[] dbrdS = null;
if (dbrd != null) {
// if(mapRXStringtoRXIDs == null){mapRXStringtoRXIDs = new java.util.Hashtable();}
for (int i = 0; i < dbrd.length; i += 1) {
String rxString = dbrd[i].toString();
if (!mapRXStringtoRXIDs.containsKey(rxString)) {
mapRXStringtoRXIDs.put(rxString, new Vector<String>());
}
mapRXStringtoRXIDs.get(rxString).add(dbrd[i].getVCellRXID().toString());
mapRXIDtoBMIDs.put(dbrd[i].getVCellRXID(), dbrd[i].getVCellBioModelID());
mapRXIDtoStructRefIDs.put(dbrd[i].getVCellRXID(), dbrd[i].getVCellStructRef());
}
dbrdS = (String[]) mapRXStringtoRXIDs.keySet().toArray(new String[0]);
}
//
if (dbrd != null && dbrd.length > 0) {
hash.put(RXSTRING_VALUE_KEY, dbrdS);
}
} catch (DataAccessException e) {
PopupGenerator.showErrorDialog(DBReactionWizardPanel.this, e.getMessage());
}
}
};
//
AsynchClientTask updateRXList = new AsynchClientTask("updateRXList", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) {
String[] dbrdS = (String[]) hash.get(RXSTRING_VALUE_KEY);
if (dbrdS != null) {
jlist.setListData(dbrdS);
} else {
jlist.setListData(new String[0]);
}
afterSearchConfigure();
}
};
//
Hashtable<String, Object> hashTemp = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hashTemp, new AsynchClientTask[] { searchReactions, updateRXList }, false);
}
}
Aggregations