/** Let's the super method create the document and also annotates it * with Title and StreamDescription properities. * * @param kit kit to user to create the document * @return the document annotated by the properties */ protected StyledDocument createStyledDocument (EditorKit kit) { StyledDocument doc = super.createStyledDocument (kit); // set document name property doc.putProperty(javax.swing.text.Document.TitleProperty, FileUtil.getFileDisplayName(obj.getPrimaryFile()) ); // set dataobject to stream desc property doc.putProperty(javax.swing.text.Document.StreamDescriptionProperty, obj ); return doc; }
/** 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; }
/** 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; }
private StyledDocument setupSlowDocumentProperties(StyledDocument doc) { assert !SwingUtilities.isEventDispatchThread(); if (doc != null && !Boolean.TRUE.equals(doc.getProperty(EXTRA_DOCUMENT_PROPERTIES))) { // setup language flavor lexing attributes Language<?> language = (Language<?>) doc.getProperty(Language.class); assert language != null : "no language for " + doc; if (language != null) { InputAttributes lexerAttrs = (InputAttributes)doc.getProperty(InputAttributes.class); assert lexerAttrs != null : "no language attributes for " + doc; if (lexerAttrs == null) { lexerAttrs = new InputAttributes(); doc.putProperty(InputAttributes.class, lexerAttrs); } Filter<?> filter = getDefaultFilter(language, doc); assert filter != null : "no language filter for " + doc + " with language " + language; if (filter != null) { lexerAttrs.setValue(language, CndLexerUtilities.LEXER_FILTER, filter, true); // NOI18N } } // try to setup document's extra properties during non-EDT load if needed PropertiesProviders.addProperty(getDataObject(), doc); doc.putProperty(EXTRA_DOCUMENT_PROPERTIES, Boolean.TRUE); rebuildDocumentControls(doc); } return doc; }
public static void actionPerformed(final Document document) { if (!((document instanceof StyledDocument) && (document instanceof BaseDocument))) return; final StyledDocument doc = (StyledDocument)document; final Project p = J2MEProjectUtils.getProjectForDocument(doc); if (p != null) { final ProjectConfigurationsHelper pch = p.getLookup().lookup(ProjectConfigurationsHelper.class); if (pch != null && pch.isPreprocessorOn()) try { J2MEProjectUtilitiesProvider utilProvider = Lookup.getDefault().lookup(J2MEProjectUtilitiesProvider.class); if (utilProvider == null) return; //we do not run in full NetBeans, but this should not happen here (no editor) final Source ppSource = utilProvider.createPPDocumentSource(doc); final Destination ppDestination = utilProvider.createPPDocumentDestination(doc); final ProjectConfiguration conf = pch.getActiveConfiguration(); final HashMap<String,String> identifiers=new HashMap<String,String>(pch.getAbilitiesFor(conf)); identifiers.put(conf.getDisplayName(),null); final CommentingPreProcessor cpp =new CommentingPreProcessor(ppSource, ppDestination, identifiers); //note: nbr transaction is already locked here try { doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, TextSwitcher.SKIP_DUCUMENT_CHANGES); NbDocument.runAtomic(doc,cpp); // NOI18N } finally { doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, null); } } catch (PreprocessorException pe) { ErrorManager.getDefault().notify(pe); } } } }
@Override protected StyledDocument createStyledDocument (EditorKit kit) { org.netbeans.api.lexer.Language lexerlanguage = language.getGsfLanguage().getLexerLanguage(); StyledDocument doc = super.createStyledDocument(kit); // Enter the file object in to InputAtrributes. It can be used by lexer. InputAttributes attributes = new InputAttributes(); FileObject fileObject = NbEditorUtilities.getFileObject(doc); attributes.setValue(lexerlanguage, FileObject.class, fileObject, false); doc.putProperty(InputAttributes.class, attributes); return doc; }
private GuardedSectionsProvider getGuardedSectionsProvider(final StyledDocument doc, EditorKit kit) { Object o = doc.getProperty(GuardedSectionsProvider.class); if (o instanceof GuardedSectionsProvider) { return (GuardedSectionsProvider) o; } String mimeType = kit.getContentType(); CndUtils.assertTrueInConsole(mimeType != null, "unexpected null content type"); // NOI18N if (mimeType != null) { GuardedSectionsFactory gsf = GuardedSectionsFactory.find(mimeType); if (gsf != null) { GuardedSectionsProvider gsp = gsf.create(new GuardedEditorSupportImpl(doc)); doc.putProperty(GuardedSectionsProvider.class, gsp); return gsp; } } return null; }
doc.putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n"); //NOI18N
myDoc.putProperty("beforeSaveStart", beforeSaveStart); myDoc.putProperty("beforeSaveEnd", saveToMemory);