Commit 1cf81579 authored by Bill Lynch's avatar Bill Lynch Committed by bill

More dev


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@313 b35dd754-fafc-0310-a699-88a17e54d16e
parent eaf9479d
/** /**
* $RCSfile$ * $RCSfile$
* $Revision * $Revision$
* $Date$ * $Date$
* *
* Copyright (C) 1999-2004 Jive Software. All rights reserved. * Copyright (C) 2004 Jive Software. All rights reserved.
* *
* This software is the proprietary information of Jive Software. Use is subject to license terms. * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.admin; package org.jivesoftware.admin;
...@@ -32,13 +33,13 @@ import java.net.URL; ...@@ -32,13 +33,13 @@ import java.net.URL;
* *
* <p>Note: IDs in the XML file must be unique because an internal mapping is kept of IDs to * <p>Note: IDs in the XML file must be unique because an internal mapping is kept of IDs to
* nodes.</p> * nodes.</p>
*
* TODO: Add other property customizers (page title, image urls, etc)
*/ */
public class AdminConsole { public class AdminConsole {
private static Collection items; private static Collection items;
private static Map idMap; // map of item ids -> item objs private static Map idMap; // map of item ids -> item objs
private static String appName;
private static String logoImage;
static { static {
items = new ArrayList(); items = new ArrayList();
...@@ -60,6 +61,21 @@ public class AdminConsole { ...@@ -60,6 +61,21 @@ public class AdminConsole {
addToModel(in); addToModel(in);
} }
/**
* Returns the name of the application.
*/
public static String getAppName() {
return appName;
}
/**
* Returns the URL (relative or absolute) of the main logo image for the admin console.
* @return
*/
public static String getLogoImage() {
return logoImage;
}
/** /**
* Returns all items starting from the root. Getting the iterator from this collection returns * Returns all items starting from the root. Getting the iterator from this collection returns
* all root items (should be used as tabs in the admin tool). * all root items (should be used as tabs in the admin tool).
...@@ -183,6 +199,22 @@ public class AdminConsole { ...@@ -183,6 +199,22 @@ public class AdminConsole {
private void init() { private void init() {
items = Collections.synchronizedList(new ArrayList()); items = Collections.synchronizedList(new ArrayList());
// items = Collections.synchronizedList(new ArrayList(){
// public boolean add(Object obj) {
// Item item = (Item)obj;
// if (contains(item)) {
// Item i = (Item)get(indexOf(item));
// i.setName(item.getName());
// i.setDescription(item.getDescription());
// i.setUrl(item.getUrl());
// return true;
// }
// else {
// super.add(item);
// return true;
// }
// };
// });
if (id != null && !"".equals(id.trim())) { if (id != null && !"".equals(id.trim())) {
idMap.put(id, this); idMap.put(id, this);
} }
...@@ -202,6 +234,13 @@ public class AdminConsole { ...@@ -202,6 +234,13 @@ public class AdminConsole {
return name; return name;
} }
/**
* Sets the name.
*/
void setName(String name) {
this.name = name;
}
/** /**
* Returns the description of the item. * Returns the description of the item.
*/ */
...@@ -209,6 +248,13 @@ public class AdminConsole { ...@@ -209,6 +248,13 @@ public class AdminConsole {
return description; return description;
} }
/**
* Sets the description.
*/
void setDescription(String description) {
this.description = description;
}
/** /**
* Returns the URL for this item. * Returns the URL for this item.
*/ */
...@@ -333,6 +379,13 @@ public class AdminConsole { ...@@ -333,6 +379,13 @@ public class AdminConsole {
private static void addToModel(InputStream in) throws Exception { private static void addToModel(InputStream in) throws Exception {
// Build an XMLPropertiesTest object from the input stream: // Build an XMLPropertiesTest object from the input stream:
XMLProperties xml = new XMLProperties(in); XMLProperties xml = new XMLProperties(in);
// Set any global properties
if (xml.getProperty("global.appname") != null) {
appName = xml.getProperty("global.appname");
}
if (xml.getProperty("global.logo-image") != null) {
logoImage = xml.getProperty("global.logo-image");
}
// Get all children of the 'tabs' element - should be 'tab' items: // Get all children of the 'tabs' element - should be 'tab' items:
String[] tabs = xml.getChildrenProperties("tabs"); String[] tabs = xml.getChildrenProperties("tabs");
for (int i=0; i<tabs.length; i++) { for (int i=0; i<tabs.length; i++) {
...@@ -416,4 +469,10 @@ public class AdminConsole { ...@@ -416,4 +469,10 @@ public class AdminConsole {
classLoaders[2] = ClassLoader.getSystemClassLoader(); classLoaders[2] = ClassLoader.getSystemClassLoader();
return classLoaders; return classLoaders;
} }
private static void clear() {
items = new ArrayList();
idMap = new HashMap();
load();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment