Popup on a customized toolbar button

441 views
Skip to first unread message

Nicolas Micoud

unread,
Jan 28, 2014, 7:48:36 AM1/28/14
to idem...@googlegroups.com
Hi,

I would like to add a button in the toolbar that will show a popup with different items.
It would be like the Request button.



I add a class that implements IAction

The execute method looks like :

    public void execute(Object target) {

        ADWindow adwindow = (ADWindow) target;
        ADWindowContent panel = adwindow.getADWindowContent();

        int record_ID = panel.getActiveGridTab().getRecord_ID();

...


The target is the windowNo. So i have no way to find what is the button which has called the class. And don't know how i can put the popup on the button.

Is there a way to know what button has been clicked by the user ; or is it possible to instanciate one customized button ?


Thanks,


Nicolas

Hiep Lq

unread,
Jan 28, 2014, 9:12:51 AM1/28/14
to idem...@googlegroups.com

Hi Nicolas.
by read ReportAction. I can find something.

+ "So i have no way to find what is the button which has called the class". 
try LayoutUtils.openPopupWindow(panel.getToolbar().getButton("Report"), winReport, "after_start");

if not success. discover way code add "CustomWindowToolbarButton"

+ "And don't know how i can put the popup on the button." learn ReportAction.show ()

+ "The target is the windowNo"? I see it's ADWindow. if not, please send me code. I can try check.

Nicolas Micoud

unread,
Jan 28, 2014, 9:16:23 AM1/28/14
to idem...@googlegroups.com
Hi Hiep,
thanks for answering.

Not sure that it will be as easy.
You can find example here org.adempiere.ui.zk.example.action.ExportAction

In fact, you just add a record in the AD_Toolbar table and then you will have a new button in the toolbar.
So i can't call the class with a different method than the one dedeicated to.

Regards,

Nicolas

Hiep Lq

unread,
Jan 28, 2014, 9:21:50 AM1/28/14
to idem...@googlegroups.com

I don't see org.adempiere.ui.zk.example.action.ExportAction
only org.adempiere.webui.panel.action.ExportAction. it's?

Nicolas Micoud

unread,
Jan 28, 2014, 9:24:22 AM1/28/14
to idem...@googlegroups.com

no, AFAIR, the project has to be imported in Eclipse.

Your project (see in system files) has a directory org.adempiere.ui.zk.example

--
You received this message because you are subscribed to a topic in the Google Groups "iDempiere" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idempiere/qHewmC1QEaY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/4385729f-3a74-4174-b852-9488e724f2e7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 

Hiep Lq

unread,
Jan 28, 2014, 9:33:37 AM1/28/14
to idem...@googlegroups.com
Ok. I will check late. 

I don't really know your worry. because I can wrong.

1. When you config a toolbar button. use click a button.
function IAction.execute(Object target) is call. with target is ADWindow.
because you can make your class handle AbstractADWindowContent object same constructor of ReportAction(AbstractADWindowContent panel)

2. at IAction.execute you can do as ReportAction.show () with panel.getToolbar().getButton("Report")
panel.getToolbar().getButton("Report") return button user click.

Hiep Lq

unread,
Jan 28, 2014, 9:43:21 AM1/28/14
to idem...@googlegroups.com
Just play with AttachmentScannerAction, 
I can confirm: you can use panel.getToolbar().getButton("buttonName")  to get button at toolbar.

Nicolas Micoud

unread,
Jan 28, 2014, 9:44:13 AM1/28/14
to idem...@googlegroups.com

Ah great !

Will try that.

 

Thanks a lot

 

Nicolas

Nicolas Micoud

unread,
Jan 28, 2014, 10:53:57 AM1/28/14
to idem...@googlegroups.com

It works but I notice something strange :

 

I have 2 buttons, lets call them Button1 and Button2

 

In the execute method of the class relative to Button1,

i do the following :

String buttonName = "Button2";
ToolBarButton button = panel.getToolbar().getButton(buttonName);
new WRequest(button, MTable.getTable_ID(panel.getActiveGridTab().getTableName()), panel.getActiveGridTab().getRecord_ID(), 1000065);

the button2 is instanciated but the pop up is shown under the button 1.

 

that's weird, no ??

 

Regards,

 

Nicolas

Hiep Lq

unread,
Jan 28, 2014, 11:08:32 AM1/28/14
to idem...@googlegroups.com

Maybe popup.open() only care position of mouse. cancel position of component.

Hiep Lq

unread,
Jan 28, 2014, 11:15:51 AM1/28/14
to idem...@googlegroups.com

tested. popup show at mouse point.
you can modify class WRequest.
1. add flag. isShowAtControl

2. change m_popup.open(invoker);
if (isShowAtControl){
   // Show same way of ReportAction LayoutUtils.openPopupWindow(panel.getToolbar().getButton("Report"), winReport, "after_start");
}else{
    m_popup.open(invoker);

Nicolas Micoud

unread,
Jan 28, 2014, 11:17:21 AM1/28/14
to idem...@googlegroups.com

So, the invoker is useless ?

Hiep Lq

unread,
Jan 28, 2014, 11:21:17 AM1/28/14
to idem...@googlegroups.com

Hiep Lq

unread,
Jan 28, 2014, 11:21:47 AM1/28/14
to idem...@googlegroups.com

Nicolas Micoud

unread,
Jan 28, 2014, 11:24:23 AM1/28/14
to idem...@googlegroups.com

RTFM :D

Thanks a lot

 

Nicolas

Reply all
Reply to author
Forward
0 new messages