/**
 * @author tyl
 * @Action  ini
 * 2011-4-7
 */
package cn.com.origin.autocodemanager.views.codestyleview;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

import cn.com.origin.autocodemanager.common.CreateCompositeUtil;

public class CreateCodeStyleView {
	public ViewPart viewPart;
	public Text seqBeginText;
	public Text seqMaxText;
	public Text seqLengthtext;
	public Text seqStepText;
	public Text seqExcludeStrText;
	public Text codeStyleText;
	public Text patternMinLengthText;
	public Text coverText;

	public CreateCodeStyleView(Composite composite, ViewPart viewPart) {
		this.viewPart = viewPart;
		createNewComposite(composite);
	}

	public void createNewComposite(Composite parent) {
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 1;
		parent.setLayout(gridLayout);
		parent.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		Group nodeGroup = CreateCompositeUtil.createCompositeGroup(parent, "流水码");
		nodeGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		createSeqPropertyComposite(nodeGroup);

		Group coverGroup = CreateCompositeUtil.createCompositeGroup(parent, "补位码");
		coverGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		createCoverComposite(coverGroup);

		Group styleGroup = CreateCompositeUtil.createCompositeGroup(parent, "编码样式");
		styleGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		createCodeStyleComposite(styleGroup);

		Group buttonGroup = CreateCompositeUtil.createCompositeGroup(parent, "dsdsds");
		buttonGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		createButtonComposite(buttonGroup);
	}

	
	private void createCodeStyleComposite(Composite composite) {
		Composite styleComposite = new Composite(composite, SWT.NONE);
		GridLayout gridLayout1 = new GridLayout();
		gridLayout1.numColumns = 2;
		styleComposite.setLayoutData(CreateCompositeUtil.getNewGridData());
		styleComposite.setLayout(gridLayout1);
		styleComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		CreateCompositeUtil.createNewWhiteLabel(styleComposite, "编码样式");
		codeStyleText = CreateCompositeUtil.createNewText(styleComposite, "@");
	}

	private void createButtonComposite(Composite composite) {
		Composite buttonComposite = new Composite(composite, SWT.NONE);
		buttonComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		Button button1 = CreateCompositeUtil.createNewButton(buttonComposite, "保存设置");
		button1.setVisible(true);
		Button button2 = CreateCompositeUtil.createButton(buttonComposite, "保存设置", 30, 100);
		button2.setVisible(true);
	}

	private void createCoverComposite(Composite composite) {
		Composite coverComposite = new Composite(composite, SWT.NONE);
		GridLayout gridLayout1 = new GridLayout();
		gridLayout1.numColumns = 2;
		coverComposite.setLayoutData(CreateCompositeUtil.getNewGridData());
		coverComposite.setLayout(gridLayout1);
		coverComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

		CreateCompositeUtil.createNewWhiteLabel(coverComposite, "特征码最小长度");
		patternMinLengthText = CreateCompositeUtil.createNewText(coverComposite, "");
		CreateCompositeUtil.createNewWhiteLabel(coverComposite, "补位码");
		coverText = CreateCompositeUtil.createNewText(coverComposite, "");
	}

	/**
	 * This method initializes createSeqPropertyComposite
	 * 
	 */
	public void createSeqPropertyComposite(Composite parent) {
		Composite seqComposite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout1 = new GridLayout();
		gridLayout1.numColumns = 2;
		seqComposite.setLayoutData(CreateCompositeUtil.getNewGridData());
		seqComposite.setLayout(gridLayout1);
		seqComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

		CreateCompositeUtil.createNewWhiteLabel(seqComposite, "初始值");
		seqBeginText = CreateCompositeUtil.createNewText(seqComposite, "0");

		CreateCompositeUtil.createNewWhiteLabel(seqComposite, "最大值");
		seqMaxText = CreateCompositeUtil.createNewText(seqComposite, "0");

		CreateCompositeUtil.createNewWhiteLabel(seqComposite, "长度");
		seqLengthtext = CreateCompositeUtil.createNewText(seqComposite, "0");

		CreateCompositeUtil.createNewWhiteLabel(seqComposite, "步长");
		seqStepText = CreateCompositeUtil.createNewText(seqComposite, "0");

		CreateCompositeUtil.createNewWhiteLabel(seqComposite, "不含数字");
		seqExcludeStrText = CreateCompositeUtil.createNewText(seqComposite, "");
	}
}
