1.1 --- a/encoder.custom.aip/src/org/netbeans/modules/encoder/custom/aip/Bundle.properties Thu Jul 24 15:52:31 2008 -0700
1.2 +++ b/encoder.custom.aip/src/org/netbeans/modules/encoder/custom/aip/Bundle.properties Thu Jul 24 16:33:08 2008 -0700
1.3 @@ -75,6 +75,8 @@
1.4
1.5 encoding_node.lbl.escape_sequence=Escape Sequence
1.6
1.7 +encoding_node.lbl.fine_inherit=Fine Inherit
1.8 +
1.9 encoding_node.lbl.alignment=Alignment
1.10
1.11 encoding_node.lbl.serial_charset=Serializing Charset
2.1 --- a/encoder.custom.aip/src/org/netbeans/modules/encoder/custom/aip/EncodingNode.java Thu Jul 24 15:52:31 2008 -0700
2.2 +++ b/encoder.custom.aip/src/org/netbeans/modules/encoder/custom/aip/EncodingNode.java Thu Jul 24 16:33:08 2008 -0700
2.3 @@ -275,13 +275,13 @@
2.4 }
2.5
2.6 if (mEncodingOption.testIsGlobal() && mEncodingOption.isTop()) {
2.7 - //The Escape Sequence Property
2.8 - PropertySupport.Reflection<String> escapeSequenceProp =
2.9 - new PropertySupport.Reflection<String>(mEncodingOption,
2.10 - String.class, "escapeSequence"); //NOI18N
2.11 - escapeSequenceProp.setName("escapeSequence"); //NOI18N
2.12 - escapeSequenceProp.setDisplayName(_bundle.getString("encoding_node.lbl.escape_sequence"));
2.13 - propSet.put(escapeSequenceProp);
2.14 + //The Fine Inherit Property
2.15 + PropertySupport.Reflection<Boolean> fineInheritProp =
2.16 + new PropertySupport.Reflection<Boolean>(mEncodingOption,
2.17 + boolean.class, "fineInherit"); //NOI18N
2.18 + fineInheritProp.setName("fineInherit"); //NOI18N
2.19 + fineInheritProp.setDisplayName(_bundle.getString("encoding_node.lbl.fine_inherit"));
2.20 + propSet.put(fineInheritProp);
2.21 }
2.22 } catch (NoSuchMethodException e) {
2.23 throw new RuntimeException(_bundle.getString("encoding_node.exp.no_such_mthd"), e);
3.1 --- a/encoder.custom.aip/src/org/netbeans/modules/encoder/custom/aip/EncodingOption.java Thu Jul 24 15:52:31 2008 -0700
3.2 +++ b/encoder.custom.aip/src/org/netbeans/modules/encoder/custom/aip/EncodingOption.java Thu Jul 24 16:33:08 2008 -0700
3.3 @@ -170,6 +170,7 @@
3.4 private String mAlignment = mTextMap.get(ALIGNMENT_PREFIX + "_" + NodeProperties.Alignment.BLIND); //NOI18N
3.5 private int mLength = 0;
3.6 private String mEscapeSequence = ""; //NOI18N
3.7 + private boolean mFineInherit = false;
3.8
3.9 private CustomEncoding mCustomEncoding = null;
3.10 private AppInfo mAppInfo = null;
3.11 @@ -330,6 +331,23 @@
3.12 firePropertyChange("escapeSequence", old, mEscapeSequence); //NOI18N
3.13 }
3.14
3.15 + public boolean isFineInherit() {
3.16 + return mFineInherit;
3.17 + }
3.18 +
3.19 + public void setFineInherit(boolean fineInherit) {
3.20 + Boolean old = Boolean.valueOf(mFineInherit);
3.21 + mFineInherit = fineInherit;
3.22 + if (!mFineInherit) {
3.23 + // if false, remove the "fineInherit" element.
3.24 + mCustomEncoding.getNodeProperties().unsetFineInherit();
3.25 + } else {
3.26 + mCustomEncoding.getNodeProperties().setFineInherit(mFineInherit);
3.27 + }
3.28 + commitToAppInfo();
3.29 + firePropertyChange("fineInherit", old, Boolean.valueOf(mFineInherit)); //NOI18N
3.30 + }
3.31 +
3.32 public String getNodeType() {
3.33 return mNodeType;
3.34 }
3.35 @@ -801,7 +819,11 @@
3.36 if (customEncoding.getNodeProperties().isSetEscapeSequence()) {
3.37 mEscapeSequence = customEncoding.getNodeProperties().getEscapeSequence();
3.38 }
3.39 -
3.40 + //Populates the FineInherit field
3.41 + if (customEncoding.getNodeProperties().isSetFineInherit()) {
3.42 + mFineInherit = customEncoding.getNodeProperties().getFineInherit();
3.43 + }
3.44 +
3.45 // I guess that following lines will cause recursive loop when
3.46 // the AppInfo is removed from the text editing pane.
3.47 //if (mAppInfo == null) {
3.48 @@ -889,44 +911,41 @@
3.49
3.50 private synchronized void commitToAppInfo() {
3.51 boolean startedTrans = false;
3.52 + SchemaModel model = null;
3.53 if (mAppInfo == null) {
3.54 Annotation anno = annotation();
3.55 - try {
3.56 - if (!anno.getModel().isIntransaction()) {
3.57 - if (!anno.getModel().startTransaction()) {
3.58 - //TODO how to handle???
3.59 + model = anno.getModel();
3.60 + if (!model.isIntransaction()) {
3.61 + if (!model.startTransaction()) {
3.62 + // happens if failed to acquire transaction, for e.g.
3.63 + // when model has transitioned into invalid state.
3.64 + //TODO how to handle???
3.65 }
3.66 - startedTrans = true;
3.67 - }
3.68 - AppInfo newAppInfo = anno.getModel().getFactory().createAppInfo();
3.69 - mAppInfo = newAppInfo;
3.70 - anno.addAppInfo(newAppInfo);
3.71 - newAppInfo.setURI(EncodingConst.URI);
3.72 - newAppInfo.setContentFragment(
3.73 - contentFragFromXmlObject(mCustomEncoding));
3.74 - } catch (IOException ex) {
3.75 - //TODO how to handle???
3.76 + startedTrans = true;
3.77 + }
3.78 + // create a new AppInfo object
3.79 + mAppInfo = anno.getModel().getFactory().createAppInfo();
3.80 + anno.addAppInfo(mAppInfo);
3.81 + mAppInfo.setURI(EncodingConst.URI);
3.82 + } else {
3.83 + model = mAppInfo.getModel();
3.84 + if (!model.isIntransaction()) {
3.85 + if (!model.startTransaction()) {
3.86 + // happens if failed to acquire transaction, for e.g.
3.87 + // when model has transitioned into invalid state.
3.88 + //TODO how to handle???
3.89 + }
3.90 + startedTrans = true;
3.91 + }
3.92 + }
3.93 + try {
3.94 + String contentFrag = contentFragFromXmlObject(mCustomEncoding);
3.95 + mAppInfo.setContentFragment(contentFrag);
3.96 + } catch (IOException ex) {
3.97 + //TODO how to handle???
3.98 } finally {
3.99 - if (startedTrans) {
3.100 - anno.getModel().endTransaction();
3.101 - }
3.102 - }
3.103 - } else {
3.104 - try {
3.105 - if (!mAppInfo.getModel().isIntransaction()) {
3.106 - if (!mAppInfo.getModel().startTransaction()) {
3.107 - //TODO how to handle???
3.108 - }
3.109 - startedTrans = true;
3.110 - }
3.111 - mAppInfo.setContentFragment(
3.112 - contentFragFromXmlObject(mCustomEncoding));
3.113 - } catch (IOException ex) {
3.114 - //TODO how to handle???
3.115 - } finally {
3.116 - if (startedTrans) {
3.117 - mAppInfo.getModel().endTransaction();
3.118 - }
3.119 + if (startedTrans) {
3.120 + model.endTransaction();
3.121 }
3.122 }
3.123 }
3.124 @@ -941,8 +960,7 @@
3.125 }
3.126
3.127 private String xmlFragFromAppInfo(AppInfo appInfo) {
3.128 - StringBuffer sb = new StringBuffer();
3.129 - sb.append("<xml-fragment"); //NOI18N
3.130 + StringBuffer sb = new StringBuffer("<xml-fragment"); //NOI18N
3.131 sb.append(" ").append("source=\"").append(EncodingConst.URI).append("\""); //NOI18N
3.132 if (appInfo.getPeer() != null) {
3.133 String prefix = appInfo.getPeer().lookupPrefix(EncodingConst.URI);
3.134 @@ -969,21 +987,21 @@
3.135 }
3.136
3.137 private String contentFragFromXmlObject(XmlObject xmlObject) {
3.138 - XmlCursor c = null;
3.139 + XmlCursor cursor = null;
3.140 try {
3.141 - c = xmlObject.newCursor();
3.142 - StringBuffer sb = new StringBuffer();
3.143 - if (!c.toFirstChild()) {
3.144 + cursor = xmlObject.newCursor();
3.145 + StringBuffer buff = new StringBuffer();
3.146 + if (!cursor.toFirstChild()) {
3.147 return ""; //NOI18N
3.148 }
3.149 - sb.append(c.xmlText());
3.150 - while (c.toNextSibling()) {
3.151 - sb.append(c.xmlText());
3.152 + buff.append(cursor.xmlText());
3.153 + while (cursor.toNextSibling()) {
3.154 + buff.append(cursor.xmlText());
3.155 }
3.156 - return sb.toString();
3.157 + return buff.toString();
3.158 } finally {
3.159 - if (c != null) {
3.160 - c.dispose();
3.161 + if (cursor != null) {
3.162 + cursor.dispose();
3.163 }
3.164 }
3.165 }