Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-18 14:53:52 -0500
committerMichael Valenta2006-01-18 14:53:52 -0500
commitced45af7b50990a19c75e537dcf022c9a4ba6112 (patch)
tree375c29438841363c10373e3714efe06c7e5cd8a9
parent8ffd1dace0bb70b861442525f1bbd1654b13c5e3 (diff)
downloadeclipse.platform.team-branch_20060117_ModelActions.tar.gz
eclipse.platform.team-branch_20060117_ModelActions.tar.xz
eclipse.platform.team-branch_20060117_ModelActions.zip
Refactoring to make default handlers available to modelsbranch_20060117_ModelActions
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/MergeAction.java17
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java19
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java15
3 files changed, 34 insertions, 17 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/MergeAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/MergeAction.java
index 65bcf4576..04f28c8c0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/MergeAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/MergeAction.java
@@ -16,9 +16,8 @@ import org.eclipse.core.commands.*;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.team.ui.mapping.SynchronizationActionProvider;
+import org.eclipse.team.ui.mapping.MergeActionHandler;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.ui.navigator.IExtensionStateModel;
/**
* An action that delegates to an appropriate handler when performing
@@ -76,19 +75,7 @@ public class MergeAction extends Action {
}
private IHandler getDefaultHandler() {
- if (handlerId == SynchronizationActionProvider.MERGE_ACTION_ID) {
- return new ResourceMergeHandler(configuration, false /* no overwrite */);
- } else if (handlerId == SynchronizationActionProvider.OVERWRITE_ACTION_ID) {
- return new ResourceMergeHandler(configuration, true /* overwrite */);
- } else if (handlerId == SynchronizationActionProvider.MARK_AS_MERGE_ACTION_ID) {
- return new ResourceMarkAsMergedHandler(configuration);
- }
- return null;
- }
-
- private IExtensionStateModel getExtensionStateModel() {
- // TODO Auto-generated method stub
- return null;
+ return MergeActionHandler.getDefaultHandler(handlerId, configuration);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java
index ca27723a9..9417baa1c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java
@@ -15,6 +15,8 @@ import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.commands.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.mapping.ResourceMarkAsMergedHandler;
+import org.eclipse.team.internal.ui.mapping.ResourceMergeHandler;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
/**
@@ -43,6 +45,23 @@ public abstract class MergeActionHandler extends AbstractHandler {
updatedEnablement(event);
}
};
+
+ /**
+ * Return an instance of the default handler for the given merge action id.
+ * @param mergeActionId the merge action id
+ * @param configuration the ynchronization page configuration
+ * @return the default handler for the given nerge action or <code>null</code>
+ */
+ public static IHandler getDefaultHandler(String mergeActionId, ISynchronizePageConfiguration configuration) {
+ if (mergeActionId == SynchronizationActionProvider.MERGE_ACTION_ID) {
+ return new ResourceMergeHandler(configuration, false /* no overwrite */);
+ } else if (mergeActionId == SynchronizationActionProvider.OVERWRITE_ACTION_ID) {
+ return new ResourceMergeHandler(configuration, true /* overwrite */);
+ } else if (mergeActionId == SynchronizationActionProvider.MARK_AS_MERGE_ACTION_ID) {
+ return new ResourceMarkAsMergedHandler(configuration);
+ }
+ return null;
+ }
/**
* Create the handler.
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java
index 097e1953e..3a46ed895 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java
@@ -14,6 +14,7 @@ import java.util.*;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.internal.ui.mapping.CommonMenuManager;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
@@ -102,7 +103,7 @@ public class SynchronizationActionProvider extends CommonActionProvider {
* @return the configuration from the synchronize page that contains
* the common viewer
*/
- public final ISynchronizePageConfiguration getSynchronizePageConfiguration() {
+ protected final ISynchronizePageConfiguration getSynchronizePageConfiguration() {
return (ISynchronizePageConfiguration)getExtensionStateModel().getProperty(TeamUI.SYNCHRONIZATION_PAGE_CONFIGURATION);
}
@@ -112,11 +113,21 @@ public class SynchronizationActionProvider extends CommonActionProvider {
* @return the extension state model for the content provider associated with
* action provider
*/
- protected IExtensionStateModel getExtensionStateModel() {
+ protected final IExtensionStateModel getExtensionStateModel() {
return config.getExtensionStateModel();
}
/**
+ * Return the synchronization context to which the actions of this provider
+ * apply.
+ * @return the synchronization context to which the actions of this provider
+ * apply
+ */
+ protected final ISynchronizationContext getSynchronizationContext() {
+ return (ISynchronizationContext)getExtensionStateModel().getProperty(TeamUI.SYNCHRONIZATION_CONTEXT);
+ }
+
+ /**
* Register the handler as the handler for the given action id when
* a merge action is performed on elements that match this groups
* enablement.

Back to the top