1 11 package org.eclipse.help.internal.webapp.data; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 import java.util.StringTokenizer ; 16 17 21 public class ToolbarButton { 22 private String name; 23 private String tooltip; 24 private String image; 25 private String action; 26 private String param; 27 private String styleClass; 28 private boolean state; 29 private boolean isSeparator; 30 31 public ToolbarButton() { 32 isSeparator = true; 33 } 34 35 public ToolbarButton(String name, String tooltip, String image, 36 String action, String param, String state) { 37 this.name = name; 38 this.tooltip = tooltip; 39 this.image = image; 40 this.action = action; 41 this.param = param; 42 this.state = state.equalsIgnoreCase("on")?true:false; if (state.startsWith("hid")) this.styleClass = "buttonHidden"; else if ("menu".equals(action)) { this.styleClass = "buttonMenu"; } 48 else 49 this.styleClass = state.equalsIgnoreCase("on")?"buttonOn":"button"; } 51 52 public boolean isSeparator() { 53 return isSeparator; 54 } 55 56 public boolean isMenu() { 57 return "menu".equals(action); } 59 60 public String getName() { 61 return name; 62 } 63 64 public String [][] getMenuData() { 65 List list = new ArrayList (); 66 StringTokenizer tok = new StringTokenizer (param, ","); while(tok.hasMoreTokens()) { 68 String token = tok.nextToken(); 69 int index = token.indexOf('='); 70 list.add(new String [] { token.substring(0, index), token.substring(index + 1) }); 71 } 72 return (String [][])list.toArray(new String [list.size()][]); 73 } 74 75 public String getTooltip() { 76 return tooltip; 77 } 78 79 84 public String getImage() { 85 int i = image.lastIndexOf('/'); 86 return image.substring(0, i) + "/e_" + image.substring(i + 1); } 88 89 94 public String getOnImage() { 95 return getImage(); 96 } 97 98 public String getAction() { 99 return action; 100 } 101 102 public String getParam() { 103 return param; 104 } 105 106 public boolean isOn() { 107 return state; 108 } 109 110 public String getStyleClass() { 111 return styleClass; 112 } 113 } 114 | Popular Tags |