public void setInitialSelection(final String filename) { fPathToSelect = null; Protocol.invokeLater( new Runnable() { public void run() { fFileToSelect = filename; } }); }
private void onConnected(final Throwable x) { Protocol.invokeLater( new Runnable() { public void run() { if (x != null) { terminate(x); closed = true; } if (closed) { try { if (out != null) out.close(); if (inp != null) inp.close(); } catch (IOException y) { Protocol.log("Cannot close pipe", y); } } else { started = true; start(); } } }); }
private void loadChildren(final FileInfo parent) { assert Thread.currentThread() == fDisplay.getThread(); if (parent.children_pending) return; assert parent.children == null; parent.children_pending = true; parent.children_error = null; Protocol.invokeLater( new Runnable() { public void run() { final IFileSystem fs = fFileSystem; if (fs == null || !canHaveChildren(parent)) { doneLoadChildren(parent, null, new FileInfo[0]); return; } if (parent.fullname == null) { fs.roots( new IFileSystem.DoneRoots() { public void doneRoots( IToken token, FileSystemException error, DirEntry[] entries) { if (error != null) { doneLoadChildren(parent, error, null); } else { final List<FileInfo> fileInfos = new ArrayList<FileInfo>(entries.length); for (DirEntry entry : entries) { FileInfo info = new FileInfo(); info.parent = parent; String name = entry.filename; int length = name.length(); if (length > 1 && (name.endsWith("\\") || name.endsWith("/"))) { name = name.substring(0, length - 1); } info.name = name; info.fullname = entry.longname != null ? entry.longname : entry.filename; info.isDir = entry.attrs != null ? entry.attrs.isDirectory() : false; if (!fDirectoriesOnly || info.isDir) { fileInfos.add(info); } } doneLoadChildren( parent, null, fileInfos.toArray(new FileInfo[fileInfos.size()])); } } }); return; } fs.opendir( parent.fullname, new IFileSystem.DoneOpen() { final List<FileInfo> fileInfos = new ArrayList<FileInfo>(); public void doneOpen( IToken token, FileSystemException error, final IFileHandle handle) { if (error != null) { doneLoadChildren(parent, error, null); return; } fs.readdir( handle, new IFileSystem.DoneReadDir() { public void doneReadDir( IToken token, FileSystemException error, DirEntry[] entries, boolean eof) { if (entries != null) { for (DirEntry entry : entries) { FileInfo info = new FileInfo(); info.parent = parent; info.name = entry.filename; info.fullname = entry.longname != null ? entry.longname : (new Path(parent.fullname).append(info.name).toString()); info.isDir = entry.attrs != null ? entry.attrs.isDirectory() : false; if (!fDirectoriesOnly || info.isDir) { fileInfos.add(info); } } } if (error != null || eof) { fs.close( handle, new IFileSystem.DoneClose() { public void doneClose(IToken token, FileSystemException error) { // ignore error } }); int size = fileInfos.size(); if (size == 0 && error != null) { doneLoadChildren(parent, error, null); } else { doneLoadChildren( parent, null, fileInfos.toArray(new FileInfo[size])); } } else { fs.readdir(handle, this); } } }); } }); } }); }