/** * Creates a new descriptor. * * @param element the configuration element to read * @throws InvalidRegistryObjectException if the configuration element is not valid any longer * @throws org.eclipse.core.runtime.CoreException if the configuration does not contain mandatory * attributes */ ProposalSorterHandle(IConfigurationElement element) throws InvalidRegistryObjectException, CoreException { Assert.isLegal(element != null); fElement = element; fId = element.getAttribute(ID); checkNotNull(fId, ID); String name = element.getAttribute(NAME); if (name == null) fName = fId; else fName = name; fClass = element.getAttribute(CLASS); checkNotNull(fClass, CLASS); }
/** * Creates a new descriptor. * * @param element the configuration element to read * @throws InvalidRegistryObjectException if the configuration element is not valid any longer * @throws CoreException if the configuration does not contain mandatory attributes */ ProposalSorterHandle(IConfigurationElement element) throws InvalidRegistryObjectException, CoreException { Assert.isLegal(element != null); fElement= element; fId= element.getAttribute(ID); checkNotNull(fId, ID); String name= element.getAttribute(NAME); if (name == null) fName= fId; else fName= name; fClass= element.getAttribute(CLASS); checkNotNull(fClass, CLASS); }
private Collection<LifecycleListener> listeners() { final Collection<LifecycleListener> existingListeners = listeners.get(); if (existingListeners != null) { return existingListeners; } final Collection<LifecycleListener> newLifecycleListeners = new ArrayList<>(); for (final IConfigurationElement lifecycleListenerElement : Platform.getExtensionRegistry() .getConfigurationElementsFor(LIFECYCLE_LISTENER_EXTENSION_ID)) { final Bundle extensionBundle = Platform.getBundle(lifecycleListenerElement.getDeclaringExtension() .getNamespaceIdentifier()); try { newLifecycleListeners.add((LifecycleListener) extensionBundle.loadClass( lifecycleListenerElement.getAttribute(CLASS_ATTRIBUTE)).newInstance()); } catch (ClassNotFoundException | InvalidRegistryObjectException | InstantiationException | IllegalAccessException e) { Activator.INSTANCE.log(e); } } if (listeners.compareAndSet(null, newLifecycleListeners)) { return newLifecycleListeners; } return listeners.get(); }
TriggerDescriptor(IConfigurationElement conf) { Bundle plugin = Platform.getBundle(conf.getContributor().getName()); this.name = conf.getAttribute("name"); this.description = conf.getAttribute("description"); try { this.triggerClass = plugin.loadClass(conf.getAttribute("class")); this.editorClass = plugin.loadClass(conf.getAttribute("editorClass")); } catch (ClassNotFoundException | InvalidRegistryObjectException e1) { e1.printStackTrace(); } String imagePath = conf.getAttribute("image"); if (imagePath != null) try { this.image = new Image(Display.getDefault(), FileLocator.resolve(plugin.getEntry(imagePath)).getPath()); } catch(Exception e) { e.printStackTrace(); } }
private static ParameterizedCommand convertCommand ( final IConfigurationElement commandElement ) throws NotDefinedException, InvalidRegistryObjectException { final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench ().getService ( ICommandService.class ); final Command command = commandService.getCommand ( commandElement.getAttribute ( "id" ) ); //$NON-NLS-1$ final List<Parameterization> parameters = new ArrayList<Parameterization> (); for ( final IConfigurationElement parameter : commandElement.getChildren ( "parameter" ) ) //$NON-NLS-1$ { final IParameter name = command.getParameter ( parameter.getAttribute ( "name" ) ); //$NON-NLS-1$ final String value = parameter.getAttribute ( "value" ); //$NON-NLS-1$ parameters.add ( new Parameterization ( name, value ) ); } return new ParameterizedCommand ( command, parameters.toArray ( new Parameterization[] {} ) ); }
static Library create(IConfigurationElement configurationElement) throws LibraryFactoryException { try { if (ELEMENT_NAME_LIBRARY.equals(configurationElement.getName())) { Library library = new Library(configurationElement.getAttribute(ATTRIBUTE_NAME_ID)); library.setName(configurationElement.getAttribute(ATTRIBUTE_NAME_NAME)); library.setSiteUri(new URI(configurationElement.getAttribute(ATTRIBUTE_NAME_SITE_URI))); library.setGroup(configurationElement.getAttribute(ATTRIBUTE_NAME_GROUP)); library.setToolTip(configurationElement.getAttribute(ATTRIBUTE_NAME_TOOLTIP)); library.setLibraryDependencies(getLibraryDependencies( configurationElement.getChildren(ELEMENT_NAME_LIBRARY_DEPENDENCY))); library.setLibraryFiles( getLibraryFiles(configurationElement.getChildren(ELEMENT_NAME_LIBRARY_FILE))); String exportString = configurationElement.getAttribute(ATTRIBUTE_NAME_EXPORT); if (exportString != null) { library.setExport(Boolean.parseBoolean(exportString)); } String dependencies = configurationElement.getAttribute("dependencies"); //$NON-NLS-1$ if (!"include".equals(dependencies)) { //$NON-NLS-1$ library.setResolved(); } String versionString = configurationElement.getAttribute("javaVersion"); //$NON-NLS-1$ if (versionString != null) { library.setJavaVersion(versionString); } return library; } else { throw new LibraryFactoryException( Messages.getString("UnexpectedConfigurationElement", configurationElement.getName(), ELEMENT_NAME_LIBRARY)); } } catch (InvalidRegistryObjectException | URISyntaxException | IllegalArgumentException ex) { throw new LibraryFactoryException(Messages.getString("CreateLibraryError"), ex); } }
private static List<LibraryFile> getLibraryFiles(IConfigurationElement[] children) throws InvalidRegistryObjectException, URISyntaxException { List<LibraryFile> libraryFiles = new ArrayList<>(); for (IConfigurationElement libraryFileElement : children) { if (ELEMENT_NAME_LIBRARY_FILE.equals(libraryFileElement.getName())) { MavenCoordinates mavenCoordinates = getMavenCoordinates( libraryFileElement.getChildren(ELEMENT_NAME_MAVEN_COORDINATES)); LibraryFile libraryFile = loadSingleFile(libraryFileElement, mavenCoordinates); libraryFile.updateVersion(); libraryFiles.add(libraryFile); } } return libraryFiles; }
/** * Checks that the given attribute value is not <code>null</code>. * * @param value the value to check if not null * @param attribute the attribute * @throws InvalidRegistryObjectException if the registry element is no longer valid * @throws org.eclipse.core.runtime.CoreException if <code>value</code> is <code>null</code> */ private void checkNotNull(Object value, String attribute) throws InvalidRegistryObjectException, CoreException { if (value == null) { Object[] args = {getId(), fElement.getContributor().getName(), attribute}; String message = Messages.format( JavaTextMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args); IStatus status = new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, null); throw new CoreException(status); } }
Status createExceptionStatus(InvalidRegistryObjectException x) { // extension has become invalid - log & disable String disable = createBlameMessage(); String reason = JavaTextMessages.CompletionProposalComputerDescriptor_reason_invalid; return new Status( IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, disable + " " + reason, x); // $NON-NLS-1$ }
protected void readElement(IConfigurationElement element) { try { declaringExtensionId = element.getDeclaringExtension() .getNamespace(); } catch (InvalidRegistryObjectException e) { Logger.logException(e); } if (TAG_CONTRIBUTION.equals(element.getName())) { IConfigurationElement[] mappingInfoElementList = element .getChildren(SchemaStoreCatalogConstants.TAG_SCHEMA); processMappingInfoElements(mappingInfoElementList); } }
public Map<String, IHawkFactory> getHawkFactoryInstances() { final Map<String, IHawkFactory> ids = new HashMap<>(); for (IConfigurationElement elem : getHawkFactories()) { try { ids.put(elem.getAttribute(HAWKFACTORY_CLASS_ATTRIBUTE), (IHawkFactory) elem .createExecutableExtension(HAWKFACTORY_CLASS_ATTRIBUTE)); } catch (InvalidRegistryObjectException | CoreException e) { // print error and skip this element e.printStackTrace(); } } return ids; }
/** * Checks that the given attribute value is not <code>null</code>. * * @param value the object to check if not null * @param attribute the attribute * @throws InvalidRegistryObjectException if the registry element is no longer valid * @throws CoreException if <code>value</code> is <code>null</code> */ private void checkNotNull(Object value, String attribute) throws InvalidRegistryObjectException, CoreException { if (value == null) { Object[] args= { getId(), fElement.getContributor().getName(), attribute }; String message= Messages.format(JavaTextMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args); IStatus status= new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, null); throw new CoreException(status); } }
/** * Returns the contributor of the described extension. * * @return the contributor of the described extension */ IContributor getContributor() { try { return fElement.getContributor(); } catch (InvalidRegistryObjectException e) { return null; } }
/** * Checks that the given attribute value is not <code>null</code>. * * @param value the value to check if not null * @param attribute the attribute * @throws InvalidRegistryObjectException if the registry element is no longer valid * @throws CoreException if <code>value</code> is <code>null</code> */ private void checkNotNull(Object value, String attribute) throws InvalidRegistryObjectException, CoreException { if (value == null) { Object[] args= { getId(), fElement.getContributor().getName(), attribute }; String message= Messages.format(JavaTextMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args); IStatus status= new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, null); throw new CoreException(status); } }
public IContributor getContributor( ) throws InvalidRegistryObjectException { if( bundle == null ) { IExtension declaringExtn = getDeclaringExtension(); if( declaringExtn != null ) return declaringExtn.getContributor(); return null; } return bundle.getContributor( ); }
private void addFunction(IConfigurationElement conf) throws InvalidRegistryObjectException { Category category = categories.get(conf.getAttribute("categoryID")); if (category == null) category = defaultCategory; String contextID = conf.getAttribute("contextID"); if (INTERNAL_ID.equals(contextID) && !EventPlugin.PLUGIN_ID.equals(conf.getNamespaceIdentifier())) throw new IllegalArgumentException("The internal context can only used in cuina.eventx-Plugin."); ContextTarget context = contexts.get(contextID); if (context == null) throw new NullPointerException("Context '" + contextID + "' is not defined."); String name = conf.getAttribute("name"); if (name.isEmpty()) throw new IllegalArgumentException(); String label = conf.getAttribute("label"); if (label == null) label = name; String description = conf.getAttribute("description"); IConfigurationElement[] childs = conf.getChildren("argument"); String[] argTypes = new String[childs.length]; String[] argNames = new String[childs.length]; for (int i = 0; i < childs.length; i++) { argTypes[i] = childs[i].getAttribute("type"); argNames[i] = childs[i].getAttribute("label"); } addFunction(new FunctionEntry(category, context.getTarget(), context.className, name, label, description, argTypes, argNames)); }
/** * Returns the map of commands. * * @return the map of commands and handler activations. */ private List<ParameterizedCommand> getCommandSet() { IConfigurationElement[] commands = Platform.getExtensionRegistry() .getConfigurationElementsFor("net.dependableos.dcase.diagram.setAttributeContribution"); //$NON-NLS-1$ List<ParameterizedCommand> ret = new ArrayList<ParameterizedCommand>(); try { if (commands != null && commands.length > 0) { for (IConfigurationElement element : commands) { if ("command".equals(element.getName())) { //$NON-NLS-1$ String cmdId = (String) element.getAttribute("commandId"); //$NON-NLS-1$ ParameterizedCommand cmd = getCommandList(cmdId); ret.add(cmd); } } } } catch (InvalidRegistryObjectException e) { throw new DcaseSystemException(e.getMessage(), e, MessageTypeImpl.UNDEFINED); } return ret; }
@Override public String getAttribute(String name) throws InvalidRegistryObjectException { return attributes.get(name); }
@Override public String getAttribute(String attrName, String locale) throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public String getAttributeAsIs(String name) throws InvalidRegistryObjectException { return attributes.get(name); }
@Override public String[] getAttributeNames() throws InvalidRegistryObjectException { return attributes.keySet().toArray(new String[0]); }
@Override public IConfigurationElement[] getChildren() throws InvalidRegistryObjectException { return children.values().toArray(new IConfigurationElement[0]); }
@Override public IConfigurationElement[] getChildren(String name) throws InvalidRegistryObjectException { return new IConfigurationElement[0]; }
@Override public IExtension getDeclaringExtension() throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public String getName() throws InvalidRegistryObjectException { return name; }
@Override public Object getParent() throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public String getValue() throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public String getValue(String locale) throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public String getValueAsIs() throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public String getNamespace() throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public String getNamespaceIdentifier() throws InvalidRegistryObjectException { throw new UnsupportedOperationException(); }
@Override public IContributor getContributor() throws InvalidRegistryObjectException { return contributor; }
public String getAttribute(String name) throws InvalidRegistryObjectException { return null; }
public String getAttribute(String attrName, String locale) throws InvalidRegistryObjectException { return null; }
public String getAttributeAsIs(String name) throws InvalidRegistryObjectException { return null; }
public String[] getAttributeNames() throws InvalidRegistryObjectException { return null; }