tablecellmondiier.java

来自「eclipse jsp 插件」· Java 代码 · 共 80 行

JAVA
80
字号
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
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?