public void fireFileObjectDoubleClicked(FileObject selectedItem) { if (fileDialogMode != VFS_DIALOG_SAVEAS) { // let's try drilling into the file as a new vfs root first String scheme = null; if (selectedItem.getName().getExtension().contains("jar")) { scheme = "jar:"; } else if (selectedItem.getName().getExtension().contains("zip")) { scheme = "zip:"; } else if (selectedItem.getName().getExtension().contains("gz")) { scheme = "gz:"; } else if (selectedItem.getName().getExtension().contains("war")) { scheme = "war:"; } else if (selectedItem.getName().getExtension().contains("ear")) { scheme = "ear:"; } else if (selectedItem.getName().getExtension().contains("sar")) { scheme = "sar:"; } else if (selectedItem.getName().getExtension().contains("tar")) { scheme = "tar:"; } else if (selectedItem.getName().getExtension().contains("tbz2")) { scheme = "tbz2:"; } else if (selectedItem.getName().getExtension().contains("tgz")) { scheme = "tgz:"; } else if (selectedItem.getName().getExtension().contains("bz2")) { scheme = "bz2:"; } if (scheme != null) { try { FileObject jarFileObject = selectedItem .getFileSystem() .getFileSystemManager() .resolveFile(scheme + selectedItem.getName().getURI()); vfsBrowser.resetVfsRoot(jarFileObject); updateParentFileCombo(jarFileObject); vfsBrowser.fileSystemTree.forceFocus(); } catch (FileSystemException e) { e.printStackTrace(); okPressed = true; hideCustomPanelChildren(); dialog.dispose(); } } else { okPressed = true; hideCustomPanelChildren(); dialog.dispose(); } } else { // anything? } }
public void resolveVfsBrowser() { FileObject newRoot = null; try { // newRoot = // rootFile.getFileSystem().getFileSystemManager().resolveFile(getSelectedFile().getName().getURI()); if (currentPanel != null) { newRoot = currentPanel.resolveFile(getSelectedFile().getName().getURI()); } } catch (FileSystemException e) { displayMessageBox(SWT.OK, Messages.getString("VfsFileChooserDialog.error"), e.getMessage()); } // if (newRoot != null && !newRoot.equals(vfsBrowser.getRootFileObject())) { if (newRoot != null) { vfsBrowser.resetVfsRoot(newRoot); } }
public void promptForNewVfsRoot() { boolean done = false; String defaultText = vfsBrowser.rootFileObject.getName().getURI(); String text = defaultText; while (!done) { if (text == null) { text = defaultText; } File fileRoots[] = File.listRoots(); String roots[] = new String[fileRoots.length]; for (int i = 0; i < roots.length; i++) { try { roots[i] = fileRoots[i].toURI().toURL().toExternalForm(); } catch (MalformedURLException e) { e.printStackTrace(); } } ComboBoxInputDialog textDialog = new ComboBoxInputDialog( Messages.getString("VfsFileChooserDialog.enterNewVFSRoot"), text, roots, 650, 100); //$NON-NLS-1$ text = textDialog.open(); if (text != null && !"".equals(text)) { // $NON-NLS-1$ try { vfsBrowser.resetVfsRoot(currentPanel.resolveFile(text)); done = true; } catch (FileSystemException e) { MessageBox errorDialog = new MessageBox(vfsBrowser.getDisplay().getActiveShell(), SWT.OK); errorDialog.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$ errorDialog.setMessage(e.getMessage()); errorDialog.open(); } } else { done = true; } } }
public void widgetSelected(SelectionEvent se) { if (se.widget == openFileCombo) { // String filePath = parentFoldersCombo.getItem(parentFoldersCombo.getSelectionIndex()); // vfsBrowser.selectTreeItemByName(filePath, true); try { // resolve the selected folder (without displaying access/secret keys in plain text) // FileObject newRoot = // rootFile.getFileSystem().getFileSystemManager().resolveFile(folderURL.getFolderURL(openFileCombo.getText())); FileObject newRoot = currentPanel.resolveFile(getSelectedFile().getName().getURI()); vfsBrowser.resetVfsRoot(newRoot); } catch (FileSystemException e) { } } else if (se.widget == okButton) { okPressed(); } else if (se.widget == folderUpButton) { try { FileObject newRoot = vfsBrowser.getSelectedFileObject().getParent(); if (newRoot != null) { vfsBrowser.resetVfsRoot(newRoot); vfsBrowser.setSelectedFileObject(newRoot); // make sure access/secret keys not displayed in plain text // String str = folderURL.setFolderURL(newRoot.getName().getURI()); openFileCombo.setText(newRoot.getName().getURI()); } } catch (Exception e) { // top of root } } else if (se.widget == newFolderButton) { promptForNewFolder(); } else if (se.widget == deleteFileButton) { MessageBox messageDialog = new MessageBox(se.widget.getDisplay().getActiveShell(), SWT.YES | SWT.NO); messageDialog.setText(Messages.getString("VfsFileChooserDialog.confirm")); // $NON-NLS-1$ messageDialog.setMessage( Messages.getString("VfsFileChooserDialog.deleteFile")); // $NON-NLS-1$ int status = messageDialog.open(); if (status == SWT.YES) { try { vfsBrowser.deleteSelectedItem(); } catch (FileSystemException e) { MessageBox errorDialog = new MessageBox(se.widget.getDisplay().getActiveShell(), SWT.OK); errorDialog.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$ errorDialog.setMessage(e.getMessage()); errorDialog.open(); } } // } else if (se.widget == changeRootButton) { // promptForNewVfsRoot(); } else if (se.widget == fileFilterCombo) { Runnable r = new Runnable() { public void run() { String filter = fileFilters[fileFilterCombo.getSelectionIndex()]; vfsBrowser.setFilter(filter); try { vfsBrowser.applyFilter(); } catch (FileSystemException e) { MessageBox mb = new MessageBox(newFolderButton.getShell(), SWT.OK); mb.setText( Messages.getString("VfsFileChooserDialog.errorApplyFilter")); // $NON-NLS-1$ mb.setMessage(e.getMessage()); mb.open(); } } }; BusyIndicator.showWhile(fileFilterCombo.getDisplay(), r); } else { okPressed = false; hideCustomPanelChildren(); dialog.dispose(); } }