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 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 oldIds = params.get("CONTENT_IDS"); 20 if( oldIds == null ) { 21 String oldData = (String ) 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 contentNodeId = new Integer ( (String )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 e ) { 43 throw new Error ( e.getMessage() ); 44 } 45 46 47 } 48 49 public String getSelectionData( TKHashtable params ) 50 { 51 Object selected = params.get("CONTENT_IDS"); 52 if( selected instanceof TKNull ) return ""; 53 if( selected instanceof String ) return (String ) selected; 54 55 StringBuffer result = new StringBuffer (); 56 Enumeration e = ((TKVector) selected).elements(); 57 result.append( (String ) e.nextElement() ); 58 while( e.hasMoreElements() ) { 59 result.append( ";"+(String ) e.nextElement() ); 60 } 61 return result.toString(); 62 } 63 64 public TKVector doSelection( String 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 ( t.nextToken() ) ); 72 } 73 return result; 74 } 75 } 76 | Popular Tags |