?? tablecellmondiier.java
字號:
package test.actions;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.widgets.TableItem;
public class TableCellMondiier implements ICellModifier {
private TableViewer tableViewer;
private int content;
private String property;
public TableCellMondiier(TableViewer tableViewer,int content,String property) {
this.tableViewer=tableViewer;
this.content=content;
this.property=property;
}
public TableCellMondiier(){
}
public boolean canModify(Object element, String property) {
return true;
public Object getValue(Object element, String property) {
PropertyEntity pe=(PropertyEntity)element;
if(property.equals("value")&&content>300){
return getNameIndex(pe.getSex());
}else{
return pe.getSex();
}
}
private int getNameIndex(String name) {
CreateTable mtn=new CreateTable();
for(int i=0;i<2;i++){
if(mtn.COLUMN_NAMES[i].equals(name)){
return i;
}
}
return -1;
}
public void modify(Object element, String property, Object value) {
TableItem item=(TableItem)element;
PropertyEntity pe=(PropertyEntity)item.getData();
CreateTable mtn1=new CreateTable();
String oldValue=pe.getSex();
int count=0;
if(property.equals("value")){
for(int i=0;i<mtn1.COLUMN_NAMES.length;i++){
if(value instanceof Integer){
if(mtn1.COLUMN_NAMES[i].equals(oldValue)){
count=i;
if(content>300&&count!=(Integer)value){
Integer comboIndex=(Integer)value;
CreateTable mtn=new CreateTable();
String valueName=mtn.COLUMN_NAMES[comboIndex];
pe.setSex(valueName);
ListenerShowSelection lss=new ShowSelection();
lss.changeSelection(this.property, valueName);
tableViewer.refresh();
return;
}
}
}else{
String valueName=(String)value;
pe.setSex(valueName);
ListenerShowSelection lss=new ShowSelection();
lss.changeSelection(this.property, valueName);
tableViewer.refresh();
return;
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -