I have a form from which I want to make a small program which enables me to view one particular tab in a given window.
Can anyone help me, please?
Thanks in advance.
Saber.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think that this is only possible with some enhancements in APanel.java but here is a way that should work:
to open a window:
// open the Window (filtered) - same should work with query=null/without whereString
String whereString = " C_Order_ID IN (1000000, 1000001)";
final AWindow poFrame = new AWindow();
final MQuery query = new MQuery("C_Order");
query.addRestriction(whereString);
final boolean ok = poFrame.initWindow(AD_Window_ID, query);
//you need to define the AD_Window_ID somewhere, look at the table AD_Window in db to find the right ID...
if (!ok) {
return false;
}
poFrame.pack();
AEnv.showCenterScreen(poFrame);
to navigate to a tab of the window you have to add some methods to APanel.java:
public int getSelectedTabIndex() {
return m_curWinTab.getSelectedIndex();
}
public void setSelectedTabIndex(int index) {
m_curWinTab.setSelectedIndex(index);
}
public int noOfTabs() {
return m_curWinTab.getTabCount();
}
public String getSelectedTabName() {
String title = m_curWinTab.getTitleAt(m_curWinTab.getSelectedIndex());
title = title.substring(title.indexOf("<html>")+6);
title = title.substring(0,title.indexOf("<"));
return title;
}
get the APanel of the opened window:
APanel apanel = poFrame.getAPanel();
now you can use the added methods to navigate to a tab of the window.
Best regards,
Karsten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Karsten, I think this can be a good enhancement to be added into trunk.
We can think in future to add also some code for Zoom functionality to navigate directly to the tab where the record is defined (currently Zoom is opening the window, selecting the parent and positioning on first tab).
Regards,
Carlos Ruiz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> We can think in future to add also some code for Zoom functionality to navigate directly to the tab where the record is defined (currently Zoom is opening the window, selecting the parent and positioning on first tab).
This functionality is totally missing from current adempiere, and this is very annoying for users, so it would be great if it will be implemented in trunk.
Best regards,
Teo Sarca
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi developers, I completed this submission on revision 2101, but it has a problem, the window is not focused after programatically opening.
Let me explain better:
I'm opening the window and navigating to the tab from a button callout (another good enhancement :-)
If I just open the window without navigating to the tab, it works perfect.
If I open the window and navigate to a tab (apanel.setSelectedTabIndex(2);) then the new window lost the focus, and the focus is returned to the original window with the button that called the callout.
I tried already with
apanel.requestFocus();
and
frame.requestFocus();
but none is working.
Can you advice on the matter?
The GW reproducible callout code would be:
-----------------------
if (frame.initWindow(123 /*BPartner Window*/, MQuery.getEqualQuery("C_BPartner_ID", 112))) {
AEnv.addToWindowManager(frame);
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED))
AEnv.showMaximized(frame);
else
AEnv.showCenterScreen(frame);
// Navigate to the subscriber tab (problem, is losing the focus)
APanel apanel = frame.getAPanel();
if (apanel.noOfTabs() >= 7) {
apanel.setSelectedTabIndex(5);
apanel.setSelectedTabIndex(6);
apanel.requestFocus();
frame.requestFocus();
}
frame = null;
}
return "";
----------------------
Regards,
Carlos Ruiz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I have a form from which I want to make a small program which enables me to view one particular tab in a given window.
Can anyone help me, please?
Thanks in advance.
Saber.
Hi Saber,
I think that this is only possible with some enhancements in APanel.java but here is a way that should work:
to open a window:
// open the Window (filtered) - same should work with query=null/without whereString
String whereString = " C_Order_ID IN (1000000, 1000001)";
final AWindow poFrame = new AWindow();
final MQuery query = new MQuery("C_Order");
query.addRestriction(whereString);
final boolean ok = poFrame.initWindow(AD_Window_ID, query);
//you need to define the AD_Window_ID somewhere, look at the table AD_Window in db to find the right ID...
if (!ok) {
return false;
}
poFrame.pack();
AEnv.showCenterScreen(poFrame);
to navigate to a tab of the window you have to add some methods to APanel.java:
public int getSelectedTabIndex() {
return m_curWinTab.getSelectedIndex();
}
public void setSelectedTabIndex(int index) {
m_curWinTab.setSelectedIndex(index);
}
public int noOfTabs() {
return m_curWinTab.getTabCount();
}
public String getSelectedTabName() {
String title = m_curWinTab.getTitleAt(m_curWinTab.getSelectedIndex());
title = title.substring(title.indexOf("<html>")+6);
title = title.substring(0,title.indexOf("<"));
return title;
}
get the APanel of the opened window:
APanel apanel = poFrame.getAPanel();
now you can use the added methods to navigate to a tab of the window.
Best regards,
Karsten
Hi Karsten, I think this can be a good enhancement to be added into trunk.
We can think in future to add also some code for Zoom functionality to navigate directly to the tab where the record is defined (currently Zoom is opening the window, selecting the parent and positioning on first tab).
Regards,
Carlos Ruiz
Hi,
>Access to a tab in a window programmatically
I also like this functionality and would like to see it in trunk.
Kind regards,
Trifon
Integrated in revision 1576
regards,
Karsten
> We can think in future to add also some code for Zoom functionality to navigate directly to the tab where the record is defined (currently Zoom is opening the window, selecting the parent and positioning on first tab).
This functionality is totally missing from current adempiere, and this is very annoying for users, so it would be great if it will be implemented in trunk.
Best regards,
Teo Sarca
Hi Karsten,
Thanks a lot for your help. I tested it and it works fine.
Bast Regards,
Saber.
Hi,
perhaps it would be easier just to have a
public JTabbedPane getCurWinTab(){
Hi,
perhaps it would be easier just to have a
public JTabbedPane getCurWinTab(){
return m_curWinTab;
}
what do you think?
Regards,
Karsten
Hi,
from a object orientated view it will be better not to give direct access to the JTabbedPane so I guess I will just add the three methods.
Karsten
Hi,
I added a wiki page for that:
http://www.adempiere.com/wiki/index.php/Open_Window_and_Tab
Regards,
Karsten
Hi developers, I completed this submission on revision 2101, but it has a problem, the window is not focused after programatically opening.
Let me explain better:
I'm opening the window and navigating to the tab from a button callout (another good enhancement :-)
If I just open the window without navigating to the tab, it works perfect.
If I open the window and navigate to a tab (apanel.setSelectedTabIndex(2);) then the new window lost the focus, and the focus is returned to the original window with the button that called the callout.
I tried already with
apanel.requestFocus();
and
frame.requestFocus();
but none is working.
Can you advice on the matter?
The GW reproducible callout code would be:
-----------------------
if (frame.initWindow(123 /*BPartner Window*/, MQuery.getEqualQuery("C_BPartner_ID", 112))) {
AEnv.addToWindowManager(frame);
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED))
AEnv.showMaximized(frame);
else
AEnv.showCenterScreen(frame);
// Navigate to the subscriber tab (problem, is losing the focus)
APanel apanel = frame.getAPanel();
if (apanel.noOfTabs() >= 7) {
apanel.setSelectedTabIndex(5);
apanel.setSelectedTabIndex(6);
apanel.requestFocus();
frame.requestFocus();
}
frame = null;
}
return "";
----------------------
Regards,
Carlos Ruiz
hi carlos,
this should work:
frame.toFront();
Hi,
so if it works it may be useful to include this call into the setSelectedTabIndex() because I guess this is the behaviour most users would expect.
Regards,
Karsten
> frame.toFront();
didn't work :-(
Regards,
Carlos Ruiz
carlos,
can u try this under java 1.6, it could be a swing bug. Also, if you can attach a test case somewhere, I'll try to debug this.
Regards,
Low
Hi Carlos,
Did you solve your problem ?
If not, check out:
https://sourceforge.net/tracker/index.php?func=detail&aid=1707221&group_id=176962&atid=879332
Best regards,
Teo Sarca