1 19 20 package org.netbeans.modules.xml.schema.ui.nodes; 21 22 import java.awt.Dialog ; 23 import java.awt.datatransfer.Transferable ; 24 import java.beans.FeatureDescriptor ; 25 import java.beans.PropertyChangeEvent ; 26 import java.beans.PropertyChangeListener ; 27 import java.beans.PropertyEditor ; 28 import java.beans.PropertyEditorSupport ; 29 import java.io.IOException ; 30 import java.lang.ref.SoftReference ; 31 import java.lang.reflect.InvocationTargetException ; 32 import java.util.ArrayList ; 33 import java.util.Collections ; 34 import java.util.LinkedList ; 35 import java.util.List ; 36 import java.util.Set ; 37 import javax.swing.Action ; 38 import org.netbeans.modules.xml.refactoring.actions.FindUsagesAction; 39 import org.netbeans.modules.xml.refactoring.actions.RefactorAction; 40 import org.netbeans.modules.xml.refactoring.ui.ReferenceableProvider; 41 import org.netbeans.modules.xml.refactoring.ui.util.AnalysisUtilities; 42 import org.netbeans.modules.xml.schema.model.Annotation; 43 import org.netbeans.modules.xml.schema.model.Documentation; 44 import org.netbeans.modules.xml.schema.model.ReferenceableSchemaComponent; 45 import org.netbeans.modules.xml.schema.model.Schema; 46 import org.netbeans.modules.xml.schema.model.SchemaComponent; 47 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 48 import org.netbeans.modules.xml.schema.model.SchemaModel; 49 import org.netbeans.modules.xml.schema.ui.basic.DesignGotoType; 50 import org.netbeans.modules.xml.schema.ui.basic.SchemaGotoType; 51 import org.netbeans.modules.xml.schema.ui.basic.SchemaSettings; 52 import org.netbeans.modules.xml.schema.ui.basic.UIUtilities; 53 import org.netbeans.modules.xml.xam.dom.Utils; 54 import org.netbeans.modules.xml.xam.ui.ComponentPasteType; 55 import org.netbeans.modules.xml.xam.ui.actions.GotoType; 56 import org.netbeans.modules.xml.xam.ui.actions.SourceGotoType; 57 import org.netbeans.modules.xml.xam.ui.actions.SuperGotoType; 58 import org.netbeans.modules.xml.xam.ui.cookies.GetComponentCookie; 59 import org.netbeans.modules.xml.xam.ui.cookies.GetSuperCookie; 60 import org.netbeans.modules.xml.xam.Component; 61 import org.netbeans.modules.xml.xam.ComponentEvent; 62 import org.netbeans.modules.xml.xam.ComponentListener; 63 import org.netbeans.modules.xml.xam.Nameable; 64 import org.netbeans.modules.xml.xam.Named; 65 import org.netbeans.modules.xml.xam.NamedReferenceable; 66 import org.netbeans.modules.xml.schema.ui.basic.ShowSchemaAction; 67 import org.netbeans.modules.xml.xam.ui.cookies.GotoCookie; 68 import org.netbeans.modules.xml.xam.ui.customizer.Customizer; 69 import org.netbeans.modules.xml.xam.ui.customizer.CustomizerProvider; 70 import org.netbeans.modules.xml.xam.ui.highlight.Highlight; 71 import org.netbeans.modules.xml.xam.ui.highlight.HighlightManager; 72 import org.netbeans.modules.xml.xam.ui.highlight.Highlighted; 73 import org.netbeans.modules.xml.schema.ui.basic.editors.StringEditor; 74 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BaseSchemaProperty; 75 import org.netbeans.modules.xml.xam.ui.XAMUtils; 76 import org.netbeans.modules.xml.xam.ui.actions.GoToAction; 77 import org.netbeans.modules.xml.xam.ui.cookies.CountChildrenCookie; 78 import org.openide.DialogDescriptor; 79 import org.openide.DialogDisplayer; 80 import org.openide.ErrorManager; 81 import org.openide.actions.CopyAction; 82 import org.openide.actions.CutAction; 83 import org.openide.actions.DeleteAction; 84 import org.openide.actions.NewAction; 85 import org.openide.actions.PasteAction; 86 import org.openide.actions.PropertiesAction; 87 import org.openide.actions.ReorderAction; 88 import org.openide.explorer.propertysheet.ExPropertyEditor; 89 import org.openide.explorer.propertysheet.PropertyEnv; 90 import org.openide.filesystems.FileObject; 91 import org.openide.loaders.DataObject; 92 import org.openide.loaders.DataObjectNotFoundException; 93 import org.openide.nodes.AbstractNode; 94 import org.openide.nodes.Children; 95 import org.openide.nodes.Index; 96 import org.openide.nodes.Node; 97 import org.openide.nodes.Node.Property; 98 import org.openide.nodes.PropertySupport; 99 import org.openide.nodes.Sheet; 100 import org.openide.util.HelpCtx; 101 import org.openide.util.Lookup; 102 import org.openide.util.NbBundle; 103 import org.openide.util.WeakListeners; 104 import org.openide.util.actions.SystemAction; 105 import org.openide.util.datatransfer.NewType; 106 import org.openide.util.datatransfer.PasteType; 107 import org.openide.util.lookup.AbstractLookup; 108 import org.openide.util.lookup.InstanceContent; 109 import org.openide.util.lookup.Lookups; 110 import org.openide.util.lookup.ProxyLookup; 111 112 117 public abstract class SchemaComponentNode<T extends SchemaComponent> 118 extends AbstractNode 119 implements Node.Cookie, ComponentListener, PropertyChangeListener , 120 Highlighted, ReferenceableProvider, CountChildrenCookie, 121 GetComponentCookie, GetSuperCookie, GotoCookie { 122 123 127 public SchemaComponentNode(SchemaUIContext context, 128 SchemaComponentReference<T> reference, Children children) { 129 this(context,reference,children,new InstanceContent()); 130 } 131 132 133 137 private SchemaComponentNode(SchemaUIContext context, 138 SchemaComponentReference<T> reference, Children children, 139 InstanceContent contents) { 140 super(children, createLookup(context, contents)); 141 142 this.context=context; 143 this.reference=reference; 144 this.lookupContents=contents; 145 146 contents.add(this); 148 DataObject dobj = getDataObject(); 151 if (dobj != null) { 152 contents.add(dobj); 153 } 154 contents.add(context); 155 contents.add(reference); 156 contents.add(new DefaultExpandedCookie(false)); 157 163 if (children instanceof Index && isEditable() && 165 !(reference.get() instanceof Schema)) { 167 contents.add(children); 168 } 169 T comp = reference.get(); 170 contents.add(comp); 171 172 SchemaModel model = reference.get().getModel(); 176 if (model != null) { 177 weakModelListener= 178 WeakListeners.propertyChange(this,model); 179 model.addPropertyChangeListener(weakModelListener); 180 weakComponentListener = (ComponentListener) WeakListeners.create( 181 ComponentListener.class, this, model); 182 model.addComponentListener(weakComponentListener); 183 } 184 if (comp instanceof Named) { 186 _setName(((Named) comp).getName()); 189 } else { 190 _setName(comp.getPeer().getLocalName()); 191 } 192 if (model != null) { 194 updateDisplayName(); 196 updateShortDescription(); 198 } 199 200 setIconBaseWithExtension( 201 "org/netbeans/modules/xml/schema/ui/nodes/resources/"+ 202 "generic.png"); 203 204 referenceSet = Collections.singleton( 205 (Component) ((SchemaComponentReference) reference).get()); 206 highlights = new LinkedList <Highlight>(); 207 HighlightManager.getDefault().addHighlighted(this); 208 } 209 210 216 private static Lookup createLookup(SchemaUIContext context, 217 InstanceContent contents) { 218 return new ProxyLookup(new Lookup[] { 223 new AbstractLookup(contents), 228 Lookups.exclude(context.getLookup(), new Class [] { 229 Node.class, 230 DataObject.class, 231 }), 232 }); 233 } 234 235 241 private DataObject getDataObject() { 242 try { 243 SchemaModel model = reference.get().getModel(); 246 if (model != null) { 247 FileObject fobj = (FileObject) model.getModelSource(). 248 getLookup().lookup(FileObject.class); 249 if (fobj != null) { 250 return DataObject.find(fobj); 251 } 252 } 253 } catch (DataObjectNotFoundException donfe) { 254 } 256 return null; 257 } 258 259 264 protected CustomizerProvider getCustomizerProvider() { 265 return null; 266 } 267 268 275 @Override 276 public java.awt.Component getCustomizer() { 277 if(!hasCustomizer()|| !isEditable()) return null; 278 if(custRef==null || custRef.get()==null) { 280 CustomizerProvider cp = getCustomizerProvider(); 281 if (cp==null) return null; 282 Customizer cust = cp.getCustomizer(); 283 if (cust==null || cust.getComponent()==null) return null; 284 custRef = new SoftReference <Customizer>(cust); 285 } else { 286 custRef.get().reset(); 288 } 289 Customizer customizer = custRef.get(); 290 DialogDescriptor descriptor = UIUtilities. 291 getCustomizerDialog(customizer,getTypeDisplayName(),isEditable()); 292 Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor); 293 dlg.getAccessibleContext().setAccessibleDescription(dlg.getTitle()); 294 return dlg; 295 } 296 297 301 public boolean equals(Object o) { 302 if (o instanceof SchemaComponentNode) { 304 SchemaComponentNode scn = (SchemaComponentNode) o; 305 SchemaComponentReference scr = scn.getReference(); 306 return scr.equals(reference); 307 } 308 return false; 309 } 310 311 312 316 public int hashCode() { 317 return reference.hashCode(); 319 } 320 321 322 326 public SchemaUIContext getContext() { 327 return context; 328 } 329 330 331 335 public SchemaComponentReference<T> getReference() { 336 return reference; 337 } 338 339 340 345 protected InstanceContent getLookupContents() { 346 return lookupContents; 347 } 348 349 355 protected boolean isValid() { 356 return getReference().get().getModel() != null; 357 } 358 359 365 protected boolean isEditable() { 366 SchemaModel model = getReference().get().getModel(); 367 return model != null && model == getContext().getModel() && 368 XAMUtils.isWritable(model); 369 } 370 371 378 protected void updateDisplayName() { 379 if (!isValid()) { 380 return; 382 } 383 T component = getReference().get(); 384 if (component instanceof Named) { 385 String name=((Named)component).getName(); 386 _setName(name); 388 if(name==null||name.equals("")) name = component.getPeer().getLocalName(); 389 setDisplayName(name); 390 } 391 } 392 393 394 398 private void updateShortDescription() { 399 if (!isValid()) { 400 return; 402 } 403 T component = getReference().get(); 404 Documentation d = null; 405 Annotation a = null; 406 String language = SchemaSettings.getDefault().getLanguage(); 407 if (component instanceof Documentation) { 408 d = (Documentation) component; 409 } else if (component instanceof Annotation) { 410 a = (Annotation) component; 411 } else { 412 a = component.getAnnotation(); 413 } 414 if (a != null && !a.getDocumentationElements().isEmpty()) { 415 if(language==null) { 416 d = a.getDocumentationElements().iterator().next(); 417 } else { 418 for (Documentation doc:a.getDocumentationElements()) { 419 if(language.equals(doc.getLanguage())) { 420 d = doc; 421 break; 422 } 423 } 424 if(d==null) { 425 d = a.getDocumentationElements().iterator().next(); 426 } 427 } 428 } 429 if (d != null) { 430 setShortDescription(d.getContentFragment()); 431 } else { 432 setShortDescription(null); 433 } 434 } 435 436 437 441 public abstract String getTypeDisplayName(); 442 443 444 448 protected String getHtmlTypeDisplayName() { 449 return "<font color='#aaaaaa'>("+getTypeDisplayName()+")</font>"; 450 } 451 452 453 457 public boolean isDefaultExpanded() { 458 DefaultExpandedCookie cookie=(DefaultExpandedCookie) 459 getCookie(DefaultExpandedCookie.class); 460 if (cookie!=null) 461 return cookie.isDefaultExpanded(); 462 else 463 return false; 464 } 465 466 467 471 public void setDefaultExpanded(boolean value) { 472 DefaultExpandedCookie cookie=(DefaultExpandedCookie) 473 getCookie(DefaultExpandedCookie.class); 474 if (cookie!=null) 475 cookie.setDefaultExpanded(value); 476 } 477 478 479 485 protected ReferenceableSchemaComponent getSuperDefinition() { 486 return null; 487 } 488 489 public int getChildCount() { 490 return getReference().get().getChildren().size(); 491 } 492 493 public Component getComponent() { 494 return getReference().get(); 495 } 496 497 public Class <? extends Component> getComponentType() { 498 return getReference().get().getComponentType(); 499 } 500 501 public SchemaComponent getSuper() 503 { 504 return getSuperDefinition(); 505 } 506 507 508 512 516 @Override 517 public HelpCtx getHelpCtx() { 518 return new HelpCtx(getClass()); 519 } 520 521 522 526 @Override 527 public boolean canCut() { 528 return isEditable(); 529 } 530 531 532 536 @Override 537 public boolean canCopy() { 538 return true; 539 } 540 541 @Override 542 @SuppressWarnings ("unchecked") 543 protected void createPasteTypes(Transferable transferable, List list) { 544 if (isValid() && isEditable()) { 545 PasteType type = ComponentPasteType.getPasteType( 546 reference.get(), transferable, null); 547 if (type != null) { 548 list.add(type); 549 } 550 } 551 } 552 553 @Override 554 public PasteType getDropType(Transferable transferable, int action, int index) { 555 if (isValid() && isEditable()) { 556 PasteType type = ComponentPasteType.getDropType( 557 reference.get(), transferable, null, action, index); 558 if (type != null) { 559 return type; 560 } 561 } 562 return null; 563 } 564 565 @Override 566 public boolean canDestroy() { 567 SchemaComponent component = getReference().get(); 568 if (component instanceof Schema || !isEditable()) { 569 return false; 570 } 571 return true; 572 } 573 574 575 579 @Override 580 public boolean canRename() { 581 return supportsRename(); 582 } 583 584 585 590 private boolean isNameable() { 591 return Nameable.class.isAssignableFrom( 595 getReference().get().getComponentType()); 596 } 597 598 599 604 private boolean supportsRename() { 605 return isNameable() && isEditable(); 607 } 608 609 610 614 private void _setName(String value) { 615 if(value==null) value=""; 617 super.setName(value); 618 } 619 620 621 625 @Override 626 public void setName(String value) { 627 NamedReferenceable ref = getReferenceable(); 628 if(ref==null) 629 { 630 _setName(value); 631 if (supportsRename()) 632 { 633 try 634 { 635 getReference().get().getModel().startTransaction(); 636 Nameable n = (Nameable)getReference().get(); 637 n.setName(value); 638 } 639 finally 640 { 641 getReference().get().getModel().endTransaction(); 642 } 643 } 644 } 645 else 646 { 647 AnalysisUtilities.locallyRenameRefactor((Nameable)ref, value); 648 } 649 } 650 651 655 public void destroy() throws IOException { 656 SchemaModel model = getReference().get().getModel(); 657 if(model == null) { 658 model = getContext().getModel(); 663 model.removeComponentListener(weakComponentListener); 664 model.removePropertyChangeListener(weakModelListener); 665 } else { 666 model.removeComponentListener(weakComponentListener); 667 model.removePropertyChangeListener(weakModelListener); 668 669 SchemaComponent component = getReference().get(); 671 try { 672 model.startTransaction(); 673 model.removeChildComponent(component); 674 } finally { 675 model.endTransaction(); 676 } 677 } 678 super.destroy(); 679 } 680 681 682 686 @Override 687 protected Sheet createSheet() { 688 super.createSheet(); 689 Sheet sheet=Sheet.createDefault(); 690 Sheet.Set set=sheet.get(Sheet.PROPERTIES); 691 set.put( 692 new PropertySupport("kind",String .class, 693 NbBundle.getMessage(SchemaComponentNode.class, 694 "PROP_SchemaComponentNode_Kind"), 695 "",true,false) { 696 public Object getValue() { 697 return getTypeDisplayName(); 698 } 699 700 public void setValue(Object value) { 701 } 703 }); 704 705 try { 706 Property idProperty = new BaseSchemaProperty((SchemaComponent)getReference().get(), 708 String .class, 709 SchemaComponent.ID_PROPERTY, 710 NbBundle.getMessage(SchemaComponentNode.class, 711 "PROP_SchemaComponentNode_ID"), 712 NbBundle.getMessage(SchemaComponentNode.class, 713 "PROP_SchemaComponentNode_IDDesc"), 714 StringEditor.class 715 ){ 716 public void setValue(Object o) throws 717 IllegalAccessException , InvocationTargetException { 718 if (o instanceof String ) { 719 if("".equals(o)) { 720 super.setValue(null); 721 } else if (Utils.isValidNCName(o.toString())){ 722 super.setValue(o); 723 } else { 724 String msg = NbBundle.getMessage(BaseSchemaProperty.class, 725 "MSG_Neg_Int_Value", o); IllegalArgumentException iae = new IllegalArgumentException (msg); 727 ErrorManager.getDefault().annotate(iae, ErrorManager.USER, 728 msg, msg, null, new java.util.Date ()); 729 throw iae; 730 } 731 } else { 732 super.setValue(o); 733 } 734 } 735 }; 736 set.put(new SchemaModelFlushWrapper(getReference().get(), idProperty)); 737 } catch (NoSuchMethodException nsme) { 738 assert false: "properties must be defined"; 739 } 740 741 if (isNameable()) 743 set.put(new PropertySupport.Name(this)); 744 745 if(hasCustomizer()&&isEditable()) { 746 Property structureProp = new PropertySupport.ReadWrite("structure", String .class, 748 NbBundle.getMessage(SchemaComponentNode.class, 749 "PROP_SchemaComponentNode_Customize"), 750 NbBundle.getMessage(SchemaComponentNode.class, 751 "PROP_SchemaComponentNode_Customize_ShortDesc")) { 752 public Object getValue() throws IllegalAccessException ,InvocationTargetException { 753 return NbBundle.getMessage(SchemaComponentNode.class, 754 "PROP_SchemaComponentNode_Customize_Label"); 755 } 756 public void setValue(Object val) throws IllegalAccessException ,IllegalArgumentException ,InvocationTargetException { 757 } 758 public PropertyEditor getPropertyEditor() { 759 return new StructurePropertyEditor(); 760 } 761 }; 762 set.put(structureProp); 763 } 764 765 return sheet; 766 } 767 768 775 protected boolean allowReordering() { 776 return getReference().get().getChildren().size() > 1; 780 } 781 782 @Override 783 public Action [] getActions(boolean context) { 784 ReadOnlyCookie roc = (ReadOnlyCookie) getContext().getLookup().lookup( 785 ReadOnlyCookie.class); 786 List <Action > actions = new ArrayList <Action >(); 787 if (roc != null && roc.isReadOnly()) { 788 actions.add(SystemAction.get(GoToAction.class)); 790 } else { 791 actions.add(SystemAction.get(CutAction.class)); 793 actions.add(SystemAction.get(CopyAction.class)); 794 actions.add(SystemAction.get(PasteAction.class)); 795 actions.add(null); 796 actions.add(SystemAction.get(NewAction.class)); 797 actions.add(SystemAction.get(DeleteAction.class)); 798 if (allowReordering()) { 799 actions.add(SystemAction.get(ReorderAction.class)); 800 } 801 actions.add(null); 802 actions.add(SystemAction.get(GoToAction.class)); 803 actions.add(SystemAction.get(FindUsagesAction.class)); 804 actions.add(null); 805 actions.add(SystemAction.get(RefactorAction.class)); 806 actions.add(null); 807 actions.add(SystemAction.get(PropertiesAction.class)); 808 } 809 return actions.toArray(new Action [actions.size()]); 810 } 811 812 @Override 813 public Action getPreferredAction() { 814 ReadOnlyCookie roc = (ReadOnlyCookie) getCookie(ReadOnlyCookie.class); 816 if (roc != null && roc.isReadOnly()) { 817 return SystemAction.get(ShowSchemaAction.class); 818 } 819 return super.getPreferredAction(); 820 } 821 822 823 829 protected NewTypesFactory getNewTypesFactory() { 830 return new NewTypesFactory(); 831 } 832 833 public final NewType[] getNewTypes() { 834 if(isEditable()) { 835 return getNewTypesFactory().getNewTypes(getReference(), null); 836 } 837 return new NewType[] {}; 838 } 839 840 public GotoType[] getGotoTypes() { 841 return GOTO_TYPES; 842 } 843 844 848 public void childrenAdded(ComponentEvent evt) { 849 if (isValid()) { 850 if(evt.getSource() == getReference().get()) 851 { 852 ((RefreshableChildren) getChildren()).refreshChildren(); 853 } 854 if(evt.getSource() == getReference().get() || 855 evt.getSource() == getReference().get().getAnnotation()) 856 { 857 updateShortDescription(); 858 } 859 } 860 } 861 862 public void childrenDeleted(ComponentEvent evt) { 863 if (isValid()) { 864 if(evt.getSource() == getReference().get()) 865 { 866 ((RefreshableChildren) getChildren()).refreshChildren(); 867 } 868 if(evt.getSource() == getReference().get() || 869 evt.getSource() == getReference().get().getAnnotation()) 870 { 871 updateShortDescription(); 872 } 873 } 874 } 875 876 public void valueChanged(ComponentEvent evt) { 877 if (isValid()) 878 { 879 T component = getReference().get(); 880 if(evt.getSource() == component) 881 { 882 updateDisplayName(); 883 } 884 Documentation d = null; 885 if(component instanceof Documentation) 886 d = (Documentation)component; 887 else if(component instanceof Annotation) 888 { 889 Annotation a = (Annotation)component; 890 if(!a.getDocumentationElements().isEmpty()) 891 d = a.getDocumentationElements().iterator().next(); 892 } 893 else 894 { 895 Annotation a = component.getAnnotation(); 896 if(a!=null && !a.getDocumentationElements().isEmpty()) 897 d = a.getDocumentationElements().iterator().next(); 898 } 899 if(evt.getSource()==d) 900 { 901 updateShortDescription(); 902 } 903 } 904 } 905 906 912 public void propertyChange(PropertyChangeEvent event) { 913 if (isValid() && event.getSource() == getReference().get()) { 914 try { 915 updateDisplayName(); 916 String propName = event.getPropertyName(); 917 Sheet.Set propertySet = getSheet().get(Sheet.PROPERTIES); 918 if(propertySet!=null){ 919 if (propertySet.get(propName)!=null) { 920 firePropertyChange(propName,event.getOldValue(), 921 event.getNewValue()); 922 } 923 else { 924 ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, 925 propName + " property is not defined in " + 926 getTypeDisplayName()); 927 } 928 } 929 } catch (IllegalStateException ise) { 930 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ise); 932 } catch (NullPointerException npe) { 933 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, npe); 935 } 936 } 937 } 938 939 public Set <Component> getComponents() { 940 return referenceSet; 941 } 942 943 public void highlightAdded(Highlight hl) { 944 highlights.add(hl); 945 fireDisplayNameChange("TempName", getDisplayName()); 946 } 947 948 public void highlightRemoved(Highlight hl) { 949 highlights.remove(hl); 950 fireDisplayNameChange("TempName", getDisplayName()); 951 } 952 953 961 protected String applyHighlights(String name) { 962 int count = highlights.size(); 963 if (count > 0) { 964 Highlight hl = highlights.get(count - 1); 966 String type = hl.getType(); 967 String code = null; 968 969 970 if (type.equals(Highlight.SEARCH_RESULT)) { 971 code = "e68b2c"; 972 } else if (type.equals(Highlight.SEARCH_RESULT_PARENT)) { 973 code = "ffc73c"; 974 } else if (type.equals(Highlight.FIND_USAGES_RESULT_PARENT)) { 975 code = "B5E682"; }else if (type.equals(Highlight.FIND_USAGES_RESULT)) { 977 code = "8be62c"; } 979 name = "<strong><font color=\"#" + code + "\">" + name + 980 "</font></strong>"; 981 } 982 return name; 983 } 984 985 public String getDisplayName() { 986 String instanceName = getDefaultDisplayName(); 987 return instanceName.length()==0 ? instanceName : 988 instanceName + " " + "[" + getTypeDisplayName() + "]"; } 990 991 public String getDefaultDisplayName() { 992 String instanceName = super.getDisplayName(); 993 return instanceName == null || instanceName.length() == 0 994 ? "" : instanceName; 995 } 996 997 public String getHtmlDisplayName() { 998 String name = getDefaultDisplayName(); 999 if(name!=null) 1001 name = name.replace("<", "<").replace(">", ">"); 1002 return applyHighlights(name); 1003 } 1004 1005 1009 private class StructurePropertyEditor extends PropertyEditorSupport 1010 implements ExPropertyEditor { 1011 public boolean supportsCustomEditor() { 1012 return true; 1013 } 1014 1015 public java.awt.Component getCustomEditor() { 1016 return getCustomizer(); 1017 } 1018 1019 public void attachEnv(PropertyEnv env ) { 1020 FeatureDescriptor desc = env.getFeatureDescriptor(); 1021 desc.setValue("canEditAsText", Boolean.FALSE); } 1023 } 1024 1025 private SchemaUIContext context; 1026 private SchemaComponentReference<T> reference; 1027 private Set <Component> referenceSet; 1028 1029 private List <Highlight> highlights; 1030 private InstanceContent lookupContents; 1031 private PropertyChangeListener modelListener; 1032 private PropertyChangeListener weakModelListener; 1033 private ComponentListener weakComponentListener; 1034 private SoftReference <Customizer> custRef; 1035 private static final GotoType[] GOTO_TYPES = new GotoType[] { 1036 new SourceGotoType(), 1037 new SchemaGotoType(), 1038 new DesignGotoType(), 1039 new SuperGotoType(), 1040 }; 1041 1042 1049 public NamedReferenceable getReferenceable() { 1050 SchemaComponent comp = reference.get(); 1051 if (comp instanceof NamedReferenceable && isValid() && comp.getModel(). 1052 getModelSource().getLookup().lookup(FileObject.class) != null){ 1053 return NamedReferenceable.class.cast(comp); 1054 } 1055 return null; 1056 } 1057 1058 1062 public void setReferencingNode(final Node referencingNode) { 1063 getLookupContents().add( 1064 new ReferencingNodeProvider() { 1065 public Node getNode() { 1066 return referencingNode; 1067 } 1068 }); 1069 } 1070} 1071 | Popular Tags |