| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.common.ui.client.widgets.field.layout.element; |
| 17 | |
|
| 18 | |
import org.kuali.student.common.ui.client.application.Application; |
| 19 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.ValidationMessagePanel; |
| 20 | |
import org.kuali.student.common.ui.client.widgets.HasInputWidget; |
| 21 | |
import org.kuali.student.common.ui.client.widgets.HasWatermark; |
| 22 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
| 23 | |
import org.kuali.student.common.ui.client.widgets.KSTitleDescPanel; |
| 24 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton.AbbrButtonType; |
| 25 | |
import org.kuali.student.common.ui.client.widgets.field.layout.layouts.FieldLayoutComponent; |
| 26 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
| 27 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel; |
| 28 | |
|
| 29 | |
import com.google.gwt.user.client.Element; |
| 30 | |
import com.google.gwt.user.client.ui.Composite; |
| 31 | |
import com.google.gwt.user.client.ui.FlowPanel; |
| 32 | |
import com.google.gwt.user.client.ui.HTMLPanel; |
| 33 | |
import com.google.gwt.user.client.ui.Panel; |
| 34 | |
import com.google.gwt.user.client.ui.Widget; |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
public class FieldElement extends Composite implements FieldLayoutComponent{ |
| 68 | |
|
| 69 | |
|
| 70 | 0 | private KSTitleDescPanel titlePanel = new KSTitleDescPanel(); |
| 71 | 0 | private FlowPanel layout = new FlowPanel(); |
| 72 | |
private FieldTitle fieldTitle; |
| 73 | 0 | private SpanPanel instructions = new SpanPanel(); |
| 74 | 0 | private SpanPanel constraints = new SpanPanel(); |
| 75 | 0 | private AbbrPanel required = new AbbrPanel("Required", "ks-form-module-elements-required", " * "); |
| 76 | 0 | private AbbrButton help = new AbbrButton(AbbrButtonType.HELP); |
| 77 | |
private Widget fieldWidget; |
| 78 | 0 | private SpanPanel widgetSpan = new SpanPanel(); |
| 79 | |
private String fieldHTMLId; |
| 80 | 0 | private String watermarkText = null; |
| 81 | 0 | public static enum LineNum{SINGLE, DOUBLE, TRIPLE} |
| 82 | |
|
| 83 | |
private ValidationMessagePanel validationPanel; |
| 84 | |
private String fieldKey; |
| 85 | 0 | private boolean labelShown = true; |
| 86 | |
|
| 87 | |
private Panel parentPanel; |
| 88 | |
private Element parentElement; |
| 89 | |
|
| 90 | 0 | private ErrorLevel status = ErrorLevel.OK; |
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
public void setValidationPanel(ValidationMessagePanel validationPanel) { |
| 99 | 0 | this.validationPanel = validationPanel; |
| 100 | 0 | } |
| 101 | |
|
| 102 | |
|
| 103 | |
public Panel getParentPanel() { |
| 104 | 0 | return parentPanel; |
| 105 | |
} |
| 106 | |
|
| 107 | |
public void setParentPanel(Panel parentPanel) { |
| 108 | 0 | this.parentPanel = parentPanel; |
| 109 | 0 | this.parentElement = parentPanel.getElement(); |
| 110 | 0 | } |
| 111 | |
|
| 112 | |
public void setParentElement(Element element){ |
| 113 | 0 | parentElement = element; |
| 114 | 0 | } |
| 115 | |
|
| 116 | |
private String fieldName; |
| 117 | |
private String instructionText; |
| 118 | |
|
| 119 | |
public String getInstructionText() { |
| 120 | 0 | return instructionText; |
| 121 | |
} |
| 122 | |
|
| 123 | 0 | public FieldElement(String title, Widget widget) { |
| 124 | 0 | generateLayout(title, title, null, null, null, widget); |
| 125 | |
|
| 126 | 0 | } |
| 127 | |
|
| 128 | 0 | public FieldElement(String key, String title, Widget widget){ |
| 129 | 0 | generateLayout(key, title, null, null, null, widget); |
| 130 | 0 | } |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | 0 | public FieldElement(String key, MessageKeyInfo info){ |
| 138 | 0 | init(key, info, null); |
| 139 | 0 | } |
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | 0 | public FieldElement(String key, MessageKeyInfo info, Widget widget){ |
| 148 | 0 | init(key, info, widget); |
| 149 | |
|
| 150 | 0 | } |
| 151 | |
|
| 152 | |
private void init(String key, MessageKeyInfo info, Widget widget){ |
| 153 | 0 | String title = Application.getApplicationContext().getUILabel(info.getGroup(), info.getType(), info.getState(), info.getId()); |
| 154 | |
|
| 155 | 0 | String help = Application.getApplicationContext().getUILabel(info.getGroup(), info.getType(), info.getState(), |
| 156 | |
info.getId() + HELP_MESSAGE_KEY); |
| 157 | 0 | if(help.equals(info.getId() + HELP_MESSAGE_KEY)){ |
| 158 | 0 | help = null; |
| 159 | |
} |
| 160 | |
|
| 161 | 0 | String instructions = Application.getApplicationContext().getUILabel(info.getGroup(), info.getType(), info.getState(), |
| 162 | |
info.getId() + INSTRUCT_MESSAGE_KEY); |
| 163 | 0 | if(instructions.equals(info.getId() + INSTRUCT_MESSAGE_KEY)){ |
| 164 | 0 | instructions = null; |
| 165 | |
} |
| 166 | |
|
| 167 | 0 | String constraints = Application.getApplicationContext().getUILabel(info.getGroup(), info.getType(), info.getState(), |
| 168 | |
info.getId() + CONSTRAINT_MESSAGE_KEY); |
| 169 | 0 | if(constraints.equals(info.getId() + CONSTRAINT_MESSAGE_KEY)){ |
| 170 | 0 | constraints = null; |
| 171 | |
} |
| 172 | |
|
| 173 | 0 | watermarkText = Application.getApplicationContext().getUILabel(info.getGroup(), info.getType(), info.getState(), |
| 174 | |
info.getId() + WATERMARK_MESSAGE_KEY); |
| 175 | 0 | if(watermarkText.equals(info.getId() + WATERMARK_MESSAGE_KEY)){ |
| 176 | 0 | watermarkText = null; |
| 177 | |
} |
| 178 | |
|
| 179 | 0 | generateLayout(key, title, help, instructions, constraints, widget); |
| 180 | 0 | } |
| 181 | |
|
| 182 | |
private void generateLayout(String key, String title, String helpText, String instructText, String constraintText, Widget widget){ |
| 183 | 0 | this.setKey(key); |
| 184 | 0 | fieldName = title; |
| 185 | |
|
| 186 | 0 | fieldHTMLId = HTMLPanel.createUniqueId(); |
| 187 | 0 | fieldTitle = new LabelPanel(title, fieldHTMLId); |
| 188 | |
|
| 189 | 0 | required.setVisible(false); |
| 190 | 0 | fieldTitle.add(required); |
| 191 | 0 | if(helpText != null){ |
| 192 | 0 | this.setHelp(helpText); |
| 193 | |
} |
| 194 | |
else{ |
| 195 | 0 | help.setVisible(false); |
| 196 | |
} |
| 197 | |
|
| 198 | 0 | fieldTitle.add(help); |
| 199 | 0 | layout.add(fieldTitle); |
| 200 | 0 | if(instructText != null){ |
| 201 | 0 | this.setInstructions(instructText); |
| 202 | |
} |
| 203 | |
else{ |
| 204 | 0 | instructions.setVisible(false); |
| 205 | |
} |
| 206 | |
|
| 207 | 0 | if(constraintText != null){ |
| 208 | 0 | this.setConstraintText(constraintText); |
| 209 | |
} |
| 210 | |
else{ |
| 211 | 0 | constraints.setVisible(false); |
| 212 | |
} |
| 213 | 0 | instructions.setStyleName("ks-form-module-elements-instruction"); |
| 214 | 0 | layout.add(instructions); |
| 215 | 0 | layout.add(widgetSpan); |
| 216 | 0 | if(widget != null){ |
| 217 | 0 | this.setWidget(widget); |
| 218 | |
} |
| 219 | 0 | constraints.setStyleName("ks-form-module-elements-help-text"); |
| 220 | 0 | layout.add(constraints); |
| 221 | |
|
| 222 | |
|
| 223 | 0 | initWidget(layout); |
| 224 | 0 | layout.addStyleName("ks-form-module-elements"); |
| 225 | 0 | layout.addStyleName("ks-form-module-single-line-margin"); |
| 226 | 0 | } |
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
public void setWidget(Widget w){ |
| 234 | 0 | if(fieldWidget != null){ |
| 235 | 0 | widgetSpan.remove(fieldWidget); |
| 236 | |
} |
| 237 | 0 | fieldWidget = w; |
| 238 | |
|
| 239 | 0 | if(fieldWidget != null){ |
| 240 | |
|
| 241 | |
|
| 242 | 0 | if(fieldWidget instanceof HasInputWidget){ |
| 243 | 0 | Widget input = ((HasInputWidget)fieldWidget).getInputWidget(); |
| 244 | 0 | if(input != null){ |
| 245 | 0 | if(input instanceof HasWatermark && watermarkText != null){ |
| 246 | 0 | ((HasWatermark)input).setWatermarkText(watermarkText); |
| 247 | |
} |
| 248 | 0 | input.getElement().setAttribute("id", fieldHTMLId); |
| 249 | |
} |
| 250 | |
else{ |
| 251 | 0 | fieldWidget.getElement().setAttribute("id", fieldHTMLId); |
| 252 | |
} |
| 253 | 0 | } |
| 254 | |
else{ |
| 255 | 0 | if(fieldWidget instanceof HasWatermark && watermarkText != null){ |
| 256 | 0 | ((HasWatermark)fieldWidget).setWatermarkText(watermarkText); |
| 257 | |
} |
| 258 | 0 | fieldWidget.getElement().setAttribute("id", fieldHTMLId); |
| 259 | |
} |
| 260 | |
|
| 261 | 0 | widgetSpan.add(fieldWidget); |
| 262 | |
} |
| 263 | 0 | } |
| 264 | |
|
| 265 | |
|
| 266 | |
|
| 267 | |
|
| 268 | |
|
| 269 | |
|
| 270 | |
|
| 271 | |
public void setRequiredString(String requiredKey){ |
| 272 | 0 | String requiredText = Application.getApplicationContext().getMessage(requiredKey); |
| 273 | 0 | required.setText(requiredText); |
| 274 | 0 | required.setVisible(true); |
| 275 | 0 | } |
| 276 | |
|
| 277 | |
public void setRequiredString(String requiredKey, String style){ |
| 278 | 0 | String requiredText = Application.getApplicationContext().getMessage(requiredKey); |
| 279 | 0 | required.setText(requiredText); |
| 280 | 0 | required.setStyleName(style); |
| 281 | 0 | required.setVisible(true); |
| 282 | 0 | } |
| 283 | |
|
| 284 | |
public AbbrPanel getRequiredPanel(){ |
| 285 | 0 | return required; |
| 286 | |
} |
| 287 | |
|
| 288 | |
public void clearRequiredText(){ |
| 289 | 0 | required.setText(""); |
| 290 | 0 | } |
| 291 | |
|
| 292 | |
public Widget getFieldWidget(){ |
| 293 | 0 | return fieldWidget; |
| 294 | |
} |
| 295 | |
|
| 296 | |
public FlowPanel getFieldDetailsLayout(){ |
| 297 | 0 | FlowPanel div = new FlowPanel(); |
| 298 | 0 | div.add(fieldTitle); |
| 299 | 0 | div.add(instructions); |
| 300 | 0 | div.addStyleName("ks-form-module-elements"); |
| 301 | 0 | return div; |
| 302 | |
} |
| 303 | |
|
| 304 | |
public FlowPanel getFieldWidgetAreaLayout(){ |
| 305 | 0 | FlowPanel div = new FlowPanel(); |
| 306 | 0 | div.add(fieldWidget); |
| 307 | 0 | div.add(constraints); |
| 308 | 0 | div.addStyleName("ks-form-module-elements"); |
| 309 | 0 | return div; |
| 310 | |
} |
| 311 | |
|
| 312 | |
public boolean isRequired() { |
| 313 | 0 | return required.isVisible(); |
| 314 | |
} |
| 315 | |
|
| 316 | |
public void setRequired(boolean isRequired){ |
| 317 | 0 | required.setVisible(isRequired); |
| 318 | 0 | } |
| 319 | |
|
| 320 | |
public void setInstructions(String text){ |
| 321 | 0 | instructionText = text; |
| 322 | 0 | if(instructionText != null && !instructionText.trim().equals("")){ |
| 323 | 0 | instructions.setHTML(text); |
| 324 | 0 | instructions.setVisible(true); |
| 325 | |
} |
| 326 | 0 | } |
| 327 | |
|
| 328 | |
public void setConstraintText(String text){ |
| 329 | 0 | if(text != null && !text.trim().equals("")){ |
| 330 | 0 | constraints.setHTML(text); |
| 331 | 0 | constraints.setVisible(true); |
| 332 | |
} |
| 333 | 0 | } |
| 334 | |
|
| 335 | |
public void setHelp(final String html){ |
| 336 | 0 | if(html != null && !html.trim().equals("")){ |
| 337 | 0 | help.setVisible(true); |
| 338 | 0 | help.setHoverHTML(html); |
| 339 | |
|
| 340 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
|
| 345 | |
|
| 346 | |
|
| 347 | |
|
| 348 | |
} |
| 349 | |
else{ |
| 350 | 0 | help.setVisible(false); |
| 351 | |
} |
| 352 | 0 | } |
| 353 | |
|
| 354 | |
public Widget getTitleWidget() { |
| 355 | 0 | return titlePanel.getTitleWidget(); |
| 356 | |
} |
| 357 | |
|
| 358 | |
public ValidationMessagePanel getValidationPanel() { |
| 359 | 0 | return validationPanel; |
| 360 | |
} |
| 361 | |
|
| 362 | |
public Panel getEncapsulatingPanel() { |
| 363 | 0 | return parentPanel; |
| 364 | |
} |
| 365 | |
|
| 366 | |
public String getFieldName() { |
| 367 | 0 | return fieldName; |
| 368 | |
} |
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
|
| 374 | |
|
| 375 | |
public void setErrorState(boolean error){ |
| 376 | 0 | if(error){ |
| 377 | 0 | fieldTitle.addStyleName("invalid"); |
| 378 | 0 | if(parentPanel != null){ |
| 379 | 0 | parentPanel.addStyleName("error"); |
| 380 | |
} |
| 381 | 0 | else if(parentElement != null){ |
| 382 | 0 | parentElement.setClassName("error"); |
| 383 | |
} |
| 384 | |
|
| 385 | 0 | setWarnState(false); |
| 386 | |
} |
| 387 | |
else{ |
| 388 | 0 | fieldTitle.removeStyleName("invalid"); |
| 389 | 0 | if(parentPanel != null){ |
| 390 | 0 | parentPanel.removeStyleName("error"); |
| 391 | |
} |
| 392 | 0 | else if(parentElement != null){ |
| 393 | 0 | parentElement.setClassName(""); |
| 394 | |
} |
| 395 | |
|
| 396 | 0 | setWarnState(validationPanel.hasWarnings()); |
| 397 | |
} |
| 398 | 0 | } |
| 399 | |
|
| 400 | |
|
| 401 | |
|
| 402 | |
|
| 403 | |
|
| 404 | |
|
| 405 | |
public void setWarnState(boolean warn){ |
| 406 | 0 | if(warn){ |
| 407 | |
|
| 408 | 0 | if(parentPanel != null){ |
| 409 | 0 | parentPanel.addStyleName("warning"); |
| 410 | |
} |
| 411 | 0 | else if(parentElement != null){ |
| 412 | 0 | parentElement.setClassName("warning"); |
| 413 | |
} |
| 414 | |
|
| 415 | |
} |
| 416 | |
else{ |
| 417 | |
|
| 418 | 0 | if(parentPanel != null){ |
| 419 | 0 | parentPanel.removeStyleName("warning"); |
| 420 | |
} |
| 421 | 0 | else if(parentElement != null){ |
| 422 | 0 | parentElement.setClassName(""); |
| 423 | |
} |
| 424 | |
} |
| 425 | 0 | } |
| 426 | |
|
| 427 | |
|
| 428 | |
|
| 429 | |
|
| 430 | |
|
| 431 | |
|
| 432 | |
|
| 433 | |
public ErrorLevel processValidationResult(ValidationResultInfo vr) { |
| 434 | |
|
| 435 | 0 | if(getFieldWidget() instanceof ValidationProcessable){ |
| 436 | 0 | if(((ValidationProcessable)getFieldWidget()).shouldProcessValidationResult(vr)){ |
| 437 | 0 | if (fieldName != null && fieldName.trim() != "") |
| 438 | 0 | return ((ValidationProcessable)getFieldWidget()).processValidationResult(vr, fieldName); |
| 439 | |
else |
| 440 | 0 | return ((ValidationProcessable)getFieldWidget()).processValidationResult(vr); |
| 441 | |
} |
| 442 | |
} |
| 443 | |
|
| 444 | 0 | status = ErrorLevel.OK; |
| 445 | |
|
| 446 | 0 | if(vr.getLevel() == ErrorLevel.ERROR){ |
| 447 | 0 | String message = Application.getApplicationContext().getUILabel("validation", vr.getMessage()); |
| 448 | 0 | this.addValidationErrorMessage(message); |
| 449 | |
|
| 450 | 0 | if(status.getLevel() < ErrorLevel.ERROR.getLevel()){ |
| 451 | 0 | status = vr.getLevel(); |
| 452 | |
} |
| 453 | 0 | } |
| 454 | 0 | else if(vr.getLevel() == ErrorLevel.WARN){ |
| 455 | 0 | String message = Application.getApplicationContext().getUILabel("validation", vr.getMessage()); |
| 456 | 0 | this.addValidationWarningMessage(message); |
| 457 | |
|
| 458 | 0 | if(status.getLevel() < ErrorLevel.WARN.getLevel()){ |
| 459 | 0 | status = vr.getLevel(); |
| 460 | |
} |
| 461 | |
} |
| 462 | |
else{ |
| 463 | |
|
| 464 | |
} |
| 465 | 0 | return status; |
| 466 | |
} |
| 467 | |
|
| 468 | |
|
| 469 | |
|
| 470 | |
|
| 471 | |
|
| 472 | |
public void addValidationErrorMessage(String text){ |
| 473 | 0 | if(validationPanel != null){ |
| 474 | |
KSLabel message; |
| 475 | 0 | if(fieldName != null && !fieldName.trim().equals("")){ |
| 476 | 0 | message = new KSLabel(fieldName + " - " + text); |
| 477 | |
} |
| 478 | |
else{ |
| 479 | 0 | message = new KSLabel(text); |
| 480 | |
} |
| 481 | 0 | message.setStyleName("ks-form-error-label"); |
| 482 | 0 | this.setErrorState(true); |
| 483 | 0 | this.validationPanel.addErrorMessage(message); |
| 484 | |
} |
| 485 | 0 | } |
| 486 | |
|
| 487 | |
|
| 488 | |
|
| 489 | |
|
| 490 | |
|
| 491 | |
public void addValidationWarningMessage(String text){ |
| 492 | 0 | if(validationPanel != null){ |
| 493 | 0 | SpanPanel message = new SpanPanel(); |
| 494 | 0 | if(fieldName != null && !fieldName.trim().equals("")){ |
| 495 | 0 | message.setHTML("<b> Warning </b> " + fieldName + " - " + text); |
| 496 | |
} |
| 497 | |
else{ |
| 498 | 0 | message.setHTML("<b> Warning </b> " + text); |
| 499 | |
} |
| 500 | 0 | message.setStyleName("ks-form-warn-label"); |
| 501 | |
|
| 502 | 0 | this.setWarnState((status != ErrorLevel.ERROR)); |
| 503 | 0 | this.validationPanel.addWarnMessage(message); |
| 504 | |
} |
| 505 | 0 | } |
| 506 | |
|
| 507 | |
|
| 508 | |
|
| 509 | |
|
| 510 | |
public void clearValidationErrors(){ |
| 511 | 0 | this.setErrorState(false); |
| 512 | 0 | if(validationPanel != null){ |
| 513 | 0 | this.validationPanel.clearErrors(); |
| 514 | |
} |
| 515 | |
|
| 516 | |
|
| 517 | 0 | if(getFieldWidget() instanceof ValidationProcessable){ |
| 518 | 0 | ((ValidationProcessable)getFieldWidget()).clearValidationErrors(); |
| 519 | |
} |
| 520 | 0 | } |
| 521 | |
|
| 522 | |
|
| 523 | |
|
| 524 | |
|
| 525 | |
public void clearValidationWarnings(){ |
| 526 | 0 | this.setWarnState(false); |
| 527 | 0 | if(validationPanel != null){ |
| 528 | 0 | this.validationPanel.clearWarnings(); |
| 529 | |
} |
| 530 | |
|
| 531 | |
|
| 532 | 0 | if(getFieldWidget() instanceof ValidationProcessable){ |
| 533 | 0 | ((ValidationProcessable)getFieldWidget()).clearValidationWarnings(); |
| 534 | |
} |
| 535 | 0 | } |
| 536 | |
|
| 537 | |
@Override |
| 538 | |
public String getKey() { |
| 539 | 0 | return fieldKey; |
| 540 | |
} |
| 541 | |
|
| 542 | |
@Override |
| 543 | |
public void setKey(String key) { |
| 544 | 0 | if(key == null){ |
| 545 | |
|
| 546 | 0 | key = HTMLPanel.createUniqueId(); |
| 547 | |
} |
| 548 | 0 | this.fieldKey = key; |
| 549 | 0 | } |
| 550 | |
|
| 551 | |
|
| 552 | |
|
| 553 | |
|
| 554 | |
|
| 555 | |
|
| 556 | |
public void setTitleDescLineHeight(LineNum margin) { |
| 557 | 0 | layout.removeStyleName("ks-form-module-single-line-margin"); |
| 558 | 0 | switch(margin){ |
| 559 | |
case TRIPLE: |
| 560 | 0 | if(firstLineExists() && secondLineExists()){ |
| 561 | 0 | layout.addStyleName("ks-form-module-single-line-margin"); |
| 562 | |
} |
| 563 | 0 | else if((firstLineExists() || secondLineExists())){ |
| 564 | 0 | layout.addStyleName("ks-form-module-double-line-margin"); |
| 565 | |
} |
| 566 | |
else{ |
| 567 | 0 | layout.addStyleName("ks-form-module-triple-line-margin"); |
| 568 | |
} |
| 569 | |
|
| 570 | 0 | break; |
| 571 | |
case DOUBLE: |
| 572 | 0 | if((firstLineExists() || secondLineExists())){ |
| 573 | 0 | layout.addStyleName("ks-form-module-single-line-margin"); |
| 574 | |
} |
| 575 | |
else{ |
| 576 | 0 | layout.addStyleName("ks-form-module-double-line-margin"); |
| 577 | |
} |
| 578 | 0 | break; |
| 579 | |
case SINGLE: |
| 580 | 0 | layout.addStyleName("ks-form-module-single-line-margin"); |
| 581 | |
break; |
| 582 | |
} |
| 583 | |
|
| 584 | 0 | } |
| 585 | |
|
| 586 | |
private boolean firstLineExists(){ |
| 587 | 0 | boolean exists = false; |
| 588 | 0 | if((fieldName != null && !fieldName.equals("")) || required.isVisible() || help.isVisible()){ |
| 589 | 0 | exists = true; |
| 590 | |
} |
| 591 | 0 | return exists; |
| 592 | |
} |
| 593 | |
|
| 594 | |
private boolean secondLineExists(){ |
| 595 | 0 | boolean exists = false; |
| 596 | 0 | if(instructions.isVisible()){ |
| 597 | 0 | exists = true; |
| 598 | |
} |
| 599 | 0 | return exists; |
| 600 | |
} |
| 601 | |
|
| 602 | |
|
| 603 | |
|
| 604 | |
|
| 605 | |
public void hideLabel() { |
| 606 | 0 | layout.removeStyleName("ks-form-module-double-line-margin"); |
| 607 | 0 | layout.removeStyleName("ks-form-module-triple-line-margin"); |
| 608 | 0 | layout.addStyleName("ks-form-module-single-line-margin"); |
| 609 | 0 | fieldTitle.setStyleName("accessibility-hidden"); |
| 610 | 0 | instructions.setVisible(false); |
| 611 | 0 | labelShown = false; |
| 612 | 0 | } |
| 613 | |
|
| 614 | |
public boolean isLabelShown(){ |
| 615 | 0 | return labelShown; |
| 616 | |
} |
| 617 | |
} |