Select items from list
Created: 2010-03-30 14:04:45
This workflow pops up a window containing an input list of strings. The user is invited to select one or more strings for downstream processing.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Descriptions (1)
This workflow pops up a window containing an input list of strings. The user is invited to select one or more strings for downstream processing. |
Dependencies (0)
Processors (4)
Name |
Type |
Description |
selectworker |
beanshell |
Script/**
* Class representing the selected values of this beanshell processor
*/
class SelectedValues
{
ArrayList selectedValues;
SelectedValues()
{
selectedValues = new ArrayList();
}
synchronized void addToValues(ArrayList values)
{
for(int i = 0; i < values.size(); i ++)
selectedValues.add(values.get(i));
notifyAll();
}
synchronized ArrayList getValues()
{
while (selectedValues.size() == 0)
{
try
{
wait();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
return selectedValues;
}
}
/**
* Class representing the GUI for selecting the values to be
* processed by the remainder of the workflow.
*/
MultipleSelectWorkerGUI(ArrayList input, SelectedValues values)
{
JList list;
DefaultListModel listModel;
final String submitString = "Submit";
JButton submitButton;
int[] accessions;
SelectedValues selectedValues;
ArrayList inputdata;
void init()
{
super.frame = new JFrame("Select data for downstream analysis");
//Place window in centre of the screen
super.frame.setLocationRelativeTo(null);
pane = new JPanel();
super.frame.getContentPane().add(pane);
pane.setLayout(new BorderLayout());
// Set up input data available for selection
listModel = new DefaultListModel();
for (int i = 0; i < input.size(); i++)
listModel.addElement(input.get(i));
selectedValues = values;
//Create the list and put it in a scroll pane
list = new JList(listModel);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setSelectedIndex(0);
list.addListSelectionListener(this);
list.setVisibleRowCount(10);
list.setSize(800,500);
list.setFixedCellHeight(20);
JScrollPane listScrollPane = new JScrollPane(list);
submitButton = new JButton(submitString);
submitButton.setActionCommand(submitString);
submitButton.addActionListener(this);
//Create a panel
JPanel buttonPane = new JPanel();
buttonPane.add(submitButton);
buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
pane.add(listScrollPane, BorderLayout.CENTER);
pane.add(buttonPane, BorderLayout.PAGE_END);
//frame.setSize(800,500);
frame.setVisible(true);
frame.pack();
}
//This method is required by ListSelectionListener.
void valueChanged(ListSelectionEvent e)
{
if (!e.getValueIsAdjusting())
{
if (list.getSelectedIndex() == -1)
{
//No selection so disable fire button
submitButton.setEnabled(false);
}
else
{
//Selection made so enable the fire button.
submitButton.setEnabled(true);
}
}
}
// This method is called only if there is a valid selection
void actionPerformed(ActionEvent e)
{
ArrayList al = new ArrayList();
if (list.getSelectedIndices().length == 0)
{
// Nothing selected so disable firing
submitButton.setEnabled(false);
}
else
{
selectedItems = list.getSelectedIndices();
//System.out.println(selectedItems);
for(int i = 0; i < selectedItems.length; i++)
{
String str = listModel.elementAt(selectedItems[i]);
al.add(str);
}
selectedValues.addToValues(al);
super.frame.dispose();
}
}
init();
return this;
}
/**
* Wrapper for MultipleSelectWorkerGUI
*/
class WorkerWrapper extends Thread
{
SelectedValues selectedValues;
ArrayList inputdata;
WorkerWrapper(ArrayList input, SelectedValues v)
{
inputdata = inputList;
selectedValues = v;
}
void run()
{
msw = MultipleSelectWorkerGUI(inputdata, selectedValues);
}
}
sv = new SelectedValues();
wrapper = new WorkerWrapper(inputList, sv);
wrapper.start();
outputList = sv.getValues(); |
data |
stringconstant |
Valuea,b,c,d,e |
split |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
|
regex_value |
stringconstant |
Value, |
Beanshells (1)
Name |
Description |
Inputs |
Outputs |
selectworker |
|
inputList
|
outputList
|
Datalinks (4)
Source |
Sink |
split:split |
selectworker:inputList |
regex_value:value |
split:regex |
data:value |
split:string |
selectworker:outputList |
out |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (1)
(People/Groups)
Attributions (0)
(Workflows/Files)
None
Shared with Groups (0)
None
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment