/**
  * Initialize the column descriptor by reading the attributes from the configuration element.
  *
  * @param column The column descriptor to be initialized.
  * @param configuration The configuration element.
  * @throws CoreException Thrown during parsing.
  */
 @SuppressWarnings("rawtypes")
 void initColumn(ColumnDescriptor column, IConfigurationElement configuration)
     throws CoreException {
   String name = configuration.getAttribute("name"); // $NON-NLS-1$
   Assert.isNotNull(name);
   column.setName(name);
   column.setDescription(configuration.getAttribute("description")); // $NON-NLS-1$
   String attribute = configuration.getAttribute("moveable"); // $NON-NLS-1$
   if (attribute != null) {
     column.setMoveable(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("resizable"); // $NON-NLS-1$
   if (attribute != null) {
     column.setResizable(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("visible"); // $NON-NLS-1$
   if (attribute != null) {
     column.setVisible(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("style"); // $NON-NLS-1$
   if (attribute != null) {
     column.setStyle(parseAlignment(attribute));
   }
   attribute = configuration.getAttribute("alignment"); // $NON-NLS-1$
   if (attribute != null) {
     column.setAlignment(parseAlignment(attribute));
   }
   attribute = configuration.getAttribute("width"); // $NON-NLS-1$
   if (attribute != null) {
     try {
       column.setWidth(Integer.parseInt(attribute));
     } catch (NumberFormatException e) {
     }
   }
   attribute = configuration.getAttribute("image"); // $NON-NLS-1$
   if (attribute != null) {
     String symbolicName = configuration.getContributor().getName();
     URL resource = Platform.getBundle(symbolicName).getResource(attribute);
     Image image = ImageDescriptor.createFromURL(resource).createImage();
     column.setImage(image);
   }
   attribute = configuration.getAttribute("labelProvider"); // $NON-NLS-1$
   if (attribute != null) {
     ILabelProvider labelProvider =
         (ILabelProvider) configuration.createExecutableExtension("labelProvider"); // $NON-NLS-1$
     if (labelProvider != null) {
       column.setLabelProvider(labelProvider);
     }
   }
   attribute = configuration.getAttribute("comparator"); // $NON-NLS-1$
   if (attribute != null) {
     Comparator comparator =
         (Comparator) configuration.createExecutableExtension("comparator"); // $NON-NLS-1$
     if (comparator != null) {
       column.setComparator(comparator);
     }
   }
 }
Example #2
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) {
        }
      }
    }
  }
 public static List<ICheckNodesService> getCheckNodesService() {
   if (checkNodeServices == null) {
     checkNodeServices = new ArrayList<ICheckNodesService>();
     IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
     IExtensionPoint extensionPoint =
         extensionRegistry.getExtensionPoint(
             "org.talend.designer.core.check_nodes"); //$NON-NLS-1$
     if (extensionPoint != null) {
       IExtension[] extensions = extensionPoint.getExtensions();
       for (IExtension extension : extensions) {
         IConfigurationElement[] configurationElements = extension.getConfigurationElements();
         for (IConfigurationElement configurationElement : configurationElements) {
           try {
             Object service =
                 configurationElement.createExecutableExtension("class"); // $NON-NLS-1$
             if (service instanceof ICheckNodesService) {
               checkNodeServices.add((ICheckNodesService) service);
             }
           } catch (CoreException e) {
             ExceptionHandler.process(e);
           }
         }
       }
     }
   }
   return checkNodeServices;
 }
  public Bpmn2SectionDescriptor(Bpmn2TabDescriptor td, IConfigurationElement e) {
    tab = td.getId();
    id = tab + ".section";

    try {
      String className = e.getAttribute("class");
      if ("default".equals(className)) {
        sectionClass = new DefaultPropertySection();
        if (e.getAttribute("features") != null) {
          String[] properties = e.getAttribute("features").split(" ");
          ((DefaultPropertySection) sectionClass).setProperties(properties);
        }
      } else {
        sectionClass = (AbstractPropertySection) e.createExecutableExtension("class");
      }
      filter = e.getAttribute("filter");
      if (filter == null || filter.isEmpty())
        filter = "org.eclipse.bpmn2.modeler.ui.property.Bpmn2PropertyFilter";
      enablesFor = e.getAttribute("enablesFor");
      String type = e.getAttribute("type");
      if (type != null && !type.isEmpty()) {
        appliesToClass = Class.forName(type);
        if (sectionClass instanceof DefaultPropertySection) {
          ((DefaultPropertySection) sectionClass).setAppliesTo(appliesToClass);
        }
      }
    } catch (Exception e1) {
      e1.printStackTrace();
    }

    td.getSectionDescriptors().add(this);
  }
Example #5
0
 /** @param viewer */
 private void addDndSupport(GraphicalViewer viewer, String type) {
   IExtensionPoint point =
       Platform.getExtensionRegistry().getExtensionPoint(UMLPlugin.PLUGIN_ID, "dnd");
   IExtension[] extensions = point.getExtensions();
   for (int i = 0; i < extensions.length; i++) {
     IExtension extension = extensions[i];
     IConfigurationElement[] elements = extension.getConfigurationElements();
     for (int j = 0; j < elements.length; j++) {
       IConfigurationElement element = elements[j];
       try {
         Object object = element.createExecutableExtension("class");
         if (object instanceof UMLDropTargetListenerFactory) {
           UMLDropTargetListenerFactory factory = (UMLDropTargetListenerFactory) object;
           if (factory.accept(type)) {
             TransferDropTargetListener targetListener = factory.getDropTargetListener(viewer);
             viewer.addDropTargetListener(targetListener);
           }
         }
       } catch (CoreException e) {
         e.printStackTrace();
       } finally {
       }
     }
   }
 }
Example #6
0
 /**
  * Runs an artifact analysis for the given file by searching the given extension point for an
  * {@link IArtifactAnalysis} that matches its language ID.
  *
  * <p>This is a utility method generally invoked from {@link #doArtifactAnalysis(ITranslationUnit,
  * List)}.
  *
  * <p>It is assumed that only one extension will be contributed per language ID. If multiple
  * extensions are found, it is unspecified which one will be run.
  *
  * @param extensionPointID
  * @param tu
  * @param includes
  * @param allowPrefixOnlyMatch
  * @return {@link ScanReturn}
  * @since 6.0
  */
 protected ScanReturn runArtifactAnalysisFromExtensionPoint(
     String extensionPointID,
     final ITranslationUnit tu,
     final List<String> includes,
     final boolean allowPrefixOnlyMatch) {
   try {
     final String languageID = tu.getLanguage().getId();
     for (IConfigurationElement config :
         Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointID)) {
       try {
         if (languageID.equals(config.getAttribute("languageID"))) {
           IArtifactAnalysis artifactAnalysis =
               (IArtifactAnalysis) config.createExecutableExtension("class"); // $NON-NLS-1$
           return artifactAnalysis.runArtifactAnalysis(
               languageID, tu, includes, allowPrefixOnlyMatch);
         }
       } catch (CoreException e) {
         CommonPlugin.log(e.getClass().getSimpleName() + ": " + e.getMessage());
       }
     }
   } catch (CoreException e) {
     e.printStackTrace();
     CommonPlugin.log(
         IStatus.ERROR,
         "RunAnalyseMPICommandHandler: Error setting up analysis for project "
             + tu.getCProject()
             + " error="
             + e.getMessage()); // $NON-NLS-1$ //$NON-NLS-2$
   }
   return new ScanReturn();
 }
  private IEvaluatedType evaluateType(AbstractTypeGoal goal, int time, List list) {
    Set typeSet = new HashSet();
    for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
      IConfigurationElement element = (IConfigurationElement) iterator.next();
      ITypeInferencer ti;
      try {
        ti = (ITypeInferencer) element.createExecutableExtension("evaluator"); // $NON-NLS-1$
      } catch (CoreException e) {
        e.printStackTrace();
        continue;
      }
      // ITypeInferencer ti = (ITypeInferencer)
      // iterator.next();
      IEvaluatedType type = ti.evaluateType(goal, time);
      if (type != null && !(type instanceof UnknownType)) {
        if (type instanceof AmbiguousType) {
          flattenTypes((AmbiguousType) type, typeSet);
        } else {
          typeSet.add(type);
        }
      }
    }
    if ((typeSet.size() > 1) && (goal.getContext() instanceof BasicContext)) {
      reduceTypes((BasicContext) goal.getContext(), typeSet);
    }

    if (typeSet.size() == 1) {
      return (IEvaluatedType) typeSet.iterator().next();
    } else if (typeSet.size() > 1) {
      return new AmbiguousType(
          (IEvaluatedType[]) typeSet.toArray(new IEvaluatedType[typeSet.size()]));
    } else {
      return null;
    }
  }
 public ClasspathFixProcessor getProcessor(IJavaProject project) {
   if (matches(project)) {
     if (fProcessorInstance == null) {
       try {
         Object extension = fConfigurationElement.createExecutableExtension(CLASS);
         if (extension instanceof ClasspathFixProcessor) {
           fProcessorInstance = (ClasspathFixProcessor) extension;
         } else {
           String message =
               "Invalid extension to "
                   + ATT_EXTENSION //$NON-NLS-1$
                   + ". Must extends ClasspathFixProcessor: "
                   + getID(); //$NON-NLS-1$
           JavaPlugin.log(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, message));
           fStatus = Boolean.FALSE;
           return null;
         }
       } catch (CoreException e) {
         JavaPlugin.log(e);
         fStatus = Boolean.FALSE;
         return null;
       }
     }
     return fProcessorInstance;
   }
   return null;
 }
Example #9
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;
  }
 /**
  * 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;
 }
  /** 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;
          }
        }
      }
    }
  }
Example #12
0
  /* (non-Javadoc)
   * @see org.eclipse.graphiti.features.custom.ICustomFeature#execute(org.eclipse.graphiti.features.context.ICustomContext)
   */
  @Override
  public void execute(ICustomContext context) {
    PictogramElement _pe =
        context.getPictogramElements()[0] instanceof Connection
            ? ((Connection) context.getPictogramElements()[0]).getStart().getParent()
            : context.getPictogramElements()[0];
    final Object bo = getBusinessObjectForPictogramElement(_pe);

    if (bo instanceof CamelModelElement) {
      CamelModelElement _ep = (CamelModelElement) bo;

      // inject palette entries delivered via extension points
      IConfigurationElement[] extensions =
          Platform.getExtensionRegistry()
              .getConfigurationElementsFor(DBL_CLICK_HANDLER_EXT_POINT_ID);
      try {
        for (IConfigurationElement e : extensions) {
          final Object o = e.createExecutableExtension("class");
          if (o instanceof ICustomDblClickHandler) {
            ICustomDblClickHandler handler = (ICustomDblClickHandler) o;
            if (handler.canHandle(_ep)) {
              handler.handleDoubleClick(_ep);
              break;
            }
          }
        }
      } catch (CoreException ex) {
        CamelEditorUIActivator.pluginLog().logError(ex);
      }
    }
  }
    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$
      }
    }
  /**
   * 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$
  }
Example #15
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);
         }
       }
     }
   }
 }
Example #16
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);
    }
  }
  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;
  }
 /**
  * If the extension's LabelProvider is non-null and implements the IColorProvider interface the
  * background color from the provider is returned otherwise null is returned
  */
 public Color getBackground(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);
   Color color = null;
   if (labelProviderAtt != null) {
     try {
       IBaseLabelProvider baseProvider =
           (IBaseLabelProvider) extension.createExecutableExtension(LABEL_PROVIDER_ATT);
       if (baseProvider instanceof IColorProvider) {
         IColorProvider labelProvider = (IColorProvider) baseProvider;
         color = labelProvider.getBackground(backingObject);
       }
     } catch (CoreException e) {
       // not good log this
       ProjectEditPlugin.log("Unable to load the LabelProvider for Element: " + extensionId, e);
     }
   }
   return color;
 }
Example #19
0
  /** 加载记忆库匹配实现 ; */
  private void runExtension() {
    IConfigurationElement[] config =
        Platform.getExtensionRegistry().getConfigurationElementsFor(TMIMPORTER_EXTENSION_ID);
    try {
      for (IConfigurationElement e : config) {
        final Object o = e.createExecutableExtension("class");
        if (o instanceof ITmImporter) {
          ISafeRunnable runnable =
              new ISafeRunnable() {

                public void handleException(Throwable exception) {
                  logger.error(Messages.getString("importer.TmImporter.logger1"), exception);
                }

                public void run() throws Exception {
                  tmImporter = (ITmImporter) o;
                }
              };
          SafeRunner.run(runnable);
        }
      }
    } catch (CoreException ex) {
      logger.error(Messages.getString("importer.TmImporter.logger1"), 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;
 }
Example #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;
 }
 /**
  * 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;
 }
 /**
  * Initialize the filter descriptor from the specified configuration element.
  *
  * @param descriptor The new descriptor to be initialized.
  * @param configuration The configuration element to initialize the filter.
  * @throws CoreException Thrown during parsing.
  */
 void initFilter(FilterDescriptor descriptor, IConfigurationElement configuration)
     throws CoreException {
   String attribute = configuration.getAttribute("name"); // $NON-NLS-1$
   Assert.isNotNull(attribute);
   descriptor.setName(attribute);
   attribute = configuration.getAttribute("description"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setDescription(attribute);
   }
   attribute = configuration.getAttribute("image"); // $NON-NLS-1$
   if (attribute != null) {
     String symbolicName = configuration.getContributor().getName();
     URL resource = Platform.getBundle(symbolicName).getResource(attribute);
     Image image = ImageDescriptor.createFromURL(resource).createImage();
     descriptor.setImage(image);
   }
   attribute = configuration.getAttribute("enabled"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setEnabled(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("class"); // $NON-NLS-1$
   Assert.isNotNull(attribute);
   ViewerFilter filter =
       (ViewerFilter) configuration.createExecutableExtension("class"); // $NON-NLS-1$
   Assert.isNotNull(filter);
   descriptor.setFilter(filter);
   attribute = configuration.getAttribute("visibleInUI"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setVisible(Boolean.valueOf(attribute).booleanValue());
   }
 }
  @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;
  }
  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;
  }
Example #26
0
 /**
  * Creates an extension. If the extension plugin has not been loaded, a busy cursor will be
  * activated during the duration of the load.
  *
  * @param element the config element defining the extension
  * @param classAttribute the name of the attribute carrying the class
  * @return the extension object
  */
 public static Object createExtension(
     final IConfigurationElement element, final String classAttribute) throws CoreException {
   // If plugin has been loaded, create extension.
   // Otherwise, show busy cursor then create extension.
   String id = element.getContributor().getName();
   Bundle bundle = Platform.getBundle(id);
   if (bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
     return element.createExecutableExtension(classAttribute);
   }
   final Object[] ret = new Object[1];
   final CoreException[] exc = new CoreException[1];
   BusyIndicator.showWhile(
       null,
       new Runnable() {
         @Override
         public void run() {
           try {
             ret[0] = element.createExecutableExtension(classAttribute);
           } catch (CoreException e) {
             exc[0] = e;
           }
         }
       });
   if (exc[0] != null) throw exc[0];
   return ret[0];
 }
Example #27
0
 EngineExtensionManager() {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint extensionPoint =
       registry.getExtensionPoint("org.eclipse.birt.core.FactoryService");
   IExtension[] extensions = extensionPoint.getExtensions();
   for (IExtension extension : extensions) {
     IConfigurationElement[] elements = extension.getConfigurationElements();
     for (IConfigurationElement element : elements) {
       String type = element.getAttribute("type");
       if ("org.eclipse.birt.report.engine.extension".equals(type)) {
         try {
           Object factoryObject = element.createExecutableExtension("class");
           if (factoryObject instanceof IReportEngineExtensionFactory) {
             IReportEngineExtensionFactory factory =
                 (IReportEngineExtensionFactory) factoryObject;
             IReportEngineExtension engineExtension = factory.createExtension(ReportEngine.this);
             exts.put(engineExtension.getExtensionName(), engineExtension);
           }
         } catch (CoreException ex) {
           logger.log(Level.WARNING, "can not load the engine extension factory", ex);
         }
       }
     }
   }
 }
 /*
  * 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;
 }
Example #29
0
  private void initGlobaleGuiceInjector() {
    List<Module> moduleList = new ArrayList<Module>();
    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] extensions =
        reg.getConfigurationElementsFor(ISharedModuleProvider.EXTENSION_POINT_ID);
    for (int i = 0; i < extensions.length; i++) {
      IConfigurationElement element = extensions[i];
      if (element.getAttribute("class") != null) {
        try {
          ISharedModuleProvider provider =
              (ISharedModuleProvider) element.createExecutableExtension("class");
          moduleList.add(provider.get());
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    Injector injector = Guice.createInjector(moduleList);
    try {
      Field field = GuiceContext.class.getDeclaredField("globalSharedInjector");
      field.setAccessible(true);
      field.set(GuiceContext.class, injector);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public boolean isEnabled(List<IServicePolicy> selectedPolicies) {
    boolean result = true;

    // If we don't allow multi select and multiple policies have been selected
    // then this operation is not enabled.
    if (!multiSelect && selectedPolicies.size() > 1) {
      result = false;
    }

    if (result && enabledElement != null) {
      // We have an extension for this enablement code so we will call this
      // code.
      if (enableOperationObject == null) {
        try {
          String enabledClassName =
              RegistryUtils.getAttributeName(enabledElement, "enabledclass"); // $NON-NLS-1$
          enableOperationObject =
              (IEnableOperation) enabledElement.createExecutableExtension(enabledClassName);
        } catch (Exception exc) {
          ServicePolicyActivatorUI.logError(
              "Error loading service policy ui \"enabled\" class.", exc); // $NON-NLS-1$
        }

        if (enableOperationObject != null) {
          result = enableOperationObject.isEnabled(selectedPolicies);
        }
      }
    }

    return result;
  }