| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.common.ui.client.configurable.mvc.sections; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.HashSet; |
| 20 | |
import java.util.List; |
| 21 | |
|
| 22 | |
import org.kuali.student.common.assembly.data.Data; |
| 23 | |
import org.kuali.student.common.assembly.data.Data.Key; |
| 24 | |
import org.kuali.student.common.assembly.data.QueryPath; |
| 25 | |
import org.kuali.student.common.ui.client.application.Application; |
| 26 | |
import org.kuali.student.common.ui.client.configurable.mvc.CanProcessValidationResults; |
| 27 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
| 28 | |
import org.kuali.student.common.ui.client.configurable.mvc.LayoutController; |
| 29 | |
import org.kuali.student.common.ui.client.configurable.mvc.ValidationEventBinding; |
| 30 | |
import org.kuali.student.common.ui.client.configurable.mvc.ValidationEventBindingImpl; |
| 31 | |
import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding; |
| 32 | |
import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBindingSupport; |
| 33 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityComposite; |
| 34 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityGroup; |
| 35 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityGroupItem; |
| 36 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityItem; |
| 37 | |
import org.kuali.student.common.ui.client.event.ContentDirtyEvent; |
| 38 | |
import org.kuali.student.common.ui.client.event.ValidateRequestEvent; |
| 39 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
| 40 | |
import org.kuali.student.common.ui.client.mvc.Controller; |
| 41 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
| 42 | |
import org.kuali.student.common.ui.client.mvc.HasCrossConstraints; |
| 43 | |
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
| 44 | |
import org.kuali.student.common.ui.client.mvc.View; |
| 45 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrPanel; |
| 46 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.FieldElement; |
| 47 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel; |
| 48 | |
import org.kuali.student.common.ui.client.widgets.field.layout.layouts.FieldLayout; |
| 49 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
| 50 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel; |
| 51 | |
|
| 52 | |
import com.google.gwt.core.client.GWT; |
| 53 | |
import com.google.gwt.user.client.ui.Widget; |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | 0 | public abstract class BaseSection extends SpanPanel implements Section{ |
| 61 | |
|
| 62 | |
protected FieldLayout layout; |
| 63 | |
|
| 64 | 0 | protected ArrayList<Section> sections = new ArrayList<Section>(); |
| 65 | 0 | protected ArrayList<FieldDescriptor> fields = new ArrayList<FieldDescriptor>(); |
| 66 | 0 | protected LayoutController layoutController = null; |
| 67 | 0 | protected boolean isValidationEnabled = true; |
| 68 | 0 | protected boolean isDirty = false; |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
@Override |
| 83 | |
public String addField(final FieldDescriptor fieldDescriptor) { |
| 84 | 0 | String key = null; |
| 85 | |
|
| 86 | 0 | if (fieldDescriptor.isVisible()){ |
| 87 | 0 | fields.add(fieldDescriptor); |
| 88 | 0 | key = layout.addField(fieldDescriptor.getFieldElement()); |
| 89 | |
|
| 90 | 0 | ValidationEventBinding binding = new ValidationEventBindingImpl(); |
| 91 | 0 | if(fieldDescriptor.getValidationRequestCallback()== null){ |
| 92 | 0 | fieldDescriptor.setValidationCallBack(new Callback<Boolean>() { |
| 93 | |
@Override |
| 94 | |
public void exec(Boolean result) { |
| 95 | 0 | final ModelWidgetBinding mwb = fieldDescriptor.getModelWidgetBinding(); |
| 96 | 0 | if (mwb != null) { |
| 97 | 0 | final Widget w = fieldDescriptor.getFieldWidget(); |
| 98 | 0 | final String modelId = fieldDescriptor.getModelId(); |
| 99 | |
final Controller parent; |
| 100 | 0 | Controller findResult = LayoutController.findParentLayout(w); |
| 101 | 0 | if(BaseSection.this instanceof View){ |
| 102 | 0 | findResult = ((View)BaseSection.this).getController(); |
| 103 | |
} |
| 104 | 0 | parent = findResult; |
| 105 | 0 | if(parent != null){ |
| 106 | 0 | if (modelId == null) { |
| 107 | 0 | parent.requestModel(new ModelRequestCallback<DataModel>() { |
| 108 | |
|
| 109 | |
@Override |
| 110 | |
public void onModelReady(DataModel model) { |
| 111 | 0 | validateField(fieldDescriptor, model, parent); |
| 112 | |
|
| 113 | |
|
| 114 | 0 | HashSet<HasCrossConstraints> fds = Application.getApplicationContext().getCrossConstraint(null, Application.getApplicationContext().getParentPath()+fieldDescriptor.getFieldKey()); |
| 115 | 0 | if(fds!=null){ |
| 116 | 0 | for(HasCrossConstraints fd:fds){ |
| 117 | 0 | fd.reprocessWithUpdatedConstraints(); |
| 118 | |
} |
| 119 | |
} |
| 120 | 0 | } |
| 121 | |
|
| 122 | |
@Override |
| 123 | |
public void onRequestFail(Throwable cause) { |
| 124 | 0 | GWT.log("Unable to retrieve model to validate " + fieldDescriptor.getFieldKey(), null); |
| 125 | 0 | } |
| 126 | |
|
| 127 | |
}); |
| 128 | |
} else { |
| 129 | 0 | parent.requestModel(modelId, new ModelRequestCallback<DataModel>() { |
| 130 | |
|
| 131 | |
@Override |
| 132 | |
public void onModelReady(DataModel model) { |
| 133 | 0 | validateField(fieldDescriptor, model, parent); |
| 134 | 0 | } |
| 135 | |
|
| 136 | |
@Override |
| 137 | |
public void onRequestFail(Throwable cause) { |
| 138 | 0 | GWT.log("Unable to retrieve model to validate " + fieldDescriptor.getFieldKey(), null); |
| 139 | 0 | } |
| 140 | |
|
| 141 | |
}); } |
| 142 | |
} |
| 143 | 0 | } else { |
| 144 | 0 | GWT.log(fieldDescriptor.getFieldKey() + " has no widget binding.", null); |
| 145 | |
} |
| 146 | 0 | } |
| 147 | |
}); |
| 148 | |
} |
| 149 | 0 | binding.bind(fieldDescriptor); |
| 150 | |
} |
| 151 | |
|
| 152 | 0 | return key; |
| 153 | |
} |
| 154 | |
|
| 155 | |
private void validateField( |
| 156 | |
final FieldDescriptor fieldDescriptor, final DataModel model, Controller controller) { |
| 157 | 0 | Widget w = fieldDescriptor.getFieldWidget(); |
| 158 | 0 | ModelWidgetBinding mwb = fieldDescriptor.getModelWidgetBinding(); |
| 159 | 0 | if(fieldDescriptor.getFieldKey() != null){ |
| 160 | 0 | mwb.setModelValue(w, model, fieldDescriptor.getFieldKey()); |
| 161 | 0 | dirtyCheckField(fieldDescriptor, model); |
| 162 | 0 | ValidateRequestEvent e = new ValidateRequestEvent(); |
| 163 | 0 | e.setFieldDescriptor(fieldDescriptor); |
| 164 | 0 | e.setValidateSingleField(true); |
| 165 | 0 | controller.fireApplicationEvent(e); |
| 166 | |
} |
| 167 | 0 | } |
| 168 | |
|
| 169 | |
private void dirtyCheckField(FieldDescriptor fieldDescriptor, DataModel model){ |
| 170 | 0 | QueryPath fieldPath = QueryPath.parse(fieldDescriptor.getFieldKey()); |
| 171 | 0 | QueryPath qPathDirty = fieldPath.subPath(0, fieldPath.size() - 1); |
| 172 | 0 | qPathDirty.add(ModelWidgetBindingSupport.RUNTIME_ROOT); |
| 173 | 0 | qPathDirty.add(ModelWidgetBindingSupport.DIRTY_PATH); |
| 174 | 0 | qPathDirty.add(fieldPath.get(fieldPath.size()-1)); |
| 175 | 0 | Boolean dirty = false; |
| 176 | |
|
| 177 | 0 | if(ensureDirtyFlagPath(model.getRoot(), qPathDirty)){ |
| 178 | 0 | dirty = model.get(qPathDirty); |
| 179 | |
} |
| 180 | 0 | if(dirty){ |
| 181 | 0 | setIsDirty(true); |
| 182 | 0 | fieldDescriptor.setDirty(true); |
| 183 | |
} |
| 184 | 0 | } |
| 185 | |
|
| 186 | |
protected boolean ensureDirtyFlagPath(Data root, QueryPath path) { |
| 187 | 0 | Data current = root; |
| 188 | 0 | boolean containsFlag = false; |
| 189 | 0 | for (int i = 0; i < path.size(); i++) { |
| 190 | 0 | Key key = path.get(i); |
| 191 | 0 | if(i == path.size() - 1){ |
| 192 | 0 | containsFlag = current.containsKey(key); |
| 193 | 0 | break; |
| 194 | |
} |
| 195 | 0 | Data d = current.get(key); |
| 196 | 0 | if (d == null) { |
| 197 | 0 | containsFlag = false; |
| 198 | 0 | break; |
| 199 | |
} |
| 200 | 0 | current = d; |
| 201 | |
} |
| 202 | 0 | return containsFlag; |
| 203 | |
} |
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
@Override |
| 211 | |
public String addSection(Section section) { |
| 212 | |
|
| 213 | 0 | section.setLayoutController(layoutController); |
| 214 | 0 | sections.add(section); |
| 215 | 0 | String key = layout.addLayout(section.getLayout()); |
| 216 | 0 | return key; |
| 217 | |
} |
| 218 | |
|
| 219 | |
|
| 220 | |
|
| 221 | |
|
| 222 | |
|
| 223 | |
|
| 224 | |
@Override |
| 225 | |
public void removeSection(Section section){ |
| 226 | 0 | sections.remove(section); |
| 227 | 0 | layout.removeLayoutElement(section.getLayout()); |
| 228 | 0 | } |
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
protected void clearValidation() { |
| 235 | 0 | layout.clearValidation(); |
| 236 | |
|
| 237 | 0 | } |
| 238 | |
|
| 239 | |
|
| 240 | |
|
| 241 | |
|
| 242 | |
|
| 243 | |
|
| 244 | |
@Override |
| 245 | |
public List<FieldDescriptor> getFields() { |
| 246 | 0 | List<FieldDescriptor> allFields = new ArrayList<FieldDescriptor>(); |
| 247 | 0 | allFields.addAll(fields); |
| 248 | |
|
| 249 | 0 | for(Section ns: sections){ |
| 250 | 0 | allFields.addAll(ns.getFields()); |
| 251 | |
} |
| 252 | 0 | return allFields; |
| 253 | |
} |
| 254 | |
|
| 255 | |
|
| 256 | |
|
| 257 | |
|
| 258 | |
|
| 259 | |
@Override |
| 260 | |
public List<FieldDescriptor> getUnnestedFields() { |
| 261 | 0 | return fields; |
| 262 | |
} |
| 263 | |
|
| 264 | |
|
| 265 | |
|
| 266 | |
|
| 267 | |
|
| 268 | |
@Override |
| 269 | |
public List<Section> getSections() { |
| 270 | 0 | return sections; |
| 271 | |
} |
| 272 | |
|
| 273 | |
|
| 274 | |
|
| 275 | |
|
| 276 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
@Override |
| 280 | |
public ErrorLevel processValidationResults(List<ValidationResultInfo> results, boolean clearAllValidation){ |
| 281 | 0 | if(clearAllValidation){ |
| 282 | 0 | this.clearValidation(); |
| 283 | |
} |
| 284 | 0 | ErrorLevel status = ErrorLevel.OK; |
| 285 | |
|
| 286 | 0 | if (isValidationEnabled){ |
| 287 | |
|
| 288 | 0 | for(FieldDescriptor f: this.fields){ |
| 289 | |
|
| 290 | 0 | if(f.hasHadFocus()){ |
| 291 | 0 | for(ValidationResultInfo vr: results){ |
| 292 | 0 | String vrElement = vr.getElement(); |
| 293 | 0 | if(vrElement.startsWith("/")){ |
| 294 | 0 | vrElement = vrElement.substring(1); |
| 295 | |
} |
| 296 | 0 | if(vrElement.equals(f.getFieldKey())){ |
| 297 | 0 | FieldElement element = f.getFieldElement(); |
| 298 | 0 | if (element != null){ |
| 299 | 0 | ErrorLevel fieldStatus = element.processValidationResult(vr); |
| 300 | 0 | if(fieldStatus.getLevel() > status.getLevel()){ |
| 301 | 0 | status = fieldStatus; |
| 302 | |
} |
| 303 | |
} |
| 304 | |
} |
| 305 | 0 | } |
| 306 | |
} |
| 307 | |
|
| 308 | 0 | if(f.getFieldWidget() instanceof MultiplicityComposite ){ |
| 309 | 0 | MultiplicityComposite mc = (MultiplicityComposite) f.getFieldWidget(); |
| 310 | |
|
| 311 | |
|
| 312 | 0 | for(MultiplicityItem item: mc.getItems()){ |
| 313 | 0 | if(item.getItemWidget() instanceof Section && !item.isDeleted()){ |
| 314 | 0 | ErrorLevel fieldStatus = ((Section)item.getItemWidget()).processValidationResults(results, clearAllValidation); |
| 315 | 0 | if(fieldStatus.getLevel() > status.getLevel()){ |
| 316 | 0 | status = fieldStatus; |
| 317 | |
} |
| 318 | 0 | } |
| 319 | |
} |
| 320 | |
} |
| 321 | |
|
| 322 | 0 | if(f.getFieldWidget() instanceof MultiplicityGroup ){ |
| 323 | 0 | MultiplicityGroup mg = (MultiplicityGroup) f.getFieldWidget(); |
| 324 | |
|
| 325 | |
|
| 326 | 0 | for(MultiplicityGroupItem item: mg.getItems()){ |
| 327 | 0 | if(item.getItemWidget() instanceof Section && !item.isDeleted()){ |
| 328 | 0 | ErrorLevel fieldStatus = ((Section)item.getItemWidget()).processValidationResults(results, clearAllValidation); |
| 329 | 0 | if(fieldStatus.getLevel() > status.getLevel()){ |
| 330 | 0 | status = fieldStatus; |
| 331 | |
} |
| 332 | 0 | } |
| 333 | |
} |
| 334 | |
} |
| 335 | 0 | if (f.getFieldWidget() instanceof CanProcessValidationResults) { |
| 336 | 0 | ErrorLevel fieldStatus = ((CanProcessValidationResults) f.getFieldWidget()).processValidationResults(f, results, clearAllValidation); |
| 337 | 0 | if (fieldStatus.getLevel() > status.getLevel()) { |
| 338 | 0 | status = fieldStatus; |
| 339 | |
} |
| 340 | 0 | } |
| 341 | |
} |
| 342 | |
|
| 343 | 0 | for(Section s: sections){ |
| 344 | 0 | ErrorLevel subsectionStatus = s.processValidationResults(results,clearAllValidation); |
| 345 | 0 | if(subsectionStatus.getLevel() > status.getLevel()){ |
| 346 | 0 | status = subsectionStatus; |
| 347 | |
} |
| 348 | 0 | } |
| 349 | |
} |
| 350 | |
|
| 351 | 0 | return status; |
| 352 | |
} |
| 353 | |
|
| 354 | |
|
| 355 | |
|
| 356 | |
|
| 357 | |
|
| 358 | |
@Override |
| 359 | |
public ErrorLevel processValidationResults(List<ValidationResultInfo> results) { |
| 360 | 0 | return processValidationResults(results, true); |
| 361 | |
} |
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | |
|
| 366 | |
|
| 367 | |
|
| 368 | |
@Override |
| 369 | |
public LayoutController getLayoutController() { |
| 370 | 0 | return this.layoutController; |
| 371 | |
} |
| 372 | |
|
| 373 | |
@Override |
| 374 | |
public void setLayoutController(LayoutController controller) { |
| 375 | 0 | this.layoutController = controller; |
| 376 | 0 | } |
| 377 | |
|
| 378 | |
|
| 379 | |
|
| 380 | |
|
| 381 | |
|
| 382 | |
|
| 383 | |
@Override |
| 384 | |
public String addWidget(Widget w) { |
| 385 | 0 | return layout.addWidget(w); |
| 386 | |
} |
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | |
|
| 391 | |
|
| 392 | |
|
| 393 | |
|
| 394 | |
public void setFieldHasHadFocusFlags(boolean hadFocus) { |
| 395 | 0 | for(FieldDescriptor f: fields){ |
| 396 | 0 | f.setHasHadFocus(hadFocus); |
| 397 | 0 | if(f.getFieldWidget() instanceof MultiplicityComposite){ |
| 398 | 0 | MultiplicityComposite mc = (MultiplicityComposite) f.getFieldWidget(); |
| 399 | |
|
| 400 | 0 | for(MultiplicityItem item: mc.getItems()){ |
| 401 | 0 | if(item.getItemWidget() instanceof Section && !item.isDeleted()){ |
| 402 | 0 | ((Section) item.getItemWidget()).setFieldHasHadFocusFlags(hadFocus); |
| 403 | |
} |
| 404 | |
} |
| 405 | 0 | }else if(f.getFieldWidget() instanceof MultiplicityGroup){ |
| 406 | 0 | MultiplicityGroup mg = (MultiplicityGroup) f.getFieldWidget(); |
| 407 | |
|
| 408 | 0 | for(MultiplicityGroupItem item: mg.getItems()){ |
| 409 | 0 | if(item.getItemWidget() instanceof Section && !item.isDeleted()){ |
| 410 | 0 | ((Section) item.getItemWidget()).setFieldHasHadFocusFlags(hadFocus); |
| 411 | |
} |
| 412 | |
} |
| 413 | 0 | } |
| 414 | |
} |
| 415 | |
|
| 416 | 0 | for(Section s: sections){ |
| 417 | 0 | s.setFieldHasHadFocusFlags(hadFocus); |
| 418 | |
} |
| 419 | |
|
| 420 | 0 | } |
| 421 | |
|
| 422 | |
|
| 423 | |
|
| 424 | |
|
| 425 | |
|
| 426 | |
@Override |
| 427 | |
public void enableValidation(boolean enableValidation) { |
| 428 | 0 | this.isValidationEnabled = enableValidation; |
| 429 | 0 | } |
| 430 | |
|
| 431 | |
@Override |
| 432 | |
public boolean isValidationEnabled() { |
| 433 | 0 | return isValidationEnabled; |
| 434 | |
} |
| 435 | |
|
| 436 | |
|
| 437 | |
|
| 438 | |
|
| 439 | |
|
| 440 | |
|
| 441 | |
|
| 442 | |
@Override |
| 443 | |
public void updateModel(DataModel model){ |
| 444 | 0 | SectionBinding.INSTANCE.setModelValue(this, model, ""); |
| 445 | 0 | } |
| 446 | |
|
| 447 | |
|
| 448 | |
|
| 449 | |
|
| 450 | |
|
| 451 | |
|
| 452 | |
|
| 453 | |
|
| 454 | |
|
| 455 | |
@Override |
| 456 | |
public void updateWidgetData(DataModel model) { |
| 457 | 0 | SectionBinding.INSTANCE.setWidgetValue(this, model, ""); |
| 458 | 0 | } |
| 459 | |
|
| 460 | |
|
| 461 | |
|
| 462 | |
|
| 463 | |
|
| 464 | |
@Override |
| 465 | |
public void resetFieldInteractionFlags() { |
| 466 | 0 | this.isDirty = false; |
| 467 | 0 | for(FieldDescriptor f: fields){ |
| 468 | 0 | f.setDirty(false); |
| 469 | 0 | f.setHasHadFocus(false); |
| 470 | |
} |
| 471 | |
|
| 472 | 0 | for(Section s: sections){ |
| 473 | 0 | s.resetFieldInteractionFlags(); |
| 474 | |
} |
| 475 | |
|
| 476 | 0 | } |
| 477 | |
|
| 478 | |
@Override |
| 479 | |
public void resetDirtyFlags() { |
| 480 | 0 | this.isDirty = false; |
| 481 | 0 | for(FieldDescriptor f: fields){ |
| 482 | 0 | f.setDirty(false); |
| 483 | |
} |
| 484 | |
|
| 485 | 0 | for(Section s: sections){ |
| 486 | 0 | s.resetDirtyFlags(); |
| 487 | |
} |
| 488 | 0 | } |
| 489 | |
|
| 490 | |
|
| 491 | |
|
| 492 | |
|
| 493 | |
|
| 494 | |
|
| 495 | |
|
| 496 | |
@Override |
| 497 | |
public String addSection(String key, Section section) { |
| 498 | 0 | sections.add(section); |
| 499 | 0 | section.getLayout().setKey(key); |
| 500 | 0 | String rkey = layout.addLayout(section.getLayout()); |
| 501 | 0 | return rkey; |
| 502 | |
} |
| 503 | |
|
| 504 | |
@Override |
| 505 | |
public FieldDescriptor getField(String fieldKey) { |
| 506 | 0 | for(FieldDescriptor f: fields){ |
| 507 | 0 | if(f.getFieldKey().equals(fieldKey)){ |
| 508 | 0 | return f; |
| 509 | |
} |
| 510 | |
} |
| 511 | 0 | return null; |
| 512 | |
} |
| 513 | |
|
| 514 | |
|
| 515 | |
|
| 516 | |
|
| 517 | |
|
| 518 | |
|
| 519 | |
|
| 520 | |
@Override |
| 521 | |
public FieldLayout getLayout() { |
| 522 | 0 | return layout; |
| 523 | |
} |
| 524 | |
|
| 525 | |
@Override |
| 526 | |
public Section getSection(String sectionKey) { |
| 527 | 0 | for(Section s: sections){ |
| 528 | 0 | if(s.getLayout().getKey().equals(sectionKey)){ |
| 529 | 0 | return s; |
| 530 | |
} |
| 531 | |
} |
| 532 | 0 | return null; |
| 533 | |
} |
| 534 | |
|
| 535 | |
@Override |
| 536 | |
public void removeField(String fieldKey) { |
| 537 | 0 | int index = 0; |
| 538 | 0 | boolean found = false; |
| 539 | 0 | for(FieldDescriptor f: fields){ |
| 540 | 0 | if(f.getFieldKey().equals(fieldKey)){ |
| 541 | 0 | index = fields.indexOf(f); |
| 542 | 0 | found = true; |
| 543 | 0 | break; |
| 544 | |
} |
| 545 | |
} |
| 546 | 0 | if(found){ |
| 547 | 0 | fields.remove(index); |
| 548 | |
} |
| 549 | 0 | layout.removeLayoutElement(fieldKey); |
| 550 | |
|
| 551 | 0 | } |
| 552 | |
|
| 553 | |
@Override |
| 554 | |
public void removeField(FieldDescriptor field) { |
| 555 | |
|
| 556 | 0 | fields.remove(field); |
| 557 | 0 | layout.removeLayoutElement(field.getFieldKey()); |
| 558 | |
|
| 559 | 0 | } |
| 560 | |
|
| 561 | |
@Override |
| 562 | |
public void removeSection(String sectionKey) { |
| 563 | 0 | int index = 0; |
| 564 | 0 | boolean found = false; |
| 565 | 0 | for(Section s: sections){ |
| 566 | 0 | if(s.getLayout().getKey().equals(sectionKey)){ |
| 567 | 0 | index = sections.indexOf(s); |
| 568 | 0 | found = true; |
| 569 | 0 | break; |
| 570 | |
} |
| 571 | |
} |
| 572 | 0 | if(found){ |
| 573 | 0 | sections.remove(index); |
| 574 | |
} |
| 575 | 0 | layout.removeLayoutElement(sectionKey); |
| 576 | |
|
| 577 | 0 | } |
| 578 | |
|
| 579 | |
@Override |
| 580 | |
public void removeWidget(Widget widget) { |
| 581 | 0 | layout.removeLayoutElement(widget); |
| 582 | |
|
| 583 | 0 | } |
| 584 | |
|
| 585 | |
@Override |
| 586 | |
public void removeWidget(String key) { |
| 587 | 0 | layout.removeLayoutElement(key); |
| 588 | |
|
| 589 | 0 | } |
| 590 | |
|
| 591 | |
|
| 592 | |
|
| 593 | |
|
| 594 | |
|
| 595 | |
|
| 596 | |
|
| 597 | |
public boolean isDirty(){ |
| 598 | 0 | if(!this.isDirty){ |
| 599 | |
|
| 600 | 0 | for(Section s: sections){ |
| 601 | 0 | if(s.isDirty()){ |
| 602 | 0 | setIsDirty(true); |
| 603 | 0 | break; |
| 604 | |
} |
| 605 | |
} |
| 606 | |
} |
| 607 | 0 | return isDirty; |
| 608 | |
} |
| 609 | |
|
| 610 | |
public void setIsDirty(boolean state) { |
| 611 | |
|
| 612 | 0 | if (layoutController == null){ |
| 613 | 0 | layoutController = LayoutController.findParentLayout(layout); |
| 614 | |
} |
| 615 | 0 | if (isDirty != state){ |
| 616 | 0 | isDirty = state; |
| 617 | 0 | if (layoutController != null && isDirty){ |
| 618 | 0 | layoutController.fireApplicationEvent(new ContentDirtyEvent()); |
| 619 | |
} |
| 620 | |
} |
| 621 | 0 | } |
| 622 | |
|
| 623 | |
|
| 624 | |
|
| 625 | |
|
| 626 | |
@Override |
| 627 | |
public void add(Widget w) { |
| 628 | 0 | super.add(w); |
| 629 | 0 | } |
| 630 | |
|
| 631 | |
|
| 632 | |
|
| 633 | |
|
| 634 | |
|
| 635 | |
@Override |
| 636 | |
public void addStyleName(String style) { |
| 637 | 0 | layout.addStyleName(style); |
| 638 | 0 | } |
| 639 | |
|
| 640 | |
@Override |
| 641 | |
public void setStyleName(String style) { |
| 642 | 0 | layout.setStyleName(style); |
| 643 | 0 | } |
| 644 | |
|
| 645 | |
|
| 646 | |
|
| 647 | |
|
| 648 | |
|
| 649 | |
public void setInstructions(String html){ |
| 650 | 0 | layout.setInstructions(html); |
| 651 | 0 | } |
| 652 | |
|
| 653 | |
|
| 654 | |
|
| 655 | |
|
| 656 | |
|
| 657 | |
public void setHelp(String html){ |
| 658 | 0 | layout.setHelp(html); |
| 659 | 0 | } |
| 660 | |
|
| 661 | |
|
| 662 | |
|
| 663 | |
|
| 664 | |
|
| 665 | |
public void setRequired(AbbrPanel required){ |
| 666 | 0 | layout.setRequired(required); |
| 667 | 0 | } |
| 668 | |
} |