1 19 20 package org.netbeans.modules.form; 21 22 import org.openide.nodes.*; 23 import org.openide.actions.PropertiesAction; 24 import org.openide.util.actions.SystemAction; 25 26 import org.netbeans.modules.form.actions.*; 27 28 34 35 class FormRootNode extends FormNode { 36 private Node.Property[] codeGenProperties; 37 private Node.Property[] i18nProperties; 38 private Node.Property[] allProperties; 39 40 public FormRootNode(FormModel formModel) { 41 super(new RootChildren(formModel), formModel); 42 setName("Form Root Node"); setIconBaseWithExtension("org/netbeans/modules/form/resources/formDesigner.gif"); updateName(formModel.getName()); 45 } 46 47 51 public boolean canRename() { 52 return false; 53 } 54 55 public boolean canDestroy() { 56 return false; 57 } 58 59 public javax.swing.Action [] getActions(boolean context) { 60 if (systemActions == null) systemActions = new SystemAction[] { 62 SystemAction.get(ReloadAction.class), 63 null, 64 SystemAction.get(PropertiesAction.class) 65 }; 66 return systemActions; 67 } 68 69 void updateName(String name) { 70 setDisplayName(FormUtils.getFormattedBundleString("FMT_FormNodeName", new Object [] { name })); 72 } 73 74 FormOthersNode getOthersNode() { 75 return ((RootChildren)getChildren()).othersNode; 76 } 77 78 public Node.PropertySet[] getPropertySets() { 79 Node.PropertySet codeSet = new Node.PropertySet( 80 "codeGeneration", FormUtils.getBundleString("CTL_SyntheticTab"), FormUtils.getBundleString("CTL_SyntheticTabHint")) { 84 public Node.Property[] getProperties() { 85 return getCodeGenProperties(); 86 } 87 }; 88 Node.PropertySet i18nSet = new Node.PropertySet( 89 "i18n", FormUtils.getBundleString("CTL_I18nTab"), FormUtils.getBundleString("CTL_I18nTabHint")) { 93 public Node.Property[] getProperties() { 94 return getI18nProperties(); 95 } 96 }; 97 return new Node.PropertySet[] { codeSet, i18nSet }; 98 } 99 100 Node.Property[] getCodeGenProperties() { 101 if (codeGenProperties == null) 102 codeGenProperties = createCodeGenProperties(); 103 return codeGenProperties; 104 } 105 106 private Node.Property[] createCodeGenProperties() { 107 return FormEditor.getCodeGenerator(getFormModel()).getSyntheticProperties(null); 108 } 109 110 Node.Property[] getI18nProperties() { 111 if (i18nProperties == null) 112 i18nProperties = createI18nProperties(); 113 return i18nProperties; 114 } 115 116 private Node.Property[] createI18nProperties() { 117 return FormEditor.getI18nSupport(getFormModel()).createFormProperties(); 118 } 119 120 Node.Property[] getAllProperties() { 121 if (allProperties == null) { 122 int codeGenCount = getCodeGenProperties().length; 123 int i18nCount = getI18nProperties().length; 124 allProperties = new Node.Property[codeGenCount + i18nCount]; 125 System.arraycopy(codeGenProperties, 0, allProperties, 0, codeGenCount); 126 System.arraycopy(i18nProperties, 0, allProperties, codeGenCount, i18nCount); 127 } 128 return allProperties; 129 } 130 131 133 static class RootChildren extends Children.Keys { 134 135 static final Object OTHERS_ROOT = new Object (); 136 static final Object MAIN_VISUAL_ROOT = new Object (); 137 138 private FormModel formModel; 139 private FormOthersNode othersNode; 140 141 protected RootChildren(FormModel formModel) { 142 this.formModel = formModel; 143 setKeys(formModel.getTopRADComponent() != null ? 144 new Object [] { OTHERS_ROOT, MAIN_VISUAL_ROOT } : 145 new Object [] { OTHERS_ROOT } ); 146 } 147 148 protected Node[] createNodes(Object key) { 149 Node node; 150 if (key == MAIN_VISUAL_ROOT) 151 node = new RADComponentNode(formModel.getTopRADComponent()); 152 else node = othersNode = new FormOthersNode(formModel); 154 155 node.getChildren().getNodes(); return new Node[] { node }; 157 } 158 159 protected final FormModel getFormModel() { 160 return formModel; 161 } 162 } 163 164 } 165 | Popular Tags |