01: /*
02: * CoadunationAdmin: The admin frontend for coadunation.
03: * Copyright (C) 2007 - 2008 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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 Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * ContentPanel.java
20: */
21:
22: // package path
23: package com.rift.coad.web.admin.client;
24:
25: // java imports
26: import java.util.HashMap;
27:
28: // gwt imports
29: import com.google.gwt.user.client.Window;
30: import com.google.gwt.user.client.ui.Composite;
31: import com.google.gwt.user.client.ui.HTML;
32: import com.google.gwt.user.client.ui.VerticalPanel;
33: import com.google.gwt.user.client.ui.Widget;
34: import com.google.gwt.user.client.ui.DeckPanel;
35:
36: /**
37: * This is the content panel for the admin console.
38: *
39: * @author brett chaldecott
40: */
41: public class ContentPanel extends Composite {
42:
43: // singleton member variables
44: private static ContentPanel singleton = null;
45:
46: // private member variables
47: private DeckPanel deckPanel = new DeckPanel();
48: private HashMap entries = new HashMap();
49:
50: /**
51: * Creates a new instance of ContentPanel
52: */
53: private ContentPanel() {
54:
55: // set the values of the deck panel
56: deckPanel.setHeight("100%");
57: deckPanel.setWidth("100%");
58:
59: // init the widget
60: initWidget(deckPanel);
61: }
62:
63: /**
64: * This method returns an instance of the content panel.
65: *
66: * @return A reference to the content panel.
67: */
68: public static synchronized ContentPanel getInstance() {
69: if (singleton == null) {
70: singleton = new ContentPanel();
71: }
72: return singleton;
73: }
74:
75: /**
76: * This method is responsible setting a panel entry.
77: *
78: * @param name The name of the panel to add.
79: * @param widget The reference to the panel.
80: */
81: public void setPanel(String name, Widget widget) {
82: if (entries.containsKey(name)) {
83: deckPanel.showWidget(((Integer) entries.get(name))
84: .intValue());
85: } else {
86: Integer index = new Integer(entries.size());
87: entries.put(name, index);
88: deckPanel.add(widget);
89: deckPanel.showWidget(index.intValue());
90: }
91: }
92: }
|