Search in sources :

Example 1 with IPluginBase

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

the class GenericServerTemplate method updateModel.

protected void updateModel(IProgressMonitor monitor) throws CoreException {
    IPluginBase plugin = model.getPluginBase();
    IPluginModelFactory factory = model.getPluginFactory();
    addRuntimeType(plugin, factory);
    addServerType(plugin, factory);
    addWizardFragment(plugin, factory);
    addServerImage(plugin, factory);
    addRuntimeTargetHandler(plugin, factory);
    addServerDefinition(plugin, factory);
}
Also used : IPluginBase(org.eclipse.pde.core.plugin.IPluginBase) IPluginModelFactory(org.eclipse.pde.core.plugin.IPluginModelFactory)

Example 2 with IPluginBase

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

the class CheckExtensionGenerator method createNewFile.

/**
 * Create a new plugin.xml file.
 *
 * @param catalog
 *          the built catalog
 * @param pluginxml
 *          the file (not existing)
 * @param monitor
 *          progress monitor
 * @throws CoreException
 *           if the plug-in extension could not be created
 * @see org.eclipse.pde.internal.ui.wizards.product.ProductIntroOperation
 */
private void createNewFile(final CheckCatalog catalog, final IFile pluginxml, final IProgressMonitor monitor) throws CoreException {
    WorkspacePluginModelBase pluginModel = (WorkspacePluginModelBase) getModel(pluginxml);
    IPluginBase base = pluginModel.getPluginBase();
    base.setSchemaVersion(TargetPlatformHelper.getSchemaVersion());
    manager.addExtensions(catalog, pluginModel, monitor);
    manager.sortAllExtensions(pluginModel, monitor);
    pluginModel.save();
}
Also used : WorkspacePluginModelBase(org.eclipse.pde.internal.core.plugin.WorkspacePluginModelBase) IPluginBase(org.eclipse.pde.core.plugin.IPluginBase)

Example 3 with IPluginBase

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

the class CheckExtensionGenerator method updateExtensions.

/**
 * Modifies an existing <code>plugin.xml</code> file.
 *
 * @param pluginXmlFile
 *          the plugin.xml file to modify
 * @param catalog
 *          the check catalog
 * @param monitor
 *          progress monitor
 * @throws CoreException
 *           if an error occurred while modifying the plugin.xml file
 * @see org.eclipse.pde.internal.ui.wizards.product.ProductIntroOperation
 */
private void updateExtensions(final IFile pluginXmlFile, final CheckCatalog catalog, final IProgressMonitor monitor) throws CoreException {
    // null means don't contact me...
    IStatus status = PDEPlugin.getWorkspace().validateEdit(new IFile[] { pluginXmlFile }, null);
    if (!status.isOK()) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.getPluginId(), IStatus.ERROR, "Could not update plugin extensions", null));
    }
    if (!STANDARD_PLUGIN_FILENAME.equals(pluginXmlFile.getName())) {
        WorkspacePluginModel pluginModel = new CheckWorkspacePluginModel(pluginXmlFile, false);
        IPluginBase base = pluginModel.getPluginBase();
        base.setSchemaVersion(TargetPlatformHelper.getSchemaVersion());
        pluginModel.load();
        manager.updateExtensions(catalog, pluginModel, monitor);
        manager.addExtensions(catalog, pluginModel, monitor);
        manager.sortAllExtensions(pluginModel, monitor);
        pluginModel.save();
    } else {
        final ModelModification modification = new ModelModification(pluginXmlFile) {

            @Override
            protected void modifyModel(final IBaseModel model, final IProgressMonitor monitor) throws CoreException {
                // NOPMD NPath complexity
                if (!(model instanceof IPluginModelBase)) {
                    return;
                }
                IPluginModelBase pluginModel = (IPluginModelBase) model;
                manager.updateExtensions(catalog, pluginModel, monitor);
                manager.addExtensions(catalog, pluginModel, monitor);
                manager.sortAllExtensions(pluginModel, monitor);
            }

            @Override
            public boolean saveOpenEditor() {
                // do nothing with any open editor...
                return false;
            }
        };
        modifyModel(modification, monitor);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IBaseModel(org.eclipse.pde.core.IBaseModel) IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IPluginBase(org.eclipse.pde.core.plugin.IPluginBase) CoreException(org.eclipse.core.runtime.CoreException) ModelModification(org.eclipse.pde.internal.ui.util.ModelModification) IPluginModelBase(org.eclipse.pde.core.plugin.IPluginModelBase) WorkspacePluginModel(org.eclipse.pde.internal.core.plugin.WorkspacePluginModel)

Example 4 with IPluginBase

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

the class CheckExtensionGenerator method removeExtensions.

/**
 * Removes extensions registered for a check catalog. This operation has extension point specific behavior.
 * Validator, quickfix and preference extensions can safely be removed without any checking. The marker help
 * extension, however, contains elements from all catalogs of current project. Therefore only elements belonging
 * to given catalog may be removed, and not the whole extension. Table of contents and contexts extensions are
 * never removed once created - they are not catalog specific and do not harm.
 *
 * @param file
 *          the plugin.xml file to be modified
 * @param object
 *          the object
 * @param monitor
 *          a progress monitor
 * @throws CoreException
 *           if the file is read-only and cannot be edited
 */
private void removeExtensions(final IFile file, final Object object, final IProgressMonitor monitor) throws CoreException {
    // null means don't contact me...
    IStatus status = PDEPlugin.getWorkspace().validateEdit(new IFile[] { file }, null);
    if (status.getSeverity() != IStatus.OK) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.getPluginId(), IStatus.ERROR, "Could not remove plugin extensions", null));
    }
    if (!STANDARD_PLUGIN_FILENAME.equals(file.getName())) {
        WorkspacePluginModel pluginModel = new CheckWorkspacePluginModel(file, false);
        IPluginBase base = pluginModel.getPluginBase();
        base.setSchemaVersion(TargetPlatformHelper.getSchemaVersion());
        pluginModel.load();
        if (object instanceof IEObjectDescription) {
            // called when catalog is deleted
            manager.removeExtensions((IEObjectDescription) object, pluginModel, monitor);
        } else if (object instanceof CheckCatalog) {
            // called in order to remove extensions in an invalid model
            manager.removeExtensions((CheckCatalog) object, pluginModel, monitor);
        }
        pluginModel.save();
    } else {
        final ModelModification mod = new ModelModification(file) {

            @Override
            protected void modifyModel(final IBaseModel model, final IProgressMonitor monitor) throws CoreException {
                if (!(model instanceof IPluginModelBase)) {
                    return;
                }
                IPluginModelBase pluginModel = (IPluginModelBase) model;
                if (object instanceof IEObjectDescription) {
                    // called when catalog is deleted
                    manager.removeExtensions((IEObjectDescription) object, pluginModel, monitor);
                } else if (object instanceof CheckCatalog) {
                    // called in order to remove extensions in an invalid model
                    manager.removeExtensions((CheckCatalog) object, pluginModel, monitor);
                }
            }

            @Override
            public boolean saveOpenEditor() {
                // prevent modifications to open plugin manifest editor; the editor will become dirty once the modification is performed
                return false;
            }
        };
        modifyModel(mod, monitor);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IBaseModel(org.eclipse.pde.core.IBaseModel) IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IPluginBase(org.eclipse.pde.core.plugin.IPluginBase) CoreException(org.eclipse.core.runtime.CoreException) ModelModification(org.eclipse.pde.internal.ui.util.ModelModification) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) IPluginModelBase(org.eclipse.pde.core.plugin.IPluginModelBase) WorkspacePluginModel(org.eclipse.pde.internal.core.plugin.WorkspacePluginModel) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

IPluginBase (org.eclipse.pde.core.plugin.IPluginBase)4 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IBaseModel (org.eclipse.pde.core.IBaseModel)2 IPluginModelBase (org.eclipse.pde.core.plugin.IPluginModelBase)2 WorkspacePluginModel (org.eclipse.pde.internal.core.plugin.WorkspacePluginModel)2 ModelModification (org.eclipse.pde.internal.ui.util.ModelModification)2 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)1 IPluginModelFactory (org.eclipse.pde.core.plugin.IPluginModelFactory)1 WorkspacePluginModelBase (org.eclipse.pde.internal.core.plugin.WorkspacePluginModelBase)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1