界面已经基本完成,其中的附件功能直接用了过去已经写好的文件管理类的控件
接下来的工作是完成7个超链接的功能:
1. 点击产品名称显示产品编辑器
代码
public class OpenProductLink extends HyperlinkAdapter {
@Override
public void linkActivated(HyperlinkEvent e) {
LazyDTO ldto = (LazyDTO)hlOpenProduct.getData("LazyDTO");
Assert.isNotNull(ldto, MSG_PRODUCT_NOT_EXSIT);
UIOperations.openDTOWithPermission(ldto.getDTObject());
}
}
@Override
public void linkActivated(HyperlinkEvent e) {
LazyDTO ldto = (LazyDTO)hlOpenProduct.getData("LazyDTO");
Assert.isNotNull(ldto, MSG_PRODUCT_NOT_EXSIT);
UIOperations.openDTOWithPermission(ldto.getDTObject());
}
}
2.点击团队名称显示团队编辑器
3.点击注册产品显示注册的编辑器
代码
public class CreateProductLink extends HyperlinkAdapter {
@Override
public void linkActivated(HyperlinkEvent e) {
DTObject dto = systemDmc.createDTO();
EditorInput input = new EditorInput(dto){
@Override
protected void saveAfter(DataObjectEdtior editor, DTObject dto)
throws Exception {
Object name = dto.getObjectDescription();
hlOpenProduct.setText(name==null?"":name.toString());
LazyDTO ldto = new LazyDTO();
ldto.setDTO(dto);
hlOpenProduct.setData("LazyDTO", ldto);
super.saveAfter(editor, dto);
}
};
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.openEditor(input, SystemPartID.EDITOR_OBJECTEDITOR);
} catch (PartInitException er) {
er.printStackTrace();
}
super.linkActivated(e);
}
}
@Override
public void linkActivated(HyperlinkEvent e) {
DTObject dto = systemDmc.createDTO();
EditorInput input = new EditorInput(dto){
@Override
protected void saveAfter(DataObjectEdtior editor, DTObject dto)
throws Exception {
Object name = dto.getObjectDescription();
hlOpenProduct.setText(name==null?"":name.toString());
LazyDTO ldto = new LazyDTO();
ldto.setDTO(dto);
hlOpenProduct.setData("LazyDTO", ldto);
super.saveAfter(editor, dto);
}
};
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.openEditor(input, SystemPartID.EDITOR_OBJECTEDITOR);
} catch (PartInitException er) {
er.printStackTrace();
}
super.linkActivated(e);
}
}
4.点击注册团队显示团队注册的编辑器
5.点击选择产品显示产品选择对话框
代码
public class SelectProductLink extends HyperlinkAdapter {
@Override
public void linkActivated(HyperlinkEvent e) {
LazyDTO selection = FilteredSelectionDialog
.openClassDataSelector(DMModel.getDMCbyName("System"));
String name = selection.getDTObject().getDescription();
hlOpenProduct.setText(name == null ? "" : name.toString());
hlOpenProduct.setData("LazyDTO", selection);
super.linkActivated(e);
}
}
@Override
public void linkActivated(HyperlinkEvent e) {
LazyDTO selection = FilteredSelectionDialog
.openClassDataSelector(DMModel.getDMCbyName("System"));
String name = selection.getDTObject().getDescription();
hlOpenProduct.setText(name == null ? "" : name.toString());
hlOpenProduct.setData("LazyDTO", selection);
super.linkActivated(e);
}
}
6.点击选择团队显示团队选择对话框
7 点击组织结构,显示组织结构的CTreeView视图
代码
public class OpenTeamStructureLink extends HyperlinkAdapter {
@Override
public void linkActivated(HyperlinkEvent e) {
LazyDTO ldto = (LazyDTO)hlOpenTeam.getData("LazyDTO");
Assert.isNotNull(ldto, MSG_TEAM_NOT_EXSIT);
ListenerView.showView("com.sg.intellifmea.view.TeamView", ldto,true);
}
}
@Override
public void linkActivated(HyperlinkEvent e) {
LazyDTO ldto = (LazyDTO)hlOpenTeam.getData("LazyDTO");
Assert.isNotNull(ldto, MSG_TEAM_NOT_EXSIT);
ListenerView.showView("com.sg.intellifmea.view.TeamView", ldto,true);
}
}
完成了界面控制后,接下来是处理编辑器Dirty的状态。