Ejemplo n.º 1
0
  /** Reads all relevant extensions. */
  private void extensionReader() {
    final IExtensionRegistry registry = Platform.getExtensionRegistry();

    for (final IConfigurationElement ce :
        registry.getConfigurationElementsFor(InternalConstants.SCRIPT_ENGINES_EXTENSION_POINT)) {
      final String elementName = ce.getName();
      if (elementName.equals(InternalConstants.ENGINE_TAG)) {
        final String language = ce.getAttribute(InternalConstants.LANGUAGE_TAG);
        if (language == null || language.length() == 0) {
          LogUtils.error(
              ce, InternalConstants.LANGUAGE_TAG + " must be specified. Ignored"); // $NON-NLS-1$
          continue;
        }

        if (getEngines().get(language) != null) {
          LogUtils.error(ce, "Duplicate declaration of language '" + language + "'. Ignored.");
          continue;
        }

        final IScriptEngineDescriptor engine =
            IScriptEngineFactory.eINSTANCE.createScriptEngineDescriptor();
        engine.init(language, ce);
        getEngines().put(language, engine);
      } else {
        LogUtils.error(ce, "Unknown tag: '" + ce.getName() + "'");
      }
    }
  }
  public ModelEnablementDescriptor(IConfigurationElement e) {
    super(e);
    TargetRuntime rt = TargetRuntime.getRuntime(e);
    profileName = e.getAttribute("profile"); // $NON-NLS-1$
    description = e.getAttribute("description"); // $NON-NLS-1$
    String ref = e.getAttribute("ref"); // $NON-NLS-1$

    modelEnablements = new ModelEnablements(rt, id);

    if (ref != null) {
      String a[] = ref.split(":"); // $NON-NLS-1$
      rt = TargetRuntime.getRuntime(a[0]);
      String id = a[1];
      initializeFromTargetRuntime(rt, id);
    }

    for (IConfigurationElement c : e.getChildren()) {
      String object = c.getAttribute("object"); // $NON-NLS-1$
      String feature = c.getAttribute("feature"); // $NON-NLS-1$
      if (c.getName().equals("enable")) { // $NON-NLS-1$
        setEnabled(object, feature, true);
      } else if (c.getName().equals("disable")) { // $NON-NLS-1$
        setEnabled(object, feature, false);
      }
    }
  }
  @Override
  protected List<Object> getKeys() {

    List<Object> keys = new ArrayList<Object>();

    List<IConfigurationElement> proxyElements =
        ToolchainExtensions.getInstance().findExplorerProxyNodes(element);

    List<IConfigurationElement> children = new ArrayList<IConfigurationElement>();
    Collections.addAll(children, element.getChildren());

    for (IConfigurationElement proxy : proxyElements) {
      Collections.addAll(children, proxy.getChildren());
    }

    for (IConfigurationElement el : children) {

      if (ToolchainExtensions.NODE_EXTENSION_NAME.equals(el.getName())) {
        keys.add(new Key(el, null));
      }

      if (ToolchainExtensions.NODE_RESOURCE_EXTENSION_NAME.equals(el.getName())) {
        keys.add(new Key(el, null));
      }

      if (ToolchainExtensions.NODE_DYNAMIC_EXTENSION_NAME.equals(el.getName())) {
        try {
          IExplorerContentRetriever contentRetriever = contentRetrievers.get(el);
          if (contentRetriever == null) {
            contentRetriever = (IExplorerContentRetriever) el.createExecutableExtension("class");
            contentRetriever.initialize(el.getAttribute("id"), getNode().getContext());
            contentRetriever.addPropertyChangeListener(contentRetrieverListener);
            contentRetrievers.put(el, contentRetriever);
          }

          if (contentRetriever != null) {

            List<Object> contentList = contentRetriever.getChildren();
            if (contentList.isEmpty()) {

              String emptyNodeID = el.getAttribute("empty");
              if (emptyNodeID != null && !emptyNodeID.isEmpty()) {
                keys.add(new Key(el, null));
              }

            } else {
              for (Object content : contentList) {
                keys.add(new Key(el, content));
              }
            }
          }

        } catch (CoreException e) {
          e.printStackTrace();
        }
      }
    }

    return keys;
  }
  /** Called by IncQueryBasePlugin. */
  public static void initRegistry() {
    getContributedWellbehavingDerivedFeatures().clear();
    getContributedWellbehavingDerivedClasses().clear();
    getContributedWellbehavingDerivedPackages().clear();

    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IExtensionPoint poi;

    poi = reg.getExtensionPoint(IncQueryBasePlugin.WELLBEHAVING_DERIVED_FEATURE_EXTENSION_POINT_ID);
    if (poi != null) {
      IExtension[] exts = poi.getExtensions();

      for (IExtension ext : exts) {

        IConfigurationElement[] els = ext.getConfigurationElements();
        for (IConfigurationElement el : els) {
          if (el.getName().equals("wellbehaving-derived-feature")) {
            processWellbehavingExtension(el);
          } else {
            throw new UnsupportedOperationException(
                "Unknown configuration element "
                    + el.getName()
                    + " in plugin.xml of "
                    + el.getDeclaringExtension().getUniqueIdentifier());
          }
        }
      }
    }
  }
 @Override
 protected UnitCompilerDescriptor createDescriptor(IConfigurationElement extPointElement) {
   if (extPointElement.getName().equals("unitcompiler"))
     return new UnitCompilerDescriptor(extPointElement);
   else
     throw new IllegalArgumentException(
         "Was expecting unitcompiler tag, got " + extPointElement.getName());
 }
 /**
  * Creates a new locator proxy based on the given configuration element. Returns the new proxy, or
  * null if the element could not be created.
  */
 public static ProjectMetadataLocatorProxy createProxy(IConfigurationElement element) {
   ProjectMetadataLocatorProxy result = new ProjectMetadataLocatorProxy();
   result.fElement = element;
   if ("metadataLocator".equals(element.getName())) // $NON-NLS-1$
   return result;
   TapestryCore.log(
       EclipseMessages.projectMetaDataUnexpectedElement(
           element.getContributor().getName(), element.getName()));
   return null;
 }
  @Override
  public IExplorerNode getChild(Object key) {

    IConfigurationElement el = ((Key) key).element;
    Object value = ((Key) key).value;

    IExplorerNode node = null;

    if (ToolchainExtensions.NODE_EXTENSION_NAME.equals(el.getName())) {

      IExplorerNodeChildren children = new ConfigurationElementNodeChildren(el);
      node = new ConfigurationElementNode(getNode().getContext(), el, children);
    }

    if (ToolchainExtensions.NODE_RESOURCE_EXTENSION_NAME.equals(el.getName())) {

      IExplorerNodeChildren children = new ConfigurationElementNodeChildren(el);
      node = new ConfigurationElementEditorNode(getNode().getContext(), el, children);
    }

    if (ToolchainExtensions.NODE_DYNAMIC_EXTENSION_NAME.equals(el.getName())) {

      if (value == null) {
        String empty = el.getAttribute("empty");
        IConfigurationElement emptyElement =
            ToolchainExtensions.getInstance().findNodeElement(empty);
        if (emptyElement != null) {
          ExplorerNodeChildren children = new ConfigurationElementNodeChildren(emptyElement);
          node = getChild(new Key(emptyElement, children));
        }
      }

      ExplorerNodeChildren children = new ConfigurationElementNodeChildren(el);

      if (value instanceof IEditorInputResource) {
        node =
            new AlternativeNode(
                getNode().getContext(),
                el.getAttribute("editor"),
                (IEditorInputResource) value,
                children);
      }
      if (value instanceof IFile) {
        node = new AlternativeResourceNode(getNode().getContext(), (IFile) value);
      }
      if (value instanceof IProject) {
        node =
            new ConfigurationElementResourceNode(
                getNode().getContext(), el, (IResource) value, children);
        node.setName(((IProject) value).getName());
      }
    }

    return node;
  }
 private void processComponent(IConfigurationElement element) {
   if (!"component".equals(element.getName())) { // $NON-NLS-1$
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_InvalidElementStatus
                     + element.getName()
                     + ", plugin="
                     + element.getContributor().getName())); // $NON-NLS-1$
     return;
   }
   String id = element.getAttribute("id"); // $NON-NLS-1$
   String name = element.getAttribute("name"); // $NON-NLS-1$
   Category category = parseCategory(element);
   String description = parseDescription(element);
   String bundleId = parseBundleId(element);
   List<Dependency> dependencies = parseDependencies(element);
   if (id == null) {
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_InvalidIDStatus
                     + element.getContributor().getName()));
     return;
   } else if (_extensions.containsKey(id)) {
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_DuplicateIDStatus
                     + element.getContributor().getName()));
     return;
   } else if (name == null || name.length() == 0) {
     name = id;
   }
   ISwitchYardComponentExtension extension =
       new SwitchYardComponentExtension(
           id,
           name,
           category,
           element.getAttribute("scannerClass"),
           description,
           bundleId,
           dependencies); //$NON-NLS-1$
   _extensions.put(id, extension);
   _extensionsByCategory.get(category).add(extension);
 }
  @Override
  protected boolean readElement(IConfigurationElement element) {
    if (element.getName().equals(IWorkbenchRegistryConstants.TAG_TRANSFER)) {

      PreferenceTransferElement transfer = createPreferenceTransferElement(element);
      if (transfer != null) preferenceTransfers.add(transfer);
      return true;
    }

    // Allow settings transfers as well.

    return element.getName().equals(IWorkbenchRegistryConstants.TAG_SETTINGS_TRANSFER);
  }
Ejemplo n.º 10
0
  private void populateCategoriesAndTraceTypes() {
    if (fTraceTypes.isEmpty()) {
      // Populate the Categories and Trace Types
      IConfigurationElement[] config =
          Platform.getExtensionRegistry()
              .getConfigurationElementsFor(TmfTraceType.TMF_TRACE_TYPE_ID);
      for (IConfigurationElement ce : config) {
        String elementName = ce.getName();
        if (elementName.equals(TmfTraceType.TYPE_ELEM)) {
          String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR);
          fTraceTypeAttributes.put(traceTypeId, ce);
        } else if (elementName.equals(TmfTraceType.CATEGORY_ELEM)) {
          String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR);
          fTraceCategories.put(categoryId, ce);
        } else if (elementName.equals(TmfTraceType.EXPERIMENT_ELEM)) {
          String experimentTypeId = ce.getAttribute(TmfTraceType.ID_ATTR);
          fTraceTypeAttributes.put(experimentTypeId, ce);
        }
      }
      // create the trace types
      for (String typeId : fTraceTypeAttributes.keySet()) {
        IConfigurationElement ce = fTraceTypeAttributes.get(typeId);
        final String category = getCategory(ce);
        final String attribute = ce.getAttribute(TmfTraceType.NAME_ATTR);
        ITmfTrace trace = null;
        TraceElementType elementType = TraceElementType.TRACE;
        try {
          if (ce.getName().equals(TmfTraceType.TYPE_ELEM)) {
            trace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
          } else if (ce.getName().equals(TmfTraceType.EXPERIMENT_ELEM)) {
            trace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.EXPERIMENT_TYPE_ATTR);
            elementType = TraceElementType.EXPERIMENT;
          }
          if (trace == null) {
            break;
          }
          // Deregister trace as signal handler because it is only
          // used for validation
          TmfSignalManager.deregister(trace);

          final String dirString = ce.getAttribute(TmfTraceType.IS_DIR_ATTR);
          boolean isDir = Boolean.parseBoolean(dirString);

          TraceTypeHelper tt =
              new TraceTypeHelper(typeId, category, attribute, trace, isDir, elementType);
          fTraceTypes.put(typeId, tt);
        } catch (CoreException e) {
        }
      }
    }
  }
  @Override
  protected boolean readElement(IConfigurationElement element, boolean add) {
    if (element.getName().equals(TAG_RESOURCE)) {
      String packageURI = element.getAttribute(ATT_URI);
      if (packageURI == null) {
        logMissingAttribute(element, ATT_URI);
      } else if (element.getAttribute(ATT_LOCATION) == null) {
        logMissingAttribute(element, ATT_LOCATION);
      } else if (add) {
        Object previous =
            EPackage.Registry.INSTANCE.put(
                packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
        if (previous instanceof PluginClassDescriptor) {
          PluginClassDescriptor descriptor = (PluginClassDescriptor) previous;
          EcorePlugin.INSTANCE.log(
              "Both '"
                  + descriptor.element.getContributor().getName()
                  + "' and '"
                  + element.getContributor().getName()
                  + "' register a package for '"
                  + packageURI
                  + "'");
        }

        return true;
      } else {
        EPackage.Registry.INSTANCE.remove(packageURI);
        return true;
      }
    }

    return false;
  }
  @Override
  public IToolBehaviorProvider[] getAvailableToolBehaviorProviders() {
    if (toolBehaviorProviders == null) {
      DefaultBPMN2Editor editor = (DefaultBPMN2Editor) getDiagramEditor();
      TargetRuntime rt = editor.getTargetRuntime();
      IConfigurationElement[] config =
          Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.UI_EXTENSION_ID);
      Bpmn2ToolBehaviorProvider provider = null;
      try {
        for (IConfigurationElement e : config) {
          if (e.getName().equals("toolProvider")) { // $NON-NLS-1$
            String id = e.getAttribute("id"); // $NON-NLS-1$
            String runtimeId = e.getAttribute("runtimeId"); // $NON-NLS-1$
            if (rt != null && rt.getId().equals(runtimeId)) {
              String className = e.getAttribute("class"); // $NON-NLS-1$
              ClassLoader cl = rt.getRuntimeExtension().getClass().getClassLoader();
              Constructor ctor = null;
              Class providerClass = Class.forName(className, true, cl);
              ctor = providerClass.getConstructor(IDiagramTypeProvider.class);
              provider = (Bpmn2ToolBehaviorProvider) ctor.newInstance(this);
              break;
            }
          }
        }
      } catch (Exception ex) {
        Activator.logError(ex);
      }

      if (provider == null) provider = new Bpmn2ToolBehaviorProvider(this);
      toolBehaviorProviders = new IToolBehaviorProvider[] {provider};
    }
    return toolBehaviorProviders;
  }
 @Override
 public void addExtension(IExtensionTracker tracker, IExtension extension) {
   IConfigurationElement[] elements = extension.getConfigurationElements();
   for (int i = 0; i < elements.length; i++) {
     IConfigurationElement element = elements[i];
     if (element.getName().equals(tag)) {
       String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
       String file = element.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
       if (file == null || id == null) {
         Persistence.log(
             element,
             Persistence.ACTIVITY_IMAGE_BINDING_DESC,
             "definition must contain icon and ID"); //$NON-NLS-1$
         continue; // ignore - malformed
       }
       if (registry.getDescriptor(id) == null) { // first come, first serve
         ImageDescriptor descriptor =
             AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespace(), file);
         if (descriptor != null) {
           registry.put(id, descriptor);
           tracker.registerObject(extension, id, IExtensionTracker.REF_WEAK);
         }
       }
     }
   }
 }
Ejemplo n.º 14
0
 private static RSetup loadSetup(
     final String id,
     final Map<String, String> filter,
     final IConfigurationElement[] configurationElements) {
   try {
     for (int i = 0; i < configurationElements.length; i++) {
       final IConfigurationElement element = configurationElements[i];
       if (element.getName().equals(SETUP_ELEMENT_NAME)
           && id.equals(element.getAttribute(ID_ATTRIBUTE_NAME))) {
         final RSetup setup = new RSetup(id);
         if (filter != null && filter.containsKey("$os$")) { // $NON-NLS-1$
           setup.setOS(filter.get("$os$"), filter.get("$arch$")); // $NON-NLS-1$ //$NON-NLS-2$
         } else {
           setup.setOS(Platform.getOS(), Platform.getOSArch());
         }
         setup.setName(element.getAttribute(NAME_ATTRIBUTE_NAME));
         loadSetupBase(id, filter, configurationElements, setup);
         if (setup.getRHome() == null) {
           log(
               IStatus.WARNING,
               "Incomplete R setup: Missing R home for setup '" + id + "', the setup is ignored.",
               element);
           return null;
         }
         loadSetupLibraries(id, filter, configurationElements, setup);
         return setup;
       }
     }
   } catch (final Exception e) {
     LOGGER.log(
         new Status(IStatus.ERROR, PLUGIN_ID, "Error in R setup: Failed to load setup.", e));
   }
   return null;
 }
Ejemplo n.º 15
0
 @Override
 protected ResourceAdvisorDescriptor createFactory(IConfigurationElement conf) throws Exception {
   if (conf.getName().equals("advisor")) {
     return new ConfigurationFactory(conf);
   }
   return null;
 }
Ejemplo n.º 16
0
 /**
  * This gets the selection processor which in this case is a composite selection processor that
  * consists of all the extension point providers.
  *
  * @return a selection processor.
  */
 public static ISelectionProcessor getSelectionProcessor() {
   final CompositeSelectionProcessor processors = new CompositeSelectionProcessor();
   final IExtension[] extensions =
       Platform.getExtensionRegistry()
           .getExtensionPoint(SELECTION_PROCESSOR_EXTENSION_POINT_ID)
           .getExtensions();
   for (final IExtension extension : extensions) {
     final IConfigurationElement[] configurationElements = extension.getConfigurationElements();
     try {
       for (final IConfigurationElement configurationElement : configurationElements) {
         if (configurationElement.getName().equals(SELECTION_PROCESSOR)) {
           processors.addProcessor(
               (ISelectionProcessor) configurationElement.createExecutableExtension(CLASS));
         }
       }
     } catch (final CoreException e) {
       OpenInActivator.getDefault()
           .getLog()
           .log(
               Messages.error(
                   "selectionprocessor.error.message", new Object[] {}, e)); // $NON-NLS-1$
     }
   }
   return processors;
 }
Ejemplo n.º 17
0
 private static void loadSetupLibraries(
     final String id,
     final Map<String, String> filter,
     final IConfigurationElement[] configurationElements,
     final RSetup setup)
     throws Exception {
   for (int i = 0; i < configurationElements.length; i++) {
     final IConfigurationElement element = configurationElements[i];
     if (element.getName().equals(LIBRARY_ELEMENT_NAME)
         && id.equals(element.getAttribute(SETUP_ID_ATTRIBUTE_NAME))) {
       final String path = getLocation(element, filter);
       if (path == null) {
         continue;
       }
       final String groupId = element.getAttribute(GROUP_ATTRIBUTE_NAME);
       if (groupId == null || groupId.length() == 0 || groupId.equals("R_LIBS")) { // $NON-NLS-1$
         setup.getRLibs().add(path);
       } else if (groupId.equals("R_LIBS_SITE")) { // $NON-NLS-1$
         setup.getRLibsSite().add(path);
       } else if (groupId.equals("R_LIBS_USER")) { // $NON-NLS-1$
         setup.getRLibsUser().add(path);
       } else {
         log(
             IStatus.WARNING,
             "Invalid R setup element: "
                 + "Unknown library group '"
                 + groupId
                 + "', the library is ignored",
             element);
       }
     }
   }
 }
  public static List<ContextComputationStrategy> readContextComputationStrategies() {
    List<ContextComputationStrategy> strategies = new ArrayList<ContextComputationStrategy>();

    IExtensionPoint extensionPoint =
        Platform.getExtensionRegistry().getExtensionPoint(STRATEGIES_EXTENSION_POINT_ID);
    IExtension[] extensions = extensionPoint.getExtensions();
    for (IExtension extension : extensions) {
      IConfigurationElement[] configurationElements = extension.getConfigurationElements();
      for (IConfigurationElement element : configurationElements) {
        if (element.getName().equals(CONTEXT_COMPUTATION_STRATEGY)) {
          try {
            ContextComputationStrategy strategy =
                (ContextComputationStrategy) element.createExecutableExtension(ATTRIBUTE_CLASS);
            strategies.add(strategy);
          } catch (Throwable t) {
            StatusHandler.log(
                new Status(
                    IStatus.ERROR,
                    ContextCorePlugin.ID_PLUGIN,
                    NLS.bind(
                        "Cannot instantiate {0} from bundle {1}: {2}", //$NON-NLS-1$
                        new Object[] {
                          element.getAttribute(ATTRIBUTE_CLASS),
                          extension.getContributor().getName(),
                          t.getMessage()
                        }),
                    t));
          }
        }
      }
    }
    return strategies;
  }
Ejemplo n.º 19
0
 void processingExtensionPointByHand() {
   String xpid = "net.refractions.udig.project.ui.tool";
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint extensionPoint = registry.getExtensionPoint(xpid);
   if (extensionPoint == null) {
     throw new NullPointerException("Could not find extensionPoint:" + xpid);
   }
   for (IExtension extension : extensionPoint.getExtensions()) {
     for (IConfigurationElement element : extension.getConfigurationElements()) {
       String name = element.getName();
       System.out.println(name);
       if ("modalTool".equals(name)) {
         try {
           ModalTool tool = (ModalTool) element.createExecutableExtension("class");
           System.out.println(tool);
         } catch (CoreException e) {
           // Perhaps an error in the constructor?
           String message = "Could not create Modal tool " + element.getAttribute("class");
           Status status =
               new Status(IStatus.ERROR, extension.getContributor().getName(), message, e);
           Activator.getDefault().getLog().log(status);
         }
       }
     }
   }
 }
Ejemplo n.º 20
0
  private synchronized void ensurePagesRegistered() {
    if (fPageDescriptors != null) {
      return;
    }

    ArrayList<CleanUpTabPageDescriptor> result = new ArrayList<CleanUpTabPageDescriptor>();

    IExtensionPoint point =
        Platform.getExtensionRegistry().getExtensionPoint(DartUI.ID_PLUGIN, EXTENSION_POINT_NAME);
    IConfigurationElement[] elements = point.getConfigurationElements();
    for (int i = 0; i < elements.length; i++) {
      IConfigurationElement element = elements[i];

      if (TABPAGE_CONFIGURATION_ELEMENT_NAME.equals(element.getName())) {
        result.add(new CleanUpTabPageDescriptor(element));
      }
    }

    fPageDescriptors = result.toArray(new CleanUpTabPageDescriptor[result.size()]);
    Arrays.sort(
        fPageDescriptors,
        new Comparator<CleanUpTabPageDescriptor>() {
          @Override
          public int compare(CleanUpTabPageDescriptor o1, CleanUpTabPageDescriptor o2) {
            String name1 = o1.getName();
            String name2 = o2.getName();
            return Collator.getInstance()
                .compare(
                    name1.replaceAll("&", ""),
                    name2.replaceAll(
                        "&", "")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
          }
        });
  }
Ejemplo n.º 21
0
  /** Read command descriptors from extension points. */
  private void initializeCreationCommandDescriptors() {

    creationCommandDescriptors = new HashMap<Object, CreationCommandDescriptor>();
    // Reading data from plugins
    IConfigurationElement[] configElements =
        Platform.getExtensionRegistry()
            .getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID);

    CreationCommandExtensionFactory extensionReader = new CreationCommandExtensionFactory();

    for (IConfigurationElement ele : configElements) {
      CreationCommandDescriptor desc;
      try {
        if (CreationCommandExtensionFactory.CREATION_COMMAND_EXTENSIONPOINT.equals(ele.getName())) {
          desc = extensionReader.createCreationCommand(ele);
          creationCommandDescriptors.put(desc.commandId, desc);
        }
      } catch (ExtensionException e) {
        Activator.getDefault()
            .getLog()
            .log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e));
        PapyrusTrace.error(
            IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING,
            this,
            "Initialization creation command problem " + e);
      }
    }
    PapyrusTrace.trace(
        IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING,
        this,
        "" + creationCommandDescriptors.size() + " creationCommands loaded");
  }
Ejemplo n.º 22
0
 private static void getConfigurationElementsPaths(
     final Set<String> result, final String path, final IConfigurationElement[] elements) {
   if (elements.length == 0) {
     if (!result.add(path)) {
       System.err.println(
           "Error while collecting registry paths. Adding "
               + path
               + " twice."); //$NON-NLS-1$ //$NON-NLS-2$
       // Commented, because that pollutes the log!
       //				for (final String str : result) {
       //					if (path.equals(str)) {
       //						System.err.println(str);
       //					} else {
       //						System.out.println(str);
       //					}
       //				}
     }
     return;
   }
   for (final IConfigurationElement element : elements) {
     final String subPath =
         path
             + "<"
             + element.getName()
             + " "
             + getAttributes(element)
             + "/>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     getConfigurationElementsPaths(result, subPath, element.getChildren());
   }
 }
 /** readElement() */
 protected void readElement(IConfigurationElement element) {
   if (element.getName().equals(tagName)) {
     String namespace = element.getAttribute(ATT_NAME_SPACE);
     if (namespace != null) {
       Bundle bundle =
           Platform.getBundle(element.getDeclaringExtension().getContributor().getName());
       if (attributeNames.length == 1) {
         String className = element.getAttribute(attributeNames[0]);
         if (className != null) {
           nsKeyedExtensionRegistry.put(namespace, className, bundle);
         }
       } else {
         HashMap map = new HashMap();
         for (int i = 0; i < attributeNames.length; i++) {
           String attributeName = attributeNames[i];
           String className = element.getAttribute(attributeName);
           if (className != null && className.length() > 0) {
             map.put(attributeName, className);
           }
         }
         nsKeyedExtensionRegistry.put(namespace, map, bundle);
       }
     }
   }
 }
Ejemplo n.º 24
0
  /** Loads the extension for the source code view. */
  public void loadExtensions() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(EXTENSION_POINT_ID);
    if (point == null) {
      return;
    }

    IExtension[] extensions = point.getExtensions();
    if (extensions.length > 0) {
      IExtension ex = extensions[0];
      IConfigurationElement[] elems = ex.getConfigurationElements();
      for (IConfigurationElement h : elems) {
        Object obj = null;
        if (h.getName().compareTo("sourcecodeview") == 0) {

          try {
            obj = h.createExecutableExtension("class");
          } catch (CoreException e) {
            e.printStackTrace();
          }
          if (obj instanceof SourceCodeView) {
            sourceCodeView = (SourceCodeView) obj;
          }
        }
      }
    }
  }
Ejemplo n.º 25
0
  protected List<IScmAccessValidator> getAllValidators() {
    List<IScmAccessValidator> validators = new ArrayList<IScmAccessValidator>();

    IConfigurationElement[] configurationElements =
        Platform.getExtensionRegistry()
            .getConfigurationElementsFor(IScmAccessValidator.EXTENSION_POINT_ID);
    for (IConfigurationElement v : configurationElements) {
      if (!"validator".equals(v.getName())) {
        continue;
      }
      try {
        Object extension = v.createExecutableExtension("class");
        log.debug("Found SCM validator: {}", extension.getClass().getCanonicalName());

        if (!(extension instanceof IScmAccessValidator)) {
          throw new IllegalArgumentException(
              extension.getClass().getCanonicalName()
                  + " does not implement the IScmAccessValidator interface");
        }
        validators.add((IScmAccessValidator) extension);
      } catch (CoreException e) {
        log.error("Failed to instantiate SCM access validator, will be ignored", e);
      }
    }
    return validators;
  }
Ejemplo n.º 26
0
 private static void loadSetupBase(
     final String id,
     final Map<String, String> filter,
     final IConfigurationElement[] configurationElements,
     final RSetup setup)
     throws Exception {
   for (int i = 0; i < configurationElements.length; i++) {
     final IConfigurationElement element = configurationElements[i];
     if (element.getName().equals(BASE_ELEMENT_NAME)
         && id.equals(element.getAttribute(SETUP_ID_ATTRIBUTE_NAME))) {
       final String path = getLocation(element, filter);
       setup.setRHome(path);
       return;
     }
   }
   for (int i = 0; i < configurationElements.length; i++) {
     final IConfigurationElement element = configurationElements[i];
     if (element.equals(SETUP_ELEMENT_NAME)
         && id.equals(element.getAttribute(SETUP_ID_ATTRIBUTE_NAME))) {
       final String inheritId = element.getAttribute(INHERIT_BASE_ATTRIBUTE_NAME);
       if (inheritId != null) {
         loadSetupBase(inheritId, filter, configurationElements, setup);
       }
       return;
     }
   }
 }
Ejemplo n.º 27
0
  @Override
  public void processElement(IExtension extension, IConfigurationElement element) throws Exception {
    if (Login.LOGIN_DELEGATE_ELEMENT.equals(element.getName())) {
      ILoginDelegate loginDelegate;
      try {
        loginDelegate = (ILoginDelegate) element.createExecutableExtension("class"); // $NON-NLS-1$
      } catch (Exception e) {
        throw new EPProcessorException(e.getMessage(), extension, e);
      }

      if (this.loginDelegate != null)
        throw new EPProcessorException(
            "More than one plugin provide an extension to \""
                + getExtensionPointID()
                + "\": The plugin \""
                + contributingPluginId
                + "\" did already initialize loginDelegate and the plugin \""
                + extension.getNamespaceIdentifier()
                + "\" collides with this previous contribution!",
            extension); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

      this.contributingPluginId = extension.getNamespaceIdentifier();
      this.loginDelegate = loginDelegate;
    }
  }
Ejemplo n.º 28
0
  private IBreakpointActionPage getActionPage(IBreakpointAction breakpointAction) {
    IExtension[] actionExtensions = getBreakpointActionPageExtensions();

    IBreakpointActionPage actionPageResult = null;
    try {

      for (int i = 0; i < actionExtensions.length && actionPageResult == null; i++) {
        IConfigurationElement[] elements = actionExtensions[i].getConfigurationElements();
        for (int j = 0; j < elements.length && actionPageResult == null; j++) {
          IConfigurationElement element = elements[j];
          if (element.getName().equals(ACTION_PAGE_ELEMENT)) {
            if (element
                .getAttribute("actionType")
                .equals(breakpointAction.getIdentifier())) { // $NON-NLS-1$
              actionPageResult =
                  (IBreakpointActionPage) element.createExecutableExtension("class"); // $NON-NLS-1$
            }
          }
        }
      }

    } catch (CoreException e) {
    }
    return actionPageResult;
  }
 private IPortTemplateDesc addConfig(final IConfigurationElement element) {
   if (element.getName().equals(CodeGeneratorPortTemplatesRegistry.ATTR_TEMPLATE)) {
     final PortTemplateDescriptor desc = new PortTemplateDescriptor(element);
     if (!this.templateMap.containsKey(desc.getId())) {
       this.templateMap.put(desc.getId(), desc);
       final String[] ifaces = desc.getInterfaces();
       for (final String i : ifaces) {
         if (i == null) {
           continue;
         }
         Set<String> ids = this.repToIdMap.get(i);
         if (ids == null) {
           ids = new HashSet<String>();
           this.repToIdMap.put(i, ids);
         }
         ids.add(desc.getId());
       }
       return desc;
     } else {
       RedhawkCodegenActivator.logError(
           "Duplicate Code Generator registered with an ID of: " + desc.getId(), null);
     }
   }
   return null;
 }
 /*
  * Internal hook for unit testing.
  */
 public AbstractCriteriaDefinitionProvider[] getCriteriaDefinitionProviders() {
   if (null == criteriaDefinitionProviders) {
     List<AbstractCriteriaDefinitionProvider> providers = new ArrayList<>();
     IExtensionRegistry registry = Platform.getExtensionRegistry();
     IConfigurationElement[] elements =
         registry.getConfigurationElementsFor(EXTENSION_POINT_ID_CRITERIA_DEFINITION);
     for (int i = 0; i < elements.length; ++i) {
       IConfigurationElement elem = elements[i];
       if (elem.getName().equals(ELEMENT_NAME_CRITERIA_DEFINITION_PROVIDER)) {
         try {
           AbstractCriteriaDefinitionProvider provider =
               (AbstractCriteriaDefinitionProvider)
                   elem.createExecutableExtension(ATTRIBUTE_NAME_CLASS);
           providers.add(provider);
         } catch (CoreException e) {
           // log and skip
           String msg =
               "Error instantiating help keyword index provider class \""
                   + elem.getAttribute(ATTRIBUTE_NAME_CLASS)
                   + '"'; //$NON-NLS-1$
           HelpPlugin.logError(msg, e);
         }
       }
     }
     criteriaDefinitionProviders =
         providers.toArray(new AbstractCriteriaDefinitionProvider[providers.size()]);
   }
   return criteriaDefinitionProviders;
 }