how to listen to the changes of the elements's name on the editor? [message #87275] |
Fri, 22 December 2006 04:57 |
Eclipse User |
|
|
|
Originally posted by: dzhpingbo.sohu.com
I know that by default every GraphicalEditPart will add a listener to its
semantic
element and notation view in the methods :addNotationalListeners and
addSemanticListeners.
These methods will be called on the edit part activation, I override these
methods in DiagramEdit
part to add my listeners:
@Override
protected void addNotationalListeners() {
// TODO Auto-generated method stub
super.addNotationalListeners();
dzhNotificationListener myNotificationListener = new
dzhNotificationListener();
if (hasNotationView()){
addListenerFilter("View",
myNotificationListener,(View)getModel()); //$NON-NLS-1$
addListenerFilter("SemanticElement",
myNotificationListener,resolveSemanticElement());
}
}
but it can only listen the changes when adding and removing elements on the
editor.
I want to listen to the changes of the elements's name on the editor.So I
had to change the method in ???NameEditPart
/**
* @generated
*/
protected void addSemanticListeners() {
if (getParser() instanceof ISemanticParser) {
EObject element = resolveSemanticElement();
parserElements = ((ISemanticParser) getParser())
.getSemanticElementsBeingParsed(element);
for (int i = 0; i < parserElements.size(); i++) {
addListenerFilter(
"SemanticModel" + i, this, (EObject) parserElements.get(i));
//$NON-NLS-1$
addListenerFilter(
"SemanticModel" + i, myNotificationListener, (EObject)
parserElements.get(i)); //add by myself
}
} else {
super.addSemanticListeners();
}
}
It works,but it had to change the code generated by gmf...I want to know if
there are better ways to listen to the changes of ???NameEditPart.
Once upon a time, I can listen to the changes of the elements's name on the
editor without altering the gereated code by gmf, I add
"myAdapterFctoryContentProvier" in a treeviewer:
myAdapterFctoryContentProvier = new AdapterFactoryContentProvider(
NewpmbeDiagramEditorPlugin.getInstance()
.getItemProvidersAdapterFactory()) {
@Override
public void notifyChanged(Notification notification) {
// TODO Auto-generated method stub
super.notifyChanged(notification);
System.out.println("write");
}
};
but now this way can not work, I want to know how can I listen to the
changes of the elements's name on the editor?
|
|
|
Powered by
FUDForum. Page generated in 0.02860 seconds