1 package org.netbeans.modules.editor.fold; 2 3 import javax.swing.JEditorPane ; 4 import javax.swing.text.AbstractDocument ; 5 import org.netbeans.api.editor.fold.FoldHierarchy; 6 import org.netbeans.spi.editor.fold.FoldManagerFactory; 7 8 14 15 16 20 class FoldHierarchyTestEnv { 21 22 private JEditorPane pane; 23 24 FoldHierarchyTestEnv(FoldManagerFactory factory) { 25 this(new FoldManagerFactory[] { factory }); 26 } 27 28 FoldHierarchyTestEnv(FoldManagerFactory[] factories) { 29 pane = new JEditorPane (); 30 assert (getMimeType() != null); 31 32 FoldManagerFactoryProvider.setForceCustomProvider(true); 33 FoldManagerFactoryProvider provider = FoldManagerFactoryProvider.getDefault(); 34 assert (provider instanceof CustomProvider) 35 : "setForceCustomProvider(true) did not ensure CustomProvider use"; 37 CustomProvider customProvider = (CustomProvider)provider; 38 customProvider.removeAllFactories(); customProvider.registerFactories(getMimeType(), factories); 40 } 41 42 public JEditorPane getPane() { 43 return pane; 44 } 45 46 public AbstractDocument getDocument() { 47 return (AbstractDocument )getPane().getDocument(); 48 } 49 50 public String getMimeType() { 51 return pane.getEditorKit().getContentType(); 52 } 53 54 public FoldHierarchy getHierarchy() { 55 FoldHierarchy hierarchy = FoldHierarchy.get(getPane()); 56 assert (hierarchy != null); 57 return hierarchy; 58 } 59 60 } 61 | Popular Tags |