Esempio n. 1
0
  @Override
  public void createPartControl(Composite parent) {
    swtDisplay = parent.getDisplay();

    clipboard = new Clipboard(parent.getDisplay());

    tableViewer =
        new TableViewer(
            parent, SWT.H_SCROLL | SWT.VIRTUAL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new ErrorViewTreeContentProvider());
    tableViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            openSelectedMarker();
          }
        });
    tableViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
              updateStatusLine((IStructuredSelection) selection);
            }
          }
        });

    // Create actions; must be done after the construction of the tableViewer
    goToMarkerAction = new GoToMarkerAction();
    copyAction = new CopyMarkerAction();

    tableViewer.addSelectionChangedListener(copyAction);
    tableViewer.addSelectionChangedListener(goToMarkerAction);

    tableSorter = new TableSorter();
    tableSorter.setColumn(1);
    tableViewer.setComparator(tableSorter);
    tableViewer.getTable().setSortDirection(SWT.UP);

    Table table = tableViewer.getTable();

    TableViewerColumn descriptionColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
    descriptionColumn.setLabelProvider(new DescriptionLabelProvider());
    descriptionColumn.getColumn().setText("Description");
    descriptionColumn.getColumn().setWidth(520);
    descriptionColumn.getColumn().setResizable(true);
    enableSorting(descriptionColumn.getColumn(), 0);

    TableViewerColumn fileNameColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
    fileNameColumn.setLabelProvider(new FileNameLabelProvider());
    fileNameColumn.getColumn().setText("Location");
    fileNameColumn.getColumn().setWidth(220);
    fileNameColumn.getColumn().setResizable(true);
    enableSorting(fileNameColumn.getColumn(), 1);

    tableViewer.getTable().setSortColumn(fileNameColumn.getColumn());

    //    TableViewerColumn typeColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
    //    typeColumn.setLabelProvider(new TypeLabelProvider());
    //    typeColumn.getColumn().setText("Type");
    //    typeColumn.getColumn().setWidth(130);
    //    typeColumn.getColumn().setResizable(true);
    //    enableSorting(typeColumn.getColumn(), 2);

    restoreColumnWidths();

    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    //    table.setFont(parent.getFont());
    updateTableFont();

    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    table.layout(true);

    getSite().setSelectionProvider(tableViewer);

    IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();

    fillInToolbar(toolbar);
    registerContextMenu();

    tableFilter = new ErrorViewerFilter();

    updateFilters();

    startUpdateJob(swtDisplay);

    MarkersChangeService.getService().addListener(this);

    focusOnActiveEditor();
  }