# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\nam\nb55\xml\schema\core # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: src/org/netbeans/modules/xml/schema/core/multiview/SchemaColumnViewMultiViewElement.java *** C:\nam\nb55\xml\schema\core\src\org\netbeans\modules\xml\schema\core\multiview\SchemaColumnViewMultiViewElement.java Base (1.1.2.44) --- C:\nam\nb55\xml\schema\core\src\org\netbeans\modules\xml\schema\core\multiview\SchemaColumnViewMultiViewElement.java Locally Modified (Based On 1.1.2.44) *************** *** 26,31 **** --- 26,33 ---- import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; + import java.util.logging.Level; + import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.ActionMap; *************** *** 34,40 **** --- 36,44 ---- import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.UIManager; + import javax.swing.text.BadLocationException; import javax.swing.text.DefaultEditorKit; + import javax.swing.text.StyledDocument; import org.netbeans.core.spi.multiview.CloseOperationState; import org.netbeans.core.spi.multiview.MultiViewElement; import org.netbeans.core.spi.multiview.MultiViewElementCallback; *************** *** 53,58 **** --- 57,63 ---- import org.netbeans.modules.xml.validation.ValidateAction; import org.netbeans.modules.xml.xam.Component; import org.netbeans.modules.xml.xam.Model.State; + import org.netbeans.modules.xml.xam.dom.AbstractDocumentModel; import org.netbeans.modules.xml.xam.spi.Validator.ResultItem; import org.netbeans.modules.xml.xam.ui.category.Category; import org.netbeans.modules.xml.xam.ui.category.CategoryPane; *************** *** 173,179 **** addPropertyChangeListener("activatedNodes", nodesMediator); addPropertyChangeListener("activatedNodes", cpl); setLayout(new BorderLayout()); ! initUI(); } public ExplorerManager getExplorerManager() { --- 178,184 ---- addPropertyChangeListener("activatedNodes", nodesMediator); addPropertyChangeListener("activatedNodes", cpl); setLayout(new BorderLayout()); ! initUI(true); } public ExplorerManager getExplorerManager() { *************** *** 270,281 **** --- 275,299 ---- * error message. */ private void initUI() { + initUI(false); + } + + private void initUI(boolean reloadOnModelInvalid) { SchemaModel model = getSchemaModel(); if (model != null && model.getState() == SchemaModel.State.VALID) { recreateUI(); return; } + if (model != null && reloadOnModelInvalid) { + StyledDocument doc = getSchemaDataObject().getSchemaEditorSupport().getDocument(); + forceResetDocument(model, doc); + if (model.getState() == SchemaModel.State.VALID) { + recreateUI(); + return; + } + } + //if it comes here, either the schema is not well-formed or invalid if (errorMessage == null) { errorMessage = NbBundle.getMessage( *************** *** 453,459 **** --- 471,496 ---- } } } + + // work-around xdm po-venetian issue + private static final String EMPTY_DOC = ""; + static void forceResetDocument(SchemaModel model, StyledDocument doc) { + try { + String saved = doc.getText(0, doc.getLength()); + doc.remove(0, doc.getLength()); + doc.insertString(0, EMPTY_DOC, null); + model.sync(); + doc.remove(0, doc.getLength()); + doc.insertString(0, saved, null); + model.sync(); + } catch(BadLocationException e) { + Logger.getLogger(SchemaColumnViewMultiViewElement.class.getName()).log(Level.FINE, "forceResetDocument", e); + } catch(IOException e) { + Logger.getLogger(SchemaColumnViewMultiViewElement.class.getName()).log(Level.FINE, "forceResetDocument", e); } + } + }