Java Code Examples for org.openide.text.CloneableEditorSupport#getEditorKit()
The following examples show how to use
org.openide.text.CloneableEditorSupport#getEditorKit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JspSyntaxSupport.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected SyntaxSupport createSyntaxSupport(Class syntaxSupportClass) { SyntaxSupport support = super.createSyntaxSupport(syntaxSupportClass); if (support != null) return support; EditorKit kit; // try the content language support kit = CloneableEditorSupport.getEditorKit("text/html"); //NOI18N if (kit instanceof BaseKit) { support = ((BaseKit)kit).createSyntaxSupport(getDocument()); if (support != null) return support; } // try the scripting language support kit = CloneableEditorSupport.getEditorKit("text/x-java"); //NOI18N if (kit instanceof BaseKit) { support = ((BaseKit)kit).createSyntaxSupport(getDocument()); if (support != null) return support; } return null; }
Example 2
Source File: SubmitPanel.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void run() { if (EventQueue.isDispatchThread()) { try { String content = text.getDocument().getText(0, text.getDocument().getLength()); text.setEditorKit(betterXMLKit); setText(content); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } } else { betterXMLKit = CloneableEditorSupport.getEditorKit("text/xml"); if (betterXMLKit != null) { EventQueue.invokeLater(this); } } }
Example 3
Source File: EditorSanityTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testPlainEditorKits() { // VIS: JEditorPane when constructed contains javax.swing.JEditorPane$PlainEditorKit // and calling JEP.setContenetType("text/plain") has no effect. IMO this is probably // a defect in JDK, becuase JEP should always honour its EditorKit registry. JEditorPane pane = new JEditorPane(); pane.setEditorKit(new DefaultEditorKit() { public @Override String getContentType() { return "text/whatever"; } }); setContentTypeInAwt(pane, "text/plain"); // Test JDK kit EditorKit kitFromJdk = pane.getEditorKit(); assertNotNull("Can't find JDK kit for text/plain", kitFromJdk); assertEquals("The kit for text/plain should not be from JDK", "org.netbeans.modules.editor.plain.PlainKit", kitFromJdk.getClass().getName()); // Test Netbeans kit EditorKit kitFromNb = CloneableEditorSupport.getEditorKit("text/plain"); assertNotNull("Can't find Nb kit for text/plain", kitFromNb); assertEquals("Wrong Nb kit for text/plain", "org.netbeans.modules.editor.plain.PlainKit", kitFromNb.getClass().getName()); }
Example 4
Source File: ModelItem.java From netbeans with Apache License 2.0 | 5 votes |
private static void reformatAndUseRightEditor(JEditorPane pane, String data, String contentType) { if (contentType == null) { contentType = "text/plain"; // NOI18N } else { contentType = contentType.trim(); } if ("application/javascript".equals(contentType)) { // check whether this JSONP response, that is a JS method call returning JSON: String json = getJSONPResponse(data); if (json != null) { data = json; contentType = "application/json"; } } if ("application/json".equals(contentType) || "text/x-json".equals(contentType)) { data = reformatJSON(data); contentType = "text/x-json"; } if ("application/xml".equals(contentType)) { contentType = "text/xml"; } EditorKit editorKit; try { editorKit = CloneableEditorSupport.getEditorKit(contentType); } catch (IllegalArgumentException iaex) { contentType = "text/plain"; // NOI18N editorKit = CloneableEditorSupport.getEditorKit(contentType); } pane.setEditorKit(editorKit); pane.setText(data); }
Example 5
Source File: BuildActionsCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates new form BuildActionsCustomizer */ public BuildActionsCustomizer(Project project) { this.project = project; initComponents(); actionRegistry = new CustomActionRegistrationSupport(project); lsActions.setCellRenderer(new MyListCellRenderer()); tfLabel.getDocument().addDocumentListener(applyListener); EditorKit kit = CloneableEditorSupport.getEditorKit(GradleCliEditorKit.MIME_TYPE); taArgs.setEditorKit(kit); taArgs.getDocument().putProperty(Document.StreamDescriptionProperty, project); taArgs.getDocument().addDocumentListener(applyListener); initDefaultModels(); comboReady = true; }
Example 6
Source File: GradleExecutorOptionsPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates new form GradleExecutorOptionsPanel */ public GradleExecutorOptionsPanel(Project project) { this.project = project; initComponents(); EditorKit kit = CloneableEditorSupport.getEditorKit(GradleCliEditorKit.MIME_TYPE); epCLI.setEditorKit(kit); if (project != null) { epCLI.getDocument().putProperty(Document.StreamDescriptionProperty, project); } else { tfRememberAs.setEnabled(false); lbRememberAs.setEnabled(false); } epCLI.requestFocus(); }
Example 7
Source File: EditorSanityTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testHTMLEditorKits() { JEditorPane pane = new JEditorPane(); setContentTypeInAwt(pane, "text/html"); // Test JDK kit EditorKit kitFromJdk = pane.getEditorKit(); assertNotNull("Can't find JDK kit for text/html", kitFromJdk); assertTrue("Wrong JDK kit for text/html", kitFromJdk instanceof HTMLEditorKit); // Check that org.netbeans.modules.html.editor is available boolean htmlPresent = false; Collection<? extends ModuleInfo> modules = Lookup.getDefault().lookupAll(ModuleInfo.class); for(ModuleInfo info : modules) { if (info.getCodeNameBase().equals("org.netbeans.modules.html.editor")) { htmlPresent = true; break; } } if (htmlPresent) { // Test Netbeans kit EditorKit kitFromNb = CloneableEditorSupport.getEditorKit("text/html"); assertNotNull("Can't find Nb kit for text/html", kitFromNb); assertEquals("Wrong Nb kit for text/html", "org.netbeans.modules.html.editor.api.HtmlKit", kitFromNb.getClass().getName()); } else { log("Module org.netbeans.modules.html.editor not present, skipping HTMLKit test..."); } }
Example 8
Source File: EncodedReaderFactory.java From netbeans with Apache License 2.0 | 5 votes |
/** @return The writer or <code>null</code>. */ private Writer getWriterFromKit(File file, FileObject fo, FileLock lock, String mimeType) throws FileNotFoundException { EditorKit kit = CloneableEditorSupport.getEditorKit(mimeType); if (kit.getContentType().equalsIgnoreCase("text/plain") && "text/x-dtd".equalsIgnoreCase(mimeType)) { // Use XML kit for DTDs if not defined otherwise kit = CloneableEditorSupport.getEditorKit("text/xml"); } //System.out.println(" KIT for "+mimeType+" = "+kit); if (kit != null) { Document doc = kit.createDefaultDocument(); return new DocWriter(doc, fo, lock, file, kit, null, null); } return null; }
Example 9
Source File: PlainTextEditor.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
private static EditorKit getEditorKit () { return CloneableEditorSupport.getEditorKit("text/plain"); //NOI18N }
Example 10
Source File: EncodedReaderFactory.java From netbeans with Apache License 2.0 | 4 votes |
/** @return The reader or <code>null</code>. */ private Reader getReaderFromKit(File file, FileObject fo, String mimeType) throws FileNotFoundException { EditorKit kit = CloneableEditorSupport.getEditorKit(mimeType); if (kit.getContentType().equalsIgnoreCase("text/plain") && "text/x-dtd".equalsIgnoreCase(mimeType)) { // Use XML kit for DTDs if not defined otherwise kit = CloneableEditorSupport.getEditorKit("text/xml"); } //System.out.println(" KIT for "+mimeType+" = "+kit); if (kit != null) { Document doc = kit.createDefaultDocument(); InputStream stream = null; try { if (file != null) { stream = new FileInputStream(file); } else { stream = fo.getInputStream(); } kit.read(stream, doc, 0); String text = doc.getText(0, doc.getLength()); //System.out.println(" TEXT = "+text); doc = null; // Release it, we have the text return new StringReader(text); } catch (IOException ioex) { FileNotFoundException fnfex; if (file != null) { fnfex = new FileNotFoundException("Can not read file "+file.getAbsolutePath()); } else { fnfex = new FileNotFoundException("Can not read file "+fo); } fnfex.initCause(ioex); throw fnfex; } catch (BadLocationException blex) { // Something wrong??? ErrorManager.getDefault().notify(blex); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) {} } } } return null; }
Example 11
Source File: DiffViewImpl.java From netbeans with Apache License 2.0 | 4 votes |
public void setMimeType2(String mime) { EditorKit kit = CloneableEditorSupport.getEditorKit(mime); jEditorPane2.setEditorKit(kit); }
Example 12
Source File: DiffViewImpl.java From netbeans with Apache License 2.0 | 4 votes |
public void setMimeType1(String mime) { EditorKit kit = CloneableEditorSupport.getEditorKit(mime); jEditorPane1.setEditorKit(kit); }
Example 13
Source File: DiffPanel.java From netbeans with Apache License 2.0 | 4 votes |
public void setMimeType2(String mime) { EditorKit kit = CloneableEditorSupport.getEditorKit(mime); jEditorPane2.setEditorKit(kit); //Document doc = jEditorPane2.getDocument(); //if (!(doc instanceof StyledDocument)) jEditorPane2.setDocument(new DefaultStyledDocument()); }
Example 14
Source File: DiffPanel.java From netbeans with Apache License 2.0 | 4 votes |
public void setMimeType1(String mime) { EditorKit kit = CloneableEditorSupport.getEditorKit(mime); jEditorPane1.setEditorKit(kit); //Document doc = jEditorPane1.getDocument(); //if (!(doc instanceof StyledDocument)) jEditorPane1.setDocument(new DefaultStyledDocument()); }
Example 15
Source File: MergePanel.java From netbeans with Apache License 2.0 | 4 votes |
public void setMimeType3(String mime) { EditorKit kit = CloneableEditorSupport.getEditorKit(mime); jEditorPane3.setEditorKit(kit); }
Example 16
Source File: MergePanel.java From netbeans with Apache License 2.0 | 4 votes |
public void setMimeType2(String mime) { EditorKit kit = CloneableEditorSupport.getEditorKit(mime); jEditorPane2.setEditorKit(kit); //Document doc = jEditorPane2.getDocument(); //if (!(doc instanceof StyledDocument)) jEditorPane2.setDocument(new DefaultStyledDocument()); }
Example 17
Source File: MergePanel.java From netbeans with Apache License 2.0 | 4 votes |
public void setMimeType1(String mime) { EditorKit kit = CloneableEditorSupport.getEditorKit(mime); jEditorPane1.setEditorKit(kit); //Document doc = jEditorPane1.getDocument(); //if (!(doc instanceof StyledDocument)) jEditorPane1.setDocument(new DefaultStyledDocument()); }