Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-05-06 11:13:12 -0400
committerMichael Valenta2004-05-06 11:13:12 -0400
commit91228497121292b52dc61ebf6a5c790d11532dcb (patch)
treed6de7bd1bc70925e5fba24b8b10b59788d749a37
parent9b4f2e6cd3263be03c15d47f775f12af586549fb (diff)
downloadeclipse.platform.team-91228497121292b52dc61ebf6a5c790d11532dcb.tar.gz
eclipse.platform.team-91228497121292b52dc61ebf6a5c790d11532dcb.tar.xz
eclipse.platform.team-91228497121292b52dc61ebf6a5c790d11532dcb.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java18
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java33
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java23
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java38
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java103
9 files changed, 164 insertions, 72 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java
index bfa265324..853ddd1e9 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantAction.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.subscriber;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
@@ -25,6 +26,11 @@ public abstract class CVSParticipantAction extends SynchronizeModelAction {
super(null, configuration);
Utils.initAction(this, getBundleKeyPrefix(), Policy.getBundle());
}
+
+ protected CVSParticipantAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) {
+ super(null, configuration, provider);
+ Utils.initAction(this, bundleKey, Policy.getBundle());
+ }
/**
* Return the key to the action text in the resource bundle.
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java
index 932037678..043766631 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java
@@ -30,7 +30,6 @@ import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.actions.ShowAnnotationAction;
import org.eclipse.team.internal.ccvs.ui.actions.ShowResourceInHistoryAction;
import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
@@ -63,14 +62,10 @@ public class MergeSynchronizeParticipant extends CVSParticipant {
public void initialize(ISynchronizePageConfiguration configuration) {
super.initialize(configuration);
- updateAction = new MergeUpdateAction(configuration) {
- protected void initialize(ISynchronizePageConfiguration configuration) {
- // Override to avoid registering a selection listener
- }
- protected String getBundleKeyPrefix() {
- return "WorkspaceToolbarUpdateAction."; //$NON-NLS-1$
- }
- };
+ updateAction = new MergeUpdateAction(
+ configuration,
+ getVisibleRootsSelectionProvider(),
+ "WorkspaceToolbarUpdateAction."); //$NON-NLS-1$
updateAction.setPromptBeforeUpdate(true);
appendToGroup(
ISynchronizePageConfiguration.P_TOOLBAR_MENU,
@@ -98,11 +93,6 @@ public class MergeSynchronizeParticipant extends CVSParticipant {
}
}
- public void modelChanged(ISynchronizeModelElement input) {
- if (updateAction != null) {
- updateAction.setSelection(input);
- }
- }
}
public MergeSynchronizeParticipant() {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
index 15811ac00..2a1cd7045 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
@@ -11,6 +11,7 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.OrSyncInfoFilter;
@@ -25,6 +26,10 @@ public class MergeUpdateAction extends CVSParticipantAction {
super(configuration);
}
+ public MergeUpdateAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) {
+ super(configuration, provider, bundleKey);
+ }
+
private boolean promptBeforeUpdate;
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java
index d8aa8da25..e1bc49fc4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java
@@ -11,6 +11,7 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
@@ -23,6 +24,10 @@ public class WorkspaceCommitAction extends CVSParticipantAction {
super(configuration);
}
+ public WorkspaceCommitAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) {
+ super(configuration, provider, bundleKey);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter()
*/
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
index b12f5b097..e6deff927 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
@@ -17,7 +17,6 @@ import org.eclipse.team.internal.ccvs.ui.actions.GenerateDiffFileAction;
import org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction;
import org.eclipse.team.internal.ccvs.ui.actions.ShowAnnotationAction;
import org.eclipse.team.internal.ccvs.ui.actions.ShowResourceInHistoryAction;
-import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
import org.eclipse.ui.IMemento;
@@ -48,28 +47,20 @@ public class WorkspaceSynchronizeParticipant extends CVSParticipant {
public void initialize(ISynchronizePageConfiguration configuration) {
super.initialize(configuration);
- updateToolbar = new WorkspaceUpdateAction(configuration) {
- protected void initialize(ISynchronizePageConfiguration configuration) {
- // Override to prevent registering as a selection listener
- }
- protected String getBundleKeyPrefix() {
- return "WorkspaceToolbarUpdateAction."; //$NON-NLS-1$
- }
- };
+ updateToolbar = new WorkspaceUpdateAction(
+ configuration,
+ getVisibleRootsSelectionProvider(),
+ "WorkspaceToolbarUpdateAction."); //$NON-NLS-1$
updateToolbar.setPromptBeforeUpdate(true);
appendToGroup(
ISynchronizePageConfiguration.P_TOOLBAR_MENU,
TOOLBAR_CONTRIBUTION_GROUP,
updateToolbar);
- commitToolbar = new WorkspaceCommitAction(configuration) {
- protected void initialize(ISynchronizePageConfiguration configuration) {
- // Override to prevent registering as a selection listener
- }
- protected String getBundleKeyPrefix() {
- return "WorkspaceToolbarCommitAction."; //$NON-NLS-1$
- }
- };
+ commitToolbar = new WorkspaceCommitAction(
+ configuration,
+ getVisibleRootsSelectionProvider(),
+ "WorkspaceToolbarCommitAction."); //$NON-NLS-1$
appendToGroup(
ISynchronizePageConfiguration.P_TOOLBAR_MENU,
TOOLBAR_CONTRIBUTION_GROUP,
@@ -122,14 +113,6 @@ public class WorkspaceSynchronizeParticipant extends CVSParticipant {
CONTEXT_MENU_CONTRIBUTION_GROUP_4,
new RefreshDirtyStateAction(configuration));
}
- public void modelChanged(ISynchronizeModelElement element) {
- if (commitToolbar != null) {
- commitToolbar.setSelection(element);
- }
- if (updateToolbar != null) {
- updateToolbar.setSelection(element);
- }
- }
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java
index fe4d57930..282422d6b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java
@@ -11,6 +11,7 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
@@ -25,6 +26,10 @@ public class WorkspaceUpdateAction extends CVSParticipantAction {
super(configuration);
}
+ public WorkspaceUpdateAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String bundleKey) {
+ super(configuration, provider, bundleKey);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.sync.SubscriberAction#getSyncInfoFilter()
*/
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java
index 60057d774..4e9337169 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardPageActionGroup.java
@@ -11,6 +11,7 @@
package org.eclipse.team.internal.ccvs.ui.wizards;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
@@ -18,7 +19,6 @@ import org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction;
import org.eclipse.team.internal.ccvs.ui.subscriber.CVSActionDelegateWrapper;
import org.eclipse.team.internal.ccvs.ui.subscriber.CVSParticipantAction;
import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceCommitOperation;
-import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
@@ -36,14 +36,8 @@ public class SharingWizardPageActionGroup extends SynchronizePageActionGroup {
* Custom commit that includes outgoing and conflicting.
*/
class SharingCommitAction extends CVSParticipantAction {
- protected SharingCommitAction(ISynchronizePageConfiguration configuration) {
- super(configuration);
- }
- protected void initialize(ISynchronizePageConfiguration configuration) {
- // Override to avoid being registered as a selection listener
- }
- protected String getBundleKeyPrefix() {
- return "SharingCommitAction."; //$NON-NLS-1$
+ public SharingCommitAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider) {
+ super(configuration, provider, "SharingCommitAction."); //$NON-NLS-1$
}
protected FastSyncInfoFilter getSyncInfoFilter() {
return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING});
@@ -61,7 +55,9 @@ public class SharingWizardPageActionGroup extends SynchronizePageActionGroup {
super.initialize(configuration);
configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ACTION_GROUP);
- commitAction = new SharingCommitAction(configuration);
+ commitAction = new SharingCommitAction(
+ configuration,
+ getVisibleRootsSelectionProvider());
appendToGroup(
ISynchronizePageConfiguration.P_TOOLBAR_MENU,
ACTION_GROUP,
@@ -76,11 +72,4 @@ public class SharingWizardPageActionGroup extends SynchronizePageActionGroup {
}
});
}
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.presentation.ISynchronizeModelChangeListener#inputChanged(org.eclipse.team.ui.synchronize.presentation.SynchronizeModelProvider)
- */
- public void modelChanged(final ISynchronizeModelElement root) {
- commitAction.setSelection(root);
- }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java
index 7d7f82036..5cd23c2b2 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.events.DisposeEvent;
@@ -46,27 +47,41 @@ public abstract class SynchronizeModelAction extends BaseSelectionListenerAction
private ISynchronizePageConfiguration configuration;
/**
- * Create an action with the given text and configuration.
+ * Create an action with the given text and configuration. By default,
+ * the action registers for selection change with the selection provider
+ * from the configuration's site.
* @param text the action's text
* @param configuration the actions synchronize page configuration
*/
protected SynchronizeModelAction(String text, ISynchronizePageConfiguration configuration) {
+ this(text, configuration, configuration.getSite().getSelectionProvider());
+ }
+
+ /**
+ * Create an action with the given text and configuration. By default,
+ * the action registers for selection change with the given selection provider.
+ * @param text the action's text
+ * @param configuration the actions synchronize page configuration
+ * @param selectionProvider a selection provider
+ */
+ protected SynchronizeModelAction(String text, ISynchronizePageConfiguration configuration, ISelectionProvider selectionProvider) {
super(text);
this.configuration = configuration;
- initialize(configuration);
+ initialize(configuration, selectionProvider);
}
/**
- * Method invoked from the constructor when a configuration is provided.
+ * Method invoked from the constructor.
* The default implementation registers the action as a selection change
- * listener. Subclass may override.
+ * listener. Subclasses may override.
* @param configuration the synchronize page configuration
+ * @param selectionProvider a selection provider
*/
- protected void initialize(final ISynchronizePageConfiguration configuration) {
- configuration.getSite().getSelectionProvider().addSelectionChangedListener(this);
+ protected void initialize(final ISynchronizePageConfiguration configuration, final ISelectionProvider selectionProvider) {
+ selectionProvider.addSelectionChangedListener(this);
configuration.getPage().getViewer().getControl().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- configuration.getSite().getSelectionProvider().removeSelectionChangedListener(SynchronizeModelAction.this);
+ selectionProvider.removeSelectionChangedListener(SynchronizeModelAction.this);
}
});
}
@@ -174,13 +189,4 @@ public abstract class SynchronizeModelAction extends BaseSelectionListenerAction
public ISynchronizePageConfiguration getConfiguration() {
return configuration;
}
-
- /**
- * Set the selection of the action to the given object
- * @param input the selected object
- */
- public void setSelection(Object input) {
- IStructuredSelection selection = new StructuredSelection(input);
- selectionChanged(selection);
- }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java
index 778d35025..b51b04be4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java
@@ -16,10 +16,18 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.util.ListenerList;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionGroup;
@@ -64,8 +72,78 @@ public abstract class SynchronizePageActionGroup extends ActionGroup {
private ISynchronizePageConfiguration configuration;
private Map menuContributions = new HashMap();
+
+ private VisibleRootsSelectionProvider visibleRootSelectionProvider;
/**
+ * A selection provider whose selection is the root elements
+ * visible in the page. Selection changed events are sent out
+ * when the model roots change or their visible children change
+ */
+ private class VisibleRootsSelectionProvider extends SynchronizePageActionGroup implements ISelectionProvider {
+
+ private ListenerList selectionChangedListeners = new ListenerList();
+ private ISelection selection;
+
+ protected VisibleRootsSelectionProvider(ISynchronizeModelElement element) {
+ modelChanged(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#modelChanged(org.eclipse.team.ui.synchronize.ISynchronizeModelElement)
+ */
+ public void modelChanged(ISynchronizeModelElement root) {
+ if (root == null) {
+ setSelection(StructuredSelection.EMPTY);
+ } else {
+ setSelection(new StructuredSelection(root));
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ISelectionProvider.
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ISelectionProvider.
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.remove(listener);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ISelectionProvider.
+ */
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ISelectionProvider.
+ */
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ selectionChanged(new SelectionChangedEvent(this, getSelection()));
+ }
+
+ private void selectionChanged(final SelectionChangedEvent event) {
+ // pass on the notification to listeners
+ Object[] listeners = selectionChangedListeners.getListeners();
+ for (int i = 0; i < listeners.length; ++i) {
+ final ISelectionChangedListener l = (ISelectionChangedListener)listeners[i];
+ Platform.run(new SafeRunnable() {
+ public void run() {
+ l.selectionChanged(event);
+ }
+ });
+ }
+ }
+ }
+
+ /**
* Initialize the actions of this contribution.
* This method will be invoked once before any calls are
* made to <code>filleContextMenu</code> or <code>setActionBars</code>
@@ -78,6 +156,9 @@ public abstract class SynchronizePageActionGroup extends ActionGroup {
*/
public void initialize(ISynchronizePageConfiguration configuration) {
this.configuration = configuration;
+ if (visibleRootSelectionProvider != null) {
+ configuration.addActionContribution(visibleRootSelectionProvider);
+ }
}
/**
@@ -190,6 +271,28 @@ public abstract class SynchronizePageActionGroup extends ActionGroup {
internalAppendToGroup(menuId, groupId, item);
}
+ /**
+ * Return a selection provider whose selection includes all roots
+ * of the elements
+ * visible in the page. Selection change events are fired when the
+ * elements visible in the view change.
+ * @return a selection provider whgose selection is the roots of all
+ * elements visible in the page
+ */
+ protected ISelectionProvider getVisibleRootsSelectionProvider() {
+ if (visibleRootSelectionProvider == null) {
+ ISynchronizeModelElement root = null;
+ if (configuration != null) {
+ root = (ISynchronizeModelElement)configuration.getProperty(SynchronizePageConfiguration.P_MODEL);
+ }
+ visibleRootSelectionProvider = new VisibleRootsSelectionProvider(root);
+ if (configuration != null) {
+ configuration.addActionContribution(visibleRootSelectionProvider);
+ }
+ }
+ return visibleRootSelectionProvider;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/

Back to the top