public LogEntryTable(Composite parent, int style) {
    super(parent, style);
    setLayout(new GridLayout(1, false));

    addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent event) {
            switch (event.getPropertyName()) {
              case "logEntries":
                gridTableViewer.setSelection(null, true);
                gridTableViewer.setInput(logEntries.toArray(new LogEntry[logEntries.size()]));
                break;
              case "expanded":
                // TODO shroffk fix the refresh
                gridTableViewer.getGrid().setAutoHeight(expanded);
                gridTableViewer.setInput(logEntries.toArray(new LogEntry[logEntries.size()]));
                break;
              default:
                break;
            }
          }
        });

    errorBar = new ErrorBar(this, SWT.NONE);
    errorBar.setMarginBottom(5);

    gridTableViewer =
        new GridTableViewer(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.DOUBLE_BUFFERED);
    selectionProvider =
        new AbstractSelectionProviderWrapper(gridTableViewer, this) {

          @Override
          protected ISelection transform(IStructuredSelection selection) {
            return selection;
          }
        };

    grid = gridTableViewer.getGrid();
    grid.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    grid.setAutoHeight(true);
    grid.setRowsResizeable(true);
    grid.setHeaderVisible(true);
    gridTableViewer.getGrid().setLinesVisible(true);
    gridTableViewer.setContentProvider(
        new IStructuredContentProvider() {

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          @Override
          public void dispose() {}

          @Override
          public Object[] getElements(Object inputElement) {
            return (Object[]) inputElement;
          }
        });

    ColumnViewerToolTipSupport.enableFor(gridTableViewer, ToolTip.NO_RECREATE);

    // First Columns displays the Date
    GridViewerColumn column = new GridViewerColumn(gridTableViewer, SWT.NONE);
    GridColumn gridColumn = column.getColumn();
    gridColumn.setMoveable(true);
    column.setLabelProvider(
        new CellLabelProvider() {

          @Override
          public void update(ViewerCell cell) {
            LogEntry item = ((LogEntry) cell.getElement());
            String date =
                item == null || item.getCreateDate() == null
                    ? "No Data"
                    : DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                        .format(item.getCreateDate());
            cell.setText(date);
          }
        });
    column.getColumn().setText("Date");
    column.getColumn().setWordWrap(true);
    new TableColumnViewerLayout(gridTableViewer, column, 15, 100);
    new ColumnViewerSorter(gridTableViewer, column) {
      @Override
      protected int doCompare(Viewer viewer, Object e1, Object e2) {
        return Long.compare(
            ((LogEntry) e1).getCreateDate().getTime(), ((LogEntry) e2).getCreateDate().getTime());
      }
    };

    // Second column is the first line of the logEntry

    GridViewerColumn gridViewerColumnDescription =
        new GridViewerColumn(gridTableViewer, SWT.DOUBLE_BUFFERED);
    gridViewerColumnDescription.setLabelProvider(
        new ColumnLabelProvider() {

          public String getText(Object element) {
            LogEntry item = ((LogEntry) element);
            return item == null ? "" : item.getText();
          }
        });
    GridColumn tblclmnDescription = gridViewerColumnDescription.getColumn();
    tblclmnDescription.setWordWrap(true);
    tblclmnDescription.setText("Description");
    new TableColumnViewerLayout(gridTableViewer, gridViewerColumnDescription, 50, 250);

    // Third column is the owner of the logEntry

    GridViewerColumn gridViewerColumnOwner =
        new GridViewerColumn(gridTableViewer, SWT.MULTI | SWT.WRAP | SWT.DOUBLE_BUFFERED);
    gridViewerColumnOwner.setLabelProvider(
        new ColumnLabelProvider() {
          public String getText(Object element) {
            LogEntry item = ((LogEntry) element);
            return item == null ? "" : item.getOwner();
          }
        });

    // gridViewerColumnOwner.getColumn().setSort(SWT.UP);
    GridColumn tblclmnOwner = gridViewerColumnOwner.getColumn();
    tblclmnOwner.setText("Owner");
    new TableColumnViewerLayout(gridTableViewer, gridViewerColumnOwner, 10, 75);
    new ColumnViewerSorter(gridTableViewer, gridViewerColumnOwner) {
      @Override
      protected int doCompare(Viewer viewer, Object e1, Object e2) {
        return ((LogEntry) e1).getOwner().compareTo(((LogEntry) e2).getOwner());
      }
    };

    // Forth column lists the logbooks
    GridViewerColumn gridViewerColumnLogbooks =
        new GridViewerColumn(gridTableViewer, SWT.MULTI | SWT.DOUBLE_BUFFERED);
    gridViewerColumnLogbooks.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            LogEntry item = ((LogEntry) element);
            StringBuilder logbooks = new StringBuilder();
            for (Logbook logbook : item.getLogbooks()) {
              logbooks.append(logbook.getName() + eol);
            }
            return item == null ? "" : logbooks.toString();
          }
        });
    GridColumn tblclmnLogbooks = gridViewerColumnLogbooks.getColumn();
    tblclmnLogbooks.setWordWrap(false);
    tblclmnLogbooks.setText("Logbooks");
    new TableColumnViewerLayout(gridTableViewer, gridViewerColumnLogbooks, 10, 75);

    // column lists the tags
    GridViewerColumn gridViewerColumnTags =
        new GridViewerColumn(gridTableViewer, SWT.DOUBLE_BUFFERED);
    gridViewerColumnTags.setLabelProvider(
        new ColumnLabelProvider() {

          public String getText(Object element) {
            LogEntry item = ((LogEntry) element);
            StringBuilder tags = new StringBuilder();
            for (Tag tag : item.getTags()) {
              tags.append(tag.getName() + eol);
            }
            return item == null ? "" : tags.toString();
          }
        });
    GridColumn tblclmnTags = gridViewerColumnTags.getColumn();
    tblclmnTags.setWordWrap(false);
    tblclmnTags.setText("Tags");
    new TableColumnViewerLayout(gridTableViewer, gridViewerColumnTags, 10, 75);

    // Attachments
    GridViewerColumn gridViewerColumnAttachments =
        new GridViewerColumn(gridTableViewer, SWT.DOUBLE_BUFFERED);
    gridViewerColumnAttachments.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            LogEntry item = ((LogEntry) element);
            return String.valueOf(item.getAttachment().size());
          }
        });
    GridColumn tblclmnAttachment = gridViewerColumnAttachments.getColumn();
    tblclmnAttachment.setText("Attachments");
    new TableColumnViewerLayout(gridTableViewer, gridViewerColumnAttachments, 5, 30);

    new ColumnViewerSorter(gridTableViewer, gridViewerColumnAttachments) {
      @Override
      protected int doCompare(Viewer viewer, Object e1, Object e2) {
        return Integer.compare(
            ((LogEntry) e1).getAttachment().size(), ((LogEntry) e2).getAttachment().size());
      }
    };
    gridTableViewer.refresh();
  }
  private void initGird(Composite compContents) {
    gridViewer = new GridTableViewer(compContents, SWT.V_SCROLL | SWT.BORDER);
    gridViewer.setLabelProvider(new ListGridLabelProvider());
    gridViewer.setContentProvider(new ListGridContentProvider());
    gridViewer.getGrid().setSelectionEnabled(true);
    gridViewer.getGrid().setFont(SWTResourceManager.getFont("Arial", 16, SWT.NORMAL));
    gridViewer.getGrid().setItemHeight(28);
    gridViewer.getGrid().addFocusListener(new HelpAdapter("계류차량 선택 후 더블클릭 또는 [2차 계량] 버튼 클릭."));

    gridViewer.setCellEditors(
        new CellEditor[] {
          new TextCellEditor(gridViewer.getGrid()), new TextCellEditor(gridViewer.getGrid())
        });
    gridViewer.setCellModifier(
        new ICellModifier() {

          public boolean canModify(Object element, String property) {
            return false;
          }

          public Object getValue(Object element, String property) {
            return element.toString();
          }

          public void modify(Object element, String property, Object value) {}
        });
    gridViewer.setColumnProperties(colProp);
    ColumnViewerEditorActivationStrategy actSupport =
        new ColumnViewerEditorActivationStrategy(gridViewer) {
          protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                    && event.keyCode == SWT.CR);
          }
        };
    GridViewerEditor.create(
        gridViewer,
        actSupport,
        ColumnViewerEditor.TABBING_HORIZONTAL
            | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
            | ColumnViewerEditor.TABBING_VERTICAL
            | ColumnViewerEditor.KEYBOARD_ACTIVATION);

    GridColumnGroup cgSpot = new GridColumnGroup(gridViewer.getGrid(), SWT.CENTER);
    cgSpot.setText("        1차 계량");

    for (int i = 0; i < colName.length; i++) {
      GridColumn column = null;
      if (i == 3 || i == 4) {
        column = new GridColumn(cgSpot, SWT.NONE);
      } else {
        column = new GridColumn(gridViewer.getGrid(), SWT.NONE);
      }
      column.setWidth(colWidth[i]);
      column.setAlignment(colAlign[i]);
      column.setText(colName[i]);
      column.setResizeable(true);
    }

    gridViewer.getGrid().setLinesVisible(true);
    gridViewer.getGrid().setHeaderVisible(true);
    gridViewer
        .getGrid()
        .addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseDoubleClick(MouseEvent evt) {
                Grid g = (Grid) evt.getSource();
                if (listData != null
                    && listData.length > g.getSelectionIndex()
                    && g.getSelectionIndex() != -1) {
                  TsWgtInfDTO vo = listData[g.getSelectionIndex()];
                  WeighSecondDialog dialog =
                      new WeighSecondDialog(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
                  shell.close();

                  Object answer = dialog.open(vo);
                  if (answer != null) {
                    HomeView hv =
                        (HomeView)
                            PlatformUI.getWorkbench()
                                .getActiveWorkbenchWindow()
                                .getActivePage()
                                .findView(HomeView.ID);
                    hv.refreshData();
                  }
                }
              }
            });
    Grid grid = gridViewer.getGrid();
    grid.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(ControlEvent e) {
            int width = 0;
            for (int i = 0; i < gridViewer.getGrid().getColumnCount(); i++) {
              width = (int) (colWidth[i] * gridViewer.getGrid().getClientArea().width / 100);
              if (i == gridViewer.getGrid().getColumnCount() - 1) {
                width += 5;
              }
              gridViewer.getGrid().getColumn(i).setWidth(width);
            }
            int add = gridViewer.getGrid().getBounds().width / 100 - 0;
            gridViewer
                .getGrid()
                .setFont(SWTResourceManager.getFont("Arial", 12 + (add > 0 ? add : 0), SWT.NORMAL));
          }
        });
    grid.setRowsResizeable(true);

    grid.setLineColor(ColorRepository.getColor(ColorRepository.GRID_LINE));
    // grid.setBackgroundMode(SWT.INHERIT_FORCE);
    GridData gridViewerLData = new GridData();
    gridViewerLData.grabExcessHorizontalSpace = true;
    gridViewerLData.horizontalAlignment = GridData.FILL;
    gridViewerLData.grabExcessVerticalSpace = true;
    gridViewerLData.verticalAlignment = GridData.FILL;
    gridViewerLData.verticalIndent = 5;
    gridViewer.getGrid().setLayoutData(gridViewerLData);
  } // initGird