List of usage examples for org.apache.commons.vfs.util Os isFamily
public static boolean isFamily(final OsFamily family)
From source file:org.cfeclipse.cfml.views.explorer.vfs.view.VFSView.java
/** * Creates the toolbar/*from www . j a v a2 s . co m*/ * * @param shell the shell on which to attach the toolbar * @param layoutData the layout data */ private Control createToolBar(final Composite shell) { //, Object layoutData) { final ToolBar toolBar = new ToolBar(shell, SWT.FLAT); // toolBar.setLayoutData(layoutData); // New VFS ToolItem item = new ToolItem(toolBar, SWT.PUSH); item.setImage(iconCache.get(CFPluginImages.ICON_DRIVE_FTP));//.iconFile]); //item.setText(getResourceString("tool.New.vfs.text")); item.setToolTipText(getResourceString("tool.New.vfs.tip")); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { connectionAction.run(); } }); // Home item = new ToolItem(toolBar, SWT.PUSH); item.setImage(iconCache.get(CFPluginImages.ICON_HOME)); //item.setText(getResourceString("tool.home.text")); item.setToolTipText(getResourceString("tool.home.tip")); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { // Jump the file system home directory, some FS don't have homes String homeDir = getCurrentDirectory().getName().getScheme().equals("file") ? VFSUtil.USER_HOME : (String) getCurrentDirectory().getFileSystem().getAttribute("HOME_DIRECTORY"); // Build a URI from the home dir String uri = Os.isFamily(Os.OS_FAMILY_UNIX) ? getCurrentDirectory().getName().getRootURI() + homeDir : getCurrentDirectory().getName().getScheme() + ":///" + homeDir.replace('\\', '/'); FileObject fo = resolveURI(uri, getCurrentConnectionId()); if (fo.exists()) notifySelectedDirectory(fo, getCurrentConnectionId()); else VFSUtil.MessageBoxInfo(getResourceString("error.jump.home", new Object[] { homeDir })); } catch (FileSystemException ex) { FileObject fo; try { fo = resolveURI(fConnections.get(getCurrentConnectionId()).getURI().toString(), getCurrentConnectionId()); if (fo.exists()) notifySelectedDirectory(fo, getCurrentConnectionId()); else VFSUtil.MessageBoxInfo( getResourceString("error.jump.home", new Object[] { fo.getURL().toString() })); } catch (FileSystemException e1) { VFSUtil.MessageBoxInfo(ex.getMessage()); } } } }); // New folder item = new ToolItem(toolBar, SWT.PUSH); item.setImage(iconCache.get(CFPluginImages.ICON_FOLDER_NEW)); //item.setText(getResourceString("tool.New.folder.text")); item.setToolTipText(getResourceString("tool.New.folder.tip")); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { VFSUtil.newFolder(getCurrentDirectory()); } }); item = new ToolItem(toolBar, SWT.SEPARATOR); // Parent item = new ToolItem(toolBar, SWT.PUSH); item.setImage(iconCache.get(CFPluginImages.ICON_FOLDER_PARENT)); //item.setText(getResourceString("tool.Parent.tiptext")); item.setToolTipText(getResourceString("tool.Parent.tiptext")); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doParent(); } }); // Refresh item = new ToolItem(toolBar, SWT.PUSH); item.setImage(iconCache.get(CFPluginImages.ICON_REFRESH)); //item.setText(getResourceString("tool.Refresh.tiptext")); item.setToolTipText(getResourceString("tool.Refresh.tiptext")); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doRefresh(); } }); return toolBar; }
From source file:org.cfeclipse.cfml.views.explorer.vfs.view.VFSView.java
/** * Creates the Drag & Drop DragSource for items being dragged from the tree. * /*w ww . j a va 2 s.co 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. * //w w w .ja 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.sonatype.gshell.commands.vfs.EditCommand.java
private String getDefaultEditor() { if (Os.isFamily(Os.OS_FAMILY_WINDOWS)) { return "NOTEPAD"; } else if (Os.isFamily(Os.OS_FAMILY_UNIX)) { if (System.getenv("DISPLAY") != null) { String tmp = System.getenv("XEDITOR"); if (tmp != null) { return tmp; }/*from www . j a v a 2s .c o m*/ } String tmp = System.getenv("EDITOR"); if (tmp != null) { return tmp; } } throw new RuntimeException("Unable to determine the default editor command"); }