1 19 20 26 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor; 27 28 import java.awt.Image ; 29 import java.beans.PropertyChangeEvent ; 30 import java.util.logging.Level ; 31 32 import javax.swing.Action ; 33 import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory; 34 35 import org.netbeans.modules.xml.wsdl.model.Documentation; 38 import org.netbeans.modules.xml.wsdl.ui.api.property.PropertyAdapter; 39 import org.netbeans.modules.xml.wsdl.ui.commands.CommonAttributePropertyAdapter; 40 import org.netbeans.modules.xml.wsdl.ui.view.property.BaseAttributeProperty; 41 import org.netbeans.modules.xml.xam.ui.actions.GoToAction; 42 import org.openide.actions.CopyAction; 43 import org.openide.actions.CutAction; 44 import org.openide.actions.DeleteAction; 45 import org.openide.actions.PasteAction; 46 import org.openide.actions.PropertiesAction; 47 import org.openide.nodes.Children; 48 import org.openide.nodes.Node; 49 import org.openide.nodes.Sheet; 50 import org.openide.util.NbBundle; 51 import org.openide.util.Utilities; 52 import org.openide.util.actions.SystemAction; 53 54 55 56 62 public class DocumentationNode extends WSDLElementNode { 63 64 protected Documentation mWSDLConstruct; 65 66 Image ICON =Utilities.loadImage 67 ("org/netbeans/modules/xml/wsdl/ui/view/resources/documentation.png"); 68 69 private DocumentationPropertyAdapter mPropertyAdapter; 70 71 private static final SystemAction[] ACTIONS = new SystemAction[] { 72 SystemAction.get(CutAction.class), 73 SystemAction.get(CopyAction.class), 74 SystemAction.get(PasteAction.class), 75 null, 76 SystemAction.get(DeleteAction.class), 77 null, 78 SystemAction.get(GoToAction.class), 79 (SystemAction)RefactoringActionsFactory.whereUsedAction(), 81 null, 82 (SystemAction)RefactoringActionsFactory.editorSubmenuAction(), 83 null, 84 SystemAction.get(PropertiesAction.class), 85 }; 86 87 public DocumentationNode(Documentation wsdlConstruct) { 88 super(Children.LEAF, wsdlConstruct); 89 mWSDLConstruct = wsdlConstruct; 90 this.setDisplayName(NbBundle.getMessage(TypesNode.class, "DOCUMENTATION_NODE_NAME")); 91 92 this.mPropertyAdapter = new DocumentationPropertyAdapter(); 93 } 94 95 96 @Override 97 public Image getIcon(int type) { 98 return ICON; 99 } 100 101 @Override 102 public Image getOpenedIcon(int type) { 103 return ICON; 104 } 105 106 public Object getWSDLConstruct() { 107 return mWSDLConstruct; 108 } 109 110 @Override 111 public Action [] getActions(boolean context) { 112 return ACTIONS; 113 } 114 115 @Override 116 protected void refreshAttributesSheetSet() { 117 Sheet.Set ss = createPropertiesSheetSet(); 118 try { 119 Node.Property nameProperty = new BaseAttributeProperty(mPropertyAdapter, String .class, CommonAttributePropertyAdapter.VALUE); 121 122 123 nameProperty.setName(NbBundle.getMessage(DocumentationNode.class, "DOC_NODE_Documentation_text")); 124 nameProperty.setShortDescription(NbBundle.getMessage(DocumentationNode.class, "DOC_NODE_Documentation_text")); 125 ss.put(nameProperty); 126 127 128 } catch(Exception ex) { 129 mLogger.log(Level.SEVERE, "failed to create property sheet for "+ mWSDLConstruct, ex); 130 } 131 } 132 133 public void nodeValueChanged(PropertyChangeEvent evt) { 134 this.firePropertySetsChange(new Node.PropertySet[] {}, this.getPropertySets()); 137 } 138 139 public class DocumentationPropertyAdapter extends PropertyAdapter { 140 141 public DocumentationPropertyAdapter() { 142 super(mWSDLConstruct); 143 } 144 145 public void setValue(String value) { 146 mWSDLConstruct.getModel().startTransaction(); 147 mWSDLConstruct.setTextContent(value); 148 mWSDLConstruct.getModel().endTransaction(); 149 } 150 151 public String getValue() { 152 if(mWSDLConstruct.getTextContent() == null) { 153 return ""; 154 } 155 156 return mWSDLConstruct.getTextContent(); 157 } 158 159 } 160 161 @Override 162 public String getTypeDisplayName() { 163 return NbBundle.getMessage(DocumentationNode.class, "LBL_DocumentationNode_TypeDisplayName"); 164 } 165 } 166 167 | Popular Tags |