use of org.vcell.util.UtilCancelException in project vcell by virtualcell.
the class ClientRequestManager method getISizeFromUser.
public static ISize getISizeFromUser(Component guiParent, ISize initISize, String textMessage) throws UserCancelException {
Integer imageDimension = (initISize == null ? null : (initISize.getX() != 1 ? 1 : 0) + (initISize.getY() != 1 ? 1 : 0) + (initISize.getZ() != 1 ? 1 : 0));
if (imageDimension != null && (imageDimension < 1 || imageDimension > 3)) {
throw new IllegalArgumentException("Dimension must be 1, 2 or 3.");
}
try {
int xsize = (imageDimension == null ? -1 : initISize.getX());
int ysize = (imageDimension == null ? -1 : initISize.getY());
int zsize = (imageDimension == null ? -1 : initISize.getZ());
do {
String result = (imageDimension == null ? "256,256,8" : xsize + "," + ysize + "," + zsize);
result = DialogUtils.showInputDialog0(guiParent, textMessage, result);
String tempResult = result;
try {
if (result == null || result.length() == 0) {
result = "";
throw new Exception("No size values entered.");
}
xsize = Integer.parseInt(tempResult.substring(0, tempResult.indexOf(",")));
tempResult = tempResult.substring(tempResult.indexOf(",") + 1, tempResult.length());
ysize = Integer.parseInt(tempResult.substring(0, tempResult.indexOf(",")));
tempResult = tempResult.substring(tempResult.indexOf(",") + 1, tempResult.length());
zsize = Integer.parseInt(tempResult);
if (imageDimension != null) {
if (imageDimension == 2 && zsize != 1) {
throw new Exception("Dimension " + imageDimension + " must have z = 1.");
} else if (imageDimension == 1 && zsize != 1 && ysize != 1) {
throw new Exception("Dimension " + imageDimension + " must have z = 1 and y = 1.");
}
}
ISize isize = new ISize(xsize, ysize, zsize);
if (isize.getXYZ() <= 0) {
throw new Exception("Total pixels (" + xsize + "*" + ysize + "*" + zsize + ") cannot be <=0.");
}
return isize;
} catch (Exception e) {
DialogUtils.showErrorDialog(guiParent, "Error entering starting sizes\n" + e.getMessage(), e);
}
} while (true);
} catch (UtilCancelException e2) {
throw UserCancelException.CANCEL_GENERIC;
}
}
use of org.vcell.util.UtilCancelException in project vcell by virtualcell.
the class BioModelEditorPathwayDiagramPanel method groupBioPaxObjects.
private void groupBioPaxObjects() {
HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>();
selected.addAll(getSelectedBioPaxObjects());
if (selected.size() == 0)
return;
if (bioModel == null || bioModel.getPathwayModel() == null)
return;
PathwayGrouping pathwayGrouping = new PathwayGrouping();
ArrayList<String> names = new ArrayList<String>();
String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
String newName = null;
try {
newName = DialogUtils.showInputDialog0(this, "Name of the GroupObject", id);
} catch (UtilCancelException ex) {
// user canceled; it's ok
}
if (newName != null) {
if (newName.length() == 0) {
PopupGenerator.showErrorDialog(this, "The Name of the GroupObject should be provided.");
} else {
names.add(newName);
GroupObject groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), names, id, selected, GroupObject.Type.GROUPEDBIOPAXOBJECTS);
if (groupObject == null) {
// error message
DialogUtils.showErrorDialog(this, "The set of selected objects is a subset of one group object in the model. They will not be grouped together again.");
} else {
bioModel.getPathwayModel().add(groupObject);
bioModel.getPathwayModel().refreshGroupMap();
// set the grouped object to be selected
graphCartoonTool.getGraphModel().setSelectedObjects(new GroupObject[] { groupObject });
}
}
}
pathwayGraphModel.refreshAll();
}
use of org.vcell.util.UtilCancelException in project vcell by virtualcell.
the class DocumentWindow method showEditAnnotationWindow.
// /**
// * Comment
// */
// private void showBNGWindow() {
// getWindowManager().showBNGWindow();
// }
/**
* Comment
*/
private void showEditAnnotationWindow() {
try {
if (getWindowManager() != null) {
VCDocument vcDoc = getWindowManager().getVCDocument();
if (vcDoc != null) {
try {
// initialize fields - different for biomodel and mathmodel, geometry
String oldAnnotation = null;
if (vcDoc instanceof BioModel) {
oldAnnotation = ((BioModel) vcDoc).getVCMetaData().getFreeTextAnnotation((BioModel) vcDoc);
} else {
oldAnnotation = vcDoc.getDescription();
}
// show the editor
String newAnnotation = DialogUtils.showAnnotationDialog(this, oldAnnotation);
if (org.vcell.util.BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
// if VCDocument is a Biomodel, set the vcMetadata, else edit VCDoc.description for now
if (vcDoc instanceof BioModel) {
// update free text annotation in VCMetaData
VCMetaData vcMetaData = ((BioModel) vcDoc).getVCMetaData();
vcMetaData.setFreeTextAnnotation((BioModel) vcDoc, newAnnotation);
} else {
// Update VCDocument annotation
vcDoc.setDescription(newAnnotation);
}
}
} catch (UtilCancelException e) {
// Do Nothing
}
} else {
throw new Exception("No Document to Edit");
}
}
} catch (Throwable exc) {
exc.printStackTrace(System.out);
PopupGenerator.showErrorDialog(this, "Failed to edit annotation!\n" + exc.getMessage(), exc);
}
}
use of org.vcell.util.UtilCancelException in project vcell by virtualcell.
the class NetworkProxyPreferences method setProxyPrefs.
public static void setProxyPrefs(Component requester, RestartWarningProvider restartWarningProvider) throws UtilCancelException {
Preferences prefs = Preferences.userNodeForPackage(RemoteProxyVCellConnectionFactory.class);
String proxyType = prefs.get(prefProxyType, prefProxyType);
String proxyHost = prefs.get(prefProxyHost, prefProxyHost);
String proxyPort = prefs.get(prefProxyPort, prefProxyPort);
do {
try {
String init = proxyType + ":" + proxyHost + ":" + proxyPort;
String s = DialogUtils.showInputDialog0(requester, "Enter 3 : separated values, " + PROXY_FORMAT, init);
String proxyTypeNew = null;
String proxyHostNew = null;
String proxyPortNew = null;
if (s == null || s.trim().length() == 0) {
// clear proxy info
prefs.remove(prefProxyType);
prefs.remove(prefProxyHost);
prefs.remove(prefProxyPort);
} else {
StringTokenizer st = new StringTokenizer(s, ":");
proxyTypeNew = st.nextToken().toLowerCase();
if (!proxyTypeNew.equals("http") && !proxyTypeNew.equals("socks")) {
throw new IllegalArgumentException("Unkown proxyType='" + proxyTypeNew + "'");
}
proxyHostNew = st.nextToken();
proxyPortNew = st.nextToken();
prefs.put(prefProxyType, proxyTypeNew);
prefs.put(prefProxyHost, proxyHostNew);
prefs.put(prefProxyPort, Integer.parseInt(proxyPortNew) + "");
}
break;
} catch (UtilCancelException uce) {
// User didn't set proxy info
throw uce;
} catch (NumberFormatException nfe) {
nfe.printStackTrace();
DialogUtils.showErrorDialog(requester, nfe.getMessage() + "\nportNumber must be integer between 0 and 65535");
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
DialogUtils.showErrorDialog(requester, iae.getMessage() + "\nProxy type must be 'http' or 'socks'");
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(requester, e.getMessage() + "\nEntry must be of form (" + PROXY_FORMAT + ")");
}
} while (true);
NetworkProxyUtils.setProxyProperties(true, restartWarningProvider, proxyType, proxyHost, proxyPort, prefs.get(prefProxyType, prefProxyType), prefs.get(prefProxyHost, prefProxyHost), prefs.get(prefProxyPort, prefProxyPort));
}
use of org.vcell.util.UtilCancelException in project vcell by virtualcell.
the class ParameterEstimationPanel method newParameterEstimationTaskButton_ActionPerformed.
private void newParameterEstimationTaskButton_ActionPerformed() {
try {
String parameterEstimationName = "task0";
if (simulationContext == null) {
return;
}
AnalysisTask[] analysisTasks = simulationContext.getAnalysisTasks();
boolean found = true;
while (found) {
found = false;
parameterEstimationName = TokenMangler.getNextEnumeratedToken(parameterEstimationName);
for (int i = 0; analysisTasks != null && i < analysisTasks.length; i++) {
if (analysisTasks[i].getName().equals(parameterEstimationName)) {
found = true;
continue;
}
}
}
String newParameterEstimationName = null;
try {
newParameterEstimationName = DialogUtils.showInputDialog0(this, "name for new parameter estimation set", parameterEstimationName);
} catch (UtilCancelException ex) {
// user canceled; it's ok
}
if (newParameterEstimationName != null) {
if (newParameterEstimationName.length() == 0) {
PopupGenerator.showErrorDialog(this, "Error:\n name for new parameter estimation can't be empty");
} else {
final String finalname = newParameterEstimationName;
AsynchClientTask task1 = new AsynchClientTask("init task", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ParameterEstimationTask newParameterEstimationTask = new ParameterEstimationTask(simulationContext);
newParameterEstimationTask.setName(finalname);
hashTable.put("newParameterEstimationTask", newParameterEstimationTask);
}
};
AsynchClientTask task2 = new AsynchClientTask("add task", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ParameterEstimationTask newParameterEstimationTask = (ParameterEstimationTask) hashTable.get("newParameterEstimationTask");
simulationContext.addAnalysisTask(newParameterEstimationTask);
getAnalysisTaskComboBox().setSelectedItem(newParameterEstimationTask);
refreshAnalysisTaskEnables();
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(this, e.getMessage(), e);
}
}
Aggregations