예제 #1
0
 private TableColumn createTableColumn(ColumnType type, int width) {
   TableColumn tc = new TableColumn(commonTable.getTable(), SWT.LEFT);
   tc.setText(EventTableUIElementsConstants.getColumnText(type));
   tc.setWidth(width);
   tc.setMoveable(true);
   tc.addListener(SWT.Selection, sortListener);
   tc.setData(type);
   return tc;
 }
예제 #2
0
 /** Packs all columns */
 public void packAllColumns() {
   TableColumn[] columns = commonTable.getTable().getColumns();
   for (int i = 0; i < columns.length; i++) {
     columns[i].pack();
   }
 }
예제 #3
0
 /** @return */
 public Table getEventTable() {
   return commonTable.getTable();
 }
예제 #4
0
 private void hideInitialColumns() {
   commonTable.hideColumn(EventTableUIElementsConstants.getColumnText(ColumnType.TAGS));
   commonTable.hideColumn(EventTableUIElementsConstants.getColumnText(ColumnType.TRANSACTION));
 }
예제 #5
0
  /**
   * @param parent
   * @param style
   */
  private void createTable(Composite parent, int style) {
    commonTable = new CommonTable(parent, style | SWT.VIRTUAL);
    tableViewer = new TableViewer(commonTable.getTable());
    tableViewer
        .getTable()
        .getVerticalBar()
        .addSelectionListener(
            new SelectionListener() {

              public void widgetSelected(SelectionEvent e) {
                ScrollBar scrollBar = tableViewer.getTable().getVerticalBar();

                int minimum = scrollBar.getMinimum();
                int selection = scrollBar.getSelection();
                contentProvider.setRevealLatestElement(selection == minimum);
              }

              public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
              }
            });
    tableViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            try {
              IStructuredSelection selection = (IStructuredSelection) event.getSelection();
              eventDetailHandler.execute(selection.getFirstElement());
            } catch (ExecutionException e) {
              e.printStackTrace();
            }
          }
        });

    site.setSelectionProvider(tableViewer);

    Map<Color, List<Event>> rowBackGroundColorConfiguration = new HashMap<Color, List<Event>>();

    List<Event> eventsFatal = new LinkedList<Event>();
    eventsFatal.add(EventBuilder.template().setLevel(Event.FATAL).done());
    rowBackGroundColorConfiguration.put(new Color(parent.getDisplay(), 205, 0, 0), eventsFatal);

    List<Event> eventsError = new LinkedList<Event>();
    eventsError.add(EventBuilder.template().setLevel(Event.ERROR).done());
    rowBackGroundColorConfiguration.put(new Color(parent.getDisplay(), 255, 116, 76), eventsError);

    List<Event> eventsWarning = new LinkedList<Event>();
    eventsWarning.add(EventBuilder.template().setLevel(Event.WARNING).done());
    rowBackGroundColorConfiguration.put(new Color(parent.getDisplay(), 255, 255, 0), eventsWarning);

    contentProvider =
        new EventTableContentLabelProvider(
            lighthouseDomain, rowBackGroundColorConfiguration, parent.getDisplay());

    ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);

    tableViewer.setContentProvider(contentProvider);
    tableViewer.setLabelProvider(contentProvider);

    if (EventTableContentLabelProvider.isLegacyWindows)
      commonTable.getTable().setLinesVisible(true);
    commonTable.getTable().setHeaderVisible(true);

    commonTable
        .getTable()
        .addMouseListener(
            new MouseAdapter() {

              @Override
              public void mouseDown(MouseEvent e) {
                if (e.button == 3) {
                  lastMousePosition = new Point(e.x, e.y);
                }
              }
            });

    createColumns();
    createMenu();
    hideInitialColumns();
    commonTable.setTableMenu(tableMenu);
    tableViewer.setInput(events);
    contentProvider.setSortColumn(
        (ColumnType) tableViewer.getTable().getSortColumn().getData(),
        tableViewer.getTable().getSortDirection());
  }