diff options
Diffstat (limited to 'bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java')
-rw-r--r-- | bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java index 64232bb6..9ea93a7c 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/virtual/VCommandEditor.java @@ -20,6 +20,7 @@ import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor; import org.eclipse.e4.tools.emf.ui.internal.ResourceProvider; import org.eclipse.e4.tools.emf.ui.internal.common.ComponentLabelProvider; import org.eclipse.e4.tools.emf.ui.internal.common.VirtualEntry; +import org.eclipse.e4.tools.emf.ui.internal.imp.ModelImportWizard; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.commands.MCommand; import org.eclipse.e4.ui.model.application.commands.impl.CommandsFactoryImpl; @@ -35,6 +36,7 @@ import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; @@ -54,6 +56,7 @@ public class VCommandEditor extends AbstractComponentEditor { private EStructuralFeature commandsFeature; private List<Action> actions = new ArrayList<Action>(); + private List<Action> actionsImport = new ArrayList<Action>(); @Inject public VCommandEditor() { @@ -69,6 +72,13 @@ public class VCommandEditor extends AbstractComponentEditor { handleAdd(); } }); + + actionsImport.add(new Action("Import Commands", createImageDescriptor(ResourceProvider.IMG_Command)) { + @Override + public void run() { + handleImport(); + } + }); } @Override @@ -219,8 +229,11 @@ public class VCommandEditor extends AbstractComponentEditor { protected void handleAdd() { MCommand command = CommandsFactoryImpl.eINSTANCE.createCommand(); - setElementId(command); + addCommand(command); + } + private void addCommand(MCommand command) { + setElementId(command); Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), commandsFeature, command); if (cmd.canExecute()) { @@ -229,6 +242,17 @@ public class VCommandEditor extends AbstractComponentEditor { } } + protected void handleImport() { + ModelImportWizard wizard = new ModelImportWizard(MCommand.class, getEditingDomain()); + WizardDialog wizardDialog = new WizardDialog(viewer.getControl().getShell(), wizard); + if (wizardDialog.open() == WizardDialog.OK) { + MCommand[] elements = (MCommand[]) wizard.getElements(MCommand.class); + for (MCommand mCommand : elements) { + addCommand(mCommand); + } + } + } + @Override public IObservableList getChildList(Object element) { return null; @@ -240,4 +264,11 @@ public class VCommandEditor extends AbstractComponentEditor { l.addAll(actions); return l; } + + @Override + public List<Action> getActionsImport(Object element) { + ArrayList<Action> l = new ArrayList<Action>(super.getActions(element)); + l.addAll(actionsImport); + return l; + } }
\ No newline at end of file |