in taverna-external-tool-activity-ui/src/main/java/org/apache/taverna/activities/externaltool/views/StringReplacementPanel.java [63:133]
public StringReplacementPanel(final ExternalToolConfigView view, final List<ExternalToolStringReplacementViewer> stringReplacementViewList) {
super(new BorderLayout());
this.view = view;
this.stringReplacementViewList = stringReplacementViewList;
final JPanel inputEditPanel = new JPanel(new GridBagLayout());
final GridBagConstraints inputConstraint = new GridBagConstraints();
inputConstraint.anchor = GridBagConstraints.FIRST_LINE_START;
inputConstraint.gridx = 0;
inputConstraint.gridy = 0;
inputConstraint.weightx = 0.1;
inputConstraint.fill = GridBagConstraints.BOTH;
inputConstraint.gridx = 0;
synchronized (stringReplacementViewList) {
for (ExternalToolStringReplacementViewer inputView : stringReplacementViewList) {
addStringReplacementViewer(this, inputEditPanel,
inputView, elementLabels);
}
}
JTextArea descriptionText = new JTextArea(
STRING_REPLACEMENT_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.add(new JScrollPane(inputEditPanel),
BorderLayout.CENTER);
JButton addInputPortButton = new DeselectingButton("Add string replacement",
new AbstractAction() {
public void actionPerformed(ActionEvent e) {
int portNumber = 1;
String name2 = "in" + portNumber++;
boolean nameExists = true;
while (nameExists == true) {
nameExists = view.portNameExists(name2);
if (nameExists) {
name2 = "in" + portNumber++;
}
}
ExternalToolStringReplacementViewer newViewer = new ExternalToolStringReplacementViewer(
name2);
synchronized (stringReplacementViewList) {
stringReplacementViewList.add(newViewer);
addStringReplacementViewer(StringReplacementPanel.this, inputEditPanel,
newViewer, elementLabels);
inputEditPanel.revalidate();
inputEditPanel.repaint();
}
}
});
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BorderLayout());
buttonPanel.add(addInputPortButton, BorderLayout.EAST);
this.add(buttonPanel, BorderLayout.SOUTH);
}