Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » PropertyChangeListener in new View(How do I get notified of changed properties in the editor or properties view.)
PropertyChangeListener in new View [message #1218639] Fri, 29 November 2013 06:11 Go to next message
svdwoude V is currently offline svdwoude V
Messages: 3
Registered: August 2013
Junior Member
Hi!

I'm writing a new view which should be notified of selection changes or property changes (for instance a name change) in the editor or properties view.

The selection changes are already handled in my view:

ISelectionListener listener = new ISelectionListener() {
      	
		@SuppressWarnings("restriction")
		public void selectionChanged(IWorkbenchPart part, ISelection sel) {
      		if (sel instanceof IStructuredSelection) {
			IStructuredSelection ss = (IStructuredSelection) sel;
			Object o = ss.getFirstElement();
				
	        	if (o instanceof ContainerShapeEditPart) {
	        		ContainerShapeEditPart editPart = (ContainerShapeEditPart) o;
	        		IFeatureProvider fp = editPart.getFeatureProvider();
	        		selection = fp.getBusinessObjectForPictogramElement(editPart.getPictogramElement());
	        		castElement();
	        		createSuggestions();
	        	}
	        	else {
	        		generateErrorInstruction(part, sel);
	        	}
...

public void createPartControl(Composite parent) {

     ...
     getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener);
     ...
}


Is there a way to get notified of property changes like that?
For instance: the moment you start typing a new name for an element in the diagram, I'd like to be notified.
Should I extract the name label of the selection and add a listener at that point? How should i go about this?

Thanks in advance.

Re: PropertyChangeListener in new View [message #1219201 is a reply to message #1218639] Mon, 02 December 2013 10:33 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1574
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi,

in order to achieve that you will have to register EMF Adapters to the
EObjects you want to observe. They will get notified as soon as the object
or its attributes change. There are numerous tutorials in the Web, e.g.
http://www.vogella.com/articles/EclipseEMFNotification/article.html

Michael
Re: PropertyChangeListener in new View [message #1219467 is a reply to message #1219201] Tue, 03 December 2013 21:15 Go to previous message
svdwoude V is currently offline svdwoude V
Messages: 3
Registered: August 2013
Junior Member
Thank you Michael!

You pointed me in the right direction.

If other people come across this problem, register a listener to your EObject like this:

((EObject)selection).eAdapters().add(new AdapterImpl() {
    
    @Override
    public void notifyChanged(Notification msg) {
    // Execute change reaction code.
    }

});

[Updated on: Wed, 04 December 2013 03:33]

Report message to a moderator

Previous Topic:Using polygons to replicate semicircles
Next Topic:Control Points for CurvedConnection
Goto Forum:
  


Current Time: Mon Jul 28 02:15:16 EDT 2014

Powered by FUDForum. Page generated in 0.02447 seconds