KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > webman > contsel > TKWMSpecificCS


1 package com.teamkonzept.webman.contsel;
2
3 import com.teamkonzept.webman.*;
4 import com.teamkonzept.webman.mainint.*;
5 import de.webman.content.eventhandler.CEUtils;
6 import com.teamkonzept.web.*;
7 import com.teamkonzept.lib.*;
8
9 import java.util.*;
10
11 public class TKWMSpecificCS implements TKWMContentSelector {
12
13     public void modifySelection( TKHTMLTemplate t, String JavaDoc action, TKHashtable params )
14     {
15         t.set( "SEL_TYPE", params.get("SEL_TYPE") );
16         t.set( "RES_TYPE", params.get("RES_TYPE") );
17         t.set( "NODE_ID", params.get("NODE_ID") );
18
19         Object JavaDoc oldIds = params.get("CONTENT_IDS");
20         if( oldIds == null ) {
21             String JavaDoc oldData = (String JavaDoc) params.get("SEL_DATA");
22             if( oldData != null && oldData.length() > 0 ) {
23                 TKVector newIds = new TKVector();
24                 StringTokenizer st = new StringTokenizer( oldData, ";" );
25                 while( st.hasMoreTokens() ) {
26                     newIds.addElement( st.nextToken() );
27                 }
28                 oldIds = newIds;
29             }
30         }
31         
32         if( oldIds != null )
33             t.set( "CONTENT_IDS", oldIds );
34             
35         Integer JavaDoc contentNodeId = new Integer JavaDoc( (String JavaDoc)params.get("NODE_ID") );
36         try {
37             TKVector vec = CEUtils.getFilteredInstances (contentNodeId.intValue(),null);
38
39             t.setListIterator( new TKStandardPluginIterator
40                 ("CONTENTS",null,vec,false, t.getListIterator()));
41         }
42         catch( Throwable JavaDoc e ) {
43             throw new Error JavaDoc( e.getMessage() );
44         }
45         
46         
47     }
48     
49     public String JavaDoc getSelectionData( TKHashtable params )
50     {
51         Object JavaDoc selected = params.get("CONTENT_IDS");
52         if( selected instanceof TKNull ) return "";
53         if( selected instanceof String JavaDoc ) return (String JavaDoc) selected;
54         
55         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
56         Enumeration e = ((TKVector) selected).elements();
57         result.append( (String JavaDoc) e.nextElement() );
58         while( e.hasMoreElements() ) {
59             result.append( ";"+(String JavaDoc) e.nextElement() );
60         }
61         return result.toString();
62     }
63     
64     public TKVector doSelection( String JavaDoc selectionData, int contentNodeId )
65     {
66         TKVector result = new TKVector();
67         if( selectionData == null || selectionData.length() == 0 ) return result;
68         
69         StringTokenizer t = new StringTokenizer( selectionData, ";" );
70         while( t.hasMoreTokens() ) {
71             result.addElement( new Integer JavaDoc( t.nextToken() ) );
72         }
73         return result;
74     }
75 }
76
Popular Tags