1 19 20 25 26 package org.netbeans.modules.xml.schema.ui.nodes.categorized.customizer; 27 28 import java.awt.event.ItemEvent ; 29 import java.awt.event.ItemListener ; 30 import java.beans.PropertyChangeEvent ; 31 import java.beans.PropertyChangeListener ; 32 import java.io.IOException ; 33 import java.util.Collections ; 34 import javax.swing.event.DocumentEvent ; 35 import javax.swing.event.DocumentListener ; 36 import org.netbeans.modules.xml.xam.ui.customizer.MessageDisplayer; 37 import org.openide.util.HelpCtx; 38 39 import org.netbeans.modules.xml.schema.model.LocalSimpleType; 40 import org.netbeans.modules.xml.schema.model.SchemaComponentFactory; 41 import org.netbeans.modules.xml.schema.model.SimpleType; 42 import org.netbeans.modules.xml.schema.model.GlobalSimpleType; 43 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 44 import org.netbeans.modules.xml.schema.model.List; 45 import org.netbeans.modules.xml.schema.model.Union; 46 import org.netbeans.modules.xml.schema.model.SchemaComponent; 47 import org.netbeans.modules.xml.schema.model.SimpleTypeDefinition; 48 import org.netbeans.modules.xml.schema.model.SimpleTypeRestriction; 49 import org.netbeans.modules.xml.schema.ui.basic.editors.SchemaComponentSelectionPanel; 50 51 56 public class SimpleTypeCustomizer<T extends SimpleType> 57 extends AbstractSchemaComponentCustomizer<T> 58 implements PropertyChangeListener { 59 60 static final long serialVersionUID = 1L; 61 62 65 public SimpleTypeCustomizer(SchemaComponentReference<T> reference) { 66 this(reference,null,null); 67 } 68 69 70 public SimpleTypeCustomizer(SchemaComponentReference<T> reference, 71 SchemaComponent parent, GlobalSimpleType currentGlobalSimpleType) { 72 super(reference, parent); 73 this.currentGlobalSimpleType = currentGlobalSimpleType; 74 initComponents(); 75 reset(); 76 } 77 78 public void applyChanges() throws IOException { 79 SimpleType type = getReference().get(); 80 saveName(); 81 DerivationType uiDType = getUIDerivationType(); 82 TypeDefinition uiTDef = getUITypeDefinition(); 83 switch (uiDType) { 84 case RESTRICTION: 85 case LIST: 86 if(uiTDef == TypeDefinition.EXISTING && getUIType()==null) 87 break; 88 if(uiDType != _getDerivationType() || 89 uiTDef != _getTypeDefinition() || getUIType() != _getType()) 90 setModelType(); 91 break; 92 case UNION: 93 if(uiDType != _getDerivationType()) 94 setModelType(); 95 break; 96 } 97 } 98 99 public void reset() { 100 removeListeners(); 101 initializeModel(); 102 initializeUISelection(); 103 addListeners(); 104 if(hasParent()) { 105 setSaveEnabled(false); 106 } else { 107 setSaveEnabled(true); 108 } 109 setResetEnabled(false); 110 } 111 112 115 private void initializeModel() { 116 SimpleType type = getReference().get(); 117 SimpleTypeDefinition definition = type.getDefinition(); 118 if (definition instanceof SimpleTypeRestriction) { 119 derivation = DerivationType.RESTRICTION; 120 SimpleTypeRestriction str = (SimpleTypeRestriction)definition; 121 if(str.getBase()!=null) { 122 if(hasParent()) 123 currentGlobalSimpleType = str.getBase().get(); 124 typeDef = TypeDefinition.EXISTING; 125 } else if(str.getInlineType()!=null) 126 typeDef = TypeDefinition.INLINE; 127 } else if (definition instanceof List) { 128 derivation = DerivationType.LIST; 129 List list = (List)definition; 130 if(list.getType()!=null) { 131 currentGlobalSimpleType = list.getType().get(); 132 typeDef = TypeDefinition.EXISTING; 133 } else if(list.getInlineType()!=null) 134 typeDef = TypeDefinition.INLINE; 135 } else if(definition instanceof Union) { 136 derivation = DerivationType.UNION; 137 Union u = (Union)definition; 138 } 139 } 140 141 144 private void initializeUISelection() { 145 getMessageDisplayer().clear(); 146 if(isNameable()) { 147 nameTextField.setText(_getName()); 148 if(!hasParent()) nameTextField.setSelectionStart(0); 149 } else { 150 namePanel.setVisible(false); 151 } 152 DerivationType dType = _getDerivationType(); 153 if(dType!=null) { 154 switch(dType) { 155 case RESTRICTION: 156 restrictionButton.setSelected(true); 157 break; 158 case LIST: 159 listButton.setSelected(true); 160 break; 161 case UNION: 162 unionButton.setSelected(true); 163 break; 164 } 165 } 166 TypeDefinition type = _getTypeDefinition(); 167 if(type!=null) { 168 switch(type) { 169 case EXISTING: 170 useExistingButton.setSelected(true); 171 break; 172 case INLINE: 173 inlineTypeButton.setSelected(true); 174 break; 175 } 176 } 177 switchTypePanels(); 178 selectModelNode(); 179 setPreviewText(); 180 } 181 182 private void addListeners() { 183 if(nameListener == null) { 184 nameListener = new DocumentListener () { 185 public void changedUpdate(DocumentEvent e) { 186 setPreviewText(); 187 determineValidity(); 188 } 189 public void insertUpdate(DocumentEvent e) { 190 setPreviewText(); 191 determineValidity(); 192 } 193 public void removeUpdate(DocumentEvent e) { 194 setPreviewText(); 195 determineValidity(); 196 } 197 }; 198 } 199 nameTextField.getDocument().addDocumentListener(nameListener); 200 if (buttonListener ==null) { 201 buttonListener = new ItemListener () { 202 public void itemStateChanged(ItemEvent evt) { 203 Object source = evt.getSource(); 204 if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { 205 switchTypePanels(); 206 setPreviewText(); 207 determineValidity(); 208 } 209 } 210 }; 211 } 212 restrictionButton.addItemListener(buttonListener); 213 listButton.addItemListener(buttonListener); 214 unionButton.addItemListener(buttonListener); 215 useExistingButton.addItemListener(buttonListener); 216 inlineTypeButton.addItemListener(buttonListener); 217 } 218 219 private void removeListeners() { 220 nameTextField.getDocument().removeDocumentListener(nameListener); 221 } 222 223 226 private void switchTypePanels() { 227 boolean enableTypeDefPanel = getUIDerivationType()!=DerivationType.UNION; 228 typeDefPanel.setEnabled(enableTypeDefPanel); 229 useExistingButton.setEnabled(enableTypeDefPanel); 230 inlineTypeButton.setEnabled(enableTypeDefPanel); 231 if(enableTypeDefPanel && getUITypeDefinition()==null) 232 useExistingButton.setSelected(true); 233 boolean enableTypePanel = enableTypeDefPanel && useExistingButton.isSelected(); 234 componentSelectionPanel.setEnabled(enableTypePanel); 235 } 236 237 240 private void selectModelNode() { 241 componentSelectionPanel.setInitialSelection(_getType()); 242 } 243 244 247 private GlobalSimpleType _getType() { 248 return currentGlobalSimpleType; 249 } 250 251 private DerivationType _getDerivationType() { 252 return derivation; 253 } 254 255 private TypeDefinition _getTypeDefinition() { 256 return typeDef; 257 } 258 259 264 protected String getUIName() { 265 return nameTextField.getText(); 266 } 267 268 private DerivationType getUIDerivationType() { 269 if(restrictionButton.isSelected()) 270 return DerivationType.RESTRICTION; 271 if(listButton.isSelected()) 272 return DerivationType.LIST; 273 if(unionButton.isSelected()) 274 return DerivationType.UNION; 275 return null; 276 } 277 278 private TypeDefinition getUITypeDefinition() { 279 if(getUIDerivationType()==DerivationType.UNION) return null; 280 if(useExistingButton.isSelected()) 281 return TypeDefinition.EXISTING; 282 if(inlineTypeButton.isSelected()) 283 return TypeDefinition.INLINE; 284 return null; 285 } 286 287 292 private GlobalSimpleType getUIType() { 293 if(getUIDerivationType()==DerivationType.UNION) return null; 294 if(getUITypeDefinition()==TypeDefinition.INLINE) return null; 295 return componentSelectionPanel.getCurrentSelection(); 296 } 297 298 private void setModelType() { 299 SimpleType type = getReference().get(); 300 SimpleTypeDefinition definition = type.getDefinition(); 301 SchemaComponentFactory factory = type.getModel().getFactory(); 302 GlobalSimpleType gst = getUIType(); 303 LocalSimpleType inlineType = null; 304 if (definition instanceof SimpleTypeRestriction) { 305 inlineType = ((SimpleTypeRestriction)definition).getInlineType(); 306 } else if (definition instanceof List) { 307 inlineType = ((List)definition).getInlineType(); 308 } 309 switch(getUIDerivationType()) { 310 case RESTRICTION: 311 SimpleTypeRestriction str; 312 if (definition instanceof SimpleTypeRestriction) { 313 str = (SimpleTypeRestriction)definition; 314 if(gst!=null) { 315 if(inlineType!=null) str.setInlineType(null); 316 str.setBase(factory.createGlobalReference( 317 gst, GlobalSimpleType.class, str)); 318 } else { 319 if(str.getBase()!=null) str.setBase(null); 320 if(inlineType==null) { 321 str.setInlineType(createLocalSimpleType(factory)); 322 } 323 } 324 } else { 325 str = factory.createSimpleTypeRestriction(); 326 if(gst!=null) { 327 str.setBase(factory.createGlobalReference( 328 gst, GlobalSimpleType.class, str)); 329 } else if(inlineType!=null) { 330 str.setInlineType((LocalSimpleType)inlineType.copy(str)); 331 } else { 332 str.setInlineType(createLocalSimpleType(factory)); 333 } 334 type.setDefinition(str); 335 } 336 break; 337 case LIST: 338 List list; 339 if (definition instanceof List) { 340 list = (List)definition; 341 if(gst!=null) { 342 if(inlineType!=null) list.setInlineType(null); 343 list.setType(factory.createGlobalReference( 344 gst, GlobalSimpleType.class, list)); 345 } else { 346 if(list.getType()!=null) list.setType(null); 347 if(inlineType==null) { 348 list.setInlineType(createLocalSimpleType(factory)); 349 } 350 } 351 } else { 352 list = factory.createList(); 353 if(gst!=null) { 354 list.setType(factory.createGlobalReference( 355 gst, GlobalSimpleType.class, list)); 356 } else if(inlineType!=null) { 357 list.setInlineType((LocalSimpleType)inlineType.copy(list)); 358 } else { 359 list.setInlineType(createLocalSimpleType(factory)); 360 } 361 type.setDefinition(list); 362 } 363 break; 364 case UNION: 365 Union u; 366 if (definition instanceof Union) { 367 } else { 369 u = factory.createUnion(); 370 type.setDefinition(u); 371 } 372 } 374 } 375 376 private LocalSimpleType createLocalSimpleType 377 (final SchemaComponentFactory factory) { 378 LocalSimpleType lst = factory.createLocalSimpleType(); 379 SimpleTypeRestriction str = factory.createSimpleTypeRestriction(); 380 str.setBase(ElementCustomizer.createStringTypeReference(factory,str)); 381 lst.setDefinition(str); 382 return lst; 383 } 384 385 389 private void initializeTypeView() { 390 componentSelectionPanel = new SchemaComponentSelectionPanel<GlobalSimpleType>( 391 getReference().get().getModel(),GlobalSimpleType.class, 392 null, Collections.singleton(getReference().get()), true); 393 componentSelectionPanel.addPropertyChangeListener(this); 394 typePanel.add(componentSelectionPanel.getTypeSelectionPanel(),java.awt.BorderLayout.CENTER); 395 componentSelectionPanel.getTypeSelectionPanel().getAccessibleContext(). 396 setAccessibleParent(typePanel); 397 } 398 399 402 public void propertyChange(PropertyChangeEvent event) { 403 if (event.getPropertyName().equals(SchemaComponentSelectionPanel.PROPERTY_SELECTION)) { 404 setPreviewText(); 405 determineValidity(); 406 } 407 } 408 409 413 private void determineValidity() { 414 getMessageDisplayer().clear(); 415 boolean nameChanged = isNameable()&&isNameChanged(); 416 if(!nameChanged && getUIDerivationType()==_getDerivationType() && 417 getUITypeDefinition()==_getTypeDefinition() && 418 getUIType()== _getType()) { 419 if(hasParent()) { 420 setSaveEnabled(false); 421 } else { 422 setSaveEnabled(true); 423 } 424 setResetEnabled(false); 425 return; 426 } else { 427 setResetEnabled(true); 428 boolean valid = false; 429 DerivationType uiDType = getUIDerivationType(); 430 TypeDefinition uiTDef = getUITypeDefinition(); 431 switch (uiDType) { 432 case RESTRICTION: 433 case LIST: 434 if(uiTDef == TypeDefinition.EXISTING && getUIType()!=null || 435 uiTDef == TypeDefinition.INLINE) 436 valid = true; 437 break; 438 case UNION: 439 valid = true; 440 break; 441 } 442 setSaveEnabled(valid && (!isNameChanged() || isNameValid())); 443 if(!valid) 444 getMessageDisplayer().annotate(org.openide.util.NbBundle. 445 getMessage(SimpleTypeCustomizer.class, 446 "MSG_Type_Error"), 447 MessageDisplayer.Type.ERROR); 448 } 449 } 450 451 private String getInlineTypePreviewText() { 452 StringBuffer retValue = new StringBuffer ("\n <"); 453 String prefix = getReference().get().getPeer().getPrefix(); 454 if(prefix!=null) retValue.append(prefix+":"); 455 retValue.append("simpleType>"); 456 retValue.append("\n <"); 457 if(prefix!=null) retValue.append(prefix+":"); 458 retValue.append("restriction base=\""); 459 if(prefix!=null) retValue.append(prefix+":"); 460 retValue.append("string\">"); 461 retValue.append("\n </"); 462 if(prefix!=null) retValue.append(prefix+":"); 463 retValue.append("simpleType>"); 464 return retValue.toString(); 465 } 466 467 private void setPreviewText() { 468 StringBuffer retValue = new StringBuffer ("<"); 469 String prefix = getReference().get().getPeer().getPrefix(); 470 if(prefix!=null) retValue.append(prefix+":"); 471 retValue.append("simpleType"); 472 if(isNameable()) { 473 retValue.append(" name=\""); 474 retValue.append(getUIName()); 475 retValue.append("\""); 476 } 477 retValue.append(">"); 478 DerivationType dt = getUIDerivationType(); 479 TypeDefinition t = getUITypeDefinition(); 480 GlobalSimpleType gst = getUIType(); 481 if(dt!=null) { 482 switch(dt) { 483 case RESTRICTION: 484 retValue.append("\n <"); 485 if(prefix!=null) retValue.append(prefix+":"); 486 retValue.append("restriction"); 487 if(t==TypeDefinition.EXISTING) { 488 retValue.append(" base=\""); 489 if(gst!=null) 490 retValue.append(gst.getName()); 491 retValue.append("\"/>"); 492 } else if(t==TypeDefinition.INLINE) { 493 retValue.append(">"); 494 retValue.append(getInlineTypePreviewText()); 495 retValue.append("\n </"); 496 if(prefix!=null) retValue.append(prefix+":"); 497 retValue.append("restriction>"); 498 } else { 499 retValue.append("/>"); 500 } 501 break; 502 case LIST: 503 retValue.append("\n <"); 504 if(prefix!=null) retValue.append(prefix+":"); 505 retValue.append("list"); 506 if(t==TypeDefinition.EXISTING) { 507 retValue.append(" itemType=\""); 508 if(gst!=null) 509 retValue.append(gst.getName()); 510 retValue.append("\"/>"); 511 } else if(t==TypeDefinition.INLINE) { 512 retValue.append(">"); 513 retValue.append(getInlineTypePreviewText()); 514 retValue.append("\n </"); 515 if(prefix!=null) retValue.append(prefix+":"); 516 retValue.append("list>"); 517 } else { 518 retValue.append("/>"); 519 } 520 break; 521 case UNION: 522 retValue.append("\n <"); 523 if(prefix!=null) retValue.append(prefix+":"); 524 retValue.append("union/>"); 525 break; 526 } 527 } 528 retValue.append("\n</"); 529 if(prefix!=null) retValue.append(prefix+":"); 530 retValue.append("simpleType>\n"); 531 previewPane.setText(retValue.toString()); 532 533 } 534 535 541 private void initComponents() { 543 derivationGroup = new javax.swing.ButtonGroup (); 544 typeGroup = new javax.swing.ButtonGroup (); 545 typeDefPanel = new javax.swing.JPanel (); 546 typePanel = new javax.swing.JPanel (); 547 useExistingButton = new javax.swing.JRadioButton (); 548 inlineTypeButton = new javax.swing.JRadioButton (); 549 baseTypeLabel = new javax.swing.JLabel (); 550 previewLabel = new javax.swing.JLabel (); 551 jScrollPane1 = new javax.swing.JScrollPane (); 552 previewPane = new javax.swing.JEditorPane () { 553 static final long serialVersionUID = 1L; 554 protected void processMouseEvent(java.awt.event.MouseEvent e) { 556 e.consume(); 557 } 558 protected void processMouseMotionEvent(java.awt.event.MouseEvent e) { 559 e.consume(); 560 } 561 }; 562 typeLabel = new javax.swing.JLabel (); 563 restrictionButton = new javax.swing.JRadioButton (); 564 listButton = new javax.swing.JRadioButton (); 565 unionButton = new javax.swing.JRadioButton (); 566 mPanel = new javax.swing.JPanel (); 567 namePanel = new javax.swing.JPanel (); 568 nameLabel = new javax.swing.JLabel (); 569 nameTextField = new javax.swing.JTextField (); 570 571 setToolTipText(""); 572 typePanel.setLayout(new java.awt.BorderLayout ()); 573 574 initializeTypeView(); 575 576 typeGroup.add(useExistingButton); 577 org.openide.awt.Mnemonics.setLocalizedText(useExistingButton, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "LBL_SimpleTypeForm_Existing_Definition_Button")); 578 useExistingButton.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_Existing_Definition_Button")); 579 useExistingButton.setMargin(new java.awt.Insets (0, 0, 0, 0)); 580 581 typeGroup.add(inlineTypeButton); 582 org.openide.awt.Mnemonics.setLocalizedText(inlineTypeButton, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "LBL_SimpleTypeForm_Inline_Definition_Button")); 583 inlineTypeButton.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_Inline_Definition_Button")); 584 inlineTypeButton.setMargin(new java.awt.Insets (0, 0, 0, 0)); 585 586 org.openide.awt.Mnemonics.setLocalizedText(baseTypeLabel, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "TITLE_SimpleTypeForm_BaseTypePanel", new Object [] {})); 587 baseTypeLabel.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_BaseTypePanel")); 588 589 org.jdesktop.layout.GroupLayout typeDefPanelLayout = new org.jdesktop.layout.GroupLayout(typeDefPanel); 590 typeDefPanel.setLayout(typeDefPanelLayout); 591 typeDefPanelLayout.setHorizontalGroup( 592 typeDefPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 593 .add(typeDefPanelLayout.createSequentialGroup() 594 .add(typeDefPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 595 .add(baseTypeLabel) 596 .add(typeDefPanelLayout.createSequentialGroup() 597 .add(11, 11, 11) 598 .add(typeDefPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 599 .add(inlineTypeButton) 600 .add(useExistingButton))) 601 .add(typeDefPanelLayout.createSequentialGroup() 602 .add(30, 30, 30) 603 .add(typePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE))) 604 .addContainerGap()) 605 ); 606 typeDefPanelLayout.setVerticalGroup( 607 typeDefPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 608 .add(typeDefPanelLayout.createSequentialGroup() 609 .add(baseTypeLabel) 610 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 611 .add(inlineTypeButton) 612 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 613 .add(useExistingButton) 614 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 615 .add(typePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)) 616 ); 617 618 previewLabel.setLabelFor(previewPane); 619 org.openide.awt.Mnemonics.setLocalizedText(previewLabel, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "TITLE_CustomizerForm_Preview")); 620 previewLabel.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_Preview")); 621 622 previewPane.setEditable(false); 623 previewPane.setContentType("text/xml"); 624 previewPane.setEnabled(false); 625 jScrollPane1.setViewportView(previewPane); 626 627 org.openide.awt.Mnemonics.setLocalizedText(typeLabel, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "TITLE_SimpleTypeForm_DerivationTypePanel", new Object [] {})); 628 typeLabel.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_DerivationTypePanel")); 629 630 derivationGroup.add(restrictionButton); 631 org.openide.awt.Mnemonics.setLocalizedText(restrictionButton, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "LBL_SimpleTypeForm_Restriction_Button")); 632 restrictionButton.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_Restriction_Button")); 633 restrictionButton.setMargin(new java.awt.Insets (0, 0, 0, 0)); 634 635 derivationGroup.add(listButton); 636 org.openide.awt.Mnemonics.setLocalizedText(listButton, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "LBL_SimpleTypeForm_List_Button")); 637 listButton.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_List_Button")); 638 listButton.setMargin(new java.awt.Insets (0, 0, 0, 0)); 639 640 derivationGroup.add(unionButton); 641 org.openide.awt.Mnemonics.setLocalizedText(unionButton, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "LBL_SimpleTypeForm_Union_Button")); 642 unionButton.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_Union_Button")); 643 unionButton.setMargin(new java.awt.Insets (0, 0, 0, 0)); 644 645 mPanel.setLayout(new java.awt.BorderLayout ()); 646 647 mPanel.add(getMessageDisplayer().getComponent(),java.awt.BorderLayout.CENTER); 648 649 nameLabel.setLabelFor(nameTextField); 650 org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "LBL_CustomizerForm_Name")); 651 nameLabel.setToolTipText(org.openide.util.NbBundle.getMessage(SimpleTypeCustomizer.class, "HINT_SimpleTypeForm_Name")); 652 653 nameTextField.setEditable(!hasParent()); 654 655 org.jdesktop.layout.GroupLayout namePanelLayout = new org.jdesktop.layout.GroupLayout(namePanel); 656 namePanel.setLayout(namePanelLayout); 657 namePanelLayout.setHorizontalGroup( 658 namePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 659 .add(namePanelLayout.createSequentialGroup() 660 .addContainerGap() 661 .add(nameLabel) 662 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 663 .add(nameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE) 664 .addContainerGap()) 665 ); 666 namePanelLayout.setVerticalGroup( 667 namePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 668 .add(namePanelLayout.createSequentialGroup() 669 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 670 .add(namePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 671 .add(nameLabel) 672 .add(nameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) 673 ); 674 675 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 676 this.setLayout(layout); 677 layout.setHorizontalGroup( 678 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 679 .add(layout.createSequentialGroup() 680 .addContainerGap() 681 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 682 .add(typeLabel) 683 .add(layout.createSequentialGroup() 684 .add(11, 11, 11) 685 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 686 .add(listButton) 687 .add(restrictionButton) 688 .add(unionButton)))) 689 .addContainerGap(398, Short.MAX_VALUE)) 690 .add(namePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 691 .add(org.jdesktop.layout.GroupLayout.TRAILING, mPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE) 692 .add(layout.createSequentialGroup() 693 .addContainerGap() 694 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 695 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE) 696 .add(previewLabel)) 697 .addContainerGap()) 698 .add(layout.createSequentialGroup() 699 .addContainerGap() 700 .add(typeDefPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 701 ); 702 layout.setVerticalGroup( 703 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 704 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() 705 .add(namePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 706 .add(11, 11, 11) 707 .add(typeLabel) 708 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 709 .add(restrictionButton) 710 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 711 .add(listButton) 712 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 713 .add(unionButton) 714 .add(11, 11, 11) 715 .add(typeDefPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 716 .add(11, 11, 11) 717 .add(previewLabel) 718 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 719 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE) 720 .add(0, 0, 0) 721 .add(mPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)) 722 ); 723 } 725 public HelpCtx getHelpCtx() { 726 return new HelpCtx(SimpleTypeCustomizer.class); 727 } 728 729 public javax.swing.JLabel baseTypeLabel; 731 public javax.swing.ButtonGroup derivationGroup; 732 public javax.swing.JRadioButton inlineTypeButton; 733 public javax.swing.JScrollPane jScrollPane1; 734 public javax.swing.JRadioButton listButton; 735 public javax.swing.JPanel mPanel; 736 public javax.swing.JLabel nameLabel; 737 public javax.swing.JPanel namePanel; 738 public javax.swing.JTextField nameTextField; 739 public javax.swing.JLabel previewLabel; 740 public javax.swing.JEditorPane previewPane; 741 public javax.swing.JRadioButton restrictionButton; 742 public javax.swing.JPanel typeDefPanel; 743 public javax.swing.ButtonGroup typeGroup; 744 public javax.swing.JLabel typeLabel; 745 public javax.swing.JPanel typePanel; 746 public javax.swing.JRadioButton unionButton; 747 public javax.swing.JRadioButton useExistingButton; 748 750 private DocumentListener nameListener; 751 private transient ItemListener buttonListener; 752 private transient GlobalSimpleType currentGlobalSimpleType; 753 private transient DerivationType derivation; 754 private transient TypeDefinition typeDef; 755 private transient SchemaComponentSelectionPanel<GlobalSimpleType> 756 componentSelectionPanel; 757 private enum DerivationType {RESTRICTION,LIST,UNION}; 758 private enum TypeDefinition {EXISTING,INLINE}; 759 760 } 761 | Popular Tags |