protected void generate(IProgressMonitor progressMonitor, int style, List pluginVariables, String outputFilePath, JETEmitter jetEmitter)
public void generate(IProgressMonitor progressMonitor)
  protected void generate(IProgressMonitor progressMonitor, int style, List pluginVariables, String outputFilePath, JETEmitter jetEmitter)  {    try    {      IPath outputPath = new Path(outputFilePath.substring(0, outputFilePath.lastIndexOf("/")));      progressMonitor.beginTask("", 3);      progressMonitor.subTask(CodeGenEcorePlugin.INSTANCE.getString("_UI_GeneratingFile_message", new Object [] { outputFilePath }));      IContainer container = findOrCreateContainer(new SubProgressMonitor(progressMonitor, 1), style, pluginVariables, outputPath, false);      if (container != null)      {        IFile targetFile = container.getFile(new Path(outputFilePath.substring(outputFilePath.lastIndexOf("/") + 1)));        if (targetFile.exists() && (outputFilePath.endsWith("/build.properties") || !outputFilePath.endsWith(".properties")))        {          return;        }        boolean changed = false;        boolean isUnicodeEscapeEncoded = outputFilePath.endsWith(".properties");        String emitterResult = jetEmitter.generate(new SubProgressMonitor(progressMonitor, 1), new Object [] { this });        if (isUnicodeEscapeEncoded)        {          emitterResult = unicodeEscapeEncode(emitterResult);        }        progressMonitor.worked(1);        InputStream contents = new ByteArrayInputStream(emitterResult.toString().getBytes(isUnicodeEscapeEncoded ? "ISO-8859-1" : "UTF-8"));        if (targetFile.exists())        {          // Don't overwrite exising file          PropertyMerger propertyMerger = new PropertyMerger();          propertyMerger.setSourceProperties(emitterResult);          progressMonitor.subTask            (CodeGenEcorePlugin.INSTANCE.getString("_UI_ExaminingOld_message", new Object [] { targetFile.getFullPath() }));          String oldProperties = propertyMerger.createPropertiesForInputStream(targetFile.getContents(true));          propertyMerger.setTargetProperties(oldProperties);          progressMonitor.subTask            (CodeGenEcorePlugin.INSTANCE.getString("_UI_PreparingNew_message", new Object [] { targetFile.getFullPath() }));          propertyMerger.merge();          progressMonitor.worked(1);          String mergedResult = propertyMerger.getTargetProperties();          changed = !mergedResult.equals(oldProperties);          if (changed)          {            if (targetFile.isReadOnly() &&                   targetFile.getWorkspace().validateEdit(new IFile [] { targetFile }, new SubProgressMonitor(progressMonitor, 1)).isOK())            {              propertyMerger.setTargetProperties(propertyMerger.createPropertiesForInputStream(targetFile.getContents(true)));              propertyMerger.merge();              mergedResult = propertyMerger.getTargetProperties();            }            contents = new ByteArrayInputStream(mergedResult.getBytes(isUnicodeEscapeEncoded ? "ISO-8859-1" : "UTF-8"));          }        }        else        {          changed = true;        }        if (changed)        {          String redirection = getGenModel().getRedirection();          boolean redirect = redirection != null && redirection.indexOf("{0}") != -1;          // Use an alternate if we can't write to this one.          //          if (redirect)          {            String baseName = MessageFormat.format(redirection, new Object [] { targetFile.getName() });            targetFile = container.getFile(new Path(baseName));            progressMonitor.subTask              (CodeGenEcorePlugin.INSTANCE.getString("_UI_UsingAlternate_message", new Object [] { targetFile.getFullPath() }));          }            if (targetFile.isReadOnly())          {            if (getGenModel().isForceOverwrite())            {              ResourceAttributes resourceAttributes = targetFile.getResourceAttributes();              if (resourceAttributes != null)              {                resourceAttributes.setReadOnly(false);                targetFile.setResourceAttributes(resourceAttributes);              }            }            else            {              targetFile = container.getFile(new Path("." + targetFile.getName() + ".new"));              progressMonitor.subTask                (CodeGenEcorePlugin.INSTANCE.getString("_UI_UsingDefaultAlternate_message", new Object [] { targetFile.getFullPath() }));            }          }            if (targetFile.exists())          {            targetFile.setContents(contents, true, true, new SubProgressMonitor(progressMonitor, 1));          }          else          {            targetFile.create(contents, true, new SubProgressMonitor(progressMonitor, 1));          }        }      }    }    catch (Exception exception)    {      CodeGenEcorePlugin.INSTANCE.log(exception);    }    finally    {      progressMonitor.done();    }  }