本文整理匯總了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 );
}
}