1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
416 */
417 static InputStream getResourceAsStream(String name) {
418 try {
419 return ResourceLoader.getResourceAsStream(name);
420 } catch (Throwable e) {
421 // If the class doesn't exist or we have some other
422 // problem we just try to call getResourceAsStream directly.
423 return HTMLEditorKit.class.getResourceAsStream(name);
424 }
425 }
426
427 /**
428 * Fetches the command list for the editor. This is
429 * the list of commands supported by the superclass
430 * augmented by the collection of commands defined
431 * locally for style operations.
432 *
433 * @return the command list
434 */
435 public Action[] getActions() {
436 return TextAction.augmentList(super.getActions(), this.defaultActions);
437 }
438
439 /**
440 * Copies the key/values in <code>element</code>s AttributeSet into
441 * <code>set</code>. This does not copy component, icon, or element
442 * names attributes. Subclasses may wish to refine what is and what
443 * isn't copied here. But be sure to first remove all the attributes that
444 * are in <code>set</code>.<p>
445 * This is called anytime the caret moves over a different location.
446 *
447 */
448 protected void createInputAttributes(Element element,
449 MutableAttributeSet set) {
450 set.removeAttributes(set);
451 set.addAttributes(element.getAttributes());
452 set.removeAttribute(StyleConstants.ComposedTextAttribute);
453
454 Object o = set.getAttribute(StyleConstants.NameAttribute);
455 if (o instanceof HTML.Tag) {
456 HTML.Tag tag = (HTML.Tag)o;
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
416 */
417 static InputStream getResourceAsStream(String name) {
418 try {
419 return ResourceLoader.getResourceAsStream(name);
420 } catch (Throwable e) {
421 // If the class doesn't exist or we have some other
422 // problem we just try to call getResourceAsStream directly.
423 return HTMLEditorKit.class.getResourceAsStream(name);
424 }
425 }
426
427 /**
428 * Fetches the command list for the editor. This is
429 * the list of commands supported by the superclass
430 * augmented by the collection of commands defined
431 * locally for style operations.
432 *
433 * @return the command list
434 */
435 public Action[] getActions() {
436 return TextAction.augmentList(super.getActions(), HTMLEditorKit.defaultActions);
437 }
438
439 /**
440 * Copies the key/values in <code>element</code>s AttributeSet into
441 * <code>set</code>. This does not copy component, icon, or element
442 * names attributes. Subclasses may wish to refine what is and what
443 * isn't copied here. But be sure to first remove all the attributes that
444 * are in <code>set</code>.<p>
445 * This is called anytime the caret moves over a different location.
446 *
447 */
448 protected void createInputAttributes(Element element,
449 MutableAttributeSet set) {
450 set.removeAttributes(set);
451 set.addAttributes(element.getAttributes());
452 set.removeAttribute(StyleConstants.ComposedTextAttribute);
453
454 Object o = set.getAttribute(StyleConstants.NameAttribute);
455 if (o instanceof HTML.Tag) {
456 HTML.Tag tag = (HTML.Tag)o;
|