List of usage examples for org.apache.commons.vfs FileSystemException printStackTrace
public void printStackTrace()
From source file:org.pentaho.di.ui.job.entries.talendjobexec.JobEntryTalendJobExecDialog.java
public JobEntryInterface open() { Shell parent = getParent();//from ww w. j a va 2 s.c o m Display display = parent.getDisplay(); shell = new Shell(parent, props.getJobsDialogStyle()); props.setLook(shell); JobDialog.setShellImage(shell, jobEntry); ModifyListener lsMod = new ModifyListener() { public void modifyText(ModifyEvent e) { jobEntry.setChanged(); } }; changed = jobEntry.hasChanged(); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.Title")); int middle = props.getMiddlePct(); int margin = Const.MARGIN; // Filename line wlName = new Label(shell, SWT.RIGHT); wlName.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.Name.Label")); props.setLook(wlName); fdlName = new FormData(); fdlName.left = new FormAttachment(0, 0); fdlName.right = new FormAttachment(middle, -margin); fdlName.top = new FormAttachment(0, margin); wlName.setLayoutData(fdlName); wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wName); wName.addModifyListener(lsMod); fdName = new FormData(); fdName.left = new FormAttachment(middle, 0); fdName.top = new FormAttachment(0, margin); fdName.right = new FormAttachment(100, 0); wName.setLayoutData(fdName); Control lastControl = wName; // Filename line wlFilename = new Label(shell, SWT.RIGHT); wlFilename.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.Filename.Label")); props.setLook(wlFilename); fdlFilename = new FormData(); fdlFilename.left = new FormAttachment(0, 0); fdlFilename.top = new FormAttachment(lastControl, margin); fdlFilename.right = new FormAttachment(middle, -margin); wlFilename.setLayoutData(fdlFilename); wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER); props.setLook(wbFilename); wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse")); fdbFilename = new FormData(); fdbFilename.right = new FormAttachment(100, 0); fdbFilename.top = new FormAttachment(lastControl, 0); // fdbFilename.height = 22; wbFilename.setLayoutData(fdbFilename); wFilename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wFilename); wFilename.addModifyListener(lsMod); fdFilename = new FormData(); fdFilename.left = new FormAttachment(middle, 0); fdFilename.top = new FormAttachment(lastControl, margin); fdFilename.right = new FormAttachment(wbFilename, -margin); wFilename.setLayoutData(fdFilename); // Whenever something changes, set the tooltip to the expanded version: wFilename.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { wFilename.setToolTipText(jobMeta.environmentSubstitute(wFilename.getText())); } }); wbFilename.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { FileObject fileName = null; try { String curFile = wFilename.getText(); if (curFile.trim().length() > 0) { fileName = KettleVFS.getInstance().getFileSystemManager() .resolveFile(jobMeta.environmentSubstitute(wFilename.getText())); } else { fileName = KettleVFS.getInstance().getFileSystemManager() .resolveFile(Const.getUserHomeDirectory()); } } catch (FileSystemException ex) { fileName = KettleVFS.getInstance().getFileSystemManager() .resolveFile(Const.getUserHomeDirectory()); } VfsFileChooserDialog vfsFileChooser = Spoon.getInstance() .getVfsFileChooserDialog(fileName.getParent(), fileName); FileObject selected = vfsFileChooser.open(shell, null, EXTENSIONS, FILETYPES, VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE); wFilename.setText(selected != null ? selected.getURL().toString() : Const.EMPTY_STRING); } catch (FileSystemException ex) { ex.printStackTrace(); } } }); lastControl = wFilename; // Filename line Label wlClassName = new Label(shell, SWT.RIGHT); wlClassName.setText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.ClassName.Label")); props.setLook(wlClassName); FormData fdlClassName = new FormData(); fdlClassName.left = new FormAttachment(0, 0); fdlClassName.right = new FormAttachment(middle, -margin); fdlClassName.top = new FormAttachment(lastControl, margin); wlClassName.setLayoutData(fdlClassName); wClassName = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wClassName.setToolTipText(BaseMessages.getString(PKG, "JobEntryTalendJobExec.ClassName.Tooltip")); props.setLook(wClassName); wClassName.addModifyListener(lsMod); FormData fdClassName = new FormData(); fdClassName.left = new FormAttachment(middle, 0); fdClassName.top = new FormAttachment(lastControl, margin); fdClassName.right = new FormAttachment(100, 0); wClassName.setLayoutData(fdClassName); lastControl = wClassName; wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); FormData fd = new FormData(); fd.right = new FormAttachment(50, -10); fd.bottom = new FormAttachment(100, 0); fd.width = 100; wOK.setLayoutData(fd); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); fd = new FormData(); fd.left = new FormAttachment(50, 10); fd.bottom = new FormAttachment(100, 0); fd.width = 100; wCancel.setLayoutData(fd); BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wClassName); // Add listeners lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wCancel.addListener(SWT.Selection, lsCancel); wOK.addListener(SWT.Selection, lsOK); lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wName.addSelectionListener(lsDef); wFilename.addSelectionListener(lsDef); // Detect X or ALT-F4 or something that kills this window... shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); getData(); BaseStepDialog.setSize(shell); shell.open(); props.setDialogSize(shell, "JobEntryTalendJobExec.DialogSize"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return jobEntry; }
From source file:org.rzo.yajsw.config.YajswConfigurationImpl.java
private boolean fileExists(String file) { try {// w w w. java 2 s .c o m String current = System.getProperty("javax.xml.parsers.DocumentBuilderFactory"); System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); DefaultFileSystemManager fsManager = (DefaultFileSystemManager) VFS.getManager(); if (current != null) System.setProperty("javax.xml.parsers.DocumentBuilderFactory", current); else System.clearProperty("javax.xml.parsers.DocumentBuilderFactory"); FileObject f = VFSUtils.resolveFile(".", file); return f.exists(); } catch (FileSystemException e) { e.printStackTrace(); return false; } }