@Override
 protected CellEditor getCellEditor(Object element) {
   allowedKeys = getAllowedKeys();
   cellEditor =
       new ComboBoxCellEditor((Composite) viewer.getControl(), allowedKeys, SWT.READ_ONLY);
   return cellEditor;
 }
  /**
   * Constructs advisor for a viewer
   *
   * @param columnViewer ColumnViewer on which the advisor is installed
   */
  public ColumnAdvisor(ColumnViewer columnViewer) {
    this.columnViewer = columnViewer;
    this.control = columnViewer.getControl();
    this.control.addMouseTrackListener(
        new MouseTrackAdapter() {
          public void mouseEnter(MouseEvent e) {
            handleMouseOver(e);
          }

          public void mouseExit(MouseEvent e) {
            handleMouseExit(e);
          }
        });

    this.control.addMouseMoveListener(
        new MouseMoveListener() {
          public void mouseMove(MouseEvent e) {
            handleMouseOver(e);
          }
        });
    this.control.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseUp(MouseEvent e) {
            handleMouseUp(e);
          }
        });
  }
  @Override
  public Command createCommand(Collection<?> selection) {
    EStructuralFeature ef = feature;
    EObject owner = (EObject) viewer.getInput();
    if (domain.getClipboard() == null) {
      return UnexecutableCommand.INSTANCE;
    }
    Collection<Object> objs = getPasteObjs(EcoreUtil.copyAll(domain.getClipboard()), eclass);
    if (objs.size() > 0) {
      if (!MetadataViewerUtil.isShowCategory(viewer)) {
        return AddCommand.create(getEditingDomain(), owner, ef, objs);
      }
      MetadataCategory cate = MetadataViewerUtil.getSelectedCategory(viewer, false);
      if (cate instanceof UncategorizedItemsCategoryImpl) {
        return AddCommand.create(getEditingDomain(), owner, ef, objs);
      } else if (cate instanceof MetadataCategory) {
        CompoundCommand command = new CompoundCommand();
        command.append(
            AddCommand.create(
                getEditingDomain(), cate, MetadataPackage.Literals.METADATA_CATEGORY__ITEMS, objs));

        command.append(AddCommand.create(getEditingDomain(), owner, ef, objs));
        // 再添加到分组

        return command;
      }
    }
    return UnexecutableCommand.INSTANCE;
  }
    public void propertyChange(PropertyChangeEvent evt) {
      if (myColumnViewer.getControl().isDisposed()) {
        dispose();
        return;
      }
      if (myData == null) {
        return;
      }

      if (GriddableSeries.PROPERTY_CHANGED.equals(evt.getPropertyName())) {
        myColumnViewer.refresh(evt.getNewValue(), true);
      } else if (GriddableSeries.PROPERTY_DELETED.equals(evt.getPropertyName())
          || //
          GriddableSeries.PROPERTY_ADDED.equals(evt.getPropertyName())) {
        myColumnViewer.refresh(true);
      }
    }
    @Override
    protected void initialize(ColumnViewer viewer, ViewerColumn column) {
      super.initialize(viewer, column);

      Font font = viewer.getControl().getFont();

      if (font != null) {
        FontData data = font.getFontData()[0];

        boldFont = new Font(font.getDevice(), data.getName(), data.getHeight(), SWT.BOLD);
      }
    }
 protected void sortUsing(SortInfo info) {
   if (info == infos[0]) info.descending = !info.descending;
   else {
     for (int i = 0; i < infos.length; i++) {
       if (info == infos[i]) {
         System.arraycopy(infos, 0, infos, 1, i);
         infos[0] = info;
         info.descending = false;
         break;
       }
     }
   }
   viewer.refresh();
 }
Exemple #7
0
    public InlineComboEditingSupport(ColumnViewer viewer) {
      super(viewer);
      this.editor =
          new ComboBoxCellEditor((Composite) viewer.getControl(), new String[] {}, SWT.READ_ONLY);

      Control control = editor.getControl();
      ((CCombo) control)
          .addSelectionListener(
              new SelectionListener() {
                public void widgetSelected(SelectionEvent e) {
                  editor.deactivate();
                }

                public void widgetDefaultSelected(SelectionEvent e) {}
              });
    }
 /**
  * Create a new instance of the receiver.
  *
  * @param viewer the viewer where the editing support is being provided (cannot be <code>null
  *     </code>)
  * @param columnID the column id
  */
 public PropertyNameEditingSupport(ColumnViewer viewer, int columnID) {
   super(viewer);
   this.columnID = columnID;
   this.editor = new TextCellEditor((Composite) viewer.getControl());
 }