1 package com.genimen.djeneric.tools.specifier.editor; 2 3 import java.awt.BorderLayout ; 4 import java.awt.Component ; 5 import java.awt.Dimension ; 6 import java.awt.Font ; 7 import java.awt.event.ActionEvent ; 8 import java.awt.event.FocusEvent ; 9 import java.awt.event.FocusListener ; 10 import java.util.HashMap ; 11 12 import javax.swing.BorderFactory ; 13 import javax.swing.JButton ; 14 import javax.swing.JComponent ; 15 import javax.swing.JLabel ; 16 import javax.swing.JPanel ; 17 import javax.swing.JScrollPane ; 18 import javax.swing.JTabbedPane ; 19 import javax.swing.border.Border ; 20 import javax.swing.event.ChangeEvent ; 21 import javax.swing.event.ChangeListener ; 22 23 import com.genimen.djeneric.language.Messages; 24 import com.genimen.djeneric.repository.DjDomain; 25 import com.genimen.djeneric.repository.DjList; 26 import com.genimen.djeneric.repository.DjObject; 27 import com.genimen.djeneric.repository.exceptions.DjenericException; 28 import com.genimen.djeneric.structure.EditorDefinition; 29 import com.genimen.djeneric.structure.ExtentUsage; 30 import com.genimen.djeneric.structure.PropertyUsage; 31 import com.genimen.djeneric.structure.RelationUsage; 32 import com.genimen.djeneric.structure.ScriptDefinition; 33 import com.genimen.djeneric.tools.specifier.Specifier; 34 import com.genimen.djeneric.tools.specifier.base.AbstractEditorPanel; 35 import com.genimen.djeneric.tools.specifier.components.DjBindable; 36 import com.genimen.djeneric.tools.specifier.components.DjHtmlArea; 37 import com.genimen.djeneric.tools.specifier.components.DjTextArea; 38 import com.genimen.djeneric.tools.specifier.interfaces.ObjectViewer; 39 import com.genimen.djeneric.ui.Util; 40 41 public class EditorPanel extends AbstractEditorPanel implements ChangeListener , FocusListener 42 { 43 private static final long serialVersionUID = 1L; 44 BorderLayout borderLayout1 = new BorderLayout (); 45 JPanel jPanel1 = new JPanel (); 46 JPanel jPanel2 = new JPanel (); 47 BorderLayout borderLayout2 = new BorderLayout (); 48 JButton _butOk = new JButton (); 49 JPanel jPanel3 = new JPanel (); 50 JButton _butApply = new JButton (); 51 JButton _butCancel = new JButton (); 52 JButton _butUp = new JButton (); 53 JButton _butDown = new JButton (); 54 JButton _butBottom = new JButton (); 55 JButton _butFirst = new JButton (); 56 JButton _butDelete = new JButton (); 57 JButton _butCreate = new JButton (); 58 JLabel _lblExtent = new JLabel (); 59 JPanel _content = new JPanel (); 60 Border border1; 61 BorderLayout borderLayout3 = new BorderLayout (); 62 JButton _butRequery = new JButton (); 63 HashMap _tabcontrols = new HashMap (); 64 65 ObjectViewer _viewerWithFocus = null; 66 ObjectViewer _masterView = null; 67 EditorDefinition _editorDefinition; 68 ExtentUsage _editorStructure; 69 70 public void construct(EditorDefinition editorDefinition, DjList objects) throws Exception 71 { 72 setStatusMessageNow(Messages.getString("global.Loading"), true); 73 74 _editorDefinition = editorDefinition; 75 76 if (editorDefinition != null) _editorStructure = editorDefinition.getUsages(); 77 else throw new DjenericException(Messages.getString("EditorPanel.NoEditor")); 78 79 boolean editorForNewObject = objects.size() == 0; 80 81 if (editorForNewObject) 82 { 83 DjObject obj = getSession().createObject(_editorStructure.getExtent()); 84 objects.add(obj); 85 } 86 87 DjList lst = new DjList(); 88 for (int i = 0; i < objects.size(); i++) 89 { 90 DjObject org = objects.getDjenericObjectAt(i); 91 DjObject copy = getSession().getObject(org.getExtent(), org.getObjectId()); 92 lst.add(copy); 93 } 94 setMasterObjects(lst); 95 96 jbInit(); 97 98 setStatusMessage(Specifier.OK_MSG, true); 99 100 buildEditor(_editorStructure, getMasterObjects()); 101 if (editorForNewObject) setDefaultValues(); 102 103 if (!shouldCommitAndCloseSession()) _butApply.setVisible(false); 104 105 ScriptDefinition script = editorDefinition.getScriptDefinition(); 106 107 if (script != null && script.getCode() != null && script.getCode().trim().length() != 0) 108 { 109 setScript(script); 110 111 if (editorForNewObject) 112 { 113 DjObject obj = lst.getDjenericObjectAt(0); 114 beforeObjectCreated(_editorDefinition.getUsages(), obj); 115 afterRowInserted(_editorDefinition.getUsages()); 116 } 117 } 118 } 119 120 protected void jbInit() throws Exception 121 { 122 border1 = BorderFactory.createEmptyBorder(0, 5, 0, 0); 123 this.setLayout(borderLayout1); 124 jPanel1.setLayout(borderLayout2); 125 _butOk.setText(Messages.getString("global.Ok")); 126 _butOk.addActionListener(new java.awt.event.ActionListener () 127 { 128 public void actionPerformed(ActionEvent e) 129 { 130 _butOk_actionPerformed(e); 131 } 132 }); 133 _butApply.setPreferredSize(new Dimension (24, 24)); 134 _butApply.setIcon(Specifier.getImageIcon("save.gif")); 135 136 _butApply.setRequestFocusEnabled(true); 137 _butApply.setToolTipText(Messages.getString("global.ApplyAll")); 138 _butApply.addActionListener(new java.awt.event.ActionListener () 139 { 140 public void actionPerformed(ActionEvent e) 141 { 142 _butApply_actionPerformed(e); 143 } 144 }); 145 _butCancel.setRequestFocusEnabled(true); 146 _butCancel.setText(Messages.getString("global.Cancel")); 147 _butCancel.addActionListener(new java.awt.event.ActionListener () 148 { 149 public void actionPerformed(ActionEvent e) 150 { 151 _butCancel_actionPerformed(e); 152 } 153 }); 154 _content.setLayout(borderLayout3); 155 _butRequery.addActionListener(new java.awt.event.ActionListener () 156 { 157 public void actionPerformed(ActionEvent e) 158 { 159 _butRequery_actionPerformed(e); 160 } 161 }); 162 _butRequery.setRequestFocusEnabled(true); 163 _butRequery.setToolTipText(Messages.getString("EditorPanel.ReloadObject")); 164 _butRequery.setIcon(Specifier.getImageIcon("reload.gif")); 165 _butRequery.setPreferredSize(new Dimension (24, 24)); 166 _butUp.setPreferredSize(new Dimension (24, 24)); 167 _butUp.setIcon(Specifier.getImageIcon("up.gif")); 168 _butUp.setToolTipText(Messages.getString("global.PreviousInList")); 169 _butUp.setRequestFocusEnabled(true); 170 _butUp.addActionListener(new java.awt.event.ActionListener () 171 { 172 public void actionPerformed(ActionEvent e) 173 { 174 _butUp_actionPerformed(e); 175 } 176 }); 177 _butDown.addActionListener(new java.awt.event.ActionListener () 178 { 179 public void actionPerformed(ActionEvent e) 180 { 181 _butDown_actionPerformed(e); 182 } 183 }); 184 _butDown.setRequestFocusEnabled(true); 185 _butDown.setToolTipText(Messages.getString("global.NextInList")); 186 _butDown.setIcon(Specifier.getImageIcon("down.gif")); 187 _butDown.setPreferredSize(new Dimension (24, 24)); 188 _butBottom.setPreferredSize(new Dimension (24, 24)); 189 _butBottom.setIcon(Specifier.getImageIcon("bottom.gif")); 190 _butBottom.setToolTipText(Messages.getString("global.LastInList")); 191 _butBottom.setRequestFocusEnabled(true); 192 _butBottom.addActionListener(new java.awt.event.ActionListener () 193 { 194 public void actionPerformed(ActionEvent e) 195 { 196 _butBottom_actionPerformed(e); 197 } 198 }); 199 _butFirst.setPreferredSize(new Dimension (24, 24)); 200 _butFirst.setIcon(Specifier.getImageIcon("top.gif")); 201 _butFirst.setToolTipText(Messages.getString("global.FirstInList")); 202 _butFirst.setRequestFocusEnabled(true); 203 _butFirst.addActionListener(new java.awt.event.ActionListener () 204 { 205 public void actionPerformed(ActionEvent e) 206 { 207 _butFirst_actionPerformed(e); 208 } 209 }); 210 _butDelete.addActionListener(new java.awt.event.ActionListener () 211 { 212 public void actionPerformed(ActionEvent e) 213 { 214 _butDelete_actionPerformed(e); 215 } 216 }); 217 _butDelete.setRequestFocusEnabled(true); 218 _butDelete.setToolTipText(Messages.getString("global.DeleteCtrl")); 219 _butDelete.setIcon(Specifier.getImageIcon("delete.gif")); 220 _butDelete.setPreferredSize(new Dimension (24, 24)); 221 _butCreate.addActionListener(new java.awt.event.ActionListener () 222 { 223 public void actionPerformed(ActionEvent e) 224 { 225 _butCreate_actionPerformed(e); 226 } 227 }); 228 _butCreate.setRequestFocusEnabled(true); 229 _butCreate.setToolTipText(Messages.getString("global.CreateCtrl")); 230 _butCreate.setIcon(Specifier.getImageIcon("new.gif")); 231 _butCreate.setPreferredSize(new Dimension (24, 24)); 232 this.add(jPanel1, BorderLayout.SOUTH); 233 jPanel1.add(jPanel2, BorderLayout.EAST); 234 jPanel2.add(_butCancel, null); 235 jPanel2.add(_butOk, null); 236 jPanel1.add(jPanel3, BorderLayout.WEST); 237 jPanel3.add(_butApply, null); 238 jPanel3.add(_butRequery, null); 239 jPanel3.add(_butUp, null); 240 jPanel3.add(_butDown, null); 241 jPanel3.add(_butFirst, null); 242 jPanel3.add(_butBottom, null); 243 jPanel3.add(_butCreate, null); 244 jPanel3.add(_butDelete, null); 245 jPanel1.add(_lblExtent, BorderLayout.CENTER); 246 this.add(_content, BorderLayout.CENTER); 247 Util.sizeButtons(jPanel2); 248 } 249 250 public void initializeUsage(ExtentUsage usageDef) throws DjenericException 251 { 252 if (usageDef != null) 253 { 254 _masterView.setDeleteable(usageDef.isDeleteAllowed()); 255 _masterView.setInserteable(usageDef.isInsertAllowed()); 256 _masterView.setEditable(usageDef.isEditAllowed()); 257 } 258 259 if (!getSession().canCreate()) _masterView.setInserteableRecursive(false); 260 if (!getSession().canDelete()) _masterView.setDeleteableRecursive(false); 261 if (!getSession().canModify()) _masterView.setEditableRecursive(false); 262 263 if (!getSession().canCreate() && !getSession().canDelete() && !getSession().canModify()) 264 { 265 _butApply.setEnabled(false); 266 _butOk.setEnabled(false); 267 } 268 269 _masterView.synchronize(); 270 _masterView.synchronizeUsage(); 271 } 272 273 void _butApply_actionPerformed(ActionEvent e) 274 { 275 try 276 { 277 apply(); 278 } 279 catch (Exception x) 280 { 281 setStatusMessage(x); 282 } 283 } 284 285 public void requestFocus() 286 { 287 if (_masterView != null) 288 { 289 _masterView.requestFocus(); 290 } 291 } 292 293 public void setSelectedIndexOfMaster(int index) throws DjenericException 294 { 295 _masterView.setSelectedIndex(index); 296 } 297 298 public void _butCancel_actionPerformed(ActionEvent e) 299 { 300 if (canClose()) close(); 301 } 302 303 void _butOk_actionPerformed(ActionEvent e) 304 { 305 try 306 { 307 apply(); 308 close(); 309 } 310 catch (Exception x) 311 { 312 setStatusMessage(x); 313 } 314 } 315 316 protected void createMemoTabs(JTabbedPane tabs, ObjectViewer viewer, ExtentUsage editorStructure) throws Exception 317 { 318 for (int i = 0; i < editorStructure.getPropertyUsageCount(); i++) 319 { 320 PropertyUsage pu = editorStructure.getPropertyUsage(i); 321 322 if (DjDomain.isMemoComponent(pu.getComponentType()) && pu.isDisplayed()) 323 { 324 if (pu.getComponentType() == DjDomain.COMP_MEMO) addDefaultMemo(tabs, viewer, pu); 325 else if (pu.getComponentType() == DjDomain.COMP_HTML_MEMO) addHtmlMemo(tabs, viewer, pu); 326 else if (pu.isCustomComponent()) try 327 { 328 addCustomMemo(tabs, viewer, pu); 329 } 330 catch (ClassNotFoundException cnf) 331 { 332 setStatusMessage(cnf); 333 addDefaultMemo(tabs, viewer, pu); 335 } 336 else throw new DjenericException("Unknown component type: " + pu.getComponentType()); 337 } 338 } 339 } 340 341 private void addCustomMemo(JTabbedPane tabs, ObjectViewer viewer, PropertyUsage pu) throws ClassNotFoundException , 342 InstantiationException , IllegalAccessException , DjenericException 343 { 344 String className = pu.getCustomEditorClass(); 345 Class clz = Thread.currentThread().getContextClassLoader().loadClass(className); 346 Object o = clz.newInstance(); 347 348 if (!(o instanceof DjBindable)) throw new DjenericException(Messages.getString("global.Implement", o.getClass() 349 .getName(), DjBindable.class.getName())); 350 DjBindable bind = (DjBindable) o; 351 bind.setPropertyName(pu.getPropertyName()); 352 bind.setViewer(viewer); 353 viewer.bindEditor(getSession(), bind, pu.getPropertyName()); 354 355 if (pu.getDescription() != null && pu.getDescription().trim().length() > 0) 356 { 357 bind.setToolTipText(pu.getDescription()); 358 } 359 360 if (pu.getSeq() < 0) tabs.add((JComponent ) bind, pu.getPrompt(), 0); 361 else tabs.add((JComponent ) bind, pu.getPrompt()); 362 } 363 364 private void addHtmlMemo(JTabbedPane tabs, ObjectViewer viewer, PropertyUsage pu) throws DjenericException 365 { 366 DjHtmlArea ta = new DjHtmlArea(viewer, pu.getPropertyName()); 367 if (pu.getDescription() != null && pu.getDescription().trim().length() > 0) 368 { 369 ta.setToolTipText(pu.getDescription()); 370 } 371 372 if (pu.getSeq() < 0) tabs.add(ta, pu.getPrompt(), 0); 373 else tabs.add(ta, pu.getPrompt()); 374 375 viewer.bindEditor(getSession(), ta, pu.getPropertyName()); 376 } 377 378 private void addDefaultMemo(JTabbedPane tabs, ObjectViewer viewer, PropertyUsage pu) throws DjenericException 379 { 380 DjTextArea ta = new DjTextArea(viewer, pu.getPropertyName()); 381 if (pu.getDescription() != null && pu.getDescription().trim().length() > 0) 382 { 383 ta.setToolTipText(pu.getDescription()); 384 } 385 ta.setLineWrap(false); 386 ta.setWrapStyleWord(false); 387 ta.setFont(new Font ("Monospaced", 0, 11)); 388 ta.setTabSize(2); 389 JScrollPane scr = new JScrollPane (); 390 scr.getViewport().add(ta, null); 391 scr.setAutoscrolls(true); 392 393 if (pu.getSeq() < 0) tabs.add(scr, pu.getPrompt(), 0); 394 else tabs.add(scr, pu.getPrompt()); 395 396 viewer.bindEditor(getSession(), ta, pu.getPropertyName()); 397 } 398 399 protected ObjectViewer createDetailViewer(RelationUsage viaRel) throws Exception 400 { 401 ExtentUsage editorStructure = viaRel.getDetail(); 402 403 ObjectViewer view = null; 404 405 if (editorStructure.isMultiRow()) 406 { 407 view = new DjenericObjectTable(getSession(), editorStructure, getContextManager()); 408 setSizeOfView(view, editorStructure); 409 } 410 else 411 { 412 view = new DjenericObjectForm(getSession(), editorStructure, getContextManager()); 413 } 414 415 registerViewer(view); 416 417 return view; 418 } 419 420 public JTabbedPane getTabbedPane(String extentUsageId) 421 { 422 return (JTabbedPane ) _tabcontrols.get(extentUsageId); 423 } 424 425 protected void recurseEditorTree(ObjectViewer masterViewer, ExtentUsage editorStructure, JPanel inPanel) 426 throws Exception 427 { 428 if ((editorStructure.getDetailRelationCount() > 0) || hasMemos(editorStructure)) 429 { 430 JTabbedPane tabs = new JTabbedPane (); 431 432 _tabcontrols.put(editorStructure.getId(), tabs); 433 434 tabs.addChangeListener(this); 435 tabs.addFocusListener(this); 436 437 inPanel.add(tabs, BorderLayout.CENTER); 438 439 for (int i = 0; i < editorStructure.getDetailRelationCount(); i++) 440 { 441 RelationUsage via = editorStructure.getDetailRelation(i); 442 ObjectViewer detailView = createDetailViewer(via); 443 444 masterViewer.addDetailViewer(detailView, via); 445 446 String placement; 449 450 ExtentUsage detailEditor = via.getDetail(); 451 452 if (via.getDetail().getDetailRelationCount() > 0 || hasMemos(detailEditor)) 453 { 454 placement = BorderLayout.NORTH; 455 } 456 else 457 { 458 placement = BorderLayout.CENTER; 459 } 460 JPanel branch = new JPanel (new BorderLayout ()); 461 branch.add((Component ) detailView, placement); 462 tabs.add(branch, via.getDetail().getTitle()); 463 recurseEditorTree(detailView, via.getDetail(), branch); 464 } 465 createMemoTabs(tabs, masterViewer, editorStructure); 466 } 467 } 468 469 protected void buildEditor(ExtentUsage editorStructure, DjList dataForMasterModel) throws Exception 470 { 471 if (editorStructure == null) 472 { 473 throw new Exception (Messages.getString("EditorPanel.SorryNoEditor")); 474 } 475 if (editorStructure.isMultiRow()) 476 { 477 _masterView = new DjenericObjectTable(getSession(), editorStructure, getContextManager()); 478 setSizeOfView(_masterView, editorStructure); 479 } 480 else 481 { 482 _masterView = new DjenericObjectForm(getSession(), editorStructure, getContextManager()); 483 } 484 485 registerViewer(_masterView); 486 _masterView.requestFocus(); 487 488 String position; 489 if ((editorStructure.getDetailRelationCount() > 0) || hasMemos(editorStructure)) position = BorderLayout.NORTH; 490 else position = BorderLayout.CENTER; 491 492 _content.add((Component ) _masterView, position); 493 494 recurseEditorTree(_masterView, editorStructure, _content); 495 496 dataForMasterModel.sort(editorStructure.getPropertySortIndices()); 497 _masterView.setViewerFor(dataForMasterModel, null); 498 focusReceived(_masterView, null); 499 } 500 501 void _butRequery_actionPerformed(ActionEvent e) 502 { 503 try 504 { 505 getSession().resetValidValueLists(); 506 if (_viewerWithFocus != null) _viewerWithFocus.reload(); 507 508 } 509 catch (Exception x) 510 { 511 setStatusMessage(x.getMessage(), false); 512 } 513 514 } 515 516 void _butUp_actionPerformed(ActionEvent e) 517 { 518 try 519 { 520 if (_viewerWithFocus != null) _viewerWithFocus.prev(); 521 } 522 catch (Exception x) 523 { 524 setStatusMessage(x.getMessage(), false); 525 } 526 } 527 528 void _butDown_actionPerformed(ActionEvent e) 529 { 530 try 531 { 532 if (_viewerWithFocus != null) _viewerWithFocus.next(); 533 } 534 catch (Exception x) 535 { 536 setStatusMessage(x.getMessage(), false); 537 } 538 } 539 540 void _butBottom_actionPerformed(ActionEvent e) 541 { 542 try 543 { 544 if (_viewerWithFocus != null) _viewerWithFocus.bottom(); 545 } 546 catch (Exception x) 547 { 548 setStatusMessage(x.getMessage(), false); 549 } 550 } 551 552 void _butFirst_actionPerformed(ActionEvent e) 553 { 554 try 555 { 556 if (_viewerWithFocus != null) _viewerWithFocus.top(); 557 } 558 catch (Exception x) 559 { 560 setStatusMessage(x.getMessage(), false); 561 } 562 } 563 564 void _butDelete_actionPerformed(ActionEvent e) 565 { 566 try 567 { 568 if (_viewerWithFocus != null) _viewerWithFocus.markForDelete(); 569 } 570 catch (Exception x) 571 { 572 setStatusMessage(x); 573 } 574 } 575 576 void _butCreate_actionPerformed(ActionEvent e) 577 { 578 try 579 { 580 if (_viewerWithFocus != null) _viewerWithFocus.createNew(); 581 } 582 catch (Exception x) 583 { 584 setStatusMessage(x.getMessage(), false); 585 } 586 587 } 588 589 public void hideDefaultOkCCancelButtons(boolean hide) 590 { 591 _butOk.setVisible(!hide); 592 _butCancel.setVisible(!hide); 593 } 594 595 public void apply() throws DjenericException 596 { 597 for (int i = 0; i < getViewerCount(); i++) 599 { 600 ObjectViewer vw = getViewer(i); 601 if (!vw.isDetail()) 603 { 604 vw.validateModel(true); 605 } 606 } 607 608 fireEditorEvent("validate"); 609 610 if (shouldCommitAndCloseSession()) getSession().commit(); 611 getSpecifierPanelContainer().editorApplied(this); 612 613 try 614 { 615 for (int i = 0; i < getViewerCount(); i++) 616 { 617 ObjectViewer vw = getViewer(i); 618 vw.updateAllModels(getSession()); 619 } 620 621 if (getAssociatedTreeNode() != null) getAssociatedTreeNode().reload(); 622 } 623 catch (Exception x) 624 { 625 } 627 } 628 629 public void focusReceived(ObjectViewer viewer, Component component) 630 { 631 _viewerWithFocus = viewer; 632 _lblExtent.setText(viewer.getExtentUsage().getTitle()); 633 634 _butDelete.setEnabled(viewer.isDeleteable()); 635 _butCreate.setEnabled(viewer.isInserteable()); 636 } 637 638 public void stateChanged(ChangeEvent e) 639 { 640 updateSelectedViewer(e.getSource()); 641 } 642 643 protected void updateSelectedViewer(Object src) 644 { 645 if (src instanceof JTabbedPane ) 646 { 647 JTabbedPane tp = (JTabbedPane ) src; 648 ObjectViewer vw = findObjectViewerChild(tp.getSelectedComponent()); 649 if (vw != null) 650 { 651 focusReceived(vw, null); 652 tp.requestFocus(); 653 } 654 } 655 } 656 657 public void registerEvent(String eventName, String eventTitle, String eventOption) 658 { 659 hideDefaultOkCCancelButtons(true); 660 registerAdditionalEvent(eventName, eventTitle, eventOption); 661 } 662 663 public void registerAdditionalEvent(String eventName, String eventTitle, String eventOption) 664 { 665 JButton newButton = new JButton (); 666 667 newButton.setText(eventTitle); 668 newButton.setActionCommand(eventName + "," + eventOption); 669 newButton.addActionListener(new java.awt.event.ActionListener () 670 { 671 public void actionPerformed(ActionEvent e) 672 { 673 fireEditorEventAndHandleOption(e); 674 } 675 }); 676 if (_butOk.isVisible()) 677 { 678 jPanel2.add(newButton, null, 0); 679 } 680 else 681 { 682 jPanel2.add(newButton, null); 683 } 684 Util.sizeButtons(jPanel2); 685 } 686 687 public void focusGained(FocusEvent e) 688 { 689 updateSelectedViewer(e.getSource()); 690 } 691 692 public void focusLost(FocusEvent e) 693 { 694 } 695 696 public String getTitle() 697 { 698 if (getMasterObjects().size() != 1) 699 { 700 return _editorStructure.getTitle(); 701 } 702 String descr = getMasterObjects().getDjenericObjectAt(0).getDescriptor(); 703 if (descr == null || descr.trim().length() == 0) 704 { 705 if (getMasterObjects().getDjenericObjectAt(0).isNew()) 706 { 707 descr = _editorStructure.getExtent().getTitle() + "*"; 708 } 709 else 710 { 711 descr = _editorStructure.getExtent().getTitle(); 712 } 713 } 714 return descr; 715 } 716 717 protected boolean hasMemos(ExtentUsage editorStructure) 718 { 719 for (int i = 0; i < editorStructure.getPropertyUsageCount(); i++) 720 { 721 PropertyUsage pu = editorStructure.getPropertyUsage(i); 722 if (DjDomain.isMemoComponent(pu.getComponentType())) 723 { 724 return true; 725 } 726 } 727 return false; 728 } 729 730 protected void setSizeOfView(ObjectViewer viewer, ExtentUsage editorStructure) 731 { 732 int rows = editorStructure.getRowsDisplayed(); 733 if (rows == 0) 734 { 735 rows = 4; 736 } 737 738 rows++; 739 740 JComponent vc = (JComponent ) viewer; 741 if (rows > 0) 742 { 743 vc.setPreferredSize(new Dimension ((int) vc.getPreferredSize().getWidth(), rows * 16 + 4)); 744 } 745 } 746 747 protected void releaseEditors() 748 { 749 for (int i = 0; i < getViewerCount(); i++) 750 { 751 ObjectViewer vw = getViewer(i); 752 vw.unbindEditors(); 753 } 754 } 755 756 protected void setDefaultValues() throws Exception 757 { 758 _masterView.getModel().setDefaults(); 759 _masterView.synchronize(); 760 } 761 762 protected void cleanup() throws DjenericException 763 { 764 releaseEditors(); 765 if (shouldCommitAndCloseSession()) 766 { 767 getSession().close(); 768 } 769 } 770 771 public ObjectViewer getMasterView() 772 { 773 return _masterView; 774 } 775 } | Popular Tags |