Search in sources :

Example 11 with IPluginElement

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

the class CheckTocExtensionTest method createErroneousTocExtension.

/**
 * Creates an erroneous toc extension.
 *
 * @return the plugin extension
 * @throws CoreException
 *           the core exception
 */
private IPluginExtension createErroneousTocExtension() throws CoreException {
    IPluginExtension newExtension = pluginModel.getFactory().createExtension();
    newExtension.setPoint(CheckTocExtensionHelper.TOC_EXTENSION_POINT_ID);
    newExtension.setName(tocUtil.getExtensionPointName(catalog));
    IPluginElement element = pluginModel.getFactory().createElement(newExtension);
    element.setName("toc");
    element.setAttribute("file", "dummy/file/location");
    newExtension.add(element);
    return newExtension;
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement)

Example 12 with IPluginElement

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

the class CheckTocExtensionTest method testIsExtensionUpdateRequiredFalse.

/**
 * Tests if isExtensionUpdateRequires returns false if a correct extension already exists.
 *
 * @throws CoreException
 *           the core exception
 */
@Test
public void testIsExtensionUpdateRequiredFalse() throws CoreException {
    IPluginExtension extension = tocUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null);
    Iterable<IPluginElement> elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class);
    assertFalse("No toc extension update is required", tocUtil.isExtensionUpdateRequired(catalog, extension, elements));
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) Test(org.junit.Test)

Example 13 with IPluginElement

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

the class CheckTocExtensionTest method testCreateExtension.

/**
 * Tests if the toc extension is correctly created.
 *
 * @throws CoreException
 *           the core exception
 */
@Test
public void testCreateExtension() throws CoreException {
    IPluginExtension extension = tocUtil.addExtensionToPluginBase(pluginModel, catalog, ExtensionType.CONTEXTS, null);
    assertEquals("Toc extension has been created", CheckTocExtensionHelper.TOC_EXTENSION_POINT_ID, extension.getPoint());
    assertEquals("Toc extension name is correct", tocUtil.getExtensionPointName(catalog), extension.getName());
    assertEquals("Extension has exactly one element", 1, extension.getChildCount());
    assertEquals("toc.xml file location is correctly set", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue());
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) Test(org.junit.Test)

Example 14 with IPluginElement

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

the class GenericServerTemplate method addServerDefinition.

private void addServerDefinition(IPluginBase plugin, IPluginModelFactory factory) throws CoreException {
    // $NON-NLS-1$
    IPluginExtension definitionExtension = createExtension("org.eclipse.jst.server.generic.core.serverdefinition", true);
    IPluginElement serverDef = factory.createElement(definitionExtension);
    // $NON-NLS-1$
    serverDef.setName("serverdefinition");
    // $NON-NLS-1$
    serverDef.setAttribute("id", getRuntimeId());
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    serverDef.setAttribute("definitionfile", "/servers/" + getStringOption(KEY_SERVER_NAME) + ".serverdef");
    definitionExtension.add(serverDef);
    if (!definitionExtension.isInTheModel())
        plugin.add(definitionExtension);
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement)

Example 15 with IPluginElement

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

the class GenericServerTemplate method addWizardFragment.

private void addWizardFragment(IPluginBase plugin, IPluginModelFactory factory) throws CoreException {
    // $NON-NLS-1$
    IPluginExtension wizardExtension = createExtension("org.eclipse.wst.server.ui.wizardFragments", true);
    IPluginElement runtimeWiz = factory.createElement(wizardExtension);
    // $NON-NLS-1$
    runtimeWiz.setName("fragment");
    // $NON-NLS-1$ //$NON-NLS-2$
    runtimeWiz.setAttribute("id", getNamespace() + ".runtimeWizard");
    // $NON-NLS-1$ //$NON-NLS-2$
    runtimeWiz.setAttribute("class", "org.eclipse.jst.server.generic.ui.internal.GenericServerRuntimeWizardFragment");
    // $NON-NLS-1$
    runtimeWiz.setAttribute("typeIds", getRuntimeId());
    wizardExtension.add(runtimeWiz);
    if (!wizardExtension.isInTheModel())
        plugin.add(wizardExtension);
    IPluginElement serverWiz = factory.createElement(wizardExtension);
    // $NON-NLS-1$
    serverWiz.setName("fragment");
    // $NON-NLS-1$ //$NON-NLS-2$
    serverWiz.setAttribute("id", getNamespace() + ".serverWizard");
    // $NON-NLS-1$ //$NON-NLS-2$
    serverWiz.setAttribute("class", "org.eclipse.jst.server.generic.ui.internal.GenericServerWizardFragment");
    // $NON-NLS-1$
    serverWiz.setAttribute("typeIds", getServerId());
    wizardExtension.add(serverWiz);
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement)

Aggregations

IPluginElement (org.eclipse.pde.core.plugin.IPluginElement)24 IPluginExtension (org.eclipse.pde.core.plugin.IPluginExtension)19 Test (org.junit.Test)11 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)4 IPluginObject (org.eclipse.pde.core.plugin.IPluginObject)4 Check (com.avaloq.tools.ddk.check.check.Check)3 IQualifiedNameProvider (org.eclipse.xtext.naming.IQualifiedNameProvider)2 XIssueExpression (com.avaloq.tools.ddk.check.check.XIssueExpression)1 NoSuchElementException (java.util.NoSuchElementException)1 IPluginAttribute (org.eclipse.pde.core.plugin.IPluginAttribute)1 Pair (org.eclipse.xtext.util.Pair)1