From 75434d34a87d6133a7ce7d8dfe701fd5d671b019 Mon Sep 17 00:00:00 2001 From: Michael Valenta Date: Wed, 28 Apr 2004 16:02:28 +0000 Subject: *** empty log message *** --- .../ccvs/ui/wizards/SharingWizardTreeAdviser.java | 110 -------- .../ui/synchronize/SynchronizeCompareInput.java | 302 --------------------- 2 files changed, 412 deletions(-) delete mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardTreeAdviser.java delete mode 100644 bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeCompareInput.java diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardTreeAdviser.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardTreeAdviser.java deleted file mode 100644 index 68b97eb9e..000000000 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardTreeAdviser.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.ui.wizards; - -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.widgets.Display; -import org.eclipse.team.core.synchronize.*; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; -import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; -import org.eclipse.team.internal.ccvs.ui.Policy; -import org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction; -import org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitOperation; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; -import org.eclipse.team.ui.synchronize.*; -import org.eclipse.ui.*; - -/** - * Adviser used to add toolbar buttons to the last page of the sharing wizard. - */ -public class SharingWizardTreeAdviser extends TreeViewerAdvisor implements ISynchronizeModelChangeListener { - - private ActionDelegateWrapper commitToolbar; - private ActionDelegateWrapper ignoreAction; - - /** - * Custom commit that includes outgoing and conflicting. - */ - class SharingCommitAction extends SynchronizeModelAction { - protected FastSyncInfoFilter getSyncInfoFilter() { - return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}); - } - protected SynchronizeModelOperation getSubscriberOperation(IWorkbenchPart part, IDiffElement[] elements) { - return new SubscriberCommitOperation(part, elements, true /* override */); - } - - } - - public SharingWizardTreeAdviser(String menuId, IWorkbenchPartSite site, SyncInfoTree set) { - super(menuId, site, set); - - // Sync changes are used to update the action state for the update/commit buttons. - addInputChangedListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.subscriber.SynchronizeViewerAdvisor#initializeActions(org.eclipse.jface.viewers.StructuredViewer) - */ - protected void initializeActions(StructuredViewer viewer) { - super.initializeActions(viewer); - - commitToolbar = new ActionDelegateWrapper(new SharingCommitAction(), null /* view part */); - Utils.initAction(commitToolbar, "action.SynchronizeViewCommit.", Policy.getBundle()); //$NON-NLS-1$ - - ignoreAction = new ActionDelegateWrapper(new IgnoreAction(), null /* view part */); - Utils.initAction(ignoreAction, "action.SharingWizardIgnore.", Policy.getBundle()); //$NON-NLS-1$ - - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ignoreAction.setSelection(event.getSelection()); - } - }); - ignoreAction.setSelection(viewer.getSelection()); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#setActionBars(org.eclipse.ui.IActionBars) - */ - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - IToolBarManager toolbar = actionBars.getToolBarManager(); - if (toolbar != null) { - toolbar.add(new Separator()); - toolbar.add(commitToolbar); - toolbar.add(ignoreAction); - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.sync.AbstractSynchronizeParticipant#dispose() - */ - public void dispose() { - super.dispose(); - removeInputChangedListener(this); - CVSUIPlugin.removePropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.team.ui.synchronize.presentation.ISynchronizeModelChangeListener#inputChanged(org.eclipse.team.ui.synchronize.presentation.SynchronizeModelProvider) - */ - public void modelChanged(ISynchronizeModelElement root) { - commitToolbar.setSelection(root); - Display.getDefault().syncExec(new Runnable() { - public void run() { - ignoreAction.setSelection(getViewer().getSelection()); - } - }); - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeCompareInput.java deleted file mode 100644 index eafa44735..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeCompareInput.java +++ /dev/null @@ -1,302 +0,0 @@ -/******************************************************************************* - * 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.lang.reflect.InvocationTargetException; - -import org.eclipse.compare.*; -import org.eclipse.compare.internal.CompareEditor; -import org.eclipse.compare.internal.INavigatable; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ui.Utils; -import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; -import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.team.ui.ISharedImages; -import org.eclipse.team.ui.TeamImages; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.progress.IProgressService; - -/** - * A CompareEditorInput whose diff viewer shows the resources contained - * in a SyncInfoSet. The configuration of the diff viewer is determined by the - * SyncInfoSetCompareConfiguration that is used to create the - * SynchronizeCompareInput. - * - * uses the presentation model defined by the configuration. - * - * @since 3.0 - */ -public class SynchronizeCompareInput extends CompareEditorInput implements IContentChangeListener { - - private TreeViewerAdvisor diffViewerConfiguration; - private Viewer diffViewer; - private NavigationAction nextAction; - private NavigationAction previousAction; - - private boolean buffered = false; - - /** - * Create a SynchronizeCompareInput whose diff viewer is configured - * using the provided SyncInfoSetCompareConfiguration. - * @param configuration the compare configuration - * @param diffViewerConfiguration the diff viewer configuration - */ - public SynchronizeCompareInput(CompareConfiguration configuration, TreeViewerAdvisor diffViewerConfiguration) { - super(configuration); - this.diffViewerConfiguration = diffViewerConfiguration; - } - - public final Viewer createDiffViewer(Composite parent) { - this.diffViewer = internalCreateDiffViewer(parent, getViewerConfiguration()); - diffViewer.getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); - - // buffered merge mode, don't ask for save when switching nodes since contents will be buffered in diff nodes - // and saved when the input is saved. - if(isBuffered()) { - getCompareConfiguration().setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false)); - } - - /* - * This viewer can participate in navigation support in compare editor inputs. Note that - * it is currently accessing an internal compare interface that should be made public. See - * the following bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=48795. - */ - INavigatable nav= new INavigatable() { - public boolean gotoDifference(boolean next) { - return diffViewerConfiguration.navigate(next); - } - }; - diffViewer.getControl().setData(INavigatable.NAVIGATOR_PROPERTY, nav); - - nextAction = new NavigationAction(true); - previousAction = new NavigationAction(false); - nextAction.setCompareEditorInput(this); - previousAction.setCompareEditorInput(this); - - initializeToolBar(diffViewer.getControl().getParent()); - initializeDiffViewer(diffViewer); - diffViewerConfiguration.navigate(true); - return diffViewer; - } - - /** - * Create the diff viewer for this compare input. This method simply creates the widget. - * Any initialization is performed in the initializeDiffViewer(StructuredViewer) - * method. The default diff viewer is a SyncInfoDiffTreeViewer. Subclass may override. - * @param parent the parent Composite of the diff viewer to be created - * @param diffViewerConfiguration the configuration for the diff viewer - * @return the created diff viewer - */ - protected StructuredViewer internalCreateDiffViewer(Composite parent, TreeViewerAdvisor diffViewerConfiguration) { - TreeViewer viewer = new TreeViewerAdvisor.NavigableTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - GridData data = new GridData(GridData.FILL_BOTH); - viewer.getControl().setLayoutData(data); - diffViewerConfiguration.initializeViewer(viewer); - return viewer; - } - - protected TreeViewerAdvisor getViewerConfiguration() { - return diffViewerConfiguration; - } - - protected Viewer getViewer() { - return diffViewer; - } - - /** - * Initialize the diff viewer created for this compare input. If a subclass - * overrides the createDiffViewer(Composite) method, it should - * invoke this method on the created viewer in order to get the proper - * labelling in the compare input's contents viewers. - * @param viewer the diff viewer created by the compare input - */ - protected void initializeDiffViewer(Viewer viewer) { - if (viewer instanceof StructuredViewer) { - ((StructuredViewer) viewer).addOpenListener(new IOpenListener() { - public void open(OpenEvent event) { - ISelection s = event.getSelection(); - final SyncInfoModelElement node = getElement(s); - if (node != null) { - IResource resource = node.getResource(); - int kind = node.getKind(); - if (resource != null && resource.getType() == IResource.FILE) { - // Cache the contents because compare doesn't show progress - // when calling getContents on a diff node. - IProgressService manager = PlatformUI.getWorkbench().getProgressService(); - try { - node.cacheContents(new NullProgressMonitor()); - hookContentChangeListener(node); - } catch (TeamException e) { - Utils.handle(e); - } finally { - // Update the labels even if the content wasn't fetched correctly. This is - // required because the selection would still of changed. - Utils.updateLabels(node.getSyncInfo(), getCompareConfiguration()); - } - } - } - } - }); - } - } - - private void hookContentChangeListener(DiffNode node) { - ITypedElement left = node.getLeft(); - if(left instanceof IContentChangeNotifier) { - ((IContentChangeNotifier)left).addContentChangeListener(this); - } - ITypedElement right = node.getRight(); - if(right instanceof IContentChangeNotifier) { - ((IContentChangeNotifier)right).addContentChangeListener(this); - } - } - - public void contributeToToolBar(ToolBarManager tbm) { - if(nextAction != null && previousAction != null) { - tbm.appendToGroup("navigation", nextAction); //$NON-NLS-1$ - tbm.appendToGroup("navigation", previousAction); //$NON-NLS-1$ - } - } - - private void initializeToolBar(Composite parent) { - ToolBarManager tbm= CompareViewerPane.getToolBarManager(parent); - if (tbm != null) { - tbm.removeAll(); - tbm.add(new Separator("navigation")); //$NON-NLS-1$ - contributeToToolBar(tbm); - IActionBars bars = getActionBars(tbm); - getViewerConfiguration().setActionBars(bars); - tbm.update(true); - } - } - - /* private */ SyncInfoModelElement getElement(ISelection selection) { - if (selection != null && selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection) selection; - if (ss.size() == 1) { - Object o = ss.getFirstElement(); - if(o instanceof SyncInfoModelElement) { - return (SyncInfoModelElement)o; - } - } - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#prepareInput(org.eclipse.core.runtime.IProgressMonitor) - */ - protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - return getViewerConfiguration().prepareInput(monitor); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } - } - - /* - * (non-Javadoc) - * @see CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor) - */ - public void saveChanges(IProgressMonitor pm) throws CoreException { - super.saveChanges(pm); - ISynchronizeModelElement root = (ISynchronizeModelElement)diffViewerConfiguration.getViewer().getInput(); - if (root != null && root instanceof DiffNode) { - try { - commit(pm, (DiffNode)root); - } finally { - setDirty(false); - } - } - } - - private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { - ITypedElement left = node.getLeft(); - if (left instanceof LocalResourceTypedElement) - ((LocalResourceTypedElement) left).commit(pm); - - ITypedElement right = node.getRight(); - if (right instanceof LocalResourceTypedElement) - ((LocalResourceTypedElement) right).commit(pm); - - //node.getC - IDiffElement[] children = (IDiffElement[])node.getChildren(); - for (int i = 0; i < children.length; i++) { - commit(pm, (DiffNode)children[i]); - } - } - - /* (non-Javadoc) - * @see org.eclipse.compare.IContentChangeListener#contentChanged(org.eclipse.compare.IContentChangeNotifier) - */ - public void contentChanged(IContentChangeNotifier source) { - try { - if (isBuffered()) { - setDirty(true); - } else if (source instanceof DiffNode) { - commit(new NullProgressMonitor(), (DiffNode) source); - } else if (source instanceof LocalResourceTypedElement) { - ((LocalResourceTypedElement) source).commit(new NullProgressMonitor()); - } - } catch (CoreException e) { - Utils.handle(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.compare.CompareEditorInput#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return TeamImages.getImageDescriptor(ISharedImages.IMG_COMPARE_VIEW); - } - - /** - * Returns true if this compare input will buffer node content changes until the input is saved, - * otherwise content changes are saved to disk immediatly when each node is saved in the content merge viewer. - */ - public boolean isBuffered() { - return buffered; - } - - private IActionBars getActionBars(final IToolBarManager toolbar) { - return new IActionBars() { - public void clearGlobalActionHandlers() { - } - public IAction getGlobalActionHandler(String actionId) { - return null; - } - public IMenuManager getMenuManager() { - return null; - } - public IStatusLineManager getStatusLineManager() { - return null; - } - public IToolBarManager getToolBarManager() { - return toolbar; - } - public void setGlobalActionHandler(String actionId, IAction handler) { - } - public void updateActionBars() { - } - }; - } -} \ No newline at end of file -- cgit v1.2.3