Search in sources :

Example 1 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project webtools.servertools by eclipse.

the class GenericServerTemplate method addRuntimeTargetHandler.

private void addRuntimeTargetHandler(IPluginBase plugin, IPluginModelFactory factory) throws CoreException {
    // $NON-NLS-1$
    IPluginExtension handlerExtension = createExtension("org.eclipse.wst.server.core.runtimeTargetHandlers", true);
    IPluginElement handler = factory.createElement(handlerExtension);
    // $NON-NLS-1$
    handler.setName("runtimeTargetHandler");
    // $NON-NLS-1$ //$NON-NLS-2$
    handler.setAttribute("id", getNamespace() + ".runtimeTarget");
    // $NON-NLS-1$
    handler.setAttribute("runtimeTypeIds", getRuntimeId());
    // $NON-NLS-1$ //$NON-NLS-2$
    handler.setAttribute("class", "org.eclipse.jst.server.generic.core.internal.GenericServerRuntimeTargetHandler");
    handlerExtension.add(handler);
    if (!handlerExtension.isInTheModel())
        plugin.add(handlerExtension);
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement)

Example 2 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class AbstractCheckExtensionHelper method createExtension.

/**
 * Creates the extension. Note that the <code>id</code> attribute is optional and thus not created.
 *
 * @param catalog
 *          the catalog for which to crate the extension content.
 * @param extensionId
 *          the extension id, may be <code>null</code>
 * @param pluginModel
 *          the model
 * @return the plugin extension
 * @throws CoreException
 *           a core exception
 */
protected IPluginExtension createExtension(final CheckCatalog catalog, final String extensionId, final IPluginModelBase pluginModel) throws CoreException {
    IPluginExtension newExtension = pluginModel.getFactory().createExtension();
    newExtension.setPoint(getExtensionPointId());
    if (extensionId != null) {
        newExtension.setId(extensionId);
    }
    if (getExtensionPointName(catalog) != null) {
        newExtension.setName(getExtensionPointName(catalog));
    }
    // Add contents to the extension
    for (final IPluginObject p : getElements(catalog, newExtension)) {
        newExtension.add(p);
    }
    return newExtension;
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginObject(org.eclipse.pde.core.plugin.IPluginObject)

Example 3 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class CheckExtensionHelperManager method removeExtensions.

/**
 * Remove check catalog extensions as a catalog is removed.
 *
 * @param obj
 *          the catalog
 * @param pluginModel
 *          the plugin model
 * @param monitor
 *          the monitor
 * @throws CoreException
 *           the core exception
 */
public void removeExtensions(final IEObjectDescription obj, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException {
    for (IPluginExtension extension : findExtensions(pluginModel, obj.getName(), ExtensionType.ALL)) {
        final ExtensionType extensionType = getExtensionType(extension);
        getExtensionHelper(extensionType).removeExtensionFromPluginBase(pluginModel, extension, obj, extensionType);
    }
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension)

Example 4 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class CheckMarkerHelpExtensionTest method testMarkerTypeUpdate.

/**
 * Tests if the marker type attribute is updated if the trigger kind changes for a check.
 *
 * @throws Exception
 *           the exception
 */
@Test
public void testMarkerTypeUpdate() throws Exception {
    IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
    assertEquals("Before update: Markertype is fast.", MARKERTYPE_FAST, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
    CheckCatalog updateMarkertype = parser.parse(CATALOG_WITH_FIRST_CHECK_ONDEMAND);
    markerUtil.updateExtension(updateMarkertype, extension);
    assertEquals("After update: Markertype is expensive.", MARKERTYPE_EXPENSIVE, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) Test(org.junit.Test)

Example 5 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class CheckMarkerHelpExtensionTest method testAddElement.

/**
 * Tests, if the marker help extension is updated correctly, i.e. add marker help elements for new checks
 * and delete the elements of removed checks.
 *
 * @throws Exception
 *           the exception
 */
@Test
public void testAddElement() throws Exception {
    final CheckCatalog catalogWithOneCheck = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE);
    IPluginExtension extension = createMarkerHelpExtension(catalogWithOneCheck);
    assertEquals("Original catalog has one marker help extension", 1, extension.getChildCount());
    CheckCatalog catalogWithTwoChecks = parser.parse(CATALOG_WITH_TWO_CHECKS);
    markerUtil.updateExtension(catalogWithTwoChecks, extension);
    Set<String> contextIds = Sets.newHashSet();
    // Test if the marker help element for the old Check has been removed
    for (IPluginObject element : extension.getChildren()) {
        contextIds.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue());
    }
    assertEquals("The extension has two elements", 2, extension.getChildCount());
    assertTrue("Both checks are elements of the extension ", contextIds.containsAll(Sets.newHashSet(FIRSTCHECK_CONTEXID, SECONDCHECK_CONTEXTID)));
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) IPluginObject(org.eclipse.pde.core.plugin.IPluginObject) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) Test(org.junit.Test)

Aggregations

IPluginExtension (org.eclipse.pde.core.plugin.IPluginExtension)27 IPluginElement (org.eclipse.pde.core.plugin.IPluginElement)19 Test (org.junit.Test)12 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)4 IPluginObject (org.eclipse.pde.core.plugin.IPluginObject)3 QualifiedName (org.eclipse.xtext.naming.QualifiedName)3 XIssueExpression (com.avaloq.tools.ddk.check.check.XIssueExpression)1