public void actionPerformed(ActionEvent e) { final String S_ProcName = "actionPerformed"; ICFInternetSchemaObj schemaObj = swingSchema.getSchema(); ICFInternetMinorVersionObj obj = (ICFInternetMinorVersionObj) schemaObj.getMinorVersionTableObj().newInstance(); JInternalFrame frame = swingSchema.getMinorVersionFactory().newViewEditJInternalFrame(obj); frame.addInternalFrameListener(getViewEditInternalFrameListener()); ICFInternetMinorVersionEditObj edit = (ICFInternetMinorVersionEditObj) (obj.beginEdit()); if (edit == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "edit"); } ICFSecurityTenantObj secTenant = schemaObj.getSecTenant(); edit.setRequiredOwnerTenant(secTenant); ICFInternetMajorVersionObj container = (ICFInternetMajorVersionObj) (getSwingContainer()); if (container == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "SwingContainer"); } edit.setRequiredContainerMajorVersion(container); ICFInternetSwingMinorVersionJPanelCommon jpanelCommon = (ICFInternetSwingMinorVersionJPanelCommon) frame; jpanelCommon.setPanelMode(CFJPanel.PanelMode.Add); Container cont = getParent(); while ((cont != null) && (!(cont instanceof JInternalFrame))) { cont = cont.getParent(); } if (cont != null) { JInternalFrame myInternalFrame = (JInternalFrame) cont; myInternalFrame.getDesktopPane().add(frame); frame.setVisible(true); frame.show(); } }
public void startElement( String uri, String localName, String qName, Attributes attrs ) throws SAXException { CFAsteriskXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; String attrTenantId = null; String attrMajorId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals( "RqstMinorVersionReadByMajorIdx" ); CFAsteriskXMsgRqstHandler xmsgRqstHandler = (CFAsteriskXMsgRqstHandler)getParser(); if( xmsgRqstHandler == null ) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException( getClass(), S_ProcName, 0, "getParser()" ); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFAsteriskSchemaObj 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( "TenantId" ) ) { if( attrTenantId != null ) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName ); } attrTenantId = attrs.getValue( idxAttr ); } else if( attrLocalName.equals( "MajorId" ) ) { if( attrMajorId != null ) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName ); } attrMajorId = 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( ( attrMajorId == null ) || ( attrMajorId.length() <= 0 ) ) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException( getClass(), S_ProcName, 0, "MajorId" ); } // Save named attributes to 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 ); long natMajorId; natMajorId = Long.parseLong( attrMajorId ); // Read the objects List<ICFInternetMinorVersionObj> list = schemaObj.getMinorVersionTableObj().readMinorVersionByMajorIdx( natTenantId, natMajorId ); String responseOpening = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgMinorVersionMessageFormatter.formatMinorVersionRspnListOpenTag(); xmsgRqstHandler.appendResponse( responseOpening ); Iterator<ICFInternetMinorVersionObj> iter = list.iterator(); ICFInternetMinorVersionObj cur; String subxml; while( iter.hasNext() ) { cur = iter.next(); subxml = CFAsteriskXMsgMinorVersionMessageFormatter.formatMinorVersionRspnDerivedRec( "\n\t\t", cur.getMinorVersionBuff() ); xmsgRqstHandler.appendResponse( subxml ); } String responseClosing = "\n" + "\t" + CFAsteriskXMsgMinorVersionMessageFormatter.formatMinorVersionRspnListCloseTag() + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse( responseClosing ); } catch( RuntimeException e ) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler)getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException( "\n\t\t\t", e ) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse( response ); xmsgRqstHandler.setCaughtException( true ); } catch( Error e ) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler)getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException( "\n\t\t\t", e ) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse( response ); xmsgRqstHandler.setCaughtException( true ); } }