/**
   * Handling mouse over event to display hand cursor in case cell contains an URL
   *
   * @param e mouse event
   */
  void handleMouseOver(MouseEvent e) {
    Point pt = new Point(e.x, e.y);
    ViewerCell cell = getViewer().getCell(pt);
    boolean cursorSet = false;

    if (cell != null) {
      int colIndex = cell.getColumnIndex();
      Object element = cell.getElement();
      if (getCellControlType(element, colIndex) == CellControlType.URL) {
        Rectangle cellBounds = cell.getBounds();
        Image img = getImage(element, colIndex);
        if (img != null) {
          cellBounds.x += img.getBounds().width;
        }
        if (cellBounds.contains(pt)) {
          if (getString(element, colIndex) != null) {
            this.control.setCursor(CURSOR_HAND);
            cursorSet = true;
          }
        }
      }
    }

    if (!cursorSet) {
      handleMouseExit(e);
    }
  }
Example #2
0
 @Override
 public void update(ViewerCell cell) {
   LogicalTask logicalTask = (LogicalTask) cell.getElement();
   int columnIndex = cell.getColumnIndex();
   if (columnIndex == 0) {
     cell.setImage(severityImages[logicalTask.getSeverityType()]);
     cell.setText(logicalTask.getSummary());
     cell.setFont(logicalTask.getSeverityType() > 1 ? bold : null);
     cell.setForeground(logicalTask.isAllFixed() ? gray : null);
   } else {
     Version version = taskModel.getVersions()[columnIndex - 1];
     VersionTask versionTask = logicalTask.getVersionTask(version);
     if (versionTask != null) {
       cell.setText(versionTask.getStatus());
       cell.setFont(!"enhancement".equalsIgnoreCase(versionTask.getSeverity()) ? bold : null);
       cell.setForeground("FIXED".equalsIgnoreCase(versionTask.getResolution()) ? gray : null);
       cell.setBackground(logicalTask.getVersionTaskCount(version) > 1 ? red : null);
     } else {
       cell.setText("");
       cell.setFont(null);
       cell.setForeground(null);
       cell.setBackground(null);
     }
   }
 }
Example #3
0
  public void addSelectedColumnAsFilterCriteria() {
    ViewerCell cell = (ViewerCell) tableViewer.getCell(lastMousePosition);
    int columnIndex = cell.getColumnIndex();
    ColumnType columnType = (ColumnType) tableViewer.getTable().getColumn(columnIndex).getData();

    Event event = (Event) ((StructuredSelection) tableViewer.getSelection()).getFirstElement();
    List<Object> values = new LinkedList<Object>();
    int propertyIndex =
        EventTableUIElementsConstants.transformColumnNameToFilterPropertyIndex(columnType);

    switch (propertyIndex) {
      case EventFilterModel.UDF:
        for (Entry<String, Object> entry : event.getUdfs().entrySet()) {
          values.add(new Tuple<String, Object>(entry.getKey(), entry.getValue()));
        }
        values.addAll(eventFilterModel.getValuesFor(propertyIndex));
        break;
      case EventFilterModel.DATE:
        values.add(new Tuple<Date, Object>(event.getDateOfOccurrence(), null));
        break;
      case EventFilterModel.TRANSACTION_ID:
        for (String transActionId : event.getTransactionIds()) {
          values.add((Object) transActionId);
        }
        values.addAll(eventFilterModel.getValuesFor(propertyIndex));
        break;
      default:
        values.add(cell.getText());
        values.addAll(eventFilterModel.getValuesFor(propertyIndex));
    }
    eventFilterModel.setValuesFor(values, propertyIndex);
  }
 public void update(ViewerCell cell) {
   SliceProfileRow element = (SliceProfileRow) cell.getElement();
   int index = cell.getColumnIndex();
   String columnText = getColumnText(element, index);
   cell.setText(columnText);
   cell.setImage(getColumnImage(element, index));
   if (sliceProfileIntersectionIndices.contains(element.getStatementID() - 1)) {
     cell.setBackground(highlightColor);
   } else cell.setBackground(null);
   super.update(cell);
 }
 @Override
 public void update(ViewerCell cell) {
   super.update(cell);
   ISellOrder t = (ISellOrder) cell.getElement();
   Object[] data = {null, null, null, null};
   getCellData(t, SellOrderTable.getColumns()[cell.getColumnIndex()], data);
   if (data[TEXT] != null) cell.setText((String) data[TEXT]);
   if (data[IMAGE] != null) cell.setImage((Image) data[IMAGE]);
   if (data[FONT] != null) cell.setFont((Font) data[FONT]);
   if (data[FOREGROUND] != null) cell.setForeground((Color) data[FOREGROUND]);
 }
  @Override
  protected void focusCellChanged(ViewerCell newCell, ViewerCell oldCell) {
    super.focusCellChanged(newCell, oldCell);

    // Redraw new area
    if (newCell != null) {
      final Rectangle rect = newCell.getBounds();
      final int x = newCell.getColumnIndex() == 0 ? 0 : rect.x;
      final int width = newCell.getColumnIndex() == 0 ? rect.x + rect.width : rect.width;
      // 1 is a fix for Linux-GTK
      newCell.getControl().redraw(x, rect.y - 1, width, rect.height + 1, true);
    }

    if (oldCell != null) {
      final Rectangle rect = oldCell.getBounds();
      final int x = oldCell.getColumnIndex() == 0 ? 0 : rect.x;
      final int width = oldCell.getColumnIndex() == 0 ? rect.x + rect.width : rect.width;
      // 1 is a fix for Linux-GTK
      oldCell.getControl().redraw(x, rect.y - 1, width, rect.height + 1, true);
    }
  }
 /**
  * Opens URL for an URL control
  *
  * @param e mouse event
  */
 void handleMouseUp(MouseEvent e) {
   Point pt = new Point(e.x, e.y);
   ViewerCell cell = getViewer().getCell(pt);
   if (cell != null && this.control.getCursor() == CURSOR_HAND) {
     int colIndex = cell.getColumnIndex();
     Object element = cell.getElement();
     if (getCellControlType(element, colIndex) == CellControlType.URL) {
       String url = getUrl(element, colIndex);
       if (url != null && !url.isEmpty()) {
         OpenURL.open(url, this.control.getShell());
       }
     }
   }
 }
 @Override
 public void update(ViewerCell cell) {
   Object element = cell.getElement();
   if (element instanceof Cartridge) {
     Cartridge ink = (Cartridge) element;
     int index = cell.getColumnIndex();
     switch (index) {
       case 0: // UUID
         cell.setText(ink.getUuid().toString());
         break;
       case 1: // Maker
         cell.setText(ink.getMaker());
         break;
       case 2: // Model
         cell.setText(ink.getModel());
         break;
       case 3: // Abbreviation
         cell.setText(ink.getAbbreviation());
         break;
       case 4: // Name
         cell.setText(ink.getName());
         break;
       case 5: // Fill Volume
         cell.setText(Double.toString(ink.getFillVolume()));
         break;
       case 6: // Remaining Volume
         cell.setText(Double.toString(ink.getRemainingVolume()));
         break;
       case 7: // Installation Date
         Calendar installation = ink.getInstallDate();
         if (installation != null) {
           cell.setText(PrintPreferences.getDateFormat().format(installation.getTime()));
         }
         break;
       case 8: // Disposal Date
         Calendar disposal = ink.getDisposeDate();
         if (disposal != null) {
           cell.setText(PrintPreferences.getDateFormat().format(disposal.getTime()));
         }
         break;
       case 9: // Price
         cell.setText(ink.getPrice().toString());
         break;
       default:
         break;
     }
   }
 }
Example #9
0
    @Override
    @SuppressWarnings("restriction")
    public void mouseDoubleClick(MouseEvent event) {
      Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
      if (element instanceof LogicalTask) {
        LogicalTask logicalTask = (LogicalTask) element;
        ViewerCell cell = viewer.getCell(new Point(event.x, event.y));

        int columnIndex = cell.getColumnIndex();
        if (columnIndex != 0) {
          Version[] versions = taskModel.getVersions();
          Version version = versions[columnIndex - 1];

          for (VersionTask versionTask : logicalTask.getVersionTasks()) {
            if (versionTask.getVersion().equals(version)) {
              ITask task = versionTask.getTask();
              org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal
                  .refreshAndOpenTaskListElement(task);
            }
          }
        }
      }
    }
  @Override
  public void update(ViewerCell cell) {
    super.update(cell);

    SourceFilesViewer.TranslationUnitInfo tuInfo = null;
    Object element = cell.getElement();
    if (element instanceof ITranslationUnit) {
      tuInfo = SourceFilesViewer.fetchTranslationUnitInfo((Executable) viewer.getInput(), element);
    }

    int orgColumnIndex = cell.getColumnIndex();

    if (orgColumnIndex == 0) {
      if (element instanceof String) {
        cell.setText((String) element);
        Font italicFont =
            resourceManager.createFont(
                FontDescriptor.createFrom(viewer.getTree().getFont()).setStyle(SWT.ITALIC));
        cell.setFont(italicFont);
      } else {
        cell.setFont(viewer.getTree().getFont());
      }
    } else if (orgColumnIndex == 1) {
      cell.setText(null);
      if (tuInfo != null) {
        if (tuInfo.location != null) {
          cell.setText(tuInfo.location.toOSString());
          if (tuInfo.exists)
            cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
          else cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
        }
      }
      cell.setImage(null);
    } else if (orgColumnIndex == 2) {
      cell.setText(null);
      if (tuInfo != null && tuInfo.originalLocation != null) {
        cell.setText(tuInfo.originalLocation.toOSString());
        if (tuInfo.originalExists)
          cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
        else cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
      }
      cell.setImage(null);
    } else if (orgColumnIndex == 3) {
      cell.setText(null);
      if (tuInfo != null) {
        if (tuInfo.exists) {
          cell.setText(Long.toString(tuInfo.fileLength));
        }
      }
      cell.setImage(null);
    } else if (orgColumnIndex == 4) {
      cell.setText(null);
      if (tuInfo != null) {
        if (tuInfo.exists) {
          String dateTimeString =
              DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                  .format(new Date(tuInfo.lastModified));
          cell.setText(dateTimeString);
        }
      }
      cell.setImage(null);
    } else if (orgColumnIndex == 5) {
      cell.setText(null);
      if (tuInfo != null) {
        if (tuInfo.location != null) {
          String fileExtension = tuInfo.location.getFileExtension();
          if (fileExtension != null) cell.setText(fileExtension.toLowerCase());
        }
      }
      cell.setImage(null);
    }
  }
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.jface.viewers.ColumnLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
  */
 @Override
 public void update(final ViewerCell cell) {
   columnIndex = cell.getColumnIndex();
   super.update(cell);
 }
 @Override
 public void mouseDown(MouseEvent e) {
   ViewerCell cell = fTableViewer.getCell(new Point(e.x, e.y));
   fSelectedColumn = (cell != null) ? cell.getColumnIndex() : -1;
 }