1 19 20 package org.netbeans.modules.javadoc.comments; 21 22 import java.util.ArrayList ; 23 24 import javax.swing.JEditorPane ; 25 26 import org.openide.src.JavaDocTag; 27 28 33 34 abstract class TagPanel extends javax.swing.JPanel { 35 36 protected ArrayList htmlComponents = new ArrayList (); 37 38 private JavaDocEditorPanel editorPanel; 39 40 TagPanel( JavaDocEditorPanel editorPanel ) { 41 this.editorPanel = editorPanel; 42 } 43 44 abstract void setData( JavaDocTag tag ); 45 46 abstract String getCardName(); 47 48 abstract JavaDocTag getTag( String tagName ); 49 50 void addHTMLComponent( JEditorPane component ) { 51 htmlComponents.add( component ); 52 } 53 54 void handleFormatButton( String begTag, String endTag ) { 55 for ( int i = 0; i < htmlComponents.size(); i++ ) { 56 JEditorPane component = (JEditorPane )htmlComponents.get( i ); 57 if ( component.hasFocus() ) { 58 59 int caretPosition = component.getCaretPosition(); 60 try { 61 component.getDocument().insertString( component.getSelectionStart(), begTag, null ); 62 component.getDocument().insertString( component.getSelectionEnd(), endTag, null ); 63 component.setCaretPosition( caretPosition + begTag.length() ); 64 } 65 catch ( javax.swing.text.BadLocationException e ) { 66 } 68 break; 69 } 70 } 71 } 72 73 void commitTagChange() { 74 editorPanel.commitTagChange(); 75 } 76 77 void enableHTMLButtons( boolean enable ) { 78 editorPanel.enableButtons( enable ); 79 } 80 81 abstract void grabFirstFocus(); 82 } 83 | Popular Tags |