Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-10-01 14:16:32 +0000
committerMichael Valenta2004-10-01 14:16:32 +0000
commite16cf822385950aded05130261f6e32018724361 (patch)
treed8e89a1ab98a8305710c2831616ac7a13c3e0015
parentb215b8d73ed65ca396d169e9dc8283871b8d8281 (diff)
downloadeclipse.platform.team-e16cf822385950aded05130261f6e32018724361.tar.gz
eclipse.platform.team-e16cf822385950aded05130261f6e32018724361.tar.xz
eclipse.platform.team-e16cf822385950aded05130261f6e32018724361.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java40
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java61
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java10
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java)35
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java73
8 files changed, 173 insertions, 56 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java
new file mode 100644
index 000000000..9203f79b8
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.subscriber;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;
+
+/**
+ * Action group that is used by CVS Change Set Capabilities
+ */
+public class CVSChangeSetActionGroup extends SynchronizePageActionGroup {
+
+ private OpenChangeSetAction openCommitSet;
+
+ public void initialize(ISynchronizePageConfiguration configuration) {
+ super.initialize(configuration);
+ openCommitSet = new OpenChangeSetAction(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ if (getConfiguration().getMode() == ISynchronizePageConfiguration.OUTGOING_MODE) {
+ appendToGroup(
+ menu,
+ ISynchronizePageConfiguration.FILE_GROUP,
+ openCommitSet);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
index 840a6239b..d063b7d16 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
@@ -45,6 +45,7 @@ import org.eclipse.team.internal.core.Assert;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.*;
+import org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.progress.UIJob;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java
index 31b84f3fe..34dded90b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java
@@ -11,12 +11,16 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import java.lang.reflect.InvocationTargetException;
+import java.text.DateFormat;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.ChangeSet;
+import org.eclipse.team.core.subscribers.CheckedInChangeSet;
import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.*;
import org.eclipse.team.core.variants.IResourceVariant;
@@ -28,11 +32,8 @@ import org.eclipse.team.ui.synchronize.*;
class OpenChangeSetAction extends SynchronizeModelAction {
- private final ChangeLogModelProvider provider;
-
- protected OpenChangeSetAction(ChangeLogModelProvider provider, ISynchronizePageConfiguration configuration) {
+ protected OpenChangeSetAction(ISynchronizePageConfiguration configuration) {
super(Policy.bind("OpenCommitSetAction.20"), configuration); //$NON-NLS-1$
- this.provider = provider;
}
/* (non-Javadoc)
@@ -55,25 +56,36 @@ class OpenChangeSetAction extends SynchronizeModelAction {
})
});
}
-
+
+ private ChangeSet getChangeSet(IStructuredSelection selection) {
+ // First, check to see if a change set is selected directly
+ if (selection.size() == 1) {
+ Object o = selection.getFirstElement();
+ if (o instanceof IAdaptable) {
+ ChangeSet set = (ChangeSet)((IAdaptable)o).getAdapter(ChangeSet.class);
+ if (set != null)
+ return set;
+ }
+ }
+ // Failing that, check to see if all the selected elements and their childen are in the same change set
+ return getChangeSet(selection.toArray());
+ }
+
+ private ChangeSet getChangeSet(Object[] elements) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/
protected boolean updateSelection(IStructuredSelection selection) {
boolean enabled = super.updateSelection(selection);
if (enabled) {
- // The selection only contains appropriate files
- // only enable if there is only one item selected and
- // it is a file or a commit set
- if (selection.size() == 1) {
- Object o = selection.getFirstElement();
- if (o instanceof ChangeSetDiffNode) return true;
- if (o instanceof ISynchronizeModelElement) {
- ISynchronizeModelElement element = (ISynchronizeModelElement)o;
- IResource resource = element.getResource();
- return (resource != null && resource.getType() == IResource.FILE);
- }
- }
+ // The selection only contains appropriate files so
+ // only enable if the selection is contained within a single change set
+ ChangeSet set = getChangeSet(selection);
+ return set != null;
}
return false;
}
@@ -121,16 +133,13 @@ class OpenChangeSetAction extends SynchronizeModelAction {
private String getCompareTitle() {
IDiffElement[] elements = getSelectedDiffElements();
- for (int i = 0; i < elements.length; i++) {
- IDiffElement element = elements[i];
- while (element != null) {
- if (element instanceof ChangeSetDiffNode) {
- return ((ChangeSetDiffNode)element).getShortName();
- }
- element = element.getParent();
- }
+ ChangeSet set = getChangeSet(elements);
+ if (set instanceof CheckedInChangeSet) {
+ CheckedInChangeSet cics = (CheckedInChangeSet)set;
+ String date = DateFormat.getDateTimeInstance().format(cics.getDate());
+ return "[" + cics.getAuthor() + "] (" + date + ")";
}
- return null;
+ return "CVS Change";
}
private ICVSRepositoryLocation getLocation(SyncInfo info) {
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 64ae79696..8c0012981 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
@@ -186,7 +186,13 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
public SubscriberChangeSetCollector getActiveChangeSetManager() {
return CVSUIPlugin.getPlugin().getChangeSetManager();
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#getActionGroup()
+ */
+ public SynchronizePageActionGroup getActionGroup() {
+ return new CVSChangeSetActionGroup();
+ }
}
/**
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java
index 8c39fb40e..f1774965e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java
@@ -77,4 +77,14 @@ public class ChangeSetDiffNode extends SynchronizeModelElement {
}
return super.equals(object);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter.equals(ChangeSet.class)) {
+ return set;
+ }
+ return super.getAdapter(adapter);
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
index b05c1958d..bfea748c1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
@@ -25,6 +25,7 @@ import org.eclipse.team.core.subscribers.ChangeSet;
import org.eclipse.team.core.subscribers.IChangeSetChangeListener;
import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup;
import org.eclipse.team.ui.synchronize.*;
/**
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java
index 1966ccff4..ed6c2242f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
+package org.eclipse.team.internal.ui.synchronize.actions;
import java.lang.reflect.InvocationTargetException;
@@ -25,6 +25,8 @@ import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFil
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.actions.TeamAction;
+import org.eclipse.team.internal.ui.synchronize.ChangeSetModelProvider;
+import org.eclipse.team.internal.ui.synchronize.ChangeSetModelSorter;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -227,13 +229,8 @@ public final class ChangeSetActionGroup extends SynchronizePageActionGroup {
super.initialize(configuration);
if (getChangeSetCapability().supportsCheckedInChangeSets()) {
- sortByComment = new MenuManager(Policy.bind("ChangeLogModelProvider.0a")); //$NON-NLS-1$
- appendToGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
- ISynchronizePageConfiguration.SORT_GROUP,
- sortByComment);
initializeSortCriteria(configuration);
-
+ sortByComment = new MenuManager(Policy.bind("ChangeLogModelProvider.0a")); //$NON-NLS-1$
sortByComment.add(new ToggleSortOrderAction(Policy.bind("ChangeLogModelProvider.1a"), ChangeSetModelSorter.COMMENT)); //$NON-NLS-1$
sortByComment.add(new ToggleSortOrderAction(Policy.bind("ChangeLogModelProvider.2a"), ChangeSetModelSorter.DATE)); //$NON-NLS-1$
sortByComment.add(new ToggleSortOrderAction(Policy.bind("ChangeLogModelProvider.3a"), ChangeSetModelSorter.USER)); //$NON-NLS-1$
@@ -252,22 +249,32 @@ public final class ChangeSetActionGroup extends SynchronizePageActionGroup {
addToChangeSet.add(new Separator());
editChangeSet = new EditChangeSetAction(configuration);
makeDefault = new MakeDefaultChangeSetAction(configuration);
-
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ if (getChangeSetCapability().supportsCheckedInChangeSets() && getConfiguration().getMode() == ISynchronizePageConfiguration.INCOMING_MODE) {
+ appendToGroup(menu, ISynchronizePageConfiguration.SORT_GROUP, sortByComment);
+ }
+ if (getChangeSetCapability().supportsActiveChangeSets() && getConfiguration().getMode() == ISynchronizePageConfiguration.OUTGOING_MODE) {
appendToGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ menu,
CHANGE_SET_GROUP,
addToChangeSet);
appendToGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ menu,
CHANGE_SET_GROUP,
editChangeSet);
appendToGroup(
- ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ menu,
CHANGE_SET_GROUP,
makeDefault);
- }
- }
-
+ }
+ }
+
private void initializeSortCriteria(ISynchronizePageConfiguration configuration) {
try {
IDialogSettings pageSettings = getConfiguration().getSite().getPageSettings();
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java
index 62cdf1901..29ad078fb 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java
@@ -24,52 +24,95 @@ public abstract class ChangeSetCapability {
/**
* Return whether the associated participant supports
- * the display of checked-in change sets.
+ * the display of checked-in change sets. The default is
+ * unsupported (<code>false</code>). If subclasses support
+ * checked-in change sets, they must override the
+ * <code>createCheckedInChangeSetCollector</code>
+ * method to return an appropriate values.
* @return whether the associated participant supports
* the display of checked-in change sets
*/
- public abstract boolean supportsCheckedInChangeSets();
+ public boolean supportsCheckedInChangeSets() {
+ return false;
+ }
/**
* Return whether the associated participant supports
- * the use of active change sets.
+ * the use of active change sets. The default is unsupported
+ * (<code>false</code>). If a subclass overrides this method in
+ * order to support active change sets, they must also override the methods
+ * <code>getActiveChangeSetManager</code>,
+ * <code>createChangeSet</code> and <code>editChangeSet</code>.
* @return whether the associated participant supports
* the use of active change sets
*/
- public abstract boolean supportsActiveChangeSets();
+ public boolean supportsActiveChangeSets() {
+ return false;
+ }
/**
* Return the change set collector that manages the active change
- * set for the particpant associated with this capability.
+ * set for the particpant associated with this capability. A <code>null</code>
+ * is returned if active change sets are not supported. The default is to
+ * return <code>null</code>. This method must be
+ * overridden by subclasses that support active change sets.
* @return the change set collector that manages the active change
- * set for the particpant associated with this capability
+ * set for the particpant associated with this capability or
+ * <code>null</code> if active change sets are not supported.
*/
- public abstract SubscriberChangeSetCollector getActiveChangeSetManager();
+ public SubscriberChangeSetCollector getActiveChangeSetManager() {
+ return null;
+ }
/**
* Create a change set from the given manager that contains the given sync info.
- * This method is invoked from the UI thread.
- * @param configuration TODO
+ * This method is invoked from the UI thread. A <code>null</code>
+ * is returned if active change sets are not supported. The default is to
+ * return <code>null</code>. This method must be
+ * overridden by subclasses that support active change sets.
+ * @param configuration the configuration of the page displaying the change sets
* @param infos the sync info to be added to the change set
* @param manager a change set manager
* @return the created set.
*/
- public abstract ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, SyncInfo[] infos);
+ public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, SyncInfo[] infos) {
+ return null;
+ }
/**
- * Edit the title and comment of the given change set.
+ * Edit the title and comment of the given change set. This method must be
+ * overridden by subclasses that support active change sets.
* This method is invoked from the UI thread.
- * @param configuration TODO
+ * @param configuration the configuration of the page displaying the change sets
* @param set the set to be edited
*/
- public abstract void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set);
+ public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) {
+ // Default is to do nothing
+ }
/**
* Return a collector that can be used to group a set of checked-in changes
- * into a set of checked-in change sets.
+ * into a set of checked-in change sets. This method must be
+ * overridden by subclasses that support checked-in change sets.
* @param configuration the configuration for the page that will be displaying the change sets
* @return a change set collector
*/
- public abstract SyncInfoSetChangeSetCollector createCheckedInChangeSetCollector(ISynchronizePageConfiguration configuration);
+ public SyncInfoSetChangeSetCollector createCheckedInChangeSetCollector(ISynchronizePageConfiguration configuration) {
+ return null;
+ }
+
+ /**
+ * Return an action group for contributing context menu items
+ * to the synchronize page while change sets are enabled.
+ * Return <code>null</code> if no custom actions are required.
+ * Note that only context menus can be contributed since the view menu
+ * and toolbar menu are fixed. This method can be overridden by subclasses
+ * who wish to support custom change set actions.
+ * @return an action group for contributing context menu items
+ * to the synchronize page while change sets are enabled or <code>null</code>
+ */
+ public SynchronizePageActionGroup getActionGroup() {
+ return null;
+ }
}

Back to the top