blob: 49e5c67beacddf8d324aaec6edbb1dc47eea24f4 [file] [log] [blame]
{
"http://purl.org/dc/terms/rights": "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.",
"http://purl.org/dc/terms/license": {"@id": "http://www.apache.org/licenses/LICENSE-2.0"},
"classLoaderSharing" : "workflow",
"script" : "import java.awt.CardLayout;\nimport java.awt.Image;\nimport java.awt.Toolkit;\nimport java.io.File;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport javax.swing.ImageIcon;\nimport javax.swing.JEditorPane;\nimport javax.swing.JFileChooser;\nimport javax.swing.JLabel;\nimport javax.swing.JPanel;\nimport javax.swing.filechooser.FileFilter;\n\nclass FileExtFilter extends FileFilter {\n\n\tpublic FileExtFilter(String ext, String label, boolean includeDir) {\n\t\tthis.ext = ext;\n\t\tthis.label = label;\n\t\tthis.includeDir = includeDir;\n\t}\n\n\tpublic String getDescription() {\n\t\treturn this.label;\n\t}\n\n\tpublic boolean accept(File file) {\n\t\tif (file.isDirectory() && includeDir) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn file.getName().endsWith(this.ext);\n\t\t}\n\t}\n\n\tString ext, label;\n\n\tboolean includeDir;\n}\n\nif (title == void) {\n\ttitle = null;\n}\n\nif ((fileExtensions == void) || (fileExtensions == null)) {\n\tfileExtensions = \"\";\n}\n\nif ((fileExtLabels == void) || (fileExtLabels == null)) {\n\tfileExtLabels = \"\";\n}\n\nJFileChooser chooser = new JFileChooser();\nchooser.setDialogTitle(title);\n\nString[] fileTypeList = fileExtensions.split(\",\");\nString[] filterLabelList = fileExtLabels.split(\",\");\n\nif (fileTypeList != null && filterLabelList != null && fileTypeList.length != filterLabelList.length) {\n\tthrow new RuntimeException(\"The list of extensions and file filter labels must be the same length\");\n}\n\n// create the file filters\nfor (int i = 0; i < fileTypeList.length; i++) {\n\tFileExtFilter filter = new FileExtFilter(fileTypeList[i], filterLabelList[i], true);\n\tchooser.setFileFilter(filter);\n}\n\nchooser.showOpenDialog(null);\nFile file = chooser.getSelectedFile();\nselectedFile = file.getAbsolutePath();\n",
"localworkerName" : "net.sourceforge.taverna.scuflworkers.ui.SelectFileWorker",
"inputPorts" : [ {
"name" : "title",
"depth" : 0,
"type" : "String"
}, {
"name" : "fileExtensions",
"depth" : 0,
"type" : "String"
}, {
"name" : "fileExtLabels",
"depth" : 0,
"type" : "String"
} ],
"outputPorts" : [ {
"name" : "selectedFile",
"depth" : 0,
"granularDepth" : 0
} ],
"isAltered" : false
}