package cn.edu.jfcs.ui;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import cn.edu.jfcs.model.Course;
import cn.edu.jfcs.model.CourseTreeChildren;
import cn.edu.jfcs.model.CourseTreeParent;
import cn.edu.jfcs.model.YearTeachUnit;
import cn.edu.jfcs.sys.HibernateSessionFactory;
import cn.edu.jfcs.sys.IAppConstants;
import cn.edu.jfcs.sys.IImageKey;
import cn.edu.jfcs.sys.SetControlEnabled;
import cn.edu.jfcs.sys.SetTableColColorListener;
import cn.edu.jfcs.sys.YearManager;
public class TeachUnitClass extends ViewPart implements ISelectionListener {
private TreeViewer treeViewer;
private Action saveAction, calcAction, closeTreeAction, openTreeAction;
// 表格的列名,同时也作为编辑器的属性名
// 课程名称
public static final String COURSENAME = "coursename";
// 学期
public static final String TERM = "term";
// 学时数
public static final String N2J = "n2j";
// 学生数
public static final String NJ = "nj";
// 班级名
public static final String CLASSNAME = "classname";
// 学生层次系数
public static final String R1J = "r1j";
// 课程/专业系数
public static final String R2J = "r2j";
// 课程质量系数
public static final String R3J = "r3j";
// 作为treeViewer的ColumnProperties属性,列的别名
public static final String[] PROPERTIES = { COURSENAME, TERM, N2J, NJ,
CLASSNAME, R1J, R2J, R3J };
public TeachUnitClass() {
super();
}
public void createPartControl(Composite parent) {
createTreeViewer(parent);
createActions();
createToolbarButtons();
setHelpContextID();
// 监听TeachUnitView视图的SelectionProvider,以便其发生改变时激活selectionChanged
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.addSelectionListener(this);
}
// 创建treeViewer内容
private void createTreeViewer(Composite parent) {
treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.V_SCROLL
| SWT.FULL_SELECTION);
treeViewer.setUseHashlookup(true);
treeViewer.setContentProvider(new TeachUnitClassContentProvider());
treeViewer.setLabelProvider(new TeachUnitClassLabelProvider());
// 创建表头列
final Tree tree = treeViewer.getTree();
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
final TreeColumn tbcl1 = new TreeColumn(tree, SWT.LEFT);
tbcl1.setText("课程名称");
tbcl1.setWidth(175);
final TreeColumn tbcl2 = new TreeColumn(tree, SWT.CENTER);
tbcl2.setText("学期");
tbcl2.setWidth(40);
final TreeColumn tbcl3 = new TreeColumn(tree, SWT.CENTER);
tbcl3.setText("学时");
tbcl3.setWidth(40);
final TreeColumn tbcl4 = new TreeColumn(tree, SWT.CENTER);
tbcl4.setText("学生数");
tbcl4.setWidth(52);
final TreeColumn tbcl5 = new TreeColumn(tree, SWT.CENTER);
tbcl5.setText("班级");
tbcl5.setWidth(112);
final TreeColumn tbcl6 = new TreeColumn(tree, SWT.CENTER);
tbcl6.setText("层次");
tbcl6.setWidth(40);
final TreeColumn tbcl7 = new TreeColumn(tree, SWT.CENTER);
tbcl7.setText("课程/专业");
tbcl7.setWidth(70);
final TreeColumn tbcl8 = new TreeColumn(tree, SWT.CENTER);
tbcl8.setText("质量");
tbcl8.setWidth(40);
// 创建编辑器,前面5列为null,表示该列不允许修改
final CellEditor[] editors = new CellEditor[8];
editors[5] = new TextCellEditor(tree);
editors[6] = new TextCellEditor(tree);
editors[7] = new TextCellEditor(tree);
treeViewer.setColumnProperties(PROPERTIES);
treeViewer.setCellModifier(new TeachUnitClassCellModifier(treeViewer));
treeViewer.setCellEditors(editors);
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
treeViewer.expandToLevel(2);
tree.setFocus();
// 记录改变时当前行突出显示
tree.addListener(SWT.EraseItem, new SetTableColColorListener(tree));
}
// 创建Action对象
private void createActions() {
saveAction = new Action("保存数据", AbstractUIPlugin
.imageDescriptorFromPlugin(IAppConstants.APPLICATION_ID,
IImageKey.SAVE_DATA)) {
public void run() {
saveData();
}
};
calcAction = new Action("经费测算", AbstractUIPlugin
.imageDescriptorFromPlugin(IAppConstants.APPLICATION_ID,
IImageKey.CALC)) {
public void run() {
// 7.7节实现
}
};
closeTreeAction = new Action("收缩数据", AbstractUIPlugin
.imageDescriptorFromPlugin(IAppConstants.APPLICATION_ID,
IImageKey.CLOSE_TREE)) {
public void run() {
treeViewer.collapseAll();
}
};
openTreeAction = new Action("展开数据", AbstractUIPlugin
.imageDescriptorFromPlugin(IAppConstants.APPLICATION_ID,
IImageKey.OPEN_TREE)) {
public void run() {
treeViewer.expandAll();
}
};
}
// 创建导航按钮
private void createToolbarButtons() {
IToolBarManager toolBar = getViewSite().getActionBars()
.getToolBarManager();
toolBar.add(saveAction);
toolBar.add(calcAction);
toolBar.add(closeTreeAction);
toolBar.add(openTreeAction);
}
// 监听教学单位视图教学单位选择状态的变化
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (!selection.isEmpty()) {
saveAction.setEnabled(new SetControlEnabled().isEnabled(YearManager
.getInstance().getCurYear()));
IViewPart vp = getViewSite().getPage().findView(
IAppConstants.TEACH_UNIT_NAME_VIEW_ID);
// 获得数据
Table table = ((TeachUnitName) vp).getTableViewer().getTable();
YearTeachUnit ytu = (YearTeachUnit) table.getItem(
table.getSelectionIndex()).getData();
treeViewer.setInput(getCourse(ytu.getTeachunit().getUnitid(),
YearManager.getInstance().getCurYear()));
// 设置标题栏教学单位名称
setPartName(getConfigurationElement().getAttribute("name")
.toString()
+ "---" + ytu.getTeachunit().getUnitname());
treeViewer.expandToLevel(2);
}
}
// 获得数据
private List getCourse(String unitid, int year) {
List<CourseTreeParent> list = new ArrayList<CourseTreeParent>();
Session session = HibernateSessionFactory
.getSession("hibernate_derby.cfg.xml");
// 获得课程明细数据
Query query = session
.getNamedQuery("cn.edu.jfcs.ui.TeachUnitClass.getCourse");
query.setInteger(0, year);
query.setString(1, unitid);
int oldType = -1, curType = 0;
CourseTreeParent ctp = null;
for (Iterator iter = query.iterate(); iter.hasNext();) {
Course course = (Course) iter.next();
curType = Integer.parseInt(course.getCoursetype());
String nodeName = curType == 1 ? "专业课明细" : "公共课明细";
if
没有合适的资源?快使用搜索试试~ 我知道了~
Eclipse RCP应用系统开发方法与实战
共1221个文件
dat:336个
class:272个
java:232个
需积分: 0 21 下载量 199 浏览量
2008-10-06
14:31:05
上传
评论
收藏 4.77MB RAR 举报
温馨提示
第7章代码 Eclipse RCP应用系统开发方法与实战 我也是下别人的。。。
资源推荐
资源详情
资源评论
收起资源包目录
Eclipse RCP应用系统开发方法与实战 (1221个子文件)
splash.bmp 394KB
splash.bmp 394KB
splash.bmp 394KB
splash.bmp 394KB
splash.bmp 394KB
TeachUnitClass.class 11KB
PieDiagram.class 7KB
PieDiagram.class 7KB
TeachUnitName.class 6KB
TeachUnitName.class 6KB
TeachUnitName.class 6KB
TeachUnitName.class 6KB
ApplicationActionBarAdvisor.class 5KB
ApplicationActionBarAdvisor.class 5KB
ApplicationActionBarAdvisor.class 5KB
ApplicationActionBarAdvisor.class 5KB
ApplicationActionBarAdvisor.class 5KB
YearTeachUnit.class 4KB
YearTeachUnit.class 4KB
YearTeachUnit.class 4KB
YearTeachUnit.class 4KB
YearTeachUnit.class 4KB
PubData.class 4KB
PubData.class 4KB
PubData.class 4KB
PubData.class 4KB
PubData.class 4KB
ApplicationWorkbenchWindowAdvisor.class 4KB
ApplicationWorkbenchWindowAdvisor.class 4KB
ApplicationWorkbenchWindowAdvisor.class 4KB
ApplicationWorkbenchWindowAdvisor.class 4KB
ApplicationWorkbenchWindowAdvisor.class 4KB
Login.class 4KB
Login.class 4KB
LoginDialog.class 4KB
LoginDialog.class 4KB
LoginDialog.class 4KB
LoginDialog.class 4KB
LoginDialog.class 4KB
Login.class 4KB
Login.class 4KB
Login.class 4KB
HookSysTray.class 4KB
HookSysTray.class 4KB
HookSysTray.class 4KB
HookSysTray.class 4KB
HookSysTray.class 4KB
Course.class 3KB
Course.class 3KB
Course.class 3KB
Course.class 3KB
Course.class 3KB
PieDiagram$DrawArc.class 3KB
PieDiagram$DrawArc.class 3KB
TeachUnitClassCellModifier.class 3KB
YearCombo.class 3KB
YearCombo.class 3KB
YearCombo.class 3KB
YearCombo.class 3KB
TeachUnitClassLabelProvider.class 3KB
TeachUnitClass$5.class 3KB
GetCalcResult.class 3KB
GetCalcResult.class 3KB
YearManager.class 2KB
YearManager.class 2KB
YearManager.class 2KB
CuryearPropertyChange.class 2KB
CuryearPropertyChange.class 2KB
CuryearPropertyChange.class 2KB
CuryearPropertyChange.class 2KB
YearManager.class 2KB
Calcresult.class 2KB
Calcresult.class 2KB
Calcresult.class 2KB
Calcresult.class 2KB
Calcresult.class 2KB
TeachUnitNameLabelProvider.class 2KB
TeachUnitNameLabelProvider.class 2KB
TeachUnitNameLabelProvider.class 2KB
TeachUnitNameLabelProvider.class 2KB
SetTableColColorListener.class 2KB
IImageKey.class 2KB
IImageKey.class 2KB
IImageKey.class 2KB
IImageKey.class 2KB
IImageKey.class 2KB
CacheImage.class 2KB
CacheImage.class 2KB
CacheImage.class 2KB
CacheImage.class 2KB
CacheImage.class 2KB
HibernateSessionFactory.class 2KB
HibernateSessionFactory.class 2KB
HibernateSessionFactory.class 2KB
HibernateSessionFactory.class 2KB
HibernateSessionFactory.class 2KB
StatusBarContribution.class 2KB
StatusBarContribution.class 2KB
StatusBarContribution.class 2KB
StatusBarContribution.class 2KB
共 1221 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
手艺人工作中
- 粉丝: 2
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功