View unanswered posts | View active topics It is currently Sat May 25, 2013 1:08 am



This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
 catch activity change category 
Author Message

Joined: Fri Aug 10, 2007 11:27 am
Posts: 33
Post catch activity change category
Hello,

I 'm able to catch event :
- during activity change with
Code:
dateAreaBean1.getDateArea().addActivityMoveListener(new ActivityMoveListener() {....

- at the end of activity change (mouse released) with
Code:
dateAreaBean.getDateArea().addActivityDragResizeListener( new ActivityDragResizeListener() {....


I want to do the same when activity change category. I'm able to catch event during activity change category with
Code:
dateAreaBean1.getDateArea().addActivityMoveListener(new ActivityMoveListener() {

   @Override
   public void activityMoved(ActivityMoveEvent e) {
      
      DefaultDateArea da = (DefaultDateArea) e.getSource();
      Point point = ((MouseEvent) e.getEvent()).getPoint();
      GridRow row = da.getDateGrid().getRowAt(Grid.SECONDARY_DIMENSION, point, 1000);
      if (row == null) {
         return;
      }
      CategoryFilter catFilter = (CategoryFilter) row.getFilter();
      if (catFilter == null) {
         return;
      }
      Object[] c1Arr = e.getActivity().getCategoryIDs();
      Category c1 = (c1Arr != null && c1Arr.length > 0) ? CategoryDepository.getCategory(c1Arr[0]) : null;

      Category[] c2Arr = catFilter.getCategories();
      Category c2 = (c2Arr != null && c2Arr.length > 0) ? c2Arr[0] : null;

      if (c1 != null && c2 != null && c1 != c2) {
         //activity change category
         e.getActivity().setCategoryIDs(new Object[]{c2.getId()});
         da.doLayout();
      }
   }
}


but I don't known how to catch event at the end of activity change category (mouse released).

Thanks for your help.
Laurent


Thu Feb 05, 2009 11:47 am
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: catch activity change category
Hello,

I don't think there is an easy way unfortunately.

Also, please post support questions as a support ticket from our site.


Thu Feb 05, 2009 8:20 pm
Profile WWW

Joined: Fri Aug 10, 2007 11:27 am
Posts: 33
Post Re: catch activity change category
I found solution in my case:

Code:
dateAreaBean.getDateArea().addActivityDragResizeListener( new ActivityDragResizeListener() {
   @Override
   public void activityDragResized(ActivityDragResizeEvent e) {

      Activity act;
      Planning plan = null;
      boolean periodeModifie = false;
      boolean salarieModifie = false;
      
      TimeSpan[] activities = lstActivity.toArray();
      for (int i = 0; i < activities.length; i++) {
         act = ((Activity) activities[i]);
         plan = (Planning) act.getID();
         
         //test if category change
         Object[] catArray = act.getCategoryIDs();
         Category c1 = (catArray != null && catArray.length > 0) ? CategoryDepository.getCategory(catArray[0]) : null;
         Integer salarieActivity = null;
         Integer salariePlanning = plan.getFkSalarie();
         if (c1 != null && c1.getId() instanceof Salarie) {
            
            salarieActivity = ((Salarie)c1.getId()).getId();
            if(!salarieActivity.equals(salariePlanning)){
               salarieModifie = true;
               plan.setFkSalarie(salarieActivity);
            }
         }
                  
         //test if date range modify
         if (!plan.getPlaDebut().getTime().equals(d.getTime()) ||
               !plan.getPlaFin().getTime().equals(f.getTime())) {
            periodeModifie  =true;
         }

         if(salarieModifie || periodeModifie){
            ....
         }
      }
   }
});


Fri Feb 06, 2009 11:12 am
Profile
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 3 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.