void GISSetFieldAttributeMsgCommand::DoExecute() throw (GException) { LOG_LEVEL3("DoExecute()"); GISAbsData* pGISAbsData = GetData(); QSharedPointer<GISModel> pModel = GISModelSingleton::GetInstance()->GetModel(); { QMutexLocker mtxScope(pModel->GetMutex()); GDisplay* poDisplay = pModel->GetDisplay(pGISAbsData->GetDisplay()); GScreen* poScreen = poDisplay->GetScreen(pGISAbsData->GetScreen()); GSegment* poSegment = poScreen->GetSegment(pGISAbsData->GetSegment()); GTextField* poField = poSegment->GetField(pGISAbsData->GetField()); if( poField != NULL ) { poField->SetAttribute(pGISAbsData->GetAttr()); } } }
void GISDisplaySegmentMsgCommand::DoExecute() throw (GException) { LOG_LEVEL3("DoExecute()"); GISAbsData* pGISAbsData = GetData(); QSharedPointer<GISModel> pModel = GISModelSingleton::GetInstance()->GetModel(); { QMutexLocker mtxScope(pModel->GetMutex()); GDisplay* poDisplay = pModel->GetDisplay(pGISAbsData->GetDisplay()); GScreen* poScreen = poDisplay->GetScreen(pGISAbsData->GetScreen()); GSegment* poSegment = poScreen->GetSegment(pGISAbsData->GetSegment()); //Erase the content of the if and else branches. Leave the empty if commented. //Whichever value the attribute has, make a gsegment clon and do what is done to the poSegment in if branch, to the clon // if (pGISAbsData->GetAttr()==GAttributeEnum::eNotErasePreviousLocation) // {// If Attr is not zero call old setters and getters // } // else// GetAttr is eErasePreviousLocation otherwise ( all other options where discarded in Validate of MsgData ). // { // } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // GSegment *poClonedSegment = GSegment::Clone(poSegment); // // if (pGISAbsData->GetXpos()) // poClonedSegment->SetXPos(pGISAbsData->GetXpos()); // // if (pGISAbsData->GetYpos()) // poClonedSegment->SetYPos(pGISAbsData->GetYpos()); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Java implements this command in the following way, the Spec seems to prefer the one commented above. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (pGISAbsData->GetXpos()) { poSegment->SetXPos(pGISAbsData->GetXpos()); } if (pGISAbsData->GetYpos()) { poSegment->SetYPos(pGISAbsData->GetYpos()); } GSegment *poClonedSegment = GSegment::Clone(poSegment); if (poClonedSegment) { poClonedSegment->SetVisible(true); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Call Update section (instead of updateview) with a pointer to the clon (without validation) pModel->UpdateViewSection(poClonedSegment,pGISAbsData->GetSynchronousRequest()); } }
void GISAddDisplayMsgCommand::DoExecute() throw (GException) { LOG_LEVEL3("DoExecute()"); GISAbsData* pGISAbsData = GetData(); QSharedPointer<GISModel> pModel = GISModelSingleton::GetInstance()->GetModel(); { QMutexLocker mtxScope(pModel->GetMutex()); GDisplay* poDisplay = pModel->GetDisplay(pGISAbsData->GetDisplay()); if ( poDisplay == NULL ) { QList<GDisplay *> lstDisplays = pModel->GetAllDisplays(); if( lstDisplays.count() == 0 ) { pModel->AddDisplay(new GDisplay(pGISAbsData->GetDisplay())); } } } }
void GISSetFieldAttributeMsgData::Validate() throw(GException) { /* *05 = Field number already used *06 = Invalid display number or display number does not exist *07 = Invalid screen number or screen number does not exist *08 = Invalid segment number or segment number does not exist *09 = InvalidFieldNumberOrFieldNumberDoesNotExist *12 = Invalid Attribute */ LOG_LEVEL4("Validate()"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TODO: DisplayManager Constrain - If improvement is done on Specs, this should be removed. if ( GetDisplay() != 1) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidDisplayNumberOrDisplayNumberDoesNotExist); } if ( GetScreen() == 0) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidScreenNumberOrScreenNumberDoesNotExist); } if( GetSegment() == 0 ) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidSegmentNumberOrSegmentNumberDoesNotExist); } if( GetField() == 0 ) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidFieldNumberOrFieldNumberDoesNotExist); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QSharedPointer<GISModel> pModel = GISModelSingleton::GetInstance()->GetModel(); { QMutexLocker mtxScope(pModel->GetMutex()); GDisplay* poDisplay = pModel->GetDisplay(GetDisplay()); if( poDisplay == NULL ) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidDisplayNumberOrDisplayNumberDoesNotExist); } GScreen* poScreen = poDisplay->GetScreen(GetScreen()); if( poScreen == NULL ) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidScreenNumberOrScreenNumberDoesNotExist); } GSegment* poSegment = poScreen->GetSegment(GetSegment()); if( poSegment == NULL ) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidSegmentNumberOrSegmentNumberDoesNotExist); } GTextField* poField = poSegment->GetField(GetField()); if( poField == NULL ) { //NGP 121, GPT 14/10/09 throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidFieldNumberOrFieldNumberDoesNotExist); } int iAtt = GetAttr(); if( !((iAtt > GAttributeEnum::eBeforeFirstAttrib) && (iAtt < GAttributeEnum::eAfterLastAttrib)) ) { throw GIS_EXCEPTION(GISCommandStatusEnum::eInvalidAttribute); } } }