本文整理汇总了Java中org.eclipse.swt.program.Program.findProgram方法的典型用法代码示例。如果您正苦于以下问题:Java Program.findProgram方法的具体用法?Java Program.findProgram怎么用?Java Program.findProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.program.Program
的用法示例。
在下文中一共展示了Program.findProgram方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImage
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
public Image loadImage(File file) {
if (OSExplorer.getInstance().isRoot(file)) {
return loadImage("drive.png");
} else if (file.isDirectory()) {
return loadImage("folder.png");
} else {
String extension = OSExplorer.getInstance().getExtension(file);
if (extension.equals("")) {
return loadImage("file.png");
} else {
Program program = Program.findProgram(extension);
if (program == null) {
return loadImage("file.png");
} else {
return loadImage(program);
}
}
}
}
示例2: launchURL
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
private static void launchURL(String s) {
Program program = Program.findProgram(".html");
if (program != null && program.getName().contains("Chrome")) {
try {
Field field = Program.class.getDeclaredField("command");
field.setAccessible(true);
String command = (String) field.get(program);
command = command.replaceAll("%[1lL]", s);
command = command.replace(" --", "");
PluginInitializer.getDefaultInterface().getUtilities().createProcess(command + " -incognito");
} catch (Exception e1) {
e1.printStackTrace();
Utils.launch(s);
}
} else {
Utils.launch(s);
}
}
示例3: isProgramInstalled
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
@Override
public boolean
isProgramInstalled(
String extension,
String name )
{
if ( !extension.startsWith( "." )){
extension = "." + extension;
}
Program program = Program.findProgram( extension );
return( program == null ? false:(program.getName().toLowerCase(Locale.US)
.contains(name.toLowerCase(Locale.US))));
}
示例4: createCompleteMessageDialog
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
/**
*
* void
*/
protected void createCompleteMessageDialog() {
boolean result = MessageDialog.openConfirm(getShell(),
UMLMessage.MESSAGE_COMPLETE_DOCUMENT_CREATION,//"문서산출물 생성완료",
fileLocation +
UMLMessage.MESSAGE_DOCUMENT_HAS_BEEN_CREATED);//" 문서가 생성되었습니다. 생성된 문서를 보시겠습니까?");
if( result ) {
File file = new File(fileLocation);
if( file.exists() ) {
Program program = Program.findProgram(file.getName().substring(file.getName().lastIndexOf(UICoreConstant.PROJECT_CONSTANTS__DOT)));
if (null != program) {
String string = file.getAbsolutePath().toString();
program.execute(string);
}
}
}
}
示例5: doXRef
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
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;
}
示例6: execute
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
/**
* Run a program to view an external file
*
* @param filename
*/
public void execute(String filename){
try {
int r = filename.lastIndexOf('.');
String ext = ""; //$NON-NLS-1$
if (r != -1) {
ext = filename.substring(r + 1);
}
Program proggie = Program.findProgram(ext);
if (proggie != null) {
proggie.execute(filename);
} else {
if (Program.launch(filename) == false) {
Runtime.getRuntime().exec(filename);
}
}
} catch (Exception ex) {
ExHandler.handle(ex);
SWTHelper.showError(Messages.NotesDetail_couldNotLaunch, ex.getMessage());
}
}
示例7: execute
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
public void execute(){
try {
String ext = StringConstants.SPACE; //""; //$NON-NLS-1$
File temp = createTemporaryFile(null);
Program proggie = Program.findProgram(ext);
if (proggie != null) {
proggie.execute(temp.getAbsolutePath());
} else {
if (Program.launch(temp.getAbsolutePath()) == false) {
Runtime.getRuntime().exec(temp.getAbsolutePath());
}
}
} catch (Exception ex) {
ExHandler.handle(ex);
SWTHelper.showError(Messages.DocHandle_runErrorHeading, ex.getMessage());
}
}
示例8: getSystemEditorImageDescriptor
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
/**
* Return the image descriptor of the system editor that is registered with
* the OS to edit files of this type. <code>null</code> if none can be
* found.
*/
private ImageDescriptor getSystemEditorImageDescriptor(String extension) {
Program externalProgram = null;
if (extension != null) {
externalProgram = Program.findProgram(extension);
}
if (externalProgram == null) {
return null;
}
return new EditorImageDescriptor(externalProgram);
}
示例9: launchBrowser
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
/**
* 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();
}
}
示例10: getImage
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
@Override
public Image getImage(Object element) {
if (element instanceof ProjectResource) {
ProjectResource proResource = (ProjectResource) element;
String fileName = proResource.getLabel();
if (proResource.isProject()) {
return projectImg;
} else if (proResource.isFolder()) {
return folderImg;
} else if (fileName.endsWith(".hsxliff")) {
return hsXLiffImg;
} else if (fileName.endsWith(".html")) {
return htmlImg;
} else {
int index = fileName.lastIndexOf(".");
if (index != -1) {
String extension = fileName.substring(index, fileName.length());
if (imgMap.containsKey(extension)) {
return imgMap.get(extension);
}
Program program = Program.findProgram(extension);
if (program != null) {
ImageData imageData = program.getImageData();
if (imageData != null) {
Image img = new Image(getShell().getDisplay(), imageData);
imgMap.put(extension, img);
return img;
}
}
}
}
}
return defaultImg;
}
示例11: isProgramInstalled
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
public boolean
isProgramInstalled(
String extension,
String name )
{
if ( !extension.startsWith( "." )){
extension = "." + extension;
}
Program program = Program.findProgram( extension );
return( program == null ? false:(program.getName().toLowerCase(Locale.US).indexOf( name.toLowerCase(Locale.US)) != -1));
}
示例12: getImage
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
@Override
public Image getImage(Object element) {
if (element instanceof ProjectResource) {
ProjectResource proResource = (ProjectResource) element;
String fileName = proResource.getLabel();
if (proResource.isProject()) {
return projectImg;
}else if (proResource.isFolder()) {
return folderImg;
}else if (fileName.endsWith(".hsxliff")) {
return hsXLiffImg;
}else if (fileName.endsWith(".html")) {
return htmlImg;
}else {
int index = fileName.lastIndexOf(".");
if (index != -1) {
String extension = fileName.substring(index, fileName.length());
if (imgMap.containsKey(extension)) {
return imgMap.get(extension);
}
Program program = Program.findProgram(extension);
if (program != null) {
ImageData imageData = program.getImageData();
if (imageData != null) {
Image img = new Image(getShell().getDisplay(), imageData);
imgMap.put(extension, img);
return img;
}
}
}
}
}
return defaultImg;
}
示例13: getFileType
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
public String getFileType(File file) {
String extension = getExtension(file);
if (extension.equals("Folder")) {
return "Folder";
} else if (extension.equals("")) {
return "File";
} else {
Program program = Program.findProgram(extension);
if (program == null) {
return "File " + extension;
} else {
return program.getName();
}
}
}
示例14: createMailTreeItems
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
private void createMailTreeItems(TreeItem currentRoot, SmtpMessagePart part)
{
if (part != null && part.getParts() != null)
{
Iterator<SmtpMessagePart> it = part.getParts().iterator();
while (it.hasNext())
{
SmtpMessagePart p = it.next();
TreeItem item = new TreeItem(currentRoot, SWT.NONE);
item.setText(p.getContentType());
item.setData(p);
if (SmimeUtilities.isEnvelopedData(p))
item.setImage(SWTHelper.loadImage("smime.gif")); //$NON-NLS-1$
else if (isSigned && "application/pkcs7-signature".equals(p.getContentType()))
item.setImage(SWTHelper.loadImage("smime_sig.gif")); //$NON-NLS-1$
else if (p.getFileName() != null && p.getFileName().lastIndexOf('.') > -1)
{
String fileName = p.getFileName();
String ext = fileName.substring(fileName.lastIndexOf('.')); //$NON-NLS-1$
Program program = Program.findProgram(ext);
if (program != null && program.getImageData() != null)
item.setImage(new Image(SWTHelper.getDisplay(), program.getImageData()));
else
item.setImage(SWTHelper.loadImage("attach.gif")); //$NON-NLS-1$
}
else
item.setImage(SWTHelper.loadImage("part.gif")); //$NON-NLS-1$
createMailTreeItems(item, p);
item.setExpanded(true);
}
}
}
示例15: openDocument
import org.eclipse.swt.program.Program; //导入方法依赖的package包/类
/**
* 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 ext = FileTool.getExtension(docName);
File temp = File.createTempFile("lab" + counter, "doc." + ext); //$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(ext));
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());
}
}