Exemplo n.º 1
0
 /**
  * Load Persistence Object
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 17/05/2014, 11:03:25
  * @return
  * @return boolean
  */
 private boolean loadPO() {
   Env.setTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getTabNo(), m_Record_ID);
   Env.setTabKeyColumns(m_TabParam.getActivityNo(), m_TabParam.getTabNo(), m_KeyColums);
   //	Get Model
   if (model == null) {
     int instance_ID = m_Record_ID[0];
     if (m_Record_ID.length > 1) instance_ID = 0;
     //
     model = MSPSTable.getPO(m_ctx, instance_ID, m_TabInfo.getTableName(), conn);
     //
     if (model != null && m_Record_ID.length > 1) model.loadData(m_Record_ID, m_KeyColums);
   }
   //	For null
   if (model == null) {
     return false;
   }
   //	Set identifier
   Env.setContext(
       m_TabParam.getActivityNo(),
       m_TabParam.getTabNo(),
       m_TabInfo.getTableName() + "_ID",
       model.getID());
   //
   return true;
 }
Exemplo n.º 2
0
 /**
  * *** Constructor ***
  *
  * @param m_ctx
  * @param m_TabParam
  * @param m_TabInfo
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 19/05/2014, 11:47:36
  */
 public GridTab(Context m_ctx, TabParameter m_TabParam, InfoTab m_TabInfo, DB conn) {
   this.m_ctx = m_ctx;
   this.m_TabParam = m_TabParam;
   this.m_TabInfo = m_TabInfo;
   this.conn = conn;
   m_fields = new ArrayList<GridField>();
   //	Set Identifiers
   m_Record_ID = Env.getTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getTabNo());
   m_KeyColums = Env.getTabKeyColumns(m_TabParam.getActivityNo(), m_TabParam.getTabNo());
   //	Parent
   int[] parent = Env.getTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getParentTabNo());
   m_Parent_Record_ID = parent[0];
   loadPO();
 }
Exemplo n.º 3
0
 /**
  * valid and save data
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 25/02/2014, 14:07:20
  * @see https://adempiere.atlassian.net/browse/SPIN-5
  * @return
  * @return boolean
  */
 public boolean save() {
   boolean ok = true;
   m_Record_ID = Env.getTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getTabNo());
   m_KeyColums = Env.getTabKeyColumns(m_TabParam.getActivityNo(), m_TabParam.getTabNo());
   //	Error
   if (model == null) {
     m_ErrorMsg = "@NoModelClass@";
     return false;
   }
   //	Get Values
   for (GridField vField : m_fields) {
     if ((vField.isMandatory() || vField.isParent())
         && vField.isEmpty()
         && !PO.isSkipColumn(vField.getColumnName())) {
       m_ErrorMsg = "@MustFillField@ \"@" + vField.getName() + "@\"";
       //	Set ok to false
       ok = false;
       break;
     }
     //	Changed
     if (!vField.isChanged(model.isNew()) && !(vField instanceof VLookupSpinner)) continue;
     //	Set to model
     model.set_Value(vField.getColumnName(), vField.getValue());
     //	Set on Context
     DisplayType.setContextValue(
         m_ctx,
         m_TabParam.getActivityNo(),
         m_TabParam.getTabNo(),
         vField.getField(),
         vField.getValue());
     //
   }
   //	Set Record Identifier
   model.set_Value(m_TabInfo.getTableKeyName(), m_Record_ID[0]);
   //	No saved
   if (!ok) return ok;
   //	Save
   ok = modelSave();
   //	Return
   return ok;
 }
Exemplo n.º 4
0
 /**
  * Save only model
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 29/08/2014, 16:51:48
  * @return
  * @return boolean
  */
 public boolean modelSave() {
   boolean ok = true;
   m_ErrorMsg = null;
   ok = model.save();
   //	Set Record Identifier
   m_Record_ID = model.getIDs();
   m_KeyColums = model.getKeyColumns();
   if (ok) {
     Env.setTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getTabNo(), m_Record_ID);
     Env.setTabKeyColumns(m_TabParam.getActivityNo(), m_TabParam.getTabNo(), m_KeyColums);
     //
     Env.setContext(
         m_TabParam.getActivityNo(),
         m_TabParam.getTabNo(),
         m_TabInfo.getTableKeyName(),
         m_Record_ID[0]);
   } else {
     m_ErrorMsg = model.getError();
   }
   //
   return ok;
 }
Exemplo n.º 5
0
 /**
  * Refresh
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 18/10/2014, 13:36:09
  * @param record_ID
  * @param keyColumn
  * @param parentChanged
  * @return
  * @return boolean
  */
 public boolean refresh(int[] record_ID, String[] keyColumn, boolean parentChanged) {
   this.m_Record_ID = record_ID;
   //	Set record Identifier in context
   Env.setTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getTabNo(), m_Record_ID);
   Env.setTabKeyColumns(m_TabParam.getActivityNo(), m_TabParam.getTabNo(), m_KeyColums);
   //	Parent changed
   if (parentChanged || record_ID[0] <= 0) model.clear(false);
   //
   model.loadData(record_ID, keyColumn);
   //	Refresh
   loadData();
   //	Set Identifier
   Env.setContext(
       m_TabParam.getActivityNo(),
       m_TabParam.getTabNo(),
       m_TabInfo.getTableKeyName(),
       model.getID());
   //	Set Parent Record Identifier
   int[] parent = Env.getTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getParentTabNo());
   m_Parent_Record_ID = parent[0];
   //	Return
   return !isEmpty();
 }
Exemplo n.º 6
0
 /**
  * *** Constructor ***
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 04/02/2014, 17:06:03
  * @param ctx
  * @param id_View
  * @param data
  * @param p_IsGroup
  */
 public BChatThreadAdapter(
     Context ctx, ArrayList<DisplayBChatThreadItem> data, boolean p_IsGroup) {
   super(ctx, R.layout.i_bchat_thread, data);
   this.ctx = ctx;
   this.id_View = R.layout.i_bchat_thread;
   this.data = data;
   this.isGroup = p_IsGroup;
   m_SelectedItems = new SparseBooleanArray();
   inflater = LayoutInflater.from(ctx);
   m_DirectoryApp = Env.getBC_IMG_DirectoryPathName(ctx) + File.separator;
   int memClass =
       ((ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
   int maxSize = 1024 * 1024 * memClass / 8;
   m_ImageCache = new ImageCacheLru(maxSize);
   //	Get Image Size
   loadDefaultValues();
 }
Exemplo n.º 7
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    final BC_ThreadHolder msgHolder;
    DisplayBChatThreadItem diti = data.get(position);
    //	Image Key
    String imageKey = m_DirectoryApp + diti.getFileName();
    //	Size
    int desiredWidth = 0;
    boolean isImage = false;
    //	Inflate
    if (view == null) {
      msgHolder = new BC_ThreadHolder();
      view = inflater.inflate(id_View, null);
      msgHolder.ll_MainMessage = (LinearLayout) view.findViewById(R.id.ll_MainMessage);
      msgHolder.ll_Message = (LinearLayout) view.findViewById(R.id.ll_Message);
      msgHolder.rl_Conversation = (RelativeLayout) view.findViewById(R.id.rl_Conversation);
      msgHolder.tv_Conversation = (TextView) view.findViewById(R.id.tv_Conversation);
      msgHolder.tv_Time = (TextView) view.findViewById(R.id.tv_Time);
      msgHolder.tv_UserName = (TextView) view.findViewById(R.id.tv_UserName);
      //
      view.setTag(msgHolder);
    } else {
      msgHolder = (BC_ThreadHolder) view.getTag();
    }
    //	Parameters
    LinearLayout.LayoutParams params =
        (LinearLayout.LayoutParams) msgHolder.ll_Message.getLayoutParams();

    //	Set Conversation
    msgHolder.tv_Conversation.setText(diti.getText());

    //	Set Time
    msgHolder.tv_Time.setText(diti.getTimeAsString());
    msgHolder.tv_UserName.setText(diti.getUserName());
    //	Get Size from text
    msgHolder.ll_Message.measure(0, 0);
    msgHolder.tv_Conversation.measure(0, 0);
    msgHolder.tv_UserName.measure(0, 0);
    msgHolder.tv_Time.measure(0, 0);
    //	For Image
    if (diti.getFileName() != null && diti.getFileName().length() > 0) {
      //	Set flag
      isImage = true;
      Bitmap bmimage = m_ImageCache.get(imageKey);
      if (bmimage == null) {
        bmimage = AttachmentHandler.getBitmapFromFile(imageKey, m_ImageWidth, m_ImageHeight);
        //	Re-Check
        if (bmimage != null) {
          m_ImageCache.put(imageKey, bmimage);
          msgHolder.rl_Conversation.setBackgroundDrawable(
              new BitmapDrawable(ctx.getResources(), bmimage));
        } else {
          msgHolder.rl_Conversation.setBackgroundDrawable(null);
        }
      } else {
        msgHolder.rl_Conversation.setBackgroundDrawable(
            new BitmapDrawable(ctx.getResources(), bmimage));
      }
    } else {
      msgHolder.rl_Conversation.setBackgroundDrawable(null);
    }
    //
    desiredWidth = msgHolder.rl_Conversation.getMeasuredWidth();
    //
    desiredWidth += msgHolder.tv_Conversation.getMeasuredWidth();
    //	Set Visibility
    if (!isGroup || !diti.getType().equals(MQTTDefaultValues.TYPE_IN)) {
      msgHolder.tv_UserName.setVisibility(View.GONE);
    } else {
      msgHolder.tv_UserName.setVisibility(View.VISIBLE);
      //	Change Desired
      desiredWidth = Math.max(desiredWidth, msgHolder.tv_UserName.getMeasuredWidth());
    }
    //	Add Time
    desiredWidth += msgHolder.tv_Time.getMeasuredWidth();
    //
    int id_att = R.attr.ic_bc_bubble_local;
    int gravity = Gravity.START;
    //	Verify with parent
    //	For Type Message change Background
    if (diti.getType().equals(MQTTDefaultValues.TYPE_IN)) {
      //	Change Position
      msgHolder.tv_UserName.setGravity(Gravity.START);
      //
      if (m_SelectedItems.get(position)) {
        id_att = R.attr.ic_bc_bubble_remote_selected;
      } else {
        id_att = R.attr.ic_bc_bubble_remote;
      }
    } else {
      if (diti.getStatus().equals(MQTTDefaultValues.STATUS_CREATED)) {
        id_att = R.attr.ic_bc_bubble_local;
      } else if (diti.getStatus().equals(MQTTDefaultValues.STATUS_SENT)) {
        id_att = R.attr.ic_bc_bubble_local_sent;
      } else if (diti.getStatus().equals(MQTTDefaultValues.STATUS_DELIVERED)) {
        id_att = R.attr.ic_bc_bubble_local_delivered;
      } else if (diti.getStatus().equals(MQTTDefaultValues.STATUS_READED)) {
        id_att = R.attr.ic_bc_bubble_local_readed;
      }
      //
      if (m_SelectedItems.get(position)) {
        id_att = R.attr.ic_bc_bubble_local_selected;
      }
      //	Change Gravity
      gravity = Gravity.END;
    }
    //
    msgHolder.ll_Message.setBackgroundResource(Env.getResourceID(ctx, id_att));
    //	Change Size
    if (m_TextViewMaxWidth < desiredWidth) {
      desiredWidth = m_TextViewMaxWidth;
    }
    //	Change Width
    if (isImage) {
      params.width = m_ImageWidth;
      params.height = m_ImageHeight;
    } else {
      params.width = desiredWidth;
      params.height = LayoutParams.WRAP_CONTENT;
    }
    //	Change Gravity
    params.gravity = gravity;
    //	Send Status
    if (diti.getType().equals(MQTTDefaultValues.TYPE_IN)
        && !diti.getStatus().equals(MQTTDefaultValues.STATUS_READED)
        && !diti.getStatus().equals(MQTTDefaultValues.STATUS_FN_READED)) {
      BCMessageHandle.getInstance(ctx)
          .sendStatusAcknowledgment(
              diti.getSPS_BC_Request_UUID(),
              diti.getSPS_BC_Message_UUID(),
              null,
              MQTTDefaultValues.STATUS_READED);
      //	Change Status for Data
      diti.setStatus(MQTTDefaultValues.STATUS_FN_READED);
      //	Change Data
      data.set(position, diti);
    }
    //	Return
    return view;
  }
Exemplo n.º 8
0
 @Override
 public String get_ValueAsString(String variableName) {
   return Env.getContext(m_TabParam.getActivityNo(), variableName);
 }
Exemplo n.º 9
0
 /**
  * Load Data from Model
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 19/05/2014, 13:55:23
  * @param model
  * @return boolean
  */
 public boolean loadData() {
   LogM.log(m_ctx, getClass(), Level.FINE, "loadData()");
   if (model == null) return false;
   //	Get Record Identifier
   int m_Record_ID = model.getID();
   //
   for (GridField vField : m_fields) {
     //
     if (m_Record_ID <= 0) {
       //	Set value to parent field
       if (vField.isParent() || vField.getSPS_Column_ID() == m_TabInfo.getTabSPS_Column_ID()) {
         vField.setValue(
             DisplayType.getContextValue(
                 m_ctx,
                 m_TabParam.getActivityNo(),
                 m_TabParam.getParentTabNo(),
                 vField.getField()));
       } else {
         //	Set Default Value
         String defaultValue = vField.getDefaultValue();
         Object value = null;
         if (defaultValue != null && defaultValue.length() > 0) {
           value =
               DisplayType.parseValue(
                   Env.parseContext(
                       m_ctx,
                       m_TabParam.getActivityNo(),
                       m_TabParam.getParentTabNo(),
                       defaultValue,
                       false,
                       null),
                   vField.getDisplayType());
         } else {
           value = model.get_Value(vField.getColumnIndex());
         }
         //	Set Value
         vField.setValue(value);
       }
     } else {
       //	Set Value from Model
       vField.setValue(model.get_Value(vField.getColumnIndex()));
     }
     //	Set Current Values
     DisplayType.setContextValue(
         m_ctx,
         m_TabParam.getActivityNo(),
         m_TabParam.getTabNo(),
         vField.getField(),
         vField.getValue());
     //	Refresh Display
     changeDisplayDepending(vField);
   }
   //	Set ID to Context
   Env.setContext(
       m_TabParam.getActivityNo(),
       m_TabParam.getTabNo(),
       m_TabInfo.getTableKeyName(),
       m_Record_ID);
   Env.setContext(m_TabParam.getActivityNo(), m_TabInfo.getTableKeyName(), m_Record_ID);
   //	Return
   return true;
 }