TreeViewer.ColumnViewerToolTipSupportのツールチップを実装すると、カスタムのツールチップコンポジットを提供できます。しかし、ここの問題は親シェルの設定サイズはシェルのサイズに影響しません。ここでのコードで ルック:ここColumnViewerToolTipSupportの使用中にシェルのサイズを修正できないのはなぜですか?
private static class MyToolTip extends ColumnViewerToolTipSupport {
public static final void enableFor(ColumnViewer viewer, int style) {
new MyToolTip(viewer, style, false);
}
private MyToolTip(ColumnViewer viewer, int style, boolean manualActivation) {
super(viewer, style, manualActivation);
setHideOnMouseDown(false);
}
@Override
protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent) {
String text = getText(event);
if (text == null || text.isEmpty()) {
return super.createViewerToolTipContentArea(event, cell, parent);
}
parent.setSize(450,300);
final Composite comp = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
comp.setLayout(gridLayout);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
StyledText styledText = new StyledText(comp, SWT.BORDER);
styledText.setText(text);
StyleRange style = new StyleRange();
style.start = 0;
style.length = text.indexOf(":");
style.fontStyle = SWT.BOLD;
styledText.setStyleRange(style);
return comp;
}
}
parent.setSize(450300)は影響はありません。親クラス(ToolTip.java)でシェルのサイズを取得すると、別の値が返され、巨大なシェルが表示されます。
どうすれば修正できますか?
完璧!これは魅力として機能します。ありがとうございました :) –