Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-03-02 16:33:15 +0000
committerJean Michel-Lemieux2004-03-02 16:33:15 +0000
commit5a8cbc6a4f8db97629901af598e2a46889a97a44 (patch)
tree338f0c9b7b455992b96d2166f1ac0118f8a100ff
parentaab84e646a573615c9f9d93cbb2ab79debe5e168 (diff)
downloadeclipse.platform.team-5a8cbc6a4f8db97629901af598e2a46889a97a44.tar.gz
eclipse.platform.team-5a8cbc6a4f8db97629901af598e2a46889a97a44.tar.xz
eclipse.platform.team-5a8cbc6a4f8db97629901af598e2a46889a97a44.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java31
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java77
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java77
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/html/00041.html4
5 files changed, 141 insertions, 50 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
index 787cf6d32..2020d6b55 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
@@ -19,7 +19,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.events.TreeAdapter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber;
import org.eclipse.team.internal.ccvs.core.CVSTag;
@@ -28,8 +27,6 @@ import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant;
import org.eclipse.team.ui.synchronize.subscriber.*;
import org.eclipse.team.ui.synchronize.viewers.*;
-import org.eclipse.team.ui.synchronize.viewers.CompareDialog;
-import org.eclipse.team.ui.synchronize.viewers.SyncInfoCompareInput;
public class CompareWithTagAction extends WorkspaceAction {
@@ -50,25 +47,17 @@ public class CompareWithTagAction extends WorkspaceAction {
public void run() {
if (event.getChanges().length == 0) {
MessageDialog.openInformation(getShell(), "Compare Complete", "No changes found comparing resources");
+ return;
}
- if (isFolderCompare(resources)) {
- compareAndOpenDialog(event, participant);
- } else {
- MessageDialog.openInformation(getShell(), "Compare Complete", event.getChanges().length + " change(s) found comparing " + resources.length + " files. Compare editors will now be opened to show the changes.");
+ if (isSingleFileCompare(resources)) {
compareAndOpenEditors(event, participant);
+ } else {
+ compareAndOpenDialog(event, participant);
}
}
});
}
});
-
-
- /*IWorkbenchWindow wWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage activePage = null;
- if (wWindow != null) {
- activePage = wWindow.getActivePage();
- }*/
-
}
/**
@@ -79,20 +68,15 @@ public class CompareWithTagAction extends WorkspaceAction {
* @return <code>true</code> if at least one element in the selection
* is a folder and <code>false</code> otherwise.
*/
- protected boolean isFolderCompare(IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- if(resources[i].getType() != IResource.FILE) {
- return true;
- }
- }
- return false;
+ protected boolean isSingleFileCompare(IResource[] resources) {
+ return resources.length == 1 && resources[0].getType() == IResource.FILE;
}
protected void compareAndOpenEditors(IRefreshEvent event, CompareParticipant participant) {
SyncInfo[] changes= event.getChanges();
for (int i = 0; i < changes.length; i++) {
SyncInfo info = changes[i];
- CompareUI.openCompareDialog(new SyncInfoCompareInput(event.getSubscriber().getName(), info));
+ CompareUI.openCompareEditor(new SyncInfoCompareInput(event.getSubscriber().getName(), info));
}
}
@@ -110,6 +94,7 @@ public class CompareWithTagAction extends WorkspaceAction {
e.printStackTrace();
}
CompareDialog dialog = new CompareDialog(getShell(), input);
+ dialog.setSynchronizeParticipant(participant);
dialog.setBlockOnOpen(true);
dialog.open();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java
index 237a00fea..09f3e6fef 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java
@@ -78,6 +78,7 @@ public class LocalResourceTypedElement extends ResourceNode {
file.create(is, false, pm);
fDirty= false;
} finally {
+ fireContentChanged();
if (is != null)
try {
is.close();
@@ -124,6 +125,7 @@ public class LocalResourceTypedElement extends ResourceNode {
} catch (CoreException ex) {
}
}
+ fireContentChanged();
return child;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java
index d46d0b03f..2b598ecd4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/CompareDialog.java
@@ -10,32 +10,49 @@
*******************************************************************************/
package org.eclipse.team.ui.synchronize.viewers;
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.internal.ResizableDialog;
+import org.eclipse.core.runtime.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
-;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.TeamUI;
+import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
-public class CompareDialog extends Dialog {
+public class CompareDialog extends ResizableDialog {
private CompareEditorInput fCompareEditorInput;
+ private ISynchronizeParticipant participant;
public CompareDialog(Shell shell, CompareEditorInput input) {
- super(shell);
- setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
+ super(shell, null);
Assert.isNotNull(input);
fCompareEditorInput= input;
}
+
+ public void setSynchronizeParticipant(ISynchronizeParticipant participant) {
+ this.participant = participant;
+ }
/* (non-Javadoc)
* Method declared on Dialog.
*/
protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, "Done", false);
+ if(participant != null) {
+ Button b = createButton(parent, IDialogConstants.OPEN_ID, "Remember", false);
+ b.setToolTipText("Remembering this comparison will add it to the Synchronize View.");
+ }
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
/* (non-Javadoc)
@@ -54,4 +71,52 @@ public class CompareDialog extends Dialog {
Dialog.applyDialogFont(parent2);
return parent;
}
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ protected void buttonPressed(int buttonId) {
+ if(buttonId == IDialogConstants.OPEN_ID) {
+ ISynchronizeManager mgr = TeamUI.getSynchronizeManager();
+ ISynchronizeView view = mgr.showSynchronizeViewInActivePage(null);
+ mgr.addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
+ view.display(participant);
+ okPressed();
+ return;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Window.
+ */
+ public int open() {
+
+ int rc= super.open();
+
+ if (rc == IDialogConstants.OK_ID && fCompareEditorInput.isSaveNeeded()) {
+
+ final WorkspaceModifyOperation operation= new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor pm) throws CoreException {
+ fCompareEditorInput.saveChanges(pm);
+ }
+ };
+
+ try {
+ PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ operation.run(monitor);
+ }
+ });
+ } catch (InterruptedException x) {
+ // NeedWork
+ } catch (OperationCanceledException x) {
+ // NeedWork
+ } catch (InvocationTargetException x) {
+ Utils.handle(x);
+ }
+ }
+ return rc;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java
index 3f03b9bd0..da8e99e4e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SynchronizeCompareInput.java
@@ -12,30 +12,21 @@ package org.eclipse.team.ui.synchronize.viewers;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.CompareViewerPane;
-import org.eclipse.compare.NavigationAction;
+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.core.resources.IResource;
import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
+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.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
@@ -49,7 +40,7 @@ import org.eclipse.ui.progress.IProgressService;
*
* @since 3.0
*/
-public class SynchronizeCompareInput extends CompareEditorInput {
+public class SynchronizeCompareInput extends CompareEditorInput implements IContentChangeListener {
private TreeViewerAdvisor diffViewerConfiguration;
private Viewer diffViewer;
@@ -71,6 +62,9 @@ public class SynchronizeCompareInput extends CompareEditorInput {
this.diffViewer = internalCreateDiffViewer(parent, getViewerConfiguration());
diffViewer.getControl().setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
+ // buffered merge mode, don't ask for save when switching nodes
+ 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
@@ -140,6 +134,7 @@ public class SynchronizeCompareInput extends CompareEditorInput {
IProgressService manager = PlatformUI.getWorkbench().getProgressService();
try {
node.cacheContents(new NullProgressMonitor());
+ hookContentChangeListener(node);
} catch (TeamException e) {
Utils.handle(e);
} finally {
@@ -154,6 +149,17 @@ public class SynchronizeCompareInput extends CompareEditorInput {
}
}
+ 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$
@@ -194,12 +200,43 @@ public class SynchronizeCompareInput extends CompareEditorInput {
throw new InvocationTargetException(e);
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.compare.CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor)
+
+ /*
+ * (non-Javadoc)
+ * @see CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor)
*/
public void saveChanges(IProgressMonitor pm) throws CoreException {
- // TODO Auto-generated method stub
super.saveChanges(pm);
+ SynchronizeModelElement root = diffViewerConfiguration.getModelProvider().getModelRoot();
+ if (root != null) {
+ try {
+ commit(pm, 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
+ DiffNode[] children = (DiffNode[])node.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ commit(pm, children[i]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.IContentChangeListener#contentChanged(org.eclipse.compare.IContentChangeNotifier)
+ */
+ public void contentChanged(IContentChangeNotifier source) {
+ setDirty(true);
}
-}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/html/00041.html b/tests/org.eclipse.team.tests.cvs.core/html/00041.html
index 0afb31ffa..cf04c052e 100644
--- a/tests/org.eclipse.team.tests.cvs.core/html/00041.html
+++ b/tests/org.eclipse.team.tests.cvs.core/html/00041.html
@@ -4,7 +4,7 @@
<meta NAME="since" content="">
</head><h2>File Revisions</h2>
<p>Since: M8<br>
-Last Modified: $Date: 2004/03/02 05:19:21 $</p><body>
+Last Modified: $Date: 2004/03/02 05:23:42 $</p><body>
Comparing
-> Team > Synchronize with Repository... (file, folder)
@@ -19,6 +19,7 @@ Comparing
-> Compare With > Two other branches or versions (file, folder) [note: this is meant to be a quick way of comparing two lineups you don't have locally. instead of having to browse the repo view all the time]
-> Compare With > Another branch/version (file, folder)
-> Compare With > Revision (file)
+-> Replace With > Restore From Repository (folder)
Options:
-> sync view
@@ -36,5 +37,6 @@ Features:
- ensure editable property is ok
- ensure save behavior
- can you see the history for each file?
+- what actions are enabled for dialog versus sync view mode?
</body></html> \ No newline at end of file

Back to the top