⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recordproperties.java

📁 一个简单的CellEditor的例子 希望给学习java的朋友一点帮助
💻 JAVA
字号:
package com.intotherain.examples.SimpleCellEditor.properties;


import java.util.ArrayList;
import java.util.List;

import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

import com.intotherain.examples.SimpleCellEditor.model.IETypeEnum;
import com.intotherain.examples.SimpleCellEditor.model.Record;
import com.intotherain.examples.SimpleCellEditor.util.DigitalValidator;
import com.intotherain.examples.SimpleCellEditor.view.MyTableView;

/**
 * 
 * @author intotherain
 *
 */
public class RecordProperties implements IPropertySource {
    private static Record record;
    
    private static final String P_ID_ID = "record.id";
    
    private static final String P_ID_NAME = "record.name";
    
    private static final String P_ID_TIME = "record.time";
    
    private static final String P_ID_IETYPE = "rcord.ietype";
    
    private static final String P_ID = "ID";
    
    private static final String P_NAME = "name";
    
    private static final String P_TIME = "OnlineTime";
    
    private static final String P_IETYPE = "IE Type";
    
    private List<IPropertyDescriptor> descriptors;
    
    @SuppressWarnings("static-access")
    public RecordProperties(Record record) {
        this.record = record;        
        initProperties();        
    }
    
    private void initProperties() {
        PropertyDescriptor propertyDesriptor;
        descriptors = new ArrayList<IPropertyDescriptor>();
        
        propertyDesriptor = new TextPropertyDescriptor(P_ID_ID, P_ID);
        propertyDesriptor.setCategory("Base Info");
        propertyDesriptor.setValidator(new DigitalValidator());
        descriptors.add(propertyDesriptor);
        
        propertyDesriptor = new PropertyDescriptor(P_ID_NAME, P_NAME);
        propertyDesriptor.setCategory("Base Info");
        descriptors.add(propertyDesriptor);
        
        propertyDesriptor = new PropertyDescriptor(P_ID_TIME, P_TIME);
        propertyDesriptor.setCategory("Base Info");
        descriptors.add(propertyDesriptor);
        
        propertyDesriptor = new IETypePropertyDescriptor(P_ID_IETYPE, P_IETYPE, record);
        propertyDesriptor.setCategory("Base Info");
        descriptors.add(propertyDesriptor);  
    }
    
    
    public Object getEditableValue() {
        return null;
    }

    public IPropertyDescriptor[] getPropertyDescriptors() {
        return descriptors.toArray(new IPropertyDescriptor[descriptors.size()]);
    }

    public Object getPropertyValue(Object id) {
        if(id.equals(P_ID_ID)) {
            return record.getId();
        }
        
        if(id.equals(P_ID_NAME)) {
            return record.getUsrName();
        }
        
        if(id.equals(P_ID_TIME)) {
            return record.getTotalTime();
        }
        
        if(id.equals(P_ID_IETYPE)) {
            return record.getIeType();
        }
        return null;
    }

    public boolean isPropertySet(Object id) {
        return false;
    }

    public void resetPropertyValue(Object id) {
        
    }

    public void setPropertyValue(Object id, Object value) {
        if(id.equals(P_ID_ID)) {
            record.setId(value.toString());
        }
        
        if(id.equals(P_ID_IETYPE)) {
            record.setIeType((IETypeEnum)value);
        }
        
        MyTableView viewer = (MyTableView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MyTableView.ID);
        viewer.refresh();
    }    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -