summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Helming2012-11-21 17:06:09 (EST)
committerSopot Cela2012-11-21 17:06:09 (EST)
commit7a90b2a518fd51faba1d078987c609da87c41ec0 (patch)
treedd555042a1bc6d490c1f4200fc06c4212c28c113
parentc215c5bbc44faf2aa396a4240b04041d1346f058 (diff)
downloadorg.eclipse.e4.tools-7a90b2a518fd51faba1d078987c609da87c41ec0.zip
org.eclipse.e4.tools-7a90b2a518fd51faba1d078987c609da87c41ec0.tar.gz
org.eclipse.e4.tools-7a90b2a518fd51faba1d078987c609da87c41ec0.tar.bz2
Bug 394345 - Fragment Editor does not allow to create a fragment in the
tree using right click
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java40
3 files changed, 35 insertions, 7 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
index c12d38c..cc5005b 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
@@ -424,6 +424,7 @@ public class Messages {
public String VModelFragmentsEditor_TreeLabel;
public String VModelFragmentsEditor_TreeLabelDescription;
public String VModelFragmentsEditor_Fragments;
+ public String VModelFragmentsEditor_AddFragment;
public String VModelImportsEditor_TreeLabel;
public String VModelImportsEditor_TreeLabelDescription;
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
index aee6827..8068a96 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
@@ -425,6 +425,7 @@ VMenuEditor_AddPopupMenuContribution=Popup Menu
VModelFragmentsEditor_TreeLabel=Fragments
VModelFragmentsEditor_TreeLabelDescription=Fragments Bla Bla Bla Bla Bla
VModelFragmentsEditor_Fragments=Fragments
+VModelFragmentsEditor_AddFragment=Model Fragment
VModelImportsEditor_TreeLabel=Imports
VModelImportsEditor_TreeLabelDescription=Imports Bla Bla Bla Bla Bla
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java
index 723342d..516e7f2 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VModelFragmentsEditor.java
@@ -10,7 +10,9 @@
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component.virtual;
+import java.util.ArrayList;
import java.util.List;
+import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.WritableValue;
@@ -27,6 +29,7 @@ import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -47,12 +50,23 @@ public class VModelFragmentsEditor extends AbstractComponentEditor {
private Composite composite;
private EMFDataBindingContext context;
private TableViewer viewer;
+ private List<Action> actions = new ArrayList<Action>();
@Inject
public VModelFragmentsEditor() {
super();
}
+ @PostConstruct
+ void init() {
+ actions.add(new Action(Messages.VModelFragmentsEditor_AddFragment, createImageDescriptor(ResourceProvider.IMG_ModelFragments)) {
+ @Override
+ public void run() {
+ handleAdd();
+ }
+ });
+ }
+
@Override
public Image getImage(Object element, Display display) {
return null;
@@ -174,15 +188,10 @@ public class VModelFragmentsEditor extends AbstractComponentEditor {
@Override
public void widgetSelected(SelectionEvent e) {
- MStringModelFragment eObject = MFragmentFactory.INSTANCE.createStringModelFragment();
- Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), FragmentPackageImpl.Literals.MODEL_FRAGMENTS__FRAGMENTS, eObject);
-
- if (cmd.canExecute()) {
- getEditingDomain().getCommandStack().execute(cmd);
- getEditor().setSelection(eObject);
- }
+ handleAdd();
}
+
});
b = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
@@ -214,4 +223,21 @@ public class VModelFragmentsEditor extends AbstractComponentEditor {
return null;
}
+ @Override
+ public List<Action> getActions(Object element) {
+ ArrayList<Action> l = new ArrayList<Action>(super.getActions(element));
+ l.addAll(actions);
+ return l;
+ }
+
+ private void handleAdd() {
+ MStringModelFragment eObject = MFragmentFactory.INSTANCE.createStringModelFragment();
+ Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), FragmentPackageImpl.Literals.MODEL_FRAGMENTS__FRAGMENTS, eObject);
+
+ if (cmd.canExecute()) {
+ getEditingDomain().getCommandStack().execute(cmd);
+ getEditor().setSelection(eObject);
+ }
+ }
+
} \ No newline at end of file