下面列出了org.eclipse.jface.viewers.CellEditor#getControl ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @generated
*/
public void relocate(CellEditor celleditor) {
Text text = (Text) celleditor.getControl();
Rectangle rect = getWrapLabel().getTextBounds().getCopy();
getWrapLabel().translateToAbsolute(rect);
if (!text.getFont().isDisposed()) {
if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) {
//Adjust editor location
rect.x = rect.x - 5;
if (rect.width < 75) {
rect.width = 75;
}
rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT)));
} else {
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);
}
}
@Override
public void relocate(final CellEditor cellEditor) {
final Text text = (Text) cellEditor.getControl();
final Rectangle rect = figure.getBounds().getCopy();
figure.translateToAbsolute(rect);
text.setBounds(rect.x + NoteFigure.RETURN_WIDTH, rect.y + NoteFigure.RETURN_WIDTH, rect.width - NoteFigure.RETURN_WIDTH * 2, rect.height - NoteFigure.RETURN_WIDTH * 2);
}
/**
* 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());
}
@Override
public void relocate(CellEditor cellEditor) {
final Text text = (Text) cellEditor.getControl();
final Rectangle rect = figure.getBounds().getCopy();
figure.translateToAbsolute(rect);
text.setBounds(rect.x + WalkerNoteFigure.RETURN_WIDTH, rect.y + WalkerNoteFigure.RETURN_WIDTH,
rect.width - WalkerNoteFigure.RETURN_WIDTH * 2, rect.height - WalkerNoteFigure.RETURN_WIDTH * 2);
}
public void relocate( CellEditor celleditor )
{
Text text = (Text) celleditor.getControl( );
Rectangle rect = figure.getClientArea( ).getCopy( );
figure.translateToAbsolute( rect );
int xOffset = 0;
int wOffset = 0;
int yOffset = 0;
int hOffset = 0;
if ( SWT.getPlatform( ).equalsIgnoreCase( "gtk" ) ) { //$NON-NLS-1$
xOffset = GTK_X_OFFSET;
wOffset = GTK_W_OFFSET;
}
else if ( SWT.getPlatform( ).equalsIgnoreCase( "carbon" ) ) { //$NON-NLS-1$
xOffset = MAC_X_OFFSET;
wOffset = MAC_W_OFFSET;
yOffset = MAC_Y_OFFSET;
hOffset = MAC_H_OFFSET;
}
else
{
xOffset = WIN_X_OFFSET;
wOffset = WIN_W_OFFSET;
}
text.setBounds( rect.x + xOffset, rect.y + yOffset, rect.width
+ wOffset, rect.height + hOffset );
}
/**
* @generated
*/
public void relocate(CellEditor celleditor) {
Text text = (Text) celleditor.getControl();
Rectangle rect = getLabel().getTextBounds().getCopy();
getLabel().translateToAbsolute(rect);
if (!text.getFont().isDisposed()) {
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);
}
}
public void relocate(CellEditor cellEditor) {
Text text = (Text) cellEditor.getControl();
Rectangle rect = this.figure.getBounds().getCopy();
this.figure.translateToAbsolute(rect);
text.setBounds(rect.x + NoteFigure.RETURN_WIDTH, rect.y
+ NoteFigure.RETURN_WIDTH, rect.width - NoteFigure.RETURN_WIDTH
* 2, rect.height - NoteFigure.RETURN_WIDTH * 2);
}