001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.event;
019:
020: import java.io.Serializable;
021: import java.util.Map;
022:
023: import de.finix.contelligent.Component;
024: import de.finix.contelligent.ComponentPath;
025:
026: final public class ComponentEvent extends ContelligentEvent {
027:
028: public final static EventType CHANGE = new EventType(
029: COMPONENT_CHANGE_EVENT, "component changed");
030:
031: public final static EventType REMOVE = new EventType(
032: COMPONENT_REMOVE_EVENT, "component removed");
033:
034: public final static EventType ADD = new EventType(
035: COMPONENT_ADD_EVENT, "component added");
036:
037: public final static EventType LOCK = new EventType(
038: COMPONENT_LOCK_EVENT, "component lock");
039:
040: public final static EventType UNLOCK = new EventType(
041: COMPONENT_UNLOCK_EVENT, "component unlock");
042:
043: public final static EventType EDIT = new EventType(
044: COMPONENT_EDIT_EVENT, "component edit");
045:
046: public final static EventType CURRENT_PAGE = new EventType(
047: COMPONENT_CURRENT_PAGE, "current page");
048:
049: public final static EventType WORKFLOW_DEF_CHANGED = new EventType(
050: WF_DEFINITION_CHANGED, "workflow definition changed");
051:
052: public final static EventType CONFIG_ADDED = new EventType(
053: COMPONENT_CONFIG_ADDED, "config added");
054:
055: public final static EventType CONFIG_CHANGED = new EventType(
056: COMPONENT_CONFIG_CHANGED, "config changed");
057:
058: public final static EventType CONFIG_REMOVED = new EventType(
059: COMPONENT_CONFIG_REMOVED, "config removed");
060:
061: private final ComponentPath targetPath;
062:
063: private final EventType eventType;
064:
065: private final transient Component component;
066:
067: public ComponentEvent(EventType eventType, Component component,
068: String origin) {
069: super (eventType.id, origin);
070: this .targetPath = component.getComponentContext().getPath();
071: this .eventType = eventType;
072: this .component = component;
073: }
074:
075: public ComponentEvent(EventType eventType,
076: ComponentPath targetPath, String origin) {
077: super (eventType.id, origin);
078: this .targetPath = targetPath;
079: this .eventType = eventType;
080: this .component = null;
081: }
082:
083: public ComponentEvent(EventType eventType,
084: ComponentPath targetPath, String origin, Map info) {
085: super (eventType.id, origin, info);
086: this .targetPath = targetPath;
087: this .eventType = eventType;
088: this .component = null;
089: }
090:
091: public int getType() {
092: return eventType.id;
093: }
094:
095: public ComponentPath getTargetPath() {
096: return targetPath;
097: }
098:
099: public Component getComponent() {
100: return component;
101: }
102:
103: public String toString() {
104: StringBuffer rs = new StringBuffer("[ComponentEvent(");
105: rs.append(eventType).append(") path=").append(targetPath)
106: .append(" origin=").append(getOrigin()).append("]");
107: if (getInfo() != null) {
108: rs.append(getInfo());
109: }
110: return rs.toString();
111: }
112:
113: protected void additionalXML(StringBuffer buf) {
114: buf.append("<Target>").append(targetPath.toString()).append(
115: "</Target>\n");
116: }
117:
118: static final public class EventType implements Serializable {
119: final public int id;
120:
121: final public String idString;
122:
123: private EventType(int id, String idString) {
124: this .id = id;
125: this .idString = idString;
126: }
127:
128: public String toString() {
129: return idString;
130: }
131: }
132:
133: }
|