これまでに私が管理してきたのは、私が追加したいToolItemが含まれていましたが、このDefaultInformationControlに基づくホバーポップアップが開いているときにはnothigが表示されていたツールバーのToolBarManagerを追加しています。 すべてのToolItemsのテキストとスタイルを指定しました。コントロールを含むツールバーをDefaultInformationControlに追加するにはどうすればよいですか?
私のコードは次のとおりです。
public class JavaTextHover implements IJavaEditorTextHover, ITextHoverExtension{
.
.
.
@Override
public IInformationControlCreator getHoverControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
ToolBar toolBar = new ToolBar(parent, SWT.NONE);
ToolItem itemPush = new ToolItem(toolBar, SWT.PUSH);
itemPush.setText("PUSH item");
ToolItem itemCheck = new ToolItem(toolBar, SWT.CHECK);
itemCheck.setText("CHECK item");
ToolItem itemRadio1 = new ToolItem(toolBar, SWT.RADIO);
itemRadio1.setText("RADIO item 1");
ToolItem itemRadio2 = new ToolItem(toolBar, SWT.RADIO);
itemRadio2.setText("RADIO item 2");
ToolItem itemSeparator = new ToolItem(toolBar, SWT.SEPARATOR);
Text text = new Text(toolBar, SWT.BORDER | SWT.SINGLE);
text.pack();
itemSeparator.setWidth(text.getBounds().width);
itemSeparator.setControl(text);
final ToolItem itemDropDown = new ToolItem(toolBar, SWT.DROP_DOWN);
itemDropDown.setText("DROP_DOWN item");
itemDropDown.setToolTipText("Click here to see a drop down menu ...");
final Menu menu = new Menu(parent, SWT.POP_UP);
new MenuItem(menu, SWT.PUSH).setText("Menu item 1");
new MenuItem(menu, SWT.PUSH).setText("Menu item 2");
new MenuItem(menu, SWT.SEPARATOR);
new MenuItem(menu, SWT.PUSH).setText("Menu item 3");
itemDropDown.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if(event.detail == SWT.ARROW) {
Rectangle bounds = itemDropDown.getBounds();
Point point = toolBar.toDisplay(bounds.x, bounds.y + bounds.height);
menu.setLocation(point);
menu.setVisible(true);
}
}
});
Listener selectionListener = new Listener() {
public void handleEvent(Event event) {
ToolItem item = (ToolItem)event.widget;
System.out.println(item.getText() + " is selected");
if((item.getStyle() & SWT.RADIO) != 0 || (item.getStyle() & SWT.CHECK) != 0)
System.out.println("Selection status: " + item.getSelection());
}
};
itemPush.addListener(SWT.Selection, selectionListener);
itemCheck.addListener(SWT.Selection, selectionListener);
itemRadio1.addListener(SWT.Selection, selectionListener);
itemRadio2.addListener(SWT.Selection, selectionListener);
itemDropDown.addListener(SWT.Selection, selectionListener);
toolBar.pack();
toolBar.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
ToolBarManager tbm=new ToolBarManager(toolBar);
System.out.println(tbm.getControl().getChildren().length);
DefaultInformationControl dic=new DefaultInformationControl(parent, tbm);
dic.setBackgroundColor(new Color(null, 98,201,145));
return dic;
}
};
}
.
.
.
}
コードを表示します。 –
ただ、私はあなたがリンクまたは何かを与えることができNlsHoverControlについての情報を見つけることができない、または多分あなたはNLSStringHoverと混同してしまったメインポスト –