本文整理汇总了Java中javax.swing.text.Document.putProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Document.putProperty方法的具体用法?Java Document.putProperty怎么用?Java Document.putProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.Document
的用法示例。
在下文中一共展示了Document.putProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEditorPane
import javax.swing.text.Document; //导入方法依赖的package包/类
private void addEditorPane( JEditorPane pane, Icon icon, File file, boolean created, boolean focus ) {
final JComponent c = (pane.getUI() instanceof BaseTextUI) ?
Utilities.getEditorUI(pane).getExtComponent() : new JScrollPane( pane );
Document doc = pane.getDocument();
doc.addDocumentListener( new MarkingDocumentListener( c ) );
doc.putProperty( FILE, file );
doc.putProperty( CREATED, created ? Boolean.TRUE : Boolean.FALSE );
UndoManager um = new UndoManager();
doc.addUndoableEditListener( um );
doc.putProperty( BaseDocument.UNDO_MANAGER_PROP, um );
com2text.put( c, pane );
tabPane.addTab( file.getName(), icon, c, file.getAbsolutePath() );
if (focus) {
tabPane.setSelectedComponent( c );
pane.requestFocus();
}
}
示例2: testBeyondEndDocHighlightsLayer
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testBeyondEndDocHighlightsLayer() throws Exception {
loggingOn();
String mimeType = "text/plain";
// MimeLookup.getLookup(MimePath.get(mimeType)).lookup(HighlightsLayer.class); // Init ML
// HighlightsLayerProvider.clear();
HighlightsLayerProvider.add("text/x-java", new HLFactory());
HighlightsLayerProvider.add(mimeType, new HLFactory());
// MemoryMimeDataProvider.reset(null);
// MemoryMimeDataProvider.addInstances("text/x-java", new HLFactory());
// MemoryMimeDataProvider.addInstances(mimeType, new HLFactory());
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty("mimeType", mimeType);
DocumentTesting.setSameThreadInvoke(container.context(), true); // Do not post to EDT
RandomTestContainer.Context gContext = container.context();
DocumentTesting.insert(gContext, 0, "a\nb");
DocumentTesting.insert(gContext, 1, "c");
DocumentTesting.remove(gContext, 2, 1);
DocumentTesting.insert(gContext, 1, "d\nx");
}
示例3: testDeleteAterInsertBreak
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testDeleteAterInsertBreak() throws Exception {
loggingOn();
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty("mimeType", "text/plain");
ViewHierarchyRandomTesting.initRandomText(container);
RandomTestContainer.Context context = container.context();
DocumentTesting.insert(context, 0,
" osen \n\n\n esl\t\ta \t\t \n\n\nabcd\td m\t\tabcdef\te\t\tab\tcdef\tef\tkojd \t\t \n\n\n t\t vpjm\ta\ngooywzmj q\tugos\tdefy\t i xs us tg z"
);
EditorPaneTesting.setCaretOffset(context, 70);
DocumentTesting.remove(context, 50, 10);
EditorPaneTesting.performAction(context, pane, DefaultEditorKit.insertBreakAction);
EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deleteNextCharAction);
}
示例4: testFindIndentTaskFactory
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testFindIndentTaskFactory() throws BadLocationException {
TestIndentTask.TestFactory factory = new TestIndentTask.TestFactory();
MockServices.setServices(MockMimeLookup.class);
MockMimeLookup.setInstances(MimePath.parse(MIME_TYPE), factory);
Document doc = new PlainDocument();
doc.putProperty("mimeType", MIME_TYPE);
Indent indent = Indent.get(doc);
indent.lock();
try {
//doc.atomicLock();
try {
indent.reindent(0);
} finally {
//doc.atomicUnlock();
}
} finally {
indent.unlock();
}
// Check that the factory was used
assertTrue(TestIndentTask.TestFactory.lastCreatedTask.indentPerformed);
}
示例5: getValue
import javax.swing.text.Document; //导入方法依赖的package包/类
public CharSequence getValue(JTextComponent component, Document document, Object attributeKey, int startOffset, int endOffset) {
try {
String tooltipText = provider.getTooltipText(document, offset, type);
HyperlinkListener hl = (HyperlinkListener)document.getProperty(HYPERLINK_LISTENER);
return hl != null ? new TooltipInfo(tooltipText, hl) : tooltipText;
} finally {
document.putProperty(HYPERLINK_LISTENER, null);
}
}
示例6: initializeModel
import javax.swing.text.Document; //导入方法依赖的package包/类
private Document initializeModel(EditorKit kit, URL page) {
Document doc = kit.createDefaultDocument();
if (doc.getProperty(Document.StreamDescriptionProperty) == null) {
doc.putProperty(Document.StreamDescriptionProperty, page);
}
return doc;
}
示例7: getHighlightsBag
import javax.swing.text.Document; //导入方法依赖的package包/类
static OffsetsBag getHighlightsBag(Document doc) {
OffsetsBag bag = (OffsetsBag) doc.getProperty(MethodChooser.class);
if (bag == null) {
doc.putProperty(MethodChooser.class, bag = new OffsetsBag(doc, true));
}
return bag;
}
示例8: testSimpleCodeGenerator
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testSimpleCodeGenerator() {
Document doc = new DefaultStyledDocument();
doc.putProperty(NbEditorDocument.MIME_TYPE_PROP, "text/x-simple-codegen-test");
String[] generatorNames = NbGenerateCodeAction.test(doc, 0);
assertEquals(generatorNames.length, 1);
assertEquals(generatorNames[0], "SimpleCodeGenerator");
}
示例9: testSimple1
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testSimple1() throws Exception {
loggingOn();
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty("mimeType", "text/plain");
RandomTestContainer.Context gContext = container.context();
DocumentTesting.insert(gContext, 0, "a\nb");
DocumentTesting.insert(gContext, 1, "c");
}
示例10: testGap
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testGap() throws Exception {
loggingOn();
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty("mimeType", "text/plain");
ViewHierarchyRandomTesting.initRandomText(container);
ViewHierarchyRandomTesting.addRound(container).setOpCount(OP_COUNT);
RandomTestContainer.Context context = container.context();
// Clear document contents
DocumentTesting.insert(context, 0, "a\tb\tc\td\te\tf\n");
EditorPaneTesting.setCaretOffset(context, 1);
DocumentTesting.insert(context, 1, "x");
EditorPaneTesting.setCaretOffset(context, 5);
EditorPaneTesting.typeChar(context, 'y');
EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, true);
EditorPaneTesting.typeChar(context, 'z');
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
EditorPaneTesting.typeChar(context, 'u');
// EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, true);
// EditorPaneTesting.typeChar(context, 'y');
// EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deleteNextCharAction);
DocumentTesting.undo(context, 1);
DocumentTesting.redo(context, 1);
DocumentTesting.undo(context, 2);
}
示例11: testNewlineInEmptyDoc
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testNewlineInEmptyDoc() throws Exception {
loggingOn();
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty("mimeType", "text/plain");
RandomTestContainer.Context gContext = container.context();
DocumentTesting.insert(gContext, 0, "\n");
}
示例12: testNewlineInsertUndo
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testNewlineInsertUndo() throws Exception {
loggingOn();
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty("mimeType", "text/plain");
RandomTestContainer.Context context = container.context();
DocumentTesting.insert(context, 0, "\n");
DocumentTesting.remove(context, 0, 1);
DocumentTesting.undo(context, 1);
}
示例13: testEmbeddingPresence
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testEmbeddingPresence() throws Exception {
Document d = new PlainDocument();
d.putProperty(Language.class,TestEmbeddingTokenId.language());
d.insertString(0, " acnacn", null);
TokenHierarchy<?> h = TokenHierarchy.get(d);
((AbstractDocument)d).readLock();
try {
TokenSequence<TestEmbeddingTokenId> ts = h.tokenSequence(TestEmbeddingTokenId.language());
TokenSequence<?> inner;
LexerTestUtilities.assertNextTokenEquals(ts,TestEmbeddingTokenId.TEXT, " ");
inner = ts.embedded();
LexerTestUtilities.assertNextTokenEquals(ts,TestEmbeddingTokenId.A, "a");
inner = ts.embedded();
LexerTestUtilities.assertNextTokenEquals(ts,TestEmbeddingTokenId.C, "c");
inner = ts.embedded();
LexerTestUtilities.assertNextTokenEquals(ts,TestEmbeddingTokenId.N, "n");
inner = ts.embedded();
LexerTestUtilities.assertNextTokenEquals(ts,TestEmbeddingTokenId.A, "a");
inner = ts.embedded();
LexerTestUtilities.assertNextTokenEquals(ts,TestEmbeddingTokenId.C, "c");
inner = ts.embedded();
LexerTestUtilities.assertNextTokenEquals(ts,TestEmbeddingTokenId.N, "n");
inner = ts.embedded();
assertEquals(1, TestEmbeddingTokenId.cEmbeddingQueryCount);
assertEquals(2, TestEmbeddingTokenId.aEmbeddingQueryCount);
} finally {
((AbstractDocument)d).readUnlock();
}
}
示例14: testUndo750
import javax.swing.text.Document; //导入方法依赖的package包/类
public void testUndo750() throws Exception {
loggingOn();
RandomTestContainer container = createContainer();
JEditorPane pane = container.getInstance(JEditorPane.class);
Document doc = pane.getDocument();
doc.putProperty("mimeType", "text/plain");
ViewHierarchyRandomTesting.initRandomText(container);
RandomTestContainer.Context context = container.context();
DocumentTesting.insert(context, 0,
" \naxj \n\n\nm hebkinc krnb\t\tabce\n\nd\t\n\n \t\talja\nj \t\tabcdef\tcdef \t \n\n\n\tabcdf\t\tq tzaicl \t\tabcdef\t \nglanm\nq\n \nv nyk\n \ndy qucjfn\tfh cdk \t\t \nj\nsm\n t\ngqa \nsjj\n\n\ncdef\t\n \t\tpabg\to\nkbcvde\tjs\ny\tfw\nr\n\n\nced"
);
EditorPaneTesting.setCaretOffset(context, 131);
EditorPaneTesting.moveCaret(context, 124);
DocumentTesting.insert(context, 102, " \t\tabcdef\t");
EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, false);
DocumentTesting.insert(context, 103, "k\t\n\n ");
EditorPaneTesting.typeChar(context, 'j');
EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
EditorPaneTesting.typeChar(context, 'q');
EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, true);
DocumentTesting.insert(context, 64, " \t\tabcdef\t");
DocumentTesting.remove(context, 121, 1);
DocumentTesting.insert(context, 52, "r");
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, false);
EditorPaneTesting.performAction(context, pane, DefaultEditorKit.insertTabAction);
EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, true);
DocumentTesting.redo(context, 3);
DocumentTesting.undo(context, 1);
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false);
EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, true);
EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, false);
EditorPaneTesting.performAction(context, pane, DefaultEditorKit.insertTabAction);
DocumentTesting.undo(context, 1);
}
示例15: tokenListTestWithWriting
import javax.swing.text.Document; //导入方法依赖的package包/类
private void tokenListTestWithWriting(String documentContent, int offset, String text, int startOffset, String... golden) throws Exception {
Document doc = new PlainDocument();
doc.putProperty(Language.class, JavaTokenId.language());
doc.insertString(0, documentContent, null);
List<String> words = new ArrayList<String>();
TokenList l = new JavaTokenList(doc);
while (l.nextWord()) {
}
doc.insertString(offset, text, null);
l.setStartOffset(startOffset);
while (l.nextWord()) {
words.add(l.getCurrentWordText().toString());
}
assertEquals(Arrays.asList(golden), words);
}