首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

gef直接编者的思路

2012-11-06 
gef直接编辑的思路拦截编辑的事件,在同样的位置,同样的大小,用Text来覆盖。?首先需要在原有的基础上多加两

gef直接编辑的思路

拦截编辑的事件,在同样的位置,同样的大小,用Text来覆盖。

?

首先需要在原有的基础上多加两个类

EDirectEditManager ? 直接编辑管理类?

ECellEditorLocator ? 单元格的编辑的位置?

?

public class ECellEditorLocator ?implements CellEditorLocator{

?

private IFigure figure;

public ECellEditorLocator(IFigure figure)

{

this.figure=figure;

}

@Override

public void relocate(CellEditor celleditor) {

更具figure的位置大小,显示 widget Text。其实就是用Text 来覆盖 Figure。

? ? ? ? ? ? ? ? 这里你也可以显示table,tree都可以。更具你的需要

Text text= (Text) celleditor.getControl();

Rectangle rct= ?figure.getBounds().getCopy();

figure.translateToAbsolute(rct);

text.setBounds(rct.x, rct.y, rct.width, rct.height);

}

?

}

?

?

?

在你需要编辑的part中填写以下代码。

@Override

public void performRequest(Request req) {

if(req.getType().equals(RequestConstants.REQ_DIRECT_EDIT))

{

performDirectEdit();

return;

}

super.performRequest(req);

}

?

private void performDirectEdit()

{

// 关键是这里,。。。,用 ECellEditorLocator ? ?创建EDirectEditManager ? 。并显示 EDirectEditManager .show();

if(directManager==null)

{

directManager=new EDirectEditManager(this, TextCellEditor.class, new ECellEditorLocator(getFigure()));

}

directManager.show();

}

?

?

热点排行