当前位置: 首页>>代码示例>>Java>>正文


Java FoldManagerFactory类代码示例

本文整理汇总了Java中org.netbeans.spi.editor.fold.FoldManagerFactory的典型用法代码示例。如果您正苦于以下问题:Java FoldManagerFactory类的具体用法?Java FoldManagerFactory怎么用?Java FoldManagerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FoldManagerFactory类属于org.netbeans.spi.editor.fold包,在下文中一共展示了FoldManagerFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerFactory

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
/**
 * Register the fold manager factory so that it will be used for the code folding
 * for the given mime-type.
 *
 * @param mimeType mime-type for which the factory is being registered.
 * @param factory fold manager factory to be registered.
 *  <br>
 *  The factory added sooner will have higher priority regarding
 *  the fold appearance.
 */
public void registerFactory(String mimeType, FoldManagerFactory factory) {
    assert (mimeType != null) && (factory != null);

    synchronized (mime2factoryList) {
        List factoryList = (List)mime2factoryList.get(mimeType);
        if (factoryList == null) {
            factoryList = new ArrayList();
            mime2factoryList.put(mimeType, factoryList);
        }
        factoryList.add(factory);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CustomProvider.java

示例2: registerFactories

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
/**
 * Register multiple factories for the given mime-type
 * in the order as they are present in the array.
 */
public void registerFactories(String mimeType, FoldManagerFactory[] factories) {
    synchronized (mime2factoryList) {
        for (int i = 0; i < factories.length; i++) {
            registerFactory(mimeType, factories[i]);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CustomProvider.java

示例3: setUp

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();
    manager = new TestFoldManager();
    
    class FMF implements FoldManagerFactory {
        @Override
        public FoldManager createFoldManager() {
            return manager;
        }
    }

    final FoldHierarchyTestEnv env = new FoldHierarchyTestEnv(
            new FMF()
    );
    doc = env.getDocument();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 20; i++) {
        sb.append("12345678901234567890");
    }
    doc.insertString(0, sb.toString(), null);
    
    hierarchy = env.getHierarchy();
    fold35 = FoldUtilities.findOffsetFold(hierarchy, 35);
    fold90 = FoldUtilities.findOffsetFold(hierarchy, 90);
    fold102 = FoldUtilities.findOffsetFold(hierarchy, 102);
    hierarchy.collapse(fold35);
    hierarchy.collapse(fold90);

    hierarchy.addFoldHierarchyListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:FoldGuardTest.java

示例4: testFoldHierarchyMonitorNoProviders

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
/**
 * Checks that FoldHierarchyMonitor is pinged during hierarchy creation.
 * No provider is registered, so the hierarchy should report active == false.
 */
public void testFoldHierarchyMonitorNoProviders() throws Exception {
    MockMimeLookup.setInstances(MimePath.parse(""), new FHM());

    FoldHierarchyTestEnv env = new FoldHierarchyTestEnv(new FoldManagerFactory[0]);
    
    env.getHierarchy();
    
    assertTrue("Folds not attached", attached);
    assertFalse("Unexpected provider", active);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:SimpleFoldManagerTest.java

示例5: FoldHierarchyTestEnv

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
public FoldHierarchyTestEnv(FoldManagerFactory... factories) {
    pane = new JEditorPane();
    assert (getMimeType() != null);
    pane.setDocument(new BaseDocument(false, "text/plain"));

    FoldManagerFactoryProvider.setForceCustomProvider(true);
    FoldManagerFactoryProvider provider = FoldManagerFactoryProvider.getDefault();
    assert (provider instanceof CustomProvider)
        : "setForceCustomProvider(true) did not ensure CustomProvider use"; // NOI18N

    CustomProvider customProvider = (CustomProvider)provider;
    customProvider.removeAllFactories(); // cleanup all registered factories
    customProvider.registerFactories(getMimeType(), factories);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FoldHierarchyTestEnv.java

示例6: setUp

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();
    Lookup.getDefault();
    prepareTest(new String[] {
            "/org/netbeans/modules/editor/resources/layer.xml",
            "/META-INF/generated-layer.xml",
            "/org/netbeans/modules/defaults/mf-layer.xml",
    },
    new Object[0]);
    // hack:
    MimeLookup.getLookup("").lookup(FoldHierarchyMonitor.class);
    env = new FoldHierarchyTestEnv(new FoldManagerFactory() {
        @Override
        public FoldManager createFoldManager() {
            return fm = new FM();
        }
    });
    pane = env.getPane();
    env.getPane().setEditorKit(new Kit());
    env.getDocument().insertString(0, "123456789-123456789-123 aa 89-123456789-1234567890", null);
    
    // ensure initialized
    env.getHierarchy(); 
    // cannot be done in FoldManager, as setEditorKit() will replace document and reinitialize folds in 2nd thread, which may
    // complete even faster than insertString(), so BLE could be thrown.
    FoldHierarchyTransaction tran = fm.op.openTransaction();
    fm.op.addToHierarchy(
            FT, 
            "", 
            true, 
            10, 
            40, 
            1, 1, 
            null, 
            tran);
    tran.commit();
                
    fold = FoldUtilities.findOffsetFold(env.getHierarchy(), 25);
   // get x/y of the folded part:
    JFrame fr = new JFrame("test");
    fr.setBounds(0, 0, 400, 100);
    fr.add(pane);
    fr.setVisible(true);
    
    delegate = (Callable<Boolean>)pane.getClientProperty("org.netbeans.api.fold.expander");
    pane.putClientProperty("org.netbeans.api.fold.expander", new Callable<Boolean>() {
        public Boolean call() throws Exception {
            return retValue = delegate.call();
        }
        
        public boolean equals(Object o) {
            return retValue = delegate.equals(o);
        }
    });
    pane.requestFocus();
    selectWordCalled = false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:BaseCaretTest.java

示例7: testUpdateNoChanges

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
/**
 * Checks that no changes (update with the same infos) will not fire events, remove or add any folds.
 * 
 * @throws Exception 
 */
public void testUpdateNoChanges() throws Exception {
    final TestFoldManager[] mgr = new TestFoldManager[1];
    FoldHierarchyTestEnv env = new FoldHierarchyTestEnv(new FoldManagerFactory() {
        @Override
        public FoldManager createFoldManager() {
            return mgr[0] = new TestFoldManager();
        }
    });
    AbstractDocument doc = env.getDocument();
    doc.insertString(0, "12345678901234567890", null);

    FoldHierarchy hierarchy = env.getHierarchy();
    
    Collection<FoldInfo> infos = new ArrayList<FoldInfo>(10);
    infos.add(FoldInfo.range(0, 1, FoldType.MEMBER));
    infos.add(FoldInfo.range(9, 10, FoldType.MEMBER));
    infos.add(FoldInfo.range(14, 16, FoldType.MEMBER));
    // not sorted, check :)
    infos.add(FoldInfo.range(3, 12, FoldType.MEMBER));
    infos.add(FoldInfo.range(5, 6, FoldType.MEMBER));
    
    doc.readLock();
    try {
        hierarchy.lock();
        TestFoldManager m = mgr[0];
        try {
            Collection<Fold> remove = new ArrayList<Fold>();
            Collection<FoldInfo> create = new ArrayList<FoldInfo>();
            
            final boolean[] changed = new boolean[1];
            
            hierarchy.addFoldHierarchyListener(new FoldHierarchyListener() {

                @Override
                public void foldHierarchyChanged(FoldHierarchyEvent evt) {
                    changed[0] = true;
                }
            });
            
            Map<FoldInfo, Fold> mapping = m.operation.update(infos, remove, create);
            
            assertEquals(m.initFolds.size(), mapping.size());
            assertTrue(m.initFolds.containsAll(mapping.values()));
            assertFalse(changed[0]);
            
        } finally {
            hierarchy.unlock();
        }
    } finally {
        doc.readUnlock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:FoldOperationTest.java

示例8: testUpdateCreateFold

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
/**
 * Checks that folds are created beween two folds, encapsulating existing folds.
 * 
 * @throws Exception 
 */
public void testUpdateCreateFold() throws Exception {
    final TestFoldManager[] mgr = new TestFoldManager[1];
    FoldHierarchyTestEnv env = new FoldHierarchyTestEnv(new FoldManagerFactory() {
        @Override
        public FoldManager createFoldManager() {
            return mgr[0] = new TestFoldManager();
        }
    });
    AbstractDocument doc = env.getDocument();
    doc.insertString(0, "12345678901234567890", null);

    FoldHierarchy hierarchy = env.getHierarchy();
    
    List<FoldInfo> infos = createDefaultInfos();
    
    // add a new fold between #1 and #2
    infos.add(FoldInfo.range(2, 3, FoldType.MEMBER));
    
    // add a new fold at the end:
    infos.add(FoldInfo.range(19,20, FoldType.MEMBER));
    
    // add a fold, which encapsulates #2 - #5
    infos.add(FoldInfo.range(3, 18, FoldType.MEMBER));
    
    // add a fold, which encapsulates ##5
    infos.add(FoldInfo.range(13, 16, FoldType.MEMBER));
    
    doc.readLock();
    try {
        hierarchy.lock();
        TestFoldManager m = mgr[0];
        try {
            Collection<Fold> remove = new ArrayList<Fold>();
            Collection<FoldInfo> create = new ArrayList<FoldInfo>();
            
            final boolean[] changed = new boolean[1];
            
            hierarchy.addFoldHierarchyListener(new FoldHierarchyListener() {
                @Override
                public void foldHierarchyChanged(FoldHierarchyEvent evt) {
                    changed[0] = true;
                }
            });
            Map<FoldInfo, Fold> mapping = m.operation.update(infos, remove, create);
            
            // 3 folds added, no deleted:
            assertEquals(4, create.size());
            assertEquals(0, remove.size());
            
        } finally {
            hierarchy.unlock();
        }
    } finally {
        doc.readUnlock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:62,代码来源:FoldOperationTest.java

示例9: userFoldManagerFactory

import org.netbeans.spi.editor.fold.FoldManagerFactory; //导入依赖的package包/类
/**
 * Creates a user-defined fold manager, that processes specific token type.
 * The manager tries to find start/end markers within the token text. If found,
 * a Fold is created. The manager only looks in tokens, whose {@code primaryCategory}
 * starts with a String, which is stored under 'tokenId' key in the params map.
 * <p/>
 * The method is designed to be called from the filesystem layer as follows:
 * <code><pre>
 * &lt;file name="my-custom-foldmanager.instance">
 * &lt;attr name="instanceCreate" methodvalue="org.netbeans.api.editor.fold.FoldUtilities.createUserFoldManager"/>
 * &lt;attr name="tokenid" stringvalue="comment"/>
 * &lt;/file>
 * </pre></code>
 *
 * @param map the configuration parameters.
 * @return FoldManagerFactory instance
 */
public static FoldManagerFactory userFoldManagerFactory(Map params) {
    final String s = (String) params.get("tokenId");
    return new FoldManagerFactory() {
        @Override
        public FoldManager createFoldManager() {
            return userFoldManager(s);
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:FoldingSupport.java


注:本文中的org.netbeans.spi.editor.fold.FoldManagerFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。