use of com.avaloq.tools.ddk.check.check.CheckCatalog 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);
}
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckHoverProvider method getHoverInfoAsHtml.
@Override
protected String getHoverInfoAsHtml(final EObject object) {
if (!hasHover(object) || object.eIsProxy()) {
// TODO object will be proxy in CA when referencing CheckCatalogs!
return null;
}
if (object instanceof Check) {
Check check = (Check) object;
// a dispatcher would be nice
StringBuffer buffer = new StringBuffer();
buffer.append(getFirstLine(check));
appendSection(buffer, "Description", generatorExtension.formatDescription(check.getDescription()));
appendSection(buffer, "Message", generatorExtension.replacePlaceholder(check.getMessage()));
return buffer.toString();
} else if (object instanceof CheckCatalog) {
CheckCatalog catalog = (CheckCatalog) object;
StringBuffer buffer = new StringBuffer();
buffer.append(getFirstLine(catalog));
appendSection(buffer, "Description", generatorExtension.formatDescription(catalog.getDescription()));
return buffer.toString();
}
return super.getHoverInfoAsHtml(object);
}
Aggregations