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

📄 stockmanagerview.java

📁 java eclipse rcp学习
💻 JAVA
字号:

package chainShopMS.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

/**
 * @author Administrator
 *	采购管理的视图
 */
public class StockManagerView extends ViewPart
{
	private Text productID;// 商品编号

	private Text productName;// 商品名称

	private Combo provider;// 供应商
	
	private Text productDate;// 生产日期

	private Text buyer;// 采购员

	private Text buyMoney;// 单位进价
	
	private Text sellMoney;// 单位售价
	
	private Text productNum;// 数量
	
	private Text productNote;// 备注
	
	
	private Button productStock;// 商品采购添加

	
	/** 该视图的ID */
	public static final String ID = "chainShopMS.views.StockManagerView";

	/**
	 * 生成GridData对象的重复代码太多,写出一个可以减少程序的行数,用起来也方便,而且要注意一个GridData只能呗一个组件实验
	 * 不能两个组件使用一个GridData,否则一个组件不会显示出来
	 */
	private GridData createGridData(int style,int horizontalSpan)
	{
		GridData gridData=new GridData(style);
		gridData.horizontalSpan=horizontalSpan;
		gridData.grabExcessHorizontalSpace=true;
		gridData.horizontalAlignment=SWT.FILL;
		return gridData;
	}
	
	// 必须实现的两个方法
	public void createPartControl(final Composite parent)
	{
		parent.setLayout(new GridLayout(6, false));// 信息面板分成6列

		new Label(parent, SWT.NONE).setText("商品编号:");
		productID = new Text(parent, SWT.BORDER);
		productID.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));

		new Label(parent, SWT.NONE).setText("商品名称:");
		productName = new Text(parent, SWT.BORDER);
		productName.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));
		
		new Label(parent, SWT.NONE).setText("供 应 商:");
		provider = new Combo(parent, SWT.BORDER);
		//从数据库从得到供应商的数据添加
		provider.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));

		new Label(parent, SWT.NONE).setText("采 购 员:");
		buyer = new Text(parent, SWT.BORDER);
		buyer.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));

		new Label(parent, SWT.NONE).setText("数   量:");
		productNum = new Text(parent, SWT.BORDER);
		
		productNum.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));
		
		new Label(parent, SWT.NONE).setText("生产日期:");
		productDate = new Text(parent, SWT.BORDER);
		productDate.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));
		
		new Label(parent, SWT.NONE).setText("单位进价:");
		buyMoney= new Text(parent, SWT.BORDER);
		buyMoney.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));
		
		new Label(parent, SWT.NONE).setText("单位售价:");
		sellMoney= new Text(parent, SWT.BORDER);
		sellMoney.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));
		
		new Label(parent, SWT.NONE).setText("备   注:");
		productNote= new Text(parent, SWT.BORDER);
		productNote.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1));
		
		new Label(parent, SWT.NONE);
		new Label(parent, SWT.NONE);
		new Label(parent, SWT.NONE);
		new Label(parent, SWT.NONE);
		new Label(parent, SWT.NONE);
		//按钮
		productStock =new Button(parent,SWT.NONE);
		productStock.setText("  采购  ");
		
		
	}

	public void setFocus()
	{
		productID.setFocus();
	}
}

⌨️ 快捷键说明

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