1 26 package org.objectweb.util.explorer.core.menu.lib; 27 28 import org.objectweb.util.explorer.core.common.api.Description; 29 import org.objectweb.util.explorer.core.menu.api.AcceleratorDescription; 30 31 39 public class BasicAcceleratorDescription 40 implements AcceleratorDescription 41 { 42 43 49 protected char char_=0; 50 protected boolean ctrlKey_ = false; 51 protected boolean altKey_ = false; 52 protected boolean shiftKey_ = false; 53 protected boolean metaKey_ = false; 54 55 61 67 protected boolean equals(BasicAcceleratorDescription accDesc){ 68 if(accDesc!=null){ 69 return char_==accDesc.char_ 70 && ctrlKey_==accDesc.ctrlKey_ 71 && altKey_==accDesc.altKey_ 72 && shiftKey_==accDesc.shiftKey_ 73 && metaKey_==accDesc.metaKey_; 74 } 75 return false; 76 } 77 78 protected String getStringRepresentation(){ 79 StringBuffer sb = new StringBuffer (); 80 sb.append(ctrlKey_?"ctrl-":""); 81 sb.append(altKey_?"alt-":""); 82 sb.append(shiftKey_?"shift-":""); 83 sb.append(metaKey_?"meta-":""); 84 sb.append(Character.toUpperCase(char_)); 85 return sb.toString(); 86 } 87 88 94 97 public String getDescriptionType() { 98 return Description.ACCELERATOR_DESCRIPTION; 99 } 100 101 104 public boolean isEmpty() { 105 return char_==0; 106 } 107 108 114 115 118 public void setAcceleratorCharacter(char car) { 119 char_ = car; 120 } 121 122 125 public char getAcceleratorCharacter() { 126 return char_; 127 } 128 129 132 public void setCtrlKey(boolean ctrlKey) { 133 ctrlKey_ = ctrlKey; 134 } 135 136 139 public boolean getCtrlKey() { 140 return ctrlKey_; 141 } 142 143 146 public void setAltKey(boolean altKey) { 147 altKey_ = altKey; 148 } 149 150 153 public boolean getAltKey() { 154 return altKey_; 155 } 156 157 160 public void setShiftKey(boolean shiftKey) { 161 shiftKey_ = shiftKey; 162 } 163 164 167 public boolean getShiftKey() { 168 return shiftKey_; 169 } 170 171 174 public void setMetaKey(boolean metaKey) { 175 metaKey_ = metaKey; 176 } 177 178 181 public boolean getMetaKey() { 182 return metaKey_; 183 } 184 185 188 public String getName() { 189 return getStringRepresentation(); 190 } 191 192 198 202 public boolean equals(Object o){ 203 if(o!=null && o instanceof BasicAcceleratorDescription){ 204 return equals((BasicAcceleratorDescription)o); 205 } 206 return false; 207 } 208 209 213 public String toString(){ 214 return "BasicAcceleratorDescription[value=" + getStringRepresentation() + "]"; 215 } 216 217 } 218 219 220 | Popular Tags |