wiki:OpenCommand

Open a dialog when double clicking on an edit part

<back

  • Follow the instructions you find here.
  • Write a command class similar to this:
    public class OpenDialogCommand extends Command {
    
    		@Override
    		public void execute() {
    
    			TwoListsSelectionDialog dialog = new TwoListsSelectionDialog(
    					PlatformUI.getWorkbench().getActiveWorkbenchWindow()
    							.getShell());
    			EObject exhibitionModule = ((ExhibitionModuleEditPart) getParent())
    					.resolveSemanticElement();
    
    			dialog.setList(((ExhibitionModule) exhibitionModule).getSlides());
    			Object[] results = null;
    			dialog.open();
    			results = dialog.getResult();
    
    			Sequence seq = (Sequence) resolveSemanticElement();
    			if (results == null) {
    				seq.eSet(ExhibitionPackage.eINSTANCE.getSequence_SlideOrder(),
    						null);
    				return;
    			}
    
    			String slideOrder = "";
    
    			for (Object obj : results) {
    				if (obj instanceof Slide) {
    					slideOrder += ((Slide) obj).getSlideId() + ";";
    				}
    			}
    			org.eclipse.emf.common.command.Command cmd = SetCommand.create(
    					getEditingDomain(), seq, ExhibitionPackage.eINSTANCE
    							.getSequence_SlideOrder(), slideOrder);
    			getEditingDomain().getCommandStack().execute(cmd);
    			System.out.println(getClass().getName() + " seq "
    					+ seq.getSlideOrder());
    		}
    
    	}
    
Last modified 16 years ago Last modified on Apr 8, 2008, 7:52:29 PM