home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.text;
-
- import com.sun.java.swing.JEditorPane;
- import java.awt.event.ActionEvent;
- import java.util.EventObject;
-
- public abstract class StyledEditorKit$StyledTextAction extends TextAction {
- public StyledEditorKit$StyledTextAction(String var1) {
- super(var1);
- }
-
- protected final JEditorPane getEditor(ActionEvent var1) {
- if (var1 != null) {
- Object var2 = ((EventObject)var1).getSource();
- if (var2 instanceof JEditorPane) {
- return (JEditorPane)var2;
- }
-
- JTextComponent var3 = ((TextAction)this).getFocusedComponent();
- if (var3 instanceof JEditorPane) {
- return (JEditorPane)var3;
- }
- }
-
- throw new IllegalArgumentException("target must be JEditorPane");
- }
-
- protected final StyledDocument getStyledDocument(JEditorPane var1) {
- Document var2 = ((JTextComponent)var1).getDocument();
- if (var2 instanceof StyledDocument) {
- return (StyledDocument)var2;
- } else {
- throw new IllegalArgumentException("document must be StyledDocument");
- }
- }
-
- protected final StyledEditorKit getStyledEditorKit(JEditorPane var1) {
- EditorKit var2 = var1.getEditorKit();
- if (var2 instanceof StyledEditorKit) {
- return (StyledEditorKit)var2;
- } else {
- throw new IllegalArgumentException("EditorKit must be StyledEditorKit");
- }
- }
-
- protected final void setCharacterAttributes(JEditorPane var1, AttributeSet var2, boolean var3) {
- int var4 = ((JTextComponent)var1).getSelectionStart();
- int var5 = ((JTextComponent)var1).getSelectionEnd();
- if (var4 != var5) {
- StyledDocument var8 = this.getStyledDocument(var1);
- var8.setCharacterAttributes(var4, var5 - var4, var2, var3);
- } else {
- StyledEditorKit var6 = this.getStyledEditorKit(var1);
- MutableAttributeSet var7 = var6.getInputAttributes();
- if (var3) {
- var7.removeAttributes(var7);
- }
-
- var7.addAttributes(var2);
- }
- }
-
- protected final void setParagraphAttributes(JEditorPane var1, AttributeSet var2, boolean var3) {
- int var4 = ((JTextComponent)var1).getSelectionStart();
- int var5 = ((JTextComponent)var1).getSelectionEnd();
- StyledDocument var6 = this.getStyledDocument(var1);
- var6.setParagraphAttributes(var4, var5 - var4, var2, var3);
- }
- }
-