📄 statusbar.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 Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.apps;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.compiere.model.*;
import org.compiere.plaf.*;
import org.compiere.swing.*;
import org.compiere.util.*;
/**
* Status Bar
*
* @author Jorg Janke
* @version $Id: StatusBar.java,v 1.14 2005/03/11 20:27:59 jjanke Exp $
*/
public class StatusBar extends CPanel
{
/**
* Standard Status Bar
*/
public StatusBar()
{
this(false);
} // StatusBar
/**
* Status Bar with additional info
* @param withInfo with info
*/
public StatusBar (boolean withInfo)
{
super();
try
{
jbInit();
}
catch (Exception e)
{}
this.setName("statusBar");
if (!withInfo)
infoLine.setVisible(false);
} // StatusBar
private BorderLayout mainLayout = new BorderLayout();
private JLabel statusLine = new JLabel();
private JLabel statusDB = new JLabel();
private JLabel infoLine = new JLabel();
//
private boolean mt_error;
private String mt_text;
//
private String m_text;
private DataStatusEvent m_dse = null;
/**
* Static Init
* @throws Exception
*/
private void jbInit() throws Exception
{
statusLine.setBorder(BorderFactory.createEtchedBorder());
statusLine.setText("statusLine");
statusLine.setOpaque(false);
statusDB.setForeground(Color.blue);
statusDB.setBorder(BorderFactory.createEtchedBorder());
statusDB.setText("#");
statusDB.setOpaque(false);
statusDB.addMouseListener(new StatusBar_mouseAdapter(this));
this.setLayout(mainLayout);
infoLine.setFont(CompierePLAF.getFont_Label());
infoLine.setBorder(BorderFactory.createRaisedBevelBorder());
infoLine.setHorizontalAlignment(SwingConstants.CENTER);
infoLine.setHorizontalTextPosition(SwingConstants.CENTER);
infoLine.setText("info");
mainLayout.setHgap(2);
mainLayout.setVgap(2);
this.add(statusLine, BorderLayout.CENTER);
this.add(statusDB, BorderLayout.EAST);
this.add(infoLine, BorderLayout.NORTH);
} // jbInit
/**************************************************************************
* Set Standard Status Line (non error)
* @param text text
*/
public void setStatusLine (String text)
{
if (text == null)
setStatusLine("", false);
else
setStatusLine(text, false);
} // setStatusLine
/**
* Set Status Line
* @param text text
* @param error error
*/
public void setStatusLine (String text, boolean error)
{
mt_error = error;
mt_text = text;
if (mt_error)
statusLine.setForeground(CompierePLAF.getTextColor_Issue());
else
statusLine.setForeground(CompierePLAF.getTextColor_OK());
statusLine.setText(" " + mt_text);
//
Thread.yield();
} // setStatusLine
/**
* Get Status Line text
* @return StatusLine text
*/
public String getStatusLine ()
{
return statusLine.getText().trim();
} // setStatusLine
/**
* Set ToolTip of StatusLine
* @param tip tip
*/
public void setStatusToolTip (String tip)
{
statusLine.setToolTipText(tip);
} // setStatusToolTip
/**
* Set Status DB Info
* @param text text
* @param dse data status event
*/
public void setStatusDB (String text, DataStatusEvent dse)
{
// log.config( "StatusBar.setStatusDB - " + text + " - " + created + "/" + createdBy);
if (text == null || text.length() == 0)
{
statusDB.setText("");
statusDB.setVisible(false);
}
else
{
StringBuffer sb = new StringBuffer (" ");
sb.append(text).append(" ");
statusDB.setText(sb.toString());
if (!statusDB.isVisible())
statusDB.setVisible(true);
}
// Save
m_text = text;
m_dse = dse;
} // setStatusDB
/**
* Set Status DB Info
* @param text text
*/
public void setStatusDB (String text)
{
setStatusDB (text, null);
} // setStatusDB
/**
* Set Status DB Info
* @param no no
*/
public void setStatusDB (int no)
{
setStatusDB (String.valueOf(no), null);
} // setStatusDB
/**
* Set Info Line
* @param text text
*/
public void setInfo (String text)
{
if (!infoLine.isVisible())
infoLine.setVisible(true);
infoLine.setText(text);
} // setInfo
/**
* Add Component to East of StatusBar
* @param component component
*/
public void addStatusComponent (JComponent component)
{
this.add(component, BorderLayout.EAST);
} // addStatusComponent
/**
* Show WHO
* @param e event
*/
void mouseClicked(MouseEvent e)
{
if (m_dse == null
|| m_dse.CreatedBy == null
|| !MRole.getDefault().isShowPreference())
return;
//
String title = Msg.getMsg(Env.getCtx(), "Who") + m_text;
RecordInfo info = new RecordInfo (Env.getFrame(this), title, m_dse);
AEnv.showCenterScreen(info);
} // addStatusComponent
} // StatusBar
/******************************************************************************
* Mouse Adapter for Status Bar (statusDB)
*/
class StatusBar_mouseAdapter extends java.awt.event.MouseAdapter
{
private StatusBar adaptee;
/**
* Constructor
* @param adaptee adaptee
*/
StatusBar_mouseAdapter(StatusBar adaptee)
{
this.adaptee = adaptee;
}
/**
* Click
* @param e event
*/
public void mouseClicked(MouseEvent e)
{
adaptee.mouseClicked(e);
}
} // StatusBar_mouseAdapter
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -