private void saveAll()

in taverna-results-view/src/main/java/org/apache/taverna/workbench/views/results/workflow/WorkflowResultsComponent.java [174:266]


	private void saveAll() {
		final JDialog dialog = new HelpEnabledDialog(getMainWindow(), TITLE,
				true);
		dialog.setResizable(false);
		dialog.setLocationRelativeTo(getMainWindow());
		JPanel panel = new JPanel(new BorderLayout());
		DialogTextArea explanation = new DialogTextArea();
		explanation.setText(EXPLANATION);
		explanation.setColumns(40);
		explanation.setEditable(false);
		explanation.setOpaque(false);
		explanation.setBorder(new EmptyBorder(5, 20, 5, 20));
		explanation.setFocusable(false);
		explanation.setFont(new JLabel().getFont()); // make the font the same as for other components in the dialog
		panel.add(explanation, NORTH);
		final Map<String, JCheckBox> inputChecks = new HashMap<>();
		final Map<String, JCheckBox> outputChecks = new HashMap<>();
		final Map<JCheckBox, Path> checkReferences = new HashMap<>();
		final Map<String, Path> chosenReferences = new HashMap<>();
		final Set<Action> actionSet = new HashSet<>();

		ItemListener listener = new ItemListener() {
			@Override
			public void itemStateChanged(ItemEvent e) {
				JCheckBox source = (JCheckBox) e.getItemSelectable();
				if (inputChecks.containsValue(source) && source.isSelected()
						&& outputChecks.containsKey(source.getText()))
					outputChecks.get(source.getText()).setSelected(false);
				if (outputChecks.containsValue(source) && source.isSelected()
						&& inputChecks.containsKey(source.getText()))
					inputChecks.get(source.getText()).setSelected(false);
				chosenReferences.clear();
				for (JCheckBox checkBox : checkReferences.keySet())
					if (checkBox.isSelected())
						chosenReferences.put(checkBox.getText(),
								checkReferences.get(checkBox));
			}
		};
		NavigableMap<String, Path> inputPorts = new TreeMap<>();
		try {
			inputPorts = DataBundles.getPorts(inputs);
		} catch (IOException e1) {
			logger.info("No input ports for worklow " + workflow.getName(), e1);
		}
		NavigableMap<String, Path> outputPorts = new TreeMap<>();
		try {
			outputPorts = DataBundles.getPorts(outputs);
		} catch (IOException e1) {
			logger.info("No output ports for worklow " + workflow.getName(), e1);
		}
		JPanel portsPanel = new JPanel();
		portsPanel.setLayout(new GridBagLayout());
		if (!workflow.getInputPorts().isEmpty())
			createInputPortsPanel(inputChecks, checkReferences, listener,
					inputPorts, outputPorts, portsPanel);
		if (!workflow.getOutputPorts().isEmpty())
			createOutputPortsPanel(outputChecks, checkReferences, listener,
					outputPorts, portsPanel);
		panel.add(portsPanel, CENTER);
		chosenReferences.clear();
		for (JCheckBox checkBox : checkReferences.keySet())
			if (checkBox.isSelected())
				chosenReferences.put(checkBox.getText(),
						checkReferences.get(checkBox));

		JPanel buttonsBar = new JPanel();
		buttonsBar.setLayout(new FlowLayout());
		// Get all existing 'Save result' actions
		for (SaveAllResultsSPI spi : saveActions) {
			AbstractAction action = spi.getAction();
			actionSet.add(action);
			JButton saveButton = new JButton((AbstractAction) action);
			if (action instanceof SaveAllResultsSPI) {
				((SaveAllResultsSPI) action)
						.setChosenReferences(chosenReferences);
				((SaveAllResultsSPI) action).setParent(dialog);
			}
			buttonsBar.add(saveButton);
		}
		JButton cancelButton = new JButton("Cancel", closeIcon);
		cancelButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				dialog.setVisible(false);
			}
		});
		buttonsBar.add(cancelButton);
		panel.add(buttonsBar, SOUTH);
		panel.revalidate();
		dialog.add(panel);
		dialog.pack();
		dialog.setVisible(true);
	}