KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > documenttype > eventhandler > DTUpdatePresCompHandler


1 package de.webman.documenttype.eventhandler;
2
3 import com.teamkonzept.web.*;
4 import com.teamkonzept.webman.*;
5 import com.teamkonzept.webman.db.TKWebmanDBManager;
6 import com.teamkonzept.webman.mainint.*;
7 import com.teamkonzept.webman.mainint.db.*;
8
9
10 import com.teamkonzept.webman.mainint.db.queries.*;
11 import com.teamkonzept.webman.mainint.events.*;
12 import com.teamkonzept.lib.*;
13 import com.teamkonzept.field.*;
14 import com.teamkonzept.field.db.*;
15 import com.teamkonzept.db.*;
16
17 import java.util.*;
18 import java.sql.*;
19
20 /**
21 *
22 * Speichern der Aenderungen zu einer Componente einer Presentation
23 *
24  * @author $Author: alex $
25  * @version $Revision: 1.7 $
26 */

27 public class DTUpdatePresCompHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
28 {
29     /** Konstruktor private - Singleton */
30     private DTUpdatePresCompHandler()
31     {}
32
33     /** Singleton Instance */
34     private static DTUpdatePresCompHandler instance = new DTUpdatePresCompHandler();
35     
36     public static DTUpdatePresCompHandler getInstance()
37     {
38         return instance;
39     }
40     
41     public void handleEvent(TKEvent evt) throws TKException
42     {
43         try
44         {
45             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.PRESENTATIONS);
46             String JavaDoc compType = evt.getParameter( PARAMETER, "COMPONENT_TYPE" );
47             String JavaDoc intType = evt.getParameter( PARAMETER, "INTEGRATION_TYPE" );
48             String JavaDoc formId = evt.getNotNullParameter( PARAMETER, "THE_FORM_ID" );
49             //String subPresId = evt.getNotNullParameter( PARAMETER, "SUB_PRESENTATION_ID" );
50
String JavaDoc update = evt.getNotNullParameter( PARAMETER, "UPDATE" );
51             String JavaDoc oldCompType = evt.getNotNullParameter( PARAMETER, "OLD_COMPONENT_TYPE" );
52
53             if( compType.equals( REFERENCE_FREE ) ) { // freie Ref.: keinen Eintrag in PRESENTATION_REFERENCE, gleich speichern
54
if( !oldCompType.equals( "" ) && !oldCompType.equals( compType ) ) {
55                     DTUtils.removeOldContext( evt, oldCompType );
56                 }
57                 DTUtils.updatePresComp(evt);
58             }
59             else if( compType.equals( REFERENCE_TYPED ) ) { // getypte Ref.
60
if( update.equals( "NO_SEL" ) ) {
61                     if( !oldCompType.equals( "" ) && !oldCompType.equals( compType ) ) {
62                         DTUtils.removeOldContext( evt, oldCompType );
63                         DTEditSubPresSelectionHandler.getInstance().handleEvent(evt); // Auswahl ermoeglichen
64
return;
65                     }
66                     else {
67                         DTUtils.updatePresComp(evt); // sub presentation-auswahl hat sich nicht geaendert, also nur in PRESENTATION_COMPONENT updaten
68
}
69                 }
70                 else { // sub presentation-auswahl hat sich geaendert, also erst in PRESENTATION_COMPONENT updaten,
71
// dann in PRESENTATION_REFERENCE...
72
if( !oldCompType.equals( "" ) && !oldCompType.equals( compType ) ) {
73                         DTUtils.removeOldContext( evt, oldCompType );
74                     }
75                     DTUtils.updatePresComp(evt);
76                     DTUtils.updatePresRef(evt);
77                 }
78             }
79             else if( compType.equals( CONTENT ) ) { // Content Components
80
if( formId.equals( "" ) ) { // Auswahl einer FORM_ID in neuer Maske
81
DTUtils.subSelection( evt, TKDBFormGetAll69.class, false );
82                     return;
83                 }
84                 else { // schon FORM_ID ausgewaehlt: update
85
if( !oldCompType.equals( "" ) && !oldCompType.equals( compType ) ) {
86                         DTUtils.removeOldContext( evt, oldCompType );
87                         DTUtils.updatePresComp(evt);
88                         DTUtils.insertPresCont( evt, formId );
89                     }
90                     else {
91                         DTUtils.updatePresComp(evt);
92                         DTUtils.updatePresCont( evt, formId );
93                     }
94                 }
95             }
96             else if( compType.equals( STRUCTURE ) && intType.equals( SINGLE ) ) { // Structure Components
97
if( formId.equals( "" ) ) { // Auswahl einer FORM_ID in neuer Maske
98
DTUtils.subSelection( evt, TKDBFormGetStruct.class, false );
99                     return;
100                 }
101                 else { // schon FORM_ID ausgewaehlt: update
102
if( !oldCompType.equals( "" ) && !oldCompType.equals( compType ) ) {
103                         DTUtils.removeOldContext( evt, oldCompType );
104                         DTUtils.updatePresComp(evt);
105                         DTUtils.insertPresCont( evt, formId );
106                     }
107                     else {
108                         DTUtils.updatePresComp(evt);
109                         DTUtils.updatePresCont( evt, formId );
110                     }
111                 }
112             }
113             DTEditHandler.getInstance().handleEvent(evt);
114         }
115         catch (Throwable JavaDoc e)
116         {
117             // TO DO : Analyze Exception !
118
throw WebmanExceptionHandler.getException(e);
119         }
120     }
121     
122     public boolean isHandler(TKEvent evt)
123     {
124         return evt.getName().equalsIgnoreCase("PR_UPDATE_PRES_COMP") ;
125     }
126 }
127
Popular Tags