/**
  * Gets the icon.
  *
  * @param e IConfigurationElement
  * @param attribute name of icon
  * @return icon of algorithm
  */
 private static Image getIcon(IConfigurationElement e, String attribute) {
   try {
     Bundle bundle = Platform.getBundle(e.getContributor().getName());
     if (bundle != null) {
       URL resource = bundle.getResource(attribute);
       if (resource != null) {
         return new Image(Display.getDefault(), resource.openStream());
       }
     }
   } catch (InvalidRegistryObjectException e1) {
     e1.printStackTrace();
   } catch (IOException e1) {
     e1.printStackTrace();
   }
   return null;
 }
示例#2
0
  private void loadVariables() {
    try {
      IExtension[] extensions =
          Warlock2Plugin.getDefault().getExtensions("cc.warlock.rcp.macroVariables");
      for (int i = 0; i < extensions.length; i++) {
        IExtension ext = extensions[i];
        IConfigurationElement[] ce = ext.getConfigurationElements();

        for (int j = 0; j < ce.length; j++) {
          Object obj = ce[j].createExecutableExtension("classname");

          if (obj instanceof IMacroVariable) {
            IMacroVariable var = (IMacroVariable) obj;
            variables.put(var.getIdentifier(), var);
          }
        }
      }
    } catch (InvalidRegistryObjectException e) {
      e.printStackTrace();
    } catch (CoreException e) {
      e.printStackTrace();
    }
  }