/**
   * 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);
    }
  }
 @Override
 public void update(ViewerCell cell) {
   Object element = cell.getElement();
   cell.setText(getText(element));
   Image image = getImage(element);
   cell.setImage(image);
 }
 @Override
 public void update(ViewerCell cell) {
   PlatzhalterTreeData data = (PlatzhalterTreeData) cell.getElement();
   if (data != null) {
     cell.setText(data.getName());
   }
 }
예제 #4
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);
  }
예제 #5
0
 private void getInput(Control c) {
   if (InInput) {
     return;
   }
   if (klickedCell == null) {
     return;
   }
   XViewerColumn xCol =
       xv.getXViewerFactory()
           .getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId());
   if (xCol instanceof ExtendedViewerColumn) {
     ExtendedViewerColumn extendedCol = (ExtendedViewerColumn) xCol;
     CellEditDescriptor ced =
         extendedCol.getCellEditDescriptorMap().get(klickedCell.getElement().getClass());
     if (ced == null || ced.getControl() == null) {
       return;
     }
     InInput = true;
     try {
       converter.getInput(c, ced, klickedCell.getElement());
       xv.refresh(klickedCell.getElement());
     } catch (Exception ex) {
       InInput = false;
     }
     InInput = false;
   }
 }
예제 #6
0
    @Override
    public void update(ViewerCell cell) {
      EObject o = (EObject) cell.getElement();

      String label = ""; // $NON-NLS-1$
      Image img = null;
      AbstractComponentEditor elementEditor = getEditor().getEditor(o.eClass());
      if (elementEditor != null) {
        label = elementEditor.getDetailLabel(o);
        label = label == null ? elementEditor.getLabel(o) : label;
        img = elementEditor.getImage(o, composite.getDisplay());
      }

      List<String> parentPath = new ArrayList<String>();
      while (o.eContainer() != null) {
        o = o.eContainer();
        elementEditor = getEditor().getEditor(o.eClass());
        if (elementEditor != null) {
          parentPath.add(0, elementEditor.getLabel(o));
        }
      }

      String parentString = ""; // $NON-NLS-1$
      for (String p : parentPath) {
        parentString += "/" + p; // $NON-NLS-1$
      }

      StyledString s = new StyledString(label);
      s.append(" - " + parentString, StyledString.DECORATIONS_STYLER); // $NON-NLS-1$
      cell.setStyleRanges(s.getStyleRanges());
      cell.setText(s.getString());
      cell.setImage(img);
    }
 @Override
 public void update(final ViewerCell cell) {
   final Object element = cell.getElement();
   String text = null;
   if (element instanceof RemoteR) {
     text = getText((RemoteR) element);
   }
   cell.setText(text);
 }
 @Override
 public void update(ViewerCell cell) {
   Object element = cell.getElement();
   StyledString styledText = getStyledText(element);
   cell.setText(styledText.toString());
   cell.setStyleRanges(styledText.getStyleRanges());
   cell.setImage(getImage(element));
   super.update(cell);
 }
예제 #9
0
    protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
      int idx = ((Integer) cellEditor.getValue()).intValue();
      String[] items = ((ComboBoxCellEditor) cellEditor).getItems();

      String selectedVersion = items[idx];
      cell.setText(selectedVersion);

      if (cell.getElement() instanceof JarDiff) {
        ((JarDiff) cell.getElement()).setSelectedVersion(selectedVersion);
        return;
      }
      PackageInfo modelElement = (PackageInfo) cell.getElement();
      modelElement.setSelectedVersion(selectedVersion);
    }
 /**
  * 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());
       }
     }
   }
 }
예제 #11
0
    /**
     * @see
     *     org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
     */
    @Override
    public void update(ViewerCell cell) {
      // Interlace
      if (isInterlaceRow) {
        // Font
        cell.setText("BOLD");
        cell.setFont(SwtFonts.TEXT_BOLD.font());

        // Image
        cell.setImage(SwtImagesSilk.DELETE.image());

        // Color
        cell.setBackground(SwtColors.color(ColorType.RED));

      } else {
        // Font
        cell.setText("Normal");
        cell.setFont(SwtFonts.TEXT.font());

        // Image
        cell.setImage(SwtImagesSilk.ADD.image());

        // Color
        cell.setBackground(SwtColors.color(ColorType.GREEN));
      }
      isInterlaceRow = !isInterlaceRow;
      super.update(cell);
    }
예제 #12
0
    @Override
    protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
      int idx = ((Integer) cellEditor.getValue()).intValue();
      String[] items = ((ComboBoxCellEditor) cellEditor).getItems();

      String selectedVersion = items[idx];
      cell.setText(selectedVersion);

      if (cell.getElement() instanceof Baseline) {
        ((Baseline) cell.getElement()).setSuggestedVersion(Version.parseVersion(selectedVersion));
      } else if (cell.getElement() instanceof Info) {
        ((Info) cell.getElement()).suggestedVersion = Version.parseVersion(selectedVersion);
      }
    }
    @Override
    public void update(ViewerCell cell) {
      ExtractedEntry entry = (ExtractedEntry) cell.getElement();
      String text = getText(entry);
      if (text == null) text = ""; // $NON-NLS-1$

      boolean strikeout = !entry.isImported();
      StyledString styledString = new StyledString(text, strikeout ? strikeoutStyler : null);

      cell.setText(styledString.toString());
      cell.setStyleRanges(styledString.getStyleRanges());
      cell.setImage(getImage(entry));

      super.update(cell);
    }
예제 #14
0
 private void setInput(Control c) {
   if (klickedCell == null) {
     return;
   }
   XViewerColumn xCol =
       xv.getXViewerFactory()
           .getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId());
   if (xCol instanceof ExtendedViewerColumn) {
     ExtendedViewerColumn extendedCol = (ExtendedViewerColumn) xCol;
     CellEditDescriptor ced =
         extendedCol.getCellEditDescriptorMap().get(klickedCell.getElement().getClass());
     if (ced == null || ced.getControl() == null) {
       return;
     }
     converter.setInput(c, ced, klickedCell.getElement());
   }
   c.setBounds(klickedCell.getBounds());
 }
예제 #15
0
    @Override
    protected void initializeCellEditorValue(CellEditor cellEditor, ViewerCell cell) {

      String selectedVersion = "";
      if (cell.getElement() instanceof Baseline) {
        selectedVersion = ((Baseline) cell.getElement()).getSuggestedVersion().toString();
      } else if (cell.getElement() instanceof Info) {
        selectedVersion = ((Info) cell.getElement()).suggestedVersion.toString();
      }

      String[] items = ((ComboBoxCellEditor) cellEditor).getItems();
      int idx = 0;
      for (int i = 0; i < items.length; i++) {
        if (items[i].equals(selectedVersion)) {
          idx = i;
          break;
        }
      }

      cellEditor.setValue(idx);
      cell.setText(selectedVersion);
    }
예제 #16
0
    protected void initializeCellEditorValue(CellEditor cellEditor, ViewerCell cell) {

      String selectedVersion;
      if (cell.getElement() instanceof JarDiff) {
        selectedVersion = ((JarDiff) cell.getElement()).getSelectedVersion();
      } else {
        PackageInfo pi = (PackageInfo) cell.getElement();
        selectedVersion = pi.getSelectedVersion();
      }

      String[] items = ((ComboBoxCellEditor) cellEditor).getItems();
      int idx = 0;
      for (int i = 0; i < items.length; i++) {
        if (items[i].equals(selectedVersion)) {
          idx = i;
          break;
        }
      }

      cellEditor.setValue(idx);
      cell.setText(selectedVersion);
    }
예제 #17
0
    @Override
    public void update(ViewerCell cell) {
      // result on given cell text
      String cellText = (String) cell.getElement();

      StyledString styledLabel = new StyledString();

      String customLabel;
      if (cellText.contains("1")) {
        if (cellText.contains("2")) {
          customLabel = "3";
        } else {
          customLabel = "1";
        }
      } else {
        if (cellText.contains("2")) {
          customLabel = "2";
        } else {
          customLabel = "0";
        }
      }

      if (cellText.contains("1")) {
        styledLabel.append(customLabel + "spre" + modifier, StyledString.COUNTER_STYLER);
        styledLabel.append(" ", null);
      }

      styledLabel.append(customLabel + "nonstyled" + modifier, null);

      if (cellText.contains("2")) {
        styledLabel.append(" ", null);
        styledLabel.append(customLabel + "spost" + modifier, StyledString.COUNTER_STYLER);
      }

      cell.setText(styledLabel.toString());
      cell.setStyleRanges(styledLabel.getStyleRanges());

      super.update(cell);
    }
예제 #18
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);
            }
          }
        }
      }
    }
  /**
   * Creates a {@link Binding} between the editor and the element to be edited. Invokes {@link
   * #doCreateCellEditorObservable(CellEditor)}, {@link #doCreateElementObservable(Object,
   * ViewerCell)}, and then {@link #createBinding(IObservableValue, IObservableValue)}.
   */
  protected final void initializeCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
    IObservableValue target = doCreateCellEditorObservable(cellEditor);
    Assert.isNotNull(
        target, "doCreateCellEditorObservable(...) did not return an observable"); // $NON-NLS-1$

    IObservableValue model = doCreateElementObservable(cell.getElement(), cell);
    Assert.isNotNull(
        model, "doCreateElementObservable(...) did not return an observable"); // $NON-NLS-1$

    Binding binding = createBinding(target, model);
    Assert.isNotNull(binding, "createBinding(...) did not return a binding"); // $NON-NLS-1$

    editingState = new EditingState(binding, target, model);

    getViewer().getColumnViewerEditor().addEditorActivationListener(activationListener);
  }
 @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]);
 }
예제 #21
0
 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) {
   CeylonHierarchyNode n = (CeylonHierarchyNode) cell.getElement();
   if (n.isMultiple()) {
     cell.setText("multiple supertypes" + getViewInterfacesShortcut());
     cell.setStyleRanges(new StyleRange[0]);
     cell.setImage(MULTIPLE_TYPES_IMAGE);
   } else {
     StyledString styledText = getStyledText(n);
     cell.setText(styledText.toString());
     cell.setStyleRanges(styledText.getStyleRanges());
     cell.setImage(getImageForDeclaration(getDisplayedDeclaration(n), n.isFocus()));
   }
   super.update(cell);
 }
  @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);
    }
  }
 /**
  * {@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);
 }
예제 #25
0
  @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);
    }
  }
 @Override
 public void update(ViewerCell cell) {
   cell.setText(labelProvider.getText(cell.getElement()));
   cell.setImage(labelProvider.getImage(cell.getElement()));
 }
 @Override
 public void update(ViewerCell cell) {
   Person element = (Person) cell.getElement();
   cell.setText(element.getLastName());
   super.update(cell);
 }
예제 #28
0
 @Override
 public void update(ViewerCell cell) {
   cell.setText(((ETItem) cell.getElement()).label);
 }
예제 #29
0
 @Override
 public final void update(ViewerCell cell) {
   Activity activity = (Activity) cell.getElement();
   cell.setText(getText(activity));
 }
 /**
  * Call this method from update(ViewerCell) to flip normal/italic font style. If column is created
  * with IColumnLabelProvider, this method is called by inner implementation of CellLabelProvider
  * with italic=IColumnLabelProvider.isModified(element) Custom implementation of CellLabelProvider
  * may keep to the same behavior or choose another condition for using italic font.
  *
  * @param cell
  * @param italic
  */
 public void applyFont(ViewerCell cell, boolean italic) {
   cell.setFont(italic ? italicFont : normalFont);
 }