* Copyright (c) 2002-2004 IBM Corporation and others.
* Copyright (c) 2002-2005 IBM Corporation and others.
  public String generate(Object argument)  {    StringBuffer stringBuffer = new StringBuffer();    /** * <copyright> * * Copyright (c) 2002-2004 IBM Corporation and others. * All rights reserved.   This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: *   IBM - Initial API and implementation * * </copyright> */    GenClass genClass = (GenClass)argument; GenPackage genPackage = genClass.getGenPackage(); GenModel genModel=genPackage.getGenModel();    stringBuffer.append(TEXT_1);    stringBuffer.append(TEXT_2);    stringBuffer.append("$");    stringBuffer.append(TEXT_3);    stringBuffer.append("$");    stringBuffer.append(TEXT_4);    stringBuffer.append(genPackage.getProviderPackageName());    stringBuffer.append(TEXT_5);    genModel.addImport("org.eclipse.emf.common.notify.AdapterFactory");    genModel.addImport("org.eclipse.emf.common.notify.Notification");    genModel.addImport("org.eclipse.emf.common.util.ResourceLocator");    genModel.addImport("org.eclipse.emf.edit.provider.IEditingDomainItemProvider");    genModel.addImport("org.eclipse.emf.edit.provider.IItemLabelProvider");    genModel.addImport("org.eclipse.emf.edit.provider.IItemPropertySource");    genModel.addImport("org.eclipse.emf.edit.provider.IStructuredItemContentProvider");    genModel.addImport("org.eclipse.emf.edit.provider.ITreeItemContentProvider");    genModel.addImport("java.util.List");    genModel.markImportLocation(stringBuffer);    stringBuffer.append(TEXT_6);    stringBuffer.append(genClass.getQualifiedInterfaceName());    stringBuffer.append(TEXT_7);    stringBuffer.append(genClass.getProviderClassName());    stringBuffer.append(TEXT_8);    stringBuffer.append(genClass.getProviderBaseClassName() != null ? genClass.getProviderBaseClassName() : genModel.getImportedName("org.eclipse.emf.edit.provider.ItemProviderAdapter"));    stringBuffer.append(TEXT_9);    if (genModel.getCopyrightText() != null) {    stringBuffer.append(TEXT_10);    stringBuffer.append(genModel.getImportedName("java.lang.String"));    stringBuffer.append(TEXT_11);    stringBuffer.append(genModel.getCopyrightText());    stringBuffer.append(TEXT_12);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(TEXT_13);    }    stringBuffer.append(TEXT_14);    stringBuffer.append(genClass.getProviderClassName());    stringBuffer.append(TEXT_15);    for (Iterator i=genClass.getPropertyFeatures().iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next();    stringBuffer.append(TEXT_16);    stringBuffer.append(genFeature.getCapName());    stringBuffer.append(TEXT_17);    }    stringBuffer.append(TEXT_18);    for (Iterator i=genClass.getPropertyFeatures().iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next();    stringBuffer.append(TEXT_19);    stringBuffer.append(genFeature.getFormattedName());    stringBuffer.append(TEXT_20);    stringBuffer.append(genFeature.getCapName());    stringBuffer.append(TEXT_21);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.provider.ItemPropertyDescriptor"));    stringBuffer.append(TEXT_22);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.provider.ComposeableAdapterFactory"));    stringBuffer.append(TEXT_23);    stringBuffer.append(genFeature.getGenClass().getName());    stringBuffer.append(TEXT_24);    stringBuffer.append(genFeature.getName());    stringBuffer.append(TEXT_25);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(TEXT_26);    stringBuffer.append(genFeature.getGenClass().getName());    stringBuffer.append(TEXT_27);    stringBuffer.append(genFeature.getName());    stringBuffer.append(TEXT_28);    stringBuffer.append(genFeature.getGenClass().getName());    stringBuffer.append(TEXT_29);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(genModel.getNonNLS(2));    stringBuffer.append(genModel.getNonNLS(3));    stringBuffer.append(TEXT_30);    stringBuffer.append(genFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_31);    stringBuffer.append(genFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_32);    if (genFeature.isReferenceType()) {    stringBuffer.append(TEXT_33);    stringBuffer.append(genFeature.getProperty() == GenPropertyKind.EDITABLE_LITERAL ? "true" : "false");    stringBuffer.append(TEXT_34);    } else {    stringBuffer.append(TEXT_35);    stringBuffer.append(genFeature.getProperty() == GenPropertyKind.EDITABLE_LITERAL ? "true" : "false");    stringBuffer.append(TEXT_36);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.provider.ItemPropertyDescriptor"));    stringBuffer.append(TEXT_37);    stringBuffer.append(genFeature.getPropertyImageName());    stringBuffer.append(TEXT_38);    }    stringBuffer.append(TEXT_39);    }    if (!genClass.getChildrenFeatures().isEmpty()) {    stringBuffer.append(TEXT_40);    stringBuffer.append(genModel.getImportedName("java.util.Collection"));    stringBuffer.append(TEXT_41);    for (Iterator i=genClass.getChildrenFeatures().iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next();    stringBuffer.append(TEXT_42);    stringBuffer.append(genFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_43);    stringBuffer.append(genFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_44);    }    stringBuffer.append(TEXT_45);    if (genClass.getChildrenFeatures().size() > 1) {    stringBuffer.append(TEXT_46);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EStructuralFeature"));    stringBuffer.append(TEXT_47);    }    }    if (genClass.isImage()) {    stringBuffer.append(TEXT_48);    stringBuffer.append(genClass.getName());    stringBuffer.append(TEXT_49);    stringBuffer.append(genClass.getName());    stringBuffer.append(TEXT_50);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(TEXT_51);    }    stringBuffer.append(TEXT_52);    if (genClass.isMapEntry()) {    stringBuffer.append(TEXT_53);    stringBuffer.append(genClass.getImportedInterfaceName());    stringBuffer.append(TEXT_54);    stringBuffer.append(genClass.getSafeUncapName());    stringBuffer.append(TEXT_55);    stringBuffer.append(genClass.getImportedInterfaceName());    stringBuffer.append(TEXT_56);    stringBuffer.append(genClass.getSafeUncapName());    stringBuffer.append(TEXT_57);    stringBuffer.append(genClass.getSafeUncapName());    stringBuffer.append(TEXT_58);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(genModel.getNonNLS(2));    } else if (genClass.getLabelFeature() != null) { GenFeature labelFeature = genClass.getLabelFeature();    if (labelFeature.isPrimitiveType()) {    stringBuffer.append(TEXT_59);    stringBuffer.append(genClass.getImportedInterfaceName());    stringBuffer.append(TEXT_60);    stringBuffer.append(genClass.getSafeUncapName());    stringBuffer.append(TEXT_61);    stringBuffer.append(genClass.getImportedInterfaceName());    stringBuffer.append(TEXT_62);    stringBuffer.append(genClass.getName());    stringBuffer.append(TEXT_63);    stringBuffer.append(genClass.getSafeUncapName());    stringBuffer.append(TEXT_64);    stringBuffer.append(genClass.getLabelFeature().getGetAccessor());    stringBuffer.append(TEXT_65);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(genModel.getNonNLS(2));    } else {    if (labelFeature.isStringType()) {    stringBuffer.append(TEXT_66);    stringBuffer.append(genClass.getImportedInterfaceName());    stringBuffer.append(TEXT_67);    stringBuffer.append(labelFeature.getGetAccessor());    stringBuffer.append(TEXT_68);    } else {    stringBuffer.append(TEXT_69);    stringBuffer.append(labelFeature.getImportedType());    stringBuffer.append(TEXT_70);    stringBuffer.append(genClass.getImportedInterfaceName());    stringBuffer.append(TEXT_71);    stringBuffer.append(labelFeature.getGetAccessor());    stringBuffer.append(TEXT_72);    }    stringBuffer.append(TEXT_73);    stringBuffer.append(genClass.getName());    stringBuffer.append(TEXT_74);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(TEXT_75);    stringBuffer.append(genClass.getName());    stringBuffer.append(TEXT_76);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(genModel.getNonNLS(2));    }    } else {    stringBuffer.append(TEXT_77);    stringBuffer.append(genClass.getName());    stringBuffer.append(TEXT_78);    stringBuffer.append(genModel.getNonNLS());    }    stringBuffer.append(TEXT_79);    if (!genClass.getLabelNotifyFeatures().isEmpty() || !genClass.getContentNotifyFeatures().isEmpty() || !genClass.getLabelAndContentNotifyFeatures().isEmpty()) {    stringBuffer.append(TEXT_80);    stringBuffer.append(genClass.getImportedInterfaceName());    stringBuffer.append(TEXT_81);    if (!genClass.getLabelNotifyFeatures().isEmpty()) {    for (Iterator i=genClass.getLabelNotifyFeatures().iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next();    stringBuffer.append(TEXT_82);    stringBuffer.append(genClass.getQualifiedFeatureID(genFeature));    stringBuffer.append(TEXT_83);    }    stringBuffer.append(TEXT_84);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.provider.ViewerNotification"));    stringBuffer.append(TEXT_85);    }    if (!genClass.getContentNotifyFeatures().isEmpty()) {    for (Iterator i=genClass.getContentNotifyFeatures().iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next();    stringBuffer.append(TEXT_86);    stringBuffer.append(genClass.getQualifiedFeatureID(genFeature));    stringBuffer.append(TEXT_87);    }    stringBuffer.append(TEXT_88);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.provider.ViewerNotification"));    stringBuffer.append(TEXT_89);    }    if (!genClass.getLabelAndContentNotifyFeatures().isEmpty()) {    for (Iterator i=genClass.getLabelAndContentNotifyFeatures().iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next();    stringBuffer.append(TEXT_90);    stringBuffer.append(genClass.getQualifiedFeatureID(genFeature));    stringBuffer.append(TEXT_91);    }    stringBuffer.append(TEXT_92);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.provider.ViewerNotification"));    stringBuffer.append(TEXT_93);    }    stringBuffer.append(TEXT_94);    }    stringBuffer.append(TEXT_95);    if (genModel.isCreationCommands()) {    stringBuffer.append(TEXT_96);    stringBuffer.append(genModel.getImportedName("java.util.Collection"));    stringBuffer.append(TEXT_97);    for (Iterator i=genClass.getCrossPackageCreateChildFeatures().iterator(); i.hasNext();) { GenFeature createFeature = (GenFeature)i.next();    for (Iterator c=genClass.getCrossPackageChildrenClasses(createFeature).iterator(); c.hasNext();) { GenClass createClass = (GenClass)c.next();    stringBuffer.append(TEXT_98);    stringBuffer.append(createFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_99);    stringBuffer.append(createFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_100);    if (createClass.isMapEntry()) {     stringBuffer.append(TEXT_101);    stringBuffer.append(createClass.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_102);    stringBuffer.append(createClass.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_103);    stringBuffer.append(createClass.getName());    stringBuffer.append(TEXT_104);    } else {    stringBuffer.append(TEXT_105);    stringBuffer.append(createClass.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_106);    stringBuffer.append(createClass.getName());    stringBuffer.append(TEXT_107);    }    }    }    for (Iterator i=genClass.getCreateChildFeatures().iterator(); i.hasNext();) { GenFeature createFeature = (GenFeature)i.next();    if (createFeature.isFeatureMapType()) {    for (Iterator d=createFeature.getDelegatedFeatures().iterator(); d.hasNext();) { GenFeature delegatedFeature = (GenFeature)d.next();    if (delegatedFeature.isReferenceType()) {    for (Iterator c=genClass.getChildrenClasses(delegatedFeature).iterator(); c.hasNext();) { GenClass createClass = (GenClass)c.next();    stringBuffer.append(TEXT_108);    stringBuffer.append(createFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_109);    stringBuffer.append(createFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_110);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.util.FeatureMapUtil"));    stringBuffer.append(TEXT_111);    stringBuffer.append(delegatedFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_112);    stringBuffer.append(delegatedFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_113);    if (createClass.isMapEntry()) {     stringBuffer.append(TEXT_114);    stringBuffer.append(createClass.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_115);    stringBuffer.append(createClass.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_116);    stringBuffer.append(createClass.getName());    stringBuffer.append(TEXT_117);    } else {    stringBuffer.append(TEXT_118);    stringBuffer.append(createClass.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_119);    stringBuffer.append(createClass.getName());    stringBuffer.append(TEXT_120);    }    }    } else {    stringBuffer.append(TEXT_121);    stringBuffer.append(createFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_122);    stringBuffer.append(createFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_123);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.util.FeatureMapUtil"));    stringBuffer.append(TEXT_124);    stringBuffer.append(delegatedFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_125);    stringBuffer.append(delegatedFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_126);    if (delegatedFeature.isEnumBasedType()) {    stringBuffer.append(TEXT_127);    stringBuffer.append(delegatedFeature.getGenEnumType().getStaticValue(delegatedFeature.getEcoreFeature().getDefaultValueLiteral()));    stringBuffer.append(TEXT_128);    } else if (delegatedFeature.isStringBasedType()) {    stringBuffer.append(TEXT_129);    stringBuffer.append(delegatedFeature.getCreateChildValueLiteral());    stringBuffer.append(TEXT_130);    stringBuffer.append(genModel.getNonNLS());    } else { String literal = delegatedFeature.getCreateChildValueLiteral(); GenDataType createDataType = delegatedFeature.getGenDataTypeType();    stringBuffer.append(TEXT_131);    stringBuffer.append(createDataType.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_132);    stringBuffer.append(createDataType.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_133);    stringBuffer.append(createDataType.getClassifierAccessorName());    stringBuffer.append(TEXT_134);    stringBuffer.append(literal);    stringBuffer.append(TEXT_135);    if (literal != null) {    stringBuffer.append(genModel.getNonNLS());    } else {    stringBuffer.append(TEXT_136);    }    }    }    }    } else if (createFeature.isReferenceType()) {    for (Iterator c=genClass.getChildrenClasses(createFeature).iterator(); c.hasNext();) { GenClass createClass = (GenClass)c.next();    stringBuffer.append(TEXT_137);    stringBuffer.append(createFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_138);    stringBuffer.append(createFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_139);    if (createClass.isMapEntry()) {     stringBuffer.append(TEXT_140);    stringBuffer.append(createClass.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_141);    stringBuffer.append(createClass.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_142);    stringBuffer.append(createClass.getName());    stringBuffer.append(TEXT_143);    } else {    stringBuffer.append(TEXT_144);    stringBuffer.append(createClass.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_145);    stringBuffer.append(createClass.getName());    stringBuffer.append(TEXT_146);    }    }    } else {    stringBuffer.append(TEXT_147);    stringBuffer.append(createFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_148);    stringBuffer.append(createFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_149);    if (createFeature.isEnumBasedType()) {    stringBuffer.append(TEXT_150);    stringBuffer.append(createFeature.getGenEnumType().getStaticValue(createFeature.getEcoreFeature().getDefaultValueLiteral()));    stringBuffer.append(TEXT_151);    } else if (createFeature.isStringBasedType()) {    stringBuffer.append(TEXT_152);    stringBuffer.append(createFeature.getCreateChildValueLiteral());    stringBuffer.append(TEXT_153);    stringBuffer.append(genModel.getNonNLS());    } else { String literal = createFeature.getCreateChildValueLiteral(); GenDataType createDataType = createFeature.getGenDataTypeType();    stringBuffer.append(TEXT_154);    stringBuffer.append(createDataType.getGenPackage().getImportedFactoryInterfaceName());    stringBuffer.append(TEXT_155);    stringBuffer.append(createDataType.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_156);    stringBuffer.append(createDataType.getClassifierAccessorName());    stringBuffer.append(TEXT_157);    stringBuffer.append(literal);    stringBuffer.append(TEXT_158);    if (literal != null) {    stringBuffer.append(genModel.getNonNLS());    } else {    stringBuffer.append(TEXT_159);    }    }    }    }    stringBuffer.append(TEXT_160);    if (!genClass.getSharedClassCreateChildFeatures().isEmpty()) {    stringBuffer.append(TEXT_161);    stringBuffer.append(genModel.getImportedName("java.util.Collection"));    stringBuffer.append(TEXT_162);    if (genClass.hasFeatureMapCreateChildFeatures()) {    stringBuffer.append(TEXT_163);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EStructuralFeature"));    stringBuffer.append(TEXT_164);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.util.FeatureMapUtil"));    stringBuffer.append(TEXT_165);    stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.util.FeatureMap"));    stringBuffer.append(TEXT_166);    }    stringBuffer.append(TEXT_167);    for (Iterator i = genClass.getSharedClassCreateChildFeatures().iterator(); i.hasNext();) { GenFeature createFeature = (GenFeature)i.next();    stringBuffer.append(TEXT_168);    stringBuffer.append(createFeature.getGenPackage().getImportedPackageInterfaceName());    stringBuffer.append(TEXT_169);    stringBuffer.append(createFeature.getFeatureAccessorName());    stringBuffer.append(TEXT_170);    stringBuffer.append(i.hasNext() ? " ||" : ";");    }    stringBuffer.append(TEXT_171);    stringBuffer.append(genModel.getNonNLS());    stringBuffer.append(TEXT_172);    }    }    stringBuffer.append(TEXT_173);    stringBuffer.append(genPackage.getImportedEditPluginClassName());    stringBuffer.append(TEXT_174);    genModel.emitSortedImports();    stringBuffer.append(TEXT_175);    return stringBuffer.toString();  }