KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > viewer > TempContentManager


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * *
5  * This library is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or (at your option) any later version. *
9  * *
10  * This library is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13  * Lesser General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Lesser General Public *
16  * License along with this library; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin St, Fifth Floor, *
19  * Boston, MA 02110-1301 USA *
20  * *
21  * Or get it online : *
22  * http://www.gnu.org/copyleft/lesser.html *
23  * *
24  * *
25  ******************************************************************************/

26
27 package org.nightlabs.editor2d.viewer;
28
29 import java.awt.Component JavaDoc;
30 import java.util.ArrayList JavaDoc;
31 import java.util.Collection JavaDoc;
32
33 import org.nightlabs.editor2d.DrawComponent;
34
35 public class TempContentManager
36 implements ITempContentManager
37 {
38   public TempContentManager() {
39     tempContent = new ArrayList JavaDoc();
40   }
41
42   protected Collection JavaDoc tempContent = null;
43   public Collection JavaDoc getTempContent() {
44     return tempContent;
45   }
46   public void setTempContent(Collection JavaDoc _tempContent) {
47     tempContent = _tempContent;
48   }
49
50   public void removeFromTempContent(Object JavaDoc _object) {
51     if (tempContent.contains(_object)) {
52       tempContent.remove(_object);
53     }
54   }
55
56   public boolean contains(Object JavaDoc o) {
57     if (tempContent.contains(o)) {
58         return true;
59     } else {
60         return false;
61     }
62   }
63   
64   public void addToTempContent(Object JavaDoc _object)
65   {
66     if (tempContent == null) {
67       tempContent = new ArrayList JavaDoc();
68     }
69     if (_object instanceof DrawComponent || _object instanceof Component JavaDoc) {
70         if (tempContent.contains(_object)) {
71             return;
72         }
73       tempContent.add(_object);
74     }
75     else {
76       throw new IllegalArgumentException JavaDoc("_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