|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.editor.html; import java.awt.event.ActionEvent; import javax.swing.Action; import javax.swing.text.Document; import javax.swing.text.TextAction; import javax.swing.text.JTextComponent; import org.netbeans.editor.*; import org.netbeans.editor.ext.*; import org.netbeans.editor.ext.html.*; /** * Editor kit implementation for HTML content type * * @author Miloslav Metelka * @version 1.00 */ public class HTMLKit extends org.netbeans.modules.editor.NbEditorKit { static final long serialVersionUID =-1381945567613910297L; public static final String HTML_MIME_TYPE = "text/html"; // NOI18N public static final String shiftInsertBreakAction = "shift-insert-break"; // NOI18N private static boolean setupReadersInitialized = false; public HTMLKit(){ if (!setupReadersInitialized){ NbReaderProvider.setupReaders(); setupReadersInitialized = true; } } public String getContentType() { return HTML_MIME_TYPE; } protected void initDocument(BaseDocument doc) { /*doc.addLayer(new JavaDrawLayerFactory.JavaLayer(), JavaDrawLayerFactory.JAVA_LAYER_VISIBILITY);*/ doc.addDocumentListener(new HTMLDrawLayerFactory.TagParenWatcher()); } /** Create new instance of syntax coloring scanner * @param doc document to operate on. It can be null in the cases the syntax * creation is not related to the particular document */ public Syntax createSyntax(Document doc) { return new HTMLSyntax(); } /** Create syntax support */ public SyntaxSupport createSyntaxSupport(BaseDocument doc) { return new HTMLSyntaxSupport(doc); } public Completion createCompletion(ExtEditorUI extEditorUI) { return new HTMLCompletion(extEditorUI); } public Formatter createFormatter() { //return new LineWrapFormatter(this.getClass()); return new HTMLFormatter(this.getClass()); } protected Action[] createActions() { Action[] HTMLActions = new Action[] { new HTMLShiftBreakAction() }; return TextAction.augmentList(super.createActions(), HTMLActions); } public static class HTMLShiftBreakAction extends BaseAction { static final long serialVersionUID =4004043376345356061L; public HTMLShiftBreakAction() { super( shiftInsertBreakAction, ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET); } public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { Completion completion = ExtUtilities.getCompletion(target); if (completion != null && completion.isPaneVisible()) { if (completion.substituteText( true )) { // completion.setPaneVisible(false); } else { completion.refresh(false); } } } } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.