Java Code Examples for org.eclipse.swt.program.Program#execute()
The following examples show how to use
org.eclipse.swt.program.Program#execute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalLink.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public boolean doXRef(String refProvider, String refID){ try { int r = refID.lastIndexOf('.'); String ext = ""; //$NON-NLS-1$ if (r != -1) { ext = refID.substring(r + 1); } Program proggie = Program.findProgram(ext); if (proggie != null) { proggie.execute(refID); } else { if (Program.launch(refID) == false) { Runtime.getRuntime().exec(refID); } } } catch (Exception ex) { ElexisStatus status = new ElexisStatus(ElexisStatus.ERROR, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE, Messages.ExternalLink_CouldNotStartFile, ex); StatusManager.getManager().handle(status); } return true; }
Example 2
Source File: BrowserUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Launches the browser with the given name. This method does not use the Eclipse browser methods to launch the * browser since they do not properly pass quoted strings as a single argument. */ public static void launchBrowser(String browserName, String url) throws CoreException, IOException { IBrowserDescriptor browser = findBrowser(browserName); if (browser == null) { throw new CoreException( StatusUtilities.newErrorStatus("Could not find browser \"" + browserName + "\".", CorePlugin.PLUGIN_ID)); } // SystemBrowserDescriptors have no info in them... if (browser instanceof SystemBrowserDescriptor) { Program p = Program.findProgram("html"); boolean launched = false; if (p != null) { launched = p.execute(url); } if (!launched) { String msg = "Could not launch the default " + "browser, please configure a browser in " + "Preferences -> General -> Web Browsers"; MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell()); mb.setMessage(msg); mb.open(); throw new CoreException(StatusUtilities.newErrorStatus(msg, CorePlugin.PLUGIN_ID)); } } else { List<String> command = computeCommandLine(browser, url); new ProcessBuilder(command).start(); } }
Example 3
Source File: OpenUIDLogCommand.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Boolean execute(ExecutionEvent event) throws ExecutionException { final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final Optional<File> logFile = UIDesignerServerManager.getInstance().getLogFile(); if (logFile.isPresent() && logFile.get().exists()) { try { IFileStore fileStore = EFS.getLocalFileSystem().getStore(logFile.get().toURI()); final File localFile = fileStore.toLocalFile(EFS.NONE, Repository.NULL_PROGRESS_MONITOR); final long fileSize = localFile.length(); if (fileSize < MAX_FILE_SIZE) { IDE.openEditorOnFileStore(page, fileStore); } else { Program textEditor = Program.findProgram("log"); if (textEditor == null) { textEditor = Program.findProgram("txt"); } if (textEditor == null || !textEditor.execute(localFile.getAbsolutePath())) { showWarningMessage(localFile); } } return true; } catch (final Exception e) { BonitaStudioLog.error(e); return false; } } MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.unableTofindLogTitle, Messages.unableTofindLogMessage); return false; }
Example 4
Source File: OpenEngineLogCommand.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Boolean execute(final ExecutionEvent event) throws ExecutionException { final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final File logFile = BOSWebServerManager.getInstance().getBonitaLogFile(); if (logFile != null && logFile.exists()) { IFileStore fileStore; try { fileStore = EFS.getLocalFileSystem().getStore(logFile.toURI()); final File localFile = fileStore.toLocalFile(EFS.NONE, Repository.NULL_PROGRESS_MONITOR); final long fileSize = localFile.length(); if (fileSize < MAX_FILE_SIZE) { IDE.openEditorOnFileStore(page, fileStore); } else { Program textEditor = Program.findProgram("log"); if (textEditor == null) { textEditor = Program.findProgram("txt"); } if (textEditor != null) { final boolean success = textEditor.execute(localFile.getAbsolutePath()); if (!success) { showWarningMessage(localFile); } } else { showWarningMessage(localFile); } } return Boolean.TRUE; } catch (final Exception e) { BonitaStudioLog.error(e); return Boolean.FALSE; } } else { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.unableTofindLogTitle, Messages.unableTofindLogMessage); return Boolean.FALSE; } }
Example 5
Source File: DisplayLabDokumenteDialog.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
/** * Opens a document in a system viewer * * @param document */ private void openDocument(String docName){ Patient patient = ElexisEventDispatcher.getSelectedPatient(); try { if (this.docManager != null) { java.util.List<IOpaqueDocument> documentList = this.docManager.listDocuments(patient, null, docName, null, new TimeSpan( this.date, this.date), null); if (documentList == null || documentList.size() == 0) { throw new IOException(MessageFormat.format("Dokument {0} nicht vorhanden!", docName)); } int counter = 0; for (IOpaqueDocument document : documentList) { String fileExtension = null; try { MimeType docMimeType = new MimeType(document.getMimeType()); fileExtension = MimeTool.getExtension(docMimeType.toString()); } catch(MimeTypeParseException mpe) { fileExtension = FileTool.getExtension(document.getMimeType()); if(fileExtension == null) { fileExtension = FileTool.getExtension(docName); } } if(fileExtension == null) { fileExtension = ""; } File temp = File.createTempFile("lab" + counter, "doc." + fileExtension); //$NON-NLS-1$ //$NON-NLS-2$ temp.deleteOnExit(); byte[] b = document.getContentsAsBytes(); if (b == null) { throw new IOException("Dokument ist leer!"); } FileOutputStream fos = new FileOutputStream(temp); fos.write(b); fos.close(); Program proggie = Program.findProgram(FileTool.getExtension(fileExtension)); if (proggie != null) { proggie.execute(temp.getAbsolutePath()); } else { if (Program.launch(temp.getAbsolutePath()) == false) { Runtime.getRuntime().exec(temp.getAbsolutePath()); } } counter++; } } } catch (Exception ex) { SWTHelper.showError("Fehler beim Öffnen des Dokumentes", ex.getMessage()); } }