開始學習RCP編程
很早很早就聽說RCP了。也很想來玩玩,但是一直沒有找到好的點子來練手。不過近段時間有個老朋友要求幫他做個小東西。他現在的需求很簡單。我怕他以后有要加什么內容。所以就想用RCP來做。剛好用他來好好學習一下,要不都不好意思在bbs.rcp.cn混了。
找了本書(《Eclipse Rich
Client Platform Designing Coding and Packaging Java Applications》)按照書中的例子看了起來。
了解基本的:
AbstractUIPlugin,
WorkbenchWindowAdvisor,
WorkbenchAdvisor,
ActionBarAdvisor,
IperspectiveFactory和ViewPart幾個類。
收獲最大的就是看到yipsilon在bbs.rcp.cn中關于布局的帖子。
http://www.eclipseworld.org/bbs/read.php?tid=1312&page=e#a
public class MGRPerspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
Plugin plugin = Plugin.getDefault();
LSEmployee employee = plugin.getEmployee();
//只有在用戶登陸后才能畫界面
if (employee != null) {
String editorArea = layout.getEditorArea();
layout.setEditorAreaVisible(false);
// 主要界面
IFolderLayout main = layout.createFolder("main", IPageLayout.TOP, 0.95f, editorArea);
// 屬性界面
IFolderLayout property = layout.createFolder("property", IPageLayout.RIGHT, 0.75f, "main");
// 字典界面
IFolderLayout dictionary = layout.createFolder("dictionary", IPageLayout.BOTTOM, 0.95f, "property");
LSPosition position = employee.getPosition();
boolean isManager = position.getManager().booleanValue();
if (isManager) {
main.addView(EmployeeTableView.class.getName());
property.addView(PositionPropertyView.class.getName());
property.addView(EmployeePropertyView.class.getName());
}
if (position.getBuyer().booleanValue() || isManager) {
main.addView(ProviderTableView.class.getName());
main.addView(JHInvoiceTableView.class.getName());
property.addView(ProviderPropertyView.class.getName());
property.addView(JHInvoicePropertyView.class.getName());
}
if (position.getKeeper().booleanValue() || isManager) {
dictionary.addView(DDRepositoryView.class.getName());
main.addView(DBInvoiceTableView.class.getName());
property.addView(DBInvoicePropertyView.class.getName());
}
if (position.getSeller().booleanValue() || isManager) {
main.addView(MemberTableView.class.getName());
main.addView(YDInvoiceTableView.class.getName());
main.addView(XSInvoiceTableView.class.getName());
property.addView(MemberPropertyView.class.getName());
property.addView(YDInvoicePropertyView.class.getName());
property.addView(XSInvoicePropertyView.class.getName());
}
if (position.getMaintainer().booleanValue() || isManager) {
dictionary.addView(DDAreaView.class.getName());
dictionary.addView(DDBrandView.class.getName());
dictionary.addView(DDColorView.class.getName());
dictionary.addView(DDCompView.class.getName());
dictionary.addView(DDLevelView.class.getName());
dictionary.addView(DDSizeView.class.getName());
dictionary.addView(DDSortView.class.getName());
dictionary.addView(DDDescriptionView.class.getName());
}
}
}
}
根據這段代碼做出如下界面:
很簡單。大家見笑了。呵呵。
我的代碼就不貼了。看yipsilon的代碼就可以搞定布局了。再次感謝yipsilon。
今天就寫到這兒了。爭取周末能把ui全部畫好。