Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2002-04-08 12:02:32 -0400
committerAndre Weinand2002-04-08 12:02:32 -0400
commitd4060b25802794799be83dd5ae2d22f84bf659b5 (patch)
tree702cacb3cfaa7e66d5e1c0f44b78d8bb0abd1b34
parentf8d9abec8475be9b9d548ab066288b9d9d63145f (diff)
downloadeclipse.platform.team-d4060b25802794799be83dd5ae2d22f84bf659b5.tar.gz
eclipse.platform.team-d4060b25802794799be83dd5ae2d22f84bf659b5.tar.xz
eclipse.platform.team-d4060b25802794799be83dd5ae2d22f84bf659b5.zip
First batch of M5 fixes
-rw-r--r--bundles/org.eclipse.compare/buildnotes_compare.html31
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java13
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java187
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java125
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java333
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java40
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java10
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java40
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties1
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java22
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java6
-rw-r--r--bundles/org.eclipse.compare/plugin.properties8
-rw-r--r--bundles/org.eclipse.compare/plugin.xml13
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html31
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java13
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java187
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java125
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java333
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java40
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java10
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java40
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java5
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties1
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java22
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties8
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml13
30 files changed, 1468 insertions, 212 deletions
diff --git a/bundles/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/buildnotes_compare.html
index 8a7d8d8fb..8739886db 100644
--- a/bundles/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/buildnotes_compare.html
@@ -11,6 +11,37 @@
<h1>
Eclipse Platform Build Notes<br>
Compare</h1>
+Eclipse Build Input April 2nd 2002
+
+<h2>
+What's new in this drop</h2>
+
+<h3>
+API changes</h3>
+
+<h3>
+API Additions</h3>
+
+<h3>
+Other highlights</h3>
+
+<h2>
+Known deficiencies</h2>
+
+<h2>
+Problem reports fixed</h2>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11578">#11578</a>: Patch: Missing resource on dialog<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11579">#11579</a>: Compare with Patch should be disabled on closed projects<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11907">#11907</a>: clicking in bird's eye view spots does nothing if panes not synched<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11536">#11536</a>: Option to turn off structured comparison<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=10682">#10682</a>: Need better UI for recovering deletions from local history<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11446">#11446</a>: provide "add from local history" for compilation units<br>
+
+<h2>
+Problem reports closed</h2>
+
+<h1>
+<hr WIDTH="100%"></h1>
Eclipse Build Input March 18th 2002
<h2>
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index d6ac8c45d..a547d7261 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -27,6 +27,7 @@ import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
@@ -138,6 +139,10 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
setDirty(true);
}
};
+
+ IPreferenceStore ps= configuration.getPreferenceStore();
+ if (ps != null)
+ fStructureCompareOnSingleClick= ps.getBoolean(ComparePreferencePage.OPEN_STRUCTURE_COMPARE);
}
private boolean structureCompareOnSingleClick() {
@@ -470,13 +475,9 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
fStructurePane1.setInput(null);
} else {
Object input= getElement(selection);
- if (structureCompareOnSingleClick()) {
+ fContentInputPane.setInput(input);
+ if (structureCompareOnSingleClick())
fStructurePane1.setInput(input);
- //if (fStructurePane1.isEmpty())
- fContentInputPane.setInput(input);
- } else {
- fContentInputPane.setInput(input);
- }
fStructurePane2.setInput(null); // clear downstream pane
if (fStructurePane1.getInput() != input)
fStructurePane1.setInput(null);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index ab115e0ad..1897291f5 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -508,6 +508,21 @@ public class TextMergeViewer extends ContentMergeViewer {
h= Math.max(h, fAncestor.getLineRange(fAncestorPos, region).y);
return Math.max(h, fRight.getLineRange(fRightPos, region).y);
}
+
+ int getAncestorHeight() {
+ Point region= new Point(0, 0);
+ return fAncestor.getLineRange(fAncestorPos, region).y;
+ }
+
+ int getLeftHeight() {
+ Point region= new Point(0, 0);
+ return fLeft.getLineRange(fLeftPos, region).y;
+ }
+
+ int getRightHeight() {
+ Point region= new Point(0, 0);
+ return fRight.getLineRange(fRightPos, region).y;
+ }
}
//---- MergeTextViewer
@@ -751,7 +766,8 @@ public class TextMergeViewer extends ContentMergeViewer {
fVScrollBar.addListener(SWT.Selection,
new Listener() {
public void handleEvent(Event e) {
- scrollVertical(((ScrollBar)e.widget).getSelection(), null);
+ int vpos= ((ScrollBar)e.widget).getSelection();
+ scrollVertical(vpos, vpos, vpos, null);
}
}
);
@@ -796,7 +812,7 @@ public class TextMergeViewer extends ContentMergeViewer {
Point size= canvas.getSize();
- int virtualHeight= getVirtualHeight();
+ int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight();
if (virtualHeight < getViewportHeight())
return null;
@@ -805,7 +821,8 @@ public class TextMergeViewer extends ContentMergeViewer {
Iterator e= fAllDiffs.iterator();
for (int i= 0; e.hasNext(); i++) {
Diff diff= (Diff) e.next();
- int h= diff.getMaxDiffHeight(fShowAncestor);
+ int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor)
+ : diff.getRightHeight();
if (useChange(diff.fDirection) && !diff.fIsWhitespace) {
yy= (y*size.y)/virtualHeight;
@@ -830,7 +847,7 @@ public class TextMergeViewer extends ContentMergeViewer {
Point size= canvas.getSize();
- int virtualHeight= getVirtualHeight();
+ int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight();
if (virtualHeight < getViewportHeight())
return;
@@ -839,7 +856,8 @@ public class TextMergeViewer extends ContentMergeViewer {
Iterator e= fAllDiffs.iterator();
for (int i= 0; e.hasNext(); i++) {
Diff diff= (Diff) e.next();
- int h= diff.getMaxDiffHeight(fShowAncestor);
+ int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor)
+ : diff.getRightHeight();
if (useChange(diff.fDirection) && !diff.fIsWhitespace) {
yy= (y*size.y)/virtualHeight;
@@ -875,19 +893,6 @@ public class TextMergeViewer extends ContentMergeViewer {
y+= h;
}
}
-
- /*
- if (fVScrollBar != null) {
- c= Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
- gc.setForeground(c);
-
- yy= (fVScrollBar.getSelection()*size.y)/virtualHeight;
- hh= (fVScrollBar.getThumb()*size.y)/virtualHeight;
-
- gc.setLineWidth(1);
- gc.drawRectangle(0, yy, BIRDS_EYE_VIEW_WIDTH, hh);
- }
- */
}
private void refreshBirdsEyeView() {
@@ -2440,7 +2445,7 @@ public class TextMergeViewer extends ContentMergeViewer {
private void toggleSynchMode() {
fSynchronizedScrolling= ! fSynchronizedScrolling;
- scrollVertical(0, null);
+ scrollVertical(0, 0, 0, null);
// throw away central control (Sash or Canvas)
Control center= getCenter();
@@ -2950,36 +2955,53 @@ public class TextMergeViewer extends ContentMergeViewer {
// vertical scrolling
if (!leftIsVisible || !rightIsVisible) {
- int vpos= 0;
+ int avpos= 0, lvpos= 0, rvpos= 0;
MergeSourceViewer allButThis= null;
if (leftIsVisible) {
- vpos= realToVirtualPosition(fLeft, fLeft.getTopIndex());
+ avpos= lvpos= rvpos= realToVirtualPosition(fLeft, fLeft.getTopIndex());
allButThis= fLeft;
} else if (rightIsVisible) {
- vpos= realToVirtualPosition(fRight, fRight.getTopIndex());
+ avpos= lvpos= rvpos= realToVirtualPosition(fRight, fRight.getTopIndex());
allButThis= fRight;
} else if (ancestorIsVisible) {
- vpos= realToVirtualPosition(fAncestor, fAncestor.getTopIndex());
+ avpos= lvpos= rvpos= realToVirtualPosition(fAncestor, fAncestor.getTopIndex());
allButThis= fAncestor;
} else {
if (fAllDiffs != null) {
+ int vpos= 0;
Iterator e= fAllDiffs.iterator();
for (int i= 0; e.hasNext(); i++) {
Diff diff= (Diff) e.next();
if (diff == d)
break;
- vpos+= diff.getMaxDiffHeight(fShowAncestor);
+ if (fSynchronizedScrolling) {
+ vpos+= diff.getMaxDiffHeight(fShowAncestor);
+ } else {
+ avpos+= diff.getAncestorHeight();
+ lvpos+= diff.getLeftHeight();
+ rvpos+= diff.getRightHeight();
+ }
}
+ if (fSynchronizedScrolling)
+ avpos= lvpos= rvpos= vpos;
}
- vpos-= fRight.getViewportLines()/4;
- if (vpos < 0)
- vpos= 0;
+ int delta= fRight.getViewportLines()/4;
+ avpos-= delta;
+ if (avpos < 0)
+ avpos= 0;
+ lvpos-= delta;
+ if (lvpos < 0)
+ lvpos= 0;
+ rvpos-= delta;
+ if (rvpos < 0)
+ rvpos= 0;
}
- scrollVertical(vpos, allButThis);
+ scrollVertical(avpos, lvpos, rvpos, allButThis);
+
if (fVScrollBar != null)
- fVScrollBar.setSelection(vpos);
+ fVScrollBar.setSelection(avpos);
}
// horizontal scrolling
@@ -3148,6 +3170,21 @@ public class TextMergeViewer extends ContentMergeViewer {
}
/**
+ * Calculates height (in lines) of right view by adding the height of the right diffs.
+ */
+ private int getRightHeight() {
+ int h= 1;
+ if (fAllDiffs != null) {
+ Iterator e= fAllDiffs.iterator();
+ for (int i= 0; e.hasNext(); i++) {
+ Diff diff= (Diff) e.next();
+ h+= diff.getRightHeight();
+ }
+ }
+ return h;
+ }
+
+ /**
* The height of the TextEditors in lines.
*/
private int getViewportHeight() {
@@ -3203,66 +3240,56 @@ public class TextMergeViewer extends ContentMergeViewer {
return virtualPos;
}
- private void scrollVertical(int virtualPos, MergeSourceViewer allBut) {
-
- if (virtualPos < 0)
- virtualPos= virtualPos;
+ private void scrollVertical(int avpos, int lvpos, int rvpos, MergeSourceViewer allBut) {
+
+ int s= 0;
if (fSynchronizedScrolling) {
- int s= 0;
-
- if (true) {
- s= getVirtualHeight() - virtualPos;
- int height= fRight.getViewportLines()/4;
- if (s < 0)
- s= 0;
- if (s > height)
- s= height;
- }
-
- fInScrolling= true;
-
- if (isThreeWay() && allBut != fAncestor) {
- int y= virtualToRealPosition(fAncestor, virtualPos+s)-s;
+ s= getVirtualHeight() - rvpos;
+ int height= fRight.getViewportLines()/4;
+ if (s < 0)
+ s= 0;
+ if (s > height)
+ s= height;
+ }
+
+ fInScrolling= true;
+
+ if (isThreeWay() && allBut != fAncestor) {
+ if (fSynchronizedScrolling || allBut == null) {
+ int y= virtualToRealPosition(fAncestor, avpos+s)-s;
fAncestor.vscroll(y);
}
-
- if (allBut != fLeft) {
- int y= virtualToRealPosition(fLeft, virtualPos+s)-s;
+ }
+
+ if (allBut != fLeft) {
+ if (fSynchronizedScrolling || allBut == null) {
+ int y= virtualToRealPosition(fLeft, lvpos+s)-s;
fLeft.vscroll(y);
}
-
- if (allBut != fRight) {
- int y= virtualToRealPosition(fRight, virtualPos+s)-s;
+ }
+
+ if (allBut != fRight) {
+ if (fSynchronizedScrolling || allBut == null) {
+ int y= virtualToRealPosition(fRight, rvpos+s)-s;
fRight.vscroll(y);
}
-
- fInScrolling= false;
-
- if (isThreeWay() && fAncestorCanvas != null)
- fAncestorCanvas.repaint();
-
- if (fLeftCanvas != null)
- fLeftCanvas.repaint();
-
- Control center= getCenter();
- if (center instanceof BufferedCanvas)
- ((BufferedCanvas)center).repaint();
-
- if (fRightCanvas != null)
- fRightCanvas.repaint();
- } else {
- if (allBut == fAncestor && fAncestorCanvas != null && isThreeWay())
- fAncestorCanvas.repaint();
-
- if (allBut == fLeft && fLeftCanvas != null)
- fLeftCanvas.repaint();
-
- if (allBut == fRight && fRightCanvas != null)
- fRightCanvas.repaint();
}
- //refreshBirdsEyeView();
+ fInScrolling= false;
+
+ if (isThreeWay() && fAncestorCanvas != null)
+ fAncestorCanvas.repaint();
+
+ if (fLeftCanvas != null)
+ fLeftCanvas.repaint();
+
+ Control center= getCenter();
+ if (center instanceof BufferedCanvas)
+ ((BufferedCanvas)center).repaint();
+
+ if (fRightCanvas != null)
+ fRightCanvas.repaint();
}
/**
@@ -3278,7 +3305,7 @@ public class TextMergeViewer extends ContentMergeViewer {
int viewPosition= realToVirtualPosition(w, ix-ix2);
- scrollVertical(viewPosition, w); // scroll all but the given views
+ scrollVertical(viewPosition, viewPosition, viewPosition, w); // scroll all but the given views
if (fVScrollBar != null) {
int value= Math.max(0, Math.min(viewPosition, getVirtualHeight() - getViewportHeight()));
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java
new file mode 100644
index 000000000..7e8e9f107
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java
@@ -0,0 +1,125 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package org.eclipse.compare.internal;
+
+import java.util.ResourceBundle;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.IActionDelegate;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
+
+public class AddFromHistoryAction implements IActionDelegate {
+
+ private static final String BUNDLE_NAME= "org.eclipse.compare.internal.AddFromHistoryAction"; //$NON-NLS-1$
+
+ private ISelection fSelection;
+
+ public AddFromHistoryAction() {
+ }
+
+ public void selectionChanged(IAction a, ISelection s) {
+ fSelection= s;
+ }
+
+ public void run(IAction action) {
+
+ ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME);
+ String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$
+
+ Shell parentShell= CompareUIPlugin.getShell();
+ AddFromHistoryDialog dialog= null;
+
+ Object[] s= Utilities.getResources(fSelection);
+
+ for (int i= 0; i < s.length; i++) {
+ Object o= s[i];
+ if (o instanceof IContainer) {
+ IContainer container= (IContainer) o;
+
+ ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell);
+ IProgressMonitor pm= pmdialog.getProgressMonitor();
+ IFile[] states= null;
+ try {
+ states= container.findDeletedMembersWithHistory(IContainer.DEPTH_INFINITE, pm);
+ } catch (CoreException ex) {
+ pm.done();
+ }
+
+ if (states == null || states.length <= 0) {
+ String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$
+ MessageDialog.openInformation(parentShell, title, msg);
+ return;
+ }
+
+ if (dialog == null)
+ dialog= new AddFromHistoryDialog(parentShell, bundle);
+
+ if (dialog.select(container, states)) {
+ IFile file= dialog.getSelectedFile();
+ IFileState fileState= dialog.getSelectedFileState();
+ if (file != null && fileState != null) {
+ try {
+ updateWorkspace(bundle, parentShell, file, fileState);
+
+ } catch (InterruptedException x) {
+ // Do nothing. Operation has been canceled by user.
+
+ } catch (InvocationTargetException x) {
+ String reason= x.getTargetException().getMessage();
+ MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void createContainers(IResource resource) throws CoreException {
+ IContainer container= resource.getParent();
+ if (container instanceof IFolder) {
+ IFolder parent= (IFolder) container;
+ if (parent != null && !parent.exists()) {
+ createContainers(parent);
+ parent.create(false, true, null);
+ }
+ }
+ }
+
+ private void updateWorkspace(final ResourceBundle bundle, Shell shell,
+ final IFile file, final IFileState fileState)
+ throws InvocationTargetException, InterruptedException {
+
+ WorkspaceModifyOperation operation= new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor pm) throws InvocationTargetException {
+ try {
+ String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$
+ pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+
+ createContainers(file);
+ file.create(fileState.getContents(), false, pm);
+
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ pm.done();
+ }
+ }
+ };
+
+ ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell);
+ pmdialog.run(false, true, operation);
+ }
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
new file mode 100644
index 000000000..8239b27ab
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
@@ -0,0 +1,333 @@
+package org.eclipse.compare.internal;
+
+import java.io.*;
+import java.text.*;
+import java.util.*;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.*;
+
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
+import org.eclipse.compare.*;
+
+
+public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog {
+
+ static class HistoryInput implements ITypedElement, IStreamContentAccessor, IModificationDate {
+ IFile fFile;
+ IFileState fFileState;
+
+ HistoryInput(IFile file, IFileState fileState) {
+ fFile= file;
+ fFileState= fileState;
+ }
+ public InputStream getContents() throws CoreException {
+ return new BufferedInputStream(fFileState.getContents());
+ }
+ public String getName() {
+ return fFile.getName();
+ }
+ public String getType() {
+ return fFile.getFileExtension();
+ }
+ public Image getImage() {
+ return CompareUI.getImage(fFile);
+ }
+ public long getModificationDate() {
+ return fFileState.getModificationTime();
+ }
+ }
+
+ private CompareConfiguration fCompareConfiguration;
+ private ResourceBundle fBundle;
+ private HistoryInput fSelectedItem;
+
+ // SWT controls
+ private CompareViewerSwitchingPane fContentPane;
+ private Button fCommitButton;
+ private Table fMemberTable;
+ private CompareViewerPane fMemberPane;
+ private Tree fEditionTree;
+ private CompareViewerPane fEditionPane;
+ private Image fDateImage;
+ private Image fTimeImage;
+ private CompareViewerSwitchingPane fStructuredComparePane;
+
+
+ public AddFromHistoryDialog(Shell parent, ResourceBundle bundle) {
+ super(parent);
+ setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE);
+
+ fBundle= bundle;
+
+ String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$
+ ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName);
+ if (id != null)
+ fDateImage= id.createImage();
+ iconName= Utilities.getString(fBundle, "timeIcon", "obj16/resource_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+ id= CompareUIPlugin.getImageDescriptor(iconName);
+ if (id != null)
+ fTimeImage= id.createImage();
+ }
+
+ public boolean select(IContainer root, IFile[] files) {
+
+ create(); // create widgets
+
+ String format= Utilities.getString(fBundle, "memberPaneTitle"); //$NON-NLS-1$
+ String title= MessageFormat.format(format, new Object[] { root.getName() });
+ fMemberPane.setImage(CompareUI.getImage(root));
+ fMemberPane.setText(title);
+
+ String prefix= root.getFullPath().toString();
+
+ if (fMemberTable != null && !fMemberTable.isDisposed()) {
+ for (int i= 0; i < files.length; i++) {
+ IFile file= files[i];
+ String path= file.getFullPath().toString();
+ if (path.startsWith(prefix))
+ path= path.substring(prefix.length()+1);
+ TableItem ti= new TableItem(fMemberTable, SWT.NONE);
+ ti.setImage(CompareUI.getImage(file));
+ ti.setText(path);
+ ti.setData(file);
+ }
+ }
+
+ open();
+
+ return (getReturnCode() == OK) && (fSelectedItem != null);
+ }
+
+ IFile getSelectedFile() {
+ if (fSelectedItem != null)
+ return fSelectedItem.fFile;
+ return null;
+ }
+
+ IFileState getSelectedFileState() {
+ if (fSelectedItem != null)
+ return fSelectedItem.fFileState;
+ return null;
+ }
+
+ protected synchronized Control createDialogArea(Composite parent) {
+
+ getShell().setText(Utilities.getString(fBundle, "title")); //$NON-NLS-1$
+
+ Splitter vsplitter= new Splitter(parent, SWT.VERTICAL);
+ vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
+
+ vsplitter.addDisposeListener(
+ new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if (fDateImage != null)
+ fDateImage.dispose();
+ if (fTimeImage != null)
+ fTimeImage.dispose();
+ }
+ }
+ );
+
+ // we need two panes: the left for the elements, the right one for the editions
+ Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL);
+
+ fMemberPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT);
+ fMemberTable= new Table(fMemberPane, SWT.H_SCROLL + SWT.V_SCROLL);
+ fMemberTable.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleMemberSelect(e.item);
+ }
+ }
+ );
+
+ fMemberPane.setContent(fMemberTable);
+
+ fEditionPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT);
+
+ fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL + SWT.V_SCROLL);
+ fEditionTree.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ feedContent(e.item);
+ }
+ }
+ );
+ fEditionPane.setContent(fEditionTree);
+
+ fContentPane= new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) {
+ protected Viewer getViewer(Viewer oldViewer, Object input) {
+ return CompareUIPlugin.findContentViewer(oldViewer, input, this, fCompareConfiguration);
+ }
+ };
+ vsplitter.setWeights(new int[] { 30, 70 });
+
+ return vsplitter;
+ }
+
+ /**
+ * Feeds selection from member viewer to edition viewer.
+ */
+ private void handleMemberSelect(Widget w) {
+ Object data= w.getData();
+ if (data instanceof IFile) {
+ IFile file= (IFile) data;
+ IFileState[] states= null;
+ try {
+ states= file.getHistory(new NullProgressMonitor());
+ } catch (CoreException ex) {
+ }
+
+ fEditionPane.setImage(CompareUI.getImage(file));
+ String pattern= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$
+ String title= MessageFormat.format(pattern, new Object[] { file.getName() });
+ fEditionPane.setText(title);
+
+ if (fEditionTree != null) {
+ fEditionTree.removeAll();
+ for (int i= 0; i < states.length; i++) {
+ addEdition(new HistoryInput(file, states[i]));
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds the given Pair to the edition tree.
+ * It takes care of creating tree nodes for different dates.
+ */
+ private void addEdition(HistoryInput input) {
+ if (fEditionTree == null || fEditionTree.isDisposed())
+ return;
+
+ IFileState state= input.fFileState;
+
+ // find last day
+ TreeItem[] days= fEditionTree.getItems();
+ TreeItem lastDay= null;
+ if (days.length > 0)
+ lastDay= days[days.length-1];
+
+ boolean first= lastDay == null;
+
+ long ldate= state.getModificationTime();
+ long day= dayNumber(ldate);
+ Date date= new Date(ldate);
+ if (lastDay == null || day != dayNumber(((Date)lastDay.getData()).getTime())) {
+ lastDay= new TreeItem(fEditionTree, SWT.NONE);
+ lastDay.setImage(fDateImage);
+ String df= DateFormat.getDateInstance().format(date);
+ long today= dayNumber(System.currentTimeMillis());
+
+ String formatKey;
+ if (day == today)
+ formatKey= "todayFormat"; //$NON-NLS-1$
+ else if (day == today-1)
+ formatKey= "yesterdayFormat"; //$NON-NLS-1$
+ else
+ formatKey= "dayFormat"; //$NON-NLS-1$
+ String pattern= Utilities.getString(fBundle, formatKey);
+ if (pattern != null)
+ df= MessageFormat.format(pattern, new String[] { df });
+ lastDay.setText(df);
+ lastDay.setData(date);
+ }
+ TreeItem ti= new TreeItem(lastDay, SWT.NONE);
+ ti.setImage(fTimeImage);
+ ti.setText(DateFormat.getTimeInstance().format(date));
+ ti.setData(input);
+
+ if (first) {
+ lastDay.setExpanded(true);
+ fEditionTree.setSelection(new TreeItem[] { ti });
+ feedContent(ti);
+ }
+ }
+
+ /**
+ * Returns the number of s since Jan 1st, 1970.
+ * The given date is converted to GMT and daylight saving is taken into account too.
+ */
+ private long dayNumber(long date) {
+ int ONE_DAY_MS= 24*60*60 * 1000; // one day in milli seconds
+
+ Calendar calendar= Calendar.getInstance();
+ long localTimeOffset= calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
+
+ return (date + localTimeOffset) / ONE_DAY_MS;
+ }
+
+ private void feedContent(Widget w) {
+ if (fContentPane != null && !fContentPane.isDisposed()) {
+ Object o= w.getData();
+ if (o instanceof HistoryInput) {
+ fSelectedItem= (HistoryInput) o;
+ fContentPane.setInput(fSelectedItem);
+ fContentPane.setText(getEditionLabel(fSelectedItem));
+ fContentPane.setImage(fTimeImage);
+ } else {
+ fSelectedItem= null;
+ fContentPane.setInput(null);
+ }
+ }
+ if (fCommitButton != null)
+ fCommitButton.setEnabled(fSelectedItem != null);
+ }
+
+ protected String getEditionLabel(HistoryInput input) {
+ String format= Utilities.getString(fBundle, "historyEditionLabel", null); //$NON-NLS-1$
+ if (format == null)
+ format= Utilities.getString(fBundle, "editionLabel"); //$NON-NLS-1$
+ if (format == null)
+ format= "x{0}"; //$NON-NLS-1$
+
+ long modDate= input.getModificationDate();
+ String date= DateFormat.getDateTimeInstance().format(new Date(modDate));
+
+ return MessageFormat.format(format, new Object[] { date });
+ }
+
+ /* (non Javadoc)
+ * Returns the size initialized with the constructor.
+ */
+ protected Point getInitialSize() {
+ Point size= new Point(Utilities.getInteger(fBundle, "width", 0), //$NON-NLS-1$
+ Utilities.getInteger(fBundle, "height", 0)); //$NON-NLS-1$
+
+ Shell shell= getParentShell();
+ if (shell != null) {
+ Point parentSize= shell.getSize();
+ if (size.x <= 0)
+ size.x= parentSize.x-300;
+ if (size.y <= 0)
+ size.y= parentSize.y-200;
+ }
+ if (size.x < 700)
+ size.x= 700;
+ if (size.y < 500)
+ size.y= 500;
+ return size;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ String buttonLabel= Utilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$
+ // a 'Cancel' and a 'Add' button
+ fCommitButton= createButton(parent, IDialogConstants.OK_ID, buttonLabel, true);
+ fCommitButton.setEnabled(false);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index 057ddb329..45f40301d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
@@ -48,6 +48,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
};
private static final String PREFIX= CompareUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+ public static final String OPEN_STRUCTURE_COMPARE= PREFIX + "OpenStructureCompare"; //$NON-NLS-1$
public static final String SYNCHRONIZE_SCROLLING= PREFIX + "SynchronizeScrolling"; //$NON-NLS-1$
public static final String SHOW_PSEUDO_CONFLICTS= PREFIX + "ShowPseudoConflicts"; //$NON-NLS-1$
public static final String INITIALLY_SHOW_ANCESTOR_PANE= PREFIX + "InitiallyShowAncestorPane"; //$NON-NLS-1$
@@ -65,6 +66,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, OPEN_STRUCTURE_COMPARE),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_PSEUDO_CONFLICTS),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE),
@@ -74,6 +76,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
public static void initDefaults(IPreferenceStore store) {
+ store.setDefault(OPEN_STRUCTURE_COMPARE, true);
store.setDefault(SYNCHRONIZE_SCROLLING, true);
store.setDefault(SHOW_PSEUDO_CONFLICTS, false);
store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false);
@@ -171,6 +174,39 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.load();
fOverlayStore.start();
+ TabFolder folder= new TabFolder(parent, SWT.NONE);
+ folder.setLayout(new TabFolderLayout());
+ folder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ TabItem item= new TabItem(folder, SWT.NONE);
+ item.setText(Utilities.getString("ComparePreferencePage.generalTab.label")); //$NON-NLS-1$
+ //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
+ item.setControl(createGeneralPage(folder));
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(Utilities.getString("ComparePreferencePage.textCompareTab.label")); //$NON-NLS-1$
+ //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
+ item.setControl(createTextComparePage(folder));
+
+ initializeFields();
+
+ return folder;
+ }
+
+ private Control createGeneralPage(Composite parent) {
+ Composite composite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 1;
+ composite.setLayout(layout);
+
+ addCheckBox(composite, "ComparePreferencePage.structureCompare.label", OPEN_STRUCTURE_COMPARE, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+
+ return composite;
+ }
+
+ private Control createTextComparePage(Composite parent) {
Composite composite= new Composite(parent, SWT.NULL);
GridLayout layout= new GridLayout();
layout.numColumns= 1;
@@ -182,8 +218,6 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
addCheckBox(composite, "ComparePreferencePage.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
-
fFontEditor= addTextFontEditor(composite, "ComparePreferencePage.textFont.label", TEXT_FONT); //$NON-NLS-1$
fFontEditor.setPreferenceStore(getPreferenceStore());
fFontEditor.setPreferencePage(this);
@@ -198,8 +232,6 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
gd.heightHint= convertHeightInCharsToPixels(15);
previewer.setLayoutData(gd);
- initializeFields();
-
return composite;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index 104029ec5..b463392ac 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -599,10 +599,13 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
if (in instanceof IStreamContentAccessor) {
String type= ITypedElement.TEXT_TYPE;
+
if (in instanceof ITypedElement) {
ITypedElement tin= (ITypedElement) in;
- type= tin.getType();
- }
+ String ty= tin.getType();
+ if (ty != null)
+ type= ty;
+ }
type= normalizeCase(type);
IViewerDescriptor vd= (IViewerDescriptor) fgContentViewerDescriptors.get(type);
@@ -616,6 +619,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return new SimpleTextViewer(parent);
}
+ if (!(in instanceof ICompareInput))
+ return null;
+
ICompareInput input= (ICompareInput) in;
String type= getType(input);
type= normalizeCase(type);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java
new file mode 100644
index 000000000..c33ac3c76
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java
@@ -0,0 +1,40 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+package org.eclipse.compare.internal; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Layout;
+
+public class TabFolderLayout extends Layout {
+
+ protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+ if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
+ return new Point(wHint, hHint);
+
+ Control [] children = composite.getChildren ();
+ int count = children.length;
+ int maxWidth = 0, maxHeight = 0;
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ maxWidth = Math.max (maxWidth, pt.x);
+ maxHeight = Math.max (maxHeight, pt.y);
+ }
+
+ if (wHint != SWT.DEFAULT)
+ maxWidth= wHint;
+ if (hHint != SWT.DEFAULT)
+ maxHeight= hHint;
+
+ return new Point(maxWidth, maxHeight);
+
+ }
+
+ protected void layout (Composite composite, boolean flushCache) {
+ Rectangle rect= composite.getClientArea();
+
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ children[i].setBounds(rect);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java
index cc4a73539..53ec608ec 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java
@@ -54,9 +54,10 @@ public class CompareWithPatchAction implements IActionDelegate {
public void selectionChanged(IAction action, ISelection selection) {
fSelection= selection;
- action.setEnabled(fSelection != null && !fSelection.isEmpty());
+ IResource[] resources= PatchWizard.getResource(fSelection);
+ action.setEnabled(resources != null && resources.length == 1);
}
-
+
public void run(IAction action) {
PatchWizard wizard= new PatchWizard(fSelection);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
index ea7f493da..fc42b3797 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
@@ -136,7 +136,7 @@ import org.eclipse.compare.internal.Utilities;
patcher.parse(new BufferedReader(reader));
} catch (IOException ex) {
MessageDialog.openError(null,
- PatchMessages.getString("InputPatchPage.PatchErrorDialog.title_2"), //$NON-NLS-1$
+ PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$
PatchMessages.getString("InputPatchPage.ParseError.message")); //$NON-NLS-1$
}
@@ -149,7 +149,7 @@ import org.eclipse.compare.internal.Utilities;
Diff[] diffs= patcher.getDiffs();
if (diffs == null || diffs.length == 0) {
MessageDialog.openError(null,
- PatchMessages.getString("InputPatchPage.PatchErrorDialog.title_4"), //$NON-NLS-1$
+ PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$
PatchMessages.getString("InputPatchPage.NoDiffsFound.message")); //$NON-NLS-1$
return this;
}
@@ -341,7 +341,7 @@ import org.eclipse.compare.internal.Utilities;
fPatchTargets.addSelectionChangedListener(
new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- fPatchWizard.setTarget(PatchWizard.getResource(event.getSelection()));
+ fPatchWizard.setTargets(PatchWizard.getResource(event.getSelection()));
updateWidgetEnablements();
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties
index f38a5966f..e63f1642d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties
@@ -68,6 +68,7 @@ Patcher.DeleteError.message=Error while deleting resource
Patcher.UpdateError.message=Error while updating resource
Patcher.RefreshError.message=Error while refreshing from local
Patcher.Marker.message=Rejected patch
+Patcher.Task.message=Patching
#
# PatchCompareInput
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
index 466b59a42..965970988 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
@@ -5,6 +5,7 @@
package org.eclipse.compare.internal.patch;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import org.eclipse.swt.graphics.Image;
@@ -42,7 +43,7 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
*/
/* package */ PatchWizard(ISelection selection) {
- fTarget= getResource(selection);
+ setTargets(getResource(selection));
fPatcher= new Patcher();
@@ -58,10 +59,19 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
}
}
- static IResource getResource(ISelection selection) {
+ static IResource[] getResource(ISelection selection) {
IResource[] rs= Utilities.getResources(selection);
- if (rs != null && rs.length > 0)
- return rs[0];
+ ArrayList list= null;
+ for (int i= 0; i < rs.length; i++) {
+ IResource r= rs[i];
+ if (r != null && r.isAccessible()) {
+ if (list == null)
+ list= new ArrayList();
+ list.add(r);
+ }
+ }
+ if (list != null && list.size() > 0)
+ return (IResource[]) list.toArray(new IResource[list.size()]);
return null;
}
@@ -73,8 +83,8 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
return fTarget;
}
- void setTarget(IResource target) {
- fTarget= target;
+ void setTargets(IResource[] targets) {
+ fTarget= targets[0]; // right now we can only deal with a single selection
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index b1ca8cd63..782348d45 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -751,8 +751,10 @@ public class Patcher {
Assert.isTrue(false);
}
- if (pm != null)
- pm.beginTask("Patching", fDiffs.length*WORK_UNIT);
+ if (pm != null) {
+ String message= PatchMessages.getString("Patcher.Task.message"); //$NON-NLS-1$
+ pm.beginTask(message, fDiffs.length*WORK_UNIT);
+ }
for (int i= 0; i < fDiffs.length; i++) {
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index a2eb74b8a..09fc42603 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -54,6 +54,9 @@ ReplaceFromHistoryAction.tooltip= Replace the Selected Resource with Local Histo
ReplaceWithPreviousFromHistoryAction.label= &Previous From Local History
ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with the Previous from Local History
+addFromHistoryAction.label= Add From Local History...
+addFromHistoryAction.tooltip= Add Deleted Files From Local History
+
#
# Preference Page
#
@@ -62,11 +65,14 @@ ComparePreferencePage.initiallyShowAncestorPane.label= Initially show a&ncestor
ComparePreferencePage.showPseudoConflicts.label= Show &pseudo conflicts
ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers
ComparePreferencePage.textFont.label= Text Font
-ComparePreferencePage.showMoreInfo.label= Show additional compare &information in status line
+ComparePreferencePage.showMoreInfo.label= Show additional compare &information in the status line
ComparePreferencePage.preview.label= Preview:
ComparePreferencePage.ancestor.label= Common Ancestor
ComparePreferencePage.left.label= Local
ComparePreferencePage.right.label= Remote
+ComparePreferencePage.structureCompare.label= Open structure compare automatically
+ComparePreferencePage.generalTab.label= &General
+ComparePreferencePage.textCompareTab.label= &Text Compare
#
# Toolbar actions
diff --git a/bundles/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugin.xml
index e6a811f7d..d8fdbf8df 100644
--- a/bundles/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugin.xml
@@ -147,6 +147,19 @@
</action>
</objectContribution>
+ <objectContribution
+ id="org.eclipse.compare.AddFromHistoryAction"
+ objectClass="org.eclipse.core.resources.IContainer" adaptable="true">
+ <action
+ id="addFromHistoryAction"
+ label="%addFromHistoryAction.label"
+ tooltip="%addFromHistoryAction.tooltip"
+ menubarPath="replaceWithMenu"
+ enablesFor="1"
+ class="org.eclipse.compare.internal.AddFromHistoryAction">
+ </action>
+ </objectContribution>
+
</extension>
<extension point="org.eclipse.compare.structureCreators">
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
index 8a7d8d8fb..8739886db 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
@@ -11,6 +11,37 @@
<h1>
Eclipse Platform Build Notes<br>
Compare</h1>
+Eclipse Build Input April 2nd 2002
+
+<h2>
+What's new in this drop</h2>
+
+<h3>
+API changes</h3>
+
+<h3>
+API Additions</h3>
+
+<h3>
+Other highlights</h3>
+
+<h2>
+Known deficiencies</h2>
+
+<h2>
+Problem reports fixed</h2>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11578">#11578</a>: Patch: Missing resource on dialog<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11579">#11579</a>: Compare with Patch should be disabled on closed projects<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11907">#11907</a>: clicking in bird's eye view spots does nothing if panes not synched<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11536">#11536</a>: Option to turn off structured comparison<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=10682">#10682</a>: Need better UI for recovering deletions from local history<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=11446">#11446</a>: provide "add from local history" for compilation units<br>
+
+<h2>
+Problem reports closed</h2>
+
+<h1>
+<hr WIDTH="100%"></h1>
Eclipse Build Input March 18th 2002
<h2>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index d6ac8c45d..a547d7261 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -27,6 +27,7 @@ import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
@@ -138,6 +139,10 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
setDirty(true);
}
};
+
+ IPreferenceStore ps= configuration.getPreferenceStore();
+ if (ps != null)
+ fStructureCompareOnSingleClick= ps.getBoolean(ComparePreferencePage.OPEN_STRUCTURE_COMPARE);
}
private boolean structureCompareOnSingleClick() {
@@ -470,13 +475,9 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
fStructurePane1.setInput(null);
} else {
Object input= getElement(selection);
- if (structureCompareOnSingleClick()) {
+ fContentInputPane.setInput(input);
+ if (structureCompareOnSingleClick())
fStructurePane1.setInput(input);
- //if (fStructurePane1.isEmpty())
- fContentInputPane.setInput(input);
- } else {
- fContentInputPane.setInput(input);
- }
fStructurePane2.setInput(null); // clear downstream pane
if (fStructurePane1.getInput() != input)
fStructurePane1.setInput(null);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index ab115e0ad..1897291f5 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -508,6 +508,21 @@ public class TextMergeViewer extends ContentMergeViewer {
h= Math.max(h, fAncestor.getLineRange(fAncestorPos, region).y);
return Math.max(h, fRight.getLineRange(fRightPos, region).y);
}
+
+ int getAncestorHeight() {
+ Point region= new Point(0, 0);
+ return fAncestor.getLineRange(fAncestorPos, region).y;
+ }
+
+ int getLeftHeight() {
+ Point region= new Point(0, 0);
+ return fLeft.getLineRange(fLeftPos, region).y;
+ }
+
+ int getRightHeight() {
+ Point region= new Point(0, 0);
+ return fRight.getLineRange(fRightPos, region).y;
+ }
}
//---- MergeTextViewer
@@ -751,7 +766,8 @@ public class TextMergeViewer extends ContentMergeViewer {
fVScrollBar.addListener(SWT.Selection,
new Listener() {
public void handleEvent(Event e) {
- scrollVertical(((ScrollBar)e.widget).getSelection(), null);
+ int vpos= ((ScrollBar)e.widget).getSelection();
+ scrollVertical(vpos, vpos, vpos, null);
}
}
);
@@ -796,7 +812,7 @@ public class TextMergeViewer extends ContentMergeViewer {
Point size= canvas.getSize();
- int virtualHeight= getVirtualHeight();
+ int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight();
if (virtualHeight < getViewportHeight())
return null;
@@ -805,7 +821,8 @@ public class TextMergeViewer extends ContentMergeViewer {
Iterator e= fAllDiffs.iterator();
for (int i= 0; e.hasNext(); i++) {
Diff diff= (Diff) e.next();
- int h= diff.getMaxDiffHeight(fShowAncestor);
+ int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor)
+ : diff.getRightHeight();
if (useChange(diff.fDirection) && !diff.fIsWhitespace) {
yy= (y*size.y)/virtualHeight;
@@ -830,7 +847,7 @@ public class TextMergeViewer extends ContentMergeViewer {
Point size= canvas.getSize();
- int virtualHeight= getVirtualHeight();
+ int virtualHeight= fSynchronizedScrolling ? getVirtualHeight() : getRightHeight();
if (virtualHeight < getViewportHeight())
return;
@@ -839,7 +856,8 @@ public class TextMergeViewer extends ContentMergeViewer {
Iterator e= fAllDiffs.iterator();
for (int i= 0; e.hasNext(); i++) {
Diff diff= (Diff) e.next();
- int h= diff.getMaxDiffHeight(fShowAncestor);
+ int h= fSynchronizedScrolling ? diff.getMaxDiffHeight(fShowAncestor)
+ : diff.getRightHeight();
if (useChange(diff.fDirection) && !diff.fIsWhitespace) {
yy= (y*size.y)/virtualHeight;
@@ -875,19 +893,6 @@ public class TextMergeViewer extends ContentMergeViewer {
y+= h;
}
}
-
- /*
- if (fVScrollBar != null) {
- c= Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
- gc.setForeground(c);
-
- yy= (fVScrollBar.getSelection()*size.y)/virtualHeight;
- hh= (fVScrollBar.getThumb()*size.y)/virtualHeight;
-
- gc.setLineWidth(1);
- gc.drawRectangle(0, yy, BIRDS_EYE_VIEW_WIDTH, hh);
- }
- */
}
private void refreshBirdsEyeView() {
@@ -2440,7 +2445,7 @@ public class TextMergeViewer extends ContentMergeViewer {
private void toggleSynchMode() {
fSynchronizedScrolling= ! fSynchronizedScrolling;
- scrollVertical(0, null);
+ scrollVertical(0, 0, 0, null);
// throw away central control (Sash or Canvas)
Control center= getCenter();
@@ -2950,36 +2955,53 @@ public class TextMergeViewer extends ContentMergeViewer {
// vertical scrolling
if (!leftIsVisible || !rightIsVisible) {
- int vpos= 0;
+ int avpos= 0, lvpos= 0, rvpos= 0;
MergeSourceViewer allButThis= null;
if (leftIsVisible) {
- vpos= realToVirtualPosition(fLeft, fLeft.getTopIndex());
+ avpos= lvpos= rvpos= realToVirtualPosition(fLeft, fLeft.getTopIndex());
allButThis= fLeft;
} else if (rightIsVisible) {
- vpos= realToVirtualPosition(fRight, fRight.getTopIndex());
+ avpos= lvpos= rvpos= realToVirtualPosition(fRight, fRight.getTopIndex());
allButThis= fRight;
} else if (ancestorIsVisible) {
- vpos= realToVirtualPosition(fAncestor, fAncestor.getTopIndex());
+ avpos= lvpos= rvpos= realToVirtualPosition(fAncestor, fAncestor.getTopIndex());
allButThis= fAncestor;
} else {
if (fAllDiffs != null) {
+ int vpos= 0;
Iterator e= fAllDiffs.iterator();
for (int i= 0; e.hasNext(); i++) {
Diff diff= (Diff) e.next();
if (diff == d)
break;
- vpos+= diff.getMaxDiffHeight(fShowAncestor);
+ if (fSynchronizedScrolling) {
+ vpos+= diff.getMaxDiffHeight(fShowAncestor);
+ } else {
+ avpos+= diff.getAncestorHeight();
+ lvpos+= diff.getLeftHeight();
+ rvpos+= diff.getRightHeight();
+ }
}
+ if (fSynchronizedScrolling)
+ avpos= lvpos= rvpos= vpos;
}
- vpos-= fRight.getViewportLines()/4;
- if (vpos < 0)
- vpos= 0;
+ int delta= fRight.getViewportLines()/4;
+ avpos-= delta;
+ if (avpos < 0)
+ avpos= 0;
+ lvpos-= delta;
+ if (lvpos < 0)
+ lvpos= 0;
+ rvpos-= delta;
+ if (rvpos < 0)
+ rvpos= 0;
}
- scrollVertical(vpos, allButThis);
+ scrollVertical(avpos, lvpos, rvpos, allButThis);
+
if (fVScrollBar != null)
- fVScrollBar.setSelection(vpos);
+ fVScrollBar.setSelection(avpos);
}
// horizontal scrolling
@@ -3148,6 +3170,21 @@ public class TextMergeViewer extends ContentMergeViewer {
}
/**
+ * Calculates height (in lines) of right view by adding the height of the right diffs.
+ */
+ private int getRightHeight() {
+ int h= 1;
+ if (fAllDiffs != null) {
+ Iterator e= fAllDiffs.iterator();
+ for (int i= 0; e.hasNext(); i++) {
+ Diff diff= (Diff) e.next();
+ h+= diff.getRightHeight();
+ }
+ }
+ return h;
+ }
+
+ /**
* The height of the TextEditors in lines.
*/
private int getViewportHeight() {
@@ -3203,66 +3240,56 @@ public class TextMergeViewer extends ContentMergeViewer {
return virtualPos;
}
- private void scrollVertical(int virtualPos, MergeSourceViewer allBut) {
-
- if (virtualPos < 0)
- virtualPos= virtualPos;
+ private void scrollVertical(int avpos, int lvpos, int rvpos, MergeSourceViewer allBut) {
+
+ int s= 0;
if (fSynchronizedScrolling) {
- int s= 0;
-
- if (true) {
- s= getVirtualHeight() - virtualPos;
- int height= fRight.getViewportLines()/4;
- if (s < 0)
- s= 0;
- if (s > height)
- s= height;
- }
-
- fInScrolling= true;
-
- if (isThreeWay() && allBut != fAncestor) {
- int y= virtualToRealPosition(fAncestor, virtualPos+s)-s;
+ s= getVirtualHeight() - rvpos;
+ int height= fRight.getViewportLines()/4;
+ if (s < 0)
+ s= 0;
+ if (s > height)
+ s= height;
+ }
+
+ fInScrolling= true;
+
+ if (isThreeWay() && allBut != fAncestor) {
+ if (fSynchronizedScrolling || allBut == null) {
+ int y= virtualToRealPosition(fAncestor, avpos+s)-s;
fAncestor.vscroll(y);
}
-
- if (allBut != fLeft) {
- int y= virtualToRealPosition(fLeft, virtualPos+s)-s;
+ }
+
+ if (allBut != fLeft) {
+ if (fSynchronizedScrolling || allBut == null) {
+ int y= virtualToRealPosition(fLeft, lvpos+s)-s;
fLeft.vscroll(y);
}
-
- if (allBut != fRight) {
- int y= virtualToRealPosition(fRight, virtualPos+s)-s;
+ }
+
+ if (allBut != fRight) {
+ if (fSynchronizedScrolling || allBut == null) {
+ int y= virtualToRealPosition(fRight, rvpos+s)-s;
fRight.vscroll(y);
}
-
- fInScrolling= false;
-
- if (isThreeWay() && fAncestorCanvas != null)
- fAncestorCanvas.repaint();
-
- if (fLeftCanvas != null)
- fLeftCanvas.repaint();
-
- Control center= getCenter();
- if (center instanceof BufferedCanvas)
- ((BufferedCanvas)center).repaint();
-
- if (fRightCanvas != null)
- fRightCanvas.repaint();
- } else {
- if (allBut == fAncestor && fAncestorCanvas != null && isThreeWay())
- fAncestorCanvas.repaint();
-
- if (allBut == fLeft && fLeftCanvas != null)
- fLeftCanvas.repaint();
-
- if (allBut == fRight && fRightCanvas != null)
- fRightCanvas.repaint();
}
- //refreshBirdsEyeView();
+ fInScrolling= false;
+
+ if (isThreeWay() && fAncestorCanvas != null)
+ fAncestorCanvas.repaint();
+
+ if (fLeftCanvas != null)
+ fLeftCanvas.repaint();
+
+ Control center= getCenter();
+ if (center instanceof BufferedCanvas)
+ ((BufferedCanvas)center).repaint();
+
+ if (fRightCanvas != null)
+ fRightCanvas.repaint();
}
/**
@@ -3278,7 +3305,7 @@ public class TextMergeViewer extends ContentMergeViewer {
int viewPosition= realToVirtualPosition(w, ix-ix2);
- scrollVertical(viewPosition, w); // scroll all but the given views
+ scrollVertical(viewPosition, viewPosition, viewPosition, w); // scroll all but the given views
if (fVScrollBar != null) {
int value= Math.max(0, Math.min(viewPosition, getVirtualHeight() - getViewportHeight()));
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java
new file mode 100644
index 000000000..7e8e9f107
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java
@@ -0,0 +1,125 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package org.eclipse.compare.internal;
+
+import java.util.ResourceBundle;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.IActionDelegate;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
+
+public class AddFromHistoryAction implements IActionDelegate {
+
+ private static final String BUNDLE_NAME= "org.eclipse.compare.internal.AddFromHistoryAction"; //$NON-NLS-1$
+
+ private ISelection fSelection;
+
+ public AddFromHistoryAction() {
+ }
+
+ public void selectionChanged(IAction a, ISelection s) {
+ fSelection= s;
+ }
+
+ public void run(IAction action) {
+
+ ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME);
+ String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$
+
+ Shell parentShell= CompareUIPlugin.getShell();
+ AddFromHistoryDialog dialog= null;
+
+ Object[] s= Utilities.getResources(fSelection);
+
+ for (int i= 0; i < s.length; i++) {
+ Object o= s[i];
+ if (o instanceof IContainer) {
+ IContainer container= (IContainer) o;
+
+ ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell);
+ IProgressMonitor pm= pmdialog.getProgressMonitor();
+ IFile[] states= null;
+ try {
+ states= container.findDeletedMembersWithHistory(IContainer.DEPTH_INFINITE, pm);
+ } catch (CoreException ex) {
+ pm.done();
+ }
+
+ if (states == null || states.length <= 0) {
+ String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$
+ MessageDialog.openInformation(parentShell, title, msg);
+ return;
+ }
+
+ if (dialog == null)
+ dialog= new AddFromHistoryDialog(parentShell, bundle);
+
+ if (dialog.select(container, states)) {
+ IFile file= dialog.getSelectedFile();
+ IFileState fileState= dialog.getSelectedFileState();
+ if (file != null && fileState != null) {
+ try {
+ updateWorkspace(bundle, parentShell, file, fileState);
+
+ } catch (InterruptedException x) {
+ // Do nothing. Operation has been canceled by user.
+
+ } catch (InvocationTargetException x) {
+ String reason= x.getTargetException().getMessage();
+ MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void createContainers(IResource resource) throws CoreException {
+ IContainer container= resource.getParent();
+ if (container instanceof IFolder) {
+ IFolder parent= (IFolder) container;
+ if (parent != null && !parent.exists()) {
+ createContainers(parent);
+ parent.create(false, true, null);
+ }
+ }
+ }
+
+ private void updateWorkspace(final ResourceBundle bundle, Shell shell,
+ final IFile file, final IFileState fileState)
+ throws InvocationTargetException, InterruptedException {
+
+ WorkspaceModifyOperation operation= new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor pm) throws InvocationTargetException {
+ try {
+ String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$
+ pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+
+ createContainers(file);
+ file.create(fileState.getContents(), false, pm);
+
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ pm.done();
+ }
+ }
+ };
+
+ ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell);
+ pmdialog.run(false, true, operation);
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
new file mode 100644
index 000000000..8239b27ab
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
@@ -0,0 +1,333 @@
+package org.eclipse.compare.internal;
+
+import java.io.*;
+import java.text.*;
+import java.util.*;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.*;
+
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
+import org.eclipse.compare.*;
+
+
+public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog {
+
+ static class HistoryInput implements ITypedElement, IStreamContentAccessor, IModificationDate {
+ IFile fFile;
+ IFileState fFileState;
+
+ HistoryInput(IFile file, IFileState fileState) {
+ fFile= file;
+ fFileState= fileState;
+ }
+ public InputStream getContents() throws CoreException {
+ return new BufferedInputStream(fFileState.getContents());
+ }
+ public String getName() {
+ return fFile.getName();
+ }
+ public String getType() {
+ return fFile.getFileExtension();
+ }
+ public Image getImage() {
+ return CompareUI.getImage(fFile);
+ }
+ public long getModificationDate() {
+ return fFileState.getModificationTime();
+ }
+ }
+
+ private CompareConfiguration fCompareConfiguration;
+ private ResourceBundle fBundle;
+ private HistoryInput fSelectedItem;
+
+ // SWT controls
+ private CompareViewerSwitchingPane fContentPane;
+ private Button fCommitButton;
+ private Table fMemberTable;
+ private CompareViewerPane fMemberPane;
+ private Tree fEditionTree;
+ private CompareViewerPane fEditionPane;
+ private Image fDateImage;
+ private Image fTimeImage;
+ private CompareViewerSwitchingPane fStructuredComparePane;
+
+
+ public AddFromHistoryDialog(Shell parent, ResourceBundle bundle) {
+ super(parent);
+ setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE);
+
+ fBundle= bundle;
+
+ String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$
+ ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName);
+ if (id != null)
+ fDateImage= id.createImage();
+ iconName= Utilities.getString(fBundle, "timeIcon", "obj16/resource_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+ id= CompareUIPlugin.getImageDescriptor(iconName);
+ if (id != null)
+ fTimeImage= id.createImage();
+ }
+
+ public boolean select(IContainer root, IFile[] files) {
+
+ create(); // create widgets
+
+ String format= Utilities.getString(fBundle, "memberPaneTitle"); //$NON-NLS-1$
+ String title= MessageFormat.format(format, new Object[] { root.getName() });
+ fMemberPane.setImage(CompareUI.getImage(root));
+ fMemberPane.setText(title);
+
+ String prefix= root.getFullPath().toString();
+
+ if (fMemberTable != null && !fMemberTable.isDisposed()) {
+ for (int i= 0; i < files.length; i++) {
+ IFile file= files[i];
+ String path= file.getFullPath().toString();
+ if (path.startsWith(prefix))
+ path= path.substring(prefix.length()+1);
+ TableItem ti= new TableItem(fMemberTable, SWT.NONE);
+ ti.setImage(CompareUI.getImage(file));
+ ti.setText(path);
+ ti.setData(file);
+ }
+ }
+
+ open();
+
+ return (getReturnCode() == OK) && (fSelectedItem != null);
+ }
+
+ IFile getSelectedFile() {
+ if (fSelectedItem != null)
+ return fSelectedItem.fFile;
+ return null;
+ }
+
+ IFileState getSelectedFileState() {
+ if (fSelectedItem != null)
+ return fSelectedItem.fFileState;
+ return null;
+ }
+
+ protected synchronized Control createDialogArea(Composite parent) {
+
+ getShell().setText(Utilities.getString(fBundle, "title")); //$NON-NLS-1$
+
+ Splitter vsplitter= new Splitter(parent, SWT.VERTICAL);
+ vsplitter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
+
+ vsplitter.addDisposeListener(
+ new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if (fDateImage != null)
+ fDateImage.dispose();
+ if (fTimeImage != null)
+ fTimeImage.dispose();
+ }
+ }
+ );
+
+ // we need two panes: the left for the elements, the right one for the editions
+ Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL);
+
+ fMemberPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT);
+ fMemberTable= new Table(fMemberPane, SWT.H_SCROLL + SWT.V_SCROLL);
+ fMemberTable.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleMemberSelect(e.item);
+ }
+ }
+ );
+
+ fMemberPane.setContent(fMemberTable);
+
+ fEditionPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT);
+
+ fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL + SWT.V_SCROLL);
+ fEditionTree.addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ feedContent(e.item);
+ }
+ }
+ );
+ fEditionPane.setContent(fEditionTree);
+
+ fContentPane= new CompareViewerSwitchingPane(vsplitter, SWT.BORDER | SWT.FLAT) {
+ protected Viewer getViewer(Viewer oldViewer, Object input) {
+ return CompareUIPlugin.findContentViewer(oldViewer, input, this, fCompareConfiguration);
+ }
+ };
+ vsplitter.setWeights(new int[] { 30, 70 });
+
+ return vsplitter;
+ }
+
+ /**
+ * Feeds selection from member viewer to edition viewer.
+ */
+ private void handleMemberSelect(Widget w) {
+ Object data= w.getData();
+ if (data instanceof IFile) {
+ IFile file= (IFile) data;
+ IFileState[] states= null;
+ try {
+ states= file.getHistory(new NullProgressMonitor());
+ } catch (CoreException ex) {
+ }
+
+ fEditionPane.setImage(CompareUI.getImage(file));
+ String pattern= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$
+ String title= MessageFormat.format(pattern, new Object[] { file.getName() });
+ fEditionPane.setText(title);
+
+ if (fEditionTree != null) {
+ fEditionTree.removeAll();
+ for (int i= 0; i < states.length; i++) {
+ addEdition(new HistoryInput(file, states[i]));
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds the given Pair to the edition tree.
+ * It takes care of creating tree nodes for different dates.
+ */
+ private void addEdition(HistoryInput input) {
+ if (fEditionTree == null || fEditionTree.isDisposed())
+ return;
+
+ IFileState state= input.fFileState;
+
+ // find last day
+ TreeItem[] days= fEditionTree.getItems();
+ TreeItem lastDay= null;
+ if (days.length > 0)
+ lastDay= days[days.length-1];
+
+ boolean first= lastDay == null;
+
+ long ldate= state.getModificationTime();
+ long day= dayNumber(ldate);
+ Date date= new Date(ldate);
+ if (lastDay == null || day != dayNumber(((Date)lastDay.getData()).getTime())) {
+ lastDay= new TreeItem(fEditionTree, SWT.NONE);
+ lastDay.setImage(fDateImage);
+ String df= DateFormat.getDateInstance().format(date);
+ long today= dayNumber(System.currentTimeMillis());
+
+ String formatKey;
+ if (day == today)
+ formatKey= "todayFormat"; //$NON-NLS-1$
+ else if (day == today-1)
+ formatKey= "yesterdayFormat"; //$NON-NLS-1$
+ else
+ formatKey= "dayFormat"; //$NON-NLS-1$
+ String pattern= Utilities.getString(fBundle, formatKey);
+ if (pattern != null)
+ df= MessageFormat.format(pattern, new String[] { df });
+ lastDay.setText(df);
+ lastDay.setData(date);
+ }
+ TreeItem ti= new TreeItem(lastDay, SWT.NONE);
+ ti.setImage(fTimeImage);
+ ti.setText(DateFormat.getTimeInstance().format(date));
+ ti.setData(input);
+
+ if (first) {
+ lastDay.setExpanded(true);
+ fEditionTree.setSelection(new TreeItem[] { ti });
+ feedContent(ti);
+ }
+ }
+
+ /**
+ * Returns the number of s since Jan 1st, 1970.
+ * The given date is converted to GMT and daylight saving is taken into account too.
+ */
+ private long dayNumber(long date) {
+ int ONE_DAY_MS= 24*60*60 * 1000; // one day in milli seconds
+
+ Calendar calendar= Calendar.getInstance();
+ long localTimeOffset= calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
+
+ return (date + localTimeOffset) / ONE_DAY_MS;
+ }
+
+ private void feedContent(Widget w) {
+ if (fContentPane != null && !fContentPane.isDisposed()) {
+ Object o= w.getData();
+ if (o instanceof HistoryInput) {
+ fSelectedItem= (HistoryInput) o;
+ fContentPane.setInput(fSelectedItem);
+ fContentPane.setText(getEditionLabel(fSelectedItem));
+ fContentPane.setImage(fTimeImage);
+ } else {
+ fSelectedItem= null;
+ fContentPane.setInput(null);
+ }
+ }
+ if (fCommitButton != null)
+ fCommitButton.setEnabled(fSelectedItem != null);
+ }
+
+ protected String getEditionLabel(HistoryInput input) {
+ String format= Utilities.getString(fBundle, "historyEditionLabel", null); //$NON-NLS-1$
+ if (format == null)
+ format= Utilities.getString(fBundle, "editionLabel"); //$NON-NLS-1$
+ if (format == null)
+ format= "x{0}"; //$NON-NLS-1$
+
+ long modDate= input.getModificationDate();
+ String date= DateFormat.getDateTimeInstance().format(new Date(modDate));
+
+ return MessageFormat.format(format, new Object[] { date });
+ }
+
+ /* (non Javadoc)
+ * Returns the size initialized with the constructor.
+ */
+ protected Point getInitialSize() {
+ Point size= new Point(Utilities.getInteger(fBundle, "width", 0), //$NON-NLS-1$
+ Utilities.getInteger(fBundle, "height", 0)); //$NON-NLS-1$
+
+ Shell shell= getParentShell();
+ if (shell != null) {
+ Point parentSize= shell.getSize();
+ if (size.x <= 0)
+ size.x= parentSize.x-300;
+ if (size.y <= 0)
+ size.y= parentSize.y-200;
+ }
+ if (size.x < 700)
+ size.x= 700;
+ if (size.y < 500)
+ size.y= 500;
+ return size;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ String buttonLabel= Utilities.getString(fBundle, "buttonLabel", IDialogConstants.OK_LABEL); //$NON-NLS-1$
+ // a 'Cancel' and a 'Add' button
+ fCommitButton= createButton(parent, IDialogConstants.OK_ID, buttonLabel, true);
+ fCommitButton.setEnabled(false);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index 057ddb329..45f40301d 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
@@ -48,6 +48,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
};
private static final String PREFIX= CompareUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+ public static final String OPEN_STRUCTURE_COMPARE= PREFIX + "OpenStructureCompare"; //$NON-NLS-1$
public static final String SYNCHRONIZE_SCROLLING= PREFIX + "SynchronizeScrolling"; //$NON-NLS-1$
public static final String SHOW_PSEUDO_CONFLICTS= PREFIX + "ShowPseudoConflicts"; //$NON-NLS-1$
public static final String INITIALLY_SHOW_ANCESTOR_PANE= PREFIX + "InitiallyShowAncestorPane"; //$NON-NLS-1$
@@ -65,6 +66,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, OPEN_STRUCTURE_COMPARE),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_PSEUDO_CONFLICTS),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE),
@@ -74,6 +76,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
public static void initDefaults(IPreferenceStore store) {
+ store.setDefault(OPEN_STRUCTURE_COMPARE, true);
store.setDefault(SYNCHRONIZE_SCROLLING, true);
store.setDefault(SHOW_PSEUDO_CONFLICTS, false);
store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false);
@@ -171,6 +174,39 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.load();
fOverlayStore.start();
+ TabFolder folder= new TabFolder(parent, SWT.NONE);
+ folder.setLayout(new TabFolderLayout());
+ folder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ TabItem item= new TabItem(folder, SWT.NONE);
+ item.setText(Utilities.getString("ComparePreferencePage.generalTab.label")); //$NON-NLS-1$
+ //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
+ item.setControl(createGeneralPage(folder));
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(Utilities.getString("ComparePreferencePage.textCompareTab.label")); //$NON-NLS-1$
+ //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE));
+ item.setControl(createTextComparePage(folder));
+
+ initializeFields();
+
+ return folder;
+ }
+
+ private Control createGeneralPage(Composite parent) {
+ Composite composite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 1;
+ composite.setLayout(layout);
+
+ addCheckBox(composite, "ComparePreferencePage.structureCompare.label", OPEN_STRUCTURE_COMPARE, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+
+ return composite;
+ }
+
+ private Control createTextComparePage(Composite parent) {
Composite composite= new Composite(parent, SWT.NULL);
GridLayout layout= new GridLayout();
layout.numColumns= 1;
@@ -182,8 +218,6 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
addCheckBox(composite, "ComparePreferencePage.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
-
fFontEditor= addTextFontEditor(composite, "ComparePreferencePage.textFont.label", TEXT_FONT); //$NON-NLS-1$
fFontEditor.setPreferenceStore(getPreferenceStore());
fFontEditor.setPreferencePage(this);
@@ -198,8 +232,6 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
gd.heightHint= convertHeightInCharsToPixels(15);
previewer.setLayoutData(gd);
- initializeFields();
-
return composite;
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index 104029ec5..b463392ac 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -599,10 +599,13 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
if (in instanceof IStreamContentAccessor) {
String type= ITypedElement.TEXT_TYPE;
+
if (in instanceof ITypedElement) {
ITypedElement tin= (ITypedElement) in;
- type= tin.getType();
- }
+ String ty= tin.getType();
+ if (ty != null)
+ type= ty;
+ }
type= normalizeCase(type);
IViewerDescriptor vd= (IViewerDescriptor) fgContentViewerDescriptors.get(type);
@@ -616,6 +619,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return new SimpleTextViewer(parent);
}
+ if (!(in instanceof ICompareInput))
+ return null;
+
ICompareInput input= (ICompareInput) in;
String type= getType(input);
type= normalizeCase(type);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java
new file mode 100644
index 000000000..c33ac3c76
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java
@@ -0,0 +1,40 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+package org.eclipse.compare.internal; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Layout;
+
+public class TabFolderLayout extends Layout {
+
+ protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+ if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
+ return new Point(wHint, hHint);
+
+ Control [] children = composite.getChildren ();
+ int count = children.length;
+ int maxWidth = 0, maxHeight = 0;
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ maxWidth = Math.max (maxWidth, pt.x);
+ maxHeight = Math.max (maxHeight, pt.y);
+ }
+
+ if (wHint != SWT.DEFAULT)
+ maxWidth= wHint;
+ if (hHint != SWT.DEFAULT)
+ maxHeight= hHint;
+
+ return new Point(maxWidth, maxHeight);
+
+ }
+
+ protected void layout (Composite composite, boolean flushCache) {
+ Rectangle rect= composite.getClientArea();
+
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ children[i].setBounds(rect);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java
index cc4a73539..53ec608ec 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java
@@ -54,9 +54,10 @@ public class CompareWithPatchAction implements IActionDelegate {
public void selectionChanged(IAction action, ISelection selection) {
fSelection= selection;
- action.setEnabled(fSelection != null && !fSelection.isEmpty());
+ IResource[] resources= PatchWizard.getResource(fSelection);
+ action.setEnabled(resources != null && resources.length == 1);
}
-
+
public void run(IAction action) {
PatchWizard wizard= new PatchWizard(fSelection);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
index ea7f493da..fc42b3797 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
@@ -136,7 +136,7 @@ import org.eclipse.compare.internal.Utilities;
patcher.parse(new BufferedReader(reader));
} catch (IOException ex) {
MessageDialog.openError(null,
- PatchMessages.getString("InputPatchPage.PatchErrorDialog.title_2"), //$NON-NLS-1$
+ PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$
PatchMessages.getString("InputPatchPage.ParseError.message")); //$NON-NLS-1$
}
@@ -149,7 +149,7 @@ import org.eclipse.compare.internal.Utilities;
Diff[] diffs= patcher.getDiffs();
if (diffs == null || diffs.length == 0) {
MessageDialog.openError(null,
- PatchMessages.getString("InputPatchPage.PatchErrorDialog.title_4"), //$NON-NLS-1$
+ PatchMessages.getString("InputPatchPage.PatchErrorDialog.title"), //$NON-NLS-1$
PatchMessages.getString("InputPatchPage.NoDiffsFound.message")); //$NON-NLS-1$
return this;
}
@@ -341,7 +341,7 @@ import org.eclipse.compare.internal.Utilities;
fPatchTargets.addSelectionChangedListener(
new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- fPatchWizard.setTarget(PatchWizard.getResource(event.getSelection()));
+ fPatchWizard.setTargets(PatchWizard.getResource(event.getSelection()));
updateWidgetEnablements();
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties
index f38a5966f..e63f1642d 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties
@@ -68,6 +68,7 @@ Patcher.DeleteError.message=Error while deleting resource
Patcher.UpdateError.message=Error while updating resource
Patcher.RefreshError.message=Error while refreshing from local
Patcher.Marker.message=Rejected patch
+Patcher.Task.message=Patching
#
# PatchCompareInput
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
index 466b59a42..965970988 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
@@ -5,6 +5,7 @@
package org.eclipse.compare.internal.patch;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import org.eclipse.swt.graphics.Image;
@@ -42,7 +43,7 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
*/
/* package */ PatchWizard(ISelection selection) {
- fTarget= getResource(selection);
+ setTargets(getResource(selection));
fPatcher= new Patcher();
@@ -58,10 +59,19 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
}
}
- static IResource getResource(ISelection selection) {
+ static IResource[] getResource(ISelection selection) {
IResource[] rs= Utilities.getResources(selection);
- if (rs != null && rs.length > 0)
- return rs[0];
+ ArrayList list= null;
+ for (int i= 0; i < rs.length; i++) {
+ IResource r= rs[i];
+ if (r != null && r.isAccessible()) {
+ if (list == null)
+ list= new ArrayList();
+ list.add(r);
+ }
+ }
+ if (list != null && list.size() > 0)
+ return (IResource[]) list.toArray(new IResource[list.size()]);
return null;
}
@@ -73,8 +83,8 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
return fTarget;
}
- void setTarget(IResource target) {
- fTarget= target;
+ void setTargets(IResource[] targets) {
+ fTarget= targets[0]; // right now we can only deal with a single selection
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index b1ca8cd63..782348d45 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -751,8 +751,10 @@ public class Patcher {
Assert.isTrue(false);
}
- if (pm != null)
- pm.beginTask("Patching", fDiffs.length*WORK_UNIT);
+ if (pm != null) {
+ String message= PatchMessages.getString("Patcher.Task.message"); //$NON-NLS-1$
+ pm.beginTask(message, fDiffs.length*WORK_UNIT);
+ }
for (int i= 0; i < fDiffs.length; i++) {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
index a2eb74b8a..09fc42603 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -54,6 +54,9 @@ ReplaceFromHistoryAction.tooltip= Replace the Selected Resource with Local Histo
ReplaceWithPreviousFromHistoryAction.label= &Previous From Local History
ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with the Previous from Local History
+addFromHistoryAction.label= Add From Local History...
+addFromHistoryAction.tooltip= Add Deleted Files From Local History
+
#
# Preference Page
#
@@ -62,11 +65,14 @@ ComparePreferencePage.initiallyShowAncestorPane.label= Initially show a&ncestor
ComparePreferencePage.showPseudoConflicts.label= Show &pseudo conflicts
ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers
ComparePreferencePage.textFont.label= Text Font
-ComparePreferencePage.showMoreInfo.label= Show additional compare &information in status line
+ComparePreferencePage.showMoreInfo.label= Show additional compare &information in the status line
ComparePreferencePage.preview.label= Preview:
ComparePreferencePage.ancestor.label= Common Ancestor
ComparePreferencePage.left.label= Local
ComparePreferencePage.right.label= Remote
+ComparePreferencePage.structureCompare.label= Open structure compare automatically
+ComparePreferencePage.generalTab.label= &General
+ComparePreferencePage.textCompareTab.label= &Text Compare
#
# Toolbar actions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
index e6a811f7d..d8fdbf8df 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
@@ -147,6 +147,19 @@
</action>
</objectContribution>
+ <objectContribution
+ id="org.eclipse.compare.AddFromHistoryAction"
+ objectClass="org.eclipse.core.resources.IContainer" adaptable="true">
+ <action
+ id="addFromHistoryAction"
+ label="%addFromHistoryAction.label"
+ tooltip="%addFromHistoryAction.tooltip"
+ menubarPath="replaceWithMenu"
+ enablesFor="1"
+ class="org.eclipse.compare.internal.AddFromHistoryAction">
+ </action>
+ </objectContribution>
+
</extension>
<extension point="org.eclipse.compare.structureCreators">

Back to the top