Kaynağa Gözat

- introduces editor specific proposal abstractions
- provide injector baseded proposal provider contribution
- adapted proposal infrastructure to jface proposal infrastructure

Axel Terfloth 9 yıl önce
ebeveyn
işleme
d7e8b46357
13 değiştirilmiş dosya ile 534 ekleme ve 32 silme
  1. 4 1
      plugins/org.yakindu.sct.domain.generic/META-INF/MANIFEST.MF
  2. 2 2
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/proposals/SCTContentProposalProvider.java
  3. 113 0
      plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/assist/SCTSmartEditProposalProvider.java
  4. 14 6
      plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java
  5. 35 0
      plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericEditorModule.java
  6. 2 0
      plugins/org.yakindu.sct.ui.editor/META-INF/MANIFEST.MF
  7. 1 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/StatechartDiagramEditor.java
  8. 3 2
      plugins/org.yakindu.base.xtext.utils.gmf/src/org/yakindu/base/xtext/utils/gmf/proposals/AbstractSemanticContentProposalProvider.java
  9. 267 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/ContentProposalHandler.java
  10. 11 13
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/proposals/ContentProposalViewerKeyHandler.java
  11. 58 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/IEditProposal.java
  12. 15 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/IEditProposalProvider.java
  13. 9 7
      plugins/org.yakindu.base.xtext.utils.gmf/src/org/yakindu/base/xtext/utils/gmf/proposals/SemanticContentControlAdapter.java

+ 4 - 1
plugins/org.yakindu.sct.domain.generic/META-INF/MANIFEST.MF

@@ -13,7 +13,10 @@ Require-Bundle: org.eclipse.core.runtime,
  org.yakindu.sct.simulation.core,
  org.eclipse.xtext.ui,
  org.yakindu.sct.model.stext.ui,
- org.eclipse.xtext.ui.shared;bundle-version="2.7.2"
+ org.eclipse.xtext.ui.shared;bundle-version="2.7.2",
+ org.eclipse.gmf.runtime.notation;bundle-version="1.8.0",
+ org.yakindu.sct.ui.editor;bundle-version="2.5.0",
+ org.yakindu.base.xtext.utils.gmf;bundle-version="2.5.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Export-Package: org.yakindu.sct.domain.generic,

+ 2 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/proposals/SCTContentProposalProvider.java

@@ -8,7 +8,7 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package org.yakindu.sct.ui.editor.editor.proposals;
+package org.yakindu.sct.domain.generic.assist;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -16,11 +16,11 @@ import java.util.List;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.gef.GraphicalViewer;
-import org.yakindu.base.xtext.utils.gmf.proposals.AbstractSemanticContentProposalProvider;
 import org.yakindu.base.xtext.utils.gmf.proposals.ISemanticContentProposal;
 import org.yakindu.base.xtext.utils.gmf.proposals.ISemanticModification;
 import org.yakindu.base.xtext.utils.gmf.proposals.SemanticContentProposal;
 import org.yakindu.sct.ui.editor.StatechartImages;
+import org.yakindu.sct.ui.editor.proposals.AbstractSemanticContentProposalProvider;
 
 /**
  * 

+ 113 - 0
plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/assist/SCTSmartEditProposalProvider.java

@@ -0,0 +1,113 @@
+package org.yakindu.sct.domain.generic.assist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Image;
+import org.yakindu.base.xtext.utils.gmf.proposals.ISemanticModification;
+import org.yakindu.sct.ui.editor.editor.proposals.AddCompositeModification;
+import org.yakindu.sct.ui.editor.editor.proposals.AddOutgoingStateModification;
+import org.yakindu.sct.ui.editor.proposals.IEditProposal;
+import org.yakindu.sct.ui.editor.proposals.IEditProposalProvider;
+
+
+public class SCTSmartEditProposalProvider implements IEditProposalProvider {
+
+	@Override
+	public List<IEditProposal> getProposals(View view) {
+		List<IEditProposal> proposals = new ArrayList<IEditProposal>();
+
+		proposals.add(new ModificationWrappingEditProposal(new AddOutgoingStateModification(view), "Add outgoing state", "Adds a new outgoing transition to a new sibling state." , null));
+		proposals.add(new ModificationWrappingEditProposal(new AddCompositeModification(view), "Add sub region", "Adds a new region to this state. This region includes an initial state.", null));
+		
+		return proposals;
+	}
+	
+	
+	
+	public static class ModificationWrappingEditProposal implements IEditProposal {
+
+		protected ISemanticModification modification;
+		protected String label;
+		protected String description;
+		protected Image image;
+		
+
+		public ModificationWrappingEditProposal(ISemanticModification	modification) {
+			this(modification, null, null, null);
+		}
+
+		
+		public ModificationWrappingEditProposal(ISemanticModification	modification, String label, String description, Image image) {
+			this.modification = modification;
+			this.label = label;
+			this.description = description;
+			this.image = image;
+		}
+		
+		
+
+		public String getLabel() {
+			return label;
+		}
+
+
+
+		public void setLabel(String label) {
+			this.label = label;
+		}
+
+
+
+		public String getDescription() {
+			return description;
+		}
+
+
+
+		public void setDescription(String description) {
+			this.description = description;
+		}
+
+
+		public Image getImage() {
+			return image;
+		}
+
+
+		public void setImage(Image image) {
+			this.image = image;
+		}
+
+
+		@Override
+		public boolean isApplicable() {
+			return modification != null && modification.isApplicable();
+		}
+
+		
+		
+
+		@Override
+		public void apply() {
+			if (modification != null) modification.modify();
+		}
+
+
+		@Override
+		public String getId() {
+			return (modification != null) ? modification.getClass().getName() : null;
+		}
+		
+
+		
+		@Override
+		public int getOrder() {
+			// TODO Auto-generated method stub
+			return 0;
+		}
+		
+	}
+
+}

+ 14 - 6
plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java

@@ -18,6 +18,7 @@ import org.eclipse.xtext.ui.shared.SharedStateModule;
 import org.yakindu.sct.domain.extension.IDomainInjectorProvider;
 import org.yakindu.sct.domain.generic.modules.EntryRuleRuntimeModule;
 import org.yakindu.sct.domain.generic.modules.EntryRuleUIModule;
+import org.yakindu.sct.domain.generic.modules.GenericEditorModule;
 import org.yakindu.sct.domain.generic.modules.GenericSequencerModule;
 import org.yakindu.sct.domain.generic.modules.GenericSimulationModule;
 import org.yakindu.sct.domain.generic.modules.GenericTypeSystemModule;
@@ -40,6 +41,7 @@ import com.google.inject.util.Modules;
 /**
  * 
  * @author andreas muelder - Initial contribution and API
+ * @author terfloth - added editorInjector
  * 
  */
 public class GenericDomainInjectorProvider implements IDomainInjectorProvider {
@@ -56,30 +58,31 @@ public class GenericDomainInjectorProvider implements IDomainInjectorProvider {
 		semanticTargetToRuleMap.put(Guard.class.getName(), Guard.class);
 	}
 
-	public Module getSharedStateModule() {
+	protected Module getSharedStateModule() {
 		return new SharedStateModule();
 	}
 
-	public Module getLanguageRuntimeModule() {
+	protected Module getLanguageRuntimeModule() {
 		return new STextRuntimeModule();
 	}
 
-	public Module getLanguageUIModule() {
+	protected Module getLanguageUIModule() {
 		return new STextUiModule(STextActivator.getInstance());
 	}
 
-	public Module getTypeSystemModule() {
+	protected Module getTypeSystemModule() {
 		return new GenericTypeSystemModule();
 	}
 
-	public Module getSimulationModule() {
+	protected Module getSimulationModule() {
 		return new GenericSimulationModule();
 	}
 
-	public Module getSequencerModule() {
+	protected Module getSequencerModule() {
 		return new GenericSequencerModule();
 	}
 
+	
 	protected Module getResourceModule() {
 		Module uiModule = Modules.override(getLanguageRuntimeModule()).with(getLanguageUIModule());
 		Module result = Modules.override(uiModule).with(getSharedStateModule());
@@ -119,4 +122,9 @@ public class GenericDomainInjectorProvider implements IDomainInjectorProvider {
 	public Injector getSequencerInjector() {
 		return Guice.createInjector(getSequencerModule());
 	}
+
+	@Override
+	public Injector getEditorInjector() {
+		return Guice.createInjector(new GenericEditorModule());	
+	}
 }

+ 35 - 0
plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericEditorModule.java

@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2015 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.domain.generic.modules;
+
+import org.eclipse.xtext.service.AbstractGenericModule;
+import org.yakindu.sct.domain.generic.assist.SCTSmartEditProposalProvider;
+import org.yakindu.sct.ui.editor.proposals.IEditProposalProvider;
+
+import com.google.inject.Binder;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * 
+ * @author terfloth
+ *
+ */
+public class GenericEditorModule extends AbstractGenericModule {
+
+	public void configure(Binder binder) {
+		super.configure(binder);
+		
+		Multibinder<IEditProposalProvider> proposalProviderBinder = Multibinder.newSetBinder(binder, IEditProposalProvider.class);
+	    proposalProviderBinder.addBinding().to(SCTSmartEditProposalProvider.class);
+	}
+
+	
+}

+ 2 - 0
plugins/org.yakindu.sct.ui.editor/META-INF/MANIFEST.MF

@@ -57,12 +57,14 @@ Export-Package: org.yakindu.sct.ui.editor,
  org.yakindu.sct.ui.editor.editor,
  org.yakindu.sct.ui.editor.editor.figures,
  org.yakindu.sct.ui.editor.editor.figures.utils,
+ org.yakindu.sct.ui.editor.editor.proposals,
  org.yakindu.sct.ui.editor.editparts,
  org.yakindu.sct.ui.editor.factories,
  org.yakindu.sct.ui.editor.partitioning,
  org.yakindu.sct.ui.editor.policies,
  org.yakindu.sct.ui.editor.preferences,
  org.yakindu.sct.ui.editor.propertysheets,
+ org.yakindu.sct.ui.editor.proposals,
  org.yakindu.sct.ui.editor.providers,
  org.yakindu.sct.ui.editor.submachine,
  org.yakindu.sct.ui.editor.utils,

+ 1 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/StatechartDiagramEditor.java

@@ -41,9 +41,9 @@ import org.yakindu.sct.domain.extension.IDomainInjectorProvider;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.ui.editor.DiagramActivator;
-import org.yakindu.sct.ui.editor.editor.proposals.ContentProposalViewerKeyHandler;
 import org.yakindu.sct.ui.editor.partitioning.DiagramPartitioningEditor;
 import org.yakindu.sct.ui.editor.partitioning.DiagramPartitioningUtil;
+import org.yakindu.sct.ui.editor.proposals.ContentProposalViewerKeyHandler;
 import org.yakindu.sct.ui.editor.utils.HelpContextIds;
 import org.yakindu.sct.ui.editor.validation.SCTValidationJob;
 

+ 3 - 2
plugins/org.yakindu.base.xtext.utils.gmf/src/org/yakindu/base/xtext/utils/gmf/proposals/AbstractSemanticContentProposalProvider.java

@@ -8,7 +8,7 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package org.yakindu.base.xtext.utils.gmf.proposals;
+package org.yakindu.sct.ui.editor.proposals;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -16,6 +16,7 @@ import java.util.List;
 import org.eclipse.gef.GraphicalViewer;
 import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
 import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.yakindu.base.xtext.utils.gmf.proposals.ISemanticContentProposal;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
@@ -62,7 +63,7 @@ public abstract class AbstractSemanticContentProposalProvider implements IConten
 		Iterable<ISemanticContentProposal> validProposals = Iterables.filter(acceptor.getAllProposals(),
 				new Predicate<ISemanticContentProposal>() {
 					public boolean apply(ISemanticContentProposal input) {
-						return input.getSemanticModification().IsModificationFor((selectedEditPart.getNotationView()));
+						return input.getSemanticModification().isApplicable();
 					}
 				});
 		if (Iterables.size(validProposals) == 0) {

+ 267 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/ContentProposalHandler.java

@@ -0,0 +1,267 @@
+/**
+ * Copyright (c) 2015 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.proposals;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.fieldassist.ContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.fieldassist.IControlContentAdapter;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.yakindu.base.xtext.utils.gmf.proposals.ISemanticContentProposal;
+import org.yakindu.base.xtext.utils.gmf.proposals.SemanticContentProposal;
+import org.yakindu.sct.domain.extension.DomainRegistry;
+import org.yakindu.sct.domain.extension.IDomainInjectorProvider;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+/**
+ * As a composite instances of this class provide an array of proposals that are assembled from the a set of proposal providers. 
+ * 
+ * @author terfloth - initial contribution
+ */
+public class ContentProposalHandler implements IContentProposalProvider {
+
+	@Inject protected Set<IEditProposalProvider> proposalProviders;
+	
+	protected GraphicalViewer viewer;
+
+	private IControlContentAdapter proposalControlAdapter;
+
+	private ILabelProvider proposalLabelProvider;
+	
+	
+	
+	public ContentProposalHandler(GraphicalViewer viewer) {
+		super();
+		this.viewer = viewer;
+		this.proposalControlAdapter = new ProposalControlAdapter();
+		this.proposalLabelProvider = new ProposalLabelProvider();
+	}
+
+
+	public IControlContentAdapter getProposalControlAdapter() {
+		return proposalControlAdapter;
+	}
+
+
+	public ILabelProvider getProposalLabelProvider() {
+		return proposalLabelProvider;
+	}
+
+	
+	@Override
+	public IContentProposal[] getProposals(String contents, int position) {
+
+		intProposalProvidersOnDemand();
+		List<IEditProposal> editProposals = collectEditProposals();
+		editProposals = sort(editProposals);
+					
+		return contentProposalsFrom(editProposals);
+	}
+
+
+	protected void intProposalProvidersOnDemand() {
+	
+		try {
+			if (proposalProviders == null) {
+				IDomainInjectorProvider injectorProvider = DomainRegistry.getDomainDescriptor(getSelectedView().getElement())
+						.getDomainInjectorProvider();
+				
+				Injector injector = injectorProvider.getEditorInjector();
+				injector.injectMembers(this);
+			}
+		} catch (Throwable t) {
+			System.out.println(t);
+		}
+	
+	}
+
+
+	/**		
+	 * Collects all edit proposals from contained poroposal providers.
+	 * @return
+	 */
+	protected List<IEditProposal> collectEditProposals() {
+		List<IEditProposal> proposals = new ArrayList<IEditProposal>();
+		
+		// collect all IEditProposals
+		View selectedView = getSelectedView();
+		if ( selectedView != null ) {
+			if (proposalProviders != null) {
+				for (IEditProposalProvider provider : proposalProviders) {
+					for (IEditProposal editProposal : provider.getProposals(selectedView)) {
+						if (editProposal.isApplicable()) proposals.add(editProposal);
+					}
+				}
+			}
+		}
+		return proposals;
+	}
+
+
+	/**
+	 * @return the first selected view from the graphical viewer or null 
+	 */
+	protected View getSelectedView() {
+		View selectedView = null;
+		if ( viewer.getSelectedEditParts().size() > 0 )  {
+			if ( viewer.getSelectedEditParts().get(0) instanceof IGraphicalEditPart ){
+				selectedView = ((IGraphicalEditPart) viewer.getSelectedEditParts().get(0)).getNotationView();
+			}
+		}
+		return selectedView;
+	}
+
+
+	/**
+	 * A hook for sorting the proposals. 
+	 * 
+	 * @param the original list of proposals
+	 * @return A sorted proposal list
+	 */
+	protected List<IEditProposal> sort(List<IEditProposal> proposals) {
+		// currently we do nothing here.
+		return proposals;
+	}
+	
+	
+	/**
+	 * Wraps the edit proposals in jface IContentProposal instances.
+	 * @param editProposals
+	 * @return
+	 */
+	protected IContentProposal[] contentProposalsFrom(List<IEditProposal> editProposals) {
+		IContentProposal[] contentProposals = new IContentProposal[editProposals.size()];
+		
+		for (int i= 0; i< editProposals.size(); i++) {
+			contentProposals[i] = new EditProposalWrapper(editProposals.get(i));
+		}
+		
+		return contentProposals;
+	}
+	
+	/**
+	 * @param id The id of a proposal.
+	 * @return The proposal that matches the specified id or null.
+	 */
+	protected IEditProposal getProposalById(String id) {
+
+		List<IEditProposal> editProposals = collectEditProposals();
+		
+		if (id != null) {
+			for (IEditProposal editProposal : editProposals) {
+				if (id.equals(editProposal.getId())) return editProposal;
+			}
+		}
+		
+		return null;
+	}
+
+	
+	/**
+	 * 
+	 * @author terfloth
+	 */
+	protected static class EditProposalWrapper extends ContentProposal {
+		
+		protected IEditProposal wrappedProposal;
+		
+		public EditProposalWrapper(IEditProposal editProposal) {
+			super(editProposal.getId(), editProposal.getLabel(), editProposal.getDescription());
+			this.wrappedProposal = editProposal;
+		}
+		
+		public IEditProposal getEditProposal(){
+			return wrappedProposal;
+		}
+		
+	}
+	
+	
+	/**
+	 * @author terfloth
+	 */
+	public static class ProposalLabelProvider extends LabelProvider {
+
+		@Override
+		public String getText(Object element) {
+			if (element instanceof IContentProposal) {
+				return ((IContentProposal) element).getLabel();
+			}
+			return super.getText(element);
+		}
+
+		@Override
+		public Image getImage(Object element) {
+			if (element instanceof EditProposalWrapper) {
+				return ((EditProposalWrapper) element).getEditProposal().getImage();
+			}
+			return super.getImage(element);
+		}
+
+	}
+
+	
+	/**
+	 * 
+	 * @author andreas muelder - Initial contribution and API
+	 * 
+	 */
+	protected class ProposalControlAdapter implements IControlContentAdapter {
+
+		public Rectangle getInsertionBounds(Control control) {
+			IFigure figure = ((IGraphicalEditPart) viewer.getSelectedEditParts().get(0)).getFigure();
+			org.eclipse.draw2d.geometry.Rectangle bounds = figure.getBounds().getCopy();
+			figure.translateToAbsolute(bounds);
+			return new Rectangle(bounds.getTopRight().x, bounds.getTopRight().y, 100, 0);
+		}
+
+		public void insertControlContents(Control control, String id, int cursorPosition) {
+			IEditProposal proposal = getProposalById(id);
+			// TODO:Multi selection
+			if (proposal.isApplicable()) proposal.apply();
+		}
+
+		public String getControlContents(Control control) {
+			// Nothing to do
+			return null;
+		}
+
+		public int getCursorPosition(Control control) {
+			// Nothing to do
+			return 0;
+		}
+
+		public void setCursorPosition(Control control, int index) {
+			// Nothing to do
+		}
+
+		public void setControlContents(Control control, String contents, int cursorPosition) {
+			// Nothing to do
+		}
+
+	}
+
+}

+ 11 - 13
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/proposals/ContentProposalViewerKeyHandler.java

@@ -8,7 +8,7 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package org.yakindu.sct.ui.editor.editor.proposals;
+package org.yakindu.sct.ui.editor.proposals;
 
 import java.util.List;
 
@@ -21,9 +21,6 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Composite;
-import org.yakindu.base.xtext.utils.gmf.proposals.AbstractSemanticContentProposalProvider;
-import org.yakindu.base.xtext.utils.gmf.proposals.SemanticContentControlAdapter;
-import org.yakindu.base.xtext.utils.gmf.proposals.SemanticContentProposalLabelProvider;
 
 /**
  * 
@@ -33,7 +30,7 @@ import org.yakindu.base.xtext.utils.gmf.proposals.SemanticContentProposalLabelPr
 @SuppressWarnings("restriction")
 public class ContentProposalViewerKeyHandler extends DirectEditKeyHandler {
 
-	private AbstractSemanticContentProposalProvider proposalProvider;
+	private ContentProposalHandler proposalHandler;
 
 	private ContentProposalAdapter adapter;
 
@@ -41,25 +38,26 @@ public class ContentProposalViewerKeyHandler extends DirectEditKeyHandler {
 
 	public ContentProposalViewerKeyHandler(GraphicalViewer viewer) {
 		super(viewer);
-		createProposalProvider();
+		createProposalHandler();
 		createContentAdpater();
 	}
 
+	protected void createProposalHandler() {
+		proposalHandler = new ContentProposalHandler(getViewer());
+	}
+
 	protected void createContentAdpater() {
-		SemanticContentControlAdapter controlAdapter = new SemanticContentControlAdapter(proposalProvider, getViewer());
-		adapter = new ContentProposalAdapter((Composite) getViewer().getControl(), controlAdapter, proposalProvider,
+//		SemanticContentControlAdapter controlAdapter = new SemanticContentControlAdapter(proposalProvider, getViewer());
+		adapter = new ContentProposalAdapter((Composite) getViewer().getControl(), proposalHandler.getProposalControlAdapter(), proposalHandler,
 				keyStroke, null);
-		adapter.setLabelProvider(new SemanticContentProposalLabelProvider());
+		adapter.setLabelProvider(proposalHandler.getProposalLabelProvider());
 		adapter.setPropagateKeys(true);
 		// TODO: If not set, the adapter uses the full width of the
 		// GraphicalViewer as initial bounds
 		adapter.setPopupSize(new Point(400, 150));
 	}
 
-	protected void createProposalProvider() {
-		proposalProvider = new SCTContentProposalProvider(getViewer());
-	}
-
+	
 	@Override
 	public boolean keyPressed(KeyEvent e) {
 		if (getCurrentSelection() == null)

+ 58 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/IEditProposal.java

@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2015 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.proposals;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * 
+ * @author terfloth - initial contribution
+ *
+ */
+public interface IEditProposal {
+
+	/** 
+	 * @return true if the proposal is applicable. 
+	 */
+	public boolean isApplicable();
+	
+	/**
+	 * Applies the proposal.  
+	 */
+	public void apply();
+	
+	/**
+	 * Provides the id of the proposal. 
+	 * This id has to be unique forr all proposals on an element. 
+	 * @return
+	 */
+	public String getId();
+	
+	/**
+	 * Provides the display label of this proposal. 
+	 */
+	public String getLabel();
+	
+	/**
+	 * Provides the description of this proposal. 
+	 */
+	public String getDescription();
+	
+	/**
+	 * Optionally provides an icon image. 
+	 */
+	public Image getImage();
+	
+	/**
+	 * Provides a order number that can be used for sorting.
+	 */
+	public int getOrder();
+}

+ 15 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/IEditProposalProvider.java

@@ -0,0 +1,15 @@
+package org.yakindu.sct.ui.editor.proposals;
+
+import java.util.List;
+
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * 
+ * @author terfloth - initial implementation
+ */
+public interface IEditProposalProvider {
+	
+	public List<IEditProposal> getProposals(View view);
+	
+}

+ 9 - 7
plugins/org.yakindu.base.xtext.utils.gmf/src/org/yakindu/base/xtext/utils/gmf/proposals/SemanticContentControlAdapter.java

@@ -8,14 +8,16 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package org.yakindu.base.xtext.utils.gmf.proposals;
+package org.yakindu.sct.ui.editor.proposals;
 
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.gef.GraphicalViewer;
 import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
 import org.eclipse.jface.fieldassist.IControlContentAdapter;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Control;
+import org.yakindu.base.xtext.utils.gmf.proposals.ISemanticContentProposal;
 
 /**
  * 
@@ -24,10 +26,10 @@ import org.eclipse.swt.widgets.Control;
  */
 public class SemanticContentControlAdapter implements IControlContentAdapter {
 
-	private AbstractSemanticContentProposalProvider provider;
+	private IContentProposalProvider provider;
 	private GraphicalViewer viewer;
 
-	public SemanticContentControlAdapter(AbstractSemanticContentProposalProvider provider, GraphicalViewer viewer) {
+	public SemanticContentControlAdapter(IContentProposalProvider provider, GraphicalViewer viewer) {
 		this.provider = provider;
 		this.viewer = viewer;
 	}
@@ -40,10 +42,10 @@ public class SemanticContentControlAdapter implements IControlContentAdapter {
 	}
 
 	public void insertControlContents(Control control, String id, int cursorPosition) {
-		ISemanticContentProposal proposal = provider.getProposal(id);
-		// TODO:Multi selection
-		IGraphicalEditPart editPart = (IGraphicalEditPart) viewer.getSelectedEditParts().get(0);
-		proposal.getSemanticModification().modify(editPart.getNotationView());
+//		ISemanticContentProposal proposal = provider.getProposals(id, position)(id);
+//		// TODO:Multi selection
+//		IGraphicalEditPart editPart = (IGraphicalEditPart) viewer.getSelectedEditParts().get(0);
+//		proposal.getSemanticModification().modify(editPart.getNotationView());
 	}
 
 	public String getControlContents(Control control) {