javax.swing.text.StyledDocument.putProperty()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中javax.swing.text.StyledDocument.putProperty()方法的一些代码示例,展示了StyledDocument.putProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyledDocument.putProperty()方法的具体详情如下:
包路径:javax.swing.text.StyledDocument
类名称:StyledDocument
方法名:putProperty

StyledDocument.putProperty介绍

暂无

代码示例

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders

/** 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;
}

代码示例来源:origin: org.netbeans.api/org-openide-text

/** 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;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** 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;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** 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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-source

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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-editor

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);
      }
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

@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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-source

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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-source

doc.putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n"); //NOI18N

代码示例来源:origin: org.netbeans.api/org-openide-text

myDoc.putProperty("beforeSaveStart", beforeSaveStart);
myDoc.putProperty("beforeSaveEnd", saveToMemory);

相关文章