Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2013-11-13 23:06:47 -0500
committerMykola Nikishov2016-04-19 13:44:31 -0400
commitb1b3edccf441e5b5edf90e4c9cc08acf6d197f92 (patch)
tree350ab1d9b0dc1212136c70e7161bd08a3fcb2218
parentbff55f297a5c1f61add01419da9671cfea908c46 (diff)
downloadrt.equinox.p2-b1b3edccf441e5b5edf90e4c9cc08acf6d197f92.tar.gz
rt.equinox.p2-b1b3edccf441e5b5edf90e4c9cc08acf6d197f92.tar.xz
rt.equinox.p2-b1b3edccf441e5b5edf90e4c9cc08acf6d197f92.zip
Bug 471875 - [IconExe] Improve error message when launcher's icons has not been replaced
Provide more details in error message and show what icons actually has not been replaced: [IconExe] Error - 3 original icon(s) not replaced in /win/eclipse.exe: - 48x48, 32 bits, 9640 byte(s) @ 38384 - 32x32, 32 bits, 4264 byte(s) @ 48024 - 16x16, 32 bits, 1128 byte(s) @ 52288 We don't know what input files were actually used (we accept one or more files with icons) thus not reporting input filename in error message. Also restore documentation about icons used in launcher 3.4 for Windows by partially reverting commit a2f9d54d4ec55e27d28b6c522a2940b309729f11. Because the source code is the only source of information about requirements for icons, show the link to the browsable source code in error message. Change-Id: I900253ae3851d882b07ebbde1c827e32d1bd419e Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java90
1 files changed, 63 insertions, 27 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java
index ecbdb06aa..2caadb3c7 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java
@@ -37,19 +37,29 @@ public class IconExe {
* Note 1. Write access to the executable program is required. As a result, that
* program must not be currently running or edited elsewhere.
*
- * Note 2. The Eclipse 4.2 launcher requires an .ico file with the following 7 images (in any order).
+ * Note 2. The Eclipse 3.4 launcher requires an .ico file with the following 7 images (in any order).
+ * 1. 48x48, 32 bit (RGB / Alpha Channel)
+ * 2. 32x32, 32 bit (RGB / Alpha Channel)
+ * 3. 16x16, 32 bit (RGB / Alpha Channel)
+ * 4. 48x48, 8 bit (256 colors)
+ * 5. 32x32, 8 bit (256 colors)
+ * 6. 24x24, 8 bit (256 colors)
+ * 7. 16x16, 8 bit (256 colors)
+ *
+ * Note 3. The Eclipse 4.2 launcher requires an .ico file with the following 7 images (in any order).
* 1. 256x256, 32 bit (RGB / Alpha Channel)
* 2. 48x48, 32 bit (RGB / Alpha Channel)
* 3. 32x32, 32 bit (RGB / Alpha Channel)
* 4. 16x16, 32 bit (RGB / Alpha Channel)
* 5. 48x48, 8 bit (256 colors)
* 6. 32x32, 8 bit (256 colors)
- * 7. 16x16, 8 bit (256 colors)
+ * 7. 16x16, 8 bit (256 colors)
+ *
* A user icon matching exactly the width/height/depth of an executable icon will be written
* to the executable and will replace that executable icon. If an executable icon
* does not match a user icon, it is silently left as is.
- *
- * Note 3. This function modifies the content of the executable program and may cause
+ *
+ * Note 4. This function modifies the content of the executable program and may cause
* its corruption.
*/
public static void main(String[] args) throws Exception {
@@ -74,9 +84,15 @@ public class IconExe {
ImageData[] data = new ImageData[images.size()];
data = images.toArray(data);
- int nMissing = unloadIcons(args[0], data);
- if (nMissing != 0)
- System.err.println("Error - " + nMissing + " icon(s) not replaced in " + args[0] + " using " + args[1]); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ List<IconResInfo> unchangedIcons = unloadIcons(args[0], data);
+ if (unchangedIcons.size() != 0) {
+ System.err.println(String.format("[IconExe] Error - %d original icon(s) not replaced in %s:", unchangedIcons.size(), args[0])); //$NON-NLS-1$
+ for (IconResInfo icon : unchangedIcons) {
+ ImageData iconData = icon.data;
+ System.err.println(String.format("\t- %dx%d, %d bits, %d byte(s) @ %d", iconData.height, iconData.width, iconData.depth, icon.size, icon.offset)); //$NON-NLS-1$
+ }
+ System.err.println("[IconExe] For more details, see https://git.eclipse.org/c/equinox/rt.equinox.p2.git/tree/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java"); //$NON-NLS-1$
+ }
}
/* Implementation */
@@ -85,15 +101,24 @@ public class IconExe {
* Retrieve the Desktop icons provided in the Windows executable program.
* These icons are typically shown in various places of the Windows desktop.
*
- * Note 2. The Eclipse 4.2 launcher requires an .ico file with the following 7 images (in any order).
+ * Note. The Eclipse 3.4 launcher returns the following 7 images (in any order).
+ * 1. 48x48, 32 bit (RGB / Alpha Channel)
+ * 2. 32x32, 32 bit (RGB / Alpha Channel)
+ * 3. 16x16, 32 bit (RGB / Alpha Channel)
+ * 4. 48x48, 8 bit (256 colors)
+ * 5. 32x32, 8 bit (256 colors)
+ * 6. 24x24, 8 bit (256 colors)
+ * 7. 16x16, 8 bit (256 colors)
+ *
+ * Note 1. The Eclipse 4.2 launcher requires an .ico file with the following 7 images (in any order).
* 1. 256x256, 32 bit (RGB / Alpha Channel)
* 2. 48x48, 32 bit (RGB / Alpha Channel)
* 3. 32x32, 32 bit (RGB / Alpha Channel)
* 4. 16x16, 32 bit (RGB / Alpha Channel)
* 5. 48x48, 8 bit (256 colors)
* 6. 32x32, 8 bit (256 colors)
- * 7. 16x16, 8 bit (256 colors)
- *
+ * 7. 16x16, 8 bit (256 colors)
+ *
* @param program the Windows executable e.g c:/eclipse/eclipse.exe
*/
static ImageData[] loadIcons(String program) throws FileNotFoundException, IOException {
@@ -122,47 +147,58 @@ public class IconExe {
* the number of icons to write. Finally, use loadIcons after this operation
* to verify the icons have changed as expected.
*
- * Note 3. The Eclipse 4.2 launcher requires the following 7 images (in any order).
+ * Note 3. The Eclipse 3.4 launcher requires the following 7 images (in any order).
+ * 1. 48x48, 32 bit (RGB / Alpha Channel)
+ * 2. 32x32, 32 bit (RGB / Alpha Channel)
+ * 3. 16x16, 32 bit (RGB / Alpha Channel)
+ * 4. 48x48, 8 bit (256 colors)
+ * 5. 32x32, 8 bit (256 colors)
+ * 6. 24x24, 8 bit (256 colors)
+ * 7. 16x16, 8 bit (256 colors)
+ *
+ * Note 4. The Eclipse 4.2 launcher requires the following 7 images (in any order).
* 1. 256x256, 32 bit (RGB / Alpha Channel)
* 2. 48x48, 32 bit (RGB / Alpha Channel)
* 3. 32x32, 32 bit (RGB / Alpha Channel)
* 4. 16x16, 32 bit (RGB / Alpha Channel)
* 5. 48x48, 8 bit (256 colors)
* 6. 32x32, 8 bit (256 colors)
- * 7. 16x16, 8 bit (256 colors)
- *
+ * 7. 16x16, 8 bit (256 colors)
+ *
* Note 4. This function modifies the content of the executable program and may cause
* its corruption.
*
* @param program the Windows executable e.g c:/eclipse/eclipse.exe
* @param icons to write to the given executable
- * @return the number of icons from the original program that were not successfully replaced (0 if success)
+ * @return the list of icons from the original program that were not successfully replaced (empty if success)
*/
- static int unloadIcons(String program, ImageData[] icons) throws FileNotFoundException, IOException {
+ static List<IconResInfo> unloadIcons(String program, ImageData[] icons) throws FileNotFoundException, IOException {
RandomAccessFile raf = new RandomAccessFile(program, "rw"); //$NON-NLS-1$
IconExe iconExe = new IconExe();
- IconResInfo[] iconInfo = iconExe.getIcons(raf);
+ List<IconResInfo> iconInfo = new ArrayList<IconExe.IconResInfo>(Arrays.asList(iconExe.getIcons(raf)));
// Display an error if no icons found in target executable.
- if (iconInfo.length == 0) {
+ if (iconInfo.isEmpty()) {
System.err.println("Warning - no icons detected in \"" + program + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
raf.close();
- return 0;
+ return Collections.emptyList();
}
- int cnt = 0;
- for (int i = 0; i < iconInfo.length; i++) {
- for (int j = 0; j < icons.length; j++) {
- if (icons[j] == null)
+ Iterator<IconResInfo> originalIconsIterator = iconInfo.iterator();
+ while (originalIconsIterator.hasNext()) {
+ IconResInfo iconToReplace = originalIconsIterator.next();
+ for (ImageData iconToWrite : Arrays.asList(icons)) {
+ if (iconToWrite == null)
continue;
- if (iconInfo[i].data.width == icons[j].width && iconInfo[i].data.height == icons[j].height && iconInfo[i].data.depth == icons[j].depth) {
- raf.seek(iconInfo[i].offset);
- unloadIcon(raf, icons[j]);
- cnt++;
+
+ if (iconToReplace.data.width == iconToWrite.width && iconToReplace.data.height == iconToWrite.height && iconToReplace.data.depth == iconToWrite.depth) {
+ raf.seek(iconToReplace.offset);
+ unloadIcon(raf, iconToWrite);
+ originalIconsIterator.remove();
break;
}
}
}
raf.close();
- return iconInfo.length - cnt;
+ return iconInfo;
}
public static final String VERSION = "20050124"; //$NON-NLS-1$

Back to the top