package com.zx.dialog;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
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 com.gface.date.DatePickerCombo;
import com.gface.date.DatePickerStyle;
public class NewItemPage extends WizardPage
{
/** 页面名称 */
public static final String NEW_ITEM_PAGE = "NewItemPage";
public static final String[] ITEM_BIG_TYPE = new String[] { "水电用材", "瓦工用材",
"木工用材", "油漆用材", "其他" };
public static final String[][] ITEM_DETAIL_TYPE = new String[][] {
{ "金牛4\"水管", "内丝弯", "内丝三通", "内丝直接", "等径三通", "等径直接", "过桥弯", "异径直接",
"堵头", "外丝", "软管", "生料带", "勾钉", "水管卡", "中财40PVC管", "弯头",
"中财50PVC管", "PVC胶", "中财4\"线管", "锁母", "直接", "单暗盒", "双暗盒",
"远东2.52线", "1.52线", "山湖电视线", "普天网线", "胶布", "4\"管卡", "黄腊管",
"钢丝", "水泥", "细沙", "扫把", "垃圾袋", "防水剂" },
{ "黄沙", "水泥", "红砖" },
{ "白松木方", "拉法基石膏板", "莫干山集成板", "百源木工板", "莫干山红樱桃", "柳安五厘板", "多层九厘板",
"2.5自攻钉", "38钢排钉", "50钢排钉", "F30", "F20", "F15", "蚊钉",
"2.5元钉", "3寸元钉", "3.5寸元钉", "沙纸180#", "宁扬白乳胶", "小红桶", "刷子",
"刀片", "线条", "玻璃" },
{ "华润清底9.5kg", "华润清面9.5kg", "宁扬901胶", "宁兰500#", "白玉兰石膏粉", "高士熟胶粉",
"邦邦滚筒(粗)", "邦邦滚筒(细)", "犀利水沙360#", "犀利水沙400#", "小红桶", "美纹纸",
"绷带", "除尘布", "毛巾", "红、黄粉", "4寸羊毛刷", "4寸棕毛刷", "长江防锈漆",
"立邦美加丽", "过滤网" }, { "其他" } };
private Combo typeTxt;
private Text priceTxt;
private Text numTxt;
private DatePickerCombo dateTxt;
private Text remarkTxt;
private ItemBean item;
private long userId;
private static HashMap MAP_TYPE = new HashMap();
static
{
for ( int i = 0 ; i < ITEM_BIG_TYPE.length ; i++ )
{
MAP_TYPE.put(ITEM_BIG_TYPE[i], i);
}
}
public void setUserId ( long userId )
{
this.userId = userId;
}
protected NewItemPage()
{
super(NEW_ITEM_PAGE);
}
public void createControl ( Composite parent )
{
/** 设置面板布局 */
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
new Label(composite, SWT.NONE).setText("材料类别:");
Combo bigTypeTxt = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
bigTypeTxt.setItems(ITEM_BIG_TYPE);
bigTypeTxt.select(0);
bigTypeTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(composite, SWT.NONE).setText("材料名称:");
typeTxt = new Combo(composite, SWT.BORDER);
typeTxt.setItems(ITEM_DETAIL_TYPE[0]);
typeTxt.select(0);
typeTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
bigTypeTxt.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected ( SelectionEvent e )
{
Combo cb = (Combo) e.widget;
if ( MAP_TYPE.get(cb.getText()) != null )
{
int index = Integer.parseInt(String.valueOf(MAP_TYPE
.get(cb.getText())));
typeTxt.setItems(ITEM_DETAIL_TYPE[index]);
typeTxt.select(0);
}
}
});
new Label(composite, SWT.NONE).setText("单价:");
priceTxt = new Text(composite, SWT.BORDER);
priceTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(composite, SWT.NONE).setText("数量:");
numTxt = new Text(composite, SWT.BORDER);
numTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
int dpStyle = DatePickerStyle.BUTTONS_ON_BOTTOM
| DatePickerStyle.HIDE_WHEN_NOT_IN_FOCUS
| DatePickerStyle.SINGLE_CLICK_SELECTION
| DatePickerStyle.WEEKS_STARTS_ON_MONDAY
| DatePickerStyle.YEAR_BUTTONS | 0;
new Label(composite, SWT.NONE).setText("时间:");
dateTxt = new DatePickerCombo(composite, SWT.BORDER | SWT.READ_ONLY,
dpStyle);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
dateTxt.setDateFormat(sdf);
dateTxt.setEditable(false);
Calendar calendar = Calendar.getInstance();
dateTxt.setDate(calendar.getTime());
dateTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(composite, SWT.NONE).setText("备注:");
remarkTxt = new Text(composite, SWT.BORDER);
remarkTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
this.setControl(composite);
}
public ItemBean getItem ( )
{
if ( this.item == null )
{
this.item = new ItemBean();
}
this.item.setBelongId(this.userId);
return this.item;
}
}
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
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 com.gface.date.DatePickerCombo;
import com.gface.date.DatePickerStyle;
public class NewItemPage extends WizardPage
{
/** 页面名称 */
public static final String NEW_ITEM_PAGE = "NewItemPage";
public static final String[] ITEM_BIG_TYPE = new String[] { "水电用材", "瓦工用材",
"木工用材", "油漆用材", "其他" };
public static final String[][] ITEM_DETAIL_TYPE = new String[][] {
{ "金牛4\"水管", "内丝弯", "内丝三通", "内丝直接", "等径三通", "等径直接", "过桥弯", "异径直接",
"堵头", "外丝", "软管", "生料带", "勾钉", "水管卡", "中财40PVC管", "弯头",
"中财50PVC管", "PVC胶", "中财4\"线管", "锁母", "直接", "单暗盒", "双暗盒",
"远东2.52线", "1.52线", "山湖电视线", "普天网线", "胶布", "4\"管卡", "黄腊管",
"钢丝", "水泥", "细沙", "扫把", "垃圾袋", "防水剂" },
{ "黄沙", "水泥", "红砖" },
{ "白松木方", "拉法基石膏板", "莫干山集成板", "百源木工板", "莫干山红樱桃", "柳安五厘板", "多层九厘板",
"2.5自攻钉", "38钢排钉", "50钢排钉", "F30", "F20", "F15", "蚊钉",
"2.5元钉", "3寸元钉", "3.5寸元钉", "沙纸180#", "宁扬白乳胶", "小红桶", "刷子",
"刀片", "线条", "玻璃" },
{ "华润清底9.5kg", "华润清面9.5kg", "宁扬901胶", "宁兰500#", "白玉兰石膏粉", "高士熟胶粉",
"邦邦滚筒(粗)", "邦邦滚筒(细)", "犀利水沙360#", "犀利水沙400#", "小红桶", "美纹纸",
"绷带", "除尘布", "毛巾", "红、黄粉", "4寸羊毛刷", "4寸棕毛刷", "长江防锈漆",
"立邦美加丽", "过滤网" }, { "其他" } };
private Combo typeTxt;
private Text priceTxt;
private Text numTxt;
private DatePickerCombo dateTxt;
private Text remarkTxt;
private ItemBean item;
private long userId;
private static HashMap MAP_TYPE = new HashMap();
static
{
for ( int i = 0 ; i < ITEM_BIG_TYPE.length ; i++ )
{
MAP_TYPE.put(ITEM_BIG_TYPE[i], i);
}
}
public void setUserId ( long userId )
{
this.userId = userId;
}
protected NewItemPage()
{
super(NEW_ITEM_PAGE);
}
public void createControl ( Composite parent )
{
/** 设置面板布局 */
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
new Label(composite, SWT.NONE).setText("材料类别:");
Combo bigTypeTxt = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
bigTypeTxt.setItems(ITEM_BIG_TYPE);
bigTypeTxt.select(0);
bigTypeTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(composite, SWT.NONE).setText("材料名称:");
typeTxt = new Combo(composite, SWT.BORDER);
typeTxt.setItems(ITEM_DETAIL_TYPE[0]);
typeTxt.select(0);
typeTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
bigTypeTxt.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected ( SelectionEvent e )
{
Combo cb = (Combo) e.widget;
if ( MAP_TYPE.get(cb.getText()) != null )
{
int index = Integer.parseInt(String.valueOf(MAP_TYPE
.get(cb.getText())));
typeTxt.setItems(ITEM_DETAIL_TYPE[index]);
typeTxt.select(0);
}
}
});
new Label(composite, SWT.NONE).setText("单价:");
priceTxt = new Text(composite, SWT.BORDER);
priceTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(composite, SWT.NONE).setText("数量:");
numTxt = new Text(composite, SWT.BORDER);
numTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
int dpStyle = DatePickerStyle.BUTTONS_ON_BOTTOM
| DatePickerStyle.HIDE_WHEN_NOT_IN_FOCUS
| DatePickerStyle.SINGLE_CLICK_SELECTION
| DatePickerStyle.WEEKS_STARTS_ON_MONDAY
| DatePickerStyle.YEAR_BUTTONS | 0;
new Label(composite, SWT.NONE).setText("时间:");
dateTxt = new DatePickerCombo(composite, SWT.BORDER | SWT.READ_ONLY,
dpStyle);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
dateTxt.setDateFormat(sdf);
dateTxt.setEditable(false);
Calendar calendar = Calendar.getInstance();
dateTxt.setDate(calendar.getTime());
dateTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(composite, SWT.NONE).setText("备注:");
remarkTxt = new Text(composite, SWT.BORDER);
remarkTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
this.setControl(composite);
}
public ItemBean getItem ( )
{
if ( this.item == null )
{
this.item = new ItemBean();
}
this.item.setBelongId(this.userId);
return this.item;
}
}