X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=ekit%2Fcom%2Fhexidec%2Fekit%2Faction%2FStylesAction.java;fp=ekit%2Fcom%2Fhexidec%2Fekit%2Faction%2FStylesAction.java;h=a35b868da76d23eb28a012bdfb21e457b4e601e4;hb=6ce136dad31e39a1684a657ed5c9b33fba069623;hp=1f6657bf163ee59abf2d652501db55a3710ff01e;hpb=6dd702802493556cff5e55eb4982d23e79a30832;p=old-projects.git diff --git a/ekit/com/hexidec/ekit/action/StylesAction.java b/ekit/com/hexidec/ekit/action/StylesAction.java index 1f6657b..a35b868 100644 --- a/ekit/com/hexidec/ekit/action/StylesAction.java +++ b/ekit/com/hexidec/ekit/action/StylesAction.java @@ -1,77 +1,77 @@ -/* -GNU Lesser General Public License - -StylesAction -Copyright (C) 2000-2003 Howard Kistler - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package com.hexidec.ekit.action; - -import java.awt.event.ActionEvent; -import javax.swing.JComboBox; -import javax.swing.JEditorPane; -import javax.swing.text.MutableAttributeSet; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.StyledEditorKit; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLEditorKit; - -import com.hexidec.util.Translatrix; - -/** Class for handling CSS style events - */ -public class StylesAction extends StyledEditorKit.StyledTextAction -{ - - JComboBox parent; - - public StylesAction(JComboBox myParent) - { - super("css-style"); - parent = myParent; - } - - public void actionPerformed(ActionEvent e) - { - if(!(this.isEnabled())) - { - return; - } - JEditorPane editor = getEditor(e); - if(editor != null) - { - String stylename = (String)(parent.getSelectedItem()); - if(stylename == null) - { - return; - } - else if(stylename.equals(Translatrix.getTranslationString("NoCSSStyle"))) - { - return; - } - boolean replace = false; - MutableAttributeSet attr = null; - SimpleAttributeSet cls = new SimpleAttributeSet(); - cls.addAttribute(HTML.Attribute.CLASS, stylename); - attr = new SimpleAttributeSet(); - attr.addAttribute(HTML.Tag.FONT, cls); - MutableAttributeSet inattr = ((HTMLEditorKit)(editor.getEditorKitForContentType("text/html"))).getInputAttributes(); - inattr.addAttributes(attr); - setCharacterAttributes(editor, attr, replace); - } - } -} +/* +GNU Lesser General Public License + +StylesAction +Copyright (C) 2000 Howard Kistler + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package com.hexidec.ekit.action; + +import java.awt.event.ActionEvent; +import javax.swing.JComboBox; +import javax.swing.JEditorPane; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyledEditorKit; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLEditorKit; + +import com.hexidec.util.Translatrix; + +/** Class for handling CSS style events + */ +public class StylesAction extends StyledEditorKit.StyledTextAction +{ + + JComboBox parent; + + public StylesAction(JComboBox myParent) + { + super("css-style"); + parent = myParent; + } + + public void actionPerformed(ActionEvent e) + { + if(!(this.isEnabled())) + { + return; + } + JEditorPane editor = getEditor(e); + if(editor != null) + { + String stylename = (String)(parent.getSelectedItem()); + if(stylename == null) + { + return; + } + else if(stylename.equals(Translatrix.getTranslationString("NoCSSStyle"))) + { + return; + } + boolean replace = false; + MutableAttributeSet attr = null; + SimpleAttributeSet cls = new SimpleAttributeSet(); + cls.addAttribute(HTML.Attribute.CLASS, stylename); + attr = new SimpleAttributeSet(); + attr.addAttribute(HTML.Tag.FONT, cls); + MutableAttributeSet inattr = ((HTMLEditorKit)(editor.getEditorKitForContentType("text/html"))).getInputAttributes(); + inattr.addAttributes(attr); + setCharacterAttributes(editor, attr, replace); + } + } +}