01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.module.builders;
11:
12: import org.mmbase.core.event.NodeEvent;
13: import org.mmbase.module.core.*;
14: import org.mmbase.util.logging.*;
15:
16: /**
17: * Probably your builder must extend this if 'properties' on its nodes must work decently?
18: *
19: * @javadoc
20: *
21: * @version $Id: Properties.java,v 1.16 2007/02/25 17:56:59 nklasens Exp $
22: */
23: public class Properties extends MMObjectBuilder {
24:
25: private static final Logger log = Logging
26: .getLoggerInstance(Properties.class);
27:
28: public String getGUIIndicator(MMObjectNode node) {
29: String str = node.getStringValue("key");
30: if (str.length() > 15) {
31: return str.substring(0, 12) + "...";
32: } else {
33: return str;
34: }
35: }
36:
37: /* (non-Javadoc)
38: * @see org.mmbase.module.core.MMObjectBuilder#notify(org.mmbase.core.event.NodeEvent)
39: */
40: public void notify(NodeEvent event) {
41: if (event.getBuilderName().equals(this .getTableName())) {
42: if (log.isDebugEnabled()) {
43: log.debug("nodeChanged(): Property change ! "
44: + event.getMachine() + " "
45: + event.getNodeNumber() + " "
46: + event.getBuilderName() + " "
47: + NodeEvent.newTypeToOldType(event.getType()));
48: }
49: if (event.getType() == NodeEvent.TYPE_CHANGE
50: || event.getType() == NodeEvent.TYPE_NEW) {
51: // The passed node number is node of prop node
52: int parent = getNode(event.getNodeNumber())
53: .getIntValue("parent");
54: if (isNodeCached(parent)) {
55: log
56: .debug("nodeChanged(): Zapping node properties cache for "
57: + parent);
58: MMObjectNode pnode = getNode(parent);
59: if (pnode != null)
60: pnode.delPropertiesCache();
61: }
62: }
63: }
64: super.notify(event);
65: }
66: }
|