下面列出了org.eclipse.ui.IWorkbenchPartSite#getShell ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Display getDisplay() {
XtextEditor editor = this.editor;
if (editor == null){
if(sourceViewer != null)
return sourceViewer.getControl().getDisplay();
return null;
}
IWorkbenchPartSite site = editor.getSite();
if (site == null)
return null;
Shell shell = site.getShell();
if (shell == null || shell.isDisposed())
return null;
Display display = shell.getDisplay();
if (display == null || display.isDisposed())
return null;
return display;
}
private Display getDisplay() {
XtextEditor editor = this.editor;
if (editor == null) {
if (sourceViewer != null) {
return sourceViewer.getControl().getDisplay();
}
return null;
}
IWorkbenchPartSite site = editor.getSite();
if (site == null) {
return null;
}
Shell shell = site.getShell();
if (shell == null || shell.isDisposed()) {
return null;
}
Display display = shell.getDisplay();
if (display == null || display.isDisposed()) {
return null;
}
return display;
}
/**
* Update the presentation.
*
* @param textPresentation the text presentation
* @param addedPositions the added positions
* @param removedPositions the removed positions
*/
private void updatePresentation(TextPresentation textPresentation, List<Position> addedPositions, List<Position> removedPositions) {
Runnable runnable= fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
if (runnable == null)
return;
JavaEditor editor= fEditor;
if (editor == null)
return;
IWorkbenchPartSite site= editor.getSite();
if (site == null)
return;
Shell shell= site.getShell();
if (shell == null || shell.isDisposed())
return;
Display display= shell.getDisplay();
if (display == null || display.isDisposed())
return;
display.asyncExec(runnable);
}
private Shell getShell() {
ITextEditor editor = getTextEditor();
if (editor != null) {
IWorkbenchPartSite site = editor.getSite();
Shell shell = site.getShell();
if (shell != null && !shell.isDisposed()) {
return shell;
}
}
return null;
}
public static Shell getActivePartShell() {
IWorkbenchPage activePage = WorkbenchUtils.getActivePage();
if (activePage == null) {
return null;
}
IWorkbenchPart activePart = activePage.getActivePart();
if (activePart == null) {
return null;
}
IWorkbenchPartSite site = activePart.getSite();
if (site == null) {
return null;
}
return site.getShell();
}
private Shell getShell() {
ITextEditor editor= getTextEditor();
if (editor != null) {
IWorkbenchPartSite site= editor.getSite();
Shell shell= site.getShell();
if (shell != null && !shell.isDisposed()) {
return shell;
}
}
return null;
}
public void format() {
Display display = null;
IWorkbenchPartSite site = getSite();
Shell shell = site.getShell();
if (shell != null && !shell.isDisposed())
display = shell.getDisplay();
BusyIndicator.showWhile(display, new Runnable() {
public void run() {
doFormat();
}
});
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
IWorkbenchPartSite site= targetPart.getSite();
fShell= site != null ? site.getShell() : null;
}