當前位置: 首頁>>代碼示例>>Java>>正文


Java JXTable.getSearchable方法代碼示例

本文整理匯總了Java中org.jdesktop.swingx.JXTable.getSearchable方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.getSearchable方法的具體用法?Java JXTable.getSearchable怎麽用?Java JXTable.getSearchable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdesktop.swingx.JXTable的用法示例。


在下文中一共展示了JXTable.getSearchable方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testTableMovedColumn

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/** 
 * test that the search predicate's highlight column index is in 
 * model coordinates
 *
 */
@Test
public void testTableMovedColumn() {
    JXTable table = new JXTable(new TestTableModel());
    table.putClientProperty(AbstractSearchable.MATCH_HIGHLIGHTER, Boolean.TRUE);
    
    // move first column to end
    int firstColumn = table.getColumnCount() - 1;
    table.getColumnModel().moveColumn(0, firstColumn);
    int row = 39;
    String firstSearchText = table.getValueAt(row, firstColumn).toString();
    PatternModel model = new PatternModel();
    model.setRawText(firstSearchText);
    // initialize searchable to "found state"
    table.getSearchable().search(model.getPattern(), -1);
    // column index in view coordinates
    int foundColumn = ((AbstractSearchable) table.getSearchable()).lastSearchResult.foundColumn;
    assertEquals("column must be updated", firstColumn, foundColumn);
    AbstractHighlighter hl = ((AbstractSearchable) table.getSearchable()).getMatchHighlighter();
    assertTrue("searchPredicate", hl.getHighlightPredicate() instanceof SearchPredicate);
    SearchPredicate predicate = (SearchPredicate) hl.getHighlightPredicate();
    assertEquals(table.convertColumnIndexToModel(firstColumn), predicate.getHighlightColumn());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:28,代碼來源:SearchableTest.java

示例2: testTableResetStateWithNullSearchString

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/** 
 * test if internal state is reset to not found by
 * passing a null searchstring.
 *
 */
@Test
public void testTableResetStateWithNullSearchString() {
    JXTable table = new JXTable(new TestTableModel());
    int row = 39;
    int firstColumn = 0;
    String firstSearchText = table.getValueAt(row, firstColumn).toString();
    PatternModel model = new PatternModel();
    model.setRawText(firstSearchText);
    // initialize searchable to "found state"
    int foundIndex = table.getSearchable().search(model.getPattern(), -1);
    // sanity asserts
    int foundColumn = ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn;
    assertEquals("last line found", row, foundIndex);
    assertEquals("column must be updated", firstColumn, foundColumn);
    // search with null searchstring 
    int notFoundIndex =  table.getSearchable().search((String) null);
    assertEquals("nothing found", -1, notFoundIndex);
    assertEquals("column must be reset", -1, ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn);

}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:26,代碼來源:FindTest.java

示例3: testTableResetStateWithEmptySearchString

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/** 
 * test if internal state is reset to not found by
 * passing a empty (="") searchstring.
 *
 */
@Test
public void testTableResetStateWithEmptySearchString() {
    JXTable table = new JXTable(new TestTableModel());
    int row = 39;
    int firstColumn = 0;
    String firstSearchText = table.getValueAt(row, firstColumn).toString();
    PatternModel model = new PatternModel();
    model.setRawText(firstSearchText);
    // initialize searchable to "found state"
    int foundIndex = table.getSearchable().search(model.getPattern(), -1);
    // sanity asserts
    int foundColumn = ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn;
    assertEquals("last line found", row, foundIndex);
    assertEquals("column must be updated", firstColumn, foundColumn);
    // search with null searchstring 
    int notFoundIndex =  table.getSearchable().search("");
    assertEquals("nothing found", -1, notFoundIndex);
    assertEquals("column must be reset", -1, ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn);

}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:26,代碼來源:FindTest.java

示例4: testTableFoundPreviousColumnInNextRow

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * test if search loops all columns of next row.
 *
 * Hmm... not testable? 
 * Needed to widen access for lastFoundColumn.
 */
@Test
public void testTableFoundPreviousColumnInNextRow() {
    JXTable table = new JXTable(new TestTableModel());
    int row = 0;
    int firstColumn = 1;
    String firstSearchText = table.getValueAt(row, firstColumn).toString();
    int foundIndex = table.getSearchable().search(firstSearchText);
    assertEquals("last line found", row, foundIndex);
    int foundColumn = ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn;
    assertEquals("column must be updated", firstColumn, foundColumn);
    // the last char(s) of all values is the row index
    // here we are searching for an entry in the next row relative to
    // the previous search and expect the match in the first column (index = 0);
    int nextRow = row + 1;
    String secondSearchText = String.valueOf(nextRow);
    int secondFoundIndex = table.getSearchable().search(secondSearchText, nextRow);
    // sanity assert
    assertEquals("must find match in same row", nextRow, secondFoundIndex);
    assertEquals("column must be updated", 0, ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn);
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:28,代碼來源:FindTest.java

示例5: testTargetTable

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Task: new api in AbstractSearchable to support match highlighter.
 */
@Test
public void testTargetTable() {
    JXTable table = new JXTable();
    AbstractSearchable searchable = (AbstractSearchable) table.getSearchable();
    assertSame("get target same as table", table, searchable.getTarget());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:10,代碼來源:SearchableTest.java

示例6: testTableFoundNextColumnInPreviousRow

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * test if search loops all columns of previous row (backwards search).
 * 
 * Hmm... not testable? 
 * Needed to widen access for lastFoundColumn.
 */
@Test
public void testTableFoundNextColumnInPreviousRow() {
    JXTable table = new JXTable(new TestTableModel());
    int lastColumn = table.getColumnCount() -1;
    int row = 39;
    int firstColumn = lastColumn - 1;
    String firstSearchText = table.getValueAt(row, firstColumn).toString();
    // need a pattern for backwards search
    PatternModel model = new PatternModel();
    model.setRawText(firstSearchText);
    int foundIndex = table.getSearchable().search(model.getPattern(), -1, true);
    assertEquals("last line found", row, foundIndex);
    int foundColumn = ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn;
    assertEquals("column must be updated", firstColumn, foundColumn);
    // the last char(s) of all values is the row index
    // here we are searching for an entry in the next row relative to
    // the previous search and expect the match in the first column (index = 0);
    int previousRow = row -1;
    String secondSearchText = String.valueOf(previousRow);
    model.setRawText(secondSearchText);
    int secondFoundIndex = table.getSearchable().search(model.getPattern(), previousRow, true);
    // sanity assert
    assertEquals("must find match in same row", previousRow, secondFoundIndex);
    assertEquals("column must be updated", lastColumn, ((TableSearchable) table.getSearchable()).lastSearchResult.foundColumn);
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:33,代碼來源:FindTest.java


注:本文中的org.jdesktop.swingx.JXTable.getSearchable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。