Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Table


    return table.indexOf(item);
  }
 
  private void copyToItem(TableItem newItem) {
    Table table = getTable();
    if (table == null || item == null)
      return;

//    newItem.setText(text_values);
    newItem.setImage(image_values);
    Color colorFG = item.getForeground();
    Color colorBG = item.getBackground();
    newItem.setForeground(colorFG);
    newItem.setBackground(colorBG);
    int numColumns = table.getColumnCount();
    for (int i = 0; i < numColumns; i++) {
      try {
        newItem.setText(i, item.getText(i));
        Color colorColumnFG = item.getForeground(i);
        Color colorColumnBG = item.getBackground(i);
        if (!colorColumnFG.equals(colorFG))
          newItem.setForeground(i, colorColumnFG);
        if (!colorColumnBG.equals(colorBG))
          newItem.setBackground(i, colorColumnBG);
      } catch (NoSuchMethodError e) {
        /* Ignore for Pre 3.0 SWT.. */
      }
    }
    if (isSelected())
      table.select(table.indexOf(newItem));
    else
      table.deselect(table.indexOf(newItem));

    newItem.setData("TableRow", item.getData("TableRow"));
  }
View Full Code Here


  public int getPosition() {
    return position;
  }

  public Image getBackgroundImage() {
    Table table = row.getTable();
   
    Rectangle bounds = getBounds();
   
    if (bounds.isEmpty()) {
      return null;
    }
   
    Image image = new Image(table.getDisplay(), bounds.width, bounds.height);
   
    GC gc = new GC(table);
    gc.copyArea(image, bounds.x, bounds.y);
    gc.dispose();
   
View Full Code Here

    });
    //cBlockView.moveAbove(null);

    cBlockView.addMouseListener(new MouseAdapter() {
        public void mouseDown(MouseEvent e) {
          Table table = getTable();
          Rectangle r = cBlockView.getBounds();
          TableItem[] item = { table.getItem(new Point(r.x, r.y)) };
          if (item[0] != null) {
            table.setSelection(item);
          }
          table.setFocus();
        }
        public void mouseUp(MouseEvent e) {
          getTable().setFocus();
        }
      }
View Full Code Here

      cBlockView.setLocation(bounds.x, bounds.y);
      canvasBounds = cBlockView.getBounds();
      //debugOut("doPaint(GC): move cBlockView to " + bounds.x + "x" + bounds.y, false);
    }

    Table table = getTable();
    Rectangle tableBounds = table.getClientArea();
    if (tableBounds.y < table.getHeaderHeight()) {
      tableBounds.y = table.getHeaderHeight();
    }
    Rectangle rNewCanvas = bounds.intersection(tableBounds);
    //debugOut("doPaint(gc) rNewCanvas="+rNewCanvas+";canvasBounds="+canvasBounds+";tableBounds="+tableBounds, false);
    if (rNewCanvas.width <= 0 || rNewCanvas.height <= 0) {
      return;
View Full Code Here

  public void doPaint(Rectangle clipping) {
    //debugOut("doPaint() clipping="+clipping, false);
    if (cBlockView == null || cBlockView.isDisposed())
      return;

    Table table = getTable();
    //Compute bounds ...
    Rectangle bounds = getBoundsForCanvas();
    //In case item isn't displayed bounds is null
    if (bounds == null || image == null || image.isDisposed()) {
      return;
    }
   
    Rectangle canvasBounds = cBlockView.getBounds();
    //debugOut("Block:"+canvasBounds+";cell:"+bounds,false);
    if (canvasBounds.x != bounds.x || canvasBounds.y != bounds.y) {
      //cBlockView.moveAbove(null);
      cBlockView.setLocation(bounds.x, bounds.y);
      canvasBounds = cBlockView.getBounds();
      //debugOut("doPaint(clipping): move cBlockView to " + bounds.x + "x" + bounds.y, false);
    }
    if (bounds.width != canvasBounds.width ||
        bounds.height != canvasBounds.height) {
      cBlockView.setSize(bounds.width, bounds.height);
      canvasBounds = cBlockView.getBounds();
    }
    //debugOut("doPaint()" + ((gc == null) ? "GC NULL" : String.valueOf(gc.getClipping())) +
    //         "ta="+table.getClientArea()+";bounds="+bounds, false);
   
    if (orientation == SWT.FILL) {
      Rectangle imageBounds = image.getBounds();
      if (imageBounds.width != bounds.width ||
          imageBounds.height != bounds.height) {
        // Enable this for semi-fast visual update with some flicker
        cBlockView.setSize(bounds.width, bounds.height);
        GC gc = new GC(cBlockView);
        if (gc == null) {
          return;
        }
        gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height,
                     0, 0, bounds.width, bounds.height);
        gc.dispose();
/*
        // _OR_ enable refresh() for slower visual update with lots of flicker
        //refresh();
       
        // OR, disable both and image will be updated on next graphic bar update
       
        // TODO: make config option to choose
*/
        invalidate();
        return;
      }
    }
   
    if (clipping == null) {
      clipping = new Rectangle(0, 0, bounds.width, bounds.height);
    }
    Rectangle tableBounds = table.getClientArea();
    if (tableBounds.y < table.getHeaderHeight()) {
      tableBounds.y = table.getHeaderHeight();
    }
    //debugOut("doPaint() tableBounds="+tableBounds+";canvasBounds="+canvasBounds+";clipping="+clipping, false);
    tableBounds.x -= canvasBounds.x;
    tableBounds.y -= canvasBounds.y;
    clipping = clipping.intersection(tableBounds);
View Full Code Here

    Label label = new Label(shell,SWT.NULL);
    label.setText(Localizer._("columneditorwindow.draghint"));
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    label.setLayoutData(gridData);
   
    table = new Table (shell, SWT.VIRTUAL | SWT.CHECK | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    gridData = new GridData(GridData.FILL_BOTH);
    table.setLayoutData(gridData);
    table.setHeaderVisible(true);
   
    Composite cButtonArea = new Composite(shell, SWT.NULL);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    cButtonArea.setLayoutData(gridData);
    RowLayout rLayout = new RowLayout(SWT.HORIZONTAL);
    rLayout.marginLeft = 0;
   rLayout.marginTop = 0;
   rLayout.marginRight = 0;
   rLayout.marginBottom = 0;
   rLayout.spacing = 5;
   cButtonArea.setLayout (rLayout);
   
    Button bOk = new Button(cButtonArea,SWT.PUSH);
    bOk.setFont(skin.getButtonFont());
    bOk.setImage(skin.getButtonImage(SkinConstants.FINISH_BUTTON_IMAGE));
    bOk.setText(Localizer._("mainwindow.button.ok"));
    rd = new RowData();
    rd.width = 70;
    bOk.setLayoutData(rd);
    bOk.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event e) {
        saveAndApply();
        close();
      }
    });
   
    Button bCancel = new Button(cButtonArea,SWT.PUSH);
    bCancel.setFont(skin.getButtonFont());
    bCancel.setImage(skin.getButtonImage(SkinConstants.CANCEL_BUTTON_IMAGE));
    bCancel.setText(Localizer._("mainwindow.button.cancel"));
    rd = new RowData();
    rd.width = 70;
    bCancel.setLayoutData(rd);
    bCancel.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event e) {
        close();
      }
    });
   
    Button bApply = new Button(cButtonArea,SWT.PUSH);
    bApply.setFont(skin.getButtonFont());
    bApply.setImage(skin.getButtonImage(SkinConstants.OK_BUTTON_IMAGE));
    bApply.setText(Localizer._("mainwindo.button.apply"));
    rd = new RowData();
    rd.width = 70;
    bApply.setLayoutData(rd);
    bApply.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event e) {
        saveAndApply();
      }
    });
   
   
    TableColumn column;
    column = new TableColumn(table, SWT.NONE);
    column.setText(Localizer._("columneditorwindow.column.column_name"));
    column = new TableColumn(table, SWT.NONE);
    column.setText(Localizer._("columneditorwindow.column.description"));
    table.getColumn(0).setWidth(160);
    table.getColumn(1).setWidth(1000);

    table.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event e) {
        if (e.detail != SWT.CHECK)
          return;
        mousePressed = false;
    TableItem item = (TableItem) e.item;
    int index = item.getParent().indexOf(item);
    TableColumn tableColumn = tableColumns.get(index);
    newEnabledState.put(tableColumn, new Boolean(item.getChecked()));
      }
    });
   
    table.addListener(SWT.SetData, new Listener() {
      public void handleEvent(Event event) {
        final TableItem item = (TableItem) event.item;
        if (item == null)
          return;
        Table table = item.getParent();
        int index = table.indexOf(item);
        if (index < 0) {
          // Trigger a Table._getItem, which assigns the item to the array
          // in Table, so indexOf(..) can find it.  This is a workaround for
          // a WinXP bug.
          Rectangle r = item.getBounds(0);
          table.getItem(new Point(r.x, r.y));
          index = table.indexOf(item);
          if (index < 0)
            return;
        }
       
      if (index % 2 == 0)
        item.setBackground(ROW_ALTERNATE_COLOR_2);
      else
        item.setBackground(ROW_ALTERNATE_COLOR_1);
       
      TableColumn tableColumn = tableColumns.get(index);
        //String sTitleLanguageKey = tableColumn.getTitleLanguageKey();
        item.setText(0, tableColumn.getText());
        item.setText(1, (String)tableColumn.getData(SWTConstants.COLUMN_DESC_KEY));
       
        //Causes SetData listener to be triggered again, which messes up SWT
          //table.getColumn(1).pack();

        final boolean bChecked = ((Boolean) newEnabledState.get(tableColumn));
        item.setChecked(bChecked);

      }
    });
    table.setItemCount(tableColumns.size());
   
    table.addMouseListener(new MouseAdapter() {
     
      public void mouseDown(MouseEvent arg0) {
        mousePressed = true;
        selectedItem = table.getItem(new Point(arg0.x,arg0.y));
      }
     
      public void mouseUp(MouseEvent e) {
        mousePressed = false;
        //1. Restore old image
        if(oldPoint != null) {
          table.redraw(oldPoint.x, oldPoint.y, shell.getSize().x,
              oldPoint.y + 2, false);
          oldPoint = null;
        }
        Point p = new Point(e.x,e.y);
        TableItem item = table.getItem(p);
        if(item != null && selectedItem != null) {
          int index = table.indexOf(item);
          int oldIndex = table.indexOf(selectedItem);
          if(index == oldIndex)
            return;

          TableColumn tableColumn =
                           (TableColumn)tableColumns.get(oldIndex);
         
          tableColumns.remove(tableColumn);
          tableColumns.add(index, tableColumn);
          table.clearAll();
        }
      }
    });
   
    table.addMouseMoveListener(new MouseMoveListener(){
      public void mouseMove(MouseEvent e) {
        if (!mousePressed || selectedItem == null)
          return;

        Point p = new Point(e.x,e.y);
        TableItem item = table.getItem(p);
        if (item == null)
          return;

        Rectangle bounds = item.getBounds(0);
        int selectedPosition = table.indexOf(selectedItem);
        int newPosition = table.indexOf(item);

        //1. Restore old area
        if(oldPoint != null) {
          table.redraw(oldPoint.x, oldPoint.y, bounds.width, oldPoint.y + 2, false);
          oldPoint = null;
        }           
        bounds.y += VerticalAligner.getTableAdjustVerticalBy(table);
        if(newPosition <= selectedPosition)
          oldPoint = new Point(bounds.x,bounds.y);
        else
          oldPoint = new Point(bounds.x,bounds.y+bounds.height);

        //3. Draw a thick line
        table.redraw(oldPoint.x, oldPoint.y, bounds.width, oldPoint.y + 2, false);
      }
    });
   
    table.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent e) {
        if (!mousePressed || selectedItem == null || oldPoint == null) {
          return;
        }
       
        Point p = new Point(e.x,e.y);
        TableItem item = table.getItem(p);
        if (item == null)
          return;
   
        Rectangle bounds = item.getBounds(0);
        GC gc = new GC(table);
View Full Code Here

      if (item != null)
        tree.setSelection(new TreeItem[] { item });

      selEvent.item = item;
    } else if (w instanceof Table) {
      Table table = (Table) w;
      TableItem item = table.getItem(new Point(e.x, e.y));
      if (item != null)
        table.setSelection(new TableItem[] { item });

      selEvent.item = item;
    } else
      return;
View Full Code Here

    /*
     * @see org.eclipse.jface.viewers.ColumnViewerToolTipSupport#getToolTipArea(org.eclipse.swt.widgets.Event)
     */
    @Override
    protected Object getToolTipArea(Event event) {
      Table table = (Table) event.widget;
      Point point = new Point(event.x, event.y);
      TableItem item = table.getItem(point);

      /* Only valid for Feed Column */
      if (item != null) {
        if (item.getBounds(COL_FEED).contains(point))
          return super.getToolTipArea(event);
View Full Code Here

    }
    return -1;
  }

  public MediaTableView(Composite pParent) {
    mTable = new Table(pParent, SWT.BORDER | SWT.FULL_SELECTION
        | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    mTable.setHeaderVisible(true);
    GridData lData = new GridData(GridData.FILL_BOTH);
    mTable.setLayoutData(lData);
    buildColumns();
View Full Code Here

  /**
   * @param parent
   * @param style
   */
  public CTable(Composite parent, int style) {
    fTable = new Table(parent, style);
    parent.addListener(SWT.Resize, new Listener() {
      public void handleEvent(Event event) {
        onTableResize();
      }
    });
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.