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);
}
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();
}
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);
}
}
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);
}
}
Aggregations