private boolean InitGraph() { boolean result = true; try { if (initGraphEnabled) { result = graphEx.InitGraph(); } if (!result && allowGraphBuilding) { statusLabel.setText("Graph is incomplete"); } } catch (Exception e) { if (e.getMessage() != null) { statusLabel.setText("Error: " + e.getMessage()); } else { statusLabel.setText("Error: " + e.toString()); } result = false; } return result; }
private boolean ValidateAllNodes() { if (isProcessing) return false; if (productSetPanel == null) return false; if (graphExecutorList.isEmpty()) return false; boolean result; statusLabel.setText(""); try { cloneGraphs(); assignParameters(); // first graph must pass result = graphExecutorList.get(0).InitGraph(); } catch (Exception e) { statusLabel.setText(e.getMessage()); bottomStatusLabel.setText(""); result = false; } return result; }
@Override protected Boolean doInBackground() throws Exception { pm.beginTask("Processing Graph...", 100 * graphExecuterList.size()); try { executeStartTime = Calendar.getInstance().getTime(); isProcessing = true; for (GraphExecuter graphEx : graphExecuterList) { final String desc = graphEx.getGraphDescription(); if (desc != null && !desc.isEmpty()) statusLabel.setText("Processing " + graphEx.getGraphDescription()); graphEx.InitGraph(); graphEx.executeGraph(SubProgressMonitor.create(pm, 100)); graphEx.disposeGraphContext(); } } catch (Exception e) { System.out.print(e.getMessage()); if (e.getMessage() != null && !e.getMessage().isEmpty()) statusLabel.setText(e.getMessage()); else statusLabel.setText(e.toString()); errorOccured = true; } finally { isProcessing = false; pm.done(); if (SnapApp.getDefault().getPreferences().getBoolean(GPF.BEEP_AFTER_PROCESSING_PROPERTY, false)) { Toolkit.getDefaultToolkit().beep(); } } return true; }
private boolean ValidateAllNodes() { if (isProcessing) return false; if (ioPanel == null || graphExecuterList.isEmpty()) return false; boolean result; statusLabel.setText(""); try { // check the all files have been saved final Product srcProduct = ioPanel.getSelectedSourceProduct(); if (srcProduct != null && (srcProduct.isModified() || srcProduct.getFileLocation() == null)) { throw new OperatorException("The source product has been modified. Please save it before using it in " + getTitle()); } assignParameters(); // first graph must pass result = graphExecuterList.get(0).InitGraph(); } catch (Exception e) { statusLabel.setText(e.getMessage()); result = false; } return result; }
/** * For running graphs in unit tests * * @throws Exception when failing validation */ public void testRunGraph() throws Exception { ioPanel.initProducts(); initGraphs(); if (ValidateAllNodes()) { for (GraphExecuter graphEx : graphExecuterList) { final String desc = graphEx.getGraphDescription(); if (desc != null && !desc.isEmpty()) System.out.println("Processing " + graphEx.getGraphDescription()); graphEx.InitGraph(); graphEx.executeGraph(ProgressMonitor.NULL); graphEx.disposeGraphContext(); } cleanUpTempFiles(); } else { throw new OperatorException(statusLabel.getText()); } }