1 19 20 package org.netbeans.editor; 21 22 import java.util.ResourceBundle ; 23 import javax.swing.Action ; 24 import javax.swing.text.JTextComponent ; 25 import org.netbeans.modules.editor.lib2.EditorImplementation; 26 import org.netbeans.spi.editor.EditorImplementationProvider; 27 28 41 42 public abstract class ImplementationProvider { 43 44 private static final ImplementationProvider PROVIDER = new ProviderBridge(); 45 46 47 public static ImplementationProvider getDefault() { 48 return PROVIDER; 49 } 50 51 52 public static void registerDefault(ImplementationProvider prov) { 53 EditorImplementation.getDefault().setExternalProvider(new Wrapper(prov)); 54 } 55 56 57 public abstract ResourceBundle getResourceBundle(String localizer); 58 59 63 public abstract Action [] getGlyphGutterActions(JTextComponent target); 64 65 68 public boolean activateComponent(JTextComponent c) { 69 return false; 70 } 71 72 private static final class ProviderBridge extends ImplementationProvider { 73 74 public ResourceBundle getResourceBundle(String localizer) { 75 return EditorImplementation.getDefault().getResourceBundle(localizer); 76 } 77 78 public Action [] getGlyphGutterActions(JTextComponent target) { 79 return EditorImplementation.getDefault().getGlyphGutterActions(target); 80 } 81 82 public boolean activateComponent(JTextComponent c) { 83 return EditorImplementation.getDefault().activateComponent(c); 84 } 85 } 87 private static final class Wrapper implements EditorImplementationProvider { 88 89 private ImplementationProvider origProvider; 90 91 public Wrapper(ImplementationProvider origProvider) { 92 this.origProvider = origProvider; 93 } 94 95 public ResourceBundle getResourceBundle(String localizer) { 96 return origProvider.getResourceBundle(localizer); 97 } 98 99 public Action [] getGlyphGutterActions(JTextComponent target) { 100 return origProvider.getGlyphGutterActions(target); 101 } 102 103 public boolean activateComponent(JTextComponent c) { 104 return origProvider.activateComponent(c); 105 } 106 107 } } 109 | Popular Tags |