⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 popupvalueobjectpicker.java

📁 《j2ee开发全程实录》随书源码
💻 JAVA
字号:
package com.cownew.PIS.ui.ctrl.prompt.OVPicker;

import java.awt.Component;

import javax.swing.JTextField;

import com.cownew.PIS.framework.client.MainFrame;
import com.cownew.PIS.framework.client.RemoteServiceLocator;
import com.cownew.PIS.framework.common.IBaseDAO;
import com.cownew.PIS.framework.common.IValueObject;
import com.cownew.PIS.ui.ctrl.prompt.PopupDataPicker;
import com.cownew.PIS.ui.ctrl.query.QueryExecutor;
import com.cownew.ctk.common.PropertyUtils;
import com.cownew.ctk.common.ExceptionUtils;
import com.cownew.ctk.common.StringUtils;

public class PopupValueObjectPicker extends PopupDataPicker
{
	private JTextField edt;

	private IValueObject valueObject;

	private String displayProperty;

	private ValueObjectListDialog dlg;

	private QueryExecutor queryExecutor;

	public PopupValueObjectPicker(Class daoIntfName)
	{
		super();

		try
		{
			IBaseDAO baseDAO = (IBaseDAO) RemoteServiceLocator
					.getRemoteService(daoIntfName);
			queryExecutor = new QueryExecutor(baseDAO);
			dlg = new ValueObjectListDialog(MainFrame.getMainFrame(),
					queryExecutor);
			dlg.setModal(true);
			edt = new JTextField();
			edt.setEditable(false);

			updateUI();

		} catch (Exception e)
		{
			throw ExceptionUtils.toRuntimeException(e);
		}
	}

	public String getDisplayProperty()
	{
		return displayProperty;
	}

	public void setDisplayProperty(String displayProperty)
	{
		this.displayProperty = displayProperty;
	}

	public Component getEditor()
	{
		return edt;
	}

	public QueryExecutor getQueryExecutor()
	{
		return queryExecutor;
	}

	public IValueObject getValueObject()
	{
		return valueObject;
	}

	public void setValueObject(IValueObject valueObject)
	{
		this.valueObject = valueObject;
		if (valueObject == null)
		{
			edt.setText(null);
			return;
		}

		if (StringUtils.isEmpty(getDisplayProperty()))
		{
			edt.setText(valueObject.toString());
		} else
		{
			Object dispalyValue = PropertyUtils.getProperty(valueObject,
					getDisplayProperty());
			if (dispalyValue == null)
			{
				edt.setText(null);
			} else
			{
				edt.setText(dispalyValue.toString());
			}

		}

	}

	protected void pickData()
	{
		try
		{
			dlg.refreshData();
		} catch (Exception e)
		{
			ExceptionUtils.toRuntimeException(e);
		}
		dlg.show();
		if (dlg.isOK())
		{
			setValueObject(dlg.getSelectedData());
		}
	}

	protected void clearData()
	{
		setValueObject(null);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -