Community
Participate
Working Groups
It would be great to preview colors somehow when editing CSS rules (e.g. background-color: #EBD957;): - either as popup on hovering, like in Firebug - or as small squares (near the color value or maybe somewhere in vertical ruler/overview ruler), like in Opera Dragonfly
This is indeed something I always thought could be handy.
Created attachment 207631 [details] patch
Released the changes to HEAD for Juno.
Oh, and it's implemented as a text hover. So just hover over a color value and it'll popup with a square with the appropriate color.
(In reply to comment #3) > Released the changes to HEAD for Juno. Will it work if I install it in Eclipse 3.7.1? I would like to use it ASAP :)
(In reply to comment #2) > Created attachment 207631 [details] Check for null at line 52 is redundant: 52 if (region != null) { 53 if (region instanceof ICSSPrimitiveValue) { 54 return getColorValue((ICSSPrimitiveValue) region); 55 } 56 } - in this case instanceof will return false accordingly to JLS, so code may be simplified to if (region instanceof ICSSPrimitiveValue) { return getColorValue((ICSSPrimitiveValue) region); }
Also the code in private RGB getRGBFromHex(String hex) can be simplified (no loops, arrays, StringBuffers, string copying): private RGB getRGBFromHex(String hex) { int r, g, b; try { if (hex.length() == 4) { // 3-digit notation "#rgb" r = Integer.parseInt(hex.substring(1, 2), 16); g = Integer.parseInt(hex.substring(2, 3), 16); b = Integer.parseInt(hex.substring(3, 4), 16); r = (r << 4) | r; g = (g << 4) | g; b = (b << 4) | b; return new RGB(r, g, b); } else if (hex.length() == 7) { // 6-digit notation "#rrggbb" r = Integer.parseInt(hex.substring(1, 3), 16); g = Integer.parseInt(hex.substring(3, 5), 16); b = Integer.parseInt(hex.substring(5, 7), 16); return new RGB(r, g, b); } } catch (NumberFormatException e) { // Invalid hexcode used. } return null; }
(In reply to comment #5) > (In reply to comment #3) > > Released the changes to HEAD for Juno. > > Will it work if I install it in Eclipse 3.7.1? I would like to use it ASAP :) Nope. The new functionality will be in Juno. Thanks for checking out the code. I removed the redundant null check between the time I attached this patch and releasing the code. I'll simplify the hex extraction, not quite sure why I chose the loop route.