貌似RCP的资料比较少,仅有的也没发现介绍的比较详细的,现在都是东学一点西学一点,此帖简单记录一下要点
1.RCP中怎么实现全屏显示的程序
ApplicationWorkbenchWindowAdvisor 类中增加以下代码
public void postWindowCreate(){
super.postWindowCreate();
getWindowConfigurer().getWindow().getShell().setMaximized(true);
}
public void postWindowCreate(){
super.postWindowCreate();
getWindowConfigurer().getWindow().getShell().setMaximized(true);
}
2.在设置Layout为 BorderLayout时,会自动增加swing2swt.jar,但是在运行该工程时会报错,The activator ****.Activator for bundle aabb is invalid
我的解决办法是 打开plugin.xml文件,选择Runtime标签,在Classpath中将swing2swt.jar删除后再增加进来,并把swing2swt.jar Add to Build Path
3.增加table事件,点击某一行时改变颜色,始终没有效果出现
table.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
int total = table.getItemCount();
TableItem tableItem = new TableItem(table, SWT.NONE,table.getSelectionIndex()+1);
tableItem.setText(new String[]{"1","2","3"});
for(int i=0;i<total;i++){
TableItem[] ii= table.getSelection();
table.getSelectionIndex();
table.getSelectionCount();
TableItem item = table.getItem(i);
if(table.isSelected(i)){
item.setBackground(item.getDisplay().getSystemColor(SWT.COLOR_RED));
item.setForeground(item.getDisplay().getSystemColor(SWT.COLOR_GREEN));
}else{
item.setBackground(null);
item.setForeground(null);
}
}
}
});
public void widgetSelected(SelectionEvent e){
int total = table.getItemCount();
TableItem tableItem = new TableItem(table, SWT.NONE,table.getSelectionIndex()+1);
tableItem.setText(new String[]{"1","2","3"});
for(int i=0;i<total;i++){
TableItem[] ii= table.getSelection();
table.getSelectionIndex();
table.getSelectionCount();
TableItem item = table.getItem(i);
if(table.isSelected(i)){
item.setBackground(item.getDisplay().getSystemColor(SWT.COLOR_RED));
item.setForeground(item.getDisplay().getSystemColor(SWT.COLOR_GREEN));
}else{
item.setBackground(null);
item.setForeground(null);
}
}
}
});