[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Custom view and ... ??


Well, no probs, maybe U can answer my D&D question then :)


When I select element on my Editor selectionChanged() is called in View. This method is called because I've registered selection listener for my Custom View. Now I need data from selected object. Because I can't get data directly I'm using IAdaptable to do that. My EditPart implements IAdapatble and method getAdapter().




    public Object getAdapter(Class adapter)
        {
        if (adapter.equals(IGeneralProperties.class))
            {
            element = ((CallflowElement) getModel());

            return new GeneralProperties();
            }
        else
            return null;
        }


MyEditPart{ ... private CallflowElement element = (CallflowElement) getModel(); private class GeneralProperties implements IGeneralProperties { //private CallflowElement element;


public void setName(String name) { element.setName(name); }

 ...

        public String getName()
            {
            return element.getName();
            }

...
        }

...
}

I'm pasing object of GeneralProperties to a View, and it has implementation of getProp and setProp methods.

    protected void pageSelectionChanged(IWorkbenchPart part,
            ISelection selection)
        {
        StructuredSelection sel = (StructuredSelection) selection;

if (sel.getFirstElement() instanceof IAdaptable)
{
if (sel.getFirstElement() instanceof CallflowEditPart)
{
IGeneralProperties prop = (IGeneralProperties) ((IAdaptable) sel


.getFirstElement()).getAdapter(IGeneralProperties.class);
                _viewer.setGeneralProperties(prop);
                }
            }
        }

So in Viewer when somethings changed I can update Model properties.
That's it:)


Greg

Martijn van Steenbergen wrote:
Care to share? :)

Greg wrote:

Thank's Martijn for afford.
I just figured it out :)