/** * Construct the LoadFileTask object. The constructor will run on the EDT, so we capture a * reference to the File to be loaded here. To keep things simple, the resources for this Task are * specified to be in the same ResourceMap as the DocumentEditorView class's resources. They're * defined in resources/ImageFlowView.properties. * * @param file */ public SaveFileTask(final File file) { super(ImageFlow.getApplication()); ImageFlowView.getProgressBar().setIndeterminate(true); ImageFlowView.getProgressBar().setVisible(true); this.file = file; this.view = (ImageFlowView) ImageFlow.getApplication().getMainView(); }
/* Called on the EDT if doInBackground fails because * an uncaught exception is thrown. We show an error * dialog here. The dialog is configured with resources * loaded from this Tasks's ResourceMap. */ @Override protected void failed(final Throwable e) { logger.log(Level.WARNING, "couldn't save " + getFile(), e); final String msg = getResourceMap().getString("loadFailedMessage", getFile()); final String title = getResourceMap().getString("loadFailedTitle"); final int type = JOptionPane.ERROR_MESSAGE; ImageFlowView.getProgressBar().setIndeterminate(false); ImageFlowView.getProgressBar().setVisible(false); JOptionPane.showMessageDialog(ImageFlow.getApplication().getMainFrame(), msg, title, type); }
/** * Reads the contents of a flow-XML input stream. * * @param in S flow-XML input stream */ public void read(URL url) { try { SAXBuilder sb = new SAXBuilder(); Document doc = sb.build(url); Element root = doc.getRootElement(); System.out.println("Read nodes ..."); // read units Element unitsElement = root.getChild("Units"); readUnits(newNodes, url, unitsElement); // at this point we have all units in the workflow, however no connections // groups are missing their inputs and outputs // System.out.println("Process Connection Delegates ..."); // process ConnectionDelegates for (ConnectionDelegate conndel : connectionDelegates) { conndel.list.add(readConnection(newNodes, conndel)); } System.out.println("Process Groups and add inputs and outputs ..."); // process groups for (GroupUnitElement unit : groupUnits) { unit.dealWithConnections(getConnectionList()); } System.out.println("Read global connections ..."); // read connections Element connectionsElement = root.getChild("Connections"); readConnections(newNodes, connectionsElement); } catch (Exception e) { System.err.println("Invalid XML-File!"); e.printStackTrace(); JOptionPane.showMessageDialog( ((ImageFlow) ImageFlow.getInstance()).getMainFrame(), "The selected workflow could not be loaded.", "Workflow not loaded", JOptionPane.INFORMATION_MESSAGE); } }