本文整理汇总了Java中javax.swing.text.Document.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getProperty方法的具体用法?Java Document.getProperty怎么用?Java Document.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.Document
的用法示例。
在下文中一共展示了Document.getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCodeStyle
import javax.swing.text.Document; //导入方法依赖的package包/类
private static CodeStyle getCodeStyle(CompilationInfo info) {
if (info != null) {
try {
Document doc = info.getDocument();
if (doc != null) {
CodeStyle cs = (CodeStyle)doc.getProperty(CodeStyle.class);
return cs != null ? cs : CodeStyle.getDefault(doc);
}
} catch (IOException ioe) {
// ignore
}
FileObject file = info.getFileObject();
if (file != null) {
return CodeStyle.getDefault(file);
}
}
return CodeStyle.getDefault((Document)null);
}
示例2: visualColumn
import javax.swing.text.Document; //导入方法依赖的package包/类
private static int visualColumn(Document doc, int lineStartOffset, int offset) {
Integer tabSizeInteger = (Integer) doc.getProperty(PlainDocument.tabSizeAttribute);
int tabSize = (tabSizeInteger != null) ? tabSizeInteger : 8;
CharSequence docText = getText(doc);
// Expected that offset <= docText.length()
int column = 0;
for (int i = lineStartOffset; i < offset; i++) {
char c = docText.charAt(i);
if (c == '\t') {
column = (column + tabSize) / tabSize * tabSize;
} else {
column++;
}
}
return column;
}
示例3: getBag
import javax.swing.text.Document; //导入方法依赖的package包/类
public static OffsetsBag getBag(Document doc) {
OffsetsBag ob = (OffsetsBag) doc.getProperty(AnnotationHolder.class);
if (ob == null) {
doc.putProperty(AnnotationHolder.class, ob = new OffsetsBag(doc));
}
return ob;
}
示例4: getBag
import javax.swing.text.Document; //导入方法依赖的package包/类
private static OffsetsBag getBag(Document doc) {
OffsetsBag bag = (OffsetsBag) doc.getProperty(HighlightURLs.class);
if (bag == null) {
doc.putProperty(HighlightURLs.class, bag = new OffsetsBag(doc));
}
return bag;
}
示例5: getBag
import javax.swing.text.Document; //导入方法依赖的package包/类
public static OffsetsBag getBag(Document doc) {
OffsetsBag bag = (OffsetsBag) doc.getProperty(DebuggingHighlightsLayerFactory.class);
if (bag == null) {
doc.putProperty(DebuggingHighlightsLayerFactory.class, bag = new OffsetsBag(doc));
}
return bag;
}
示例6: getMimeType
import javax.swing.text.Document; //导入方法依赖的package包/类
static String getMimeType(JTextComponent component) {
Document doc = component.getDocument();
String mimeType = (String) doc.getProperty("mimeType"); //NOI18N
if (mimeType == null) {
EditorKit kit = component.getUI().getEditorKit(component);
if (kit != null) {
mimeType = kit.getContentType();
}
}
return mimeType;
}
示例7: getBag
import javax.swing.text.Document; //导入方法依赖的package包/类
static OffsetsBag getBag(Document doc) {
OffsetsBag bag = (OffsetsBag) doc.getProperty(TreeNavigatorProviderImpl.class);
if (bag == null) {
doc.putProperty(TreeNavigatorProviderImpl.class, bag = new OffsetsBag(doc));
}
return bag;
}
示例8: isJsp
import javax.swing.text.Document; //导入方法依赖的package包/类
public static boolean isJsp(Document doc) {
if(doc == null)
return false;
Object mimeType = doc.getProperty("mimeType"); //NOI18N
if (mimeType != null && "text/x-jsp".equals(mimeType)) { //NOI18N
return true;
}
return false;
}
示例9: getPrimaryFile
import javax.swing.text.Document; //导入方法依赖的package包/类
public static FileObject getPrimaryFile(Document doc) {
Object o = doc.getProperty(Document.StreamDescriptionProperty);
if (o instanceof FileObject) {
return (FileObject) o;
} else if (o instanceof Lookup.Provider) {
//Note: DataObject is a Lookup.Provider
return ((Lookup.Provider) o).getLookup().lookup(FileObject.class);
} else {
return null;
}
}
示例10: initFolds
import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
public void initFolds(FoldHierarchyTransaction transaction) {
Document doc = operation.getHierarchy().getComponent().getDocument();
Object od = doc.getProperty(Document.StreamDescriptionProperty);
if (od instanceof DataObject) {
FileObject file = ((DataObject)od).getPrimaryFile();
parserTask = FoldTask.getTask(file);
parserTask.updateFoldManager(this, file);
}
}
示例11: CoverageSideBar
import javax.swing.text.Document; //导入方法依赖的package包/类
/** Creates new form CoverageSideBar */
public CoverageSideBar(final JTextComponent target) {
Document document = target.getDocument();
fileForDocument = GsfUtilities.findFileObject(document);
String mimeType = (String) document.getProperty("mimeType"); // NOI18N
boolean on = false;
if (mimeType != null) {
CoverageManagerImpl manager = CoverageManagerImpl.getInstance();
on = manager.isEnabled(mimeType);
if (on) {
CoverageProvider provider = getProvider();
if (provider != null) {
on = provider.isEnabled() && manager.getShowEditorBar();
} else {
on = false;
}
}
}
if (on) {
showCoveragePanel(true);
} else {
updatePreferredSize();
}
Action focus = new AbstractAction(COVERAGE_SIDEBAR_FOCUS) {
public void actionPerformed(ActionEvent e) {
CoverageSideBar.this.requestFocusInWindow();
}
};
target.getInputMap().put(KeyStroke.getKeyStroke(FOCUS_KEY_BINDING), COVERAGE_SIDEBAR_FOCUS);
target.getActionMap().put(COVERAGE_SIDEBAR_FOCUS, focus);
// Since CoverageSideBar is a component storing its instance in target rather than document
// to btw allow GC of cloned editor components.
target.putClientProperty(COVERAGE_SIDEBAR_PROP, this);
}
示例12: ParserManagerImpl
import javax.swing.text.Document; //导入方法依赖的package包/类
public ParserManagerImpl (Document doc) {
this.document = doc;
tokenHierarchy = TokenHierarchy.get (doc);
String mimeType = (String) doc.getProperty ("mimeType");
if (tokenHierarchy == null) {
// for tests only....
if (mimeType != null) {
try {
Language language = LanguagesManager.getDefault ().getLanguage (mimeType);
if (language.getParser () != null) {
doc.putProperty (
org.netbeans.api.lexer.Language.class,
new SLanguageHierarchy (language).language ()
);
tokenHierarchy = TokenHierarchy.get (doc);
}
} catch (LanguageDefinitionNotFoundException ex) {
}
}
}
if (tokenHierarchy != null) {
new DocListener (this, tokenHierarchy);
if (mimeType != null && state == State.NOT_PARSED) {
try {
LanguagesManager.getDefault().getLanguage(mimeType);
startParsing();
} catch (LanguageDefinitionNotFoundException e) {
//not supported language
}
}
}
managers.put (doc, new WeakReference<ParserManager> (this));
}
示例13: findFilePath
import javax.swing.text.Document; //导入方法依赖的package包/类
private String findFilePath(Document doc) {
Object o = doc.getProperty(Document.StreamDescriptionProperty);
if (o != null) {
return o.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(o)) + ":" + o.toString(); //NOI18N
} else {
return "null"; //NOI18N
}
}
示例14: emptyTag
import javax.swing.text.Document; //导入方法依赖的package包/类
/**
* Writes out all empty elements (all tags that have no
* corresponding end tag).
*
* @param elem an Element
* @exception IOException on any I/O error
* @exception BadLocationException if pos represents an invalid
* location within the document.
*/
protected void emptyTag(Element elem) throws BadLocationException, IOException {
if (!inContent && !inPre) {
indent();
}
AttributeSet attr = elem.getAttributes();
closeOutUnwantedEmbeddedTags(attr);
writeEmbeddedTags(attr);
if (matchNameAttribute(attr, HTML.Tag.CONTENT)) {
inContent = true;
text(elem);
}
else if (matchNameAttribute(attr, HTML.Tag.COMMENT)) {
comment(elem);
}
else {
boolean isBlock = isBlockTag(elem.getAttributes());
if (inContent && isBlock) {
writeLineSeparator();
indent();
}
Object nameTag = (attr != null) ? attr.getAttribute(StyleConstants.NameAttribute) : null;
Object endTag = (attr != null) ? attr.getAttribute(HTML.Attribute.ENDTAG) : null;
boolean outputEndTag = false;
// If an instance of an UNKNOWN Tag, or an instance of a
// tag that is only visible during editing
//
if (nameTag != null && endTag != null && (endTag instanceof String) && ((String) endTag).equals("true")) {
outputEndTag = true;
}
if (completeDoc && matchNameAttribute(attr, HTML.Tag.HEAD)) {
if (outputEndTag) {
// Write out any styles.
writeStyles(((HTMLDocument) getDocument()).getStyleSheet());
}
wroteHead = true;
}
write('<');
if (outputEndTag) {
write('/');
}
write(elem.getName());
writeAttributes(attr);
write('>');
if (matchNameAttribute(attr, HTML.Tag.TITLE) && !outputEndTag) {
Document doc = elem.getDocument();
String title = (String) doc.getProperty(Document.TitleProperty);
write(title);
}
else if (!inContent || isBlock) {
writeLineSeparator();
if (isBlock && inContent) {
indent();
}
}
}
}
示例15: IndentImpl
import javax.swing.text.Document; //导入方法依赖的package包/类
public IndentImpl(Document doc) {
this.doc = doc;
String mimeType = (String)doc.getProperty("mimeType"); //NOI18N
this.prefs = mimeType != null ? MimeLookup.getLookup(mimeType).lookup(Preferences.class) : null;
}