File cssFile = new File( this.buildSetting.getResDir().getAbsolutePath() + File.separator + vendor.getIdentifier() + File.separator + "polish.css"); if (cssFile.exists()) { CssReader reader = new CssReader( this.styleSheet ); reader.add( cssFile ); vendor.setStyleSheet( reader.getStyleSheet() ); } else { vendor.setStyleSheet( new StyleSheet() ); }
this.preprocessor.removeSymbol("polish.useDynamicStyles");
	private void preprocess( Device device ) {		System.out.println("now preprocessing for device [" +  device.getIdentifier() + "]." );		try {			String targetDir = this.buildSetting.getWorkDir().getAbsolutePath() 				+ File.separatorChar + device.getVendorName() 				+ File.separatorChar + device.getName();			device.setBaseDir( targetDir );			targetDir += File.separatorChar + "source";			device.setSourceDir(targetDir);			// initialise the preprocessor:			this.preprocessor.setTargetDir( targetDir );			this.preprocessor.setSymbols( device.getFeatures() );			this.preprocessor.setVariables( device.getCapabilities() );			// get the last modfication time of the build.xml file			// so that it can be checked whether there are any changes at all:			File buildXml = new File( this.project.getBaseDir().getAbsolutePath() 						+ File.separatorChar + "build.xml" );			long buildXmlLastModified = buildXml.lastModified();			// check if the polish gui is used at all:			boolean usePolishGui = this.buildSetting.usesPolishGui()								  && device.supportsPolishGui();			if (usePolishGui) {				// initialise the CSS-style sheet:				CssReader cssReader = new CssReader( this.styleSheet );				Vendor vendor = device.getVendor();				StyleSheet sheet = vendor.getStyleSheet();				if ( sheet != null ) {					cssReader.add( sheet );				} else {					// CSS file has not been read yet:					File cssFile = new File( this.buildSetting.getResDir().getAbsolutePath()							+ File.separator + vendor.getIdentifier() 							+ File.separator + "polish.css");					if (cssFile.exists()) {						CssReader reader = new CssReader( this.styleSheet );						reader.add( cssFile );						vendor.setStyleSheet( reader.getStyleSheet() );					} else {						vendor.setStyleSheet( new StyleSheet() );					}				}				DeviceGroup[] groups = device.getGroups();				for (int i = 0; i < groups.length; i++) {					DeviceGroup group = groups[i];					sheet = group.getStyleSheet();					if (sheet != null) {						cssReader.add(sheet);					} else {						File cssFile = new File( this.buildSetting.getResDir().getAbsolutePath()								+ File.separator + vendor.getIdentifier() 								+ File.separator + "polish.css");						if (cssFile.exists()) {							CssReader reader = new CssReader( this.styleSheet );							reader.add( cssFile );							group.setStyleSheet( reader.getStyleSheet() );						} else {							group.setStyleSheet( new StyleSheet() );						}					}				}				this.preprocessor.setSyleSheet( cssReader.getStyleSheet() );			}			for (int i = 0; i < this.sourceDirs.length; i++) {				File sourceDir = this.sourceDirs[i];				this.preprocessor.addVariable( "polish.source", sourceDir.getAbsolutePath() );				TextFile[] files = this.sourceFiles[i];				//System.out.println("current source dir: " + sourceDir );								for (int j = 0; j < files.length; j++) {					TextFile file = files[j];					// check if file needs to be preprocessed at all:					long sourceLastModified = file.lastModified();					File targetFile = new File( targetDir							+ File.separatorChar + file.getFileName() );					long targetLastModified = targetFile.lastModified();					// preprocess this file, but only when there can					// be changes at all - this could be when					// 1. The preprocessed file does not yet exists					// 2. The source file has been modified since the last run					// 3, The build.xml has been modified since the last run					boolean saveInAnyCase =  ( !targetFile.exists() )							 || ( sourceLastModified > targetLastModified );					/*					if (( sourceLastModified > targetLastModified )) {						System.out.println("File has been modified: " + file.getFileName() 								+ "\n last mod of source: " + sourceLastModified + " last mod of target: " + targetLastModified );					}					if (( buildXmlLastModified > targetLastModified ) ) {						System.out.println("build.xml has been modified: " + file.getFileName() 								+ "\n last mod of target: " + targetLastModified + " last mod of build.xml: " + buildXmlLastModified );					}					*/					if (   ( saveInAnyCase )						|| ( buildXmlLastModified > targetLastModified ) )					{						// preprocess this file:						StringList sourceCode = new StringList( file.getContent() );						// generate the class-name from the file-name:						String className = file.getFileName();						if (className.endsWith(".java")) {							className = className.substring(0, className.length() - 5 );							className = TextUtil.replace(className, '/', '.' );						}						int result = this.preprocessor.preprocess( className, sourceCode );						if (result != Preprocessor.SKIP_FILE) {							sourceCode.reset();							// now replace the import statements:							boolean changed = this.importConverter.processImports(usePolishGui, device.isMidp1(), sourceCode);							if (changed) {								result = Preprocessor.CHANGED;							}							// save modified file:							if ( ( saveInAnyCase ) 							  || (result == Preprocessor.CHANGED) ) 							{								//System.out.println( "preprocessed [" + className + "]." );								file.saveToDir(targetDir, sourceCode.getArray(), false );							//} else {							//	System.out.println("not saving " + file.getFileName() );							}						} else {							System.out.println("Skipping file " + file.getFileName() );						}					} // when preprocessing should be done.				} // for each file			} // for each source folder		} catch (FileNotFoundException e) {			e.printStackTrace();			throw new BuildException( e.getMessage() );		} catch (IOException e) {			e.printStackTrace();			throw new BuildException( e.getMessage() );		} catch (PreprocessException e) {			e.printStackTrace();			throw new BuildException( e.getMessage() );		}	}