protected void makeConfigPanel()

in taverna-loop-ui/src/main/java/org/apache/taverna/workbench/loop/LoopConfigurationPanel.java [375:507]


	protected void makeConfigPanel() {
		configPanel.removeAll();
		configPanel.setLayout(new GridBagLayout());

		GridBagConstraints gbc = new GridBagConstraints();
		gbc.anchor = GridBagConstraints.LINE_START;
		gbc.gridx = 0;
		gbc.gridy = 0;
		gbc.gridwidth = 4;
		gbc.weightx = 0.1;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		JLabel invokedRepeatedlyLabel = new JLabel(

				"<html><body>The service <strong>" + processor.getName() +  "</strong> " +
						"will be invoked repeatedly <em>until</em> its output port</body></html>");
		invokedRepeatedlyLabel.setBorder(new EmptyBorder(10,0,10,0)); // give some top and bottom border to the label
		configPanel.add(invokedRepeatedlyLabel, gbc);
		gbc.ipadx = 4;
		gbc.ipady = 4;

		gbc.weightx = 0.0;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.gridx = 0;
		gbc.gridy = 1;
		gbc.gridwidth = 1;
		List<String> activityOutputPorts = getActivityOutputPorts();
		portCombo = new JComboBox(activityOutputPorts.toArray());
		configPanel.add(portCombo, gbc);

		comparisonCombo = new JComboBox(ActivityGenerator.comparisons.toArray());
		comparisonCombo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Comparison selectedComparison = (Comparison) comparisonCombo
						.getSelectedItem();
				if (selectedComparison != null) {
					valueTypeLabel.setText("the "
							+ selectedComparison.getValueType());
				}
			}
		});
		if (comparisonCombo.getSelectedIndex() == -1) {
			comparisonCombo.setSelectedIndex(0);
		}
		gbc.gridx = 1;
		gbc.gridy = 1;
		configPanel.add(comparisonCombo, gbc);

		gbc.gridx = 2;
		gbc.gridy = 1;
		valueTypeLabel.setHorizontalAlignment(SwingConstants.RIGHT);
		configPanel.add(valueTypeLabel, gbc);

		gbc.gridx = 3;
		gbc.gridy = 1;
		gbc.weightx = 0.5; // request all extra space
		gbc.fill = GridBagConstraints.HORIZONTAL;
		configPanel.add(valueField, gbc);

		gbc.gridx = 0;
		gbc.gridy = 2;
		gbc.weightx = 0.0;
		configPanel.add(delayLabel, gbc);

		gbc.gridx = 1;
		gbc.gridx = 1;
		gbc.gridy = 2;
		gbc.weightx = 0.0;
		delayField.setHorizontalAlignment(JTextField.RIGHT);
		configPanel.add(delayField, gbc);

		gbc.gridx = 2;
		gbc.gridy = 2;
		gbc.gridwidth = 2;
		gbc.weightx = 0.5; // request all extra space
		gbc.fill = GridBagConstraints.HORIZONTAL;
		configPanel.add(secondsLabel, gbc);

		if (activityOutputPorts.isEmpty()) {
			JLabel warningLabel = new JLabel(
					"<html><body><strong>Warning:</strong><br>"
							+ "<i>No single value output ports detected on the main service, "
							+ "cannot use built-in comparisons. You may still add a customized " +
									"looping script</i></body></html>");
			gbc.gridx = 0;
			gbc.gridy++;
			gbc.gridwidth = 4;
			gbc.weightx = 0.1;
			gbc.fill = GridBagConstraints.BOTH;
			gbc.gridy++;
			configPanel.add(warningLabel, gbc);
			invokedRepeatedlyLabel.setVisible(false);
			portCombo.setVisible(false);
			comparisonCombo.setVisible(false);
			portWarning.setVisible(false);
			valueTypeLabel.setVisible(false);
			valueField.setVisible(false);
			delayField.setVisible(false);
			delayLabel.setVisible(false);
			secondsLabel.setVisible(false);
		}

		gbc.gridy++;
		gbc.gridx = 0;
		gbc.weightx = 0.1;
		gbc.gridwidth = 4;
		gbc.weightx = 0.1;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.insets = new Insets(10, 0, 10, 0);
		configPanel.add(portWarning, gbc);

		gbc.insets = new Insets(0, 0, 0, 0);
		gbc.weightx = 0.1;
		gbc.fill = GridBagConstraints.NONE;
		gbc.gridx = 0;
		gbc.gridy++;
		gbc.gridwidth = 4;
		gbc.anchor = GridBagConstraints.LAST_LINE_END;
		JPanel customiseButtonPanel = new JPanel(new FlowLayout());
		customizeButton = new JButton("Customize loop condition");
		customizeButton.addActionListener(new CustomizeAction());
		customiseButtonPanel.add(customizeButton);
		configPanel.add(customiseButtonPanel, gbc);

		// filler
		gbc.gridy++;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.gridx = 4;
		gbc.weightx = 0.1;
		gbc.weighty = 0.1;
		gbc.gridwidth = 4;
		configPanel.add(Box.createGlue(), gbc);
	}