Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-05-03 16:09:48 -0400
committerJean Michel-Lemieux2004-05-03 16:09:48 -0400
commit7e24e804698c2c982e6c0d16cc43ed892e3aa705 (patch)
tree906571a69cf178650034a7b8d310c13940688be9
parent2bb45abd9c09aed24098c1c0042e9caeb1b2973b (diff)
downloadeclipse.platform.team-7e24e804698c2c982e6c0d16cc43ed892e3aa705.tar.gz
eclipse.platform.team-7e24e804698c2c982e6c0d16cc43ed892e3aa705.tar.xz
eclipse.platform.team-7e24e804698c2c982e6c0d16cc43ed892e3aa705.zip
Keybinding support in synchronize pages. Currently only view bindings work
and will have to debug why dialog bindings aren't working.
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java14
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java83
5 files changed, 81 insertions, 35 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
index f0b430a15..d5e209f32 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
@@ -74,6 +74,7 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor {
ISynchronizeParticipant participant = configuration.getParticipant();
ISynchronizePageSite site = configuration.getSite();
+
gotoNext = new NavigateAction(site, participant.getName(), configuration, true /*next*/);
gotoPrevious = new NavigateAction(site, participant.getName(), configuration, false /*previous*/);
}
@@ -230,7 +231,7 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor {
super(configuration);
INavigatable nav = (INavigatable)configuration.getProperty(SynchronizePageConfiguration.P_NAVIGATOR);
if (nav == null) {
- configuration.setProperty(SynchronizePageConfiguration.P_NAVIGATOR, this);
+ configuration.setProperty(SynchronizePageConfiguration.P_NAVIGATOR, getAdapter(INavigatable.class));
}
configuration.addActionContribution(new NavigationActionGroup());
StructuredViewer viewer = TreeViewerAdvisor.createViewer(parent, configuration);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java
index 1951c539e..254475c0d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java
@@ -24,6 +24,7 @@ public class WorkbenchPartSynchronizePageSite implements ISynchronizePageSite {
private IWorkbenchPart part;
private IDialogSettings settings;
private IPageSite site;
+ private IActionBars actionBars;
public WorkbenchPartSynchronizePageSite(IWorkbenchPart part, IPageSite site, IDialogSettings settings) {
this.part = part;
@@ -86,4 +87,11 @@ public class WorkbenchPartSynchronizePageSite implements ISynchronizePageSite {
public IDialogSettings getPageSettings() {
return settings;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ISynchronizePageSite#getActionBars()
+ */
+ public IActionBars getActionBars() {
+ return site.getActionBars();
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
index 2bce4624c..fd1c983e3 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
@@ -43,19 +43,15 @@ public class NavigateAction extends Action {
this.title = title;
this.configuration = configuration;
this.next = next;
- IWorkbenchSite workbenchSite = site.getWorkbenchSite();
- IViewSite viewSite = null;
- if (workbenchSite instanceof IViewSite) {
- viewSite = (IViewSite)workbenchSite;
- }
+ IActionBars bars = site.getActionBars();
if (next) {
Utils.initAction(this, "action.navigateNext."); //$NON-NLS-1$
- if (viewSite != null)
- viewSite.getActionBars().setGlobalActionHandler(ActionFactory.NEXT.getId(), this);
+ if (bars != null)
+ bars.setGlobalActionHandler(ActionFactory.NEXT.getId(), this);
} else {
Utils.initAction(this, "action.navigatePrevious."); //$NON-NLS-1$
- if (viewSite != null)
- viewSite.getActionBars().setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), this);
+ if (bars != null)
+ bars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), this);
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java
index 569ef4f05..7d1b18646 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizePageSite.java
@@ -90,5 +90,11 @@ public interface ISynchronizePageSite {
* @return a settings node or <code>null</code>
*/
IDialogSettings getPageSettings();
-
+
+ /**
+ * Returns the action bars for this synchronize page site.
+ *
+ * @return the action bars
+ */
+ IActionBars getActionBars();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java
index f168f8672..9fce66b32 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java
@@ -8,7 +8,9 @@
package org.eclipse.team.ui.synchronize;
import java.lang.reflect.InvocationTargetException;
+import java.util.*;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.compare.*;
import org.eclipse.compare.internal.CompareEditor;
import org.eclipse.compare.structuremergeviewer.*;
@@ -33,6 +35,9 @@ import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.*;
import org.eclipse.team.ui.SaveablePartAdapter;
import org.eclipse.ui.*;
+import org.eclipse.ui.commands.*;
+import org.eclipse.ui.commands.ActionHandler;
+import org.eclipse.ui.commands.HandlerSubmission;
import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.progress.IProgressService;
@@ -51,6 +56,7 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
private IPageBookViewPage page;
private Image titleImage;
private Shell shell;
+ private Shell dialogShell;
// Tracking of dirty state
private boolean fDirty= false;
@@ -63,6 +69,11 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
private CompareViewerSwitchingPane fStructuredComparePane;
private Viewer viewer;
private Control control;
+
+ // Keybindings enabled in the dialog, these should be removed
+ // when the dialog is closed.
+ private IActionBars actionBars;
+ private List actionHandlers = new ArrayList(2);
/*
* Page site that allows hosting the participant page in a dialog.
@@ -78,7 +89,7 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
return viewer;
}
public Shell getShell() {
- return shell;
+ return dialogShell;
}
public IWorkbenchWindow getWorkbenchWindow() {
return null;
@@ -102,6 +113,9 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
}
public IDialogSettings getPageSettings() {
return null;
+ }
+ public IActionBars getActionBars() {
+ return ParticipantPageSaveablePart.this.getActionBars();
}
}
@@ -144,6 +158,11 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
if(titleImage != null) {
titleImage.dispose();
}
+ IWorkbenchCommandSupport cm = PlatformUI.getWorkbench().getCommandSupport();
+ for (Iterator it = actionHandlers.iterator(); it.hasNext();) {
+ HandlerSubmission handler = (HandlerSubmission) it.next();
+ cm.removeHandlerSubmission(handler);
+ }
super.dispose();
}
@@ -218,6 +237,8 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
parent.setLayout(layout);
parent.setLayoutData(data);
+ dialogShell = parent2.getShell();
+
Splitter vsplitter = new Splitter(parent, SWT.VERTICAL);
vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
// we need two panes: the left for the elements, the right one for the structured diff
@@ -239,6 +260,8 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
IPageBookViewPage page = participant.createPage(pageConfiguration);
((SynchronizePageConfiguration)pageConfiguration).setSite(new CompareViewerPaneSite());
+ ToolBarManager tbm = CompareViewerPane.getToolBarManager(fEditionPane);
+ createActionBars(tbm);
try {
((ISynchronizePage)page).init(pageConfiguration.getSite());
} catch (PartInitException e1) {
@@ -260,8 +283,7 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
initializeDiffViewer(((ISynchronizePage)page).getViewer());
}
- ToolBarManager tbm = CompareViewerPane.getToolBarManager(fEditionPane);
- page.setActionBars(getActionBars(tbm));
+ page.setActionBars(getActionBars());
fEditionPane.setContent(page.getControl());
tbm.update(true);
if(page instanceof ISynchronizePage) {
@@ -445,29 +467,42 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
boolean newDirty= fDirtyViewers.size() > 0;
}
- private IActionBars getActionBars(final IToolBarManager toolbar) {
- return new IActionBars() {
- public void clearGlobalActionHandlers() {
- }
- public IAction getGlobalActionHandler(String actionId) {
- return null;
- }
- public IMenuManager getMenuManager() {
- return null;
- }
- public IStatusLineManager getStatusLineManager() {
- return null;
- }
- public IToolBarManager getToolBarManager() {
- return toolbar;
- }
- public void setGlobalActionHandler(String actionId, IAction handler) {
- }
- public void updateActionBars() {
- }
- };
+ private void createActionBars(final IToolBarManager toolbar) {
+ if (actionBars == null) {
+ actionBars = new IActionBars() {
+ public void clearGlobalActionHandlers() {
+ }
+ public IAction getGlobalActionHandler(String actionId) {
+ return null;
+ }
+ public IMenuManager getMenuManager() {
+ return null;
+ }
+ public IStatusLineManager getStatusLineManager() {
+ return null;
+ }
+ public IToolBarManager getToolBarManager() {
+ return toolbar;
+ }
+ public void setGlobalActionHandler(String actionId, IAction action) {
+ IHandler handler = new ActionHandler(action);
+ HandlerSubmission handlerSubmission = new HandlerSubmission(null,
+ dialogShell, null, actionId, handler, Priority.MEDIUM);
+ PlatformUI.getWorkbench().getCommandSupport().addHandlerSubmission(handlerSubmission);
+ actionHandlers.add(handlerSubmission);
+ }
+
+ public void updateActionBars() {
+ }
+ };
+ }
}
+ private IActionBars getActionBars() {
+ return actionBars;
+ }
+
+
/**
* Return the synchronize page configiration for this part
* @return Returns the pageConfiguration.

Back to the top