Open Window and Tab

From ADempiere
Revision as of 03:46, 19 February 2007 by Kthiemann (Talk) (how to open an ADempiere window/tab from java)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Return to Tutorials

Tutorial to open an existing ADempiere window/tab programmatically

Open a window

Open an existing ADempiere window from java.

private boolean openPurchaseOrders(){
  /** AD_Window_ID of purchase order window */
  final int PURCHASE_ORDER_WINDOW_ID = 181;
  final AWindow poFrame= new AWindow(); 
  final boolean ok = poFrame.initWindow(PURCHASE_ORDER_WINDOW_ID, null);  
  if (!ok) { 
     return false; 
  } 
  poFrame.pack(); 
  AEnv.showCenterScreen(poFrame);
  return true; 
}

Open a window with filtered data

Open a window and specify the shown data records. Use this e.g. if you create documents programmatically and you just want to show the new generated data.

private boolean openPurchaseOrders(){
  /** AD_Window_ID of purchase order window */
  final int PURCHASE_ORDER_WINDOW_ID = 181;
  /** filter the data - needs to be generated for real use... */
  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);  
  if (!ok) { 
     return false; 
  } 
  poFrame.pack(); 
  AEnv.showCenterScreen(poFrame);
  return true; 
}

Navigate to a tab (Revision 1590 and higher)

APanel has several methods for tab navigation and information:

public void setSelectedTabIndex(int index);
public int getSelectedTabIndex(); 
public int noOfTabs();
public String getSelectedTabName();

To navigate to a certain tab first get the APanel of the opened window:

APanel apanel = poFrame.getAPanel(); 

Now you can use the methods of APanel to navigate to a tab of the window. Make shure that the tabIndex you set is less then noOfTabs() returns.