public ScriptPanel()

in taverna-external-tool-activity-ui/src/main/java/org/apache/taverna/activities/externaltool/views/ScriptPanel.java [59:149]


	public ScriptPanel(final ExternalToolConfigView view, JTextComponent scriptTextArea, JCheckBox stdInCheckBox, JCheckBox stdOutCheckBox, JCheckBox stdErrCheckBox, JTextField returnCodesField) {
		super();
		this.setLayout(new BorderLayout());
	
		JTextArea descriptionText = new JTextArea(
				SCRIPT_DESCRIPTION);
		descriptionText.setEditable(false);
		descriptionText.setFocusable(false);
		descriptionText.setBorder(new EmptyBorder(5, 5, 10, 5));
		descriptionText.setLineWrap(true);
		descriptionText.setWrapStyleWord(true);
		this.add(descriptionText, BorderLayout.NORTH);

		this.scriptTextArea = scriptTextArea;
		
		this.add(new LineEnabledTextPanel(scriptTextArea),
				BorderLayout.CENTER);
		

		ToolDescription toolDescription = view.getConfiguration().getToolDescription();
		stdInCheckBox.setSelected(toolDescription.isIncludeStdIn());
		stdOutCheckBox.setSelected(toolDescription.isIncludeStdOut());
		stdErrCheckBox.setSelected(toolDescription.isIncludeStdErr());
		returnCodesField.setText(toolDescription.getReturnCodesAsText());
		
		JPanel codesPanel = new JPanel(new FlowLayout());
		codesPanel.add(new JLabel("Valid return codes:"));
		codesPanel.add(returnCodesField);

		JPanel streamPanel = new JPanel(new FlowLayout());
		streamPanel.add(stdInCheckBox);
		streamPanel.add(stdOutCheckBox);
		streamPanel.add(stdErrCheckBox);

		JPanel buttonPanel = new JPanel(new FlowLayout());
		if (view.isOriginallyFromRepository()) {
			JButton revertButton = new DeselectingButton("Revert to original description",
					new AbstractAction(){

				@Override
				public void actionPerformed(ActionEvent e) {
					ExternalToolActivityConfigurationBean bean = view.makeConfiguration();
					String repositoryUrl = bean.getRepositoryUrl();
					String id = bean.getExternaltoolid();
					ToolDescription tooldesc = null;
					try {
						tooldesc = ToolDescriptionParser.readDescriptionFromUrl(
							repositoryUrl, id);
					}
					catch (IOException ex) {
						// Already logged
					}
					if (tooldesc != null) {
						bean.setToolDescription(tooldesc);
						view.setEditable(false, bean);
					} else {
						JOptionPane.showMessageDialog(view, "Unable to find tool description " + id, "Missing tool description", JOptionPane.ERROR_MESSAGE);
					}
				}});
			revertButton.setToolTipText("Revert to the tool description from the repository");
			buttonPanel.add(revertButton);
		}
		JButton loadScriptButton = new DeselectingButton("Load description",
				new LoadDescriptionAction(this, view));
		loadScriptButton.setToolTipText("Load tool description from a file");

		JButton saveScriptButton = new DeselectingButton("Export description",
				new SaveDescriptionAction(this, view));
		saveScriptButton.setToolTipText("Export the tool description to a file");

		JButton clearScriptButton = new DeselectingButton("Clear script",
				new AbstractAction() {

			public void actionPerformed(ActionEvent e) {
				clearScript();
			}

		});
		clearScriptButton.setToolTipText("Clear the script from the edit area");

		buttonPanel.add(loadScriptButton);
		buttonPanel.add(saveScriptButton);
		buttonPanel.add(clearScriptButton);

		JPanel subPanel = new JPanel(new GridLayout(3,1));
		subPanel.add(codesPanel);
		subPanel.add(streamPanel);
		subPanel.add(buttonPanel);

		this.add(subPanel, BorderLayout.SOUTH);
	}