use of org.apache.pivot.wtk.DropAction in project pivot by apache.
the class JSONViewer method drop.
public DropAction drop(Manifest dragContent) {
DropAction dropAction = null;
try {
FileList fileList = dragContent.getFileList();
if (fileList.getLength() == 1) {
File file = fileList.get(0);
JSONSerializer jsonSerializer = new JSONSerializer();
@SuppressWarnings("resource") FileInputStream fileInputStream = null;
try {
try {
fileInputStream = new FileInputStream(file);
setValue(jsonSerializer.readObject(fileInputStream));
} finally {
if (fileInputStream != null) {
fileInputStream.close();
}
}
} catch (Exception exception) {
Prompt.prompt(exception.getMessage(), window);
}
window.setTitle(WINDOW_TITLE + " - " + file.getName());
dropAction = DropAction.COPY;
} else {
Prompt.prompt("Multiple files not supported.", window);
}
} catch (IOException exception) {
Prompt.prompt(exception.getMessage(), window);
}
return dropAction;
}
Aggregations