@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);
 }
示例#2
0
 private String abbreviateLabel(Label label, String labelText, int currentLength) {
   label.setText(labelText);
   if (label.getFont() == null) {
     label.setFont(Display.getDefault().getSystemFont());
   }
   if (label.getTextBounds().width > MAX_LABEL_WIDTH) {
     String shorterLabelText = "";
     shorterLabelText =
         StringUtils.abbreviateMiddle(label.getText(), LABEL_TEXT_SEPARATOR, currentLength);
     currentLength--;
     label.setText(shorterLabelText);
     abbreviateLabel(label, shorterLabelText, currentLength);
   }
   return label.getText();
 }
 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);
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * de.tub.tfs.muvitor.gef.directedit.IDirectEditPart.IGraphicalDirectEditPart
  * #getValueLabelTextBounds()
  */
 @Override
 public Rectangle getValueLabelTextBounds() {
   return counterLabel.getTextBounds();
 }