📄 upgraderomizedproperties.java
字号:
p.totalPieces = 3; } p = (SkinProperty)allProps.get("softbtn.image_au_bg"); if (p != null) { p.totalPieces = 3; } p = (SkinProperty)allProps.get("stringitem.image_btn"); if (p != null) { p.totalPieces = 9; } p = (SkinProperty)allProps.get("textfield.image_bg"); if (p != null) { p.totalPieces = 9; } p = (SkinProperty)allProps.get("textfield.image_bg_ue"); if (p != null) { p.totalPieces = 9; } p = (SkinProperty)allProps.get("ticker.image_bg"); if (p != null) { p.totalPieces = 3; } p = (SkinProperty)allProps.get("ticker.image_au_bg"); if (p != null) { p.totalPieces = 3; } p = (SkinProperty)allProps.get("title.image_bg"); if (p != null) { p.totalPieces = 3; } p = (SkinProperty)allProps.get("updatebar.image_frame"); if (p != null) { SkinProperty parts = (SkinProperty)allProps.get("updatebar.num_frames"); p.totalPieces = Integer.parseInt(parts.value); } }}/** * The main tool class. */public class UpgradeRomizedProperties { static PrintWriter writer; public static void main(String args[]) { if (args.length != 2) { String u = "Usage: java -cp . UpgradeRomizedProperties <infile> <outfile>"; System.out.println(u); System.exit(0); } Runtime rt = Runtime.getRuntime(); String cmd = "javac -d " + System.getProperty("user.dir") + " " + args[0]; int exitCode; try { Process p = rt.exec(cmd); exitCode = p.waitFor(); } catch (Exception e) { System.err.println(e); System.exit(1); } Hashtable rp = new Hashtable(); Object[] argz = { rp }; try { String cn = "com.sun.midp.chameleon.skins.resources.RomizedProperties"; Class clazz = Class.forName(cn); Method loadProperties; loadProperties = clazz.getMethod("load", new Class[] { Hashtable.class }); loadProperties.invoke(null, argz); } catch (Exception e) { System.err.println(e); System.exit(1); } Converter converter = new Converter(SkinProperty.properties, rp); converter.convert(); try { FileOutputStream fout = new FileOutputStream(args[1]); OutputStreamWriter w = new OutputStreamWriter(fout); writer = new PrintWriter(w); } catch (Exception e) { System.err.println(e); System.exit(1); } printHeader(); printSkinProperties(); printFooter(); writer.close(); reportUnknownProperties(converter.unknownProps); reportMissingProperties(converter.missingProps); } /** * Short-hand for printint a line into the output file */ static void pl(String s) { writer.println(s); } static void printHeader() { pl("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); pl("<!DOCTYPE configuration SYSTEM \"../configuration.dtd\">"); pl("<!--"); pl(" "); pl(""); pl(" Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved."); pl(" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER"); pl(" "); pl(" This program is free software; you can redistribute it and/or"); pl(" modify it under the terms of the GNU General Public License version"); pl(" 2 only, as published by the Free Software Foundation."); pl(" "); pl(" This program is distributed in the hope that it will be useful, but"); pl(" WITHOUT ANY WARRANTY; without even the implied warranty of"); pl(" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU"); pl(" General Public License version 2 for more details (a copy is"); pl(" included at /legal/license.txt)."); pl(" "); pl(" You should have received a copy of the GNU General Public License"); pl(" version 2 along with this work; if not, write to the Free Software"); pl(" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA"); pl(" 02110-1301 USA"); pl(" "); pl(" Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa"); pl(" Clara, CA 95054 or visit www.sun.com if you need additional"); pl(" information or have any questions."); pl("-->"); pl("<configuration>"); pl("<skin>"); pl("<skin_properties KeysClass=" + "\"com.sun.midp.chameleon.skins.SkinPropertiesIDs\">"); } static void printFooter() { pl("</skin_properties>"); pl("</skin>"); pl("</configuration>"); } static void printSkinProperties() { for (int i = 0; i < SkinProperty.properties.length; ++i) { SkinProperty p = SkinProperty.properties[i]; switch (p.type) { case SkinProperty.INT_T: pl(" <integer"); pl(" Key=\"" + p.id + "\""); pl(" Value=\"" + p.value + "\"/>"); break; case SkinProperty.INT_SEQ_T: pl(" <integer_seq"); pl(" Key=\"" + p.id + "\""); pl(" Value=\"" + p.value + "\"/>"); break; case SkinProperty.STRING_T: pl(" <string"); pl(" Key=\"" + p.id + "\""); pl(" Value=\"" + p.value + "\"/>"); break; case SkinProperty.FONT_T: pl(" <font"); pl(" Key=\"" + p.id + "\""); pl(" Value=\"" + p.value + "\"/>"); break; case SkinProperty.IMAGE_T: pl(" <image"); pl(" Key=\"" + p.id + "\""); pl(" Value=\"" + p.value + "\""); pl(" Romized=\"false\"/>"); break; case SkinProperty.C_IMAGE_T: pl(" <composite_image"); pl(" Key=\"" + p.id + "\""); pl(" Value=\"" + p.value + "\""); pl(" Pieces=\"" + p.totalPieces + "\""); pl(" Romized=\"false\"/>"); break; } pl(""); } } static void reportMissingProperties(Vector props) { String msg = "Following properties are used by current Chameleon code, but aren't present\n" +"in romized properties being converted. Old RomizedProperties.java format\n" +"allows omitting some properties. New format forbids that. All the properties\n" +"used by Chameleon must be explicitly given values in RomizedProperties.java.\n" +"Therefore, those properties have been explicitly given default values:"; if (props.size() > 0) { System.out.println(msg); for (int i = 0; i < props.size(); ++i) { SkinProperty p = (SkinProperty)props.get(i); System.out.println(" " + p.name + ": " + '"' + p.value + '"'); } } } static void reportUnknownProperties(Vector props) { String msg = "Following properties aren't used by current Chameleon code, but are present\n" +"in romized properties being converted. Probably you are using modified\n" + "Chameleon code. You'll have to add these properties manually to the\n" + "results of conversion and then modify your Chameleon code accordingly:"; if (props.size() > 0) { System.out.println(msg); for (int i = 0; i < props.size(); ++i) { SkinProperty p = (SkinProperty)props.get(i); System.out.println(" " + p.name + ": " + '"' + p.value + '"'); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -