@Override public String getProviderName() { IBundle bundle = getBundle(); return bundle == null ? null : bundle.getHeader(Constants.BUNDLE_VENDOR); }
private static String getVersionAttribute(IBundle bundle) { int manifestVersion = BundlePluginBase.getBundleManifestVersion(bundle); return (manifestVersion < 2) ? ICoreConstants.PACKAGE_SPECIFICATION_VERSION : Constants.VERSION_ATTRIBUTE; }
@Override public void add(IPluginImport iimport) throws CoreException { ensureModelEditable(); if (iimport == null) return; if (imports == null) // if imports == null, intitialize the imports list by calling getImports() getImports(); addImport(iimport); fireStructureChanged(iimport, true); }
public void add(IPluginImport iimport) throws CoreException { if (iimport == null) return; if (imports == null) // if imports == null, intitialize the imports list by calling getImports() getImports(); addImport(iimport); fireStructureChanged(iimport, true); }
@Override public void add(IPluginExtensionPoint point) throws CoreException { ensureModelEditable(); IExtensions extensions = getExtensionsRoot(); if (extensions == null) return; extensions.add(point); //reset singleton if (getExtensions().length == 0 && getExtensionPoints().length == 1) updateSingleton(true); }
public void add(IPluginLibrary library) throws CoreException { if (libraries == null) // if libraries == null, initialize the libraries varible by calling getLibraries() getLibraries(); libraries.add(library); Object header = getManifestHeader(Constants.BUNDLE_CLASSPATH); if (header instanceof BundleClasspathHeader) { ((BundleClasspathHeader)header).addLibrary(library.getName()); } else { String value = header == null ? null : ((IManifestHeader)header).getValue(); StringBuffer buffer = new StringBuffer(value == null ? "" : value); //$NON-NLS-1$ if (value != null) buffer.append(",\n "); //$NON-NLS-1$ buffer.append(library.getName()); getBundle().setHeader(Constants.BUNDLE_CLASSPATH, buffer.toString()); } fireStructureChanged(library, true); }
@Override public void add(IPluginLibrary library) throws CoreException { ensureModelEditable(); if (libraries == null) // if libraries == null, initialize the libraries varible by calling getLibraries() getLibraries(); libraries.add(library); IManifestHeader header = getManifestHeader(Constants.BUNDLE_CLASSPATH); if (header instanceof BundleClasspathHeader) { ((BundleClasspathHeader) header).addLibrary(library.getName()); } else { addLibrary(library, header); } fireStructureChanged(library, true); }
private void addImport(IPluginImport iimport) { imports.add(iimport); Object header = getManifestHeader(Constants.REQUIRE_BUNDLE); if (header instanceof RequireBundleHeader) { ((RequireBundleHeader)header).addBundle(iimport); } else { String value = header == null ? null : ((IManifestHeader)header).getValue(); StringBuffer buffer = new StringBuffer(value == null ? "" : value); //$NON-NLS-1$ if (value != null) buffer.append(",\n "); //$NON-NLS-1$ buffer.append(iimport.getId()); int bundleManifestVersion = getBundleManifestVersion(getBundle()); if (iimport.isOptional()) if (bundleManifestVersion > 1) buffer.append(";" + Constants.RESOLUTION_DIRECTIVE + ":=" + Constants.RESOLUTION_OPTIONAL); //$NON-NLS-1$ //$NON-NLS-2$ else buffer.append(";" + ICoreConstants.OPTIONAL_ATTRIBUTE + "=true"); //$NON-NLS-1$ //$NON-NLS-2$ if (iimport.isReexported()) if (bundleManifestVersion > 1) buffer.append(";" + Constants.VISIBILITY_DIRECTIVE + ":=" + Constants.VISIBILITY_REEXPORT); //$NON-NLS-1$ //$NON-NLS-2$ else buffer.append(";" + ICoreConstants.REPROVIDE_ATTRIBUTE + "=true"); //$NON-NLS-1$ //$NON-NLS-2$ String version = iimport.getVersion(); if (version != null && version.trim().length() > 0) buffer.append(";" + Constants.BUNDLE_VERSION_ATTRIBUTE + "=\"" + version.trim() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ getBundle().setHeader(Constants.REQUIRE_BUNDLE, buffer.toString()); } }
for (int i = 0; i < required.length; i++) { PluginImport importElement = new PluginImport(); importElement.setModel(getModel()); importElement.setInTheModel(true); importElement.setParent(this); for (int i = 0; i < imported.length; i++) { PluginImport importElement = new PluginImport(); importElement.setModel(getModel()); importElement.setInTheModel(true); importElement.setParent(this); IBundle bundle = getBundle(); if (bundle != null) { try { String value = bundle.getHeader(Constants.REQUIRE_BUNDLE); int bundleManifestVersion = getBundleManifestVersion(bundle); if (value != null) { ManifestElement[] elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, value); for (int i = 0; i < elements.length; i++) { PluginImport importElement = new PluginImport(); importElement.setModel(getModel()); importElement.setInTheModel(true); importElement.setParent(this);
@Override public void remove(IPluginLibrary library) throws CoreException { ensureModelEditable(); if (libraries != null) { libraries.remove(library); IManifestHeader header = getManifestHeader(Constants.BUNDLE_CLASSPATH); if (header instanceof BundleClasspathHeader) { ((BundleClasspathHeader) header).removeLibrary(library.getName()); } else if (header != null) { removeLibrary(library, header); } fireStructureChanged(library, false); } }
@Override public void setId(String id) throws CoreException { ensureModelEditable(); IBundle bundle = getBundle(); if (bundle != null) { String old = getId(); IManifestHeader header = bundle.getManifestHeader(Constants.BUNDLE_SYMBOLICNAME); if (header instanceof BundleSymbolicNameHeader) ((BundleSymbolicNameHeader) header).setId(id); else bundle.setHeader(Constants.BUNDLE_SYMBOLICNAME, id); model.fireModelObjectChanged(this, IIdentifiable.P_ID, old, id); } }
@Override public void setProviderName(String providerName) throws CoreException { ensureModelEditable(); IBundle bundle = getBundle(); if (bundle != null) { String old = getProviderName(); IManifestHeader header = bundle.getManifestHeader(Constants.BUNDLE_VENDOR); if (header instanceof BundleVendorHeader) ((BundleVendorHeader) header).setVendor(providerName); else bundle.setHeader(Constants.BUNDLE_VENDOR, providerName); model.fireModelObjectChanged(this, IPluginBase.P_PROVIDER, old, providerName); } }
@Override public void setName(String name) throws CoreException { ensureModelEditable(); IBundle bundle = getBundle(); if (bundle != null) { String old = getName(); IManifestHeader header = bundle.getManifestHeader(Constants.BUNDLE_NAME); if (header instanceof BundleNameHeader) ((BundleNameHeader) header).setBundleName(name); else bundle.setHeader(Constants.BUNDLE_NAME, name); model.fireModelObjectChanged(this, IPluginObject.P_NAME, old, name); } }
@Override public void setVersion(String version) throws CoreException { ensureModelEditable(); IBundle bundle = getBundle(); if (bundle != null) { String old = getVersion(); IManifestHeader header = bundle.getManifestHeader(Constants.BUNDLE_VERSION); if (header instanceof BundleVersionHeader) ((BundleVersionHeader) header).setVersionRange(version); else bundle.setHeader(Constants.BUNDLE_VERSION, version); model.fireModelObjectChanged(this, IPluginBase.P_VERSION, old, version); } }
public boolean isValid() { IExtensions extensions = getExtensionsRoot(); return getBundle() != null && getBundle().getHeader(Constants.BUNDLE_SYMBOLICNAME) != null && (extensions == null || extensions.isValid()); }
@Override public void remove(IPluginImport pluginImport) throws CoreException { ensureModelEditable(); if (imports != null) { imports.remove(pluginImport); Object header = getManifestHeader(Constants.REQUIRE_BUNDLE); if (header instanceof RequireBundleHeader) { ((RequireBundleHeader) header).removeBundle(pluginImport.getId()); } fireStructureChanged(pluginImport, false); } }
public IPluginLibrary[] getLibraries() { IBundle bundle = getBundle(); if (bundle == null) return new IPluginLibrary[0]; if (libraries == null) { libraries = new ArrayList(); String value = bundle.getHeader(Constants.BUNDLE_CLASSPATH); if (value != null) { try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, value); for (int i = 0; i < elements.length; i++) { PluginLibrary library = new PluginLibrary(); library.setModel(getModel()); library.setInTheModel(true); library.setParent(this); library.load(elements[i].getValue()); libraries.add(library); } } catch (BundleException e) { } } } return (IPluginLibrary[]) libraries.toArray(new IPluginLibrary[libraries.size()]); }
protected void updateSingleton(boolean singleton) { IManifestHeader header = getManifestHeader(Constants.BUNDLE_SYMBOLICNAME); if (header instanceof BundleSymbolicNameHeader) ((BundleSymbolicNameHeader) header).setSingleton(singleton); else { if (singleton) { String version = getBundle().getHeader(Constants.BUNDLE_MANIFESTVERSION); if (version == null) version = "1"; //$NON-NLS-1$ String value = header.getValue(); String singletonValue = null; if (Integer.parseInt(version) >= 2) singletonValue = Constants.SINGLETON_DIRECTIVE + ":=true"; //$NON-NLS-1$ else singletonValue = Constants.SINGLETON_DIRECTIVE + "=true"; //$NON-NLS-1$ if (value.indexOf(singletonValue) != -1) return; getBundle().setHeader(Constants.BUNDLE_SYMBOLICNAME, value + "; " + singletonValue); //$NON-NLS-1$ } // No current need to remove singleton directive outside of text model. } }
public void remove(IPluginImport pluginImport) throws CoreException { if (imports != null) { imports.remove(pluginImport); Object header = getManifestHeader(Constants.REQUIRE_BUNDLE); if (header instanceof RequireBundleHeader) { ((RequireBundleHeader)header).removeBundle(pluginImport.getId()); } fireStructureChanged(pluginImport, false); } }
public int getIndexOf(IPluginExtension e) { IExtensions extensions = getExtensionsRoot(); if (extensions == null) return -1; return extensions.getIndexOf(e); }