/** * Returns the DataSetUIElement instance that represents the dataSetUI element with the given id * defined in this data source extension. If the given data set element id is null and the data * source UI extension has only one data set element, that data set element will be returned by * default. * * @param dataSetElementID the id of the data set ui element. * @return the data set element definition. * @throws OdaException if there is no data set ui definition associated with the specified data * set element id, or if there are more than one data set elements when no element id is * specified. */ public DataSetUIElement getDataSetUIElement(String dataSetElementID) throws OdaException { if (dataSetElementID == null || dataSetElementID.length() == 0) { // find default data set element and return it if found if (m_dataSetUIElements == null || m_dataSetUIElements.size() != 1) throw new OdaException(Messages.manifest_missingDataSetElementId); Collection dataSetTypes = m_dataSetUIElements.values(); assert (dataSetTypes.size() == 1); return (DataSetUIElement) dataSetTypes.toArray()[0]; } DataSetUIElement dataSetUIDefn = (DataSetUIElement) m_dataSetUIElements.get(dataSetElementID); if (dataSetUIDefn == null) throw new OdaException( Messages.bind(Messages.manifest_invalidDataSetElementId, dataSetElementID)); return dataSetUIDefn; }
/** Returns a collection of dataSetUI elements in the given extension. */ private Hashtable getDataSetUIElements(IExtension extension) throws OdaException { Hashtable dataSetElements = new Hashtable(); IConfigurationElement[] configElements = UIManifestExplorer.getNamedElements(extension, DATA_SET_ELEMENT_NAME); for (int i = 0, size = configElements.length; i < size; i++) { IConfigurationElement configElement = configElements[i]; String dataSetId = configElement.getAttribute("id"); // $NON-NLS-1$ // if duplicated data set ids exist in the extension, // only the last one applies dataSetElements.put(dataSetId, new DataSetUIElement(configElement)); } if (dataSetElements.size() < 1) // expects one or more throw new OdaException( Messages.bind(Messages.manifest_dataSetUi_missingElement, DATA_SET_ELEMENT_NAME)); return dataSetElements; }
UIExtensionManifest(IExtension dataSourceExtn) throws OdaException { // first process the dataSourceUI element IConfigurationElement dataSourceElement = UIManifestExplorer.getNamedElement(dataSourceExtn, DATA_SOURCE_ELEMENT_NAME); assert (dataSourceElement != null); m_namespace = dataSourceExtn.getContributor().getName(); // first cache the data source element's attributes m_dataSourceElementId = dataSourceElement.getAttribute("id"); // $NON-NLS-1$ assert (m_dataSourceElementId != null && m_dataSourceElementId.length() > 0); // newDataSourceWizard element associated with dataSourceUI IConfigurationElement[] newWizardElements = dataSourceElement.getChildren(DATA_SOURCE_WIZARD_ELEMENT_NAME); if (newWizardElements.length < 1) // expects one element throw new OdaException( Messages.bind(Messages.manifest_missingAttributeValue, DATA_SOURCE_WIZARD_ELEMENT_NAME)); m_dataSourceWizardInfo = new DataSourceWizardInfo(newWizardElements[0]); // data set UI definition elements in the same extension m_dataSetUIElements = getDataSetUIElements(dataSourceExtn); }