Beispiel #1
0
 public Control getControl(Composite par) {
   if (editor == null) editor = data.getEditor(par);
   Control control = editor.getControl();
   if (control == null) {
     editor = data.getEditor(par);
     return editor.getControl();
   }
   return control;
 }
  /**
   * This method is used to set the cell editors text
   *
   * @param toEdit String to be set in the cell editor
   */
  public void setEditText(String toEdit) {

    // Get the cell editor
    CellEditor cellEditor = getCellEditor();

    // IF the cell editor doesn't exist yet...
    if (cellEditor == null) {
      // Do nothing
      return;
    }

    // Get the Text Compartment Edit Part
    IXtextAwareEditPart textEP = (IXtextAwareEditPart) getEditPart();

    // Get the Text control
    StyledText textControl = (StyledText) cellEditor.getControl();

    // Set the Figures text
    textEP.setLabelText(toEdit);

    // See RATLC00522324
    if (cellEditor instanceof TextCellEditorEx) {
      ((TextCellEditorEx) cellEditor).setValueAndProcessEditOccured(toEdit);
    } else {
      cellEditor.setValue(toEdit);
    }

    // Set the controls text and position the caret at the end of the text
    textControl.setSelection(toEdit.length());
  }
Beispiel #3
0
 public static CellEditor createPropertyEditor(
     final IServiceLocator serviceLocator,
     Composite parent,
     DBPPropertySource source,
     DBPPropertyDescriptor property) {
   if (source == null) {
     return null;
   }
   final Object object = source.getEditableValue();
   if (!property.isEditable(object)) {
     return null;
   }
   CellEditor cellEditor = UIUtils.createCellEditor(parent, object, property);
   if (cellEditor != null) {
     final Control editorControl = cellEditor.getControl();
     UIUtils.addFocusTracker(serviceLocator, UIUtils.INLINE_WIDGET_EDITOR_ID, editorControl);
     editorControl.addDisposeListener(
         new DisposeListener() {
           @Override
           public void widgetDisposed(DisposeEvent e) {
             UIUtils.removeFocusTracker(serviceLocator, editorControl);
           }
         });
   }
   return cellEditor;
 }
  /**
   * The <code>TextPropertyDescriptor</code> implementation of this <code>IPropertyDescriptor</code>
   * method creates and returns a new <code>TextCellEditor</code>.
   *
   * <p>The editor is configured with the current validator if there is one.
   *
   * @param parent the parent
   * @return the cell editor
   */
  public CellEditor createPropertyEditor(Composite parent) {
    CellEditor editor =
        new TextCellEditor(parent) {
          @Override
          protected Object doGetValue() {
            String value = (String) super.doGetValue();
            if (value == null || value.equals("")) // $NON-NLS-1$
            return (Double) null;
            return new Double(value);
          }

          @Override
          protected void doSetValue(Object value) {
            if (value == null) super.doSetValue(""); // $NON-NLS-1$
            else {
              Assert.isTrue(text != null && (value instanceof Double));
              super.doSetValue(((Double) value).toString());
            }
          }
        };
    editor.setValidator(DoubleCellEditorValidator.instance());
    setValidator(DoubleCellEditorValidator.instance());
    HelpSystem.bindToHelp(this, editor.getControl());
    return editor;
  }
 public void deactivate() {
   if (activeEditor != null) {
     Control control = activeEditor.getControl();
     if (control != null && !control.isDisposed()) {
       control.setVisible(false);
     }
   }
 }
 @Override
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Point prefSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   Rectangle rectangle = label.getTextBounds().getCopy();
   label.translateToAbsolute(rectangle);
   text.setBounds(rectangle.x - 1, rectangle.y - 1, prefSize.x + 1, prefSize.y + 1);
 }
 /** @generated */
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Rectangle rect = getLabel().getTextBounds().getCopy();
   getLabel().translateToAbsolute(rect);
   int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
   rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
   if (!rect.equals(new Rectangle(text.getBounds()))) {
     text.setBounds(rect.x, rect.y, rect.width, rect.height);
   }
 }
 /** @generated */
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Rectangle rect = getMultilineEditableFigure().getBounds().getCopy();
   rect.x = getMultilineEditableFigure().getEditionLocation().x;
   rect.y = getMultilineEditableFigure().getEditionLocation().y;
   getMultilineEditableFigure().translateToAbsolute(rect);
   if (getMultilineEditableFigure().getText().length() > 0) {
     rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT)));
   }
   if (!rect.equals(new Rectangle(text.getBounds()))) {
     text.setBounds(rect.x, rect.y, rect.width, rect.height);
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.views.properties.IPropertySheetEntry#getEditor(org.eclipse
   * .swt.widgets.Composite)
   */
  public CellEditor getEditor(Composite parent) {

    if (editor == null || editor.getControl().isDisposed()) {
      editor = descriptor.createPropertyEditor(parent);
      if (editor != null) {
        editor.addListener(cellEditorListener);
      }
    }
    // && !eq(editor.getValue(), editValue)
    if (editor != null) {
      editor.setValue(editValue);
    }
    return editor;
  }
  public void relocate(CellEditor celleditor) {
    if (celleditor == null) return;
    Text text = (Text) celleditor.getControl();

    Rectangle rect = fig.getClientArea(Rectangle.SINGLETON);
    if (fig instanceof Label) rect = ((Label) fig).getTextBounds().intersect(rect);
    fig.translateToAbsolute(rect);

    org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
    rect.translate(trim.x, trim.y);
    rect.width += trim.width;
    rect.height += trim.height;

    text.setBounds(rect.x, rect.y, rect.width, rect.height);
  }
  @Override
  protected void setValue(Object element, Object value) {
    // Locals
    CCombo statesCombo = (CCombo) editor.getControl();

    if (element instanceof Release) {
      ((Release) element).setState(statesCombo.getText());
    } else if (element instanceof Iteration) {
      // TODO: ??
    } else if (element instanceof UserStory) {
      ((UserStory) element).setState(statesCombo.getText());
    } else if (element instanceof Task) {
      ((Task) element).setState(statesCombo.getText());
    }
    // Update viewer
    getViewer().update(element, null);
  }
  @Override
  protected Object getValue(Object element) {
    // Locals
    CCombo statesCombo = (CCombo) editor.getControl();
    String state = null;

    if (element instanceof Release) {
      state = ((Release) element).getState();
    } else if (element instanceof Iteration) {
      // TODO: ??
    } else if (element instanceof UserStory) {
      state = ((UserStory) element).getState();
    } else if (element instanceof Task) {
      state = ((Task) element).getState();
    }
    // Set combo new state
    statesCombo.setText(state);

    return new Integer(-2);
  }
 @Override
 public CellEditor createPropertyEditor(Composite parent) {
   CellEditor editor = super.createPropertyEditor(parent);
   HelpSystem.bindToHelp(this, editor.getControl());
   return editor;
 }
 @Override
 protected IObservableValue doCreateCellEditorObservable(CellEditor editor) {
   return SWTObservables.observeText(editor.getControl());
 }
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Point origin = getViewportOrigin().getNegated();
   Rectangle rect = label.getTextBounds().getCopy().expand(5, 0).translate(origin);
   text.setBounds(rect.x, rect.y, rect.width, rect.height);
 }
 public Control getControl() {
   return activeEditor.getControl();
 }