Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-01-16 17:01:58 -0500
committerMichael Valenta2004-01-16 17:01:58 -0500
commitddacd8dd27b46ad476771af5b8222bed6e846dcd (patch)
tree30c9c50e91dc4b5d5f93d5029302ba131024aacf
parent8f97cd83a938c24109c586927e9dbfb35fbf0a2e (diff)
downloadeclipse.platform.team-ddacd8dd27b46ad476771af5b8222bed6e846dcd.tar.gz
eclipse.platform.team-ddacd8dd27b46ad476771af5b8222bed6e846dcd.tar.xz
eclipse.platform.team-ddacd8dd27b46ad476771af5b8222bed6e846dcd.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeNavigator.java189
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java244
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffViewerConfiguration.java287
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffViewerSyncViewConfiguration.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoDiffViewerForSynchronizeView.java)96
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java7
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java3
6 files changed, 565 insertions, 261 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeNavigator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeNavigator.java
new file mode 100644
index 000000000..311c097db
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeNavigator.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * 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.synchronize;
+
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.team.ui.synchronize.actions.INavigableControl;
+
+/**
+ * This class provides the navigation support required for keybindings
+ */
+public class SyncInfoDiffTreeNavigator {
+
+ public interface INavigationTarget {
+
+ /**
+ * @param selection
+ * @param b
+ */
+ void setSelection(TreeItem ti, boolean fireOpen);
+
+ /**
+ * @return
+ */
+ Tree getTree();
+
+ /**
+ * @param item
+ */
+ void createChildren(TreeItem item);
+
+ }
+ INavigationTarget viewer;
+
+ /**
+ * Selects the next (or previous) node of the current selection.
+ * If there is no current selection the first (last) node in the tree is selected.
+ * Wraps around at end or beginning.
+ * Clients may override.
+ *
+ * @param next if <code>true</code> the next node is selected, otherwise the previous node
+ */
+ public boolean gotoDifference(int direction) {
+ boolean next = direction == INavigableControl.NEXT ? true : false;
+ return internalNavigate(next, false);
+ }
+
+ /**
+ * Selects the next (or previous) node of the current selection.
+ * If there is no current selection the first (last) node in the tree is selected.
+ * Wraps around at end or beginning.
+ * Clients may override.
+ *
+ * @param next if <code>true</code> the next node is selected, otherwise the previous node
+ * @return <code>true</code> if at end (or beginning)
+ */
+ private boolean internalNavigate(boolean next, boolean fireOpen) {
+
+ Tree tree = getTarget().getTree();
+ if (tree == null) return false;
+
+ TreeItem item= null;
+ TreeItem children[]= tree.getSelection();
+ if (children != null && children.length > 0)
+ item= children[0];
+ if (item == null) {
+ children= tree.getItems();
+ if (children != null && children.length > 0) {
+ item= children[0];
+ if (item != null && item.getItemCount() <= 0) {
+ getTarget().setSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ return false;
+ }
+ }
+ }
+
+ while (true) {
+ item= findNextPrev(item, next);
+ if (item == null)
+ break;
+ if (item.getItemCount() <= 0)
+ break;
+ }
+
+ if (item != null) {
+ getTarget().setSelection(item, fireOpen); // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ return false;
+ }
+ return true;
+ }
+
+ private TreeItem findNextPrev(TreeItem item, boolean next) {
+
+ if (item == null)
+ return null;
+
+ TreeItem children[]= null;
+
+ if (!next) {
+
+ TreeItem parent= item.getParentItem();
+ if (parent != null)
+ children= parent.getItems();
+ else
+ children= item.getParent().getItems();
+
+ if (children != null && children.length > 0) {
+ // goto previous child
+ int index= 0;
+ for (; index < children.length; index++)
+ if (children[index] == item)
+ break;
+
+ if (index > 0) {
+
+ item= children[index-1];
+
+ while (true) {
+ getTarget().createChildren(item);
+ int n= item.getItemCount();
+ if (n <= 0)
+ break;
+
+ item.setExpanded(true);
+ item= item.getItems()[n-1];
+ }
+
+ // previous
+ return item;
+ }
+ }
+
+ // go up
+ return parent;
+
+ } else {
+ item.setExpanded(true);
+ getTarget().createChildren(item);
+
+ if (item.getItemCount() > 0) {
+ // has children: go down
+ children= item.getItems();
+ return children[0];
+ }
+
+ while (item != null) {
+ children= null;
+ TreeItem parent= item.getParentItem();
+ if (parent != null)
+ children= parent.getItems();
+ else
+ children= item.getParent().getItems();
+
+ if (children != null && children.length > 0) {
+ // goto next child
+ int index= 0;
+ for (; index < children.length; index++)
+ if (children[index] == item)
+ break;
+
+ if (index < children.length-1) {
+ // next
+ return children[index+1];
+ }
+ }
+
+ // go up
+ item= parent;
+ }
+ }
+
+ return item;
+ }
+
+ /**
+ * @return Returns the viewer.
+ */
+ public INavigationTarget getTarget() {
+ return viewer;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java
index b4321d1db..7aeb23bf9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffTreeViewer.java
@@ -11,75 +11,26 @@
package org.eclipse.team.ui.synchronize;
import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.compare.*;
import org.eclipse.compare.internal.INavigatable;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.widgets.*;
-import org.eclipse.team.core.subscribers.*;
-import org.eclipse.team.internal.ui.*;
-import org.eclipse.team.internal.ui.synchronize.views.*;
+import org.eclipse.team.internal.ui.synchronize.views.SyncSetContentProvider;
import org.eclipse.team.ui.synchronize.actions.INavigableControl;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.internal.PluginAction;
-import org.eclipse.ui.views.navigator.ResourceSorter;
public class SyncInfoDiffTreeViewer extends TreeViewer implements INavigableControl {
- private SyncInfoSet set;
+ private SyncInfoDiffViewerConfiguration configuration;
- // Actions
- private Action expandAll;
- private NavigationAction nextAction;
- private NavigationAction previousAction;
-
- private boolean acceptParticipantMenuContributions = false;
-
- private MenuManager menuMgr = null;
- private String menuId;
-
- /**
- * Change the tree layout between using compressed folders and regular folders
- * when the user setting is changed.
- */
- private IPropertyChangeListener propertyListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
- setTreeViewerContentProvider();
- }
- }
- };
-
- public SyncInfoDiffTreeViewer(Composite parent, String menuId, SyncInfoSet set) {
+ public SyncInfoDiffTreeViewer(Composite parent, SyncInfoDiffViewerConfiguration configuration) {
super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- this.menuId = menuId;
- this.set = set;
- GridData data = new GridData(GridData.FILL_BOTH);
- setSorter(new SyncViewerSorter(ResourceSorter.NAME));
- setLabelProvider(new TeamSubscriberParticipantLabelProvider());
- getTree().setLayoutData(data);
- getStore().addPropertyChangeListener(propertyListener);
- setTreeViewerContentProvider();
-
- addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
- }
- });
-
- getTree().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
-
+ this.configuration = configuration;
+ }
+
+ protected void initializeNavigation() {
INavigatable nav= new INavigatable() {
public boolean gotoDifference(boolean next) {
// Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
@@ -87,94 +38,6 @@ public class SyncInfoDiffTreeViewer extends TreeViewer implements INavigableCont
}
};
getTree().setData(INavigatable.NAVIGATOR_PROPERTY, nav);
-
- createActions();
- hookContextMenu();
-
- createToolBarActions(parent);
- setInput(new SyncInfoDiffNode(getSyncSet(), ResourcesPlugin.getWorkspace().getRoot()));
- }
-
- protected Object getTitle() {
- return "Synchronization Changes";
- }
-
- public void setAcceptParticipantMenuContributions(boolean accept) {
- this.acceptParticipantMenuContributions = accept;
- if(acceptParticipantMenuContributions) {
- IWorkbenchPartSite site = Utils.findSite(getControl());
- if(site == null) {
- site = Utils.findSite();
- }
- if(site != null) {
- site.registerContextMenu(menuId, menuMgr, this);
- }
- }
- }
-
- private void createToolBarActions(Composite parent) {
- ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent);
- if (tbm != null) {
- tbm.removeAll();
-
- tbm.add(new Separator("navigation")); //$NON-NLS-1$
-
- createToolItems(tbm);
- tbm.update(true);
- }
- }
-
- protected void createToolItems(IToolBarManager tbm) {
- nextAction= new NavigationAction(true);
- tbm.appendToGroup("navigation", nextAction); //$NON-NLS-1$
-
- previousAction= new NavigationAction(false);
- tbm.appendToGroup("navigation", previousAction); //$NON-NLS-1$
- }
-
- protected SyncInfoSet getSyncSet() {
- return set;
- }
-
- private void createActions() {
- expandAll = new Action() {
- public void run() {
- expandAllFromSelection();
- }
- };
- Utils.initAction(expandAll, "action.expandAll."); //$NON-NLS-1$
- }
-
- protected void expandAllFromSelection() {
- ISelection selection = getSelection();
- if(! selection.isEmpty()) {
- Iterator elements = ((IStructuredSelection)selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- expandToLevel(next, AbstractTreeViewer.ALL_LEVELS);
- }
- }
- }
-
- protected void fillContextMenu(IMenuManager manager) {
- manager.add(expandAll);
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- private void setTreeViewerContentProvider() {
- if (getStore().getBoolean(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
- setContentProvider(new CompressedFolderContentProvider());
- } else {
- setContentProvider(new SyncSetTreeContentProvider());
- }
- }
-
- /**
- * Return the preference store for this plugin.
- * @return IPreferenceStore for this plugin
- */
- private IPreferenceStore getStore() {
- return TeamUIPlugin.getPlugin().getPreferenceStore();
}
protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
@@ -204,66 +67,9 @@ public class SyncInfoDiffTreeViewer extends TreeViewer implements INavigableCont
*/
protected void handleDispose(DisposeEvent event) {
super.handleDispose(event);
- getStore().removePropertyChangeListener(propertyListener);
+ configuration.dispose();
}
-
- /**
- * Handles a double-click event from the viewer.
- * Expands or collapses a folder when double-clicked.
- *
- * @param event the double-click event
- */
- protected void handleDoubleClick(DoubleClickEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- Object element = selection.getFirstElement();
- // Double-clicking should expand/collapse containers
- if(isExpandable(element)) {
- setExpandedState(element, ! getExpandedState(element));
- }
- }
-
- protected void hookContextMenu() {
- menuMgr = new MenuManager(menuId); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- fillContextMenu(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(getControl());
- menu.addMenuListener(new MenuListener() {
- public void menuHidden(MenuEvent e) {
- }
- // Hack to allow action contributions to update their
- // state before the menu is shown. This is required when
- // the state of the selection changes and the contributions
- // need to update enablement based on this.
- public void menuShown(MenuEvent e) {
- IContributionItem[] items = menuMgr.getItems();
- for (int i = 0; i < items.length; i++) {
- IContributionItem item = items[i];
- if(item instanceof ActionContributionItem) {
- IAction actionItem = ((ActionContributionItem)item).getAction();
- if(actionItem instanceof PluginAction) {
- ((PluginAction)actionItem).selectionChanged(getSelection());
- }
- }
- }
- }
- });
- getControl().setMenu(menu);
-
- if(acceptParticipantMenuContributions) {
- IWorkbenchPartSite site = Utils.findSite(getControl());
- if(site == null) {
- site = Utils.findSite();
- }
- if(site != null) {
- site.registerContextMenu(menuId, menuMgr, this);
- }
- }
- }
-
+
protected void inputChanged(Object in, Object oldInput) {
super.inputChanged(in, oldInput);
if (in != oldInput) {
@@ -298,11 +104,6 @@ public class SyncInfoDiffTreeViewer extends TreeViewer implements INavigableCont
return internalNavigate(next, false);
}
- public void updateCompareEditorInput(CompareEditorInput input) {
- nextAction.setCompareEditorInput(input);
- previousAction.setCompareEditorInput(input);
- }
-
/**
* Selects the next (or previous) node of the current selection.
* If there is no current selection the first (last) node in the tree is selected.
@@ -447,6 +248,29 @@ public class SyncInfoDiffTreeViewer extends TreeViewer implements INavigableCont
}
}
-
+ protected SyncInfoDiffTreeNavigator.INavigationTarget createNavigationTarget() {
+ return new SyncInfoDiffTreeNavigator.INavigationTarget() {
+ public void setSelection(TreeItem ti, boolean fireOpen) {
+ if (ti != null) {
+ Object data= ti.getData();
+ if (data != null) {
+ // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ ISelection selection= new StructuredSelection(data);
+ SyncInfoDiffTreeViewer.this.setSelection(selection, true);
+ ISelection currentSelection= getSelection();
+ if (fireOpen && currentSelection != null && selection.equals(currentSelection)) {
+ fireOpen(new OpenEvent(SyncInfoDiffTreeViewer.this, selection));
+ }
+ }
+ }
+ }
+ public Tree getTree() {
+ return (Tree)getControl();
+ }
+ public void createChildren(TreeItem item) {
+ SyncInfoDiffTreeViewer.this.createChildren(item);
+ }
+ };
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffViewerConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffViewerConfiguration.java
new file mode 100644
index 000000000..b5723cf1e
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffViewerConfiguration.java
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * 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.synchronize;
+
+import java.util.Iterator;
+
+import org.eclipse.compare.*;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.MenuListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.team.core.subscribers.SyncInfoSet;
+import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.internal.ui.synchronize.views.*;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.internal.PluginAction;
+import org.eclipse.ui.views.navigator.ResourceSorter;
+
+/**
+ * This class provides the configurability of SyncInfo diff viewers
+ */
+public class SyncInfoDiffViewerConfiguration {
+
+ private SyncInfoSet set;
+
+ private StructuredViewer viewer;
+ private MenuManager menuMgr = null;
+ private String menuId;
+ private Action expandAll;
+ private NavigationAction nextAction;
+ private NavigationAction previousAction;
+
+ private boolean acceptParticipantMenuContributions = false;
+
+ /**
+ * Change the tree layout between using compressed folders and regular folders
+ * when the user setting is changed.
+ */
+ private IPropertyChangeListener propertyListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
+ setTreeViewerContentProvider();
+ }
+ }
+ };
+
+ public SyncInfoDiffViewerConfiguration(String menuId, SyncInfoSet set) {
+ this.menuId = menuId;
+ this.set = set;
+ }
+
+ public SyncInfoDiffTreeViewer createDiffTreeViewer(Composite parent) {
+ final SyncInfoDiffTreeViewer treeViewer = new SyncInfoDiffTreeViewer(parent, this);
+ this.viewer = treeViewer;
+ GridData data = new GridData(GridData.FILL_BOTH);
+ treeViewer.setSorter(new SyncViewerSorter(ResourceSorter.NAME));
+ treeViewer.setLabelProvider(new TeamSubscriberParticipantLabelProvider());
+ treeViewer.getTree().setLayoutData(data);
+ getStore().addPropertyChangeListener(propertyListener);
+ setTreeViewerContentProvider();
+
+ initializeListeners();
+
+ treeViewer.getTree().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
+ treeViewer.initializeNavigation();
+ createActions();
+ hookContextMenu();
+
+ createToolBarActions(parent);
+ treeViewer.setInput(new SyncInfoDiffNode(getSyncSet(), ResourcesPlugin.getWorkspace().getRoot()));
+ return treeViewer;
+ }
+
+ public SyncInfoDiffTreeViewer createDiffCheckboxTreeViewer(Composite parent) {
+ final SyncInfoDiffTreeViewer treeViewer = new SyncInfoDiffTreeViewer(parent, this);
+ this.viewer = treeViewer;
+ GridData data = new GridData(GridData.FILL_BOTH);
+ treeViewer.setSorter(new SyncViewerSorter(ResourceSorter.NAME));
+ treeViewer.setLabelProvider(new TeamSubscriberParticipantLabelProvider());
+ treeViewer.getTree().setLayoutData(data);
+ getStore().addPropertyChangeListener(propertyListener);
+ setTreeViewerContentProvider();
+
+ initializeListeners();
+
+ treeViewer.getTree().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
+ treeViewer.initializeNavigation();
+ createActions();
+ hookContextMenu();
+
+ createToolBarActions(parent);
+ treeViewer.setInput(new SyncInfoDiffNode(getSyncSet(), ResourcesPlugin.getWorkspace().getRoot()));
+ return treeViewer;
+ }
+
+ protected void initializeListeners() {
+ getViewer().addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ handleDoubleClick(event);
+ }
+ });
+ }
+
+ public SyncInfoSet getSyncSet() {
+ return set;
+ }
+
+ private void createToolBarActions(Composite parent) {
+ ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent);
+ if (tbm != null) {
+ tbm.removeAll();
+
+ tbm.add(new Separator("navigation")); //$NON-NLS-1$
+
+ createToolItems(tbm);
+ tbm.update(true);
+ }
+ }
+
+ protected void createToolItems(IToolBarManager tbm) {
+ nextAction= new NavigationAction(true);
+ tbm.appendToGroup("navigation", nextAction); //$NON-NLS-1$
+
+ previousAction= new NavigationAction(false);
+ tbm.appendToGroup("navigation", previousAction); //$NON-NLS-1$
+ }
+
+ /**
+ * Return the preference store for this plugin.
+ * @return IPreferenceStore for this plugin
+ */
+ private IPreferenceStore getStore() {
+ return TeamUIPlugin.getPlugin().getPreferenceStore();
+ }
+
+ private void setTreeViewerContentProvider() {
+ if (getStore().getBoolean(IPreferenceIds.SYNCVIEW_COMPRESS_FOLDERS)) {
+ getViewer().setContentProvider(new CompressedFolderContentProvider());
+ } else {
+ getViewer().setContentProvider(new SyncSetTreeContentProvider());
+ }
+ }
+
+ public StructuredViewer getViewer() {
+ return viewer;
+ }
+
+ private void createActions() {
+ expandAll = new Action() {
+ public void run() {
+ expandAllFromSelection();
+ }
+ };
+ Utils.initAction(expandAll, "action.expandAll."); //$NON-NLS-1$
+ }
+
+ protected void expandAllFromSelection() {
+ AbstractTreeViewer tree = getAbstractTreeViewer();
+ if (tree == null) return;
+ ISelection selection = tree.getSelection();
+ if(! selection.isEmpty()) {
+ Iterator elements = ((IStructuredSelection)selection).iterator();
+ while (elements.hasNext()) {
+ Object next = elements.next();
+ tree.expandToLevel(next, AbstractTreeViewer.ALL_LEVELS);
+ }
+ }
+ }
+
+ protected void hookContextMenu() {
+ menuMgr = new MenuManager(menuId); //$NON-NLS-1$
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ menu.addMenuListener(new MenuListener() {
+ public void menuHidden(MenuEvent e) {
+ }
+ // Hack to allow action contributions to update their
+ // state before the menu is shown. This is required when
+ // the state of the selection changes and the contributions
+ // need to update enablement based on this.
+ public void menuShown(MenuEvent e) {
+ IContributionItem[] items = menuMgr.getItems();
+ for (int i = 0; i < items.length; i++) {
+ IContributionItem item = items[i];
+ if(item instanceof ActionContributionItem) {
+ IAction actionItem = ((ActionContributionItem)item).getAction();
+ if(actionItem instanceof PluginAction) {
+ ((PluginAction)actionItem).selectionChanged(viewer.getSelection());
+ }
+ }
+ }
+ }
+ });
+ viewer.getControl().setMenu(menu);
+
+ if(acceptParticipantMenuContributions) {
+ IWorkbenchPartSite site = Utils.findSite(viewer.getControl());
+ if(site == null) {
+ site = Utils.findSite();
+ }
+ if(site != null) {
+ site.registerContextMenu(menuId, menuMgr, viewer);
+ }
+ }
+ }
+
+ protected void fillContextMenu(IMenuManager manager) {
+ if (getAbstractTreeViewer() != null) {
+ manager.add(expandAll);
+ }
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private AbstractTreeViewer getAbstractTreeViewer() {
+ if (viewer instanceof AbstractTreeViewer) {
+ return (AbstractTreeViewer)viewer;
+ }
+ return null;
+ }
+
+ protected Object getTitle() {
+ return "Synchronization Changes";
+ }
+
+ /**
+ * Cleanup listeners
+ */
+ protected void dispose() {
+ getStore().removePropertyChangeListener(propertyListener);
+ }
+
+ public void setAcceptParticipantMenuContributions(boolean accept) {
+ this.acceptParticipantMenuContributions = accept;
+ if(acceptParticipantMenuContributions) {
+ IWorkbenchPartSite site = Utils.findSite(getViewer().getControl());
+ if(site == null) {
+ site = Utils.findSite();
+ }
+ if(site != null) {
+ site.registerContextMenu(menuId, menuMgr, getViewer());
+ }
+ }
+ }
+
+ public void updateCompareEditorInput(CompareEditorInput input) {
+ nextAction.setCompareEditorInput(input);
+ previousAction.setCompareEditorInput(input);
+ }
+
+ /**
+ * Handles a double-click event from the viewer.
+ * Expands or collapses a folder when double-clicked.
+ *
+ * @param event the double-click event
+ */
+ protected void handleDoubleClick(DoubleClickEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object element = selection.getFirstElement();
+ // Double-clicking should expand/collapse containers
+ AbstractTreeViewer tree = getAbstractTreeViewer();
+ if(tree != null && tree.isExpandable(element)) {
+ tree.setExpandedState(element, ! tree.getExpandedState(element));
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoDiffViewerForSynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffViewerSyncViewConfiguration.java
index 474bdcfd1..a508cd950 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoDiffViewerForSynchronizeView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoDiffViewerSyncViewConfiguration.java
@@ -8,37 +8,42 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
+package org.eclipse.team.ui.synchronize;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.team.core.subscribers.*;
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.synchronize.actions.*;
-import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.IWorkbenchActionConstants;
-public class SyncInfoDiffViewerForSynchronizeView extends SyncInfoDiffTreeViewer {
+/**
+ * Overrides the SyncInfoDiffViewerConfiguration to configure the diff viewer for the synchroniza view
+ */
+public class SyncInfoDiffViewerSyncViewConfiguration extends SyncInfoDiffViewerConfiguration {
+ private ISynchronizeView view;
private TeamSubscriberParticipant participant;
-
- //private ISynchronizeView view;
-
+
private OpenWithActionGroup openWithActions;
private RefactorActionGroup refactorActions;
private RefreshAction refreshSelectionAction;
private Action expandAll;
- private ISynchronizeView view;
-
- public SyncInfoDiffViewerForSynchronizeView(Composite parent, ISynchronizeView view, TeamSubscriberParticipant participant, SyncInfoSet set) {
- super(parent, participant.getId(), set);
+
+ public SyncInfoDiffViewerSyncViewConfiguration(ISynchronizeView view, TeamSubscriberParticipant participant) {
+ super(participant.getId(), participant.getSyncInfoSetCollector().getSyncInfoSet());
this.view = view;
this.participant = participant;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SyncInfoDiffViewerConfiguration#createDiffTreeViewer(org.eclipse.swt.widgets.Composite)
+ */
+ public SyncInfoDiffTreeViewer createDiffTreeViewer(Composite parent) {
+ SyncInfoDiffTreeViewer treeViewer = super.createDiffTreeViewer(parent);
openWithActions = new OpenWithActionGroup(view, participant);
refactorActions = new RefactorActionGroup(view.getSite().getPage().getActivePart());
@@ -50,12 +55,9 @@ public class SyncInfoDiffViewerForSynchronizeView extends SyncInfoDiffTreeViewer
};
Utils.initAction(expandAll, "action.expandAll."); //$NON-NLS-1$
setAcceptParticipantMenuContributions(true);
+ return treeViewer;
}
-
- private void handleOpen(OpenEvent event) {
- openWithActions.openInCompareEditor();
- }
-
+
protected void fillContextMenu(IMenuManager manager) {
openWithActions.fillContextMenu(manager);
refactorActions.fillContextMenu(manager);
@@ -64,25 +66,45 @@ public class SyncInfoDiffViewerForSynchronizeView extends SyncInfoDiffTreeViewer
manager.add(expandAll);
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
-
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.ui.synchronize.SyncInfoDiffTreeViewer#handleDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ protected void handleDoubleClick(DoubleClickEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ DiffNode node = (DiffNode) selection.getFirstElement();
+ if (node != null && node instanceof SyncInfoDiffNode) {
+ SyncInfoDiffNode syncNode = (SyncInfoDiffNode)node;
+ SyncInfo info = syncNode.getSyncInfo();
+ if (syncNode != null && syncNode.getResource().getType() == IResource.FILE) {
+ openWithActions.openInCompareEditor();
+ return;
+ }
+ }
+ // Double-clicking should expand/collapse containers
+ super.handleDoubleClick(event);
+ }
+
protected void initializeListeners() {
- addSelectionChangedListener(new ISelectionChangedListener() {
+ getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateStatusLine((IStructuredSelection) event.getSelection());
}
});
- addOpenListener(new IOpenListener() {
+ getViewer().addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
- handleOpen(event);
- }
- });
- addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
+ handleOpen();
}
});
+ super.initializeListeners();
}
-
+
+ protected void handleOpen() {
+ openWithActions.openInCompareEditor();
+ }
+
/**
* Updates the message shown in the status line.
*
@@ -119,24 +141,4 @@ public class SyncInfoDiffViewerForSynchronizeView extends SyncInfoDiffTreeViewer
}
return ""; //$NON-NLS-1$
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.team.ui.synchronize.SyncInfoDiffTreeViewer#handleDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
- */
- protected void handleDoubleClick(DoubleClickEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- DiffNode node = (DiffNode) selection.getFirstElement();
- if (node != null && node instanceof SyncInfoDiffNode) {
- SyncInfoDiffNode syncNode = (SyncInfoDiffNode)node;
- SyncInfo info = syncNode.getSyncInfo();
- if (syncNode != null && syncNode.getResource().getType() == IResource.FILE) {
- openWithActions.openInCompareEditor();
- return;
- }
- }
- // Double-clicking should expand/collapse containers
- super.handleDoubleClick(event);
- }
-
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java
index 6f7b4e7b8..04f7522ab 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetCompareInput.java
@@ -34,8 +34,9 @@ public class SyncInfoSetCompareInput extends CompareEditorInput {
}
public Viewer createDiffViewer(Composite parent) {
- SyncInfoDiffTreeViewer v = new SyncInfoDiffTreeViewer(parent, menuId, syncInfoSet);
- v.updateCompareEditorInput(this);
+ SyncInfoDiffViewerConfiguration configuration = new SyncInfoDiffViewerConfiguration(menuId, syncInfoSet);
+ SyncInfoDiffTreeViewer v = configuration.createDiffTreeViewer(parent);
+ configuration.updateCompareEditorInput(this);
v.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
ISelection s = event.getSelection();
@@ -48,7 +49,7 @@ public class SyncInfoSetCompareInput extends CompareEditorInput {
}
}
});
- v.setAcceptParticipantMenuContributions(allowParticipantMenuContributions());
+ configuration.setAcceptParticipantMenuContributions(allowParticipantMenuContributions());
return v;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java
index 885635d29..a35e55697 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamSubscriberParticipantPage.java
@@ -264,7 +264,8 @@ public class TeamSubscriberParticipantPage implements IPageBookViewPage, IProper
}
public Viewer createChangesViewer(Composite parent) {
- Viewer viewer = new SyncInfoDiffViewerForSynchronizeView(parent, getSynchronizeView(), getParticipant(), getParticipant().getSyncInfoSetCollector().getSyncInfoSet());
+ SyncInfoDiffViewerSyncViewConfiguration configuration = new SyncInfoDiffViewerSyncViewConfiguration(getSynchronizeView(), getParticipant());
+ Viewer viewer = configuration.createDiffTreeViewer(parent);
getSite().setSelectionProvider(viewer);
return viewer;
}

Back to the top