Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSMergeSynchronizeParticipant.java25
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSWorkspaceSynchronizeParticipant.java19
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/clcl16/workingsets.gifbin0 -> 167 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/dlcl16/workingsets.gifbin0 -> 99 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/elcl16/workingsets.gifbin0 -> 131 bytes
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties14
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SubscriberSynchronizeViewPage.java93
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/TextToolbarManager.java28
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/ToolItemActionContributionItem.java833
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/StatisticsPanel.java177
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/DirectionFilterActionGroup.java57
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetDropDownAction.java125
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetFilterActionGroup.java25
14 files changed, 1223 insertions, 179 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSMergeSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSMergeSynchronizeParticipant.java
index 7427e3337..4db59feba 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSMergeSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSMergeSynchronizeParticipant.java
@@ -22,7 +22,7 @@ import org.eclipse.team.ui.sync.actions.RemoveSynchronizeViewPageAction;
import org.eclipse.ui.IActionBars;
public class CVSMergeSynchronizeParticipant extends CVSSynchronizeParticipant {
-
+
private RemoveSynchronizeViewPageAction removeAction;
private DirectionFilterActionGroup modes;
private Action updateAdapter;
@@ -31,7 +31,7 @@ public class CVSMergeSynchronizeParticipant extends CVSSynchronizeParticipant {
super(subscriber, name, imageDescriptor);
makeActions();
}
-
+
private void makeActions() {
removeAction = new RemoveSynchronizeViewPageAction(this);
modes = new DirectionFilterActionGroup(this, INCOMING_MODE | CONFLICTING_MODE | BOTH_MODE);
@@ -39,17 +39,20 @@ public class CVSMergeSynchronizeParticipant extends CVSSynchronizeParticipant {
Utilities.initAction(updateAdapter, "action.SynchronizeViewUpdate.", Policy.getBundle());
setMode(INCOMING_MODE);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.sync.SubscriberPage#setActionsBars(org.eclipse.ui.IActionBars)
*/
- public void setActionsBars(IActionBars actionBars) {
- super.setActionsBars(actionBars);
- IToolBarManager toolbar = actionBars.getToolBarManager();
- toolbar.add(new Separator());
- modes.fillActionBars(actionBars, null);
- toolbar.add(new Separator());
- actionBars.getToolBarManager().add(updateAdapter);
- actionBars.getToolBarManager().add(removeAction);
+ public void setActionsBars(IActionBars actionBars, IToolBarManager detailsToolbar) {
+ if(actionBars != null) {
+ IToolBarManager toolbar = actionBars.getToolBarManager();
+ toolbar.add(new Separator());
+ toolbar.add(new Separator());
+ actionBars.getToolBarManager().add(updateAdapter);
+ actionBars.getToolBarManager().add(removeAction);
+ }
+ if(detailsToolbar != null) {
+ modes.fillToolBar(detailsToolbar);
+ }
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSWorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSWorkspaceSynchronizeParticipant.java
index 644569de6..8f319aad1 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSWorkspaceSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSWorkspaceSynchronizeParticipant.java
@@ -39,13 +39,16 @@ public class CVSWorkspaceSynchronizeParticipant extends CVSSynchronizeParticipan
/* (non-Javadoc)
* @see org.eclipse.team.ui.sync.SubscriberPage#setActionsBars(org.eclipse.ui.IActionBars)
*/
- public void setActionsBars(IActionBars actionBars) {
- super.setActionsBars(actionBars);
- IToolBarManager toolbar = actionBars.getToolBarManager();
- toolbar.add(new Separator());
- modes.fillActionBars(actionBars, null);
- toolbar.add(new Separator());
- actionBars.getToolBarManager().add(updateAdapter);
- actionBars.getToolBarManager().add(commitAdapter);
+ public void setActionsBars(IActionBars actionBars, IToolBarManager detailsToolbar) {
+ if(actionBars != null) {
+ IToolBarManager toolbar = actionBars.getToolBarManager();
+ toolbar.add(new Separator());
+ toolbar.add(new Separator());
+ actionBars.getToolBarManager().add(updateAdapter);
+ actionBars.getToolBarManager().add(commitAdapter);
+ }
+ if(detailsToolbar != null) {
+ modes.fillToolBar(detailsToolbar);
+ }
}
}
diff --git a/bundles/org.eclipse.team.ui/icons/full/clcl16/workingsets.gif b/bundles/org.eclipse.team.ui/icons/full/clcl16/workingsets.gif
new file mode 100644
index 000000000..f302d8c88
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/clcl16/workingsets.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/dlcl16/workingsets.gif b/bundles/org.eclipse.team.ui/icons/full/dlcl16/workingsets.gif
new file mode 100644
index 000000000..a0f800693
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/dlcl16/workingsets.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/elcl16/workingsets.gif b/bundles/org.eclipse.team.ui/icons/full/elcl16/workingsets.gif
new file mode 100644
index 000000000..2fddc3ea1
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/elcl16/workingsets.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index acfd6ba69..0145ca6a1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -333,6 +333,12 @@ action.toggleViewFlat.image=flatLayout.gif
action.toggleViewHierarchical.label=Hierarchical
action.toggleViewHierarchical.image=hierarchicalLayout.gif
+action.workingSets.label=<None>
+action.workingSets.none=<None>
+action.workingSets.tooltip=Working Sets
+action.workingSets.description=Working Sets
+action.workingSets.image=workingsets.gif
+
action.collapseAll.label=Collapse All
action.collapseAll.tooltip=Collapse All
action.collapseAll.description=Collapse All
@@ -348,22 +354,22 @@ action.refreshWithRemote.tooltip=Refresh with remote
action.refreshWithRemote.description=Refresh with remote
action.refreshWithRemote.image=refresh.gif
-action.directionFilterIncoming.label=Incoming Mode
+action.directionFilterIncoming.label=0
action.directionFilterIncoming.tooltip=Incoming Mode
action.directionFilterIncoming.description=Incoming Mode (shows incoming changes and conflicts)
action.directionFilterIncoming.image=catchup_rls.gif
-action.directionFilterOutgoing.label=Outgoing Mode
+action.directionFilterOutgoing.label=0
action.directionFilterOutgoing.tooltip=Outgoing Mode
action.directionFilterOutgoing.description=Outgoing Mode (shows outgoing changes and conflicts)
action.directionFilterOutgoing.image=release_rls.gif
-action.directionFilterConflicts.label=Conflicts Mode
+action.directionFilterConflicts.label=0
action.directionFilterConflicts.tooltip=Conflicts Mode
action.directionFilterConflicts.description=Conflicts Mode (shows conflicts)
action.directionFilterConflicts.image=conflict_synch.gif
-action.directionFilterBoth.label=Incoming/Outgoing mode
+action.directionFilterBoth.label=0
action.directionFilterBoth.tooltip=Incoming/Outgoing mode
action.directionFilterBoth.description=Incoming/Outgoing mode (shows outgoing changes, incoming changes, and conflicts)
action.directionFilterBoth.image=catchuprelease_rls.gif
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SubscriberSynchronizeViewPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SubscriberSynchronizeViewPage.java
index 2935d8747..8bef8ce90 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SubscriberSynchronizeViewPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SubscriberSynchronizeViewPage.java
@@ -19,25 +19,25 @@ import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.team.internal.ui.jobs.JobBusyCursor;
-import org.eclipse.team.internal.ui.jobs.RefreshSubscriberInputJob;
-import org.eclipse.team.internal.ui.sync.sets.*;
+import org.eclipse.team.internal.ui.sync.sets.SubscriberInput;
import org.eclipse.team.internal.ui.sync.views.*;
import org.eclipse.team.ui.sync.ISynchronizeView;
import org.eclipse.team.ui.sync.TeamSubscriberParticipant;
import org.eclipse.team.ui.sync.actions.*;
+import org.eclipse.team.ui.sync.actions.workingsets.WorkingSetDropDownAction;
import org.eclipse.team.ui.sync.actions.workingsets.WorkingSetFilterActionGroup;
import org.eclipse.ui.*;
import org.eclipse.ui.part.*;
import org.eclipse.ui.views.navigator.ResourceSorter;
-public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSetChangedListener, IPropertyChangeListener {
+public class SubscriberSynchronizeViewPage implements IPageBookViewPage, IPropertyChangeListener {
// The viewer that is shown in the view. Currently this can be either a table or tree viewer.
private StructuredViewer viewer;
// Parent composite of this view. It is remembered so that we can dispose of its children when
// the viewer type is switched.
private Composite composite = null;
- private StatisticsPanel statsPanel;
+ private TextToolbarManager tbMgr;
// Viewer type constants
private int layout;
@@ -67,11 +67,12 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
private Action toggleLayoutTable;
private RefactorActionGroup refactorActions;
private SyncViewerShowPreferencesAction showPreferences;
- private WorkingSetFilterActionGroup workingSetGroup;
private RefreshAction refreshAction;
private ComparisonCriteriaActionGroup comparisonCriteria;
private Action collapseAll;
private Action expandAll;
+
+ private WorkingSetDropDownAction workingSetGroup;
/**
* Constructs a new SynchronizeView.
@@ -95,6 +96,7 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
gridLayout.makeColumnsEqualWidth= false;
gridLayout.marginWidth= 0;
gridLayout.marginHeight = 0;
+ gridLayout.verticalSpacing = 0;
composite.setLayout(gridLayout);
// Create the busy cursor with no control to start with (createViewer will set it)
@@ -110,9 +112,9 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
toggleLayoutTable = new ToggleViewLayoutAction(page, TeamSubscriberParticipant.TABLE_LAYOUT);
toggleLayoutTree = new ToggleViewLayoutAction(page, TeamSubscriberParticipant.TREE_LAYOUT);
+ workingSetGroup = new WorkingSetDropDownAction(getSite().getShell(), this, view, page);
showPreferences = new SyncViewerShowPreferencesAction(view.getSite().getShell());
- workingSetGroup = new WorkingSetFilterActionGroup(getSite().getShell(), this, view, page);
refreshAction = new RefreshAction(getSite().getPage(), input, true /* refresh all */);
@@ -138,9 +140,6 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
};
Utils.initAction(expandAll, "action.expandAll."); //$NON-NLS-1$
- updateStatusPanel();
-
- input.registerListeners(this);
page.addPropertyChangeListener(this);
updateMode(page.getMode());
}
@@ -199,12 +198,12 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
disposeChildren(composite);
createViewer(composite);
composite.layout();
+ setActionBars(null);
if(oldSelection == null || oldSelection.size() == 0) {
//gotoDifference(INavigableControl.NEXT);
} else {
viewer.setSelection(oldSelection, true);
}
- updateStatusPanel();
}
}
@@ -230,7 +229,8 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
}
protected void createViewer(Composite parent) {
- statsPanel = new StatisticsPanel(parent);
+ tbMgr = new TextToolbarManager(SWT.FLAT | SWT.HORIZONTAL);
+ tbMgr.createControl(parent);
switch(layout) {
case TeamSubscriberParticipant.TREE_LAYOUT:
createTreeViewerPartControl(parent);
@@ -343,17 +343,6 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
}
}
}
-
- protected void updateStatusPanel() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- SubscriberInput input = getInput();
- if(statsPanel != null) {
- statsPanel.update(new ViewStatusInformation(input));
- }
- }
- });
- }
/* (non-Javadoc)
* @see org.eclipse.ui.part.IPage#setFocus()
@@ -371,13 +360,6 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
public void dispose() {
- // cancel and wait
- RefreshSubscriberInputJob job = TeamUIPlugin.getPlugin().getRefreshJob();
- job.removeSubscriberInput(input);
-
- // Cleanup the subscriber inputs
- input.deregisterListeners(this);
- input.dispose();
busyCursor.dispose();
}
@@ -452,13 +434,6 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
private IResource getResource(Object object) {
return (IResource)TeamAction.getAdapter(object, IResource.class);
}
-
- /**
- * Update the title when either the subscriber or filter sync set changes.
- */
- public void syncSetChanged(SyncSetChangedEvent event) {
- updateStatusPanel();
- }
public void selectAll() {
if (getLayout() == TeamSubscriberParticipant.TABLE_LAYOUT) {
@@ -487,27 +462,31 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
/* (non-Javadoc)
* @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars)
*/
- public void setActionBars(final IActionBars actionBars) {
- IToolBarManager manager = actionBars.getToolBarManager();
- manager.add(comparisonCriteria);
- manager.add(refreshAction);
- manager.add(new Separator(TeamSubscriberParticipant.MB_MODESGROUP));
- manager.add(gotoNext);
- manager.add(gotoPrevious);
- manager.add(collapseAll);
-
- // drop down menu
- IMenuManager menu = actionBars.getMenuManager();
- workingSetGroup.fillActionBars(actionBars);
- MenuManager layoutMenu = new MenuManager(Policy.bind("action.layout.label")); //$NON-NLS-1$
- layoutMenu.add(toggleLayoutTable);
- layoutMenu.add(toggleLayoutTree);
- menu.add(layoutMenu);
- menu.add(new Separator());
- menu.add(showPreferences);
+ public void setActionBars(final IActionBars actionBars) {
+ if(actionBars != null) {
+ IToolBarManager manager = actionBars.getToolBarManager();
+ manager.add(comparisonCriteria);
+ manager.add(refreshAction);
+ manager.add(new Separator(TeamSubscriberParticipant.MB_MODESGROUP));
+ manager.add(gotoNext);
+ manager.add(gotoPrevious);
+ manager.add(collapseAll);
+
+ // drop down menu
+ IMenuManager menu = actionBars.getMenuManager();
+ MenuManager layoutMenu = new MenuManager(Policy.bind("action.layout.label")); //$NON-NLS-1$
+ layoutMenu.add(toggleLayoutTable);
+ layoutMenu.add(toggleLayoutTree);
+ menu.add(layoutMenu);
+ menu.add(new Separator());
+ menu.add(showPreferences);
+ }
// allow overrides
- page.setActionsBars(actionBars);
+ tbMgr.add(workingSetGroup);
+ tbMgr.add(new Separator());
+ page.setActionsBars(actionBars, tbMgr);
+ tbMgr.update(true);
}
/* (non-Javadoc)
@@ -534,9 +513,9 @@ public class SubscriberSynchronizeViewPage implements IPageBookViewPage, ISyncSe
} else if(event.getProperty().equals(WorkingSetFilterActionGroup.CHANGE_WORKING_SET)) {
Object newValue = event.getNewValue();
if (newValue instanceof IWorkingSet) {
- updateWorkingSet((IWorkingSet)newValue);
+ page.setWorkingSet((IWorkingSet)newValue);
} else if (newValue == null) {
- updateWorkingSet(null);
+ page.setWorkingSet(null);
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/TextToolbarManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/TextToolbarManager.java
new file mode 100644
index 000000000..539b4ac25
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/TextToolbarManager.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 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.ui.sync.pages;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.ToolBarManager;
+
+public class TextToolbarManager extends ToolBarManager {
+
+ public TextToolbarManager(int style) {
+ super(style);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IContributionManager#add(org.eclipse.jface.action.IAction)
+ */
+ public void add(IAction action) {
+ super.add(new ToolItemActionContributionItem(action));
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/ToolItemActionContributionItem.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/ToolItemActionContributionItem.java
new file mode 100644
index 000000000..9383cdf90
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/ToolItemActionContributionItem.java
@@ -0,0 +1,833 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 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.ui.sync.pages;
+
+import java.util.*;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class ToolItemActionContributionItem extends ContributionItem {
+
+ private static boolean USE_COLOR_ICONS = true;
+
+ private static ImageCache globalImageCache;
+
+ /**
+ * The action.
+ */
+ private IAction action;
+
+ /**
+ * The widget created for this item; <code>null</code>
+ * before creation and after disposal.
+ */
+ private Widget widget = null;
+
+ /**
+ * Remembers the parent widget.
+ */
+ private Widget parentWidget = null;
+
+ /**
+ * Listener for action property change notifications.
+ */
+ private final IPropertyChangeListener propertyListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ actionPropertyChange(event);
+ }
+ };
+
+ /**
+ * Listener for SWT button widget events.
+ */
+ private Listener buttonListener;
+
+ /**
+ * Listener for SWT tool item widget events.
+ */
+ private Listener toolItemListener;
+
+ /**
+ * Listener for SWT menu item widget events.
+ */
+ private Listener menuItemListener;
+
+ private static class ImageCache {
+ /** Map from ImageDescriptor to Entry */
+ private Map entries = new HashMap(11);
+ private Image missingImage;
+
+ private class Entry {
+ Image image;
+ Image grayImage;
+
+ void dispose() {
+ if (image != null) {
+ image.dispose();
+ image = null;
+ }
+ if (grayImage != null) {
+ grayImage.dispose();
+ grayImage = null;
+ }
+ }
+ }
+
+ Entry getEntry(ImageDescriptor desc) {
+ Entry entry = (Entry) entries.get(desc);
+ if (entry == null) {
+ entry = new Entry();
+ entries.put(desc, entry);
+ }
+ return entry;
+ }
+
+ Image getImage(ImageDescriptor desc) {
+ if (desc == null) {
+ return null;
+ }
+ Entry entry = getEntry(desc);
+ if (entry.image == null) {
+ entry.image = desc.createImage();
+ }
+ return entry.image;
+ }
+
+ Image getGrayImage(ImageDescriptor desc) {
+ if (desc == null) {
+ return null;
+ }
+ Entry entry = getEntry(desc);
+ if (entry.grayImage == null) {
+ Image image = getImage(desc);
+ if (image != null) {
+ entry.grayImage = new Image(null, image, SWT.IMAGE_GRAY);
+ }
+ }
+ return entry.grayImage;
+ }
+
+ Image getMissingImage() {
+ if (missingImage == null) {
+ missingImage = getImage(ImageDescriptor.getMissingImageDescriptor());
+ }
+ return missingImage;
+ }
+
+ void dispose() {
+ for (Iterator i = entries.values().iterator(); i.hasNext();) {
+ Entry entry = (Entry) i.next();
+ entry.dispose();
+ }
+ entries.clear();
+ }
+ }
+
+public boolean isVisible() {
+ IAction action = getAction();
+
+ if (action != null) {
+ String commandId = action.getActionDefinitionId();
+ CommandResolver.ICallback callback = CommandResolver.getInstance().getCommandResolver();
+
+ if (callback != null)
+ return callback.inContext(commandId);
+ }
+
+ return true;
+}
+
+/**
+ * Returns whether color icons should be used in toolbars.
+ *
+ * @return <code>true</code> if color icons should be used in toolbars,
+ * <code>false</code> otherwise
+ */
+public static boolean getUseColorIconsInToolbars() {
+ return USE_COLOR_ICONS;
+}
+
+/**
+ * Sets whether color icons should be used in toolbars.
+ *
+ * @param useColorIcons <code>true</code> if color icons should be used in toolbars,
+ * <code>false</code> otherwise
+ */
+public static void setUseColorIconsInToolbars(boolean useColorIcons) {
+ USE_COLOR_ICONS = useColorIcons;
+}
+
+/**
+ * Creates a new contribution item from the given action.
+ * The id of the action is used as the id of the item.
+ *
+ * @param action the action
+ */
+public ToolItemActionContributionItem(IAction action) {
+ super(action.getId());
+ this.action = action;
+}
+/**
+ * Handles a property change event on the action (forwarded by nested listener).
+ */
+private void actionPropertyChange(final PropertyChangeEvent e) {
+ // This code should be removed. Avoid using free asyncExec
+
+ if (isVisible() && widget != null) {
+ Display display = widget.getDisplay();
+ if (display.getThread() == Thread.currentThread()) {
+ update(e.getProperty());
+ }
+ else {
+ display.asyncExec(new Runnable() {
+ public void run() {
+ update(e.getProperty());
+ }
+ });
+ }
+
+ }
+}
+/**
+ * Checks whether the given menu item belongs to a context menu
+ * (the one that pops up if the user presses the right mouse button).
+ */
+private static boolean belongsToContextMenu(MenuItem item) {
+ Menu menu = item.getParent();
+ if (menu == null)
+ return false;
+ while (menu.getParentMenu() != null)
+ menu = menu.getParentMenu();
+ return (menu.getStyle() & SWT.BAR) == 0;
+}
+/**
+ * Compares this action contribution item with another object.
+ * Two action contribution items are equal if they refer to the identical Action.
+ */
+public boolean equals(Object o) {
+ if (!(o instanceof ToolItemActionContributionItem)) {
+ return false;
+ }
+ return action.equals(((ToolItemActionContributionItem) o).action);
+}
+/**
+ * The <code>ActionContributionItem</code> implementation of this
+ * <code>IContributionItem</code> method creates an SWT <code>Button</code> for
+ * the action using the action's style. If the action's checked property has
+ * been set, the button is created and primed to the value of the checked
+ * property.
+ */
+public void fill(Composite parent) {
+ if (widget == null && parent != null) {
+ int flags = SWT.PUSH;
+ if (action != null) {
+ if (action.getStyle() == IAction.AS_CHECK_BOX)
+ flags = SWT.TOGGLE;
+ if (action.getStyle() == IAction.AS_RADIO_BUTTON)
+ flags = SWT.RADIO;
+ }
+
+ Button b = new Button(parent, flags);
+ b.setData(this);
+ b.addListener(SWT.Dispose, getButtonListener());
+ // Don't hook a dispose listener on the parent
+ b.addListener(SWT.Selection, getButtonListener());
+ if (action.getHelpListener() != null)
+ b.addHelpListener(action.getHelpListener());
+ widget = b;
+ parentWidget = parent;
+
+ update(null);
+
+ action.addPropertyChangeListener(propertyListener);
+ }
+}
+/**
+ * The <code>ActionContributionItem</code> implementation of this
+ * <code>IContributionItem</code> method creates an SWT <code>MenuItem</code>
+ * for the action using the action's style. If the action's checked property has
+ * been set, a button is created and primed to the value of the checked
+ * property. If the action's menu creator property has been set, a cascading
+ * submenu is created.
+ */
+public void fill(Menu parent, int index) {
+ if (widget == null && parent != null) {
+ Menu subMenu= null;
+ int flags = SWT.PUSH;
+ if (action != null) {
+ int style = action.getStyle();
+ if (style == IAction.AS_CHECK_BOX)
+ flags= SWT.CHECK;
+ else if (style == IAction.AS_RADIO_BUTTON)
+ flags = SWT.RADIO;
+ else if (style == IAction.AS_DROP_DOWN_MENU) {
+ IMenuCreator mc = action.getMenuCreator();
+ if (mc != null) {
+ subMenu = mc.getMenu(parent);
+ flags = SWT.CASCADE;
+ }
+ }
+ }
+
+ MenuItem mi = null;
+ if (index >= 0)
+ mi = new MenuItem(parent, flags, index);
+ else
+ mi = new MenuItem(parent, flags);
+ widget = mi;
+ parentWidget = parent;
+
+ mi.setData(this);
+ mi.addListener(SWT.Dispose, getMenuItemListener());
+ mi.addListener(SWT.Selection, getMenuItemListener());
+ if (action.getHelpListener() != null)
+ mi.addHelpListener(action.getHelpListener());
+
+ if (subMenu != null)
+ mi.setMenu(subMenu);
+
+ update(null);
+
+ action.addPropertyChangeListener(propertyListener);
+ }
+}
+/**
+ * The <code>ActionContributionItem</code> implementation of this ,
+ * <code>IContributionItem</code> method creates an SWT <code>ToolItem</code>
+ * for the action using the action's style. If the action's checked property has
+ * been set, a button is created and primed to the value of the checked
+ * property. If the action's menu creator property has been set, a drop-down
+ * tool item is created.
+ */
+public void fill(ToolBar parent, int index) {
+ if (widget == null && parent != null) {
+ int flags = SWT.PUSH;
+ if (action != null) {
+ int style = action.getStyle();
+ if (style == IAction.AS_CHECK_BOX)
+ flags = SWT.CHECK;
+ else if (style == IAction.AS_RADIO_BUTTON)
+ flags = SWT.RADIO;
+ else if (style == IAction.AS_DROP_DOWN_MENU)
+ flags = SWT.DROP_DOWN;
+ }
+
+ ToolItem ti = null;
+ if (index >= 0)
+ ti = new ToolItem(parent, flags, index);
+ else
+ ti = new ToolItem(parent, flags);
+ ti.setData(this);
+ ti.addListener(SWT.Selection, getToolItemListener());
+ ti.addListener(SWT.Dispose, getToolItemListener());
+
+ widget = ti;
+ parentWidget = parent;
+
+ update(null);
+
+ action.addPropertyChangeListener(propertyListener);
+ }
+}
+/**
+ * Returns the action associated with this contribution item.
+ *
+ * @return the action
+ */
+public IAction getAction() {
+ return action;
+}
+/**
+ * Returns the image cache.
+ * The cache is global, and is shared by all action contribution items.
+ * This has the disadvantage that once an image is allocated, it is never freed until the display
+ * is disposed. However, it has the advantage that the same image in different contribution managers
+ * is only ever created once.
+ */
+private ImageCache getImageCache() {
+ ImageCache cache = globalImageCache;
+ if (cache == null) {
+ globalImageCache = cache = new ImageCache();
+ Display display = Display.getDefault();
+ if (display != null) {
+ display.disposeExec(new Runnable() {
+ public void run() {
+ if (globalImageCache != null) {
+ globalImageCache.dispose();
+ globalImageCache = null;
+ }
+ }
+ });
+ }
+ }
+ return cache;
+}
+/**
+ * Returns the listener for SWT button widget events.
+ *
+ * @return a listener for button events
+ */
+private Listener getButtonListener() {
+ if (buttonListener == null) {
+ buttonListener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ handleWidgetDispose(event);
+ break;
+ case SWT.Selection:
+ Widget ew = event.widget;
+ if (ew != null) {
+ handleWidgetSelection(event, ((Button)ew).getSelection());
+ }
+ break;
+ }
+ }
+ };
+ }
+ return buttonListener;
+}
+/**
+ * Returns the listener for SWT tool item widget events.
+ *
+ * @return a listener for tool item events
+ */
+private Listener getToolItemListener() {
+ if (toolItemListener == null) {
+ toolItemListener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ handleWidgetDispose(event);
+ break;
+ case SWT.Selection:
+ Widget ew = event.widget;
+ if (ew != null) {
+ handleWidgetSelection(event, ((ToolItem)ew).getSelection());
+ }
+ break;
+ }
+ }
+ };
+ }
+ return toolItemListener;
+}
+/**
+ * Returns the listener for SWT menu item widget events.
+ *
+ * @return a listener for menu item events
+ */
+private Listener getMenuItemListener() {
+ if (menuItemListener == null) {
+ menuItemListener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ handleWidgetDispose(event);
+ break;
+ case SWT.Selection:
+ Widget ew = event.widget;
+ if (ew != null) {
+ handleWidgetSelection(event, ((MenuItem)ew).getSelection());
+ }
+ break;
+ }
+ }
+ };
+ }
+ return menuItemListener;
+}
+/**
+ * Handles a widget dispose event for the widget corresponding to this item.
+ */
+private void handleWidgetDispose(Event e) {
+ if (e.widget == widget) {
+ // the item is being disposed
+ if (action.getStyle() == IAction.AS_DROP_DOWN_MENU) {
+ IMenuCreator mc = action.getMenuCreator();
+ if (mc != null) {
+ mc.dispose();
+ }
+ }
+ action.removePropertyChangeListener(propertyListener);
+ widget = null;
+ }
+}
+/**
+ * Handles a widget selection event.
+ */
+private void handleWidgetSelection(Event e, boolean selection) {
+
+ Widget item= e.widget;
+ if (item != null) {
+ int style = item.getStyle();
+
+ if ((style & (SWT.TOGGLE | SWT.CHECK)) != 0) {
+ if (action.getStyle() == IAction.AS_CHECK_BOX) {
+ action.setChecked(selection);
+ }
+ } else if ((style & SWT.RADIO) != 0) {
+ if (action.getStyle() == IAction.AS_RADIO_BUTTON) {
+ action.setChecked(selection);
+ }
+ } else if ((style & SWT.DROP_DOWN) != 0) {
+ if (e.detail == 4) { // on drop-down button
+ if (action.getStyle() == IAction.AS_DROP_DOWN_MENU) {
+ IMenuCreator mc = action.getMenuCreator();
+ ToolItem ti = (ToolItem) item;
+ // we create the menu as a sub-menu of "dummy" so that we can use
+ // it in a cascading menu too.
+ // If created on a SWT control we would get an SWT error...
+ //Menu dummy= new Menu(ti.getParent());
+ //Menu m= mc.getMenu(dummy);
+ //dummy.dispose();
+ if (mc != null) {
+ Menu m= mc.getMenu(ti.getParent());
+ if (m != null) {
+ // position the menu below the drop down item
+ Rectangle b = ti.getBounds();
+ Point p = ti.getParent().toDisplay(new Point(b.x, b.y+b.height));
+ m.setLocation(p.x, p.y); // waiting for SWT 0.42
+ m.setVisible(true);
+ return; // we don't fire the action
+ }
+ }
+ }
+ }
+ }
+
+ // Ensure action is enabled first.
+ // See 1GAN3M6: ITPUI:WINNT - Any IAction in the workbench can be executed while disabled.
+ if (action.isEnabled()) {
+ boolean trace = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.jface/trace/actions")); //$NON-NLS-1$ //$NON-NLS-2$
+ long ms = System.currentTimeMillis();
+ if(trace)
+ System.out.println("Running action: " + action.getText()); //$NON-NLS-1$
+ action.runWithEvent(e);
+ if(trace)
+ System.out.println((System.currentTimeMillis() - ms) + " ms to run action: " + action.getText()); //$NON-NLS-1$
+ }
+ }
+}
+/* (non-Javadoc)
+ * Method declared on Object.
+ */
+public int hashCode() {
+ return action.hashCode();
+}
+/* (non-Javadoc)
+ * Method declared on IContributionItem.
+ */
+public boolean isEnabled() {
+ return action != null && action.isEnabled();
+}
+/**
+ * The action item implementation of this <code>IContributionItem</code>
+ * method returns <code>true</code> for menu items and <code>false</code>
+ * for everything else.
+ */
+public boolean isDynamic() {
+ if(widget instanceof MenuItem) {
+ //Optimization. Only recreate the item is the check or radio style has changed.
+ boolean itemIsCheck = (widget.getStyle() & SWT.CHECK) != 0;
+ boolean actionIsCheck = getAction() != null && getAction().getStyle() == IAction.AS_CHECK_BOX;
+ boolean itemIsRadio = (widget.getStyle() & SWT.RADIO) != 0;
+ boolean actionIsRadio = getAction() != null && getAction().getStyle() == IAction.AS_RADIO_BUTTON;
+ return (itemIsCheck != actionIsCheck) || (itemIsRadio != actionIsRadio);
+ }
+ return false;
+}
+/**
+ * Returns <code>true</code> if this item is allowed to enable,
+ * <code>false</code> otherwise.
+ *
+ * @return if this item is allowed to be enabled
+ * @since 2.0
+ */
+protected boolean isEnabledAllowed() {
+ if (getParent() == null)
+ return true;
+ Boolean value = getParent().getOverrides().getEnabled(this);
+ return (value == null) ? true : value.booleanValue();
+}
+
+/**
+ * The action item implementation of this <code>IContributionItem</code>
+ * method calls <code>update(null)</code>.
+ */
+public final void update() {
+ update(null);
+}
+/**
+ * Synchronizes the UI with the given property.
+ *
+ * @param propertyName the name of the property, or <code>null</code> meaning all applicable
+ * properties
+ */
+public void update(String propertyName) {
+ if (widget != null) {
+ // determine what to do
+ boolean textChanged = propertyName == null || propertyName.equals(Action.TEXT);
+ boolean imageChanged = propertyName == null || propertyName.equals(Action.IMAGE);
+ boolean tooltipTextChanged = propertyName == null || propertyName.equals(Action.TOOL_TIP_TEXT);
+ boolean enableStateChanged = propertyName == null || propertyName.equals(Action.ENABLED) ||
+ propertyName.equals(IContributionManagerOverrides.P_ENABLED);
+ boolean checkChanged =
+ (action.getStyle() == IAction.AS_CHECK_BOX || action.getStyle() == IAction.AS_RADIO_BUTTON)
+ && (propertyName == null || propertyName.equals(Action.CHECKED));
+
+ if (widget instanceof ToolItem) {
+ ToolItem ti = (ToolItem) widget;
+
+ if(textChanged)
+ ti.setText(action.getText());
+
+ if (imageChanged)
+ updateImages(true);
+
+ if (tooltipTextChanged)
+ ti.setToolTipText(action.getToolTipText());
+
+ if (enableStateChanged) {
+ boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed();
+
+ if (ti.getEnabled() != shouldBeEnabled)
+ ti.setEnabled(shouldBeEnabled);
+ }
+
+ if (checkChanged) {
+ boolean bv = action.isChecked();
+
+ if (ti.getSelection() != bv)
+ ti.setSelection(bv);
+ }
+ return;
+ }
+
+ if (widget instanceof MenuItem) {
+ MenuItem mi = (MenuItem) widget;
+
+ if (textChanged) {
+ Integer accelerator = null;
+ String acceleratorText = null;
+ IAction action = getAction();
+ String text = null;
+
+ if (action != null) {
+ CommandResolver.ICallback callback = CommandResolver.getInstance().getCommandResolver();
+
+ if (callback != null) {
+ String commandId = action.getActionDefinitionId();
+
+ if (commandId == null)
+ commandId = callback.guessCommandIdFromActionId(action.getId());
+
+ if (commandId != null) {
+ accelerator = callback.getAccelerator(commandId);
+ acceleratorText = callback.getAcceleratorText(commandId);
+ }
+ /*
+ else
+ System.out.println("command is null for action: " + action + ", " + action.getId() + ", " + action.getText());
+ */
+ }
+ }
+
+ IContributionManagerOverrides overrides = null;
+
+ if (getParent() != null)
+ overrides = getParent().getOverrides();
+
+ if (overrides != null) {
+ text = getParent().getOverrides().getText(this);
+
+ if (acceleratorText == null)
+ acceleratorText = overrides.getAcceleratorText(this); // TODO remove
+
+ if (accelerator == null)
+ accelerator = overrides.getAccelerator(this); // TODO remove
+ }
+
+ if (accelerator == null)
+ accelerator = new Integer(action.getAccelerator());
+
+ if (accelerator != null)
+ mi.setAccelerator(accelerator.intValue());
+
+ if (text == null)
+ text = action.getText();
+
+ if (text == null)
+ text = ""; //$NON-NLS-1$
+ else
+ text = Action.removeAcceleratorText(text);
+
+ if (acceleratorText == null)
+ mi.setText(text);
+ else
+ mi.setText(text + '\t' + acceleratorText);
+ }
+
+ if (imageChanged)
+ updateImages(false);
+
+ if (enableStateChanged) {
+ boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed();
+
+ if (mi.getEnabled() != shouldBeEnabled)
+ mi.setEnabled(shouldBeEnabled);
+ }
+
+ if (checkChanged) {
+ boolean bv = action.isChecked();
+
+ if (mi.getSelection() != bv)
+ mi.setSelection(bv);
+ }
+
+ return;
+ }
+
+ if (widget instanceof Button) {
+ Button button = (Button) widget;
+
+ if (imageChanged && updateImages(false))
+ textChanged = false; // don't update text if it has an image
+
+ if (textChanged) {
+ String text = action.getText();
+
+ if (text != null)
+ button.setText(text);
+ }
+
+ if (tooltipTextChanged)
+ button.setToolTipText(action.getToolTipText());
+
+ if (enableStateChanged) {
+ boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed();
+
+ if (button.getEnabled() != shouldBeEnabled)
+ button.setEnabled(shouldBeEnabled);
+ }
+
+ if (checkChanged) {
+ boolean bv = action.isChecked();
+
+ if (button.getSelection() != bv)
+ button.setSelection(bv);
+ }
+ return;
+ }
+ }
+}
+/**
+ * Updates the images for this action.
+ *
+ * @param forceImage <code>true</code> if some form of image is compulsory,
+ * and <code>false</code> if it is acceptable for this item to have no image
+ * @return <code>true</code> if there are images for this action, <code>false</code> if not
+ */
+private boolean updateImages(boolean forceImage) {
+
+ ImageCache cache = getImageCache();
+
+ if (widget instanceof ToolItem) {
+ if (USE_COLOR_ICONS) {
+ Image image = cache.getImage(action.getHoverImageDescriptor());
+ if (image == null) {
+ image = cache.getImage(action.getImageDescriptor());
+ }
+ Image disabledImage = cache.getImage(action.getDisabledImageDescriptor());
+
+ // Make sure there is a valid image.
+ if (image == null && forceImage) {
+ image = cache.getMissingImage();
+ }
+
+ // performance: more efficient in SWT to set disabled and hot image before regular image
+ if (disabledImage != null) {
+ // Set the disabled image if we were able to create one.
+ // Assumes that SWT.ToolItem will use platform's default
+ // behavior to show item when it is disabled and a disabled
+ // image has not been set.
+ ((ToolItem) widget).setDisabledImage(disabledImage);
+ }
+ ((ToolItem) widget).setImage(image);
+
+ return image != null;
+ }
+ else {
+ Image image = cache.getImage(action.getImageDescriptor());
+ Image hoverImage = cache.getImage(action.getHoverImageDescriptor());
+ Image disabledImage = cache.getImage(action.getDisabledImageDescriptor());
+
+ // If there is no regular image, but there is a hover image,
+ // convert the hover image to gray and use it as the regular image.
+ if (image == null && hoverImage != null) {
+ image = cache.getGrayImage(action.getHoverImageDescriptor());
+ }
+ else {
+ // If there is no hover image, use the regular image as the hover image,
+ // and convert the regular image to gray
+ if (hoverImage == null && image != null) {
+ hoverImage = image;
+ image = cache.getGrayImage(action.getImageDescriptor());
+ }
+ }
+
+ // Make sure there is a valid image.
+ if (hoverImage == null && image == null && forceImage) {
+ image = cache.getMissingImage();
+ }
+
+ // performance: more efficient in SWT to set disabled and hot image before regular image
+ if (disabledImage != null) {
+ // Set the disabled image if we were able to create one.
+ // Assumes that SWT.ToolItem will use platform's default
+ // behavior to show item when it is disabled and a disabled
+ // image has not been set.
+ ((ToolItem) widget).setDisabledImage(disabledImage);
+ }
+ ((ToolItem) widget).setHotImage(hoverImage);
+ ((ToolItem) widget).setImage(image);
+
+ return image != null;
+ }
+ }
+ else if (widget instanceof Item || widget instanceof Button) {
+ // Use hover image if there is one, otherwise use regular image.
+ Image image = cache.getImage(action.getHoverImageDescriptor());
+ if (image == null) {
+ image = cache.getImage(action.getImageDescriptor());
+ }
+ // Make sure there is a valid image.
+ if (image == null && forceImage) {
+ image = cache.getMissingImage();
+ }
+ if (widget instanceof Item) {
+ ((Item) widget).setImage(image);
+ }
+ else if (widget instanceof Button) {
+ ((Button) widget).setImage(image);
+ }
+ return image != null;
+ }
+ return false;
+}
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/StatisticsPanel.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/StatisticsPanel.java
index f41603787..a8820bdf3 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/StatisticsPanel.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/StatisticsPanel.java
@@ -10,23 +10,13 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.sync.views;
+import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.swt.widgets.*;
import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.sync.sets.SyncInfoStatistics;
-import org.eclipse.team.ui.ISharedImages;
import org.eclipse.ui.IWorkingSet;
/**
@@ -37,7 +27,7 @@ import org.eclipse.ui.IWorkingSet;
* @since 3.0
*/
public class StatisticsPanel extends Composite {
-
+
private class DirectionLabel {
public Image image;
public String descriptionText;
@@ -51,15 +41,15 @@ public class StatisticsPanel extends Composite {
label.setImage(image);
}
label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
-
+
this.descriptionText = description;
descriptionLabel= new Label(parent, SWT.NONE);
descriptionLabel.setText(description);
descriptionLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
-
+
valueLabel= new Label(parent, SWT.NONE);
valueLabel.setText(initialValue);
-
+
valueLabel.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
valueLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
}
@@ -84,102 +74,119 @@ public class StatisticsPanel extends Composite {
private ViewStatusInformation stats;
+ private Tracker tracker;
+ private ToolBarManager toolbarManager;
+
public StatisticsPanel(Composite parent) {
- super(parent, SWT.WRAP);
+ super(parent, SWT.NONE);
GridLayout gridLayout= new GridLayout();
- gridLayout.numColumns= 9;
- gridLayout.makeColumnsEqualWidth= false;
- gridLayout.marginWidth= 3;
+ //gridLayout.numColumns= 9;
+ //gridLayout.makeColumnsEqualWidth= false;
+ gridLayout.marginWidth= 0;
gridLayout.marginHeight= 0;
+ //gridLayout.numColumns = 2;
setLayout(gridLayout);
- conflictingDirectionLabel = new DirectionLabel(this, Policy.bind("StatisticsPanel.conflicting"), "0", TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_CONFLICTING).createImage()); //$NON-NLS-1$ //$NON-NLS-2$
- incomingDirectionLabel = new DirectionLabel(this, Policy.bind("StatisticsPanel.incoming"), "0", TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_INCOMING).createImage()); //$NON-NLS-1$ //$NON-NLS-2$
- outgoingDirectionLabel = new DirectionLabel(this, Policy.bind("StatisticsPanel.outgoing"), "0", TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_OUTGOING).createImage()); //$NON-NLS-1$ //$NON-NLS-2$
+ GridData data = new GridData();
+ // data.horizontalAlignment = GridData.FILL;
+ setLayoutData(data);
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- disposeIcons();
- }
- });
+ //conflictingDirectionLabel = new DirectionLabel(this, Policy.bind("StatisticsPanel.conflicting"), "0", TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_CONFLICTING).createImage()); //$NON-NLS-1$ //$NON-NLS-2$
+ //incomingDirectionLabel = new DirectionLabel(this, Policy.bind("StatisticsPanel.incoming"), "0", TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_INCOMING).createImage()); //$NON-NLS-1$ //$NON-NLS-2$
+ //outgoingDirectionLabel = new DirectionLabel(this, Policy.bind("StatisticsPanel.outgoing"), "0", TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_OUTGOING).createImage()); //$NON-NLS-1$ //$NON-NLS-2$
+
+// Label l = new Label(this, SWT.NONE);
+// l.setImage(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_DLG_SYNC_OUTGOING).createImage());
+// MouseMoveListener mouseMoveListener = new MouseMoveListener() {
+// public void mouseMove(MouseEvent event) {
+// if(tracker == null) {
+// tracker = new Tracker(StatisticsPanel.this, SWT.LEFT);
+// tracker.setRectangles(new Rectangle[] {getBounds()});
+// }
+// tracker.open();
+// }
+// };
+// l.addMouseMoveListener(mouseMoveListener);
+// MouseListener mouseListener = new MouseListener() {
+// public void mouseDoubleClick(MouseEvent e) {
+// //handleMouseDoubleClick(e);
+// }
+// public void mouseDown(MouseEvent e) {}
+// public void mouseUp(MouseEvent e) {
+// //handleMouseUp(e);
+// }
+// };
+// l.addMouseListener(mouseListener);
- addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- fixLabelsOnResize();
- }
- });
- setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- updateStats();
- fixLabelsOnResize();
}
-
+
protected void disposeIcons() {
- outgoingDirectionLabel.image.dispose();
- incomingDirectionLabel.image.dispose();
- conflictingDirectionLabel.image.dispose();
+ //outgoingDirectionLabel.image.dispose();
+ //incomingDirectionLabel.image.dispose();
+ //conflictingDirectionLabel.image.dispose();
}
private void fixLabelsOnResize() {
// setup all labels for initial calculation
- outgoingDirectionLabel.descriptionLabel.setText(outgoingDirectionLabel.descriptionText);
- incomingDirectionLabel.descriptionLabel.setText(incomingDirectionLabel.descriptionText);
- conflictingDirectionLabel.descriptionLabel.setText(conflictingDirectionLabel.descriptionText);
- layout(true);
-
- Point preferredSize = outgoingDirectionLabel.valueLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Rectangle currentSize = outgoingDirectionLabel.valueLabel.getBounds();
- if(currentSize.width < preferredSize.y && outgoingDirectionLabel.descriptionLabel.getText().length() != 0) {
- outgoingDirectionLabel.descriptionLabel.setText(""); //$NON-NLS-1$
- incomingDirectionLabel.descriptionLabel.setText(""); //$NON-NLS-1$
- conflictingDirectionLabel.descriptionLabel.setText(""); //$NON-NLS-1$
- } else if(outgoingDirectionLabel.descriptionLabel.getText().length() == 0){
- outgoingDirectionLabel.descriptionLabel.setText(outgoingDirectionLabel.descriptionText);
- incomingDirectionLabel.descriptionLabel.setText(incomingDirectionLabel.descriptionText);
- conflictingDirectionLabel.descriptionLabel.setText(conflictingDirectionLabel.descriptionText);
- }
- layout(true);
- redraw();
+ // outgoingDirectionLabel.descriptionLabel.setText(outgoingDirectionLabel.descriptionText);
+ // incomingDirectionLabel.descriptionLabel.setText(incomingDirectionLabel.descriptionText);
+ // conflictingDirectionLabel.descriptionLabel.setText(conflictingDirectionLabel.descriptionText);
+ // layout(true);
+ //
+ // Point preferredSize = outgoingDirectionLabel.valueLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ // Rectangle currentSize = outgoingDirectionLabel.valueLabel.getBounds();
+ // if(currentSize.width < preferredSize.y && outgoingDirectionLabel.descriptionLabel.getText().length() != 0) {
+ // outgoingDirectionLabel.descriptionLabel.setText(""); //$NON-NLS-1$
+ // incomingDirectionLabel.descriptionLabel.setText(""); //$NON-NLS-1$
+ // conflictingDirectionLabel.descriptionLabel.setText(""); //$NON-NLS-1$
+ // } else if(outgoingDirectionLabel.descriptionLabel.getText().length() == 0){
+ // outgoingDirectionLabel.descriptionLabel.setText(outgoingDirectionLabel.descriptionText);
+ // incomingDirectionLabel.descriptionLabel.setText(incomingDirectionLabel.descriptionText);
+ // conflictingDirectionLabel.descriptionLabel.setText(conflictingDirectionLabel.descriptionText);
+ // }
+ // layout(true);
+ // redraw();
}
public void update(ViewStatusInformation stats) {
this.stats = stats;
updateStats();
}
-
+
private void updateStats() {
- if(stats != null && ! isDisposed()) {
-
- SyncInfoStatistics workspaceSetStats = stats.getSubscriberInput().getSubscriberSyncSet().getStatistics();
- SyncInfoStatistics workingSetSetStats = stats.getSubscriberInput().getWorkingSetSyncSet().getStatistics();
-
- int workspaceConflicting = (int)workspaceSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
- int workspaceOutgoing = (int)workspaceSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
- int workspaceIncoming = (int)workspaceSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
- int workingSetConflicting = (int)workingSetSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
- int workingSetOutgoing = (int)workingSetSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
- int workingSetIncoming = (int)workingSetSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
-
- if(stats.getSubscriberInput().getWorkingSet() != null) {
- conflictingDirectionLabel.valueLabel.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetConflicting).toString(), new Integer(workspaceConflicting).toString())); //$NON-NLS-1$
- incomingDirectionLabel.valueLabel.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetIncoming).toString(), new Integer(workspaceIncoming).toString())); //$NON-NLS-1$
- outgoingDirectionLabel.valueLabel.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetOutgoing).toString(), new Integer(workspaceOutgoing).toString())); //$NON-NLS-1$
- } else {
- conflictingDirectionLabel.valueLabel.setText(new Integer(workspaceConflicting).toString()); //$NON-NLS-1$
- incomingDirectionLabel.valueLabel.setText(new Integer(workspaceIncoming).toString()); //$NON-NLS-1$
- outgoingDirectionLabel.valueLabel.setText(new Integer(workspaceOutgoing).toString()); //$NON-NLS-1$
- }
- updateTooltips();
- redraw();
- }
+ // if(stats != null && ! isDisposed()) {
+ //
+ // SyncInfoStatistics workspaceSetStats = stats.getSubscriberInput().getSubscriberSyncSet().getStatistics();
+ // SyncInfoStatistics workingSetSetStats = stats.getSubscriberInput().getWorkingSetSyncSet().getStatistics();
+ //
+ // int workspaceConflicting = (int)workspaceSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
+ // int workspaceOutgoing = (int)workspaceSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
+ // int workspaceIncoming = (int)workspaceSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
+ // int workingSetConflicting = (int)workingSetSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
+ // int workingSetOutgoing = (int)workingSetSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
+ // int workingSetIncoming = (int)workingSetSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
+ //
+ // if(stats.getSubscriberInput().getWorkingSet() != null) {
+ // conflictingDirectionLabel.valueLabel.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetConflicting).toString(), new Integer(workspaceConflicting).toString())); //$NON-NLS-1$
+ // incomingDirectionLabel.valueLabel.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetIncoming).toString(), new Integer(workspaceIncoming).toString())); //$NON-NLS-1$
+ // outgoingDirectionLabel.valueLabel.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetOutgoing).toString(), new Integer(workspaceOutgoing).toString())); //$NON-NLS-1$
+ // } else {
+ // conflictingDirectionLabel.valueLabel.setText(new Integer(workspaceConflicting).toString()); //$NON-NLS-1$
+ // incomingDirectionLabel.valueLabel.setText(new Integer(workspaceIncoming).toString()); //$NON-NLS-1$
+ // outgoingDirectionLabel.valueLabel.setText(new Integer(workspaceOutgoing).toString()); //$NON-NLS-1$
+ // }
+ // updateTooltips();
+ // redraw();
+ // }
}
-
+
void updateTooltips() {
conflictingDirectionLabel.updateTooltips();
incomingDirectionLabel.updateTooltips();
outgoingDirectionLabel.updateTooltips();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.swt.widgets.Widget#dispose()
*/
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java
index 8f46d44d2..d1905e7d2 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java
@@ -3,6 +3,7 @@ package org.eclipse.team.ui.sync;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.core.subscribers.TeamSubscriber;
import org.eclipse.team.internal.ui.IPreferenceIds;
@@ -123,7 +124,7 @@ public class TeamSubscriberParticipant extends AbstractSynchronizeParticipant {
}
}
- public void setActionsBars(IActionBars actionBars) {
+ public void setActionsBars(IActionBars actionBars, IToolBarManager detailsToolbar) {
}
/* (non-Javadoc)
@@ -132,8 +133,7 @@ public class TeamSubscriberParticipant extends AbstractSynchronizeParticipant {
protected void dispose() {
super.dispose();
RefreshSubscriberInputJob refreshJob = TeamUIPlugin.getPlugin().getRefreshJob();
- refreshJob.removeSubscriberInput(input);
-
+ refreshJob.removeSubscriberInput(input);
input.dispose();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/DirectionFilterActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/DirectionFilterActionGroup.java
index b183c8189..dbaef7010 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/DirectionFilterActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/DirectionFilterActionGroup.java
@@ -16,9 +16,12 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.sync.sets.*;
import org.eclipse.team.ui.sync.TeamSubscriberParticipant;
-import org.eclipse.ui.*;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionGroup;
/**
@@ -26,7 +29,7 @@ import org.eclipse.ui.actions.ActionGroup;
* The actions are presented to the user as toolbar buttons where only one
* button is active at a time
*/
-public class DirectionFilterActionGroup extends ActionGroup implements IPropertyChangeListener {
+public class DirectionFilterActionGroup extends ActionGroup implements IPropertyChangeListener, ISyncSetChangedListener {
// An array of the selection actions for the modes (indexed by mode constant)
private List actions = new ArrayList(3);
@@ -71,7 +74,9 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty
this.page = page;
createActions();
page.addPropertyChangeListener(this);
+ page.getInput().registerListeners(this);
checkMode(page.getMode());
+ updateStats();
}
/**
@@ -116,6 +121,16 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+ */
+ public void fillToolBar(IToolBarManager toolBar) {
+ for (Iterator it = actions.iterator(); it.hasNext();) {
+ DirectionFilterAction action = (DirectionFilterAction) it.next();
+ toolBar.add(action);
+ }
+ }
+
private void checkMode(int mode) {
for (Iterator it = actions.iterator(); it.hasNext();) {
DirectionFilterAction action = (DirectionFilterAction)it.next();
@@ -144,4 +159,42 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty
// TODO Auto-generated method stub
super.dispose();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.sync.sets.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.internal.ui.sync.sets.SyncSetChangedEvent)
+ */
+ public void syncSetChanged(SyncSetChangedEvent event) {
+ updateStats();
+ }
+
+ private void updateStats() {
+ SubscriberInput input = page.getInput();
+ SyncInfoStatistics workspaceSetStats = input.getSubscriberSyncSet().getStatistics();
+ SyncInfoStatistics workingSetSetStats = input.getWorkingSetSyncSet().getStatistics();
+
+ int workspaceConflicting = (int)workspaceSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
+ int workspaceOutgoing = (int)workspaceSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
+ int workspaceIncoming = (int)workspaceSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
+ int workingSetConflicting = (int)workingSetSetStats.countFor(SyncInfo.CONFLICTING, SyncInfo.DIRECTION_MASK);
+ int workingSetOutgoing = (int)workingSetSetStats.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
+ int workingSetIncoming = (int)workingSetSetStats.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
+
+ if(bothMode != null)
+ bothMode.setText(new Integer(input.getWorkingSetSyncSet().size()).toString());
+ if(input.getWorkingSet() != null) {
+ if(conflictsMode != null)
+ conflictsMode.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetConflicting).toString(), new Integer(workspaceConflicting).toString())); //$NON-NLS-1$
+ if(incomingMode != null)
+ incomingMode.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetIncoming).toString(), new Integer(workspaceIncoming).toString())); //$NON-NLS-1$
+ if(outgoingMode != null)
+ outgoingMode.setText(Policy.bind("StatisticsPanel.changeNumbers", new Integer(workingSetOutgoing).toString(), new Integer(workspaceOutgoing).toString())); //$NON-NLS-1$
+ } else {
+ if(conflictsMode != null)
+ conflictsMode.setText(new Integer(workspaceConflicting).toString()); //$NON-NLS-1$
+ if(incomingMode != null)
+ incomingMode.setText(new Integer(workspaceIncoming).toString()); //$NON-NLS-1$
+ if(outgoingMode != null)
+ outgoingMode.setText(new Integer(workspaceOutgoing).toString()); //$NON-NLS-1$
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetDropDownAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetDropDownAction.java
new file mode 100644
index 000000000..71c0a9c77
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetDropDownAction.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 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.ui.sync.actions.workingsets;
+
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.sync.ISynchronizeView;
+import org.eclipse.team.ui.sync.TeamSubscriberParticipant;
+import org.eclipse.ui.*;
+
+public class WorkingSetDropDownAction extends Action implements IMenuCreator, IPropertyChangeListener {
+
+ private ISynchronizeView fView;
+ private MenuManager fMenu;
+ private WorkingSetFilterActionGroup wsgroup;
+ private IPropertyChangeListener workingSetUpdater;
+
+ public WorkingSetDropDownAction(Shell shell, IPropertyChangeListener workingSetUpdater, ISynchronizeView view, TeamSubscriberParticipant participant) {
+ fView= view;
+ Utils.initAction(this, "action.workingSets."); //$NON-NLS-1$
+ IKeyBindingService kbs = view.getSite().getKeyBindingService();
+ setMenuCreator(this);
+ wsgroup = new WorkingSetFilterActionGroup(shell, workingSetUpdater, view, participant);
+ wsgroup.setMenuDynamic(true);
+ participant.addPropertyChangeListener(this);
+ updateWorkingSet(participant.getWorkingSet());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#dispose()
+ */
+ public void dispose() {
+ if (fMenu != null) {
+ fMenu.dispose();
+ }
+
+ fView= null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
+ */
+ public Menu getMenu(Menu parent) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
+ */
+ public Menu getMenu(Control parent) {
+ if (fMenu != null) {
+ fMenu.dispose();
+ }
+ fMenu= new MenuManager();
+ fMenu.createContextMenu(parent);
+ wsgroup.fillActionBars(new IActionBars() {
+ public void clearGlobalActionHandlers() {
+ }
+ public IAction getGlobalActionHandler(String actionId) {
+ return null;
+ }
+ public IMenuManager getMenuManager() {
+ return fMenu;
+ }
+ public IStatusLineManager getStatusLineManager() {
+ return null;
+ }
+ public IToolBarManager getToolBarManager() {
+ return null;
+ }
+ public void setGlobalActionHandler(String actionId, IAction handler) {
+ }
+ public void updateActionBars() {
+ }
+ });
+ fMenu.update(true);
+ return fMenu.getMenu();
+ }
+
+ protected void addActionToMenu(Menu parent, Action action) {
+ ActionContributionItem item= new ActionContributionItem(action);
+ item.fill(parent, -1);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ // do nothing - this is a menu
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getProperty().equals(TeamSubscriberParticipant.P_SYNCVIEWPAGE_WORKINGSET)) {
+ Object newValue = event.getNewValue();
+ if (newValue instanceof IWorkingSet) {
+ updateWorkingSet((IWorkingSet)newValue);
+ } else if (newValue == null) {
+ updateWorkingSet(null);
+ }
+ }
+ }
+
+ private void updateWorkingSet(IWorkingSet set) {
+ if (set != null) {
+ setText(set.getName());
+ } else if (set == null) {
+ setText(Policy.bind("action.workingSets.none"));
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetFilterActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetFilterActionGroup.java
index 8921eb4fc..cfc8791ed 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetFilterActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/workingsets/WorkingSetFilterActionGroup.java
@@ -56,6 +56,8 @@ public class WorkingSetFilterActionGroup extends ActionGroup {
private ISynchronizeParticipant page;
private ISynchronizeView view;
+
+ private boolean isMenuDynamic = false;
/**
* Creates a new instance of the receiver
@@ -118,14 +120,17 @@ public class WorkingSetFilterActionGroup extends ActionGroup {
menuManager.add(editWorkingSetAction);
menuManager.add(new Separator());
menuManager.add(new Separator(SEPARATOR_ID));
-
- menuListener = new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- removePreviousMruWorkingSetActions(manager);
- addMruWorkingSetActions(manager);
- }
- };
- menuManager.addMenuListener(menuListener);
+ if(isMenuDynamic) {
+ addMruWorkingSetActions(menuManager);
+ } else {
+ menuListener = new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ removePreviousMruWorkingSetActions(manager);
+ addMruWorkingSetActions(manager);
+ }
+ };
+ menuManager.addMenuListener(menuListener);
+ }
};
/**
* Returns the working set which is currently selected.
@@ -169,6 +174,8 @@ public class WorkingSetFilterActionGroup extends ActionGroup {
}
}
-
+ public void setMenuDynamic(boolean isMenuDynamic) {
+ this.isMenuDynamic = isMenuDynamic;
+ }
}

Back to the top