Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-02-03 20:55:17 +0000
committerMichael Valenta2003-02-03 20:55:17 +0000
commite6104e4231ec6181ae64b44a37a9a1cd2517315e (patch)
tree6ad78414de3f56280c41bc3789f9f66f324e46ad
parent1d45a6b6666c843500e32dbfc1febd156e06a300 (diff)
downloadeclipse.platform.team-e6104e4231ec6181ae64b44a37a9a1cd2517315e.tar.gz
eclipse.platform.team-e6104e4231ec6181ae64b44a37a9a1cd2517315e.tar.xz
eclipse.platform.team-e6104e4231ec6181ae64b44a37a9a1cd2517315e.zip
21264: [CVS Sync View] Synchronize view opens in wrong window
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java20
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java14
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java15
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java12
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java36
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/SyncView.java37
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java14
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java13
12 files changed, 93 insertions, 90 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
index 5d2c843c4..b13a31dba 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
@@ -119,14 +119,15 @@ public class CVSUIPlugin extends AbstractUIPlugin implements IPropertyChangeList
}
/**
- * Returns the active workbench page.
+ * Returns the active workbench page. Note that the active page may not be
+ * the one that the usr perceives as active in some situations so this
+ * method of obtaining the activae page should only be used if no other
+ * method is available.
*
* @return the active workbench page
*/
public static IWorkbenchPage getActivePage() {
- IWorkbenchWindow window = getPlugin().getWorkbench().getActiveWorkbenchWindow();
- if (window == null) return null;
- return window.getActivePage();
+ return TeamUIPlugin.getActivePage();
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java
index 3899f46c9..7145027d6 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java
@@ -26,8 +26,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.team.internal.ccvs.core.EditorsInfo;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.ViewPart;
/**
@@ -42,24 +40,6 @@ public class EditorsView extends ViewPart {
private Table table;
private TableViewer tableViewer;
-
- /**
- * Makes the editors view visible in the active perspective. If there isn't
- * a editors view registered <code>null</code> is returned. Otherwise the
- * opened view part is returned.
- */
- public static EditorsView openInActivePerspective() {
- try {
-
- IWorkbenchPage page = CVSUIPlugin.getActivePage();
- if (page == null)
- return null;
- return (EditorsView)page.showView(VIEW_ID);
- } catch (PartInitException pe) {
- return null;
- }
- }
-
class EditorsContentProvider implements IStructuredContentProvider {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java
index 889f693a0..2440b520d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowEditorsAction.java
@@ -29,19 +29,16 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
*/
public class ShowEditorsAction extends WorkspaceAction {
- protected void execute(IAction action)
- throws InvocationTargetException, InterruptedException {
+ protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
final EditorsAction editorsAction = new EditorsAction();
run(new WorkspaceModifyOperation() {
-
public void execute(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
executeProviderAction(editorsAction, monitor);
}
- }, true /* cancelable */
- , PROGRESS_DIALOG);
+ }, true /* cancelable */ , PROGRESS_DIALOG);
EditorsInfo[] infos = editorsAction.getEditorsInfo();
- EditorsView view = EditorsView.openInActivePerspective();
+ EditorsView view = (EditorsView)showView(EditorsView.VIEW_ID);
if (view != null) {
view.setInput(infos);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java
index 537776247..91993cecf 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java
@@ -63,7 +63,7 @@ public class ShowHistoryAction extends CVSAction {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
ICVSRemoteFile[] files = getSelectedRemoteFiles();
- HistoryView view = HistoryView.openInActivePerspective();
+ HistoryView view = (HistoryView)showView(HistoryView.VIEW_ID);
if (view != null) {
view.showHistory(files[0], null /* no current revision */);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
index 7c86f4827..91b770da4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
@@ -30,7 +30,7 @@ public class ShowResourceInHistoryAction extends WorkspaceAction {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
IResource[] resources = getSelectedResources();
if (resources.length != 1) return;
- HistoryView view = HistoryView.openInActivePerspective();
+ HistoryView view = (HistoryView)showView(HistoryView.VIEW_ID);
if (view != null) {
view.showHistory(resources[0]);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
index 43d104932..44d61b2b4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
@@ -14,11 +14,9 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
import org.eclipse.team.internal.ui.sync.SyncCompareInput;
import org.eclipse.team.internal.ui.sync.SyncView;
-import org.eclipse.ui.PartInitException;
/**
* Action for catchup/release in popup menus.
@@ -28,17 +26,9 @@ public class SyncAction extends WorkspaceAction {
public void execute(IAction action) {
IResource[] resources = getResourcesToSync();
if (resources == null || resources.length == 0) return;
- SyncView view = (SyncView)CVSUIPlugin.getActivePage().findView(SyncView.VIEW_ID);
- if (view == null) {
- view = SyncView.findInActivePerspective();
- }
+ SyncView view = SyncView.findViewInActivePage(getTargetPage());
if (view != null) {
- try {
- CVSUIPlugin.getActivePage().showView(SyncView.VIEW_ID);
- } catch (PartInitException e) {
- CVSUIPlugin.log(e.getStatus());
- }
- view.showSync(getCompareInput(resources));
+ view.showSync(getCompareInput(resources), getTargetPage());
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
index bfdf8af26..fd1e87649 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
@@ -48,7 +48,7 @@ import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareUnsharedInput;
import org.eclipse.team.internal.ui.sync.SyncView;
import org.eclipse.team.ui.IConfigurationWizard;
import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.IWorkbenchPage;
/**
* This wizard helps the user to import a new project in their workspace
@@ -268,16 +268,9 @@ public class SharingWizard extends Wizard implements IConfigurationWizard {
});
if (doSync[0]) {
// Sync of the project
- SyncView view = (SyncView)CVSUIPlugin.getActivePage().findView(SyncView.VIEW_ID);
- if (view == null) {
- view = SyncView.findInActivePerspective();
- }
+ IWorkbenchPage activePage = null; /* not sure how to get the active page */
+ SyncView view = SyncView.findViewInActivePage(activePage);
if (view != null) {
- try {
- CVSUIPlugin.getActivePage().showView(SyncView.VIEW_ID);
- } catch (PartInitException e) {
- CVSUIPlugin.log(e.getStatus());
- }
CVSSyncCompareInput input;
if (projectExists[0]) {
try {
@@ -306,7 +299,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard {
} else {
input = new CVSSyncCompareInput(new IResource[] {project});
}
- view.showSync(input);
+ view.showSync(input, activePage);
}
}
} catch (InterruptedException e) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
index 173b832fa..df169f381 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
@@ -28,6 +28,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
@@ -83,14 +84,21 @@ public class TeamUIPlugin extends AbstractUIPlugin {
return ret[0];
}
}
+
/**
- * Convenience method to get the currently active workbench page
+ * Convenience method to get the currently active workbench page. Note that
+ * the active page may not be the one that the usr perceives as active in
+ * some situations so this method of obtaining the activae page should only
+ * be used if no other method is available.
*
* @return the active workbench page
*/
public static IWorkbenchPage getActivePage() {
- return getPlugin().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchWindow window = getPlugin().getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) return null;
+ return window.getActivePage();
}
+
/**
* Return the default instance of the receiver. This represents the runtime plugin.
*
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
index 61d753670..74b1f6363 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
@@ -36,7 +36,10 @@ import org.eclipse.team.internal.core.target.TargetProvider;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionDelegate;
/**
@@ -60,6 +63,8 @@ public abstract class TeamAction extends ActionDelegate implements IObjectAction
public final static int PROGRESS_DIALOG = 1;
public final static int PROGRESS_BUSYCURSOR = 2;
+ private IWorkbenchPart targetPart;
+
/**
* Returns the selected projects.
*
@@ -220,6 +225,7 @@ public abstract class TeamAction extends ActionDelegate implements IObjectAction
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
this.shell = targetPart.getSite().getShell();
+ this.targetPart = targetPart;
}
/**
* Shows the given errors to the user.
@@ -348,4 +354,34 @@ public abstract class TeamAction extends ActionDelegate implements IObjectAction
}
return result;
}
+
+ /**
+ * @return IWorkbenchPart
+ */
+ protected IWorkbenchPart getTargetPart() {
+ return targetPart;
+ }
+
+ /**
+ * Return the path that was active when the menu item was selected.
+ * @return IWorkbenchPage
+ */
+ protected IWorkbenchPage getTargetPage() {
+ return getTargetPart().getSite().getPage();
+ }
+
+ /**
+ * Show the view with the given ID in the perspective from which the action
+ * was executed. Returns null if the view is not registered.
+ *
+ * @param viewId
+ * @return IViewPart
+ */
+ protected IViewPart showView(String viewId) {
+ try {
+ return getTargetPage().showView(viewId);
+ } catch (PartInitException pe) {
+ return null;
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/SyncView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/SyncView.java
index 065cbf826..744f8eb07 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/SyncView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/SyncView.java
@@ -37,6 +37,7 @@ import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.help.WorkbenchHelp;
@@ -113,6 +114,8 @@ public class SyncView extends ViewPart {
private IPartListener partListener;
+ private boolean initialized = false;
+
/**
* Creates a new view.
*/
@@ -145,6 +148,7 @@ public class SyncView extends ViewPart {
partListener = new PartListener();
getViewSite().getWorkbenchWindow().getPartService().addPartListener(partListener);
WorkbenchHelp.setHelp(top, IHelpContextIds.SYNC_VIEW);
+ initialized = true;
}
public void dispose() {
@@ -155,18 +159,21 @@ public class SyncView extends ViewPart {
}
super.dispose();
}
-
+
/**
- * Makes the sync view visible in the active perspective. If there
- * isn't a sync view registered <code>null</code> is returned.
- * Otherwise the opened view part is returned.
+ * Makes the sync view visible in the active page. If there isn't a sync
+ * view registered <code>null</code> is returned. Otherwise the opened view
+ * part is returned.
*/
- public static SyncView findInActivePerspective() {
+ public static SyncView findViewInActivePage(IWorkbenchPage activePage) {
try {
- IViewPart part = TeamUIPlugin.getActivePage().findView(VIEW_ID);
- if (part == null) {
- part = TeamUIPlugin.getActivePage().showView(VIEW_ID);
+ if (activePage == null) {
+ activePage = TeamUIPlugin.getActivePage();
+ if (activePage == null) return null;
}
+ IViewPart part = activePage.findView(VIEW_ID);
+ if (part == null || !((SyncView)part).initialized)
+ part = activePage.showView(VIEW_ID);
return (SyncView)part;
} catch (PartInitException pe) {
return null;
@@ -316,8 +323,19 @@ public class SyncView extends ViewPart {
/**
* Shows synchronization information for the given resources in the sync view.
+ * @deprecated
*/
public void showSync(SyncCompareInput input) {
+ showSync(input, null);
+ }
+
+ /**
+ * Shows synchronization information for the given resources in the sync
+ * view.
+ * @param input the diff tree to be displayed
+ * @param page the page on which to open the sync view
+ */
+ public void showSync(SyncCompareInput input, IWorkbenchPage page) {
next.setCompareEditorInput(input);
previous.setCompareEditorInput(input);
IActionBars actionBars = getViewSite().getActionBars();
@@ -394,7 +412,8 @@ public class SyncView extends ViewPart {
}
// Reveal if fast view
try {
- TeamUIPlugin.getActivePage().showView(VIEW_ID);
+ if (page == null) page = TeamUIPlugin.getActivePage();
+ if (page != null) page.showView(VIEW_ID);
} catch (PartInitException e) {
TeamUIPlugin.log(e.getStatus());
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java
index e36174ebe..09c296fc5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java
@@ -11,11 +11,9 @@ import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.core.target.TargetManager;
import org.eclipse.team.internal.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.team.internal.ui.sync.SyncCompareInput;
import org.eclipse.team.internal.ui.sync.SyncView;
-import org.eclipse.ui.PartInitException;
/**
* Action for catchup/release in popup menus.
@@ -24,17 +22,9 @@ public class SyncAction extends TeamAction {
public void run(IAction action) {
IResource[] resources = getSelectedResources();
- SyncView view = (SyncView)TeamUIPlugin.getActivePage().findView(SyncView.VIEW_ID);
- if (view == null) {
- view = SyncView.findInActivePerspective();
- }
+ SyncView view = SyncView.findViewInActivePage(getTargetPage());
if (view != null) {
- try {
- TeamUIPlugin.getActivePage().showView(SyncView.VIEW_ID);
- } catch (PartInitException e) {
- TeamUIPlugin.log(e.getStatus());
- }
- view.showSync(getCompareInput(resources));
+ view.showSync(getCompareInput(resources), getTargetPage());
}
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java
index f8128b715..db00ef6f9 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSUITestCase.java
@@ -56,7 +56,6 @@ import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchException;
@@ -317,17 +316,7 @@ public class CVSUITestCase extends LoggingTestCase {
* Gets an instance of the Synchronize view
*/
protected SyncView getSyncView() {
- SyncView view = (SyncView)CVSUIPlugin.getActivePage().findView(SyncView.VIEW_ID);
- if (view == null) {
- view = SyncView.findInActivePerspective();
- }
- if (view != null) {
- try {
- CVSUIPlugin.getActivePage().showView(SyncView.VIEW_ID);
- } catch (PartInitException e) {
- CVSUIPlugin.log(e.getStatus());
- }
- }
+ SyncView view = SyncView.findViewInActivePage(null);
assertNotNull("Could not obtain a Sync View.", view);
return view;
}

Back to the top