本文整理汇总了Java中org.eclipse.ui.internal.browser.IBrowserDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java IBrowserDescriptor类的具体用法?Java IBrowserDescriptor怎么用?Java IBrowserDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IBrowserDescriptor类属于org.eclipse.ui.internal.browser包,在下文中一共展示了IBrowserDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeCommandLine
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
/**
* Computes the full command-line that can be passed directly to {@link ProcessBuilder}.
*/
public static List<String> computeCommandLine(IBrowserDescriptor browser, String url) {
String params = browser.getParameters();
if (params == null) {
params = "";
}
boolean paramsHasUrlVariable = params.contains("%URL%");
if (paramsHasUrlVariable) {
// Quote the URL in case it has spaces
params = params.replaceAll("%URL%", '"' + url + '"');
}
final List<String> command = LaunchConfigurationProcessorUtilities.parseArgs(params);
command.add(0, browser.getLocation());
if (!paramsHasUrlVariable) {
// Cover the case where the user forgot the %URL%
command.add(url);
}
return command;
}
示例2: createBrowserDescriptor
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
/**
* Creates and saves a browser model object.
*
* @param browserName
* the name of the browser
* @param browserLocation
* the location, unescaped
* @return the new object
*/
public static IBrowserDescriptor createBrowserDescriptor(String browserName, String browserLocation) {
assert browserName != null;
assert browserLocation != null;
IBrowserDescriptorWorkingCopy browserWc = BrowserManager.getInstance().createExternalWebBrowser();
browserWc.setName(browserName);
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
// Special handling necessary to get smooth launches on Mac
browserWc.setLocation("/usr/bin/open");
browserWc.setParameters("-a \"" + browserLocation + "\" %URL%");
} else {
browserWc.setLocation(browserLocation);
browserWc.setParameters("%URL%");
}
return browserWc.save();
}
示例3: findChromeBrowser
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
/**
* @return a browser that looks like Chrome, or null
* @see #findChromeBrowserName()
*/
@SuppressWarnings("unchecked")
public static IBrowserDescriptor findChromeBrowser() {
BrowserManager browserManager = BrowserManager.getInstance();
List<IBrowserDescriptor> browsers = new ArrayList<IBrowserDescriptor>(browserManager.getWebBrowsers());
// Give the default web browser the highest priority
IBrowserDescriptor currentWebBrowser = browserManager.getCurrentWebBrowser();
if (currentWebBrowser != null) {
browsers.remove(currentWebBrowser);
browsers.add(0, currentWebBrowser);
}
for (IBrowserDescriptor browser : browsers) {
if (containsChromeRelatedString(browser.getName()) || containsChromeRelatedString(browser.getLocation())) {
return browser;
}
}
return null;
}
示例4: findBrowser
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static IBrowserDescriptor findBrowser(String browserName) {
List<IBrowserDescriptor> browsers = BrowserManager.getInstance().getWebBrowsers();
for (IBrowserDescriptor browser : browsers) {
if (browser.getName().equals(browserName)) {
return browser;
}
}
return null;
}
示例5: getBrowserNames
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
public static List<String> getBrowserNames() {
List<String> browserNames = new ArrayList<String>();
for (Object browserObj : BrowserManager.getInstance().getWebBrowsers()) {
IBrowserDescriptor browser = (IBrowserDescriptor) browserObj;
browserNames.add(browser.getName());
}
return browserNames;
}
示例6: launchBrowser
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的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();
}
}
示例7: chooseBrowser
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
/**
* Opens the dialog for the user to choose a browser.
*
* @param initialSelection optional
* @return the selected browser, or <code>null</code> if the dialog was
* canceled
*/
public static IBrowserDescriptor chooseBrowser(Shell shell,
IBrowserDescriptor initialSelection) {
ElementListSelectionDialog dialog = new BrowserSelectionDialog(shell,
initialSelection);
if (dialog.open() == Window.OK) {
return (IBrowserDescriptor) dialog.getFirstResult();
}
return null;
}
示例8: BrowserSelectionDialog
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
private BrowserSelectionDialog(Shell parent,
IBrowserDescriptor initialSelection) {
super(parent, new BrowserLabelProvider());
setTitle("Browser Selection");
setMessage("Choose a browser:");
List<IBrowserDescriptor> browers = getBrowsers();
setElements(browers.toArray(new IBrowserDescriptor[browers.size()]));
setHelpAvailable(false);
if (initialSelection != null) {
setInitialSelections(new Object[] {initialSelection});
}
}
示例9: buttonPressed
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
@Override
protected void buttonPressed(int buttonId) {
super.buttonPressed(buttonId);
if (buttonId == ADD_BROWSER_ID) {
new AddBrowserDialog(getShell()).open();
IBrowserDescriptor[] elements = getBrowsers().toArray(
new IBrowserDescriptor[0]);
setElements(elements);
setListElements(elements);
}
}
示例10: findChromeBrowserName
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
/**
* @return the name for a Chrome browser or empty string
* @see #findChromeBrowser()
*/
public static String findChromeBrowserName() {
IBrowserDescriptor browser = findChromeBrowser();
return browser != null ? browser.getName() : "";
}
示例11: getText
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
public String getText(Object element) {
IBrowserDescriptor browser = (IBrowserDescriptor) element;
return browser.getName();
}
示例12: getBrowsers
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static List<IBrowserDescriptor> getBrowsers() {
return BrowserManager.getInstance().getWebBrowsers();
}
示例13: BrowserSelectionBlock
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
public BrowserSelectionBlock(IBrowserDescriptor browser, Listener listener) {
super("Browser:", "&Browse...");
this.browser = browser;
this.listener = listener;
}
示例14: getBrowser
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
public IBrowserDescriptor getBrowser() {
return browser;
}
示例15: onButtonClicked
import org.eclipse.ui.internal.browser.IBrowserDescriptor; //导入依赖的package包/类
@Override
protected String onButtonClicked() {
IBrowserDescriptor selectedBrowser = BrowserSelectionDialog.chooseBrowser(
getShell(), browser);
return selectedBrowser != null ? selectedBrowser.getName() : null;
}