コード例 #1
0
ファイル: ItogTypeEditor.java プロジェクト: baywind/rujel
 public WOActionResults saveType() {
   EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
   ec.lock();
   try {
     boolean newType = (currType == null);
     if (newType) {
       currType = (ItogType) EOUtilities.createAndInsertInstance(ec, ItogType.ENTITY_NAME);
       Number maxSort = (Number) valueForBinding("maxSort");
       if (maxSort != null) {
         currType.setSort(new Integer(maxSort.intValue() + 1));
       } else {
         currType.setSort(new Integer(1));
       }
     }
     currType.setName(itogName);
     currType.setTitle(itogTitle);
     currType.setInYearCount((itogCount == null) ? new Integer(0) : itogCount);
     ec.saveChanges();
     //			if(newType) {
     //				allTypes = allTypes.arrayByAddingObject(currType);
     //				itogsList = NSArray.EmptyArray;
     //			}
     setValueForBinding(currType, "currType");
   } catch (Exception e) {
     SetupItogs.logger.log(WOLogLevel.WARNING, "Error saving changes in list ", e);
     session().takeValueForKey(e.getMessage(), "message");
     ec.revert();
   } finally {
     ec.unlock();
   }
   return (WOActionResults) valueForBinding("actionResult");
 }
コード例 #2
0
ファイル: ItogTypeEditor.java プロジェクト: baywind/rujel
 public void appendToResponse(WOResponse aResponse, WOContext aContext) {
   ItogType type = (ItogType) valueForBinding("currType");
   currType = type;
   NamedFlags access = (NamedFlags) valueForBinding("access");
   if (access == null)
     access = (NamedFlags) session().valueForKeyPath("readAccess.FLAGS.ItogType");
   if (type == null) {
     itogName = null;
     itogTitle = null;
     itogCount = null;
     canDelete = false;
     cantEdit = (Boolean) access.valueForKey("_create");
     // session().valueForKeyPath("readAccess._create.ItogType");
   } else {
     itogName = currType.name();
     itogTitle = currType.title();
     itogCount = currType.inYearCount();
     if (itogCount.intValue() == 0) itogCount = null;
     EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
     NSArray itogs =
         EOUtilities.objectsMatchingKeyAndValue(
             ec, ItogContainer.ENTITY_NAME, ItogContainer.ITOG_TYPE_KEY, type);
     canDelete = (itogs == null || itogs.count() == 0);
     cantEdit = (Boolean) access.valueForKey("_edit");
     // session().valueForKeyPath("readAccess._edit.currType");
   }
   super.appendToResponse(aResponse, aContext);
 }