/**
 * 
 */
package de.uni_jena.iaa.linktype.atomic.editors.grapheditor.parts;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FreeformLayer;
import org.eclipse.draw2d.FreeformLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;

import de.hu_berlin.german.korpling.saltnpepper.salt.saltCommon.sDocumentStructure.SDocumentGraph;
import de.hu_berlin.german.korpling.saltnpepper.salt.saltCore.SNode;

/**
 * @author Stephan Druskat
 *
 */
public class GraphPart extends AbstractGraphicalEditPart {

	/* (non-Javadoc)
	 * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
	 */
	@Override
	protected IFigure createFigure() {
		Figure figure = new FreeformLayer();
		figure.setBorder(new MarginBorder(3)); // FIXME: Remove
		figure.setLayoutManager(new FreeformLayout());
		return figure;
	}
	
	@Override
	protected void refreshVisuals() {
		super.refreshVisuals();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
	 */
	@Override
	protected void createEditPolicies() {
		// TODO Auto-generated method stub

	}
	
	protected List<SNode> getModelChildren() {
		List<SNode> modelChildren = new ArrayList<SNode>();
		modelChildren.addAll(getModel().getSTokens());
		return modelChildren;
	}
	
	public SDocumentGraph getModel() {
		return (SDocumentGraph) super.getModel();
	}

}

@@ -313,24 +313,173 @@
 rginBorder;%0A
+import org.eclipse.emf.common.notify.Notification;%0Aimport org.eclipse.emf.common.notify.Notifier;%0Aimport org.eclipse.emf.ecore.util.EContentAdapter;%0A
 import org.e
@@ -526,16 +526,16 @@
 itPart;%0A
-
 %0Aimport 
@@ -792,16 +792,109 @@
 itPart %7B
+%0A%09%0A%09private GraphAdapter adapter;%0A%0A%09public GraphPart() %7B%0A%09%09setAdapter(new GraphAdapter());%0A%09%7D
 %0A%0A%09/* (n
@@ -1678,16 +1678,16 @@
 del() %7B%0A
-
 %09%09return
@@ -1726,10 +1726,957 @@
 ();%0A%09%7D%0A%0A
+%09/**%0A%09 * @return the adapter%0A%09 */%0A%09public GraphAdapter getAdapter() %7B%0A%09%09return adapter;%0A%09%7D%0A%0A%09/**%0A%09 * @param adapter the adapter to set%0A%09 */%0A%09public void setAdapter(GraphAdapter adapter) %7B%0A%09%09this.adapter = adapter;%0A%09%7D%0A%09%0A%09/**%0A%09 * @author Stephan Druskat%0A%09 *%0A%09 */%0A%09public class GraphAdapter extends EContentAdapter %7B%0A%09%09%0A%09%09@Override public void notifyChanged(Notification notification) %7B%0A%09    %09refreshChildren();%0A%09    %7D%0A%09 %0A%09%09@Override public Notifier getTarget() %7B%0A%09    %09return (SDocumentGraph) getModel();%0A%09    %7D%0A%09 %0A%09    @Override public boolean isAdapterForType(Object type) %7B%0A%09    %09return type.equals(SDocumentGraph.class);%0A%09    %7D%0A%0A%09%7D%0A%09%0A%09@Override %0A%09public void activate() %7B%0A%09%09if(!isActive()) %7B%0A%09%09%09((SDocumentGraph) getModel()).eAdapters().add(getAdapter());%0A%09    %7D%0A%09%09super.activate();%0A%09%7D%0A%09 %0A%09@Override %0A%09public void deactivate() %7B%0A%09%09if(isActive()) %7B%0A%09%09%09((SDocumentGraph) getModel()).eAdapters().remove(getAdapter());%0A%09%09%7D%0A%09%09super.deactivate();%0A%09%7D%0A%0A
 %7D%0A

Add adapter to GraphPart