From 6cb5e41c26d21de0cc601bd6d2834a5bb1e35a90 Mon Sep 17 00:00:00 2001 From: Jeff Jensen Date: Wed, 7 Oct 2026 09:56:32 -0500 Subject: [PATCH] feat(feature): Add the dbUnit icon to the About dialog Eclipse lists a feature in the About dialog only if the bundle that the plugin attribute of the feature names exists. It then takes the feature icon from the about.ini of that bundle, and the name and provider from its manifest. The feature named no bundle, so Eclipse looked for one named like the feature, found none, and left dbUnit out of the dialog. * Name the UI bundle as the branding bundle with the plugin attribute of the feature. Its Bundle-Name and Bundle-Vendor equal the name and provider of the feature. * Add about.ini to the UI bundle, with the 32x32 image of favicon.ico as the feature image, and list it in bin.includes. * Add BundleBrandingTest, which finds about.ini and the image the way the About dialog does, checks that the image is 32x32 pixels, and compares the bundle name and vendor, and the plugin attribute, with the feature. The UI pom passes the directory of the feature to it. * Add the 64x64 @2x image of the feature image, which high-DPI displays use instead of scaling up the 32x32 one. It is the 200x100 logo cut out of the 200x200 logo of the dbUnit core repository and resampled to 64x64 with a Lanczos filter, the same square composition as the 32x32 image of favicon.ico. * Test that the @2x image is next to the feature image and is 64x64 pixels. * Record the change in changes.xml. Refs: 8 Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01S2ejY1wAf9pQyyssAQH7sg --- .../org.dbunit.eclipse.dataset.ui/about.ini | 4 + .../build.properties | 1 + .../icons/about/dbunit32.png | Bin 0 -> 1457 bytes .../icons/about/dbunit32@2x.png | Bin 0 -> 7220 bytes bundles/org.dbunit.eclipse.dataset.ui/pom.xml | 2 + .../dataset/ui/BundleBrandingTest.java | 236 ++++++++++++++++++ .../org.dbunit.eclipse.feature/feature.xml | 8 +- src/changes/changes.xml | 3 +- 8 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 bundles/org.dbunit.eclipse.dataset.ui/about.ini create mode 100644 bundles/org.dbunit.eclipse.dataset.ui/icons/about/dbunit32.png create mode 100644 bundles/org.dbunit.eclipse.dataset.ui/icons/about/dbunit32@2x.png create mode 100644 bundles/org.dbunit.eclipse.dataset.ui/src/test/java/org/dbunit/eclipse/dataset/ui/BundleBrandingTest.java diff --git a/bundles/org.dbunit.eclipse.dataset.ui/about.ini b/bundles/org.dbunit.eclipse.dataset.ui/about.ini new file mode 100644 index 00000000..83ad2e0e --- /dev/null +++ b/bundles/org.dbunit.eclipse.dataset.ui/about.ini @@ -0,0 +1,4 @@ +# Read by the About dialog through the plugin attribute of the feature in feature.xml. +# featureImage: the 32x32 icon of the feature, relative to the root of this bundle. +featureImage=icons/about/dbunit32.png +aboutText=Edit dbUnit dataset files like a spreadsheet diff --git a/bundles/org.dbunit.eclipse.dataset.ui/build.properties b/bundles/org.dbunit.eclipse.dataset.ui/build.properties index 91767b1b..f173bc79 100644 --- a/bundles/org.dbunit.eclipse.dataset.ui/build.properties +++ b/bundles/org.dbunit.eclipse.dataset.ui/build.properties @@ -10,5 +10,6 @@ bin.includes = META-INF/,\ .,\ plugin.properties,\ plugin.xml,\ + about.ini,\ icons/,\ css/ diff --git a/bundles/org.dbunit.eclipse.dataset.ui/icons/about/dbunit32.png b/bundles/org.dbunit.eclipse.dataset.ui/icons/about/dbunit32.png new file mode 100644 index 0000000000000000000000000000000000000000..b77cb779fe9f8cbc1b907eb3a429e8da98769add GIT binary patch literal 1457 zcmV;i1y1^jP)I`I>S#2)(X|Xy1lg(+iI3R#Q00KDKYbib5^_>oS zUIs{dn^|dSCbokBt^y|$;~iq7vdqv{Y*Lk2I>b||GHu5pj7sc+fS?l-TBT7fG$_GQ z3aO3CVq^Oc0NQyWBf%i5*{(zp#;g`WYJ+MkO0l`KXh#7>M|TilM0{#Ym8{QJ!KAXJ zs)C=9U~`FZJQ1R!0LEZJYW*1yiH4B{P0L|OYE%`P+lwdEqH$GGV|8Kcuyb>+V1y3F zi7*r2;$XH4C~_rC#tC{YOwh^xfx$@pvqHJXIT^ZSkx2Ygegjt|u;9{p`D@6z(0KIp&=L4=MCDUTXE zO5E2^rvxTtIS9tO%1oW&#W^=SU-FKC&6n>N)#M(OU+#6}i4?~rYUe{QTTpYcu{Tdp zot-b;hbV$LxgiLWD~9$GK-*G24$W?HrUXM{<;mU=K#9H($vKD=9o6UZ|Ta|F`)g~bg4Y}Y9P zELU64iL}6|D)&dC8v>;6Ljq4A2qoh1FQ*09M%?h<2M?b>6H>AGTLEC}t=udK;5(Ek zBY_6hV#JEAt<uGVNq~~DS{vpSmceLBnXoBhDc7nf}LOUjsPCxp)-A9EE0k& z1iX<*9FM`)OHd>hreLQDVifd9QqVszwB2q>C32A(=^Xm5UYj=LB z?I?i#mqQjNDAb^@+IK>er1?&RIF5w6olQN#n>j`Eg z*#3o+V)?cAyTU52peB#kv{!KH8|0XK`c8ykG7@Np(4EgCR-px+J%72lxVXH$`dk&Le8|H05KbZGP=eRU;?GA#JQrI`dk(eYh}j>lMC8dta0bzOJshJFT) zJ=!@Hdi(0YbW^uQ+G(l2GI_39f4pJnSOZ$2(4_c9KA0gDwKx9-TJv1Dyo3<300000 LNkvXXu0mjf7bw1( literal 0 HcmV?d00001 diff --git a/bundles/org.dbunit.eclipse.dataset.ui/icons/about/dbunit32@2x.png b/bundles/org.dbunit.eclipse.dataset.ui/icons/about/dbunit32@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..17d995fadb2fb4feed6d8ec24a080e49e269a9b9 GIT binary patch literal 7220 zcmV-49LwX0P)000~NNklnRkDf^?thFeF_lmx%Z9TzO_EI^`~?`s&qvjco(cj=`o*4MNvY%Y)&T2O|jG!?Nxn zK)OR8Pm$J>wlur@DHlyZWZO`X{;vrydT@bPvv;= zf$8?%31}vNJlfnf*x1outLm+6eq2)DSy0<1yeH2nYe^N=C*{^U6;{bOX}O}J`=a6+ zQE_#CaZP?n4ID*9)quR>YT*u;J6mlSh#ZYeYPV2YBQC9eA2s5gn`JfP@|uG38aOE^ zuPv;Q6qeN?zzZ~$B9Q{>>Y5yoFnD)f&tU6*bDgBA zt`;DbAT-uV8tW0H^>qk4uS@Ei>*|}~#kz(q)HgQQHMR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Ft~G*V4G-XUwO~`mNeJO0weg=8y5^`@Xq-0MaLHmO=FcwNw-r;cvy)U~TzvaS8bb)M&Pl~$_&%-C))BD<& ztjiZ-QwK&TkpIQ#PeuTyJ(c>m5J1~dkR?#a+MW!Ir{`2fTuAW_i~Elgx4!X@JsfzG z6@Kgd_0*!u#;Lglk_JZyDOD2t=xq(ZB*1u~l4?0fU>R*SFn|1B35U;x!iSwH4Z&Pv z*Xc}C(+dxu^vl~iWNm7BN7uui!MV9buv8l688A@z3sXV*Gz5z8w>k)rj_pJrwO7JX zz1mWwbsWkFjE{odBs7fxITG0ZLckOY=itx`D1mMuz^z#c()im5&|3tGs${>~2AB$$ z8CA-VN+4fuKyDk&lzNouH#@$mN3%Q4Oy_2_uZ3_-DZiBfM5AauP0K;~3MA2HFdGShB-(q1c4d(9c5Fd` z(7y3=vGkEs(S2F3W&)~rlw;SLqXo0GjdWo94g+S_8nJz3dP#2Yiet9WIRH^7S*(sNIFX-T_ts0 za4fFvD6DQ1SE)pmikwneR&i5$p;VCHz!gf8b7~SYt76md-AJjt&MUvlDY=|jbRn_u z$ArQk;tM{&*?95UI59eY5-^`SA6s<(R?)@ed;bL(g1S&vz&2L^0000 ${project.build.directory} + + ${project.basedir}/../../features/org.dbunit.eclipse.feature diff --git a/bundles/org.dbunit.eclipse.dataset.ui/src/test/java/org/dbunit/eclipse/dataset/ui/BundleBrandingTest.java b/bundles/org.dbunit.eclipse.dataset.ui/src/test/java/org/dbunit/eclipse/dataset/ui/BundleBrandingTest.java new file mode 100644 index 00000000..d6d44342 --- /dev/null +++ b/bundles/org.dbunit.eclipse.dataset.ui/src/test/java/org/dbunit/eclipse/dataset/ui/BundleBrandingTest.java @@ -0,0 +1,236 @@ +/* + * + * The DbUnit Database Testing Framework + * Copyright (C)2002-2026, DbUnit.org + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package org.dbunit.eclipse.dataset.ui; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Dictionary; +import java.util.Properties; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.Point; +import org.junit.jupiter.api.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; +import org.osgi.framework.FrameworkUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +/** + * Guards what the About dialog needs to show the feature. It finds the feature icon in the about.ini of the + * bundle that the plugin attribute of the feature names, and lists the name and provider from the manifest + * of that bundle. The tests that read the feature run under Maven, whose UI pom passes its directory. + */ +class BundleBrandingTest +{ + private static final String ABOUT_INI = "$nl$/about.ini"; + + private static final String FEATURE_IMAGE_KEY = "featureImage"; + + private static final String FEATURE_NAME_KEY = "featureName"; + + private static final String PROVIDER_NAME_KEY = "providerName"; + + private static final String DOUBLE_SIZE_SUFFIX = "@2x"; + + private static final String FEATURE_DIRECTORY_PROPERTY = "dbunit.feature.directory"; + + private static final String ABOUT_INI_ADVICE = + "about.ini must be at the root of the bundle: list it in bin.includes of build.properties."; + + private static final String FEATURE_IMAGE_KEY_ADVICE = + "about.ini must set featureImage to the path of the feature image."; + + private static final String FEATURE_IMAGE_ADVICE = + "The feature image must be in the bundle: list its folder in bin.includes of build.properties."; + + private static final String IMAGE_SIZE_ADVICE = + "The About dialog shows the image at its own size, so it must be 32 by 32 pixels."; + + private static final String DOUBLE_SIZE_IMAGE_ADVICE = + "The feature image needs a copy named with @2x before its extension, for high-DPI displays."; + + private static final String DOUBLE_SIZE_ADVICE = + "A 200% display shows the @2x image at half its size, so it must be 64 by 64 pixels."; + + private static final String BRANDING_ADVICE = + "The About dialog lists the feature by the Bundle-Name and Bundle-Vendor of its branding" + + " bundle, so they must equal featureName and providerName in feature.properties."; + + private static final String FEATURE_PLUGIN_ADVICE = + "The plugin attribute of feature.xml must name the bundle that has about.ini," + + " or the About dialog leaves the feature out."; + + private static final String FEATURE_DIRECTORY_ADVICE = "The UI pom passes the feature directory as the" + + " system property " + FEATURE_DIRECTORY_PROPERTY + "."; + + private record Branding(String name, String provider) + { + } + + @Test + void testAboutIni_whenLocatedLikeTheAboutDialog_isPackagedAtTheRootOfTheBundle() + { + final Bundle bundle = FrameworkUtil.getBundle(DatasetUiPlugin.class); + + final URL aboutIni = findAboutIni(bundle); + + assertThat(aboutIni).as(ABOUT_INI_ADVICE).isNotNull(); + } + + @Test + void testFeatureImage_whenResolvedLikeTheAboutDialog_isAnImageOf32By32Pixels() throws IOException + { + final Bundle bundle = FrameworkUtil.getBundle(DatasetUiPlugin.class); + final String featureImage = readFeatureImagePath(bundle); + + final Point size = readImageSize(bundle, featureImage, FEATURE_IMAGE_ADVICE); + + assertThat(size).as(IMAGE_SIZE_ADVICE).isEqualTo(new Point(32, 32)); + } + + @Test + void testFeatureImage_whenResolvedForHighDpiDisplays_isAnImageOf64By64Pixels() throws IOException + { + final Bundle bundle = FrameworkUtil.getBundle(DatasetUiPlugin.class); + final String featureImage = readFeatureImagePath(bundle); + final String doubleSizeImage = withDoubleSizeSuffix(featureImage); + + final Point size = readImageSize(bundle, doubleSizeImage, DOUBLE_SIZE_IMAGE_ADVICE); + + assertThat(size).as(DOUBLE_SIZE_ADVICE).isEqualTo(new Point(64, 64)); + } + + @Test + void testBundleHeaders_whenListedByTheAboutDialog_matchTheNameAndProviderOfTheFeature() throws IOException + { + final Bundle bundle = FrameworkUtil.getBundle(DatasetUiPlugin.class); + final Dictionary headers = bundle.getHeaders(); + final String bundleName = headers.get(Constants.BUNDLE_NAME); + final String bundleVendor = headers.get(Constants.BUNDLE_VENDOR); + final Branding bundleBranding = new Branding(bundleName, bundleVendor); + final Properties featureProperties = readFeatureProperties(); + final String featureName = featureProperties.getProperty(FEATURE_NAME_KEY); + final String providerName = featureProperties.getProperty(PROVIDER_NAME_KEY); + final Branding featureBranding = new Branding(featureName, providerName); + + assertThat(bundleBranding).as(BRANDING_ADVICE).isEqualTo(featureBranding); + } + + @Test + void testFeature_whenReadFromTheFeatureProject_namesTheUiBundleAsItsBrandingPlugin() + throws IOException, ParserConfigurationException, SAXException + { + final Path featureXml = featureDirectory().resolve("feature.xml"); + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + final DocumentBuilder builder = factory.newDocumentBuilder(); + final String brandingPlugin; + try (InputStream stream = Files.newInputStream(featureXml)) + { + final Document feature = builder.parse(stream); + final Element root = feature.getDocumentElement(); + brandingPlugin = root.getAttribute("plugin"); + } + + assertThat(brandingPlugin).as(FEATURE_PLUGIN_ADVICE).isEqualTo(DatasetUiPlugin.PLUGIN_ID); + } + + private static URL findAboutIni(final Bundle bundle) + { + final IPath aboutIniPath = IPath.fromOSString(ABOUT_INI); + return FileLocator.find(bundle, aboutIniPath, null); + } + + private static Properties readAboutIni(final Bundle bundle) throws IOException + { + final URL aboutIni = findAboutIni(bundle); + assertThat(aboutIni).as(ABOUT_INI_ADVICE).isNotNull(); + final Properties properties = new Properties(); + try (InputStream stream = aboutIni.openStream()) + { + properties.load(stream); + } + return properties; + } + + private static String readFeatureImagePath(final Bundle bundle) throws IOException + { + final Properties aboutIni = readAboutIni(bundle); + final String featureImage = aboutIni.getProperty(FEATURE_IMAGE_KEY); + assertThat(featureImage).as(FEATURE_IMAGE_KEY_ADVICE).isNotNull(); + return featureImage; + } + + private static Point readImageSize(final Bundle bundle, final String path, final String advice) + throws IOException + { + final IPath imagePath = IPath.fromOSString(path); + final URL imageUrl = FileLocator.find(bundle, imagePath, null); + assertThat(imageUrl).as(advice).isNotNull(); + try (InputStream stream = imageUrl.openStream()) + { + final ImageData image = new ImageData(stream); + return new Point(image.width, image.height); + } + } + + private static String withDoubleSizeSuffix(final String imagePath) + { + final int extensionStart = imagePath.lastIndexOf('.'); + final String name = imagePath.substring(0, extensionStart); + final String extension = imagePath.substring(extensionStart); + return name + DOUBLE_SIZE_SUFFIX + extension; + } + + private static Properties readFeatureProperties() throws IOException + { + final Path featureProperties = featureDirectory().resolve("feature.properties"); + final Properties properties = new Properties(); + try (InputStream stream = Files.newInputStream(featureProperties)) + { + properties.load(stream); + } + return properties; + } + + private static Path featureDirectory() + { + final String directory = System.getProperty(FEATURE_DIRECTORY_PROPERTY); + assumeTrue(directory != null, FEATURE_DIRECTORY_ADVICE); + final Path featureDirectory = Path.of(directory); + return featureDirectory.normalize(); + } +} diff --git a/features/org.dbunit.eclipse.feature/feature.xml b/features/org.dbunit.eclipse.feature/feature.xml index 4c91b4ba..35095e78 100644 --- a/features/org.dbunit.eclipse.feature/feature.xml +++ b/features/org.dbunit.eclipse.feature/feature.xml @@ -3,7 +3,13 @@ id="org.dbunit.eclipse.feature" label="%featureName" version="1.0.1.qualifier" - provider-name="%providerName"> + provider-name="%providerName" + plugin="org.dbunit.eclipse.dataset.ui"> + + %description diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7ab5b50a..e2724790 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -7,7 +7,8 @@ - + + Add the dbUnit icon to the Eclipse About dialog. Add the dbUnit Dataset Editor, a spreadsheet-like editor for dbUnit flat XML dataset files.