@Override protected void onClose() { CancelProcessing(); super.onClose(); }
@Override protected void onApply() { if (isProcessing) return; ioPanel.onApply(); try { DoProcessing(); } catch (Exception e) { statusLabel.setText(e.getMessage()); } }
void initGraphs() { try { deleteGraphs(); createGraphs(); } catch (Exception e) { statusLabel.setText(e.getMessage()); } }
@Override public int show() { ioPanel.initProducts(); setContent(mainPanel); initGraphs(); return super.show(); }
/** * 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()); } }
/** * Validates the input and then call the GPF to execute the graph * * @throws GraphException on assignParameters */ private void DoProcessing() { if (ValidateAllNodes()) { SystemUtils.freeAllMemory(); progressBar.setValue(0); final SwingWorker processThread = new ProcessThread(progBarMonitor); processThread.execute(); } else { showErrorDialog(statusLabel.getText()); } }
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; }
@Override public void done() { if (!errorOccured) { final Date now = Calendar.getInstance().getTime(); final long diff = (now.getTime() - executeStartTime.getTime()) / 1000; if (diff > 120) { final float minutes = diff / 60f; statusLabel.setText("Processing completed in " + minutes + " minutes"); } else { statusLabel.setText("Processing completed in " + diff + " seconds"); } SystemUtils.freeAllMemory(); if (ioPanel.isOpenInAppSelected()) { final GraphExecuter graphEx = graphExecuterList.get(graphExecuterList.size() - 1); openTargetProducts(graphEx.getProductsToOpenInDAT()); } } cleanUpTempFiles(); }
mainPanel.add(progressPanel, BorderLayout.SOUTH); getButton(ID_APPLY).setText("Run");