1 18 19 package de.gulden.framework.amoda.generic.behaviour; 20 21 import de.gulden.framework.amoda.generic.core.*; 22 import de.gulden.framework.amoda.model.behaviour.Command; 23 import de.gulden.framework.amoda.model.data.*; 24 import java.awt.event.*; 25 import java.lang.*; 26 import java.util.*; 27 28 34 public class CommandWrapper extends GenericCommand implements Command { 35 36 40 public String text; 41 42 protected GenericApplicationMemberAbstract wrapped; 43 44 45 49 public void setParent(CompositeGroup parent) { 50 super.setParent(parent); 51 getWrapped().setParent(parent); 52 } 53 54 public void setText(String _text) { 55 text = _text; } 57 58 public GenericApplicationMemberAbstract getWrapped() { 59 text=text.trim(); 60 if (wrapped==null) { 61 try { 62 Class clazz=Class.forName(text); wrapped=(GenericApplicationMemberAbstract)clazz.newInstance(); 64 } catch (Exception e) { 65 de.gulden.framework.amoda.generic.core.GenericApplicationEnvironmentFactory.fatalError("cannot instantiate object of class '"+text+"'",e); 66 } 67 } 68 return wrapped; 69 } 70 71 public void actionPerformed(ActionEvent event) { 72 Object wrapped = getWrapped(); 73 if (wrapped instanceof GenericCommand) { 74 ((GenericCommand)wrapped).actionPerformed(event); 75 } else { 76 perform(); 77 } 78 } 79 80 public void perform() { 81 de.gulden.framework.amoda.model.behaviour.Command wrapped = (de.gulden.framework.amoda.model.behaviour.Command)getWrapped(); 82 if (wrapped.getParent()==null) { wrapped.setParent(this.getParent()); 84 } 85 wrapped.perform(); 86 } 87 88 } | Popular Tags |