@Override protected void loadFromStreamToKitHook (StyledDocument doc, InputStream stream, EditorKit kit) throws IOException, BadLocationException { if (sections == null) { guardsEditor = new GuardsEditor (doc); String mimeType = ((CloneableEditorSupport.Env) this.env).getMimeType (); GuardedSectionsFactory factory = GuardedSectionsFactory.find (mimeType); sections = factory.create (guardsEditor); } else { guardsEditor.setDocument (doc); } if (sections != null) { Reader reader = sections.createGuardedReader (stream, getEncoding ()); try { kit.read (reader, doc, 0); } finally { reader.close (); } } else { super.loadFromStreamToKitHook (doc, stream, kit); } }
/** Creates editor kit for this source. * @return editor kit */ protected EditorKit createEditorKit () { if (kit != null) return kit; if (mimeType != null) { kit = JEditorPane.createEditorKitForContentType (mimeType); } else { String defaultMIMEType = env ().getMimeType (); kit = JEditorPane.createEditorKitForContentType (defaultMIMEType); } if (isDumbKit (kit)) { kit = JEditorPane.createEditorKitForContentType ("text/plain"); // NOI18N } if (isDumbKit (kit)) { kit = new PlainEditorKit (); } return kit; }
/** Creates editor kit for this source. * @return editor kit */ protected EditorKit createEditorKit () { if (kit != null) return kit; if (mimeType != null) { kit = JEditorPane.createEditorKitForContentType (mimeType); } else { String defaultMIMEType = env ().getMimeType (); kit = JEditorPane.createEditorKitForContentType (defaultMIMEType); } if (isDumbKit (kit)) { kit = JEditorPane.createEditorKitForContentType ("text/plain"); // NOI18N } if (isDumbKit (kit)) { kit = new PlainEditorKit (); } return kit; }
/** Creates editor kit for this source. * @return editor kit */ protected EditorKit createEditorKit() { if (kit != null) { return kit; } if (mimeType != null) { kit = getEditorKit(mimeType); } else { String defaultMIMEType = cesEnv().getMimeType(); kit = getEditorKit(defaultMIMEType); } return kit; }
/** Method that can be overriden by children to create empty * styled document or attach additional document properties to it. * * @param kit the kit to use * @return styled document to use */ protected StyledDocument createStyledDocument (EditorKit kit) { StyledDocument sd = createNetBeansDocument (kit.createDefaultDocument ()); sd.putProperty("mimeType", mimeType != null ? mimeType : env().getMimeType()); // NOI18N return sd; }
/** Method that can be overriden by children to create empty * styled document or attach additional document properties to it. * * @param kit the kit to use * @return styled document to use */ protected StyledDocument createStyledDocument (EditorKit kit) { StyledDocument sd = createNetBeansDocument (kit.createDefaultDocument ()); sd.putProperty("mimeType", mimeType != null ? mimeType : env().getMimeType()); // NOI18N return sd; }
/** Method that can be overriden by children to create empty * styled document or attach additional document properties to it. * * @param kit the kit to use * @return styled document to use */ protected StyledDocument createStyledDocument(EditorKit kit) { StyledDocument sd = createNetBeansDocument(kit.createDefaultDocument()); sd.putProperty("mimeType", (mimeType != null) ? mimeType : cesEnv().getMimeType()); // NOI18N return sd; }