From: changhyun1.lee Date: Tue, 11 Dec 2012 14:28:28 +0000 (+0900) Subject: [Title] Added PluginUtil#loadClassAttribute X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01dbd791ec3aeefe4d38f20ca48b91194e79e53a;p=sdk%2Fide%2Fcommon-eplugin.git [Title] Added PluginUtil#loadClassAttribute [Desc.] [Issue] Redmine-7495 Change-Id: I5de65f47357f448856c219c05976893fc5fee2b7 --- diff --git a/org.tizen.common/src/org/tizen/common/util/PluginUtil.java b/org.tizen.common/src/org/tizen/common/util/PluginUtil.java index a451c48..b1bd640 100644 --- a/org.tizen.common/src/org/tizen/common/util/PluginUtil.java +++ b/org.tizen.common/src/org/tizen/common/util/PluginUtil.java @@ -78,7 +78,7 @@ public class PluginUtil { } /** - * Return class of specific class id which extends specific extension point id. + * Return class of specific class id which extends specific extension point id. * @param extPointId - extension point id. * @param classId - class id. * @return object class of specific class id which extends specific extension point id. @@ -102,4 +102,30 @@ public class PluginUtil { } return null; } + + /** + * Return object of specific attribute which extends specific extension point id. + * @param extPointId - extension point id. + * @param attribute - attribute. + * @return object of specific attribute which extends specific extension point id. + */ + public static Object[] getExtensionAttribute(String extPointId, String attribute) throws CoreException { + IExtensionRegistry registry = platformSurrogate.getAdapter(); + IExtensionPoint ep = registry.getExtensionPoint(extPointId ); + IExtension[] exts = ep.getExtensions(); + List values = new ArrayList(); + + for ( IExtension ext : exts ) { + IConfigurationElement[] configs = ext.getConfigurationElements(); + for ( final IConfigurationElement config : configs ) { + String value = config.getAttribute(attribute); + if (value != null && !value.isEmpty()) { + values.add(value); + } + } + } + + return values.toArray(); + } + } diff --git a/org.tizen.common/test/src/org/tizen/common/util/PluginUtilTest.java b/org.tizen.common/test/src/org/tizen/common/util/PluginUtilTest.java index 5fccdcf..7760c43 100644 --- a/org.tizen.common/test/src/org/tizen/common/util/PluginUtilTest.java +++ b/org.tizen.common/test/src/org/tizen/common/util/PluginUtilTest.java @@ -121,4 +121,17 @@ public class PluginUtilTest { Mockito.verify(config).createExecutableExtension("class"); } + /** + * Test {@link PluginUtil#getExtensionAttribute(String, String)} + * + * @throws Exception in case of failure in test + * + * @see PluginUtil#getExtensionAttribute(String, String) + */ + @Test + public void testGetExtensionAttribute() throws Exception { + when(config.getAttribute("extension")).thenReturn("css"); + PluginUtil.getExtensionAttribute(TEST_EXT_ID, "extension"); + Mockito.verify(config).getAttribute("extension"); + } }