RISE UI: Select ZIP file
Created: 2012-03-05 22:10:17
Last updated: 2012-03-05 22:11:41
This workflow ask the user to select a ZIP file on his own computer.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (0)
Titles (0)
Descriptions (0)
Dependencies (0)
Processors (8)
Name |
Type |
Description |
SelectModelZipFile |
localworker |
Scriptimport java.awt.CardLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.filechooser.FileFilter;
class FileExtFilter extends FileFilter {
public FileExtFilter(String ext, String label, boolean includeDir) {
this.ext = ext;
this.label = label;
this.includeDir = includeDir;
}
public String getDescription() {
return this.label;
}
public boolean accept(File file) {
if (file.isDirectory() && includeDir) {
return true;
} else {
return file.getName().endsWith(this.ext);
}
}
String ext, label;
boolean includeDir;
}
if (title == void) {
title = null;
}
if ((fileExtensions == void) || (fileExtensions == null)) {
fileExtensions = "";
}
if ((fileExtLabels == void) || (fileExtLabels == null)) {
fileExtLabels = "";
}
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(title);
String[] fileTypeList = fileExtensions.split(",");
String[] filterLabelList = fileExtLabels.split(",");
if (fileTypeList != null && filterLabelList != null && fileTypeList.length != filterLabelList.length) {
throw new RuntimeException("The list of extensions and file filter labels must be the same length");
}
// create the file filters
for (int i = 0; i < fileTypeList.length; i++) {
FileExtFilter filter = new FileExtFilter(fileTypeList[i], filterLabelList[i], true);
chooser.setFileFilter(filter);
}
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
selectedFile = file.getAbsolutePath();
|
AskOutputZipDirectory |
localworker |
Scriptimport javax.swing.JOptionPane;
answer = JOptionPane.showInputDialog(null, (message == void ? null : message), (title == void ? null : title), JOptionPane.QUESTION_MESSAGE);
|
zipExtensions |
stringconstant |
Valuezip |
ReadBinaryFile |
localworker |
Script public static byte[] getBytesFromFile (File file) throws IOException {
InputStream is = new FileInputStream(file);
// Get the size of the file
long length = file.length();
if (length > Integer.MAX_VALUE) {
// File is too large
}
// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file " + file.getName());
}
// Close the input stream and return bytes
is.close();
return bytes;
}
File zipfile = new File(fileurl);
byte[] filecontents = getBytesFromFile(zipfile);
|
SelectModelZipFileTitle |
stringconstant |
ValueSelect model archive (.zip) |
AskOutputZipDirectoryTitle |
stringconstant |
ValueModel output directory |
AskOutputZipDirectoryMessage |
stringconstant |
ValueEnter the output directory for model archive : |
zipExtensionsLabel |
stringconstant |
Valuezip |
Outputs (2)
Name |
Description |
ZipFile |
|
OutputZipDirectory |
|
Datalinks (8)
Source |
Sink |
zipExtensions:value |
SelectModelZipFile:fileExtensions |
SelectModelZipFileTitle:value |
SelectModelZipFile:title |
zipExtensionsLabel:value |
SelectModelZipFile:fileExtLabels |
AskOutputZipDirectoryTitle:value |
AskOutputZipDirectory:title |
AskOutputZipDirectoryMessage:value |
AskOutputZipDirectory:message |
SelectModelZipFile:selectedFile |
ReadBinaryFile:fileurl |
ReadBinaryFile:filecontents |
ZipFile |
AskOutputZipDirectory:answer |
OutputZipDirectory |
Coordinations (1)
Controller |
Target |
SelectModelZipFile |
AskOutputZipDirectory |
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