/**
*
*/
package org.springframework.richclient.sample.view;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Date;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import org.springframework.context.MessageSource;
import org.springframework.richclient.application.Application;
import org.springframework.richclient.application.ApplicationServicesLocator;
import org.springframework.richclient.application.support.AbstractView;
import org.springframework.richclient.command.ActionCommand;
import org.springframework.richclient.command.CommandGroup;
import org.springframework.richclient.dialog.TitledPageApplicationDialog;
import org.springframework.richclient.sample.form.UserForm;
import org.springframework.richclient.sample.form.UserQueryForm;
import org.springframework.richclient.sample.model.User;
import org.springframework.richclient.table.BeanTableModel;
import org.springframework.richclient.util.GuiStandardUtils;
import org.springframework.rules.closure.Closure;
/**
* @author kunrey_lew
*
*/
public class UserManageView extends AbstractView {
private UserQueryForm queryForm;
private JTable queryResultTable;
private BeanTableModel queryResultModel;
private ActionCommand addCommand;
private ActionCommand modifyCommand;
private ActionCommand deleteCommand;
/*
* (non-Javadoc)
*
* @see
* org.springframework.richclient.application.support.AbstractView#createControl
* ()
*/
@Override
protected JComponent createControl() {
initControls();
JPanel pane = new JPanel(new BorderLayout());
pane.add(queryForm.getControl(), BorderLayout.NORTH);
pane.add(new JScrollPane(queryResultTable), BorderLayout.CENTER);
pane.add(CommandGroup.createCommandGroup(
new Object[] { addCommand, modifyCommand, deleteCommand })
.createButtonBar(), BorderLayout.SOUTH);
return GuiStandardUtils.attachBorder(pane);
}
private void initControls() {
queryForm = new UserQueryForm();
queryResultModel = new BeanTableModel(User.class,
(MessageSource) ApplicationServicesLocator.services()
.getService(MessageSource.class)) {
@Override
protected String[] createColumnPropertyNames() {
return new String[] { "firstName", "lastName", "age",
"registerDate", "remark" };
}
@Override
protected Class[] createColumnClasses() {
return new Class[] { String.class, String.class, Integer.class,
Date.class, String.class };
}
};
queryResultTable = new JTable(queryResultModel);
addCommand = new ActionCommand("addCommand") {
@Override
protected void doExecuteCommand() {
TitledPageApplicationDialog dialog = getDialog(new User(),
new Closure() {
public Object call(Object argument) {
queryResultModel.addRow(argument);
return null;
}
}, addCommand);
dialog.showDialog();
}
};
modifyCommand = new ActionCommand("modifyCommand") {
@Override
protected void doExecuteCommand() {
if (queryResultTable.getSelectedRow() < 0) {
JOptionPane.showMessageDialog(Application.instance()
.getActiveWindow().getControl(),
"Please select a user.");
return;
}
TitledPageApplicationDialog dialog = getDialog(
(User) queryResultModel.getRow(queryResultTable
.getSelectedRow()), new Closure() {
public Object call(Object argument) {
queryResultModel.fireTableRowsUpdated(
queryResultTable.getSelectedRow(),
queryResultTable.getSelectedRow());
return null;
}
}, modifyCommand);
dialog.showDialog();
}
};
deleteCommand = new ActionCommand("delCommand") {
@Override
protected void doExecuteCommand() {
// TODO Auto-generated method stub
}
};
}
private TitledPageApplicationDialog getDialog(User user,
final Closure closure, ActionCommand callingCommand) {
final UserForm form = new UserForm();
form.setFormObject(user);
TitledPageApplicationDialog dialog = new TitledPageApplicationDialog(
form, Application.instance().getActiveWindow().getControl()) {
@Override
protected boolean onFinish() {
form.commit();
closure.call(form.getFormObject());
return true;
}
};
dialog.setCallingCommand(callingCommand);
dialog.setPreferredSize(new Dimension(380, 180));
return dialog;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
spring RichClient spring RichClient 示例源码
共19个文件
java:11个
xml:4个
properties:2个
需积分: 10 7 下载量 6 浏览量
2011-10-31
15:13:03
上传
评论
收藏 11KB RAR 举报
温馨提示
spring RichClient spring RichClient 示例源码
资源推荐
资源详情
资源评论
收起资源包目录
SpringRichclient.rar (19个子文件)
src
org
springframework
richclient
sample
view
UserManageView.java 4KB
WelcomeView.java 341B
sampleMessages.properties 828B
constraint
DateFormatConstraint.java 764B
model
User.java 884B
UserQueryCondition.java 491B
commands-context-sample.xml 1KB
Main2.java 305B
application.xml 3KB
form
UserForm.java 1KB
UserQueryForm.java 2KB
binding
DateSelectorBinding.java 4KB
application2.xml 3KB
Main.java 303B
SampleRulesSource.java 742B
commands-context-sample2.xml 2KB
sampleImages.properties 98B
.classpath 2KB
.project 392B
共 19 条
- 1
资源评论
snowyqian
- 粉丝: 2
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功