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

📄 eusercpanel.java

📁 jrc-src0.4.00源代码发布版(Java客户端框架)
💻 JAVA
字号:
package efly.clientframe.feature.enterprise;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

/**
 * @author efly
 * @version 1.0.0,12/14/02
 */
public class EUserCPanel extends Composite implements EUserCompound {
	private int generic;
	private Composite parent;
	private EUserNodeListener eUserNodeHandler;
	private Font newFont;

	/**
	 * Constructor for EUserCPanel.
	 * @param arg0
	 * @param arg1
	 */
	public EUserCPanel(Composite arg0, Image barImage, int genericType) {
		super(arg0, SWT.NONE);
		generic = genericType;
		parent = arg0;
		createContent(barImage);
	}

	private void createContent(final Image barImage) {
		setLayout(new FormLayout());

		final Canvas canvas = new Canvas(this, SWT.NONE);
		Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);

		canvas.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent event) {
				if (barImage != null) {
					Font font = new Font(getDisplay(), "宋体", 10, SWT.BOLD);
					event.gc.setFont(font);
					event.gc.drawImage(barImage, 0, 0);
					event.gc.drawString(getTitle(), 0, 5, true);
					font.dispose();

				}
			}
		});

		FormData data =
			new FormData(
				barImage.getBounds().width,
				barImage.getBounds().height);
		data.top = new FormAttachment(0, 0);
		data.left = new FormAttachment(0, 0);
		data.right = new FormAttachment(100, 0);
		canvas.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(canvas, 0, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		data.right = new FormAttachment(100, 0);
		separator.setLayoutData(data);
		if (generic == INDIVIDUAL) {
			createSecondaryPanel(separator);
		} else
			createPrimaryPanel(separator);
	}

	private String getTitle() {
		String title = null;
		switch (generic) {
			case ORGANIZATION :
				{
					title = "机构信息";
					break;
				}
			case DEPARTMENT :
				{
					title = "部门信息";
					break;
				}
			case USER_GROUP :
				{
					title = "用户组信息";
					break;
				}
			case INDIVIDUAL :
				{
					title = "用户信息";
					break;
				}
		}
		return title;
	}

	public void layout() {
		FormData data = new FormData();
		data.top = new FormAttachment(0, 0);
		data.left = new FormAttachment(0, 0);
		data.right = new FormAttachment(100, 0);
		data.bottom = new FormAttachment(100, 0);
		setLayoutData(data);
		parent.layout();
	}

	public void hide() {
		setVisible(false);
	}

	public void show() {
		setVisible(true);
	}

	public void remove() {
		dispose();
	}

	public int getGenericType() {
		return generic;
	}

	public void createPrimaryPanel(Control separator) {
		Label name = new Label(this, SWT.NONE);
		name.setText("名称:");

		final Text name_t = new Text(this, SWT.SINGLE | SWT.BORDER);
		name_t.setText("名称");
		name_t.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent event) {
				eUserNodeHandler.fireNodeNameChanged(name_t.getText());
			}
		});

		Label appendix = new Label(this, SWT.NONE);
		appendix.setText("备注:");

		Text app_t = new Text(this, SWT.MULTI | SWT.BORDER);

		FormData data = new FormData();
		data.top = new FormAttachment(separator, 0, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		name.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(separator, 0, SWT.BOTTOM);
		data.left = new FormAttachment(name, 0, SWT.RIGHT);
		data.right = new FormAttachment(100, 0);
		name_t.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		appendix.setLayoutData(data);

		data = new FormData(50, 50);
		data.top = new FormAttachment(name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(appendix, 0, SWT.RIGHT);
		data.right = new FormAttachment(100, 0);
		app_t.setLayoutData(data);

	}

	public void createSecondaryPanel(Control separator) {
		Label name = new Label(this, SWT.NONE);
		name.setText("姓名:");
		Label authority = new Label(this, SWT.NONE);
		authority.setText("职务:");
		final Text name_t = new Text(this, SWT.SINGLE | SWT.BORDER);
		name_t.setText("姓名");
		name_t.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent event) {
				eUserNodeHandler.fireNodeNameChanged(name_t.getText());
			}
		});
		Text authority_t = new Text(this, SWT.SINGLE | SWT.BORDER);

		Label appendix = new Label(this, SWT.NONE);
		appendix.setText("备注:");
		Text appendix_t = new Text(this, SWT.MULTI | SWT.BORDER);

		Group security = new Group(this, SWT.NONE);
		security.setText("安全信息");
		FormLayout layout = new FormLayout();
		layout.marginHeight = 3;
		layout.marginWidth = 3;
		security.setLayout(layout);

		Label user_name = new Label(security, SWT.NONE);
		user_name.setText("用户名:");
		Text user_name_t = new Text(security, SWT.SINGLE | SWT.BORDER);
		Button validate = new Button(security, SWT.CHECK);
		validate.setText("有效");

		Label password = new Label(security, SWT.NONE);
		password.setText("初始密码:");
		Label confirm = new Label(security, SWT.NONE);
		confirm.setText("确认密码:");
		Text password_t = new Text(security, SWT.SINGLE | SWT.BORDER);
		password_t.setEchoChar('*');
		Text confirm_t = new Text(security, SWT.SINGLE | SWT.BORDER);
		confirm_t.setEchoChar('*');
		Button reset = new Button(security, SWT.PUSH);
		reset.setText("重置");

		FormData data = new FormData();
		data.top = new FormAttachment(separator, 0, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		name.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(separator, 0, SWT.BOTTOM);
		data.left = new FormAttachment(name, 0, SWT.RIGHT);
		data.right = new FormAttachment(40, 0);
		name_t.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(separator, 0, SWT.BOTTOM);
		data.left = new FormAttachment(name_t, 0, SWT.RIGHT);
		authority.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(separator, 0, SWT.BOTTOM);
		data.left = new FormAttachment(authority, 0, SWT.RIGHT);
		data.right = new FormAttachment(100, 0);
		authority_t.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		appendix.setLayoutData(data);

		data = new FormData(50, 50);
		data.top = new FormAttachment(name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(appendix, 0, SWT.RIGHT);
		data.right = new FormAttachment(100, 0);
		appendix_t.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(appendix_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		data.right = new FormAttachment(100, 0);
		security.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(0, 0);
		data.left = new FormAttachment(0, 0);
		user_name.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(0, 0);
		data.left = new FormAttachment(user_name, 0, SWT.RIGHT);
		user_name_t.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(0, 0);
		data.left = new FormAttachment(user_name_t, 0, SWT.RIGHT);
		data.right = new FormAttachment(100, 0);
		validate.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(user_name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(0, 0);
		password.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(user_name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(password, 0, SWT.RIGHT);
		password_t.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(user_name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(password_t, 0, SWT.RIGHT);
		confirm.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(user_name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(confirm, 0, SWT.RIGHT);
		confirm_t.setLayoutData(data);

		data = new FormData();
		data.top = new FormAttachment(user_name_t, 0, SWT.BOTTOM);
		data.left = new FormAttachment(confirm_t, 0, SWT.RIGHT);
		data.right = new FormAttachment(100, 0);
		reset.setLayoutData(data);

	}

	public void addEUserNodeListener(EUserNodeListener nodeListener) {
		eUserNodeHandler = nodeListener;
	}
}

⌨️ 快捷键说明

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