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


Java ListSelectionModel.addSelectionInterval方法代码示例

本文整理汇总了Java中javax.swing.ListSelectionModel.addSelectionInterval方法的典型用法代码示例。如果您正苦于以下问题:Java ListSelectionModel.addSelectionInterval方法的具体用法?Java ListSelectionModel.addSelectionInterval怎么用?Java ListSelectionModel.addSelectionInterval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.ListSelectionModel的用法示例。


在下文中一共展示了ListSelectionModel.addSelectionInterval方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTo

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public void setTo(ListSelectionModel sm) {
    sm.clearSelection();
    sm.setSelectionMode(selectionMode);
    for (int[] itv : intervals) {
        sm.addSelectionInterval(itv[0], itv[1]);
    }
    sm.setAnchorSelectionIndex(anchor);
    sm.setLeadSelectionIndex(lead);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:OutlineView.java

示例2: setSelectedNodes

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public final void setSelectedNodes (File[] selectedFiles) {
    Set<File> files = new HashSet<File>(Arrays.asList(selectedFiles));
    ListSelectionModel selection = table.getSelectionModel();
    selection.setValueIsAdjusting(true);
    selection.clearSelection();
    for (int i = 0; i < table.getRowCount(); ++i) {
        T node = tableModel.getNode(table.convertRowIndexToModel(i));
        if (files.contains(node.getFile())) {
            selection.addSelectionInterval(i, i);
        }
    }
    selection.setValueIsAdjusting(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:VCSStatusTable.java

示例3: selectRows

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
private void selectRows(int[] selectedRows, int delta) {
    ListSelectionModel listSelectionModel = mappingsTable.getSelectionModel();
    listSelectionModel.clearSelection();
    for (int selectedRow : selectedRows) {
        listSelectionModel.addSelectionInterval(selectedRow + delta, selectedRow + delta);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:OptionsPanel.java

示例4: setSelectedRows

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public void setSelectedRows(int[] rows, final boolean scrollToSel) {
    final ListSelectionModel model = getSelectionModel();
    int i = -1;
    for (int j : rows) {
        i = j;
        model.addSelectionInterval(i, i);
    }
    if (scrollToSel)
        scrollRowToVisible(i);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:11,代码来源:RowTreeTable.java

示例5: addFolders

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
private void addFolders( File files[] ) {
            int[] si = rootsList.getSelectedRows();
            int lastIndex = si == null || si.length == 0 ? -1 : si[si.length - 1];
            ListSelectionModel selectionModel = this.rootsList.getSelectionModel();
            selectionModel.clearSelection();
            Set<File> rootsFromOtherProjects = new HashSet<File>();
            Set<File> rootsFromRelatedSourceRoots = new HashSet<File>();
            String type = RootsAccessor.getInstance().getType(sourceRoots);
            boolean isModule = JavaProjectConstants.SOURCES_TYPE_MODULES.equals(type);
out:        for( int i = 0; i < files.length; i++ ) {
                File normalizedFile = FileUtil.normalizeFile(files[i]);
                Project p;
                if (ownedFolders.contains(normalizedFile)) {
                    Vector dataVector = rootsModel.getDataVector();
                    for (int j=0; j<dataVector.size();j++) {
                        //Sequential search in this minor case is faster than update of positions during each modification
                        File f = (File )((Vector)dataVector.elementAt(j)).elementAt(0);
                        if (f.equals(normalizedFile)) {
                            selectionModel.addSelectionInterval(j,j);
                        }
                    }
                }
                else if (this.relatedEditMediator != null && this.relatedEditMediator.ownedFolders.contains(normalizedFile)) {
                    rootsFromRelatedSourceRoots.add (normalizedFile);
                    continue;
                }
                if ((p=FileOwnerQuery.getOwner(Utilities.toURI(normalizedFile)))!=null && !p.getProjectDirectory().equals(project.getProjectDirectory())) {
                    final Sources sources = p.getLookup().lookup(Sources.class);
                    if (sources == null) {
                        rootsFromOtherProjects.add (normalizedFile);
                        continue;
                    }
                    final SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
                    final SourceGroup[] javaGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
                    final SourceGroup[] groups = new SourceGroup [sourceGroups.length + javaGroups.length];
                    System.arraycopy(sourceGroups,0,groups,0,sourceGroups.length);
                    System.arraycopy(javaGroups,0,groups,sourceGroups.length,javaGroups.length);
                    final FileObject projectDirectory = p.getProjectDirectory();
                    final FileObject fileObject = FileUtil.toFileObject(normalizedFile);
                    if (projectDirectory == null || fileObject == null) {
                        rootsFromOtherProjects.add (normalizedFile);
                        continue;
                    }
                    for (int j=0; j<groups.length; j++) {
                        final FileObject sgRoot = groups[j].getRootFolder();
                        if (fileObject.equals(sgRoot)) {
                            rootsFromOtherProjects.add (normalizedFile);
                            continue out;
                        }
                        if (!projectDirectory.equals(sgRoot) && FileUtil.isParentOf(sgRoot, fileObject)) {
                            rootsFromOtherProjects.add (normalizedFile);
                            continue out;
                        }
                    }
                }
                int current = lastIndex + 1 + i;
                rootsModel.insertRow( current, new Object[] {normalizedFile, isModule
                            ? ((ModuleRoots)sourceRoots).createInitialPath()
                            : sourceRoots.createInitialDisplayName(normalizedFile)});
                selectionModel.addSelectionInterval(current,current);
                this.ownedFolders.add (normalizedFile);
            }
            if (rootsFromOtherProjects.size() > 0 || rootsFromRelatedSourceRoots.size() > 0) {
                rootsFromOtherProjects.addAll(rootsFromRelatedSourceRoots);
                showIllegalRootsDialog (rootsFromOtherProjects);
            }
            // fireActionPerformed();
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:69,代码来源:SourceRootsUi.java


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