1 26 27 package org.nightlabs.editor2d.viewer; 28 29 import java.awt.Component ; 30 import java.util.ArrayList ; 31 import java.util.Collection ; 32 33 import org.nightlabs.editor2d.DrawComponent; 34 35 public class TempContentManager 36 implements ITempContentManager 37 { 38 public TempContentManager() { 39 tempContent = new ArrayList (); 40 } 41 42 protected Collection tempContent = null; 43 public Collection getTempContent() { 44 return tempContent; 45 } 46 public void setTempContent(Collection _tempContent) { 47 tempContent = _tempContent; 48 } 49 50 public void removeFromTempContent(Object _object) { 51 if (tempContent.contains(_object)) { 52 tempContent.remove(_object); 53 } 54 } 55 56 public boolean contains(Object o) { 57 if (tempContent.contains(o)) { 58 return true; 59 } else { 60 return false; 61 } 62 } 63 64 public void addToTempContent(Object _object) 65 { 66 if (tempContent == null) { 67 tempContent = new ArrayList (); 68 } 69 if (_object instanceof DrawComponent || _object instanceof Component ) { 70 if (tempContent.contains(_object)) { 71 return; 72 } 73 tempContent.add(_object); 74 } 75 else { 76 throw new IllegalArgumentException ("_object is neither a instance of DrawComponent nor Component!"); 77 } 78 } 79 80 public boolean isEmpty() 81 { 82 if (tempContent != null) 83 return tempContent.isEmpty(); 84 85 return false; 86 } 87 88 public void clear() { 89 tempContent.clear(); 90 } 91 } 92 | Popular Tags |