跳转到SWT表光标的特定单元格不起作用

时间:2016-06-22 07:32:17

标签: eclipse-rcp

我的Eclipse RCP产品中有3个模块,其中我使用了表光标:

模块:

  1. Analytical Part_1(RCP编辑)
  2. 分析Part_2(RCP编辑器)
  3. 错误(RCP视图)
  4. 说明

    “Analytical Part_1”& “分析Part_2”应有一些错误记录。错误已经在错误模块中定义,点击它,我的选择&游标应该跳转到前两个模块中的错误源。错误视图将始终打开。可以从菜单中打开前两个模块。

    问题:

    当它跳转到错误源时,

    1)当产品打开并且没有打开模块并点击错误时,它将跳转到源。 2)当我打开模块并单击错误时,它将跳转到源。

    但是当我遇到与第一个模块相关的错误并且当我在第二个模块中并且单击错误跳转然后模块打开但是光标总是跳到第一行时,它将不起作用。列位置很好但行设置为第一个rowIndex。

    当上述两种情况发生时,情况低于代码工作的其他方式。我调试代码,我得到了确切的RowID& ColumnID的。

    跳转到错误来源的代码:

    if (Module_ID.equalsIgnoreCase("Analytic_PART_1"))
    {
    
        Command command = ((ICommandService) getSite().getService(ICommandService.class)).getCommand(Analytic_PART_1_Handler.ID);
    
        final Event trigger = new Event();
    
        ExecutionEvent executionEvent = ((IHandlerService) getSite().getService(IHandlerService.class)).createExecutionEvent(command, trigger);
    
        command.executeWithChecks(executionEvent);
    
        IEditorPart editorPart = page.getActiveEditor();
        Analytic_PART_1 myEditorPart = (Analytic_PART_1)editorPart;
        Table fit_table = myEditorPart.table;
    
        TableItem[] tableitemss = fit_table.getItems();
        for(TableItem items : tableitemss)
        {
           if(items.getText(1).equals(rowID))
           {
              int indexcolumn = 0;
              String[] columnName = myEditorPart.colNames;
              for(int i=0;i<columnName.length;i++)
              {
                 if(columnName[i].equals(Column_Name))
                 {
                   indexcolumn = i;
                 }
              }
    
              myEditorPart.tableCursor.setSelection(items, indexcolumn);
              myEditorPart.setFocus();
              break;
           }
        }
    }
    

0 个答案:

没有答案