Java 类javax.swing.tree.RowMapper 实例源码

项目:incubator-netbeans    文件:DebugTreeView.java   
private static void clearSelectionCache(RowMapper rm) {
    if (rm instanceof FixedHeightLayoutCache) {
        try {
            Field infoField = rm.getClass().getDeclaredField("info");
            infoField.setAccessible(true);
            Object searchInfo = infoField.get(rm);
            if (searchInfo != null) {
                Field nodeField = searchInfo.getClass().getDeclaredField("node");
                nodeField.setAccessible(true);
                nodeField.set(searchInfo, null);
            }
        } catch (Exception ex) {}
    }
}
项目:taxonaut    文件:SynchronizedListSelectionModel.java   
public SynchronizedListSelectionModel(RowMapper mapper,
                  TreeSelectionModel treeSelectionModel)
   {
super();
setRowMapper(mapper);
setTreeSelectionModel(treeSelectionModel);
   }
项目:jlubricant    文件:DatasourceTemplate.java   
/**
 * A {@link RowMapper} that returns the object contained in the first field.
 */
public <T> RowMapper<T> getSingleColumnRowMapper(Class<T> requiredType){
    return new RowMapper<T>() {

        @Override
        public T map(ResultSet rs) throws SQLException {
            return (T) rs.getObject(1);
        }
    };
}
项目:jlubricant    文件:DatasourceTemplate.java   
/**
 * Return a list of objects obtained applying the given {@link RowMapper} to each record.
 * @return  A not null empty list when the result set is empty.
 * @throws SQLException
 */
public <T> List<T> query(String sql, RowMapper<T> rowMapper) throws SQLException{
    if (logger.isDebugEnabled()) {
        logger.debug("Executing SQL statement [" + sql + "]");
    }

    Connection connection = null;
    Statement stm = null;
    ResultSet rs = null;

    ArrayList<T> result = new ArrayList<T>();

    try{
        connection = ds.getConnection();
        stm = connection.createStatement();         
        rs = stm.executeQuery(sql);

        while(rs.next()){
            result.add( rowMapper.map(rs) );
        }

    } catch (SQLException e) {
        throw e;
    }finally{
        if(rs!=null) rs.close();
        if(stm!=null) stm.close();
        if(connection!=null) connection.close();            
    }

    return result;
}
项目:incubator-netbeans    文件:TreeView.java   
/** Check if selection of the nodes could break the selection mode set in TreeSelectionModel.
 * @param nodes the nodes for selection
 * @return true if the selection mode is broken */
private boolean isSelectionModeBroken(Node[] nodes) {
    // if nodes are empty or single the everthing is ok
    // or if discontiguous selection then everthing ok
    if ((nodes.length <= 1) || (getSelectionMode() == TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)) {
        return false;
    }

    // if many nodes
    // brakes single selection mode
    if (getSelectionMode() == TreeSelectionModel.SINGLE_TREE_SELECTION) {
        return true;
    }

    // check the contiguous selection mode
    TreePath[] paths = new TreePath[nodes.length];
    RowMapper rowMapper = tree.getSelectionModel().getRowMapper();

    // if rowMapper is null then tree bahaves as discontiguous selection mode is set
    if (rowMapper == null) {
        return false;
    }

    ArrayList<Node> toBeExpaned = new ArrayList<Node>(3);

    for (int i = 0; i < nodes.length; i++) {
        toBeExpaned.clear();

        Node n = nodes[i];

        while (n.getParentNode() != null) {
            if (!isExpanded(n)) {
                toBeExpaned.add(n);
            }

            n = n.getParentNode();
        }

        for (int j = toBeExpaned.size() - 1; j >= 0; j--) {
            expandNode(toBeExpaned.get(j));
        }
        paths[i] = getTreePath(nodes[i]);
    }

    int[] rows = rowMapper.getRowsForPaths(paths);

    // check selection's rows
    Arrays.sort(rows);

    for (int i = 1; i < rows.length; i++) {
        if (rows[i] != (rows[i - 1] + 1)) {
            return true;
        }
    }

    // all is ok
    return false;
}
项目:taxonaut    文件:SynchronizedListSelectionModel.java   
public SynchronizedListSelectionModel(RowMapper mapper)
   {
this(mapper, null);
   }
项目:taxonaut    文件:SynchronizedListSelectionModel.java   
public RowMapper getRowMapper()
   {
return rowMapper;
   }
项目:taxonaut    文件:SynchronizedListSelectionModel.java   
public synchronized void setRowMapper(RowMapper mapper)
   {
rowMapper = mapper;
   }
项目:taxonaut    文件:NameTreeTable.java   
protected void initializeLocalVars()
   {
super.initializeLocalVars();
Enumeration<TableColumn> e = getColumnModel().getColumns();
while(e.hasMoreElements()) {
    TableColumn column = e.nextElement();
    setHeaderRenderer(column);
}
//setHeaderRenderer(getHeaderColumn());

AlignerTree alignerTree = getAlignerTree();
if(alignerTree != null) {
    List<NameTree> trees= getAlignableTrees();
    Aligner aligner = alignerTree.getAligner();
    for (NameTree tree : trees) {
    alignerTree.addTree(tree);
    tree.setAligner(aligner);
    }
    // or...
    //setAlignerTree(alignerTree);
    alignerTree.addTreeSelectionListener(this);
}

/*
setAligner(aligner);
TableModel rowMapper = getModel();
if(rowMapper != null &&
   rowMapper instanceof RowMapper) {
    SynchronizedListSelectionModel selector = 
    (SynchronizedListSelectionModel)getSelectionModel();
    selector.setRowMapper((RowMapper)rowMapper);
    selector.setTree(aligner);
    selector.addListSelectionListener(this);
}
setSelectAndScroll(true);
*/

/*
Aligner aligner = ((AlignerTree)((TreeHeaderRenderer)a.getHeaderRenderer()).getTree()).getAligner();
*/

TableModel rowMapper = getModel();
if(rowMapper != null &&
   rowMapper instanceof RowMapper) {
    SynchronizedListSelectionModel selector = 
    (SynchronizedListSelectionModel)getSelectionModel();
    selector.setRowMapper((RowMapper)rowMapper);
    selector.setTree(alignerTree);
    selector.setTable(this);
    SynchronizedTreeSelectionModel treeSelector =
    (SynchronizedTreeSelectionModel)alignerTree.getSelectionModel();
    treeSelector.addTreeSelectionListener(selector);
    treeSelector.setTable(this);
    selector.setTreeSelectionModel(treeSelector);
}
setSelectAndScroll(true);

preferredHeight = -1;

   }
项目:youscope    文件:MeasurementTree.java   
@Override
public RowMapper getRowMapper() {
    return rowMapper;
}
项目:youscope    文件:MeasurementTree.java   
@Override
public void setRowMapper(RowMapper newMapper) {
    rowMapper = newMapper;
}
项目:polydes    文件:DTreeSelectionModel.java   
@Override
public void setRowMapper(RowMapper newMapper)
{

}
项目:polydes    文件:DTreeSelectionModel.java   
@Override
public RowMapper getRowMapper()
{
    return null;
}
项目:NAMControllerCompiler    文件:MyCheckTreeSelectionModel.java   
@Override
public RowMapper getRowMapper() {
    throw new UnsupportedOperationException("Not implemented.");
}
项目:NAMControllerCompiler    文件:MyCheckTreeSelectionModel.java   
@Override
public void setRowMapper(RowMapper newMapper) {
    throw new UnsupportedOperationException("Not implemented.");
}
项目:jlubricant    文件:DatasourceTemplate.java   
/**
 * Execute a query that return a single result obtained allowing the current row to be mapped through
 * the provided {@link RowMapper}.
 * @throws SQLException
 */
public <T> T queryForObject(String sql, RowMapper<T> rowMapper) throws SQLException  {
    return (T) query(sql, rowMapper);
}