本文整理汇总了Java中org.eclipse.ui.IWorkbench.getActiveWorkbenchWindow方法的典型用法代码示例。如果您正苦于以下问题:Java IWorkbench.getActiveWorkbenchWindow方法的具体用法?Java IWorkbench.getActiveWorkbenchWindow怎么用?Java IWorkbench.getActiveWorkbenchWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IWorkbench
的用法示例。
在下文中一共展示了IWorkbench.getActiveWorkbenchWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench==null){
return null;
}
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow==null){
return null;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage==null){
return null;
}
IEditorPart editor = activePage.getActiveEditor();
if (editor instanceof BatchEditor){
executeOnBatchEditor((BatchEditor) editor);
}
return null;
}
示例2: getEditor
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
protected AvroSchemaEditor getEditor() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage workbenchPage = window.getActivePage();
if (workbenchPage != null) {
IWorkbenchPart activePart = workbenchPage.getActivePart();
if (activePart instanceof IWithAvroSchemaEditor) {
return ((IWithAvroSchemaEditor) activePart).getEditor();
}
}
}
return null;
}
示例3: execute
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench==null){
return null;
}
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow==null){
return null;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage==null){
return null;
}
IEditorPart editor = activePage.getActiveEditor();
if (editor instanceof BashEditor){
executeOnBashEditor((BashEditor) editor);
}
return null;
}
示例4: search
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
protected void search(String pattern, SearchType type, boolean withRef) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
IEditorPart editorPart = workbenchPage.getActiveEditor();
if (editorPart instanceof IWithAvroSchemaEditor) {
AvroSchemaEditor schemaEditor = ((IWithAvroSchemaEditor) editorPart).getEditor();
AvroContext masterContext = schemaEditor.getContext().getMaster();
SearchNodeContext searchNodeContext = masterContext.getSearchNodeContext();
if (pattern == null || pattern.trim().isEmpty()) {
searchNodeContext.reset();
} else if (searchNodeContext.searchNodes(type, pattern, withRef)) {
AvroNode node = searchNodeContext.next();
schemaEditor.getContentPart()
.getSchemaViewer(AvroContext.Kind.MASTER)
.setSelection(new StructuredSelection(node), true);
}
refreshCommands(editorPart, SearchNodePropertyTester.PROPERTIES);
}
}
示例5: unsafeGetWorkbenchPage
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
static private final IWorkbenchPage unsafeGetWorkbenchPage() {
IWorkbenchPage page = null;
if (PlatformUI.isWorkbenchRunning()) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
page = win.getActivePage();
}
return page;
}
示例6: getActivePage
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
/***/
@SuppressWarnings("restriction")
protected IWorkbenchPage getActivePage() {
IWorkbenchPage page = null;
if (org.eclipse.ui.internal.Workbench.getInstance() != null) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
// Could be null if using Timeout test rule and does not run on main thread.
if (null != window) {
page = window.getActivePage();
}
}
return page;
}
示例7: getActiveWorkbenchWindow
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
/**
* Returns the active workbench window.
* @return the active workbench window
*/
public IWorkbenchWindow getActiveWorkbenchWindow() {
IWorkbench iwb = this.getWorkbench();
if (iwb!=null) {
return iwb.getActiveWorkbenchWindow();
}
return null;
}
示例8: getActiveWorkbenchShell
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
/**
* Returns active workbench shell - or <code>null</code>
*
* @return active workbench shell - or <code>null</code>
*/
public static Shell getActiveWorkbenchShell() {
IWorkbench workbench = getWorkbench();
if (workbench == null) {
return null;
}
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window == null) {
return null;
}
Shell shell = window.getShell();
return shell;
}
示例9: getActiveWorkbenchWindow
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
public static IWorkbenchWindow getActiveWorkbenchWindow() {
IWorkbench workbench = getWorkbench();
if (workbench == null) {
return null;
}
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
if (workbenchWindow != null) {
return workbenchWindow;
}
/* fall back - try to execute in UI */
WorkbenchWindowRunnable wwr = new WorkbenchWindowRunnable();
getSafeDisplay().syncExec(wwr);
return wwr.workbenchWindowFromUI;
}
示例10: run
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
@Override
public void run() {
IWorkbench workbench = getWorkbench();
if (workbench == null) {
return;
}
workbenchWindowFromUI = workbench.getActiveWorkbenchWindow();
}
示例11: addListeners
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
public void addListeners() {
try {
IWorkbench workbench = PlatformUI.getWorkbench();
// Add a WorkbenchListener
workbenchListener = new ConvertigoWorkbenchListener();
workbench.addWorkbenchListener(workbenchListener);
// Add a WindowListener
windowListener = new ConvertigoWindowListener();
workbench.addWindowListener(windowListener);
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
// Add a PerspectiveListener
if (perspectiveListener == null) {
perspectiveListener = new ConvertigoPerspectiveListener();
activeWorkbenchWindow.addPerspectiveListener(perspectiveListener);
}
// Add a PartListener
if (partListener == null) {
partListener = new ConvertigoPartListener();
IPartService partService = activeWorkbenchWindow.getPartService();
partService.addPartListener(partListener);
}
}
}
catch (IllegalStateException e) {
studioLog.error("Could not add listeners to plugin."+ e.getMessage());
}
}
示例12: clean
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
/**
* Clean plug-in
*
* @param context
* @throws Exception
*/
private void clean(BundleContext context) throws Exception {
if (consolePipes != null)
consolePipes.stopConsoleThreads();
stderrConsoleStreamColor.dispose();
disposeImages();
cacheIProject.clear();
// Removes listeners
try {
IWorkbench workbench = PlatformUI.getWorkbench();
if (windowListener != null)
workbench.removeWindowListener(windowListener);
if (workbenchListener != null)
workbench.removeWorkbenchListener(workbenchListener);
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
if (perspectiveListener != null)
activeWorkbenchWindow.removePerspectiveListener(perspectiveListener);
if (partListener != null)
activeWorkbenchWindow.getPartService().removePartListener(partListener);
}
}
catch (IllegalStateException e) {}
if (embeddedTomcat != null)
embeddedTomcat.stop();
}
示例13: getActivePage
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
/**
* @return IWorkbenchPage
*/
public static IWorkbenchPage getActivePage() {
try {
if (!PlatformUI.isWorkbenchRunning()) return null;
} catch (Exception | NoClassDefFoundError ne) {
return null;
}
final IWorkbench bench = PlatformUI.getWorkbench();
if (bench==null) return null;
final IWorkbenchWindow window = bench.getActiveWorkbenchWindow();
if (window==null) return null;
return window.getActivePage();
}
示例14: getActivePage
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
/**
* @return IWorkbenchPage
*/
public static IWorkbenchPage getActivePage() {
final IWorkbench bench = PlatformUI.getWorkbench();
if (bench==null) return null;
final IWorkbenchWindow window = bench.getActiveWorkbenchWindow();
if (window==null) return null;
return window.getActivePage();
}
示例15: resetWorkbench
import org.eclipse.ui.IWorkbench; //导入方法依赖的package包/类
private void resetWorkbench() {
try {
IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (IViewReference iViewReference : views) {
if ( iViewReference.getTitle().equals( "Welcome" ) ) {
iViewReference.getPage().hideView(iViewReference);
break;
}
}
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
Shell activeShell = Display.getCurrent().getActiveShell();
if ( activeShell != null && activeShell != workbenchWindow.getShell() ) {
activeShell.close();
}
page.closeAllEditors( false );
page.resetPerspective();
String defaultPerspectiveId = workbench.getPerspectiveRegistry().getDefaultPerspective();
workbench.showPerspective( defaultPerspectiveId, workbenchWindow );
page.resetPerspective();
}
catch ( WorkbenchException e ) {
throw new RuntimeException( e );
}
}