public CFFreeSwitchSwingSubProjectViewEditJInternalFrame(
     ICFFreeSwitchSwingSchema argSchema, ICFInternetSubProjectObj argFocus) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   if ((argFocus != null) && (!argFocus.getIsNew())) {
     argFocus = (ICFFreeSwitchSubProjectObj) argFocus.read(true);
     swingFocus = argFocus;
   }
   swingViewEditJPanel = argSchema.getSubProjectFactory().newViewEditJPanel(argFocus);
   setContentPane(swingViewEditJPanel);
   Dimension dim = new Dimension(1024, 480);
   setSize(dim);
   dim = new Dimension(320, 240);
   setMinimumSize(dim);
   setTitle("View/Edit SubProject");
   setJMenuBar(getFrameMenuBar());
   setIconifiable(true);
   setMaximizable(true);
   setResizable(true);
   setClosable(false);
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFInternetSubProjectObj focus = getSwingFocusAsSubProject();
   if (focus != null) {
     ICFFreeSwitchSubProjectEditObj editObj = (ICFFreeSwitchSubProjectEditObj) (focus.getEdit());
     if (editObj != null) {
       setPanelMode(CFJPanel.PanelMode.Update);
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUsageException(
               getClass(), S_ProcName, "Cannot save on object that isn't being edited");
     }
   }
   try {
     setClosed(true);
   } catch (Exception x) {
   }
 }
 public void actionPerformed(ActionEvent e) {
   ICFInternetSubProjectObj focus = getSwingFocusAsSubProject();
   if (focus != null) {
     ICFFreeSwitchSubProjectEditObj editObj = (ICFFreeSwitchSubProjectEditObj) focus.getEdit();
     if (editObj != null) {
       if (editObj.getIsNew()) {
         editObj.endEdit();
         setSwingFocus(null);
         setPanelMode(CFJPanel.PanelMode.Unknown);
       } else {
         editObj.endEdit();
         setPanelMode(CFJPanel.PanelMode.View);
       }
     }
   }
   try {
     setClosed(true);
   } catch (Exception x) {
   }
 }
  public void startElement(String uri, String localName, String qName, Attributes attrs)
      throws SAXException {
    CFInternetXMsgSchemaMessageFormatter schemaFormatter = null;
    try {
      // Common XML Attributes
      String attrId = null;
      String attrRevision = null;
      // Primary Key Attributes for Constant Enum support
      String attrTenantId = null;
      // Attribute Extraction
      String attrLocalName;
      int numAttrs;
      int idxAttr;
      final String S_ProcName = "startElement";
      final String S_LocalName = "LocalName";

      assert qName.equals("RqstSubProjectDelete");

      CFInternetXMsgRqstHandler xmsgRqstHandler = (CFInternetXMsgRqstHandler) getParser();
      if (xmsgRqstHandler == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()");
      }

      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();

      ICFInternetSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
      if (schemaObj == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()");
      }

      // Instantiate a PKey buffer for the parsed information
      CFInternetDomainBasePKey pkey =
          ((ICFInternetSchema) schemaObj.getBackingStore()).getFactoryDomainBase().newPKey();

      // Extract Attributes
      numAttrs = attrs.getLength();
      for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
        attrLocalName = attrs.getLocalName(idxAttr);
        if (attrLocalName.equals("Id")) {
          if (attrId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrId = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("Revision")) {
          if (attrRevision != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrRevision = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("TenantId")) {
          if (attrTenantId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrTenantId = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("schemaLocation")) {
          // ignored
        } else {
          throw CFLib.getDefaultExceptionFactory()
              .newUnrecognizedAttributeException(
                  getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName);
        }
      }

      // Ensure that required attributes have values
      if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "TenantId");
      }
      if ((attrId == null) || (attrId.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "Id");
      }
      if ((attrRevision == null) || (attrRevision.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "Revision");
      }

      // Get current context
      CFLibXmlCoreContext curContext = getParser().getCurContext();
      // Convert string attributes to native Java types
      // and apply the converted attributes to the editBuff.

      long natTenantId;
      natTenantId = Long.parseLong(attrTenantId);
      pkey.setRequiredTenantId(natTenantId);

      pkey.setRequiredTenantId(natTenantId);
      long natId;
      natId = Long.parseLong(attrId);
      pkey.setRequiredId(natId);

      pkey.setRequiredId(natId);
      int natRevision = Integer.parseInt(attrRevision);
      // Delete the object
      ICFInternetSubProjectObj read =
          ((ICFInternetSubProjectObj) schemaObj.getSubProjectTableObj().readSubProject(pkey));
      if (read != null) {
        if (read.getSubProjectBuff().getRequiredRevision() > natRevision) {
          throw CFLib.getDefaultExceptionFactory()
              .newCollisionDetectedException(
                  getClass(), S_ProcName, "Collision detected preparing to delete SubProject");
        } else {
          ICFInternetSubProjectEditObj editBuff = (ICFInternetSubProjectEditObj) read.beginEdit();
          if (editBuff != null) {
            editBuff.delete();
            editBuff.endEdit();
            String response =
                schemaFormatter.formatRspnXmlPreamble()
                    + "\n"
                    + "\t"
                    + CFInternetXMsgSubProjectMessageFormatter.formatSubProjectRspnDeleted()
                    + "\n"
                    + schemaFormatter.formatRspnXmlPostamble();
            ((CFInternetXMsgRqstHandler) getParser()).appendResponse(response);
          } else {
            throw CFLib.getDefaultExceptionFactory()
                .newNullArgumentException(getClass(), S_ProcName, 0, "read.beginEdit()");
          }
        }
      } else {
        String response =
            schemaFormatter.formatRspnXmlPreamble()
                + "\n"
                + "\t"
                + CFInternetXMsgSchemaMessageFormatter.formatRspnNoDataFound()
                + "\n"
                + schemaFormatter.formatRspnXmlPostamble();
        ((CFInternetXMsgRqstHandler) getParser()).appendResponse(response);
      }
    } catch (RuntimeException e) {
      CFInternetXMsgRqstHandler xmsgRqstHandler = ((CFInternetXMsgRqstHandler) getParser());
      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();
      String response =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFInternetXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e)
              + "\n"
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.resetResponse();
      xmsgRqstHandler.appendResponse(response);
      xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
      CFInternetXMsgRqstHandler xmsgRqstHandler = ((CFInternetXMsgRqstHandler) getParser());
      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();
      String response =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFInternetXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e)
              + "\n"
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.resetResponse();
      xmsgRqstHandler.appendResponse(response);
      xmsgRqstHandler.setCaughtException(true);
    }
  }
  public void startElement(String uri, String localName, String qName, Attributes attrs)
      throws SAXException {
    CFInternetXMsgSchemaMessageFormatter schemaFormatter = null;
    try {
      // Common XML Attributes
      String attrId = null;
      // Attribute Extraction
      String attrLocalName;
      int numAttrs;
      int idxAttr;
      final String S_ProcName = "startElement";
      final String S_LocalName = "LocalName";

      assert qName.equals("RqstSubProjectReadAll");

      CFInternetXMsgRqstHandler xmsgRqstHandler = (CFInternetXMsgRqstHandler) getParser();
      if (xmsgRqstHandler == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()");
      }

      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();

      ICFInternetSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
      if (schemaObj == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()");
      }

      // Extract Attributes
      numAttrs = attrs.getLength();
      for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
        attrLocalName = attrs.getLocalName(idxAttr);
        if (attrLocalName.equals("Id")) {
          if (attrId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrId = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("schemaLocation")) {
          // ignored
        } else {
          throw CFLib.getDefaultExceptionFactory()
              .newUnrecognizedAttributeException(
                  getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName);
        }
      }

      // Save named attributes to context
      CFLibXmlCoreContext curContext = getParser().getCurContext();
      // Read the objects and prepare the response XML
      List<ICFInternetSubProjectObj> list =
          schemaObj.getSubProjectTableObj().readAllSubProject(true);
      String responseOpening =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFInternetXMsgSubProjectMessageFormatter.formatSubProjectRspnListOpenTag();
      xmsgRqstHandler.appendResponse(responseOpening);
      Iterator<ICFInternetSubProjectObj> iter = list.iterator();
      ICFInternetSubProjectObj cur;
      String subxml;
      while (iter.hasNext()) {
        cur = iter.next();
        subxml =
            CFInternetXMsgSubProjectMessageFormatter.formatSubProjectRspnDerivedRec(
                "\n\t\t", cur.getSubProjectBuff());
        xmsgRqstHandler.appendResponse(subxml);
      }
      String responseClosing =
          "\n"
              + "\t"
              + CFInternetXMsgSubProjectMessageFormatter.formatSubProjectRspnListCloseTag()
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.appendResponse(responseClosing);
    } catch (RuntimeException e) {
      CFInternetXMsgRqstHandler xmsgRqstHandler = ((CFInternetXMsgRqstHandler) getParser());
      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();
      String response =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFInternetXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e)
              + "\n"
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.resetResponse();
      xmsgRqstHandler.appendResponse(response);
      xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
      CFInternetXMsgRqstHandler xmsgRqstHandler = ((CFInternetXMsgRqstHandler) getParser());
      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();
      String response =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFInternetXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e)
              + "\n"
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.resetResponse();
      xmsgRqstHandler.appendResponse(response);
      xmsgRqstHandler.setCaughtException(true);
    }
  }
  public void startElement(String uri, String localName, String qName, Attributes attrs)
      throws SAXException {
    try {
      // Common XML Attributes
      String attrId = null;
      // DomainBase Attributes
      String attrDescription = null;
      // DomainBase References
      ICFInternetTenantObj refTenant = null;
      // ProjectBase Attributes
      // ProjectBase References
      // RealProject Attributes
      // RealProject References
      // SubProject Attributes
      String attrName = null;
      // SubProject References
      ICFInternetTopProjectObj refParentProject = null;
      // Attribute Extraction
      String attrLocalName;
      int numAttrs;
      int idxAttr;
      final String S_ProcName = "startElement";
      final String S_LocalName = "LocalName";

      assert qName.equals("SubProject");

      CFInternetSaxLoader saxLoader = (CFInternetSaxLoader) getParser();
      if (saxLoader == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()");
      }

      ICFInternetSchemaObj schemaObj = saxLoader.getSchemaObj();
      if (schemaObj == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()");
      }

      // Instantiate an edit buffer for the parsed information
      ICFInternetSubProjectEditObj editBuff =
          (ICFInternetSubProjectEditObj)
              schemaObj.getSubProjectTableObj().newInstance().beginEdit();

      // Extract Attributes
      numAttrs = attrs.getLength();
      for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
        attrLocalName = attrs.getLocalName(idxAttr);
        if (attrLocalName.equals("Id")) {
          if (attrId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrId = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("Description")) {
          if (attrDescription != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrDescription = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("Name")) {
          if (attrName != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrName = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("schemaLocation")) {
          // ignored
        } else {
          throw CFLib.getDefaultExceptionFactory()
              .newUnrecognizedAttributeException(
                  getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName);
        }
      }

      // Ensure that required attributes have values
      if (attrName == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "Name");
      }

      // Save named attributes to context
      CFLibXmlCoreContext curContext = getParser().getCurContext();
      curContext.putNamedValue("Id", attrId);
      curContext.putNamedValue("Description", attrDescription);
      curContext.putNamedValue("Name", attrName);

      // Convert string attributes to native Java types
      // and apply the converted attributes to the editBuff.

      Integer natId;
      if ((attrId != null) && (attrId.length() > 0)) {
        natId = new Integer(Integer.parseInt(attrId));
      } else {
        natId = null;
      }
      String natDescription = attrDescription;
      editBuff.setOptionalDescription(natDescription);

      String natName = attrName;
      editBuff.setRequiredName(natName);

      // Get the scope/container object

      CFLibXmlCoreContext parentContext = curContext.getPrevContext();
      Object scopeObj;
      if (parentContext != null) {
        scopeObj = parentContext.getNamedValue("Object");
      } else {
        scopeObj = null;
      }

      // Resolve and apply required Container reference

      if (scopeObj == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "scopeObj");
      } else if (scopeObj instanceof ICFInternetTopProjectObj) {
        refParentProject = (ICFInternetTopProjectObj) scopeObj;
        editBuff.setRequiredContainerParentProject(refParentProject);
        refTenant = (ICFInternetTenantObj) editBuff.getRequiredOwnerTenant();
      } else {
        throw CFLib.getDefaultExceptionFactory()
            .newUnsupportedClassException(
                getClass(), S_ProcName, "scopeObj", scopeObj, "ICFInternetTopProjectObj");
      }

      // Resolve and apply Owner reference

      if (refTenant == null) {
        if (scopeObj instanceof ICFInternetTenantObj) {
          refTenant = (ICFInternetTenantObj) scopeObj;
          editBuff.setRequiredOwnerTenant(refTenant);
        } else {
          throw CFLib.getDefaultExceptionFactory()
              .newNullArgumentException(getClass(), S_ProcName, 0, "Owner<Tenant>");
        }
      }

      CFInternetSaxLoader.LoaderBehaviourEnum loaderBehaviour =
          saxLoader.getSubProjectLoaderBehaviour();
      ICFInternetSubProjectEditObj editSubProject = null;
      ICFInternetSubProjectObj origSubProject =
          (ICFInternetSubProjectObj)
              schemaObj
                  .getSubProjectTableObj()
                  .readSubProjectByNameIdx(
                      refParentProject.getRequiredTenantId(),
                      refParentProject.getRequiredId(),
                      editBuff.getRequiredName());
      if (origSubProject == null) {
        editSubProject = editBuff;
      } else {
        switch (loaderBehaviour) {
          case Insert:
            break;
          case Update:
            editSubProject = (ICFInternetSubProjectEditObj) origSubProject.beginEdit();
            editSubProject.setOptionalDescription(editBuff.getOptionalDescription());
            editSubProject.setRequiredName(editBuff.getRequiredName());
            break;
          case Replace:
            editSubProject = (ICFInternetSubProjectEditObj) origSubProject.beginEdit();
            editSubProject.delete();
            editSubProject.endEdit();
            origSubProject = null;
            editSubProject = editBuff;
            break;
        }
      }

      if (editSubProject != null) {
        if (origSubProject != null) {
          editSubProject.update();
        } else {
          origSubProject = (ICFInternetSubProjectObj) editSubProject.create();
        }
        editSubProject.endEdit();
      }

      curContext.putNamedValue("Object", origSubProject);
    } catch (RuntimeException e) {
      throw new RuntimeException(
          "Near "
              + getParser().getLocationInfo()
              + ": Caught and rethrew "
              + e.getClass().getName()
              + " - "
              + e.getMessage(),
          e);
    } catch (Error e) {
      throw new Error(
          "Near "
              + getParser().getLocationInfo()
              + ": Caught and rethrew "
              + e.getClass().getName()
              + " - "
              + e.getMessage(),
          e);
    }
  }