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


Java FoldType类代码示例

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


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

示例1: init

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private void init(Lookup mimeLookup) {
    Collection<? extends FoldType> types = 
            new ArrayList<FoldType>((FoldUtilities.getFoldTypes(mime).values()));
    
    result = mimeLookup.lookupResult(ContentReader.Factory.class);
    Collection<? extends ContentReader.Factory> factories = result.allInstances();

    List<ContentReader> l;
    for (FoldType ft : types) {
        l = null;
        for (ContentReader.Factory f : factories) {
            ContentReader cr = f.createReader(ft);
            if (cr != null) {
                if (l == null) {
                    l = new ArrayList<ContentReader>(3);
                }
                l.add(cr);
            }
        }
        if (l != null) {
            readers.put(ft, l);
        }
    }
    result.addLookupListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FoldContentReaders.java

示例2: getReaders

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
public List<ContentReader> getReaders(String mime, FoldType ft) {
    N node;
    synchronized (mimeNodes) {
        node = mimeNodes.get(mime);
    }
    if (node == null) {
        node = mimeNodes.get(mime);
        if (node == null) {
            node = new N(mime, MimeLookup.getLookup(mime));
            synchronized (mimeNodes) {
                N n2 = mimeNodes.get(mime);
                if (n2 == null) {
                    mimeNodes.put(mime, node);
                } else {
                    node = n2;
                }
            }
        }
    }
    return node.readers(ft);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FoldContentReaders.java

示例3: DefaultFoldingOptions

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
/**
 * Creates new form DefaultFoldingOptions
 */
public DefaultFoldingOptions(String mime, Preferences preferences) {
    initComponents();
	 
    VerticalFlowLayout vfl = new VerticalFlowLayout();
    localSwitchboard.setLayout(vfl);
    
    vfl = new VerticalFlowLayout();
    localSwitchboard.setLayout(vfl);

    this.mimeType = mime;
    this.preferences = preferences;
    
    String parentMime = MimePath.parse(mime).getInheritedType();
    if (parentMime != null) {
        parentFoldTypes = new HashSet<String>(13);
        for (FoldType ft : FoldUtilities.getFoldTypes(parentMime).values()) {
            parentFoldTypes.add(ft.code());
        }
    } else {
        parentFoldTypes = Collections.emptyList();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:DefaultFoldingOptions.java

示例4: updateCheckers

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private String updateCheckers(PreferenceChangeEvent evt) {
    String pk = evt.getKey();
    if (pk != null) {
        if (pk.equals(SimpleValueNames.CODE_FOLDING_ENABLE)) {
            updateEnabledState();
            return pk;
        }
        if (pk.equals(PREF_OVERRIDE_DEFAULTS)) {
            updateOverrideChanged();
        } else if (!pk.startsWith(COLLAPSE_PREFIX)) {
            return pk;
        }
    } else {
        updateEnabledState();
    }
    String c = pk == null ? null : pk.substring(COLLAPSE_PREFIX.length());
    for (JCheckBox cb : controls) {
        FoldType ft = (FoldType)cb.getClientProperty("type"); // NOI18N
        FoldType ftp = ft.parent();
        if (c == null || ft.code().equals(c) || (ftp != null && ftp.code().equals(c))) {
            updateChecker(pk, cb, ft);
            return pk;
        }
    }
    return pk;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DefaultFoldingOptions.java

示例5: updatePref

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private void updatePref(ItemEvent e) {
    JCheckBox cb = (JCheckBox)e.getSource();
    FoldType ft = (FoldType)cb.getClientProperty("type"); // NOI18N
    
    String prefKey = COLLAPSE_PREFIX + ft.code();
    lastChangedCB = cb;
    LOG.log(Level.FINE, "Updating preference: " + prefKey + ", value = " + cb.isSelected()); // NOI18N
    preferences.putBoolean(prefKey, cb.isSelected());
    
    if (!"".equals(mimeType)) {
        return;
    }
    // legacy setting support in transient prefs:
    String propagate = FoldOptionsController.LEGACY_SETTINGS_MAP.get(ft.code());
    if (propagate != null) {
        prefKey = COLLAPSE_PREFIX + propagate;
        LOG.log(Level.FINE, "Updating LEGACY preference: " + prefKey + ", value = " + cb.isSelected()); // NOI18N
        preferences.putBoolean(prefKey, cb.isSelected());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DefaultFoldingOptions.java

示例6: scan

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private void scan(final ParserResult info,
    final Collection<FoldInfo> folds, final Document doc, final
    StructureScanner scanner) {
    
    // #217322, disabled folding -> no folds will be created
    String mime = info.getSnapshot().getMimeType();
    
    if (!FoldUtilities.isFoldingEnabled(mime)) {
        LOG.log(Level.FINER, "Folding is not enabled for MIME: {0}", mime);
        return;
    }
    final Map<String,List<OffsetRange>> collectedFolds = scanner.folds(info);
    final Collection<? extends FoldType> ftypes = FoldUtilities.getFoldTypes(mime).values();
    doc.render(new Runnable() {
        @Override
        public void run() {
            addTree(folds, info, collectedFolds, ftypes);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:GsfFoldManager.java

示例7: addFoldsOfType

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private boolean addFoldsOfType(
            String type, Map<String,List<OffsetRange>> folds,
            Collection<FoldInfo> result,
            FoldType foldType) {
    
    List<OffsetRange> ranges = folds.get(type); //NOI18N
    if (ranges != null) {
        if (LOG.isLoggable(Level.FINEST)) {
            LOG.log(Level.FINEST, "Creating folds {0}", new Object[] {
                type
            });
        }
        for (OffsetRange range : ranges) {
            if (LOG.isLoggable(Level.FINEST)) {
                LOG.log(Level.FINEST, "Fold: {0}", range);
            }
            addFold(range, result, foldType);
        }
        folds.remove(type);
        return true;
    } else {
        LOG.log(Level.FINEST, "No folds of type {0}", type);
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:GsfFoldManager.java

示例8: addFold

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private void addFold(OffsetRange range, Collection<FoldInfo> folds, FoldType type) {
    if (range != OffsetRange.NONE) {
        int start = range.getStart();
        int end = range.getEnd();
        // the readlock will be interrupted before FoldInfos are committed to fold hierarchy,
        // so we don't need to check against doc length here. FoldOp.update checks+ignores under read lock.
        if (start != (-1) && end != (-1)) {
            FoldInfo fi = FoldInfo.range(start, end, type);
            // hack for singular imports fold
            if (fi.getType() == IMPORTS_FOLD_TYPE && imports == null) {
                imports = fi;
            }
            folds.add(fi);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:GsfFoldManager.java

示例9: createFold

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
/**
 * Creates a new fold and adds to the fold hierarchy.
 */
private Fold createFold(FoldType type, String description, boolean collapsed,
        int startOffset, int endOffset, FoldHierarchyTransaction transaction)
            throws BadLocationException {
    Fold fold = null;
    if ( startOffset >= 0 &&
         endOffset >= 0 &&
         startOffset < endOffset &&
         endOffset <= getDocument().getLength() ) {
        fold = getOperation().addToHierarchy(
                type,
                description.intern(), //save some memory
                collapsed,
                startOffset,
                endOffset,
                description.length(),
                0,
                null,
                transaction);
    }
    return fold;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:XmlFoldManager.java

示例10: cleanupPreferences

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private void cleanupPreferences(String mime, Preferences pref) {
    Collection<? extends FoldType> types = FoldUtilities.getFoldTypes(mime).values();
    String parent = MimePath.parse(mime).getInheritedType();
    if (parent == null) {
        return;
    }
    if (types.isEmpty()) {
        // legacy language, do not erase its settings
        return;
    }
    Preferences pprefs = MimeLookup.getLookup(parent).lookup(Preferences.class);
    for (FoldType ft : types) {
        String key = FoldUtilitiesImpl.PREF_COLLAPSE_PREFIX + ft.code();
        if (isDefinedLocally(pref, key)) {
            if (pprefs.get(key, null) != null) {
                pref.remove(key);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:LegacySettingsSync.java

示例11: map

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private Map<String, FoldType> map() {
    Map<String, FoldType> m;
    
    m = valueMap;
    if (m == null) {
        synchronized (this) {
            if (valueMap != null) {
                return valueMap;
            }
            Set<FoldType> vals = enums;
            m = new LinkedHashMap<String, FoldType>();
            for (FoldType e : vals) {
                FoldType old = m.put(e.code(), e);
                if (old != null) {
                    throw new IllegalArgumentException("Two fold types share the same code: " + old + " and " + e);
                }
            }
            this.valueMap = m;
        }
    }
    return m;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FoldRegistry.java

示例12: FoldInfo

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private FoldInfo(int start, int end, FoldType ft) {
    Parameters.notNull("ft", ft);
    if (start < 0) {
        throw new IllegalArgumentException("Invalid start offet: " + start);
    }
    if (end < start) {
        throw new IllegalArgumentException("Invalid end offset: " + end + ", start is: " + start);
    }
    this.type = ft;
    this.start = start;
    this.end = end;
    this.template = ft.getTemplate();
    /*
    if ((end - start) < (template.getGuardedStart() + template.getGuardedEnd())) {
        throw new IllegalArgumentException("Invalid fold length: (endOffset=" + end // NOI18N
            + " - startOffset=" + start + ") < " // NOI18N
            + "(startGuardedLength=" + template.getGuardedStart() // NOI18N
            + " + endGuardedLength=" + template.getGuardedEnd() + ")"); // NOI18N
    }
    */
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FoldInfo.java

示例13: addFold

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private void addFold(FoldType type, int start, int stop, FoldHierarchyTransaction fht, Object extraInfo) 
        throws BadLocationException {
    Iterator<Fold> it = operation.foldIterator();
    while (it.hasNext()) {
        Fold f = it.next();
        // don't replace existing folds unless they've changed
        if (f.getStartOffset() == start && f.getEndOffset() == stop &&
                f.getType() == type) {
            //logger.info("Fold wasn't changed, skipping add...");
            return;
        }
        // remove if old fold was changed
        if (f.getStartOffset() >= start && f.getStartOffset() <= stop) {
            operation.removeFromHierarchy(f, fht);
        }
    }
    operation.addToHierarchy(type, start, stop, false, null, null, extraInfo, fht);
}
 
开发者ID:bdamer,项目名称:drools-netbeans-plugin,代码行数:19,代码来源:DRLFoldManager.java

示例14: load

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
private void load() {
    types = new ArrayList<FoldType>(FoldUtilities.getFoldTypes(mimeType).values());
    if ("".equals(mimeType)) { // NOI18N
        filterUsedMimeTypes();
    }

    boolean override = isCollapseRedefined();
    boolean currentOverride = 
            isDefinedLocally(PREF_OVERRIDE_DEFAULTS) ? !preferences.getBoolean(PREF_OVERRIDE_DEFAULTS, true) : false;
    if (override != currentOverride) {
        updateOverrideChanged();
    }
    
    for (FoldType ft : types) {
        String name = ft.getLabel();
        
        JCheckBox cb = createCheckBox(ft);
        cb.setText(name);
        cb.putClientProperty("id", ft.code()); // NOI18N
        cb.putClientProperty("type", ft); // NOI18N
        localSwitchboard.add(cb);
        controls.add(cb);
        cb.addItemListener(this);
    }
    
    // watch out for preferences
    this.preferences.addPreferenceChangeListener(this);
    updateEnabledState();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:DefaultFoldingOptions.java

示例15: isCollapseRedefined

import org.netbeans.api.editor.fold.FoldType; //导入依赖的package包/类
/**
 * Checks whether some of the collapse- options is redefined for this MIME type.
 * If so, the checkbox will be selected even though the override option is not
 * present.
 * 
 * @return 
 */
private boolean isCollapseRedefined() {
    for (FoldType ft : types) {
        String pref = k(ft);
        if (((OverridePreferences)preferences).isOverriden(pref)) {
           if (defaultPrefs == null || 
                (parentFoldTypes.contains(ft.code()) || (ft.parent() != null && parentFoldTypes.contains(ft.parent().code())))) {
                return true;
           }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:DefaultFoldingOptions.java


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