aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2012-05-19 06:11:58 (EDT)
committerMariot Chauvin2012-05-23 04:46:14 (EDT)
commit6276f573e6ac138eabfe971a37e9b30f0e5ba0da (patch)
tree1d12e4c79638c83017bfb43c7ca90af8d79485e8
parent8568f5ebaa61900f8759713e9c353a4e6afd679b (diff)
downloadorg.eclipse.swtbot-6276f573e6ac138eabfe971a37e9b30f0e5ba0da.zip
org.eclipse.swtbot-6276f573e6ac138eabfe971a37e9b30f0e5ba0da.tar.gz
org.eclipse.swtbot-6276f573e6ac138eabfe971a37e9b30f0e5ba0da.tar.bz2
Remove the use of internal
This commit removes the use of internal platform API, in order to be fully compatible with Eclipse 4.2.
-rw-r--r--org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/finders/ViewMenuFinder.java19
-rw-r--r--org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java23
2 files changed, 27 insertions, 15 deletions
diff --git a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/finders/ViewMenuFinder.java b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/finders/ViewMenuFinder.java
index fc54120..309ebad 100644
--- a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/finders/ViewMenuFinder.java
+++ b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/finders/ViewMenuFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2012 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.SubContributionItem;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotViewMenu;
@@ -23,9 +24,8 @@ import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.ListResult;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.internal.ViewPane;
-import org.eclipse.ui.internal.WorkbenchPartReference;
import org.eclipse.ui.menus.CommandContributionItem;
import org.hamcrest.Matcher;
@@ -62,13 +62,14 @@ public class ViewMenuFinder {
return UIThreadRunnable.syncExec(new ListResult<SWTBotViewMenu>() {
public List<SWTBotViewMenu> run() {
- ViewPane viewPane = (ViewPane) ((WorkbenchPartReference) view).getPane();
- MenuManager mgr = viewPane.getMenuManager();
List<SWTBotViewMenu> l = new ArrayList<SWTBotViewMenu>();
-
- l.addAll(getMenuItemsInternal(mgr.getItems(), matcher, recursive));
-
- return l;
+ IViewPart viewPart = view.getView(false);
+ if (viewPart == null) {
+ return l;
+ }
+ IMenuManager viewMenuManager = viewPart.getViewSite().getActionBars().getMenuManager();
+ l.addAll(getMenuItemsInternal(viewMenuManager.getItems(), matcher, recursive));
+ return l;
}
});
}
diff --git a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java
index ea40c46..cba2767 100644
--- a/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java
+++ b/org.eclipse.swtbot.eclipse.finder/src/org/eclipse/swtbot/eclipse/finder/widgets/SWTBotWorkbenchPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2009 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2012 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,6 +16,8 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ToolBar;
@@ -38,9 +40,10 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarPushButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarRadioButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarSeparatorButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton;
+import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.internal.PartPane;
import org.eclipse.ui.internal.WorkbenchPartReference;
import org.hamcrest.Matcher;
import org.hamcrest.SelfDescribing;
@@ -137,11 +140,19 @@ public abstract class SWTBotWorkbenchPart<T extends IWorkbenchPartReference> {
public List<SWTBotToolbarButton> getToolbarButtons() {
return UIThreadRunnable.syncExec(new ListResult<SWTBotToolbarButton>() {
- public List<SWTBotToolbarButton> run() {
- PartPane obj = ((WorkbenchPartReference) partReference).getPane();
- ToolBar toolbar = (ToolBar) obj.getToolBar();
+ public List<SWTBotToolbarButton> run() {
+ ToolBar toolbar = null;
+
+ IWorkbenchPartSite site = partReference.getPart(false).getSite();
+ if (site instanceof IViewSite) {
+ IToolBarManager t = ((IViewSite) site).getActionBars().getToolBarManager();
+ if (t instanceof ToolBarManager) {
+ toolbar = ((ToolBarManager)t).getControl();
+ }
+ }
+
final List<SWTBotToolbarButton> l = new ArrayList<SWTBotToolbarButton>();
-
+
if (toolbar == null)
return l;