@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 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.º 3
0
 private synchronized void load() {
   if (commandFilters != null) return;
   commandFilters = new HashMap<String, Set<Pattern>>();
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint point = registry.getExtensionPoint("ca.uvic.chisel.logging.eclipse.loggers");
   IConfigurationElement[] elements = point.getConfigurationElements();
   for (IConfigurationElement loggerElement : elements) {
     String categoryID = loggerElement.getAttribute("categoryID");
     if (categoryID != null) {
       for (IConfigurationElement workbenchElement : loggerElement.getChildren("workbench")) {
         for (IConfigurationElement logElement : workbenchElement.getChildren("command")) {
           // get the filters for the command
           String filter = logElement.getAttribute("commandFilter");
           if (filter != null) {
             // create a pattern for the filter
             filter = filter.replace(".", "\\.");
             filter = filter.replace("*", ".*");
             Pattern pattern = Pattern.compile(filter);
             Set<Pattern> filters = commandFilters.get(categoryID);
             if (filters == null) {
               filters = new HashSet<Pattern>();
               commandFilters.put(categoryID, filters);
             }
             filters.add(pattern);
           }
         }
       }
     }
   }
 }
 /**
  * Returns this tab group's description in the given mode set.
  *
  * @param modes the set of modes
  * @return a description of the Launch Mode if available. If not available, attempts to return a
  *     description of the Launch Configuration. If no appropriate description is found an empty
  *     string is returned.
  */
 public String getDescription(Set<String> modes) {
   String description = null;
   if (fDescriptions == null) {
     fDescriptions = new HashMap<Set<String>, String>();
     IConfigurationElement[] children =
         fConfig.getChildren(IConfigurationElementConstants.LAUNCH_MODE);
     IConfigurationElement child = null;
     String mode = null;
     HashSet<String> set = null;
     for (int i = 0; i < children.length; i++) {
       child = children[i];
       mode = child.getAttribute(IConfigurationElementConstants.MODE);
       if (mode != null) {
         set = new HashSet<String>();
         set.add(mode);
       }
       description = child.getAttribute(IConfigurationElementConstants.DESCRIPTION);
       if (description != null) {
         fDescriptions.put(set, description);
       }
     }
   }
   description = fDescriptions.get(modes);
   if (description == null) {
     description = fConfig.getAttribute(IConfigurationElementConstants.DESCRIPTION);
   }
   return (description == null ? IInternalDebugCoreConstants.EMPTY_STRING : description);
 }
Ejemplo n.º 5
0
 /* (non-Javadoc)
  * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
  */
 @Override
 public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
     throws CoreException {
   id = config.getAttribute("id");
   factoryName = config.getAttribute("name");
   name = config.getAttribute("name");
 }
Ejemplo n.º 6
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.º 7
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;
 }
 void createBinding(IConfigurationElement element, String idAttributeName) {
   String type = element.getAttribute(CONTENT_TYPE_ID_ATTRIBUTE);
   String id = element.getAttribute(idAttributeName);
   if (id == null)
     logErrorMessage(
         Utilities.getFormattedString(
             "CompareUIPlugin.targetIdAttributeMissing", idAttributeName)); // $NON-NLS-1$
   if (type != null && id != null && fIdMap != null) {
     Object o = fIdMap.get(id);
     if (o != null) {
       IContentType ct = fgContentTypeManager.getContentType(type);
       if (ct != null) {
         if (fContentTypeBindings == null) fContentTypeBindings = new HashMap();
         List l = (List) fContentTypeBindings.get(ct);
         if (l == null) fContentTypeBindings.put(ct, l = new ArrayList());
         l.add(o);
       } else {
         logErrorMessage(
             Utilities.getFormattedString(
                 "CompareUIPlugin.contentTypeNotFound", type)); // $NON-NLS-1$
       }
     } else {
       logErrorMessage(
           Utilities.getFormattedString("CompareUIPlugin.targetNotFound", id)); // $NON-NLS-1$
     }
   }
 }
  /** Loads the built-in check configurations defined in plugin.xml or custom fragments. */
  private static void loadBuiltinConfigurations() {

    IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();

    IConfigurationElement[] elements =
        pluginRegistry.getConfigurationElementsFor(CONFIGS_EXTENSION_POINT);

    for (int i = 0; i < elements.length; i++) {
      String name = elements[i].getAttribute(XMLTags.NAME_TAG);
      String description = elements[i].getAttribute(XMLTags.DESCRIPTION_TAG);
      String location = elements[i].getAttribute(XMLTags.LOCATION_TAG);

      IConfigurationType configType = ConfigurationTypes.getByInternalName("builtin");

      Map<String, String> additionalData = new HashMap<String, String>();
      additionalData.put(
          BuiltInConfigurationType.CONTRIBUTOR_KEY, elements[i].getContributor().getName());

      List<ResolvableProperty> props = new ArrayList<ResolvableProperty>();
      IConfigurationElement[] propEls = elements[i].getChildren(XMLTags.PROPERTY_TAG);
      for (IConfigurationElement propEl : propEls) {
        props.add(
            new ResolvableProperty(
                propEl.getAttribute(XMLTags.NAME_TAG), propEl.getAttribute(XMLTags.VALUE_TAG)));
      }

      ICheckConfiguration checkConfig =
          new CheckConfiguration(
              name, location, description, configType, true, props, additionalData);
      sConfigurations.add(checkConfig);
    }
  }
  /**
   * Create an instance of EntityEditorPageSettings for an extension point entry.
   *
   * @param cfg The extension point config element.
   */
  public EntityEditorPageSettings(IExtension extension, IConfigurationElement cfg)
      throws EPProcessorException {
    try {
      this.pageFactory =
          (IEntityEditorPageFactory) cfg.createExecutableExtension("class"); // $NON-NLS-1$
    } catch (Exception e) {
      throw new EPProcessorException(
          "The class attribute was not valid ", extension, e); // $NON-NLS-1$
    }

    //		this.pageClass = cfg.getAttribute("class");
    this.editorID = cfg.getAttribute("editorID"); // $NON-NLS-1$
    if (editorID == null || "".equals(editorID)) // $NON-NLS-1$
    throw new EPProcessorException("The editorID is not defined.", extension); // $NON-NLS-1$
    String indexHintStr = cfg.getAttribute("indexHint"); // $NON-NLS-1$
    if (indexHintStr != null)
      try {
        this.indexHint = Integer.parseInt(indexHintStr);
      } catch (Exception e) {
        this.indexHint = Integer.MAX_VALUE / 2;
      }
    else this.indexHint = Integer.MAX_VALUE / 2;

    String smallIconPath = cfg.getAttribute("icon16x16"); // $NON-NLS-1$
    if (smallIconPath != null) {
      this.smallIconDesc =
          AbstractUIPlugin.imageDescriptorFromPlugin(cfg.getNamespaceIdentifier(), smallIconPath);
    }
    String iconPath = cfg.getAttribute("icon48x48"); // $NON-NLS-1$
    if (iconPath != null) {
      this.iconDesc =
          AbstractUIPlugin.imageDescriptorFromPlugin(cfg.getNamespaceIdentifier(), iconPath);
    }
    this.description = cfg.getAttribute("description"); // $NON-NLS-1$
  }
Ejemplo n.º 11
0
    private static void readBridge(IConfigurationElement element) {
      try {
        Object object = element.createExecutableExtension(BridgesExtensionPointReader.ATTR_CLASS);
        if (!(object instanceof AbstractContextStructureBridge)) {
          StatusHandler.log(
              new Status(
                  IStatus.WARNING,
                  ContextCorePlugin.ID_PLUGIN,
                  "Could not load bridge: "
                      + object.getClass().getCanonicalName()
                      + " must implement " //$NON-NLS-1$ //$NON-NLS-2$
                      + AbstractContextStructureBridge.class.getCanonicalName()));
          return;
        }

        AbstractContextStructureBridge bridge = (AbstractContextStructureBridge) object;
        if (element.getAttribute(BridgesExtensionPointReader.ATTR_PARENT_CONTENT_TYPE) != null) {
          String parentContentType =
              element.getAttribute(BridgesExtensionPointReader.ATTR_PARENT_CONTENT_TYPE);
          if (parentContentType != null) {
            bridge.setParentContentType(parentContentType);
          }
        }
        ContextCorePlugin.getDefault().addStructureBridge(bridge);
      } catch (Throwable e) {
        StatusHandler.log(
            new Status(
                IStatus.WARNING,
                ContextCorePlugin.ID_PLUGIN,
                "Could not load bridge extension",
                e)); //$NON-NLS-1$
      }
    }
Ejemplo n.º 12
0
  private static IAction[] createActions(IConfigurationElement[] elements) {
    List<String> idList = new ArrayList<String>();
    List<IAction> actionList = new ArrayList<IAction>();

    // add C wizards first
    for (int i = 0; i < elements.length; ++i) {
      IConfigurationElement element = elements[i];
      if (isCProjectWizard(element)) {
        String id = element.getAttribute(TAG_ID);
        if (id != null && !idList.contains(id)) {
          idList.add(id);
          IAction action = new OpenNewWizardAction(element);
          actionList.add(action);
        }
      }
    }
    // now add C++ wizards
    for (int i = 0; i < elements.length; ++i) {
      IConfigurationElement element = elements[i];
      if (isCCProjectWizard(element)) {
        String id = element.getAttribute(TAG_ID);
        if (id != null && !idList.contains(id)) {
          idList.add(id);
          IAction action = new OpenNewWizardAction(element);
          actionList.add(action);
        }
      }
    }

    return actionList.toArray(new IAction[actionList.size()]);
  }
Ejemplo n.º 13
0
  private static String[] getWizardIDs(IConfigurationElement[] elements) {
    List<String> idList = new ArrayList<String>();

    // add C wizards first
    for (int i = 0; i < elements.length; ++i) {
      IConfigurationElement element = elements[i];
      if (isCProjectWizard(element)) {
        String id = element.getAttribute(TAG_ID);
        if (id != null && !idList.contains(id)) {
          idList.add(id);
        }
      }
    }
    // now add C++ wizards
    for (int i = 0; i < elements.length; ++i) {
      IConfigurationElement element = elements[i];
      if (isCCProjectWizard(element)) {
        String id = element.getAttribute(TAG_ID);
        if (id != null && !idList.contains(id)) {
          idList.add(id);
        }
      }
    }

    return idList.toArray(new String[idList.size()]);
  }
  /** @return a list of uris of all xmi files registered */
  public static Map<URI, Map<String, String>> getExtensionURIS() {
    final Map<URI, Map<String, String>> ret = new LinkedHashMap<URI, Map<String, String>>();
    final IConfigurationElement[] files =
        Platform.getExtensionRegistry().getConfigurationElementsFor(FILE_EXTENSION);
    final URIConverter converter = new ResourceSetImpl().getURIConverter();
    for (final IConfigurationElement file : files) {
      final String filePath = file.getAttribute(FILEPATH_ATTRIBUTE);

      final IConfigurationElement[] children = file.getChildren(FILTER_ELEMENT);
      final Map<String, String> keyValuePairs = new LinkedHashMap<String, String>();
      for (final IConfigurationElement child : children) {
        final String key = child.getAttribute(FILTER_KEY_ATTRIBUTE);
        final String value = child.getAttribute(FILTER_VALUE_ATTRIBUTE);
        keyValuePairs.put(key, value);
      }

      URI uri;
      final String bundleName = file.getContributor().getName();
      final String path = bundleName + '/' + filePath;
      uri = URI.createPlatformPluginURI(path, false);
      if (converter.exists(uri, null)) {
        ret.put(uri, keyValuePairs);
      } else {
        uri = URI.createPlatformResourceURI(filePath, false);
        if (converter.exists(uri, null)) {
          ret.put(uri, keyValuePairs);
        }
      }
    }
    return ret;
  }
Ejemplo n.º 15
0
  private ToolbarDockableRegistry() {
    super();

    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
      return;
    }
    IConfigurationElement[] extensions =
        extensionRegistry.getConfigurationElementsFor(EXTENSION_POINT_ID);
    for (IConfigurationElement element : extensions) {
      String groupId = element.getAttribute(ATT_GROUP_ID);
      if (groupId == null || groupId.trim().length() == 0) {
        groupId = GLOBAL_GROUP_ID;
      }
      List<Dockable> compos = toolbarDockables.get(groupId);
      if (compos == null) {
        compos = new ArrayList<Dockable>();
      }

      try {
        JComponent compo = (JComponent) element.createExecutableExtension(ATT_CLASS);
        Dockable dockable = new ButtonDockable(element.getAttribute(ATT_ID), compo);
        createDockableDragger(dockable);
        compos.add(dockable);
      } catch (Exception e) {
        e.printStackTrace();
      }
      toolbarDockables.put(groupId, compos);
    }
  }
  private static void retrieveSortedComponent(
      List<String> componentIds,
      List<SortedComponentSetting> componentSetting,
      IConfigurationElement parent,
      String extension) {
    IConfigurationElement[] children = parent.getChildren(extension);
    for (IConfigurationElement element : children) {
      String id = element.getAttribute("id"); // $NON-NLS-1$
      if (componentIds.contains(id)) {
        continue; // filter
      }
      String name = element.getAttribute("name"); // $NON-NLS-1$
      String pattern = element.getAttribute("pattern"); // $NON-NLS-1$
      String description = element.getAttribute("description"); // $NON-NLS-1$
      int level = parserLevel(element.getAttribute("level")); // $NON-NLS-1$

      SortedComponentSetting setting = new SortedComponentSetting();
      setting.setId(id);
      setting.setName(name);
      setting.setPattern(pattern);
      setting.setLevel(level);
      setting.setDescription(description);

      componentSetting.add(setting);
    }
  }
  @Override
  protected void findModelTypes() {
    modelTypes = new ArrayList<ModelTypeExtension>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();

    IExtensionPoint extensionPoint =
        registry.getExtensionPoint("org.eclipse.epsilon.common.dt.modelType");
    IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();

    try {
      for (int i = 0; i < configurationElements.length; i++) {
        IConfigurationElement configurationElement = configurationElements[i];
        // Intercept the EMF model as we want to provide our reduced dialog
        String type = configurationElement.getAttribute("type");
        ModelTypeExtension modelType = new ModelTypeExtension();
        modelType.setClazz(configurationElement.getAttribute("class"));
        modelType.setType(type);
        modelType.setLabel(configurationElement.getAttribute("label"));
        modelType.setStable(Boolean.parseBoolean(configurationElement.getAttribute("stable")));

        String contributingPlugin =
            configurationElement.getDeclaringExtension().getNamespaceIdentifier();
        Image image =
            AbstractUIPlugin.imageDescriptorFromPlugin(
                    contributingPlugin, configurationElement.getAttribute("icon"))
                .createImage();
        modelType.setImage(image);
        modelType.setConfigurationElement(configurationElement);
        modelTypes.add(modelType);
      }
    } catch (Exception ex) {
      LogUtil.log(ex);
    }
  }
 /**
  * If the object is a {@link ProjectElementAdapter} it returns the image returned by the
  * extension's labelProvider or the icon defined in the extension (if it is defined). If the
  * element is not a ProjectElementAdapter the a default image is returned
  *
  * @generated NOT
  */
 public Object getImage(Object object) {
   ProjectElementAdapter projectElementAdapter = ((ProjectElementAdapter) object);
   IGenericProjectElement backingObject = projectElementAdapter.getBackingObject();
   if (backingObject == null) {
     return null;
   }
   String extensionId = backingObject.getExtensionId();
   IConfigurationElement extension = findExtension(extensionId);
   String labelProviderAtt = extension.getAttribute(LABEL_PROVIDER_ATT);
   Object image = null;
   if (labelProviderAtt != null) {
     try {
       IBaseLabelProvider baseProvider =
           (IBaseLabelProvider) extension.createExecutableExtension(LABEL_PROVIDER_ATT);
       if (baseProvider instanceof ILabelProvider) {
         ILabelProvider labelProvider = (ILabelProvider) baseProvider;
         image = labelProvider.getImage(backingObject);
       }
     } catch (CoreException e) {
       // not good log this
       ProjectEditPlugin.log("Unable to load the LabelProvider for Element: " + extensionId, e);
     }
   }
   String iconPath = extension.getAttribute(ICON_ATT);
   if (image == null && iconPath != null) {
     image =
         AbstractUIPlugin.imageDescriptorFromPlugin(extension.getNamespaceIdentifier(), iconPath);
   }
   return image;
 }
Ejemplo n.º 19
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);
       }
     }
   }
 }
 /**
  * If the object is a {@link ProjectElementAdapter} it returns the text returned by the
  * extension's labelProvider or the label defined in the extension (if it is defined). If the
  * element is not a ProjectElementAdapter the a default text is returned
  *
  * @generated NOT
  */
 public String getText(Object object) {
   ProjectElementAdapter projectElementAdapter = ((ProjectElementAdapter) object);
   IGenericProjectElement backingObject = projectElementAdapter.getBackingObject();
   if (backingObject == null) {
     return projectElementAdapter.getName() + "- No backing object";
   }
   String extensionId = backingObject.getExtensionId();
   IConfigurationElement extension = findExtension(extensionId);
   String labelProviderAtt = extension.getAttribute(LABEL_PROVIDER_ATT);
   String text = null;
   if (labelProviderAtt != null) {
     try {
       IBaseLabelProvider baseProvider =
           (IBaseLabelProvider) extension.createExecutableExtension(LABEL_PROVIDER_ATT);
       if (baseProvider instanceof ILabelProvider) {
         ILabelProvider labelProvider = (ILabelProvider) baseProvider;
         text = labelProvider.getText(backingObject);
       }
     } catch (CoreException e) {
       // not good log this
       ProjectEditPlugin.log("Unable to load the LabelProvider for Element: " + extensionId, e);
     }
   }
   if (text == null) {
     text = extension.getAttribute(LABEL_ATT);
   }
   return text;
 }
Ejemplo n.º 21
0
 /**
  * Returns the {@link INamespaceLabelProvider} for the given {@link ISourceModelElement}'s
  * namespace.
  */
 public static INamespaceLabelProvider getLabelProvider(ISourceModelElement element) {
   IExtensionPoint point =
       Platform.getExtensionRegistry().getExtensionPoint(NAMESPACES_EXTENSION_POINT);
   if (point != null) {
     String namespaceURI = getNameSpaceURI(element);
     for (IExtension extension : point.getExtensions()) {
       for (IConfigurationElement config : extension.getConfigurationElements()) {
         if (namespaceURI.equals(config.getAttribute("uri"))) {
           if (config.getAttribute("labelProvider") != null) {
             try {
               Object provider = config.createExecutableExtension("labelProvider");
               if (provider instanceof INamespaceLabelProvider) {
                 return (INamespaceLabelProvider) provider;
               }
             } catch (CoreException e) {
               BeansUIPlugin.log(e);
             }
           }
           return null;
         }
       }
     }
   }
   return null;
 }
Ejemplo n.º 22
0
 public void setInitializationData(
     IConfigurationElement config, String propertyName, Object ignore) throws CoreException {
   final String METHOD_NAME = "setInitializationData";
   boolean isTraceEnabled = LOGGER.isLoggable(Level.FINER);
   boolean isDebugEnabled = LOGGER.isLoggable(Level.FINEST);
   boolean isErrorEnabled = LOGGER.isLoggable(Level.SEVERE);
   if (isTraceEnabled) {
     LOGGER.entering(CLASS_NAME, METHOD_NAME);
   }
   this.templateId = config.getAttribute("wcmTemplateId");
   String subTitle = config.getAttribute("requiresSubtitle");
   if (subTitle != null) {
     this.requiresSubtitle = Boolean.valueOf(subTitle).booleanValue();
   }
   if (config.getChildren("style").length > 0) {
     this.hasStyles = true;
   }
   if (isDebugEnabled) {
     LOGGER.finest(
         METHOD_NAME
             + " Builder initialized with template ID "
             + this.templateId
             + ", requiresSubtitle="
             + this.requiresSubtitle
             + ", hasStyles="
             + this.hasStyles
             + "...");
   }
   if (isTraceEnabled) {
     LOGGER.exiting(CLASS_NAME, METHOD_NAME);
   }
 }
 /**
  * Returns the set of modes specified in the configuration data, or <code>null</code> if none
  * (i.e. default tab group)
  *
  * @return the set of modes specified in the configuration data, or <code>null</code>
  */
 protected List<Set<String>> getModes() {
   if (fModes == null) {
     fModes = new ArrayList<Set<String>>();
     fPerspectives = new Hashtable<Set<String>, String>();
     IConfigurationElement[] modes =
         fConfig.getChildren(IConfigurationElementConstants.LAUNCH_MODE);
     if (modes.length > 0) {
       IConfigurationElement element = null;
       String perspective = null, mode = null;
       Set<String> mset = null;
       for (int i = 0; i < modes.length; i++) {
         element = modes[i];
         mode = element.getAttribute(IConfigurationElementConstants.MODE);
         mset = new HashSet<String>();
         mset.add(mode);
         fModes.add(mset);
         perspective = element.getAttribute(IConfigurationElementConstants.PERSPECTIVE);
         if (perspective != null) {
           fPerspectives.put(mset, perspective);
         }
       }
     }
   }
   return fModes;
 }
Ejemplo n.º 24
0
  private void source(Interpreter interpreter) {
    for (IConfigurationElement config :
        getExtensionInfo("org.jactr.tools.shell.commands", "source")) {
      String url = config.getAttribute("url");
      String resource = config.getAttribute("resource");
      URL actualURL = null;

      if (resource != null) actualURL = getClass().getClassLoader().getResource(resource);
      else if (url != null)
        try {
          actualURL = new URL(url);
        } catch (Exception e) {
          if (LOGGER.isWarnEnabled()) LOGGER.warn(url + " is not a valid url ", e);
        }

      if (actualURL != null)
        try {
          interpreter.set("tmpURL", actualURL);
          interpreter.eval("source(tmpURL)");
          interpreter.unset("tmpURL");
        } catch (EvalError e) {
          if (LOGGER.isDebugEnabled()) LOGGER.debug("Could not source " + url + " ", e);
        }
    }
  }
  @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
  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;
  }
Ejemplo n.º 27
0
  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);
      }
    }
  }
 /** 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);
       }
     }
   }
 }
  public Map<String, List<LibraryInfo>> getRoutineAndJars() {
    if (routineAndJars == null) {
      routineAndJars = new HashMap<String, List<LibraryInfo>>();
      for (IConfigurationElement current : configurationElements) {
        String routine = current.getAttribute(NAME_ATTR);
        List<LibraryInfo> jarList = routineAndJars.get(routine);
        if (jarList == null) {
          jarList = new ArrayList<LibraryInfo>();
          routineAndJars.put(routine, jarList);
        }
        IConfigurationElement[] children = current.getChildren(LIBRARY_ELE);
        for (IConfigurationElement child : children) {
          LibraryInfo libraryInfo = new LibraryInfo();
          String library = child.getAttribute(NAME_ATTR);
          libraryInfo.setLibName(library);
          IConfigurationElement[] bundleIdChildren = child.getChildren(BUNDLE_ID);
          if (bundleIdChildren == null || bundleIdChildren.length == 0) {
            libraryInfo.setBundleId(null);
          } else {
            for (IConfigurationElement bundleIdChild : bundleIdChildren) {
              String bundleId = bundleIdChild.getAttribute(BUNDLE_ID);
              libraryInfo.setBundleId(StringUtils.trimToEmpty(bundleId));
            }
          }
          if (!jarList.contains(libraryInfo)) {
            jarList.add(libraryInfo);
          }
        }
      }
    }

    return routineAndJars;
  }
  private static List<CloudURL> getUrls(String serverTypeId, String elementType) {
    if (!read) {
      readBrandingDefinitions();
    }
    IConfigurationElement config = brandingDefinitions.get(serverTypeId);
    if (config != null) {
      List<CloudURL> result = new ArrayList<CloudURL>();
      IConfigurationElement[] defaultUrls = config.getChildren(elementType);
      for (IConfigurationElement defaultUrl : defaultUrls) {
        String urlName = defaultUrl.getAttribute(ATTR_NAME);
        String url = defaultUrl.getAttribute(ATTR_URL);

        if (urlName != null && urlName.length() > 0 && url != null && url.length() > 0) {
          IConfigurationElement[] wildcards = defaultUrl.getChildren(ELEM_WILDCARD);
          for (IConfigurationElement wildcard : wildcards) {
            String wildcardName = wildcard.getAttribute(ATTR_NAME);
            url = url.replaceAll(wildcardName, "{" + wildcardName + "}");
          }
          result.add(new CloudURL(urlName, url, false));
        }
      }
      return result;
    }

    return null;
  }