Difference between revisions of "ADempiere Multiple Record Action Field"

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
(The Patches)
m (The Callout Rules)
 
(5 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
*Im just using here a generic window, with no purpose at all. It is up for you to figure out the possibilities
 
*Im just using here a generic window, with no purpose at all. It is up for you to figure out the possibilities
 
==The Output==
 
==The Output==
 +
 +
  
 
*The below image is the window showing the Single Row View
 
*The below image is the window showing the Single Row View
 
[[Image:Student single.png]]
 
[[Image:Student single.png]]
 +
 +
  
 
*Below, the window is viewed in Multi-Row View. Notice the fields situated at the Header(Upper part of the Window) and also the fields at the Footer( at the bottom part of the window)
 
*Below, the window is viewed in Multi-Row View. Notice the fields situated at the Header(Upper part of the Window) and also the fields at the Footer( at the bottom part of the window)
 
[[Image:Student multirow.png]]
 
[[Image:Student multirow.png]]
 +
 +
  
 
*When clicking on the "Select All" button, all the records will be marked as selected reflected by the checkbox under "Select" column. The callout logic will be explain later
 
*When clicking on the "Select All" button, all the records will be marked as selected reflected by the checkbox under "Select" column. The callout logic will be explain later
 
[[Image:Selectall.png]]
 
[[Image:Selectall.png]]
 +
 +
  
 
*When the "Unselect All" button will be clicked, all the records will cleared as unselected, in which all of the "Select" checkbox will unchecked.
 
*When the "Unselect All" button will be clicked, all the records will cleared as unselected, in which all of the "Select" checkbox will unchecked.
 
[[Image:Unselectall.png]]
 
[[Image:Unselectall.png]]
 +
 +
  
 
*User could do normal selection of the records by clicking on the "Select" checkbox in the same to other windows with checkbox
 
*User could do normal selection of the records by clicking on the "Select" checkbox in the same to other windows with checkbox
 
[[Image:Normal select.png]]
 
[[Image:Normal select.png]]
 +
 +
  
 
*Alternately, User could also use the "Invert Selection" button to invert the selection
 
*Alternately, User could also use the "Invert Selection" button to invert the selection
 
[[Image:Invert selection.png]]
 
[[Image:Invert selection.png]]
 +
 +
  
 
*I also created a sample button at the footer which will may do actions.
 
*I also created a sample button at the footer which will may do actions.
Line 27: Line 41:
  
 
*Note: Those fields mentioned above are not built-in fields. I just created them just for a sample, in fact that window is not meaningful nor usable.
 
*Note: Those fields mentioned above are not built-in fields. I just created them just for a sample, in fact that window is not meaningful nor usable.
 +
 +
=== Video Demo ===
 +
*Picture paints a thousand words, Video Paints a thousand more.
 +
*Here is the video: http://www.youtube.com/watch?v=6onpApJijzY
  
 
==The Table Definition==
 
==The Table Definition==
 +
 +
 +
 
*To achieve the sample window above, we need to define first the table
 
*To achieve the sample window above, we need to define first the table
 
[[Image:Table definition.png]]
 
[[Image:Table definition.png]]
 +
 +
 
*The table is just like common tables, ( I have copied it from "M_Freight_Category" )
 
*The table is just like common tables, ( I have copied it from "M_Freight_Category" )
 
*Aside from those standard column,I added 6 columns, in which they are the center of this discussion:
 
*Aside from those standard column,I added 6 columns, in which they are the center of this discussion:
Line 39: Line 62:
 
#doAction
 
#doAction
 
#total_selected
 
#total_selected
 +
 +
 +
  
 
*Remember the "Select All" button above, this is where that button is derived, take note of the callout specified, which will be created later
 
*Remember the "Select All" button above, this is where that button is derived, take note of the callout specified, which will be created later
 
[[Image:Table column select all.png]]
 
[[Image:Table column select all.png]]
 +
 +
  
 
*Of course this is the "Unselect All" button, again take notice of the callout specified
 
*Of course this is the "Unselect All" button, again take notice of the callout specified
 
[[Image:Table column unselect all.png]]
 
[[Image:Table column unselect all.png]]
 +
 +
  
 
*This one is for the "Invert Selection" button, so with its callout script
 
*This one is for the "Invert Selection" button, so with its callout script
 
[[Image:Table column invert selection.png]]
 
[[Image:Table column invert selection.png]]
 +
 +
  
 
*This column is just a predefined Element which I just reused. This will determine if the record is selected or not. This will be the subject for the callouts, which most of the sample callouts I have created will stir up this column.  
 
*This column is just a predefined Element which I just reused. This will determine if the record is selected or not. This will be the subject for the callouts, which most of the sample callouts I have created will stir up this column.  
 
[[Image:Table column is selected.png]]
 
[[Image:Table column is selected.png]]
*Notice that this column will not be shown when the window is viewed in Multi-Row Presentation, since this in intended for that view only, on the other hand, the other fields which are shown on the Header and Footer of the Window will only be visible when the window is viewed in Multi-Row Presentation, since it is what they are inteded ( to do actions on the Multiple Records Selected")
+
 
 +
*Notice that this column will not be shown when the window is viewed in Single-Row Presentation, since this in intended for Multi-Row View only, on the other hand, the other fields which are shown on the Header and Footer of the Window will only be visible when the window is viewed in Multi-Row Presentation, since it is what they are inteded ( to do actions on the Multiple Records Selected")
 +
 
 +
 
  
 
*This is the button at the bottom of the page which we could relate it to buttons on common wizards window of some applications which does actions such as "Next, Finish, etc".
 
*This is the button at the bottom of the page which we could relate it to buttons on common wizards window of some applications which does actions such as "Next, Finish, etc".
 
[[Image:Table column doAction.png]]
 
[[Image:Table column doAction.png]]
 +
 +
  
 
*This is a sample summary field which will display the summary of the records, in this case, the total record selected
 
*This is a sample summary field which will display the summary of the records, in this case, the total record selected
Line 60: Line 97:
  
 
==Creating new FieldGroupTypes==
 
==Creating new FieldGroupTypes==
 +
 +
 
*I added new FieldGroupTypes which are "Header - H" and "Footer - F"
 
*I added new FieldGroupTypes which are "Header - H" and "Footer - F"
 
[[Image:FieldGroupType.png]]
 
[[Image:FieldGroupType.png]]
 +
 +
 +
 
*I then create a FieldGroup "Header" of type "Header". We could use another name, but in any case the fields will still be shown in one area, and that is in the header since there are no other header area on the window
 
*I then create a FieldGroup "Header" of type "Header". We could use another name, but in any case the fields will still be shown in one area, and that is in the header since there are no other header area on the window
 
*Fields that is specified to have this Field Group("Header") will be shown at the upper part of the window, just above any other fields, below the toolbar.
 
*Fields that is specified to have this Field Group("Header") will be shown at the upper part of the window, just above any other fields, below the toolbar.
 
[[Image:Fieldgroup header.png]]
 
[[Image:Fieldgroup header.png]]
 +
 +
 +
 
*Next is the "Footer" Field Group which is of type "Footer" also, the same way as "Header" field group, fields that are specified to "Footer" will be show at the bottom part of the window, just below all any other ordinary fields.
 
*Next is the "Footer" Field Group which is of type "Footer" also, the same way as "Header" field group, fields that are specified to "Footer" will be show at the bottom part of the window, just below all any other ordinary fields.
 
[[Image:Fieldgroupfooter.png]]
 
[[Image:Fieldgroupfooter.png]]
  
 
==The Window Fields Definition==
 
==The Window Fields Definition==
 +
 
*The here comes the window definition, as usual, aside from table, this will also defined the appearance, location and behaviour of the fields in the window
 
*The here comes the window definition, as usual, aside from table, this will also defined the appearance, location and behaviour of the fields in the window
 +
 +
 +
 
*Below is the Field definition of my sample button "Select All". Take notice the Field Group which is "Header" in turn display it as the first button on the header area of the window. It is the first in the header area since it also observed the Field Order definition of the "Window Tab & Fields"
 
*Below is the Field definition of my sample button "Select All". Take notice the Field Group which is "Header" in turn display it as the first button on the header area of the window. It is the first in the header area since it also observed the Field Order definition of the "Window Tab & Fields"
 
[[Image:Window select all.png]]
 
[[Image:Window select all.png]]
 +
 +
  
 
*Just as "Select All", the "Unselect All" is also defined as "Header" field Group, but with the addition that we specify that this field is "SameLine" which will align to the first field specified.
 
*Just as "Select All", the "Unselect All" is also defined as "Header" field Group, but with the addition that we specify that this field is "SameLine" which will align to the first field specified.
 
*Note: if the "SameLine" is unchecked, this will cause the field to be created at the next line, just below the first field("Select All").
 
*Note: if the "SameLine" is unchecked, this will cause the field to be created at the next line, just below the first field("Select All").
 
[[Image:Window unselect all.png]]
 
[[Image:Window unselect all.png]]
 +
 +
  
 
*In the same way as "Select All", this "Invert Selection" field is also of "Header" field Group, and "SameLine", hence, as you could observe, the three fields are lining up at the upper part of the window.
 
*In the same way as "Select All", this "Invert Selection" field is also of "Header" field Group, and "SameLine", hence, as you could observe, the three fields are lining up at the upper part of the window.
 
[[Image:Window invert selection.png]]
 
[[Image:Window invert selection.png]]
 +
 +
  
 
*Nothing differs from "IsSelected" field to other ordinary window. Just showing it here.
 
*Nothing differs from "IsSelected" field to other ordinary window. Just showing it here.
 
[[Image:Window is selected.png]]
 
[[Image:Window is selected.png]]
 +
 +
  
 
*Next field is the "doAction" button field which is specified as "Footer" field group, causing it to be displayed at the lower part of the window.
 
*Next field is the "doAction" button field which is specified as "Footer" field group, causing it to be displayed at the lower part of the window.
 
[[Image:Window footer.png]]
 
[[Image:Window footer.png]]
 +
 +
 +
 
*"Total Selected" field is defined in "Table and Column" as of type "String", causing it to be displayed as Text field in the lower part of the window since it is also specified as "Footer" Field Group.
 
*"Total Selected" field is defined in "Table and Column" as of type "String", causing it to be displayed as Text field in the lower part of the window since it is also specified as "Footer" Field Group.
 
[[Image:Window total selected.png]]
 
[[Image:Window total selected.png]]
  
 
==The Callout Rules==
 
==The Callout Rules==
 +
 +
 +
 
*I may have a made a sample of Callout using Callout classes, but I think it is too way harder than creating the callouts in the Rule Engine.
 
*I may have a made a sample of Callout using Callout classes, but I think it is too way harder than creating the callouts in the Rule Engine.
 
*BTW, these Rule engine is a huge contribution from Carlos Luis and company, so with Victor. Thanks a lot to them!
 
*BTW, these Rule engine is a huge contribution from Carlos Luis and company, so with Victor. Thanks a lot to them!
 +
 +
  
 
*So then, to continue, we have to make callouts for our "Multiple Record Action Fields", obviously it should operate on the records
 
*So then, to continue, we have to make callouts for our "Multiple Record Action Fields", obviously it should operate on the records
Line 103: Line 168:
 
     A_Tab.setValue("IsSelected",i,"Y");
 
     A_Tab.setValue("IsSelected",i,"Y");
 
  }
 
  }
 +
 +
  
 
*As oppose to "Select All", "Unselect All" sets all "IsSelected" records to "N"
 
*As oppose to "Select All", "Unselect All" sets all "IsSelected" records to "N"
Line 113: Line 180:
 
     A_Tab.setValue("IsSelected",i,"N");
 
     A_Tab.setValue("IsSelected",i,"N");
 
  }
 
  }
 +
 +
 
*For "Invert Selection", which check to see if the record is checked, and will set it to uncheck, else otherwise.
 
*For "Invert Selection", which check to see if the record is checked, and will set it to uncheck, else otherwise.
 
[[Image:Rule InvertSelection.png]]
 
[[Image:Rule InvertSelection.png]]
Line 126: Line 195:
 
     }
 
     }
 
  }
 
  }
 +
 +
 +
 
*I have not created an interesting Callouts for this one, but for now, just be contented with this one. Or add yours to this wiki.
 
*I have not created an interesting Callouts for this one, but for now, just be contented with this one. Or add yours to this wiki.
 
[[Image:Rule DoAction.png]]
 
[[Image:Rule DoAction.png]]
Line 134: Line 206:
 
  result = "Doing Something in Callout";
 
  result = "Doing Something in Callout";
  
*"Count Selected" callout is attached to the "IsSelected" column, which in turn displays the total number of selected columns to "total_records" field located at the bottom of the window. This is not accurate all the time for the moment( maybe because of "set active callouts" blah blah.. i dunno...). Hopefully soon this will be improved. Try to see the "Sample Output window" above and take notice of the figure at the "Total Selected" fields compared to the total number of selected records. You will be that it displays just as like a summary of the list and user actions.
+
 
 +
 
 +
*"Count Selected" callout is attached to the "IsSelected" column, which in turn displays the total number of selected columns to "total_records" field located at the bottom of the window. This is not accurate all the time for the moment( maybe because of "set active callouts" blah blah.. i dunno...). Hopefully soon this will be improved. Try to see the "Sample Output window" above and take notice of the figure at the "Total Selected" fields compared to the total number of selected records. You will see that it displays just as like a summary of the list and user actions.
 
[[Image:Rule CountSelected.png]]
 
[[Image:Rule CountSelected.png]]
 
*Callout:
 
*Callout:
Line 150: Line 224:
 
  System.out.println("total selected: "+total);
 
  System.out.println("total selected: "+total);
 
  result = "";
 
  result = "";
 +
 
==The Patches==
 
==The Patches==
*Yeah, The patch files coming soon...
 
*Still Refactoring it.
 
  
 +
 +
*These are the patch files
 +
#client/src/org/compiere/grid/GridController.patch https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324880&aid=2767816
 +
#base/src/org/compiere/model/GridTab.patch https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324881&aid=2767816
 +
#base/src/org/compiere/model/X_AD_FieldGroup.patch https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324882&aid=2767816
 +
 +
 +
*New files
 +
#client/src/org/compiere/grid/SummaryPanel.java https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324883&aid=2767816
 +
#client/src/org/compiere/grid/HeaderPanel.java https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324884&aid=2767816
 +
#client/src/org/compiere/grid/FooterPanel.java https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324885&aid=2767816
 +
 +
 +
*Note: You may find that the codes I have written here seems to be odd, since this is my first time to code in Java for a real worl Application :o , but Im trying my best not to let it happen.
  
 
==See also==
 
==See also==
 +
 
*[[Script Callout]]
 
*[[Script Callout]]
 +
  
 
Feel free to discuss about this --[[User:Ivanceras|Ivanceras]] 12:27, 28 April 2009 (PDT)
 
Feel free to discuss about this --[[User:Ivanceras|Ivanceras]] 12:27, 28 April 2009 (PDT)

Latest revision as of 02:25, 29 April 2009

This is a documentation showing about my feature request for ADempiere Multiple Record Action Field [1] [2] which nobody ever responded, and due to that I made the changes all by myself (T T). Anyways I just thought I am too ambigous, So now I will explain.

ADempiere Multiple Record Action Field

  • Im just using here a generic window, with no purpose at all. It is up for you to figure out the possibilities

The Output

  • The below image is the window showing the Single Row View

Student single.png


  • Below, the window is viewed in Multi-Row View. Notice the fields situated at the Header(Upper part of the Window) and also the fields at the Footer( at the bottom part of the window)

Student multirow.png


  • When clicking on the "Select All" button, all the records will be marked as selected reflected by the checkbox under "Select" column. The callout logic will be explain later

Selectall.png


  • When the "Unselect All" button will be clicked, all the records will cleared as unselected, in which all of the "Select" checkbox will unchecked.

Unselectall.png


  • User could do normal selection of the records by clicking on the "Select" checkbox in the same to other windows with checkbox

Normal select.png


  • Alternately, User could also use the "Invert Selection" button to invert the selection

Invert selection.png


  • I also created a sample button at the footer which will may do actions.

DoAction.png

  • Note: Those fields mentioned above are not built-in fields. I just created them just for a sample, in fact that window is not meaningful nor usable.

Video Demo

The Table Definition

  • To achieve the sample window above, we need to define first the table

Table definition.png


  • The table is just like common tables, ( I have copied it from "M_Freight_Category" )
  • Aside from those standard column,I added 6 columns, in which they are the center of this discussion:
  1. select_all
  2. unselect_all
  3. invert_selection
  4. IsSelected
  5. doAction
  6. total_selected



  • Remember the "Select All" button above, this is where that button is derived, take note of the callout specified, which will be created later

Table column select all.png


  • Of course this is the "Unselect All" button, again take notice of the callout specified

Table column unselect all.png


  • This one is for the "Invert Selection" button, so with its callout script

Table column invert selection.png


  • This column is just a predefined Element which I just reused. This will determine if the record is selected or not. This will be the subject for the callouts, which most of the sample callouts I have created will stir up this column.

Table column is selected.png

  • Notice that this column will not be shown when the window is viewed in Single-Row Presentation, since this in intended for Multi-Row View only, on the other hand, the other fields which are shown on the Header and Footer of the Window will only be visible when the window is viewed in Multi-Row Presentation, since it is what they are inteded ( to do actions on the Multiple Records Selected")


  • This is the button at the bottom of the page which we could relate it to buttons on common wizards window of some applications which does actions such as "Next, Finish, etc".

Table column doAction.png


  • This is a sample summary field which will display the summary of the records, in this case, the total record selected

Table column total selected.png

Creating new FieldGroupTypes

  • I added new FieldGroupTypes which are "Header - H" and "Footer - F"

FieldGroupType.png


  • I then create a FieldGroup "Header" of type "Header". We could use another name, but in any case the fields will still be shown in one area, and that is in the header since there are no other header area on the window
  • Fields that is specified to have this Field Group("Header") will be shown at the upper part of the window, just above any other fields, below the toolbar.

Fieldgroup header.png


  • Next is the "Footer" Field Group which is of type "Footer" also, the same way as "Header" field group, fields that are specified to "Footer" will be show at the bottom part of the window, just below all any other ordinary fields.

Fieldgroupfooter.png

The Window Fields Definition

  • The here comes the window definition, as usual, aside from table, this will also defined the appearance, location and behaviour of the fields in the window


  • Below is the Field definition of my sample button "Select All". Take notice the Field Group which is "Header" in turn display it as the first button on the header area of the window. It is the first in the header area since it also observed the Field Order definition of the "Window Tab & Fields"

Window select all.png


  • Just as "Select All", the "Unselect All" is also defined as "Header" field Group, but with the addition that we specify that this field is "SameLine" which will align to the first field specified.
  • Note: if the "SameLine" is unchecked, this will cause the field to be created at the next line, just below the first field("Select All").

Window unselect all.png


  • In the same way as "Select All", this "Invert Selection" field is also of "Header" field Group, and "SameLine", hence, as you could observe, the three fields are lining up at the upper part of the window.

Window invert selection.png


  • Nothing differs from "IsSelected" field to other ordinary window. Just showing it here.

Window is selected.png


  • Next field is the "doAction" button field which is specified as "Footer" field group, causing it to be displayed at the lower part of the window.

Window footer.png


  • "Total Selected" field is defined in "Table and Column" as of type "String", causing it to be displayed as Text field in the lower part of the window since it is also specified as "Footer" Field Group.

Window total selected.png

The Callout Rules

  • I may have a made a sample of Callout using Callout classes, but I think it is too way harder than creating the callouts in the Rule Engine.
  • BTW, these Rule engine is a huge contribution from Carlos Luis and company, so with Victor. Thanks a lot to them!


  • So then, to continue, we have to make callouts for our "Multiple Record Action Fields", obviously it should operate on the records
  • Take note of the Value Search key, these are the values specified in "Table, Column & Fields" Callout.
  • The logic for selecting all the records is just to set all the "IsSelected" column to "Y"

Rule selectAll.png

  • Callout:
@script:beanshell:SelectAllRecords
  • Here is the code for copy/paste:
int rowCount = A_Tab.getRowCount();
for(int i = 0; i< rowCount; i++){
   A_Tab.setValue("IsSelected",i,"Y");
}


  • As oppose to "Select All", "Unselect All" sets all "IsSelected" records to "N"

Rule UnselectAll.png

  • Callout:
@script:beanshell:UnselectAllRecords
  • Code:
int rowCount = A_Tab.getRowCount();
for(int i = 0; i< rowCount; i++){
   A_Tab.setValue("IsSelected",i,"N");
}


  • For "Invert Selection", which check to see if the record is checked, and will set it to uncheck, else otherwise.

Rule InvertSelection.png

  • Callout:
@script:beanshell:InvertRecordSelection
  • Code:
int rowCount = A_Tab.getRowCount();
for(int i = 0; i< rowCount; i++){
   if(A_Tab.getValue(i,"IsSelected") ){
       A_Tab.setValue("IsSelected",i,"N");
   }else{
       A_Tab.setValue("IsSelected",i,"Y");
   }
}


  • I have not created an interesting Callouts for this one, but for now, just be contented with this one. Or add yours to this wiki.

Rule DoAction.png

  • Callout:
@script:beanshell:DoAction
  • Code:
javax.swing.JOptionPane.showMessageDialog(null,"Doing something in Callout!");
result = "Doing Something in Callout";


  • "Count Selected" callout is attached to the "IsSelected" column, which in turn displays the total number of selected columns to "total_records" field located at the bottom of the window. This is not accurate all the time for the moment( maybe because of "set active callouts" blah blah.. i dunno...). Hopefully soon this will be improved. Try to see the "Sample Output window" above and take notice of the figure at the "Total Selected" fields compared to the total number of selected records. You will see that it displays just as like a summary of the list and user actions.

Rule CountSelected.png

  • Callout:
@script:beanshell:CountSelected
  • Code:
int rowCount = A_Tab.getRowCount();
total = 0;
for(int i = 0; i< rowCount; i++){
   System.out.println(i+": "+A_Tab.getValue(i,"IsSelected")); 
   if( A_Tab.getValueAsBoolean(i,"IsSelected")){
       total++;
   }
}
A_Tab.setValue("total_selected",total.toString());
System.out.println("total selected: "+total);
result = "";

The Patches

  • These are the patch files
  1. client/src/org/compiere/grid/GridController.patch https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324880&aid=2767816
  2. base/src/org/compiere/model/GridTab.patch https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324881&aid=2767816
  3. base/src/org/compiere/model/X_AD_FieldGroup.patch https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324882&aid=2767816


  • New files
  1. client/src/org/compiere/grid/SummaryPanel.java https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324883&aid=2767816
  2. client/src/org/compiere/grid/HeaderPanel.java https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324884&aid=2767816
  3. client/src/org/compiere/grid/FooterPanel.java https://sourceforge.net/tracker/download.php?group_id=176962&atid=879335&file_id=324885&aid=2767816


  • Note: You may find that the codes I have written here seems to be odd, since this is my first time to code in Java for a real worl Application :o , but Im trying my best not to let it happen.

See also


Feel free to discuss about this --Ivanceras 12:27, 28 April 2009 (PDT)