List of usage examples for org.apache.commons.vfs FileName SEPARATOR
String SEPARATOR
To view the source code for org.apache.commons.vfs FileName SEPARATOR.
Click Source Link
From source file:org.cfeclipse.cfml.views.explorer.vfs.view.VFSView.java
/** * Creates the Drag & Drop DragSource for items being dragged from the tree. * /* ww w. j a v a 2s. c o m*/ * @return the DragSource for the tree */ private DragSource createTreeDragSource(final Tree tree) { DragSource dragSource = new DragSource(tree, DND.DROP_COPY); // | DND.DROP_MOVE // Transfer data type is text (file URI) dragSource.setTransfer(new Transfer[] { FileTransfer.getInstance() }); //dragSource.setTransfer(new Transfer[] { RTFTransfer.getInstance() }); dragSource.addDragListener(new DragSourceListener() { TreeItem[] dndSelection = null; String[] sourceNames = null; public void dragStart(DragSourceEvent event) { dndSelection = tree.getSelection(); sourceNames = null; event.doit = dndSelection.length > 0; isDragging = true; // processedDropFiles = null; } public void dragFinished(DragSourceEvent event) { dragSourceHandleDragFinished(event, sourceNames); dndSelection = null; sourceNames = null; isDragging = false; // processedDropFiles = null; //TODO try { // handleDeferredRefresh(); // } catch (Exception e) { // debug ("createTreeDragSource.dragFinished " + e); // } } public void dragSetData(DragSourceEvent event) { if (dndSelection == null || dndSelection.length == 0) return; //if (! FileTransfer.getInstance().isSupportedType(event.dataType)) return; if (!FileTransfer.getInstance().isSupportedType(event.dataType)) { //debug("createTreeDragSource.dragSetData File transfer data type is required"); return; } sourceNames = new String[dndSelection.length]; FileObject file = null; String uri = null; String connectionId = null; for (int i = 0; i < dndSelection.length; i++) { uri = (String) dndSelection[i].getData(TREEITEMDATA_URI); connectionId = (String) dndSelection[i].getData(TREEITEMDATA_CONNECTIONID); try { file = resolveURI(uri, connectionId); } catch (FileSystemException e) { debug(e); //"createTreeDragSource.dragSetData " + continue; } /* * In Order for FileTransfer to Work, the name must begin w/ * / in UNIX systems */ sourceNames[i] = Os.isFamily(Os.OS_FAMILY_UNIX) ? FileName.SEPARATOR + file.toString() : file.toString(); System.out.println("createTreeDragSource.dragSetData file path=" + sourceNames[i]); } //sourceNames[0] = connectionId; fSourceConnectionId = connectionId; event.data = sourceNames; } }); return dragSource; }
From source file:org.cfeclipse.cfml.views.explorer.vfs.view.VFSView.java
/** * Creates the Drag & Drop DragSource for items being dragged from the table. * /*from ww w. j a v a 2s . com*/ * @return the DragSource for the table */ private DragSource createTableDragSource(final Table table) { DragSource dragSource = new DragSource(table, DND.DROP_COPY); // | DND.DROP_MOVE // transfer type is text data (file URI) dragSource.setTransfer(new Transfer[] { FileTransfer.getInstance() }); dragSource.addDragListener(new DragSourceListener() { TableItem[] dndSelection = null; String[] sourceNames = null; public void dragStart(DragSourceEvent event) { dndSelection = table.getSelection(); sourceNames = null; event.doit = dndSelection.length > 0; isDragging = true; } public void dragFinished(DragSourceEvent event) { dragSourceHandleDragFinished(event, sourceNames); dndSelection = null; sourceNames = null; isDragging = false; //TODO try { // handleDeferredRefresh(); // } catch (Exception e) { // debug("createTableDragSource.dragFinished " + e); // } } public void dragSetData(DragSourceEvent event) { if (dndSelection == null || dndSelection.length == 0) return; if (!FileTransfer.getInstance().isSupportedType(event.dataType)) { error("createTableDragSource.dragSetData File Transfer data type text is required."); return; } // Cannot put Objects in the transfer event data field, they must be path // and begin with / in UNIX sourceNames = new String[dndSelection.length + 1]; String connectionId = ""; for (int i = 1; i < dndSelection.length; i++) { FileObject file = (FileObject) dndSelection[i].getData(TABLEITEMDATA_FILE); connectionId = (String) dndSelection[i].getData(TABLEITEMDATA_CONNECTIONID); /* * In Order for FileTransfer to Work, the name must begin w/ * / in UNIX systems */ sourceNames[i] = Os.isFamily(Os.OS_FAMILY_UNIX) ? FileName.SEPARATOR + file.toString() : file.toString(); System.out.println( "createTableDragSource::dragSetData: sourceNames [" + i + "] path= " + sourceNames[i]); } sourceNames[0] = connectionId; event.data = sourceNames; } }); return dragSource; }
From source file:org.cfeclipse.cfml.views.explorer.vfs.view.VFSView.java
/** * Gets filesystem root entries/* w w w. ja v a2s. c om*/ * @param fsManager * @return an array of Files corresponding to the root directories on the platform, * may be empty but not null */ FileObject[] getRoots(FileSystemManager fsManager) throws FileSystemException { /* * On JDK 1.22 only... */ // return File.listRoots(); FileObject[] roots = null; // FileObject[] newRequest = null; /* * On JDK 1.1.7 and beyond... * -- PORTABILITY ISSUES HERE -- */ if (System.getProperty("os.name").indexOf("Windows") != -1) { Vector /* of FileObject */ list = new Vector(); list.add(fsManager.resolveFile(DRIVE_A)); for (char i = 'c'; i <= 'z'; ++i) { //FileObject drive = new FileObject(i + ":" + FileName.SEPARATOR); FileObject drive = fsManager.resolveFile(i + ":" + FileName.SEPARATOR); if (VFSUtil.isDirectory(drive) && drive.exists()) { list.add(drive); if (initial && i == 'c') { setCurrentDirectory(drive); setCurrentConnectionId(drive.getName().toString()); initial = false; } } } roots = (FileObject[]) list.toArray(new FileObject[list.size()]); VFSUtil.sortFiles(roots); //return roots; } else { FileObject root = fsManager.resolveFile(FileName.SEPARATOR); if (initial) { setCurrentDirectory(root); setCurrentConnectionId(root.getName().toString()); initial = false; } roots = new FileObject[] { root }; } return roots; //newRequest; }
From source file:org.sonatype.gshell.commands.vfs.ListDirectoryCommand.java
private void listChildren(final IO io, final FileObject dir) throws Exception { assert io != null; assert dir != null; FileObject[] files;// w w w. jav a 2 s . co m if (includeHidden) { files = dir.getChildren(); } else { FileFilter filter = new FileFilter() { public boolean accept(final FileSelectInfo selection) { assert selection != null; try { return !selection.getFile().isHidden(); } catch (FileSystemException e) { throw new RuntimeException(e); } } }; files = dir.findFiles(new FileFilterSelector(filter)); } ConsoleReader reader = new ConsoleReader(io.streams.in, io.out, io.getTerminal()); reader.setPaginationEnabled(false); List<String> names = new ArrayList<String>(files.length); List<FileObject> dirs = new LinkedList<FileObject>(); for (FileObject file : files) { String fileName = file.getName().getBaseName(); if (FileObjects.hasChildren(file)) { fileName += FileName.SEPARATOR; if (recursive) { dirs.add(file); } } names.add(fileName); file.close(); } if (longList) { for (String name : names) { io.out.println(name); } } else { reader.printColumns(names); } if (!dirs.isEmpty()) { for (FileObject subdir : dirs) { io.out.println(); io.out.print(subdir.getName().getBaseName()); io.out.print(":"); listChildren(io, subdir); } } dir.close(); }