1 17 18 package org.objectweb.jac.aspects.gui.web; 19 20 import org.objectweb.jac.aspects.gui.*; 21 import org.objectweb.jac.core.rtti.CollectionItem; 22 import java.io.IOException ; 23 import java.io.PrintWriter ; 24 25 30 public class ChoiceCollection 31 extends AbstractCollection 32 implements HTMLViewer 33 { 34 35 int oldSelected = -1; 36 ObjectView objectView = null; 37 38 public ChoiceCollection( 39 ViewFactory factory, 40 DisplayContext context, 41 CollectionItem collection, 42 Object substance, 43 ComboBoxModel model, 44 org.objectweb.jac.aspects.gui.CollectionItemView itemView) 45 { 46 super(factory, context, collection, substance, model, itemView); 47 } 48 51 public void sort() { 52 54 } 55 56 public void genHTML(PrintWriter out) throws IOException { 57 out.println("<div class=BORDER_LINE>"); 58 out.print(GuiAC.getLabel(collection) + " : "); 59 out.print("<select name=\"index_" + getId() + "\""); 60 printAttributes(out); 61 out.println(">"); 62 63 for (int i = 0; i < model.getRowCount(); i++) { 64 65 String label = GuiAC.toString(model.getObject(i)); 66 out.println( 67 "<option" 68 + (i == selected ? " selected" : "") 69 + " value=\"" + i + "\">" 70 + label 71 + "</OPTION>"); 72 } 73 out.println("</SELECT>"); 74 75 JacRequest request = WebDisplay.getRequest(); 76 77 if (request.isIEUserAgent()) { 78 out.println( 79 "<table class=\"method\"><tr><td>" 80 + iconElement( 81 ResourceManager.getResource("view_icon"), 82 "view") 83 + eventURL("view", "onView", "") 84 + "</td></tr></table>"); 85 } else { 86 out.println( 87 "<span class=\"method\">" 88 + iconElement( 89 ResourceManager.getResource("view_icon"), 90 "view") 91 + eventURL("View", "onView", "") 92 + "</span>"); 93 } 94 95 genHeader(out, false); 96 97 101 out.println("</div>"); 102 103 if (!GuiAC.isExternalChoiceView(collection)) { 104 if (selected != -1) { 105 if (objectView == null || oldSelected != selected) { 106 Object selectedObject = model.getObject(selected); 107 objectView = 108 (ObjectView) getFactory().createObjectView( 109 GuiAC.toString(selectedObject), 110 selectedObject, 111 getContext()); 112 } 113 objectView.genHTML(out); 114 } 115 oldSelected = selected; 116 } 117 } 118 119 } 120 | Popular Tags |