1 25 26 package org.snipsnap.snip.label; 27 28 import org.snipsnap.app.Application; 29 import org.snipsnap.container.Components; 30 import org.snipsnap.snip.SnipLink; 31 import org.snipsnap.snip.SnipSpaceFactory; 32 import org.snipsnap.user.AuthenticationService; 33 34 39 public class SnipLabel extends BaseLabel { 40 public SnipLabel() { 41 super(); 42 } 43 44 public SnipLabel(String name, String value) { 45 super(name, value); 46 } 47 48 public String getType() { 49 return "SnipLabel"; 50 } 51 52 public String getInputProxy() { 53 StringBuffer buffer = new StringBuffer (); 54 buffer.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\">"); 55 buffer.append("<tr>"); 56 buffer.append("<td>Name: </td>"); 57 buffer.append("<td><input type=\"text\" value=\""); 58 buffer.append(name); 59 buffer.append("\" name=\"label.name\"/></td>"); 60 buffer.append("</tr><tr>"); 61 buffer.append("<td>Link target (Snip): </td>"); 62 buffer.append("<td><input type=\"text\" value=\""); 63 buffer.append(value); 64 buffer.append("\" name=\"label.value\"/></td>"); 65 buffer.append("</tr></table>"); 66 return buffer.toString(); 67 } 68 69 public String getSnipLink() { 70 return value; 72 } 73 74 public String [] getSnipLinks() { 75 return new String [] { value }; 77 } 78 79 public String getListProxy() { 80 StringBuffer buffer = new StringBuffer (); 81 buffer.append("<td>"); 82 buffer.append(name); 83 buffer.append("</td><td>"); 84 getSnipLink(buffer, value); 85 buffer.append("</td>"); 86 return buffer.toString(); 87 } 88 89 private StringBuffer getSnipLink(StringBuffer buffer, String name) { 90 AuthenticationService service = (AuthenticationService) Components.getComponent(AuthenticationService.class); 92 93 if (SnipSpaceFactory.getInstance().exists(name)) { 94 SnipLink.appendLink(buffer, name, name); 95 } else if (!service.isAuthenticated(Application.get().getUser())) { 96 buffer.append(name); 97 } else { 98 SnipLink.appendCreateLink(buffer, name); 99 } 100 return buffer; 101 } 102 } 103 | Popular Tags |