01: // WebOnSwing - Web Application Framework
02: //Copyright (C) 2003 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package net.ar.webonswing.managers.contributors;
19:
20: import java.util.*;
21:
22: import net.ar.webonswing.*;
23: import net.ar.webonswing.ui.*;
24:
25: import org.apache.commons.logging.*;
26:
27: public class ContributorManager {
28: private static final String CONTRIBUTION_STATE_ID = "contributor-state";
29: protected Hashtable contributorMappings = new Hashtable();
30:
31: public ContributorManager() {
32: }
33:
34: public ContributorManager(Hashtable aTable) {
35: contributorMappings = aTable;
36: }
37:
38: public String getContributorClassNameFromTreeState(
39: String aWindowName, String aComponentName) {
40: return (String) WosFramework.getInstance()
41: .getWindowTreeStateManager().getComponentState(
42: aWindowName, aComponentName,
43: CONTRIBUTION_STATE_ID);
44: }
45:
46: public void setContributorClassNameToTreeState(String aWindowName,
47: String aComponentName, String aContributionClass) {
48: WosFramework.getInstance().getWindowTreeStateManager()
49: .setComponentState(aWindowName, aComponentName,
50: CONTRIBUTION_STATE_ID, aContributionClass);
51: }
52:
53: public String getDefaultComponentContributorClassName(String anUiId) {
54: Object theEntry = contributorMappings.get(anUiId);
55:
56: if (theEntry != null)
57: return ((ComponentContributorRelationship) theEntry)
58: .getContributorClassName();
59: else {
60: LogFactory.getLog(ContributorManager.class).warn(
61: "Cannot find a contributor for: " + anUiId);
62:
63: return GenericUIContributor.class.getName();
64: }
65: }
66:
67: public Hashtable getContributorsTable() {
68: return contributorMappings;
69: }
70:
71: public void setContributorsTable(Hashtable unContributorsTable) {
72: contributorMappings = unContributorsTable;
73: }
74: }
|