processStyle( style, codeList, styleSheet, device, env );
processStyle( style, codeList, staticCodeList, styleSheet, device, env );
	public void convertStyleSheet( StringList sourceCode, 								   StyleSheet styleSheet, 								   Device device,								   Preprocessor preprocessor,								   Environment env ) 	{		this.abbreviationGenerator = null;		// search for the position to include the style-sheet definitions:		int index = -1;		while (sourceCode.next()) {			String line = sourceCode.getCurrent();			if (INCLUDE_MARK.equals(line)) {				index = sourceCode.getCurrentIndex() + 1;				break;			}		}		if (index == -1) {			throw new BuildException("Unable to modify StyleSheet.java, include point [" + INCLUDE_MARK + "] not found.");		}		// okay start with the creation of source code:		ArrayList codeList = new ArrayList();		this.referencedStyles = new ArrayList();		// initialise the syle sheet:		styleSheet.inherit();		// set the color-definitions:		this.colorConverter.setTemporaryColors( styleSheet.getColors() );		// add the font-definitions:		boolean defaultFontDefined = false;		HashMap fonts = styleSheet.getFonts();		Set keys = fonts.keySet();		for (Iterator iter = keys.iterator(); iter.hasNext();) {			String groupName = (String) iter.next();			//System.out.println("processing font " + fonts.get( groupName ) );			if ("default".equals(groupName)) {				defaultFontDefined = true;				HashMap group = (HashMap) fonts.get( groupName );				processFont(group, groupName, null, codeList, styleSheet, true, env );			} else {				HashMap group = (HashMap) fonts.get( groupName );				processFont(group, groupName, null, codeList, styleSheet, true, env );			}		}				// add the backgrounds-definition:		boolean defaultBackgroundDefined = false;		HashMap backgrounds = styleSheet.getBackgrounds();		keys = backgrounds.keySet();		for (Iterator iter = keys.iterator(); iter.hasNext();) {			String groupName = (String) iter.next();			if ("default".equals(groupName)) {				defaultBackgroundDefined = true;			} 			HashMap group = (HashMap) backgrounds.get( groupName );			processBackground(groupName, group, null, codeList, styleSheet, true );		}				// add the borders-definition:		boolean defaultBorderDefined = false;		HashMap borders = styleSheet.getBorders();		keys = borders.keySet();		for (Iterator iter = keys.iterator(); iter.hasNext();) {			String groupName = (String) iter.next();			if ("default".equals(groupName)) {				defaultBorderDefined = true;			} 			HashMap group = (HashMap) borders.get( groupName );			processBorder(groupName, group, null, codeList, styleSheet, true );		}		String test = env.getVariable("polish.license");//		if ( "GPL".equals(test) ) {//			// GPL license is fine.//		} else if (test == null || test.length() != 12) {//			throw new BuildException("Encountered invalid license.");//		} else {//			try {//				Long.parseLong(test, 0x10);//			} catch (Exception e) {//				throw new BuildException("Encountered invalid license.");//			}//		}		// add the default style:		processDefaultStyle( defaultFontDefined,  				defaultBackgroundDefined, defaultBorderDefined,				codeList, styleSheet, device, env  );						// now add all other static and referenced styles:		ArrayList defaultStyleNames = new ArrayList();		defaultStyleNames.add( "default");		defaultStyleNames.add( "label");		defaultStyleNames.add( "focused");		// check if fullscreen mode is enabled with menu:		if ((env.hasSymbol("polish.useMenuFullScreen") 			&& ((device.getCapability("polish.classes.fullscreen") != null) 					|| (device.isMidp2() && env.hasSymbol("polish.hasCommandKeyEvents") ) ))			|| env.hasSymbol("polish.needsManualMenu") 			) 		{			defaultStyleNames.add( "menu");			defaultStyleNames.add( "menuitem");		}				String[] defaultNames = (String[]) defaultStyleNames.toArray( new String[ defaultStyleNames.size() ]);		Style[] styles = styleSheet.getUsedAndReferencedStyles(defaultNames);		boolean isLabelStyleReferenced = false;		codeList.add("\t//static and referenced styles:");		for (int i = 0; i < styles.length; i++) {			Style style = styles[i];			if (!"default".equals(style.getSelector())) {				if ("label".equals(style.getSelector())) {					isLabelStyleReferenced = true;				}				processStyle( style, codeList, styleSheet, device, env );			}		}		codeList.add( STANDALONE_MODIFIER + "String lic=\"" + test +"\";");				/*		String[] styleNames = styleSheet.getUsedStyleNames();		//System.out.println("processing [" + styleNames.length + "] styles.");		int insertIndexForReferencedStyles = codeList.size();		codeList.add("\t//normal used styles:");		for (int i = 0; i < styleNames.length; i++) {			String styleName = styleNames[i];			if (!styleName.equals("default")) {				Style style = styleSheet.getStyle( styleName );				processStyle( style, codeList, styleSheet, device );			}		}		codeList.add( STANDALONE_MODIFIER + "String lic=\"" + test +"\";");				// process referenced styles:		styles = (Style[]) this.referencedStyles.toArray( new Style[ this.referencedStyles.size() ] );		boolean isLabelStyleReferenced = false;		if (styles.length > 0) {			ArrayList referencedCode = new ArrayList();			referencedCode.add("\t//referenced styles:");			for (int i = styles.length -1; i >= 0; i--) {				Style style = styles[i];				if (style.getSelector().equals("label")) {					isLabelStyleReferenced = true;				}				if (!styleSheet.isUsed(style.getSelector())) {					processStyle( style, referencedCode, styleSheet, device );				}			}			codeList.addAll( insertIndexForReferencedStyles, referencedCode );		}		*/				// check if label-style has been defined:		if (!isLabelStyleReferenced) {			//if (styleSheet.getStyle("label" ) == null) {				codeList.add( "\tpublic static Style labelStyle = defaultStyle; // no specific label-style has been defined");			/*} else {				processStyle( styleSheet.getStyle("label" ), codeList, styleSheet, device );			}*/		}						// check if fullscreen mode is enabled with menu:		/*		if ((preprocessor.hasSymbol("polish.useMenuFullScreen") 			&& ((device.getCapability("polish.classes.fullscreen") != null) 					|| (device.isMidp2() && preprocessor.hasSymbol("polish.hasCommandKeyEvents") ) ))			|| preprocessor.hasSymbol("polish.needsManualMenu") 			) {			if (styleSheet.getStyle("menu" ) == null) {				System.out.println("Warning: CSS style [menu] not found, you should define it for designing the FullScreen-menu.");			} else {				//processStyle( styleSheet.getStyle("menu" ), codeList, styleSheet, device );				this.referencedStyles.add(styleSheet.getStyle("menu" ));			}		}		*/				// process dynamic styles:		if (styleSheet.containsDynamicStyles()) {			codeList.add("\t//dynamic styles:");			Style[] dynamicStyles = styleSheet.getDynamicStyles(); 			for (int i = 0; i < dynamicStyles.length; i++) {				Style style = dynamicStyles[i];				//processStyle( style, codeList, styleSheet, device );				this.referencedStyles.add( style );			}		}						// register referenced and dynamic styles:		codeList.add("\tstatic final Hashtable stylesByName = new Hashtable(" + styles.length + ");");		if (this.referencedStyles.size() > 0) {			styles = (Style[]) this.referencedStyles.toArray( new Style[ this.referencedStyles.size() ] );			codeList.add("\tstatic { \t//register referenced and dynamic styles:");			for (int i = 0; i < styles.length; i++) {				Style style = styles[i];				String name = style.getAbbreviation();				if (name == null) {					name = style.getSelector();				}				codeList.add("\t\tstylesByName.put( \"" + name + "\", " + style.getStyleName() + "Style );");			}			codeList.add("\t}");		}				// create focused style if necessary:		Style focusedStyle = styleSheet.getStyle("focused"); 		if (focusedStyle == null) {			System.out.println("Warning: CSS-Style [focused] not found, now using the default style instead. If you use Forms or Lists, you should define the style [focused].");			codeList.add(  "\tpublic static Style focusedStyle = defaultStyle;\t// the focused-style is not defined.");		//} else {		//	processStyle( focusedStyle, codeList, styleSheet, device );		}				// generate general warnings and hints:		// check if title style has beend defined:		if (styleSheet.getStyle("title" ) == null) {			System.out.println("Warning: CSS style [title] not found, you should define it for designing the titles of screens.");		}						// now insert the created source code into the source of the polish-StyleSheet.java:		String[] code = (String[]) codeList.toArray( new String[ codeList.size()]);		sourceCode.insert(code);		sourceCode.forward( code.length );	}