/**
  * Handle calls <i>from</i> Javascript functions on the browser. (This is called by reflection by
  * JavaFx so there won't be any apparent usages for this method.)
  *
  * @param functionId
  * @param argument
  */
 public void call(String functionId, String argument) {
   try {
     IConfigurationElement element =
         BrowserExtensions.getExtension(
             BrowserExtensions.EXTENSION_ID_BROWSER_TO_ECLIPSE,
             functionId,
             view.getEngine().locationProperty().get());
     if (element != null) {
       IBrowserToEclipseFunction function =
           (IBrowserToEclipseFunction)
               WorkbenchPlugin.createExtension(element, BrowserExtensions.ELEMENT_CLASS);
       function.call(argument);
     } else {
       StatusManager.getManager()
           .handle(
               new Status(
                   IStatus.ERROR,
                   IdeUiPlugin.PLUGIN_ID,
                   "Could not instantiate browser function extension: " + functionId));
     }
   } catch (CoreException ex) {
     StatusManager.getManager()
         .handle(
             new Status(
                 IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "Could not find dashboard extension", ex));
     return;
   }
 }
 public void setClient(WebView view) {
   this.view = view;
   this.engine = view.getEngine();
   JSObject window = (JSObject) engine.executeScript("window");
   window.setMember("ide", this);
   Collection<IEclipseToBrowserFunction> onLoadFunctions =
       new ArrayList<IEclipseToBrowserFunction>();
   IConfigurationElement[] extensions =
       BrowserExtensions.getExtensions(
           BrowserExtensions.EXTENSION_ID_ECLIPSE_TO_BROWSER,
           null,
           view.getEngine().locationProperty().get());
   for (IConfigurationElement element : extensions) {
     try {
       String onLoad = element.getAttribute(BrowserExtensions.ELEMENT_ONLOAD);
       if (onLoad != null && onLoad.equals("true")) {
         onLoadFunctions.add(
             (IEclipseToBrowserFunction)
                 WorkbenchPlugin.createExtension(element, BrowserExtensions.ELEMENT_CLASS));
       }
     } catch (CoreException ex) {
       StatusManager.getManager()
           .handle(
               new Status(
                   IStatus.ERROR,
                   IdeUiPlugin.PLUGIN_ID,
                   "Could not instantiate browser element provider extension.",
                   ex));
       return;
     }
   }
   callOnBrowser(onLoadFunctions);
 }
示例#3
0
  /**
   * Loads the class that will perform the action associated with the given drop data.
   *
   * @param data the drop data
   * @return the viewer drop adapter
   */
  protected static IDropActionDelegate getPluginAdapter(PluginTransferData data)
      throws CoreException {

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    String adapterName = data.getExtensionId();
    IExtensionPoint xpt =
        registry.getExtensionPoint(
            PlatformUI.PLUGIN_ID, IWorkbenchRegistryConstants.PL_DROP_ACTIONS);
    IExtension[] extensions = xpt.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
      IConfigurationElement[] configs = extensions[i].getConfigurationElements();
      if (configs != null && configs.length > 0) {
        for (int j = 0; j < configs.length; j++) {
          String id = configs[j].getAttribute("id"); // $NON-NLS-1$
          if (id != null && id.equals(adapterName)) {
            return (IDropActionDelegate) WorkbenchPlugin.createExtension(configs[j], ATT_CLASS);
          }
        }
      }
    }
    return null;
  }
  private static void runStartupExtension(IConfigurationElement configurationElement) {
    try {
      Object object = WorkbenchPlugin.createExtension(configurationElement, ELEMENT_CLASS);
      if (!(object instanceof IIdeUiStartup)) {
        StatusHandler.log(
            new Status(
                IStatus.ERROR,
                UiPlugin.PLUGIN_ID,
                "Could not load "
                    + object.getClass().getCanonicalName()
                    + " must implement "
                    + IIdeUiStartup.class.getCanonicalName()));
        return;
      }

      IIdeUiStartup startup = (IIdeUiStartup) object;
      startup.lazyStartup();
    } catch (CoreException e) {
      StatusHandler.log(
          new Status(IStatus.ERROR, UiPlugin.PLUGIN_ID, "Could not load startup extension", e));
    }
  }