1 17 package org.eclipse.emf.edit.ui.action; 18 19 20 import java.util.ArrayList ; 21 import java.util.Collection ; 22 import java.util.Iterator ; 23 24 import org.eclipse.jface.viewers.IStructuredSelection; 25 import org.eclipse.ui.actions.BaseSelectionListenerAction; 26 27 import org.eclipse.emf.common.command.Command; 28 import org.eclipse.emf.common.command.UnexecutableCommand; 29 import org.eclipse.emf.edit.domain.EditingDomain; 30 31 32 36 public class CommandActionHandler extends BaseSelectionListenerAction 37 { 38 41 protected EditingDomain domain; 42 43 46 protected Command command; 47 48 51 public CommandActionHandler(EditingDomain domain) 52 { 53 super(""); 56 57 this.domain = domain; 58 } 59 60 63 public CommandActionHandler(EditingDomain domain, String label) 64 { 65 super(label); 66 67 this.domain = domain; 68 } 69 70 73 public EditingDomain getEditingDomain() 74 { 75 return domain; 76 } 77 78 81 public void setEditingDomain(EditingDomain domain) 82 { 83 this.domain = domain; 84 } 85 86 89 public void run() 90 { 91 domain.getCommandStack().execute(command); 92 } 93 94 97 public boolean updateSelection(IStructuredSelection selection) 98 { 99 Collection collection = new ArrayList (); 100 for (Iterator objects = selection.iterator(); objects.hasNext(); ) 101 { 102 collection.add(objects.next()); 103 } 104 105 command = createCommand(collection); 106 107 return command.canExecute(); 108 } 109 110 113 public Command createCommand(Collection selection) 114 { 115 return UnexecutableCommand.INSTANCE; 116 } 117 } 118 | Popular Tags |