Browse Source

reintegrated refactings into proposal mechanism

Axel Terfloth 9 years ago
parent
commit
c264105343

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

@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
  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"
+ org.yakindu.base.xtext.utils.gmf;bundle-version="2.5.0",
+ org.yakindu.sct.refactoring;bundle-version="2.5.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Export-Package: org.yakindu.sct.domain.generic,

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

@@ -1,113 +0,0 @@
-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;
-		}
-		
-	}
-
-}

+ 3 - 1
plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/GenericEditorModule.java

@@ -11,8 +11,9 @@
 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.refactoring.proposals.RefactoringProposalProvider;
 import org.yakindu.sct.ui.editor.proposals.IEditProposalProvider;
+import org.yakindu.sct.ui.editor.proposals.SCTSmartEditProposalProvider;
 
 import com.google.inject.Binder;
 import com.google.inject.multibindings.Multibinder;
@@ -29,6 +30,7 @@ public class GenericEditorModule extends AbstractGenericModule {
 		
 		Multibinder<IEditProposalProvider> proposalProviderBinder = Multibinder.newSetBinder(binder, IEditProposalProvider.class);
 	    proposalProviderBinder.addBinding().to(SCTSmartEditProposalProvider.class);
+	    proposalProviderBinder.addBinding().to(RefactoringProposalProvider.class);
 	}
 
 	

+ 2 - 1
plugins/org.yakindu.sct.refactoring/META-INF/MANIFEST.MF

@@ -17,4 +17,5 @@ Require-Bundle: org.eclipse.ui,
  org.yakindu.base.xtext.utils.gmf;bundle-version="2.1.2"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
-Export-Package: org.yakindu.sct.refactoring.refactor
+Export-Package: org.yakindu.sct.refactoring.proposals,
+ org.yakindu.sct.refactoring.refactor

+ 1 - 1
plugins/org.yakindu.sct.refactoring/src/org/yakindu/sct/refactoring/proposals/ExtractSubdiagramModification.java

@@ -19,7 +19,7 @@ import org.yakindu.sct.refactoring.refactor.impl.ExtractSubdiagramRefactoring;
  * @author terfloth
  * 
  */
-public class ExtractSubdiagramModification extends SemanticModificationAdapter {
+public class ExtractSubdiagramModification extends RefactoringBasedModification {
 
 	public ExtractSubdiagramModification(View view) {
 		super(view, new ExtractSubdiagramRefactoring());

+ 1 - 1
plugins/org.yakindu.sct.refactoring/src/org/yakindu/sct/refactoring/proposals/InlineSubdiagramModification.java

@@ -19,7 +19,7 @@ import org.yakindu.sct.refactoring.refactor.impl.InlineSubdiagramRefactoring;
  * @author terfloth
  * 
  */
-public class InlineSubdiagramModification extends SemanticModificationAdapter {
+public class InlineSubdiagramModification extends RefactoringBasedModification {
 
 	public InlineSubdiagramModification(View view) {
 		super(view, new InlineSubdiagramRefactoring());

+ 2 - 2
plugins/org.yakindu.sct.refactoring/src/org/yakindu/sct/refactoring/proposals/SemanticModificationAdapter.java

@@ -25,7 +25,7 @@ import org.yakindu.sct.refactoring.refactor.IRefactoring;
  * @author terfloth
  * 
  */
-public class SemanticModificationAdapter implements ISemanticModification {
+public class RefactoringBasedModification implements ISemanticModification {
 
 	private View targetView;
 	private AbstractRefactoring<View> refactoring;
@@ -42,7 +42,7 @@ public class SemanticModificationAdapter implements ISemanticModification {
 	}
 
 
-	public SemanticModificationAdapter(View view, AbstractRefactoring<View> refactoring) {
+	public RefactoringBasedModification(View view, AbstractRefactoring<View> refactoring) {
 		this.targetView = view;
 		this.refactoring = refactoring;
 	}

+ 49 - 0
plugins/org.yakindu.sct.refactoring/src/org/yakindu/sct/refactoring/proposals/RefactoringProposalProvider.java

@@ -0,0 +1,49 @@
+/**
+ * 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.refactoring.proposals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gmf.runtime.notation.View;
+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;
+import org.yakindu.sct.ui.editor.proposals.ModificationBasedEditProposal;
+
+/**
+ * This provider implementation provides the rafactorings as proposals.
+ *  
+ * @author terfloth
+ */
+public class RefactoringProposalProvider implements IEditProposalProvider {
+
+	@Override
+	public List<IEditProposal> getProposals(View view) {
+		List<IEditProposal> proposals = new ArrayList<IEditProposal>();
+
+		proposals.add(new ModificationBasedEditProposal(
+				new ExtractSubdiagramModification(view), 
+				"Refactoring - Extract Subdiagram", 
+				"Extracts all sub regions into a sub diagram. " +
+				"Direct transitions into the diagram will be substituted by entries and outgoing transitions will be substituted using exit nodes. " +
+				"Sub diagrams are opened seperately." , 
+				null));
+		proposals.add(new ModificationBasedEditProposal(
+				new InlineSubdiagramModification(view), 
+				"Refactoring - Inline Subdiagram", 
+				"Inlines the existing subdiagram. The region includes an initial state.", null));
+		
+		return proposals;
+	}
+
+}

+ 86 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/ModificationBasedEditProposal.java

@@ -0,0 +1,86 @@
+package org.yakindu.sct.ui.editor.proposals;
+
+import org.eclipse.swt.graphics.Image;
+import org.yakindu.base.xtext.utils.gmf.proposals.ISemanticModification;
+
+public class ModificationBasedEditProposal implements IEditProposal {
+
+	protected ISemanticModification modification;
+	protected String label;
+	protected String description;
+	protected Image image;
+	
+
+	public ModificationBasedEditProposal(ISemanticModification	modification) {
+		this(modification, null, null, null);
+	}
+
+	
+	public ModificationBasedEditProposal(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;
+	}
+	
+}

+ 39 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/proposals/SCTSmartEditProposalProvider.java

@@ -0,0 +1,39 @@
+/**
+ * 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 org.eclipse.gmf.runtime.notation.View;
+import org.yakindu.sct.ui.editor.editor.proposals.AddCompositeModification;
+import org.yakindu.sct.ui.editor.editor.proposals.AddOutgoingStateModification;
+
+/**
+ * This provider implementation provides the standard high level editing operations.
+ *  
+ * The first add an new outgoing transition with a new target state. Teh second adds a subregion with entry and initial state.
+ *  
+ * @author terfloth
+ */
+public class SCTSmartEditProposalProvider implements IEditProposalProvider {
+
+	@Override
+	public List<IEditProposal> getProposals(View view) {
+		List<IEditProposal> proposals = new ArrayList<IEditProposal>();
+
+		proposals.add(new ModificationBasedEditProposal(new AddOutgoingStateModification(view), "Add outgoing state", "Adds a new outgoing transition to a new sibling state." , null));
+		proposals.add(new ModificationBasedEditProposal(new AddCompositeModification(view), "Add sub region", "Adds a new region to this state. This region includes an initial state.", null));
+		
+		return proposals;
+	}
+
+}