| 1 | = Open a dialog when double clicking on an edit part = |
| 2 | |
| 3 | |
| 4 | [wiki:gmf:gmf <back] |
| 5 | |
| 6 | * Follow the instructions you find [http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/msg05684.html here]. |
| 7 | * Write a command class similar to this: |
| 8 | {{{ |
| 9 | public class OpenDialogCommand extends Command { |
| 10 | |
| 11 | @Override |
| 12 | public void execute() { |
| 13 | |
| 14 | TwoListsSelectionDialog dialog = new TwoListsSelectionDialog( |
| 15 | PlatformUI.getWorkbench().getActiveWorkbenchWindow() |
| 16 | .getShell()); |
| 17 | EObject exhibitionModule = ((ExhibitionModuleEditPart) getParent()) |
| 18 | .resolveSemanticElement(); |
| 19 | |
| 20 | dialog.setList(((ExhibitionModule) exhibitionModule).getSlides()); |
| 21 | Object[] results = null; |
| 22 | dialog.open(); |
| 23 | results = dialog.getResult(); |
| 24 | |
| 25 | Sequence seq = (Sequence) resolveSemanticElement(); |
| 26 | if (results == null) { |
| 27 | seq.eSet(ExhibitionPackage.eINSTANCE.getSequence_SlideOrder(), |
| 28 | null); |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | String slideOrder = ""; |
| 33 | |
| 34 | for (Object obj : results) { |
| 35 | if (obj instanceof Slide) { |
| 36 | slideOrder += ((Slide) obj).getSlideId() + ";"; |
| 37 | } |
| 38 | } |
| 39 | org.eclipse.emf.common.command.Command cmd = SetCommand.create( |
| 40 | getEditingDomain(), seq, ExhibitionPackage.eINSTANCE |
| 41 | .getSequence_SlideOrder(), slideOrder); |
| 42 | getEditingDomain().getCommandStack().execute(cmd); |
| 43 | System.out.println(getClass().getName() + " seq " |
| 44 | + seq.getSlideOrder()); |
| 45 | } |
| 46 | |
| 47 | } |
| 48 | }}} |