📄 mwindow.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.sql.*;
import java.util.*;
import java.io.*;
import org.compiere.util.*;
import org.compiere.plaf.*;
/**
* Window Model
*
* @author Jorg Janke
* @version $Id: MWindow.java,v 1.14 2002/09/14 05:27:40 jjanke Exp $
*/
public final class MWindow implements Serializable
{
/**
* Constructor
* @param vo value object
*/
public MWindow (MWindowVO vo)
{
m_vo = vo;
if (loadTabData())
enableEvents();
} // MWindow
/** Value Object */
private MWindowVO m_vo;
//
public static final String WindowType_Query = "Q";
public static final String WindowType_Trx = "T";
public static final String WindowType_Maintain = "M";
//
private ArrayList m_tabs = new ArrayList();
/*************************************************************************/
/**
* Dispose
*/
public void dispose()
{
Log.trace(Log.l2_Sub, "MWindow.dispose - " + m_vo.AD_Window_ID);
for (int i = 0; i < getTabCount(); i++)
getTab(i).dispose();
m_tabs.clear();
m_tabs = null;
} // dispose
/**
* Load is complete.
* Return when async load is complete
* Used for performance tests (Base.test())
*/
public void loadCompete ()
{
// for all tabs
for (int i = 0; i < getTabCount(); i++)
getTab(i).getMTable().loadComplete();
} // loadComplete
/**
* Get Tab data and create MTab(s)
* @return true if tab loaded
*/
private boolean loadTabData()
{
Log.trace(Log.l3_Util, "MWindow.loadTabData");
if (m_vo.Tabs == null)
return false;
for (int t = 0; t < m_vo.Tabs.size(); t++)
{
MTabVO mTabVO = (MTabVO)m_vo.Tabs.get(t);
if (mTabVO != null)
{
MTab mTab = new MTab(mTabVO);
// Set Link Column
if (mTab.getLinkColumnName().length() == 0)
{
ArrayList parents = mTab.getParentColumnNames();
// No Parent - no link
if (parents.size() == 0)
;
// Standard case
else if (parents.size() == 1)
mTab.setLinkColumnName((String)parents.get(0));
else
{
// More than one parent.
// Search prior tabs for the "right parent"
// for all previous tabs
for (int i = 0; i < m_tabs.size(); i++)
{
// we have a tab
MTab tab = (MTab)m_tabs.get(i);
String tabKey = tab.getKeyColumnName(); // may be ""
// look, if one of our parents is the key of that tab
for (int j = 0; j < parents.size(); j++)
{
String parent = (String)parents.get(j);
if (parent.equals(tabKey))
{
mTab.setLinkColumnName(parent);
break;
}
// The tab could have more than one key, look into their parents
if (tabKey.equals(""))
for (int k = 0; k < tab.getParentColumnNames().size(); k++)
if (parent.equals(tab.getParentColumnNames().get(k)))
{
mTab.setLinkColumnName(parent);
break;
}
} // for all parents
} // for all previous tabs
} // parents.size > 1
} // set Link column
mTab.setLinkColumnName(null); // overwrites, if AD_Column_ID exists
//
m_tabs.add(mTab);
}
} // for all tabs
return true;
} // loadTabData
/**
* Get Window Icon
* @return Icon for Window
*/
public javax.swing.Icon getIcon()
{
if (m_vo.AD_Image_ID == 0)
return null;
//
/** @todo Load Image */
return null;
} // getIcon
/**
* Get Color
* @return CompiereColor or null
*/
public CompiereColor getColor()
{
if (m_vo.AD_Color_ID == 0)
return null;
MColor mc = new MColor(m_vo.ctx, m_vo.AD_Color_ID);
return mc.getCompiereColor();
} // getColor
/**
* Open and query first Tab (events should be enabled) and get first row.
*/
public void query()
{
Log.trace(Log.l2_Sub, "MWindow.open");
MTab tab = getTab(0);
tab.query(false, 1);
if (tab.getRowCount() > 0)
tab.navigate(0);
} // open
/**
* Enable Events - enable data events of tabs (add listeners)
*/
private void enableEvents()
{
for (int i = 0; i < getTabCount(); i++)
getTab(i).enableEvents();
} // enableEvents
/**
* Get number of Tabs
* @return number of tabs
*/
public int getTabCount()
{
return m_tabs.size();
} // getTabCount
/**
* Get i-th MTab - null if not valid
* @param i index
* @return MTab
*/
public MTab getTab (int i)
{
if (i < 0 || i+1 > m_tabs.size())
return null;
return (MTab)m_tabs.get(i);
} // getTab
/**
* Get Window_ID
* @return AD_Window_ID
*/
public int getAD_Window_ID()
{
return m_vo.AD_Window_ID;
} // getAD_Window_ID
/**
* Get WindowNo
* @return WindowNo
*/
public int getWindowNo()
{
return m_vo.WindowNo;
} // getWindowNo
/**
* Get Name
* @return name
*/
public String getName()
{
return m_vo.Name;
} // getName
/**
* Get Description
* @return Description
*/
public String getDescription()
{
return m_vo.Description;
} // getDescription
/**
* Get Help
* @return Help
*/
public String getHelp()
{
return m_vo.Help;
} // getHelp
/**
* Get Window Type
* @return Window Type see WindowType_*
*/
public String getWindowType()
{
return m_vo.WindowType;
} // getWindowType
/**
* Is Transaction Window
* @return true if transaction
*/
public boolean isTransaction()
{
return m_vo.WindowType.equals(WindowType_Trx);
} // isTransaction
/**
* To String
* @return String representation
*/
public String toString()
{
return "MWindow[" + m_vo.WindowNo + "," + m_vo.Name + " (" + m_vo.AD_Window_ID + ")]";
} // toString
} // MWindow
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -