org.eclipse.ui.browser.IWebBrowser Java Examples

The following examples show how to use org.eclipse.ui.browser.IWebBrowser. 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: OpenAppAction.java    From codewind-eclipse with Eclipse Public License 2.0 8 votes vote down vote up
public static void openAppInBrowser(CodewindApplication app) {
	URL appRootUrl = app.getRootUrl();
	if (appRootUrl == null) {
		Logger.logError("The application could not be opened in the browser because the url is null: " + app.name); //$NON-NLS-1$
		return;
	}
	try {
		// Use the app's ID as the browser ID so that if this is called again on the same app,
		// the browser will be re-used
		IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
		IWebBrowser browser = browserSupport
				.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR,
						app.projectID, app.name, NLS.bind(Messages.BrowserTooltipApp, app.name));

		browser.openURL(appRootUrl);
	} catch (PartInitException e) {
		Logger.logError("Error opening app in browser", e); //$NON-NLS-1$
	}
}
 
Example #2
Source File: CoreUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static Control addLinkToDialog(Composite parent, String linkLabel, String linkUrl) {
	Link link = new Link(parent, SWT.WRAP);
	link.setText("<a>" + linkLabel + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
	link.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent event) {
			try {
				IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
				IWebBrowser browser = browserSupport.getExternalBrowser();
				URL url = new URL(linkUrl);
				browser.openURL(url);
			} catch (Exception e) {
				Logger.logError("An error occurred trying to open an external browser at: " + link, e); //$NON-NLS-1$
			}
		}
	});
	return link;
}
 
Example #3
Source File: ShowHelpCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        Properties globalProperties = PlatformUtil.getStudioGlobalProperties();
        String url = null;
        if (globalProperties != null) {
            url = globalProperties.getProperty(HELP_URL_PROPERTY);
        } else {
            url = "http://www.bonitasoft.com/bos_redirect.php?bos_redirect_id=74";
        }
        url = url.concat("&").concat(majorVersion());
        IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport()
                .createBrowser(IWorkbenchBrowserSupport.AS_EDITOR, BonitaPreferenceConstants.HELP_BROWSER_ID, "Quick Start", "");
        browser.openURL(new URL(url));

    } catch (Exception ex) {
        BonitaStudioLog.error(ex);
    }
    return null;
}
 
Example #4
Source File: OpenApplicationCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        URL url = getURL();

        IWebBrowser browser;
        browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser(IWorkbenchBrowserSupport.AS_EDITOR,
                BonitaPreferenceConstants.APPLICATION_BROWSER_ID, "Bonita Application", "");
        browser.openURL(url);

    } catch (Exception e) {
        BonitaStudioLog.error(e);
        ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                "error",
                "error starting server",
                Status.OK_STATUS);
    }

    return null;
}
 
Example #5
Source File: GroovyHelpLinkFactory.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void createGroovyHelpLink(final Composite parent) {
    final Link docLinkText = new Link(parent, SWT.NONE);
    docLinkText.setText(GROOVY_DOC_LINK);
    docLinkText.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {

            try {
                final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser(GROOVY_BROWSER_ID);
                browser.openURL(new URL(event.text));
            } catch (final Exception e) {
                BonitaStudioLog.error(e);
            }

        }
    });

}
 
Example #6
Source File: OpenBrowserUtil.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private static void internalOpen(final URL url, final boolean useExternalBrowser) {
	BusyIndicator.showWhile(null, new Runnable() {
		@Override
		public void run() {
			URL helpSystemUrl= PlatformUI.getWorkbench().getHelpSystem().resolve(url.toExternalForm(), true);
			try {
				IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
				IWebBrowser browser;
				if (useExternalBrowser)
					browser= browserSupport.getExternalBrowser();
				else
					browser= browserSupport.createBrowser(null);
				browser.openURL(helpSystemUrl);
			} catch (PartInitException ex) {
			}
		}
	});
}
 
Example #7
Source File: WorkbenchBrowserUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Opens an URL with the default settings (which will typically open in an internal browser with no toolbar/url
 * bar/etc).
 * 
 * @param url
 * @return
 */
public static IWebBrowser openURL(String url)
{
	try
	{
		IWorkbenchBrowserSupport workbenchBrowserSupport = PlatformUI.getWorkbench().getBrowserSupport();
		IWebBrowser webBrowser = workbenchBrowserSupport.createBrowser(null);
		if (webBrowser != null)
		{
			webBrowser.openURL(new URL(url));
		}
		return webBrowser;
	}
	catch (Exception e)
	{
		IdeLog.logError(UIPlugin.getDefault(), e);
	}
	return null;
}
 
Example #8
Source File: OpenBrowserUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static void internalOpen(final URL url, final boolean useExternalBrowser) {
	BusyIndicator.showWhile(null, new Runnable() {
		public void run() {
			URL helpSystemUrl= PlatformUI.getWorkbench().getHelpSystem().resolve(url.toExternalForm(), true);
			if (helpSystemUrl == null) { // can happen if org.eclipse.help.ui is not available
				return; // the resolve() method already wrote "Unable to instantiate help UI" to the log
			}
			try {
				IWorkbenchBrowserSupport browserSupport= PlatformUI.getWorkbench().getBrowserSupport();
				IWebBrowser browser;
				if (useExternalBrowser)
					browser= browserSupport.getExternalBrowser();
				else
					browser= browserSupport.createBrowser(null);
				browser.openURL(helpSystemUrl);
			} catch (PartInitException ex) {
				// XXX: show dialog?
				JavaPlugin.logErrorStatus("Opening Javadoc failed", ex.getStatus()); //$NON-NLS-1$
			}
		}
	});
}
 
Example #9
Source File: IDEUtil.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void openExternalBrowser(String urlStr) {
	try {
		IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
		IWebBrowser browser = browserSupport.getExternalBrowser();
		URL url = new URL(urlStr);
		browser.openURL(url);
	} catch (Exception e) {
		Logger.logError("An error occurred trying to open an external browser at: " + urlStr, e); //$NON-NLS-1$
	}
}
 
Example #10
Source File: WebBrowserFactory.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void openExteranlBrowser(final String urlAsString) throws MalformedURLException {
    final URL url = new URL(urlAsString);
    try {
        final IWebBrowser browser = createExternalBrowser();
        browser.openURL(url);
    } catch (final PartInitException e) {
        BonitaStudioLog.error("Failed to oepn browser to display contract constraint expression help content", e, ContractPlugin.PLUGIN_ID);
    }
}
 
Example #11
Source File: OpenBrowserOperation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void openBrowser() throws PartInitException {
    IWebBrowser browser = null;
    WebBrowserUtil.isInternalBrowserOperational = null;
    if (useInternalBrowser &&
            PlatformUI.getWorkbench().getBrowserSupport().isInternalWebBrowserAvailable()) {
        IWorkbenchWindow workbenchWindow = WebBrowserUIPlugin.getInstance().getWorkbench()
                .getActiveWorkbenchWindow();
        final IWorkbenchPage page = workbenchWindow.getActivePage();
        try {
            if (openAsView) {
                openAsView(page);
            } else {
                openAsEditor(page);
            }
        } catch (Exception e) {
            Trace.trace(Trace.SEVERE, "Error opening Web browser", e); //$NON-NLS-1$
        }
    } else if (browserIsSet()) {
        browser = externalBrowser;
        if (browser == null) {
            browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser(
                    IWorkbenchBrowserSupport.AS_EDITOR,
                    TYPE_ID, "", ""); //$NON-NLS-1$
        }
    }
    if (browser != null) {
        browser.openURL(url);
    }
    WebBrowserUtil.isInternalBrowserOperational = false;
    WebBrowserPreference.setBrowserChoice(WebBrowserPreference.EXTERNAL);
}
 
Example #12
Source File: SystemUtils.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Open a webpage in Eclipse's default browser.
 * 
 * @param url URL address of the webpage
 * @param id String id for the newly created browser view
 */
public static void openWebpageInEclipse(URL url, String id) {
    IWebBrowser browser;
    try {
        browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser(id);
        browser.openURL(url);
    } catch (Exception e) {
        Log.log(e);
    }
}
 
Example #13
Source File: SystemBrowserAdapter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Display arbitary url.
 * 
 * @param url
 */
public void displayURL( String url )
{
	// if ( !Program.launch( url ) )
	// {
	//			ViewerPlugin.logError( ViewerPlugin.getFormattedResourceString( "viewer.browser.systemBrowser.noprogramforurl", //$NON-NLS-1$
	// new Object[]{
	// url
	// } ),
	// null );
	// }

	// use WorkbenchBrowserSupport so we needn't to provide browser
	// configuration
	IWorkbenchBrowserSupport support = PlatformUI.getWorkbench( )
			.getBrowserSupport( );
	try
	{
		IWebBrowser browser = support.getExternalBrowser( );
		browser.openURL( new URL( url ) );
	}
	catch ( Exception e )
	{
		ViewerPlugin.logError( ViewerPlugin.getFormattedResourceString( "viewer.browser.systemBrowser.noprogramforurl", //$NON-NLS-1$
				new Object[]{
					url
				} ),
				null );
	}
}
 
Example #14
Source File: AbstractSelfHelpUI.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void displayURL(String url) throws Exception {
	try {
		IWebBrowser browser = getExternalBrowser();
		if (browser != null) {
			browser.openURL(new URL(url));
		}
	} catch (PartInitException pie) {
		ErrorUtil.displayErrorDialog(pie.getLocalizedMessage());
	}
}
 
Example #15
Source File: AbstractSelfHelpUI.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void displayURL(String url) throws Exception {
	try {
		IWebBrowser browser = getExternalBrowser();
		if (browser != null) {
			browser.openURL(new URL(url));
		}
	} catch (PartInitException pie) {
		ErrorUtil.displayErrorDialog(pie.getLocalizedMessage());
	}
}
 
Example #16
Source File: AbstractSelfHelpUI.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void displayURL(String url) throws Exception {
	try {
		IWebBrowser browser = getExternalBrowser();
		if (browser != null) {
			browser.openURL(new URL(url));
		}
	} catch (PartInitException pie) {
		ErrorUtil.displayErrorDialog(pie.getLocalizedMessage());
	}
}
 
Example #17
Source File: Exporter.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Opens visualize.html in the default browser
 * 
 * @throws PartInitException
 * @throws MalformedURLException
 */
private void display() throws PartInitException, MalformedURLException {
	// set to use external browser due to internal browser bug
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=501978
	final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser();
	browser.openURL(Paths.get(target, FILE_TO_OPEN_IN_BROWSER).toUri().toURL());
}
 
Example #18
Source File: WorkbenchBrowserUtil.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static IWebBrowser launchExternalBrowser(String url, String browserId)
{
	try
	{
		return launchExternalBrowser(new URL(url), browserId);
	}
	catch (MalformedURLException e)
	{
		IdeLog.logError(UIPlugin.getDefault(), e);
	}
	return null;
}
 
Example #19
Source File: ShowBrowserEditorAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IAction action) {
	try {
		IWorkbenchBrowserSupport workbenchBrowserSupport = PlatformUI.getWorkbench().getBrowserSupport();
		if (workbenchBrowserSupport.isInternalWebBrowserAvailable()) {
			IWebBrowser webBrowser = workbenchBrowserSupport.createBrowser(IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.STATUS, null, null, null);
			if (webBrowser != null) {
				webBrowser.openURL(null);
			}
		}
	} catch (PartInitException e) {
		IdeLog.logError(BrowserPlugin.getDefault(), e);
	}
}
 
Example #20
Source File: BrowserUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static IWebBrowser launchBrowser(String targetUrl) throws MalformedURLException, PartInitException {
  Workbench workbench = Workbench.getInstance();
  if (workbench == null) {
    throw new PartInitException("No workbench is available");
  }

  IWorkbenchBrowserSupport browserSupport = workbench.getBrowserSupport();

  URL url = new URL(targetUrl);

  IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, null, "GWT", "GWT");
  browser.openURL(url);
  return browser;
}
 
Example #21
Source File: ExampleModelOpener.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void openModelFiles(IProject project) {
	List<IFile> filesToOpen = Lists.newArrayList();
	addStatecharts(project, filesToOpen);

	if (filesToOpen == null || getPage() == null) {
		return;
	}
	Display.getDefault().asyncExec(() -> {
		try {
			for (IFile file : filesToOpen) {
				IDE.openEditor(getPage(), file, false);
			}

			if (online()) {
				String browserid = "org.eclipse.ui.browser.editor";
				String baseURL = "https://itemis.com/en/yakindu/state-machine/documentation/examples/example/";
				URL url = new URL((baseURL + project.getName().replace(".", "-")));
				final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser(browserid);
				browser.openURL(url);
			} else {
				openExampleReadme(project);
			}
		} catch (PartInitException | MalformedURLException e) {
			e.printStackTrace();
			return;
		}
	});
}
 
Example #22
Source File: ConnectorOutputWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Control doCreateControl(final Composite parent, final EMFDataBindingContext context) {
    final DefinitionResourceProvider messageProvider = getMessageProvider();
    final String outputsDescription = messageProvider.getOutputsDescription(getDefinition());

    scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL);
    scrolledComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    scrolledComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final AvailableExpressionTypeFilter leftFilter = new AvailableExpressionTypeFilter(new String[] {
            ExpressionConstants.VARIABLE_TYPE,
            ExpressionConstants.DOCUMENT_REF_TYPE });
    final AvailableExpressionTypeFilter rightFilter = new ConnectorOutputAvailableExpressionTypeFilter();

    final Composite mainComposite = new Composite(scrolledComposite, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(5, 5, 5, 0).create());

    if (!Strings.isNullOrEmpty(outputsDescription)) {
        final Link description = new Link(mainComposite, SWT.WRAP);
        description.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).hint(400, SWT.DEFAULT).create());
        description.setText(outputsDescription);
        description.addSelectionListener(new SelectionAdapter() {

            /*
             * (non-Javadoc)
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
                IWebBrowser browser;
                try {
                    browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser(HELP_BROWSER_ID);
                    browser.openURL(new URL(e.text));
                } catch (final PartInitException | MalformedURLException e1) {
                    BonitaStudioLog.error(e1);
                }

            }
        });
    }

    lineComposite = new WizardPageOperationsComposite(null, mainComposite, rightFilter, leftFilter, isPageFlowContext());
    lineComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 280).create());
    final IExpressionNatureProvider storageExpressionProvider = getStorageExpressionProvider();
    if (storageExpressionProvider != null) {
        lineComposite.setStorageExpressionNatureContentProvider(storageExpressionProvider);
    }
    lineComposite.setContext(context);
    lineComposite.setContext(getElementContainer());
    lineComposite.setEObject(getConnector());
    lineComposite.fillTable();

    scrolledComposite.setContent(mainComposite);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setMinSize(lineComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    return mainComposite;
}
 
Example #23
Source File: WebBrowserFactory.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected IWebBrowser createExternalBrowser() throws PartInitException {
    return PlatformUI.getWorkbench().getBrowserSupport().createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL,
            null,
            null,
            null);
}
 
Example #24
Source File: OpenTektonDashboardAction.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
  public void run() {
      if (conn == null) {
      	// should not be possible
      	Logger.logError("OpenTektonDashboardAction ran but no remote connection was selected"); //$NON-NLS-1$
	return;
}
      
      TektonDashboard tekton = conn.getTektonDashboard();
      if (tekton == null) {
      	// Should not happen since the action should not show if there is no dashboard
      	Logger.logError("OpenTektonDashboardAction ran but there is no tekton dashboard in the environment"); //$NON-NLS-1$
      	return;
      }
      
      if (!tekton.hasTektonDashboard()) {
      	Logger.logError("Tekton dashboard is not available: " + tekton.getTektonMessage()); //$NON-NLS-1$
      	String errorMsg = tekton.isNotInstalled() ? Messages.ActionOpenTektonDashboardNotInstalled : Messages.ActionOpenTektonDashboardOtherError;
      	MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.ActionOpenTektonDashboardErrorDialogTitle, errorMsg);
      	return;
      }

      URL url = tekton.getTektonUrl();
if (url == null) {
	Logger.logError("OpenTektonDashboardAction ran but could not get the url"); //$NON-NLS-1$
	return;
}

try {
	IWebBrowser browser = null;
	IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
	
	if (CoreUtil.isWindows()) {
		// Use the external browser if available since the dashboard does not display 
		// well in the internal browser on Windows
		browser = browserSupport.getExternalBrowser();
	}
	
	if (browser == null) {
		// Use the app's ID as the browser ID so that if this is called again on the same app,
		// the browser will be re-used
		browser = browserSupport
				.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR,
						conn.getConid() + "_tektonDashboard", conn.getName(), NLS.bind(Messages.BrowserTooltipTektonDashboard, conn.getName()));
	}

	browser.openURL(url);
} catch (PartInitException e) {
	Logger.logError("Error opening the Tekton dashboard in browser", e); //$NON-NLS-1$
}
  }
 
Example #25
Source File: OpenPerfMonitorAction.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
  public void run() {
      if (app == null) {
      	// should not be possible
      	Logger.logError("OpenPerformanceMonitorAction ran but no application was selected"); //$NON-NLS-1$
	return;
}

      if (!app.isRunning()) {
      	CoreUtil.openDialog(true, Messages.OpenAppAction_CantOpenNotRunningAppTitle,
      			Messages.OpenAppAction_CantOpenNotRunningAppMsg);
      	return;
      }
      
      if (!app.hasPerfDashboard()) {
      	CoreUtil.openDialog(true, Messages.GenericActionNotSupported, Messages.PerfDashboardNotSupported);
      	return;
      }

      URL url = app.getPerfDashboardUrl();
if (url == null) {
	Logger.logError("OpenPerformanceMonitorAction ran but could not get the url"); //$NON-NLS-1$
	return;
}

try {
	IWebBrowser browser = null;
	IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
	
	if (CoreUtil.isWindows()) {
		// Use the external browser if available since the performance page does not display 
		// well in the internal browser on Windows
		browser = browserSupport.getExternalBrowser();
	}
	
	if (browser == null) {
		// Use the app's ID as the browser ID so that if this is called again on the same app,
		// the browser will be re-used
		browser = browserSupport
				.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR,
						app.projectID + "_" + CoreConstants.PERF_MONITOR, app.name, NLS.bind(Messages.BrowserTooltipPerformanceMonitor, app.name));
	}

	browser.openURL(url);
} catch (PartInitException e) {
	Logger.logError("Error opening the performance dashboard in browser", e); //$NON-NLS-1$
}
  }
 
Example #26
Source File: OpenAppMonitorAction.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
  public void run() {
      if (app == null) {
      	// should not be possible
      	Logger.logError("OpenAppMonitorAction ran but no application was selected"); //$NON-NLS-1$
	return;
}

      if (!app.isRunning()) {
      	CoreUtil.openDialog(true, Messages.OpenAppAction_CantOpenNotRunningAppTitle,
      			Messages.OpenAppAction_CantOpenNotRunningAppMsg);
      	return;
      }

      URL url = app.getMetricsDashboardUrl();
if (url == null) {
	// this should not happen
	Logger.logError("OpenAppMonitorAction ran but could not construct the url"); //$NON-NLS-1$
	return;
}

      app.confirmMetricsAvailable();
      if (!app.hasMetricsDashboard()) {
      	CoreUtil.openDialog(true, Messages.GenericActionNotSupported, Messages.AppMonitorNotSupported);
      	return;
      }

try {
	IWebBrowser browser = null;
	IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
	
	if (CoreUtil.isWindows()) {
		// Use the external browser if available since the page does not display 
		// well in the internal browser on Windows
		browser = browserSupport.getExternalBrowser();
	}
	
	if (browser == null) {
		// Use the app's ID as the browser ID so that if this is called again on the same app,
		// the browser will be re-used
		browser = browserSupport
				.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR,
						app.projectID + "_" + CoreConstants.VIEW_MONITOR, app.name, NLS.bind(Messages.BrowserTooltipAppMonitor, app.name));
	}

       browser.openURL(url);
} catch (PartInitException e) {
	Logger.logError("Error opening the metrics dashboard in browser", e); //$NON-NLS-1$
}
  }
 
Example #27
Source File: CodewindConnectionComposite.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void createControl() {
       GridLayout layout = new GridLayout();
       layout.numColumns = 2;
       layout.marginHeight = 20;
	layout.marginWidth = 8;
	layout.horizontalSpacing = 7;
	layout.verticalSpacing = 7;
       this.setLayout(layout);
       
       createLabel(Messages.CodewindConnectionComposite_ConnNameLabel, this, 1);
       connNameText = createConnText(this, SWT.NONE, 1);
      
       createLabel(Messages.CodewindConnectionComposite_UrlLabel, this, 1);
       connURLText = createConnText(this, SWT.NONE, 1);
       
       createLabel(Messages.CodewindConnectionComposite_UserLabel, this, 1);
       connUserText = createConnText(this, SWT.NONE, 1);
       
       createLabel(Messages.CodewindConnectionComposite_PasswordLabel, this, 1);
       connPassText = createConnText(this, SWT.PASSWORD, 1);
       
       new Label(this, SWT.NONE).setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1));
	
	Link learnMoreLink = new Link(this, SWT.NONE);
	learnMoreLink.setText("<a>" + Messages.RegMgmtLearnMoreLink + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
	learnMoreLink.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false, 1, 1));
	
	learnMoreLink.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent event) {
			try {
				IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
				IWebBrowser browser = browserSupport.getExternalBrowser();
				URL url = new URL(UIConstants.REMOTE_SETUP_URL);
				browser.openURL(url);
			} catch (Exception e) {
				Logger.logError("An error occurred trying to open an external browser at: " + UIConstants.TEMPLATES_INFO_URL, e); //$NON-NLS-1$
			}
		}
	});

	// Add Context Sensitive Help
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, CodewindUIPlugin.MAIN_CONTEXTID);

       initialize();
       connNameText.setFocus();
}
 
Example #28
Source File: OpenBrowserOperation.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public OpenBrowserOperation withExternalBrowser(final IWebBrowser externalBrowser) {
    this.externalBrowser = externalBrowser;
    return this;
}
 
Example #29
Source File: ExploreBusinessDataModelHandler.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private IWebBrowser getBrowser() throws PartInitException {
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    return support.getExternalBrowser();
}
 
Example #30
Source File: AbstractSelfHelpUI.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
private IWebBrowser getExternalBrowser() throws PartInitException {
	IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
	return support.getExternalBrowser();
}