如何創建彈出窗口,類似於eclipse jdt中用於javadoc的窗口。當鼠標懸停在圖形節點上時,我需要顯示其他信息。eclipse彈出窗口
2
A
回答
3
我覺得IInformationPresenter (eclipse.org API)接口可以幫助你在這裏。
一個寫得很好的關於如何使用它可以在IBM找到教程:
"Equipping SWT applications with content assistants" by Berthold Daum
1
org.eclipse.jface.dialogs.PopupDialog
似乎是一個很好的起點。
1
得到這個代碼here:
public class InfoPopUp extends PopupDialog {
/**
* The text control that displays the text.
*/
private Text text;
/**
* The String shown in the popup.
*/
private String contents = "";
private final static int SHELL_STYLE = PopupDialog.INFOPOPUP_SHELLSTYLE;
public InfoPopUp(Shell parent, String infoText) {
this(parent, SHELL_STYLE, false, false, false, false, false, null,
infoText);
}
public InfoPopUp(Shell parent, String titleText, String infoText) {
this(parent, SHELL_STYLE, false, false, false, true, true, titleText,
infoText);
}
public InfoPopUp(Shell parent, int shellStyle, boolean takeFocusOnOpen,
boolean persistSize, boolean persistLocation,
boolean showDialogMenu, boolean showPersistActions,
String titleText, String infoText) {
super(parent, shellStyle, takeFocusOnOpen, persistSize,
persistLocation, showDialogMenu, showPersistActions, titleText,
infoText);
}
/**
* This method is used to show the animation by decreasing the x and y
* coordinates and by setting the size dynamically.
*
* @param shell
* of type {@link Shell}
*/
private static void doAnimation(Shell shell) {
Point shellArea = shell.getSize();
int x = shellArea.x;
int y = shellArea.y;
while (x != -200) {
try {
shell.setSize(x--, y--);
} catch (Exception e) {
e.printStackTrace();
}
}
}
protected void fillDialogMenu(IMenuManager dialogMenu) {
dialogMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager arg0) {
handleShellCloseEvent();
}
});
}
protected void handleShellCloseEvent() {
// Comment out the following if do not want any kind of animated effect.
doAnimation(getShell());
super.handleShellCloseEvent();
}
protected Control createDialogArea(Composite parent) {
text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.NO_FOCUS);
text.setText(contents);
return text;
}
protected void adjustBounds() {
super.adjustBounds();
// Point pt = getShell().getDisplay().getCursorLocation();
// getShell().setBounds(pt.x,pt.y,rectangle.width,rectangle.height);
}
/**
* Method to set the text contents of the InfoPop dialog
*
* @param textContents
* of type String indicating the message
*/
public void setText(String textContents) {
this.contents = textContents;
}
protected Control createTitleMenuArea(Composite arg0) {
Control ctrl = super.createTitleMenuArea(arg0);
Composite composite = (Composite) ctrl;
Control[] ctrls = composite.getChildren();
ToolBar toolBar = (ToolBar) ctrls[1];
ToolItem[] toolItems = toolBar.getItems();
toolItems[0].setImage(Display.getDefault().getSystemImage(SWT.ICON_WARNING));
return ctrl;
}
}
相關問題
- 1. 彈出窗口塊在Eclipse
- 2. Eclipse彈出窗口javadoc
- 3. 彈出窗口:當彈出彈出窗口時關閉彈出
- 4. 如何停止Eclipse彈出窗口?
- 5. Eclipse未顯示屬性彈出窗口
- 6. Eclipse RCP SWT問題彈出窗口
- 7. 彈出窗口
- 8. Android彈出窗口在彈出窗口外彈出時解僱
- 9. Eclipse ADT自動彈出彈出窗口時崩潰
- 10. 彈出式彈性窗口
- 11. 退出彈出式窗口與彈出式窗口
- 12. ie8彈出窗口
- 13. Javascript彈出窗口
- 14. 彈出窗口programmaticall
- 15. mvc彈出窗口
- 16. Javascript彈出窗口
- 17. javascript彈出窗口
- 18. mozilla彈出窗口
- 19. Android:彈出窗口
- 20. vb.net彈出窗口
- 21. PyQt5彈出窗口
- 22. 彈出Kendo窗口
- 23. PHP:彈出窗口
- 24. Selenium - 彈出窗口
- 25. Python:PyQt彈出窗口
- 26. Android彈出窗口
- 27. Ajax彈出窗口
- 28. android彈出窗口
- 29. 彈出窗口內
- 30. Javascript彈出窗口
鑑於全球環境基金的情況下,我不認爲有一個'ITextViewer'介入,所以'IInformationPresenter'可能不能在這裏使用。 – p12t 2012-04-18 08:37:30