Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2001-08-03 12:28:10 +0000
committerAndre Weinand2001-08-03 12:28:10 +0000
commit9a6fed89beebb64c53a2aaecd8593b9d14565a71 (patch)
tree61614eaac1b7aba5a86eb02f6f7ade816c58175b
parentf6e599d6fbd217d62d1336a04115df5ee667eecd (diff)
downloadeclipse.platform.team-9a6fed89beebb64c53a2aaecd8593b9d14565a71.tar.gz
eclipse.platform.team-9a6fed89beebb64c53a2aaecd8593b9d14565a71.tar.xz
eclipse.platform.team-9a6fed89beebb64c53a2aaecd8593b9d14565a71.zip
3 PRs fixed (1GFMLFB, 1GG0ELM, 1GGNKHN)
-rw-r--r--bundles/org.eclipse.compare/buildnotes_compare.html54
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java25
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java8
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java48
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties3
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java14
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java20
-rw-r--r--bundles/org.eclipse.compare/plugin.properties2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html54
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java25
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java8
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java48
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java14
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java20
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties2
16 files changed, 296 insertions, 52 deletions
diff --git a/bundles/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/buildnotes_compare.html
index 415abb66a..287881738 100644
--- a/bundles/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/buildnotes_compare.html
@@ -11,6 +11,60 @@
<h1>
Eclipse Platform Build Notes<br>
Compare (including example)</h1>
+Eclipse SDK Build 129, August ?? 2001
+
+<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>
+1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty<br>
+1GG0ELM: ITPVCM:ALL - Local history displayed some of Today's items as Yesterday<br>
+1GGNKHN: ITPJUI:ALL - No progress during replace with local history<br>
+
+<h2>
+Problem reports closed</h2>
+
+<h1>
+<hr WIDTH="100%"></h1>
+Eclipse SDK Build 128, July 31st 2001
+
+<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>
+1GF5RZD: ITPVCM:ALL - Missing mnemonics<br>
+
+<h2>
+Problem reports closed</h2>
+
+<h1>
+<hr WIDTH="100%"></h1>
Eclipse SDK Build 127, July 24th 2001
<h2>
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
index 681eb51d2..c399f00d3 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
@@ -11,6 +11,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashSet;
+import java.util.Calendar;
import java.io.InputStream;
import java.text.*;
@@ -145,7 +146,6 @@ public class EditionSelectionDialog extends Dialog {
}
}
- private static final int ONE_DAY_MS= 86400 * 1000; // one day in milli seconds
private static final boolean HIDE_IDENTICAL= true;
private Button fCommitButton;
@@ -241,7 +241,7 @@ public class EditionSelectionDialog extends Dialog {
Assert.isNotNull(target);
fTargetPair= new Pair(target);
-
+
// sort input editions
final int count= inputEditions.length;
final IModificationDate[] editions= new IModificationDate[count];
@@ -654,6 +654,19 @@ public class EditionSelectionDialog extends Dialog {
}
/**
+ * 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;
+ }
+
+ /**
* Adds the given Pair to the edition tree.
* It takes care of creating tree nodes for different dates.
*/
@@ -672,14 +685,14 @@ public class EditionSelectionDialog extends Dialog {
ITypedElement edition= pair.getEdition();
ITypedElement item= pair.getItem();
- long ldate= ((IModificationDate)edition).getModificationDate();
- long day= ldate / ONE_DAY_MS;
+ long ldate= ((IModificationDate)edition).getModificationDate();
+ long day= dayNumber(ldate);
Date date= new Date(ldate);
- if (lastDay == null || day != ((Date)lastDay.getData()).getTime() / ONE_DAY_MS) {
+ 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= System.currentTimeMillis() / ONE_DAY_MS;
+ long today= dayNumber(System.currentTimeMillis());
String formatKey;
if (day == today)
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
index 6e04f56f6..6b97ec592 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
@@ -150,7 +150,7 @@ public class CompareEditor extends EditorPart implements IPropertyChangeListener
}
};
- Shell shell= getSite().getWorkbenchWindow().getShell();
+ Shell shell= getSite().getShell();
try {
@@ -161,11 +161,9 @@ public class CompareEditor extends EditorPart implements IPropertyChangeListener
} catch (InterruptedException x) {
} catch (OperationCanceledException x) {
} catch (InvocationTargetException x) {
- //String title= getResourceString("Error.save.title");
- //String msg= getResourceString("Error.save.message");
String title= Utilities.getString("CompareEditor.saveError.title"); //$NON-NLS-1$
- String msg= Utilities.getString("CompareEditor.cantSaveError"); //$NON-NLS-1$
- MessageDialog.openError(shell, title, msg + x.getTargetException().getMessage());
+ String reason= x.getTargetException().getMessage();
+ MessageDialog.openError(shell, title, Utilities.getFormattedString("CompareEditor.cantSaveError", reason)); //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java
index d5f5778bb..bf992e322 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java
@@ -6,17 +6,24 @@ package org.eclipse.compare.internal;
import java.io.InputStream;
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.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.IActionDelegate;
+
+
import org.eclipse.compare.*;
@@ -51,18 +58,18 @@ public class ReplaceWithEditionAction implements IActionDelegate {
fSelection= s;
}
- void replaceFromHistory(IFile file) {
+ void replaceFromHistory(final IFile file) {
ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME);
String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$
- Shell parent= CompareUIPlugin.getShell();
+ Shell parentShell= CompareUIPlugin.getShell();
IFileState states[]= null;
try {
states= file.getHistory(null);
} catch (CoreException ex) {
- MessageDialog.openError(parent, title, ex.getMessage());
+ MessageDialog.openError(parentShell, title, ex.getMessage());
return;
}
@@ -74,21 +81,40 @@ public class ReplaceWithEditionAction implements IActionDelegate {
for (int i= 0; i < states.length; i++)
editions[i]= new HistoryItem(base, states[i]);
- EditionSelectionDialog d= new EditionSelectionDialog(parent, bundle);
+ EditionSelectionDialog d= new EditionSelectionDialog(parentShell, bundle);
- ITypedElement ti= d.selectEdition(base, editions, null);
+ final ITypedElement ti= d.selectEdition(base, editions, null);
if (ti instanceof IStreamContentAccessor) {
+
+ WorkspaceModifyOperation operation= new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor pm) throws InvocationTargetException {
+ try {
+ pm.beginTask("Replacing", IProgressMonitor.UNKNOWN);
+ InputStream is= ((IStreamContentAccessor)ti).getContents();
+ file.setContents(is, false, true, pm);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ pm.done();
+ }
+ }
+ };
+
try {
- InputStream is= ((IStreamContentAccessor)ti).getContents();
- file.setContents(is, false, true, null);
- } catch (CoreException ex) {
- MessageDialog.openError(parent, title, ex.getMessage());
+ ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell);
+ pmdialog.run(false, true, operation);
+
+ } 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$
}
}
} else {
String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$
- MessageDialog.openInformation(parent, title, msg);
+ MessageDialog.openInformation(parentShell, title, msg);
}
}
}
-
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties
index f9f6012d3..47998e61b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties
@@ -25,4 +25,5 @@ dayFormat= {0}
buttonLabel= Replace
-noLocalHistoryError= No local history available for selected resource. \ No newline at end of file
+noLocalHistoryError= No local history available for selected resource.
+replaceError=Can't replace resource (reason: {0}). \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
index 76a34cf74..55794b1f5 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
@@ -5,6 +5,7 @@
package org.eclipse.compare.internal;
import java.text.MessageFormat;
+import java.lang.reflect.InvocationTargetException;
import org.eclipse.jface.viewers.ISelection;
@@ -129,11 +130,18 @@ class ResourceCompareInput extends CompareEditorInput {
/**
* Performs a two-way or three-way diff on the current selection.
*/
- public Object prepareInput(IProgressMonitor pm) {
+ public Object prepareInput(IProgressMonitor pm) throws InvocationTargetException {
CompareConfiguration cc= (CompareConfiguration) getCompareConfiguration();
- try {
+ try {
+ // fix for PR 1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty
+ fLeftResource.refreshLocal(IResource.DEPTH_INFINITE, pm);
+ fRightResource.refreshLocal(IResource.DEPTH_INFINITE, pm);
+ if (fThreeWay && fAncestorResource != null)
+ fAncestorResource.refreshLocal(IResource.DEPTH_INFINITE, pm);
+ // end fix
+
pm.beginTask(Utilities.getString("ResourceCompare.taskName"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
String leftLabel= fLeftResource.getName();
@@ -166,6 +174,8 @@ class ResourceCompareInput extends CompareEditorInput {
fRoot= d.findDifferences(fThreeWay, pm, null, fAncestor, fLeft, fRight);
return fRoot;
+ } catch (CoreException ex) {
+ throw new InvocationTargetException(ex);
} finally {
pm.done();
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
index 84754de04..2c12a7db7 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
@@ -9,6 +9,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
+import java.text.MessageFormat;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swt.widgets.Display;
@@ -251,6 +252,17 @@ public class Utilities {
return dfltValue;
}
+ public static String getFormattedString(ResourceBundle bundle, String key, String arg) {
+
+ if (bundle != null) {
+ try {
+ return MessageFormat.format(bundle.getString(key), new String[] { arg });
+ } catch (MissingResourceException x) {
+ }
+ }
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+
public static String getString(String key) {
try {
return CompareUIPlugin.getResourceBundle().getString(key);
@@ -258,6 +270,14 @@ public class Utilities {
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
}
}
+
+ public static String getFormattedString(String key, String arg) {
+ try{
+ return MessageFormat.format(CompareUIPlugin.getResourceBundle().getString(key), new String[] { arg });
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
public static String getString(ResourceBundle bundle, String key) {
return getString(bundle, key, key);
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index 3ab11455c..78bb9134b 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -29,7 +29,7 @@ CompareUIPlugin.noDifferences=There are no differences between the selected inpu
#
defaultCompareEditor.name= Default Compare Editor
CompareEditor.saveError.title= Save Error
-CompareEditor.cantSaveError= Can\'t save
+CompareEditor.cantSaveError= Can\'t save contents ({0})
CompareEditor.invalidInput=Invalid Input: Must be CompareEditorInput
#
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 415abb66a..287881738 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,60 @@
<h1>
Eclipse Platform Build Notes<br>
Compare (including example)</h1>
+Eclipse SDK Build 129, August ?? 2001
+
+<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>
+1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty<br>
+1GG0ELM: ITPVCM:ALL - Local history displayed some of Today's items as Yesterday<br>
+1GGNKHN: ITPJUI:ALL - No progress during replace with local history<br>
+
+<h2>
+Problem reports closed</h2>
+
+<h1>
+<hr WIDTH="100%"></h1>
+Eclipse SDK Build 128, July 31st 2001
+
+<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>
+1GF5RZD: ITPVCM:ALL - Missing mnemonics<br>
+
+<h2>
+Problem reports closed</h2>
+
+<h1>
+<hr WIDTH="100%"></h1>
Eclipse SDK Build 127, July 24th 2001
<h2>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
index 681eb51d2..c399f00d3 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
@@ -11,6 +11,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashSet;
+import java.util.Calendar;
import java.io.InputStream;
import java.text.*;
@@ -145,7 +146,6 @@ public class EditionSelectionDialog extends Dialog {
}
}
- private static final int ONE_DAY_MS= 86400 * 1000; // one day in milli seconds
private static final boolean HIDE_IDENTICAL= true;
private Button fCommitButton;
@@ -241,7 +241,7 @@ public class EditionSelectionDialog extends Dialog {
Assert.isNotNull(target);
fTargetPair= new Pair(target);
-
+
// sort input editions
final int count= inputEditions.length;
final IModificationDate[] editions= new IModificationDate[count];
@@ -654,6 +654,19 @@ public class EditionSelectionDialog extends Dialog {
}
/**
+ * 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;
+ }
+
+ /**
* Adds the given Pair to the edition tree.
* It takes care of creating tree nodes for different dates.
*/
@@ -672,14 +685,14 @@ public class EditionSelectionDialog extends Dialog {
ITypedElement edition= pair.getEdition();
ITypedElement item= pair.getItem();
- long ldate= ((IModificationDate)edition).getModificationDate();
- long day= ldate / ONE_DAY_MS;
+ long ldate= ((IModificationDate)edition).getModificationDate();
+ long day= dayNumber(ldate);
Date date= new Date(ldate);
- if (lastDay == null || day != ((Date)lastDay.getData()).getTime() / ONE_DAY_MS) {
+ 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= System.currentTimeMillis() / ONE_DAY_MS;
+ long today= dayNumber(System.currentTimeMillis());
String formatKey;
if (day == today)
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
index 6e04f56f6..6b97ec592 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
@@ -150,7 +150,7 @@ public class CompareEditor extends EditorPart implements IPropertyChangeListener
}
};
- Shell shell= getSite().getWorkbenchWindow().getShell();
+ Shell shell= getSite().getShell();
try {
@@ -161,11 +161,9 @@ public class CompareEditor extends EditorPart implements IPropertyChangeListener
} catch (InterruptedException x) {
} catch (OperationCanceledException x) {
} catch (InvocationTargetException x) {
- //String title= getResourceString("Error.save.title");
- //String msg= getResourceString("Error.save.message");
String title= Utilities.getString("CompareEditor.saveError.title"); //$NON-NLS-1$
- String msg= Utilities.getString("CompareEditor.cantSaveError"); //$NON-NLS-1$
- MessageDialog.openError(shell, title, msg + x.getTargetException().getMessage());
+ String reason= x.getTargetException().getMessage();
+ MessageDialog.openError(shell, title, Utilities.getFormattedString("CompareEditor.cantSaveError", reason)); //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java
index d5f5778bb..bf992e322 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java
@@ -6,17 +6,24 @@ package org.eclipse.compare.internal;
import java.io.InputStream;
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.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.IActionDelegate;
+
+
import org.eclipse.compare.*;
@@ -51,18 +58,18 @@ public class ReplaceWithEditionAction implements IActionDelegate {
fSelection= s;
}
- void replaceFromHistory(IFile file) {
+ void replaceFromHistory(final IFile file) {
ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME);
String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$
- Shell parent= CompareUIPlugin.getShell();
+ Shell parentShell= CompareUIPlugin.getShell();
IFileState states[]= null;
try {
states= file.getHistory(null);
} catch (CoreException ex) {
- MessageDialog.openError(parent, title, ex.getMessage());
+ MessageDialog.openError(parentShell, title, ex.getMessage());
return;
}
@@ -74,21 +81,40 @@ public class ReplaceWithEditionAction implements IActionDelegate {
for (int i= 0; i < states.length; i++)
editions[i]= new HistoryItem(base, states[i]);
- EditionSelectionDialog d= new EditionSelectionDialog(parent, bundle);
+ EditionSelectionDialog d= new EditionSelectionDialog(parentShell, bundle);
- ITypedElement ti= d.selectEdition(base, editions, null);
+ final ITypedElement ti= d.selectEdition(base, editions, null);
if (ti instanceof IStreamContentAccessor) {
+
+ WorkspaceModifyOperation operation= new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor pm) throws InvocationTargetException {
+ try {
+ pm.beginTask("Replacing", IProgressMonitor.UNKNOWN);
+ InputStream is= ((IStreamContentAccessor)ti).getContents();
+ file.setContents(is, false, true, pm);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ pm.done();
+ }
+ }
+ };
+
try {
- InputStream is= ((IStreamContentAccessor)ti).getContents();
- file.setContents(is, false, true, null);
- } catch (CoreException ex) {
- MessageDialog.openError(parent, title, ex.getMessage());
+ ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell);
+ pmdialog.run(false, true, operation);
+
+ } 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$
}
}
} else {
String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$
- MessageDialog.openInformation(parent, title, msg);
+ MessageDialog.openInformation(parentShell, title, msg);
}
}
}
-
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties
index f9f6012d3..47998e61b 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.properties
@@ -25,4 +25,5 @@ dayFormat= {0}
buttonLabel= Replace
-noLocalHistoryError= No local history available for selected resource. \ No newline at end of file
+noLocalHistoryError= No local history available for selected resource.
+replaceError=Can't replace resource (reason: {0}). \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
index 76a34cf74..55794b1f5 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
@@ -5,6 +5,7 @@
package org.eclipse.compare.internal;
import java.text.MessageFormat;
+import java.lang.reflect.InvocationTargetException;
import org.eclipse.jface.viewers.ISelection;
@@ -129,11 +130,18 @@ class ResourceCompareInput extends CompareEditorInput {
/**
* Performs a two-way or three-way diff on the current selection.
*/
- public Object prepareInput(IProgressMonitor pm) {
+ public Object prepareInput(IProgressMonitor pm) throws InvocationTargetException {
CompareConfiguration cc= (CompareConfiguration) getCompareConfiguration();
- try {
+ try {
+ // fix for PR 1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty
+ fLeftResource.refreshLocal(IResource.DEPTH_INFINITE, pm);
+ fRightResource.refreshLocal(IResource.DEPTH_INFINITE, pm);
+ if (fThreeWay && fAncestorResource != null)
+ fAncestorResource.refreshLocal(IResource.DEPTH_INFINITE, pm);
+ // end fix
+
pm.beginTask(Utilities.getString("ResourceCompare.taskName"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
String leftLabel= fLeftResource.getName();
@@ -166,6 +174,8 @@ class ResourceCompareInput extends CompareEditorInput {
fRoot= d.findDifferences(fThreeWay, pm, null, fAncestor, fLeft, fRight);
return fRoot;
+ } catch (CoreException ex) {
+ throw new InvocationTargetException(ex);
} finally {
pm.done();
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
index 84754de04..2c12a7db7 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
@@ -9,6 +9,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
+import java.text.MessageFormat;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swt.widgets.Display;
@@ -251,6 +252,17 @@ public class Utilities {
return dfltValue;
}
+ public static String getFormattedString(ResourceBundle bundle, String key, String arg) {
+
+ if (bundle != null) {
+ try {
+ return MessageFormat.format(bundle.getString(key), new String[] { arg });
+ } catch (MissingResourceException x) {
+ }
+ }
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+
public static String getString(String key) {
try {
return CompareUIPlugin.getResourceBundle().getString(key);
@@ -258,6 +270,14 @@ public class Utilities {
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
}
}
+
+ public static String getFormattedString(String key, String arg) {
+ try{
+ return MessageFormat.format(CompareUIPlugin.getResourceBundle().getString(key), new String[] { arg });
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
public static String getString(ResourceBundle bundle, String key) {
return getString(bundle, key, key);
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 3ab11455c..78bb9134b 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -29,7 +29,7 @@ CompareUIPlugin.noDifferences=There are no differences between the selected inpu
#
defaultCompareEditor.name= Default Compare Editor
CompareEditor.saveError.title= Save Error
-CompareEditor.cantSaveError= Can\'t save
+CompareEditor.cantSaveError= Can\'t save contents ({0})
CompareEditor.invalidInput=Invalid Input: Must be CompareEditorInput
#

Back to the top