org.eclipse.ui.internal.browser.BrowserManager Java Examples

The following examples show how to use org.eclipse.ui.internal.browser.BrowserManager. 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: NodeJSDebugLauncher.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private boolean foundValidBrowser(String browserName){
	BrowserManager bm = BrowserManager.getInstance();
       if (bm != null){
        List<IBrowserDescriptor> browserList = bm.getWebBrowsers();
        if (browserList != null){
	        
	        int len = browserList.size();
	        
	        for (int i=0;i<len;i++){
	        	IBrowserDescriptor tempBrowser = browserList.get(i);
	        	if (tempBrowser != null && tempBrowser.getLocation() != null && 
	        			!tempBrowser.getLocation().trim().equals("")){ //$NON-NLS-1$
	        		// The location is not empty
	        		String name = tempBrowser.getName();
	        		if (name != null && name.equalsIgnoreCase(browserName)){
	        			return true;
	        		}
	        	}
	        }
        }
       }
       return false;
}
 
Example #2
Source File: BrowserUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #3
Source File: BrowserUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example #4
Source File: BrowserUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: ChromeExecutableTab.java    From wildwebdeveloper with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite res = new Composite(parent, SWT.NONE);
	res.setLayout(new GridLayout(2, false));

	new Label(res, SWT.NONE).setText(Messages.ChromeAttachTab_runWith);
	browserToUse = new ComboViewer(res, SWT.VERTICAL | SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
	browserToUse.setContentProvider(new ArrayContentProvider());
	browserToUse.setLabelProvider(new BrowserLabelProvider());
	proposals = new LinkedList<>();
	proposals.add(""); //$NON-NLS-1$
	proposals.addAll(BrowserManager.getInstance().getWebBrowsers().stream().filter(ChromeExecutableTab::isChrome).collect(Collectors.toList()));
	browserToUse.setInput(proposals);
	browserToUse.addPostSelectionChangedListener(e -> {
		setDirty(true);
		updateLaunchConfigurationDialog();
	});

	Link link = new Link(res, SWT.NONE);
	link.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
	link.setText(Messages.ChromeAttachTab_browserPreferences);
	link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
		Dialog dialog = PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.ui.browser.preferencePage", null, null); //$NON-NLS-1$
		dialog.open();
		List<IBrowserDescriptor> previous = proposals.stream().filter(IBrowserDescriptor.class::isInstance).map(IBrowserDescriptor.class::cast).collect(Collectors.toList());
		List<IBrowserDescriptor> next = BrowserManager.getInstance().getWebBrowsers();
		List<IBrowserDescriptor> toRemove = new LinkedList<>(previous);
		toRemove.removeAll(next);
		proposals.removeAll(toRemove);
		List<IBrowserDescriptor> toAdd = new LinkedList<>(next);
		toAdd.removeAll(previous);
		toAdd.removeIf(browser -> !isChrome(browser));
		proposals.addAll(toAdd);
		if (!(toAdd.isEmpty() && toRemove.isEmpty())) {
			browserToUse.refresh();
			if (browserToUse.getSelection().isEmpty()) {
				browserToUse.setSelection(new StructuredSelection("")); //$NON-NLS-1$
			}
		}
	}));
	
	setControl(res);
}
 
Example #6
Source File: BrowserSelectionDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private static List<IBrowserDescriptor> getBrowsers() {
  return BrowserManager.getInstance().getWebBrowsers();
}