我已经在我的eclipse插件编辑器中实现了拖放支持。现在我想通过从drop listener调用firePropertyChange来通知编辑器。
firePropertyChange(IEditorPart.PROP_DIRTY);
这是正确的方法吗?还是有其他选择。
DropListener代码:
public class DropListener extends ViewerDropAdapter {
private final TableViewer viewer;
private AbstractCSVFile model;
private CSVRow target ;
private final PropertyChangeSupport propertySupport = new PropertyChangeSupport(this);
public DropListener(TableViewer viewer) {
super(viewer);
this.viewer = viewer;
// TODO Auto-generated constructor stub
}
@Override
public void drop(DropTargetEvent event) {
int location = this.determineLocation(event);
target = (CSVRow) determineTarget(event);
String translatedLocation ="";
switch (location){
case 1 :
translatedLocation = "Dropped before the target ";
break;
case 2 :
translatedLocation = "Dropped after the target ";
break;
case 3 :
translatedLocation = "Dropped on the target ";
break;
case 4 :
translatedLocation = "Dropped into nothing ";
break;
}
System.out.println(translatedLocation);
System.out.println("The drop was done on the element: " + target);
super.drop(event);
}
@Override
public boolean performDrop(Object data) {
System.out.println("Drop to be performed with the event data > " + data.toString());
if (target != null) {
model = (AbstractCSVFile)getViewer().getInput();
System.out.println("viewer input >>>>" +getViewer().getInput());
model.addObjectRowAfterElement(target, data.toString());
//notify editor here ....
viewer.refresh();
}
return false;
}
@Override
public boolean validateDrop(Object target, int operation, TransferData transferType) {
// TODO Auto-generated method stub
return true;
}
}
答案 0 :(得分:0)
我已将DropListener添加为Editor的内部类,并在其中调用了该属性:
firePropertyChange(IEditorPart.PROP_DIRTY);