Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2009-03-04 09:15:43 +0000
committerTomasz Zarna2009-03-04 09:15:43 +0000
commit1aa91804ad0d64fe456fe2a92ef30addbfeedfdd (patch)
treea272f9067349695a53a03a6012091abc9c7d71fb
parent829ffb925b2184ce82d4a192def6af92bb88a19d (diff)
downloadeclipse.platform.team-1aa91804ad0d64fe456fe2a92ef30addbfeedfdd.tar.gz
eclipse.platform.team-1aa91804ad0d64fe456fe2a92ef30addbfeedfdd.tar.xz
eclipse.platform.team-1aa91804ad0d64fe456fe2a92ef30addbfeedfdd.zip
Rebasing.
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/.api_filters18
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java72
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java57
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java17
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java19
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java44
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java226
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties5
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java239
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java5
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java13
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java23
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Utilities.java33
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml15
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd52
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AbstractPatchTest.java40
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java19
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/UnifiedDiffFormatterTest.java2
21 files changed, 703 insertions, 209 deletions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/.api_filters b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/.api_filters
index 3a3acc948..4c75be799 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/.api_filters
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/.api_filters
@@ -4,20 +4,21 @@
<filter id="338944126">
<message_arguments>
<message_argument value="org.eclipse.compare.CompareViewerSwitchingPane"/>
- <message_argument value="setTitleArgument(String)"/>
+ <message_argument value="getTitleArgument()"/>
</message_arguments>
</filter>
<filter id="338944126">
<message_arguments>
<message_argument value="org.eclipse.compare.CompareViewerSwitchingPane"/>
- <message_argument value="getTitleArgument()"/>
+ <message_argument value="setTitleArgument(String)"/>
</message_arguments>
</filter>
</resource>
- <resource path="compare/org/eclipse/compare/ISharedDocumentAdapter.java" type="org.eclipse.compare.ISharedDocumentAdapter">
- <filter id="403853384">
+ <resource path="compare/org/eclipse/compare/CompareEditorInput.java" type="org.eclipse.compare.CompareEditorInput">
+ <filter id="338944126">
<message_arguments>
- <message_argument value="org.eclipse.compare.ISharedDocumentAdapter"/>
+ <message_argument value="org.eclipse.compare.CompareEditorInput"/>
+ <message_argument value="setFocus()"/>
</message_arguments>
</filter>
</resource>
@@ -42,4 +43,11 @@
</message_arguments>
</filter>
</resource>
+ <resource path="compare/org/eclipse/compare/ISharedDocumentAdapter.java" type="org.eclipse.compare.ISharedDocumentAdapter">
+ <filter id="403853384">
+ <message_arguments>
+ <message_argument value="org.eclipse.compare.ISharedDocumentAdapter"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
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 c47fb93c6..f6b1cede3 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
@@ -19,6 +19,7 @@ import java.util.Set;
import org.eclipse.compare.contentmergeviewer.IFlushable;
import org.eclipse.compare.internal.BinaryCompareViewer;
import org.eclipse.compare.internal.ChangePropertyAction;
+import org.eclipse.compare.internal.CompareContentViewerSwitchingPane;
import org.eclipse.compare.internal.CompareEditorInputNavigator;
import org.eclipse.compare.internal.CompareMessages;
import org.eclipse.compare.internal.ComparePreferencePage;
@@ -27,6 +28,7 @@ import org.eclipse.compare.internal.ICompareAsText;
import org.eclipse.compare.internal.ICompareUIConstants;
import org.eclipse.compare.internal.OutlineViewerCreator;
import org.eclipse.compare.internal.Utilities;
+import org.eclipse.compare.internal.ViewerDescriptor;
import org.eclipse.compare.structuremergeviewer.DiffTreeViewer;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener;
@@ -144,7 +146,7 @@ import org.eclipse.ui.services.IServiceLocator;
public abstract class CompareEditorInput implements IEditorInput, IPropertyChangeNotifier, IRunnableWithProgress, ICompareContainer {
private static final boolean DEBUG= false;
-
+
/**
* The name of the "dirty" property (value <code>"DIRTY_STATE"</code>).
*/
@@ -203,6 +205,7 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
private String fHelpContextId;
private InternalOutlineViewerCreator fOutlineView;
private ICompareAsText fCompareAsText;
+ private ViewerDescriptor vd;
private class InternalOutlineViewerCreator extends OutlineViewerCreator {
private OutlineViewerCreator getWrappedCreator() {
@@ -552,13 +555,8 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
Control outline= createOutlineContents(fComposite, SWT.HORIZONTAL);
- fContentInputPane= new CompareViewerSwitchingPane(fComposite, SWT.BORDER | SWT.FLAT) {
- protected Viewer getViewer(Viewer oldViewer, Object input) {
- if (input instanceof ICompareInput)
- return findContentViewer(oldViewer, (ICompareInput)input, this);
- return null;
- }
- };
+ fContentInputPane= new CompareContentViewerSwitchingPane(fComposite, SWT.BORDER | SWT.FLAT, this);
+
if (fFocusPane == null)
fFocusPane= fContentInputPane;
if (outline != null)
@@ -861,17 +859,34 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
/**
* Asks this input to take focus within its container (editor).
- * <p>
- * Clients should not call this method but they may
- * override if they implement a different layout with different visual
- * components. Clients are free to call the inherited method.
- * </p>
+ *
+ * @noreference Clients should not call this method but they may override if
+ * they implement a different layout with different visual
+ * components. Clients are free to call the inherited method.
+ *
+ * @deprecated Please use {@link #setFocus2()} instead.
*/
public void setFocus() {
+ setFocus2();
+ }
+
+ /**
+ * Asks this input to take focus within its container (editor).
+ *
+ * @noreference Clients should not call this method but they may override if
+ * they implement a different layout with different visual
+ * components. Clients are free to call the inherited method.
+ *
+ * @return <code>true</code> if the input got focus, and <code>false</code>
+ * if it was unable to.
+ * @since 3.5
+ */
+ public boolean setFocus2() {
if (fFocusPane != null) {
- fFocusPane.setFocus();
+ return fFocusPane.setFocus();
} else if (fComposite != null)
- fComposite.setFocus();
+ return fComposite.setFocus();
+ return false;
}
/**
@@ -926,8 +941,10 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
*/
public Viewer findContentViewer(Viewer oldViewer, ICompareInput input, Composite parent) {
- Viewer newViewer= CompareUI.findContentViewer(oldViewer, input, parent, fCompareConfiguration);
-
+ Viewer newViewer = vd != null ? vd.createViewer(oldViewer, parent,
+ fCompareConfiguration) : CompareUI.findContentViewer(oldViewer,
+ input, parent, fCompareConfiguration);
+
boolean isNewViewer= newViewer != oldViewer;
if (DEBUG) System.out.println("CompareEditorInput.findContentViewer: " + isNewViewer); //$NON-NLS-1$
@@ -949,6 +966,27 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
}
/**
+ * @param vd
+ * the viewer descriptor
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended
+ * by clients.
+ */
+ public void setViewerDescriptor(ViewerDescriptor vd) {
+ this.vd = vd;
+ }
+
+ /**
+ * @return the viewer descriptor set for the input
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended
+ * by clients.
+ */
+ public ViewerDescriptor getViewerDescriptor() {
+ return this.vd;
+ }
+
+ /**
* Returns <code>true</code> if there are unsaved changes.
* The value returned is the value of the <code>DIRTY_STATE</code> property of this input object.
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java
index b49cf0410..cab95e2d0 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,17 +10,34 @@
*******************************************************************************/
package org.eclipse.compare;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.*;
+import org.eclipse.swt.accessibility.ACC;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.*;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
/**
* A <code>CompareViewerPane</code> is a convenience class which installs a
@@ -63,12 +80,8 @@ public class CompareViewerPane extends ViewForm implements ISelectionProvider,
marginWidth= 0;
marginHeight= 0;
- CLabel label= new CLabel(this, SWT.NONE) {
- public Point computeSize(int wHint, int hHint, boolean changed) {
- return super.computeSize(wHint, Math.max(24, hHint), changed);
- }
- };
- setTopLeft(label);
+ Control topLeft = createTopLeft(this);
+ setTopLeft(topLeft);
MouseAdapter ml= new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
@@ -82,7 +95,7 @@ public class CompareViewerPane extends ViewForm implements ISelectionProvider,
};
addMouseListener(ml);
- label.addMouseListener(ml);
+ getTopLeft().addMouseListener(ml);
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
@@ -98,6 +111,24 @@ public class CompareViewerPane extends ViewForm implements ISelectionProvider,
}
/**
+ * @param parent
+ * a widget which will be the parent of the control (cannot be
+ * null)
+ * @return the control to be placed in the top left corner of the pane
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended
+ * by clients.
+ */
+ protected Control createTopLeft(Composite parent) {
+ CLabel label = new CLabel(this, SWT.NONE) {
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ return super.computeSize(wHint, Math.max(24, hHint), changed);
+ }
+ };
+ return label;
+ }
+
+ /**
* Set the pane's title text.
* The value <code>null</code> clears it.
*
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java
index bc2892da8..31a89a157 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java
@@ -216,6 +216,17 @@ public abstract class CompareViewerSwitchingPane extends CompareViewerPane {
return true;
return false;
}
+
+ /**
+ * @param input the input
+ * @return true, if the input is considered as changed
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended
+ * by clients.
+ */
+ protected boolean inputChanged(Object input) {
+ return getInput() != input;
+ }
/**
* Sets the input object of this pane.
@@ -233,10 +244,10 @@ public abstract class CompareViewerSwitchingPane extends CompareViewerPane {
*/
public void setInput(Object input) {
- if (getInput() == input)
+ if (!inputChanged(input))
return;
-
- boolean hadFocus= hasFocus2();
+
+ boolean hadFocus = hasFocus2();
super.setInput(input);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index 26b173b69..8edf66fcc 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -737,13 +737,14 @@ public abstract class ContentMergeViewer extends ContentViewer
updateContent(ancestor, left, right);
updateHeader();
- ToolBarManager tbm = (ToolBarManager) getToolBarManager(fComposite.getParent());
- if (tbm != null ) {
- updateToolItems();
- tbm.update(true);
- tbm.getControl().getParent().layout(true);
+ if (Utilities.okToUse(fComposite) && Utilities.okToUse(fComposite.getParent())) {
+ ToolBarManager tbm = (ToolBarManager) getToolBarManager(fComposite.getParent());
+ if (tbm != null ) {
+ updateToolItems();
+ tbm.update(true);
+ tbm.getControl().getParent().layout(true);
+ }
}
-
}
}
@@ -1260,4 +1261,8 @@ public abstract class ContentMergeViewer extends ContentViewer
}
refresh();
}
+
+ CompareHandlerService getCompareHandlerService() {
+ return fHandlerService;
+ }
}
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 b73e30fbc..36619a511 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
@@ -65,6 +65,10 @@ import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.commands.operations.IOperationHistoryListener;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.OperationHistoryEvent;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@@ -422,6 +426,11 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
/** The current diff */
private Diff fCurrentDiff;
+ // Bug 259362 - Update diffs after undo
+ private boolean copyOperationInProgress = false;
+ private IUndoableOperation copyUndoable = null;
+ private IOperationHistoryListener operationHistoryListener;
+
/**
* Preference key for highlighting current line.
*/
@@ -1365,6 +1374,14 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration);
+ operationHistoryListener = new IOperationHistoryListener() {
+ public void historyNotification(OperationHistoryEvent event) {
+ TextMergeViewer.this.historyNotification(event);
+ }
+ };
+ OperationHistoryFactory.getOperationHistory()
+ .addOperationHistoryListener(operationHistoryListener);
+
fMerger = new DocumentMerger(new IDocumentMergerInput() {
public ITokenComparator createTokenComparator(String line) {
return TextMergeViewer.this.createTokenComparator(line);
@@ -1780,6 +1797,8 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
* @param event
*/
protected void handleDispose(DisposeEvent event) {
+ OperationHistoryFactory.getOperationHistory()
+ .removeOperationHistoryListener(operationHistoryListener);
if (fHandlerService != null)
fHandlerService.dispose();
@@ -4614,7 +4633,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
invalidateLines();
return;
}
-
+ copyOperationInProgress = true;
if (leftToRight) {
if (fLeft.getEnabled()) {
// copy text
@@ -4642,10 +4661,29 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
fLeftLineCount= fLeft.getLineCount();
setLeftDirty(true);
}
+ copyOperationInProgress = false;
update(false);
selectFirstDiff(true);
}
+ private void historyNotification(OperationHistoryEvent event) {
+ switch (event.getEventType()) {
+ case OperationHistoryEvent.OPERATION_ADDED:
+ if (copyOperationInProgress) {
+ copyUndoable = event.getOperation();
+ }
+ break;
+ case OperationHistoryEvent.UNDONE:
+ if (copyUndoable == event.getOperation()) {
+ update(false);
+ }
+ break;
+ default:
+ // Nothing to do
+ break;
+ }
+ }
+
private void copyDiffLeftToRight() {
copy(fCurrentDiff, true, false);
}
@@ -4910,6 +4948,10 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
return getFindReplaceTarget();
if (adapter == CompareHandlerService.class)
return fHandlerService;
+ if (adapter == CompareHandlerService[].class) {
+ return new CompareHandlerService[] { fHandlerService,
+ super.getCompareHandlerService() };
+ }
if (adapter == IEditorInput.class) {
// return active editor input
if (fLeft != null && fLeft == fFocusPart)
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
new file mode 100644
index 000000000..8e8497a4e
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import java.util.Set;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.CompareViewerSwitchingPane;
+import org.eclipse.compare.Splitter;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.PlatformUI;
+
+public class CompareContentViewerSwitchingPane extends
+ CompareViewerSwitchingPane {
+
+ private CompareEditorInput fCompareEditorInput;
+
+ private ViewerDescriptor fSelectedViewerDescriptor;
+
+ private ToolBar toolBar;
+
+ private Menu menu;
+
+ public CompareContentViewerSwitchingPane(Splitter parent, int style,
+ CompareEditorInput cei) {
+ super(parent, style);
+ fCompareEditorInput = cei;
+ }
+
+ private CompareConfiguration getCompareConfiguration() {
+ return fCompareEditorInput.getCompareConfiguration();
+ }
+
+ protected Viewer getViewer(Viewer oldViewer, Object input) {
+ if (fSelectedViewerDescriptor != null) {
+ Set viewers = CompareUIPlugin.getDefault().findContentViewerDescriptor(
+ oldViewer, input, getCompareConfiguration());
+ if (viewers.contains(fSelectedViewerDescriptor)) {
+ // use selected viewer only when appropriate for the new input
+ fCompareEditorInput
+ .setViewerDescriptor(fSelectedViewerDescriptor);
+ Viewer viewer = fCompareEditorInput.findContentViewer(
+ oldViewer, (ICompareInput) input, this);
+ return viewer;
+ }
+ }
+ if (input instanceof ICompareInput) {
+ fCompareEditorInput.setViewerDescriptor(null);
+ Viewer viewer = fCompareEditorInput.findContentViewer(oldViewer,
+ (ICompareInput) input, this);
+ fCompareEditorInput.setViewerDescriptor(fSelectedViewerDescriptor);
+ return viewer;
+ }
+ return null;
+ }
+
+ protected Control createTopLeft(Composite p) {
+ final Composite composite = new Composite(p, SWT.NONE) {
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ return super.computeSize(wHint, Math.max(24, hHint), changed);
+ }
+ };
+
+ RowLayout layout = new RowLayout();
+ layout.marginTop = 0;
+ composite.setLayout(layout);
+
+ CLabel cl = new CLabel(composite, SWT.NONE);
+ cl.setText(null);
+
+ toolBar = new ToolBar(composite, SWT.FLAT);
+ toolBar.setVisible(false); // hide by default
+ final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
+ /* IWorkbenchGraphicConstants */"IMG_LCL_VIEW_MENU")); //$NON-NLS-1$
+ toolItem
+ .setToolTipText(CompareMessages.CompareContentViewerSwitchingPane_switchButtonTooltip);
+ toolItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Rectangle bounds = toolItem.getBounds();
+ Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
+ topLeft = toolBar.toDisplay(topLeft);
+ menu.setLocation(topLeft.x, topLeft.y);
+ menu.setVisible(true);
+ }
+ });
+ return composite;
+ }
+
+ protected boolean inputChanged(Object input) {
+ return getInput() != input
+ || fCompareEditorInput.getViewerDescriptor() != fSelectedViewerDescriptor;
+ }
+
+ public void setInput(Object input) {
+ super.setInput(input);
+ Set/* <ViewerDescriptor> */data = CompareUIPlugin.getDefault()
+ .findContentViewerDescriptor(getViewer(), input,
+ getCompareConfiguration());
+ updateMenu(data);
+ }
+
+ private void updateMenu(Set data) {
+ if (data != null && data.size() > 1) {
+ ViewerDescriptor[] fViewerDescriptors = (ViewerDescriptor[]) data
+ .toArray(new ViewerDescriptor[0]);
+
+ // dispose the old menu, if exists
+ if (menu != null)
+ menu.dispose();
+
+ menu = new Menu(getShell(), SWT.POP_UP);
+
+ // add default
+ String label = fViewerDescriptors[0].getLabel();
+ if (label == null || label.equals("")) { //$NON-NLS-1$
+ label = CompareMessages.CompareContentViewerSwitchingPane_defaultViewer;
+ }
+ MenuItem defaultItem = new MenuItem(menu, SWT.RADIO);
+ defaultItem.setText(label);
+ defaultItem
+ .addSelectionListener(createSelectionListener(fViewerDescriptors[0]));
+ menu.setDefaultItem(defaultItem);
+ defaultItem.setSelection(fViewerDescriptors[0] == fSelectedViewerDescriptor);
+
+ // add others
+ for (int j = 1; j < fViewerDescriptors.length; j++) {
+ final ViewerDescriptor vdi = fViewerDescriptors[j];
+ label = vdi.getLabel();
+ if (label != null && !label.equals("")) { //$NON-NLS-1$
+ MenuItem item = new MenuItem(menu, SWT.RADIO);
+ item.setText(label);
+ item.addSelectionListener(createSelectionListener(vdi));
+ item
+ .setSelection(fViewerDescriptors[j] == fSelectedViewerDescriptor);
+ }
+ }
+ toolBar.setVisible(true);
+ } else {
+ toolBar.setVisible(false);
+ }
+ }
+
+ private SelectionListener createSelectionListener(final ViewerDescriptor vd) {
+ return new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ MenuItem mi = (MenuItem) e.widget;
+ if (mi.getSelection()) {
+ Viewer oldViewer = getViewer();
+ fSelectedViewerDescriptor = vd;
+ CompareContentViewerSwitchingPane.this.setInput(oldViewer
+ .getInput());
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do
+ }
+ };
+ }
+
+ public void setText(String label) {
+ Composite c = (Composite) getTopLeft();
+ Control[] children = c.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof CLabel) {
+ CLabel cl = (CLabel) children[i];
+ if (cl != null && !cl.isDisposed()) {
+ cl.setText(label);
+ c.layout();
+ }
+ return;
+ }
+ }
+ }
+
+ public void setImage(Image image) {
+ Composite c = (Composite) getTopLeft();
+ Control[] children = c.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof CLabel) {
+ CLabel cl = (CLabel) children[i];
+ if (cl != null && !cl.isDisposed())
+ cl.setImage(image);
+ return;
+ }
+ }
+ }
+
+ public void addMouseListener(MouseListener listener) {
+ Composite c = (Composite) getTopLeft();
+ Control[] children = c.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof CLabel) {
+ CLabel cl = (CLabel) children[i];
+ cl.addMouseListener(listener);
+ }
+ }
+ }
+}
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 9fb3b36c3..ced5faf57 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
@@ -490,7 +490,8 @@ public class CompareEditor extends EditorPart implements IReusableEditor, ISavea
public void setFocus() {
IEditorInput input= getEditorInput();
if (input instanceof CompareEditorInput)
- ((CompareEditorInput)input).setFocus();
+ if (!((CompareEditorInput)input).setFocus2())
+ fPageBook.setFocus();
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
index e9a1dd8a9..66f0e4bea 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
@@ -132,6 +132,10 @@ public final class CompareMessages extends NLS {
public static String CompareWithOtherResourceDialog_externalFolderRadioButton;
public static String CompareWithOtherResourceDialog_workspaceMainButton;
public static String CompareWithOtherResourceDialog_workspaceRadioButton;
+ public static String CompareContentViewerSwitchingPane_defaultViewer;
+ public static String CompareContentViewerSwitchingPane_switchButtonTooltip;
+
+ public static String ReaderCreator_fileIsNotAccessible;
public static String CreatePatchActionTitle;
public static String WorkspacePatchDialogTitle;
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
index d55d7612e..903de260f 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
@@ -145,6 +145,11 @@ CompareWithOtherResourceDialog_externalFolderRadioButton=External folder
CompareWithOtherResourceDialog_workspaceMainButton=Browse...
CompareWithOtherResourceDialog_workspaceRadioButton=Workspace
+CompareContentViewerSwitchingPane_defaultViewer=Default
+CompareContentViewerSwitchingPane_switchButtonTooltip=Switch
+
+ReaderCreator_fileIsNotAccessible=Cannot create a reader because the file is inaccessible.
+
WorkspacePatchDialogTitle=Set a Patch Location
WorkspacePatchDialogDescription=Select a folder in the workspace and enter a name for the patch.
Save_To_Clipboard_2=&Clipboard
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 a9695a338..829313753 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -92,73 +93,89 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
static class CompareRegistry {
- private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
- private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
- private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$
-
- private HashMap fIdMap; // maps ids to data
- private HashMap fExtensionMap; // maps extensions to data
- private HashMap fContentTypeBindings; // maps content type bindings to data
-
-
- void register(IConfigurationElement element, Object data) {
- String id= element.getAttribute(ID_ATTRIBUTE);
- if (id != null) {
- if (fIdMap == null)
- fIdMap= new HashMap();
- fIdMap.put(id, data);
- }
-
- String types= element.getAttribute(EXTENSIONS_ATTRIBUTE);
- if (types != null) {
- if (fExtensionMap == null)
- fExtensionMap= new HashMap();
- StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreElements()) {
- String extension= tokenizer.nextToken().trim();
- fExtensionMap.put(normalizeCase(extension), data);
- }
- }
- }
+ private final static String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
+ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
+ private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$
+
+ private HashMap fIdMap; // maps ids to data
+ private HashMap fExtensionMap; // multimap: maps extensions to list of data
+ private HashMap fContentTypeBindings; // multimap: maps content type bindings to list of data
+
+
+ void register(IConfigurationElement element, Object data) {
+ String id= element.getAttribute(ID_ATTRIBUTE);
+ if (id != null) {
+ if (fIdMap == null)
+ fIdMap= new HashMap();
+ fIdMap.put(id, data);
+ }
- void createBinding(IConfigurationElement element, String idAttributeName) {
- String type= element.getAttribute(CONTENT_TYPE_ID_ATTRIBUTE);
- String id= element.getAttribute(idAttributeName);
- if (id == null)
- logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetIdAttributeMissing", idAttributeName)); //$NON-NLS-1$
- if (type != null && id != null && fIdMap != null) {
- Object o= fIdMap.get(id);
- if (o != null) {
- IContentType ct= fgContentTypeManager.getContentType(type);
- if (ct != null) {
- if (fContentTypeBindings == null)
- fContentTypeBindings= new HashMap();
- fContentTypeBindings.put(ct, o);
- } else {
- logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.contentTypeNotFound", type)); //$NON-NLS-1$
- }
- } else {
- logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetNotFound", id)); //$NON-NLS-1$
- }
- }
- }
+ String types= element.getAttribute(EXTENSIONS_ATTRIBUTE);
+ if (types != null) {
+ if (fExtensionMap == null)
+ fExtensionMap= new HashMap();
+ StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$
+ while (tokenizer.hasMoreElements()) {
+ String extension= tokenizer.nextToken().trim();
+ List l = (List) fExtensionMap.get(normalizeCase(extension));
+ if (l == null)
+ fExtensionMap.put(normalizeCase(extension), l = new ArrayList());
+ l.add(data);
+ }
+ }
+ }
- Object search(IContentType type) {
- if (fContentTypeBindings != null) {
- for (; type != null; type= type.getBaseType()) {
- Object data= fContentTypeBindings.get(type);
- if (data != null)
- return data;
- }
- }
- return null;
- }
+ void createBinding(IConfigurationElement element, String idAttributeName) {
+ String type= element.getAttribute(CONTENT_TYPE_ID_ATTRIBUTE);
+ String id= element.getAttribute(idAttributeName);
+ if (id == null)
+ logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetIdAttributeMissing", idAttributeName)); //$NON-NLS-1$
+ if (type != null && id != null && fIdMap != null) {
+ Object o= fIdMap.get(id);
+ if (o != null) {
+ IContentType ct= fgContentTypeManager.getContentType(type);
+ if (ct != null) {
+ if (fContentTypeBindings == null)
+ fContentTypeBindings= new HashMap();
+ List l = (List) fContentTypeBindings.get(ct);
+ if (l == null)
+ fContentTypeBindings.put(ct, l = new ArrayList());
+ l.add(o);
+ } else {
+ logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.contentTypeNotFound", type)); //$NON-NLS-1$
+ }
+ } else {
+ logErrorMessage(Utilities.getFormattedString("CompareUIPlugin.targetNotFound", id)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ Object search(IContentType type) {
+ List list = searchAll(type);
+ return list != null ? list.get(0) : null;
+ }
- Object search(String extension) {
- if (fExtensionMap != null)
- return fExtensionMap.get(normalizeCase(extension));
- return null;
- }
+ List searchAll(IContentType type) {
+ if (fContentTypeBindings != null) {
+ for (; type != null; type= type.getBaseType()) {
+ List data= (List) fContentTypeBindings.get(type);
+ if (data != null)
+ return data;
+ }
+ }
+ return null;
+ }
+
+ Object search(String extension) {
+ List list = searchAll(extension);
+ return list != null ? list.get(0) : null;
+ }
+
+ List searchAll(String extension) {
+ if (fExtensionMap != null)
+ return (List) fExtensionMap.get(normalizeCase(extension));
+ return null;
+ }
}
/** Status code describing an internal error */
@@ -171,19 +188,19 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
private static final String BINARY_TYPE= "binary"; //$NON-NLS-1$
private static final String STREAM_MERGER_EXTENSION_POINT= "streamMergers"; //$NON-NLS-1$
- private static final String STREAM_MERGER= "streamMerger"; //$NON-NLS-1$
- private static final String STREAM_MERGER_ID_ATTRIBUTE= "streamMergerId"; //$NON-NLS-1$
+ private static final String STREAM_MERGER= "streamMerger"; //$NON-NLS-1$
+ private static final String STREAM_MERGER_ID_ATTRIBUTE= "streamMergerId"; //$NON-NLS-1$
private static final String STRUCTURE_CREATOR_EXTENSION_POINT= "structureCreators"; //$NON-NLS-1$
- private static final String STRUCTURE_CREATOR= "structureCreator"; //$NON-NLS-1$
- private static final String STRUCTURE_CREATOR_ID_ATTRIBUTE= "structureCreatorId"; //$NON-NLS-1$
-
+ private static final String STRUCTURE_CREATOR= "structureCreator"; //$NON-NLS-1$
+ private static final String STRUCTURE_CREATOR_ID_ATTRIBUTE= "structureCreatorId"; //$NON-NLS-1$
+
private static final String VIEWER_TAG= "viewer"; //$NON-NLS-1$
private static final String STRUCTURE_MERGE_VIEWER_EXTENSION_POINT= "structureMergeViewers"; //$NON-NLS-1$
- private static final String STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE= "structureMergeViewerId"; //$NON-NLS-1$
+ private static final String STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE= "structureMergeViewerId"; //$NON-NLS-1$
private static final String CONTENT_MERGE_VIEWER_EXTENSION_POINT= "contentMergeViewers"; //$NON-NLS-1$
- private static final String CONTENT_MERGE_VIEWER_ID_ATTRIBUTE= "contentMergeViewerId"; //$NON-NLS-1$
+ private static final String CONTENT_MERGE_VIEWER_ID_ATTRIBUTE= "contentMergeViewerId"; //$NON-NLS-1$
private static final String CONTENT_VIEWER_EXTENSION_POINT= "contentViewers"; //$NON-NLS-1$
- private static final String CONTENT_VIEWER_ID_ATTRIBUTE= "contentViewerId"; //$NON-NLS-1$
+ private static final String CONTENT_VIEWER_ID_ATTRIBUTE= "contentViewerId"; //$NON-NLS-1$
private static final String CONTENT_TYPE_BINDING= "contentTypeBinding"; //$NON-NLS-1$
@@ -223,7 +240,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
private Map fStructureViewerAliases;
private CompareFilter fFilter;
private IPropertyChangeListener fPropertyChangeListener;
-
+
/**
* Creates the <code>CompareUIPlugin</code> object and registers all
* structure creators, content merge viewers, and structure merge viewers
@@ -807,21 +824,8 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return null;
}
- /**
- * Returns a content compare viewer based on an old viewer and an input object.
- * If the old viewer is suitable for showing the input the old viewer
- * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry
- * which in turn is used to create a content compare viewer under the given parent composite.
- * If no viewer descriptor can be found <code>null</code> is returned.
- *
- * @param oldViewer a new viewer is only created if this old viewer cannot show the given input
- * @param in the input object for which to find a content viewer
- * @param parent the SWT parent composite under which the new viewer is created
- * @param cc a configuration which is passed to a newly created viewer
- * @return the compare viewer which is suitable for the given input object or <code>null</code>
- */
- public Viewer findContentViewer(Viewer oldViewer, Object in, Composite parent, CompareConfiguration cc) {
-
+ public Set/*<ViewerDescriptor>*/ findContentViewerDescriptor(Viewer oldViewer, Object in, CompareConfiguration cc) {
+ Set result = new LinkedHashSet();
if (in instanceof IStreamContentAccessor) {
String type= ITypedElement.TEXT_TYPE;
@@ -831,9 +835,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
IContentType ct= getContentType(tin);
if (ct != null) {
initializeRegistries();
- Viewer viewer= getViewer(fContentViewers.search(ct), oldViewer, parent, cc);
- if (viewer != null)
- return viewer;
+ List list = fContentViewers.searchAll(ct);
+ if (list != null)
+ result.addAll(list);
}
String ty= tin.getType();
@@ -842,18 +846,18 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
}
initializeRegistries();
- Viewer viewer= getViewer(fContentViewers.search(type), oldViewer, parent, cc);
- if (viewer != null)
- return viewer;
+ List list = fContentViewers.searchAll(type);
+ if (list != null)
+ result.addAll(list);
// fallback
- return new SimpleTextViewer(parent);
+ result.add(fContentViewers.search(Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT)));
+ return result;
}
if (!(in instanceof ICompareInput))
return null;
-
- ICompareInput input= (ICompareInput) in;
+ ICompareInput input= (ICompareInput) in;
IContentType ctype= getCommonType(input);
if (isCompareAsText(input, cc)) {
@@ -861,9 +865,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
}
if (ctype != null) {
initializeRegistries();
- Viewer viewer= getViewer(fContentMergeViewers.search(ctype), oldViewer, parent, cc);
- if (viewer != null)
- return viewer;
+ List list = fContentMergeViewers.searchAll(ctype);
+ if (list != null)
+ result.addAll(list);
}
String[] types= getTypes(input);
@@ -888,9 +892,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
if (type != null) {
initializeRegistries();
- Viewer viewer= getViewer(fContentMergeViewers.search(type), oldViewer, parent, cc);
- if (viewer != null)
- return viewer;
+ List list = fContentMergeViewers.searchAll(type);
+ if (list != null)
+ result.addAll(list);
}
// fallback
@@ -906,13 +910,34 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
type= BINARY_TYPE;
initializeRegistries();
- IViewerDescriptor vd= (IViewerDescriptor) fContentMergeViewers.search(type);
- if (vd != null)
- return vd.createViewer(oldViewer, parent, cc);
+ List list = fContentMergeViewers.searchAll(type);
+ if (list != null)
+ result.addAll(list);
+ return result;
}
return null;
}
+ /**
+ * Returns a content compare viewer based on an old viewer and an input object.
+ * If the old viewer is suitable for showing the input the old viewer
+ * is returned. Otherwise the input's type is used to find a viewer descriptor in the registry
+ * which in turn is used to create a content compare viewer under the given parent composite.
+ * If no viewer descriptor can be found <code>null</code> is returned.
+ *
+ * @param oldViewer a new viewer is only created if this old viewer cannot show the given input
+ * @param in the input object for which to find a content viewer
+ * @param parent the SWT parent composite under which the new viewer is created
+ * @param cc a configuration which is passed to a newly created viewer
+ * @return the compare viewer which is suitable for the given input object or <code>null</code>
+ */
+ public Viewer findContentViewer(Viewer oldViewer, Object in,
+ Composite parent, CompareConfiguration cc) {
+ Set descriptors = findContentViewerDescriptor(oldViewer, in, cc);
+ return getViewer(descriptors != null ? descriptors.toArray()[0] : null, oldViewer,
+ parent, cc);
+ }
+
private boolean isCompareAsText(ICompareInput input, CompareConfiguration cc) {
Set set = (Set)cc.getProperty(ICompareAsText.PROP_TEXT_INPUTS);
if (set == null)
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
index 22d598c5d..a410ea926 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
@@ -28,14 +28,15 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction {
synchronizeWithPreference();
}
- protected void toggleState(boolean checked) {
+ protected boolean toggleState(boolean checked) {
if (fNeedsPainters == null)
- return; // Not initialized yet
+ return false; // Not initialized yet
if (checked) {
showWhitespace();
} else {
hideWhitespace();
}
+ return true;
}
private synchronized Map getPainters() {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
index d13efb915..f7a49847f 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
@@ -57,8 +57,8 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL
checked = store.getBoolean(getPreferenceKey());
}
if (checked != isChecked()) {
- toggleState(checked);
- setChecked(checked);
+ if (toggleState(checked))
+ setChecked(checked);
}
}
@@ -77,8 +77,15 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL
store.removePropertyChangeListener(this);
}
- protected void toggleState(boolean checked) {
+ /**
+ * @param checked
+ * new state
+ * @return <code>true</code> if state has been changed, toggle has been
+ * successful
+ */
+ protected boolean toggleState(boolean checked) {
// No-op by default
+ return false;
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java
index 86fff3282..e5d35bcf9 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,13 +10,12 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import org.eclipse.swt.widgets.Composite;
-
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IViewerCreator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.compare.*;
-
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
/**
* Creates <code>Viewer</code>s from an <code>IConfigurationElement</code>.
@@ -25,6 +24,7 @@ public class ViewerDescriptor implements IViewerDescriptor {
private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
+ private final static String LABEL_ATTRIBUTE = "label"; //$NON-NLS-1$
private IConfigurationElement fConfiguration;
private IViewerCreator fViewerCreator;
@@ -53,9 +53,12 @@ public class ViewerDescriptor implements IViewerDescriptor {
// If we are going to return a new viewer, we want to preemptively deregister
// any handlers to avoid the logging of conflict warnings
if (currentViewer != null) {
- CompareHandlerService compareHandlerService = (CompareHandlerService)Utilities.getAdapter(currentViewer, CompareHandlerService.class);
- if (compareHandlerService != null)
- compareHandlerService.dispose();
+ CompareHandlerService[] compareHandlerService = (CompareHandlerService[]) Utilities.getAdapter(currentViewer, CompareHandlerService[].class);
+ if (compareHandlerService != null) {
+ for (int i = 0; i < compareHandlerService.length; i++) {
+ compareHandlerService[i].dispose();
+ }
+ }
}
Viewer viewer= fViewerCreator.createViewer(parent, mp);
if (viewer != null)
@@ -69,4 +72,8 @@ public class ViewerDescriptor implements IViewerDescriptor {
public String getExtension() {
return fConfiguration.getAttribute(EXTENSIONS_ATTRIBUTE);
}
+
+ String getLabel() {
+ return fConfiguration.getAttribute(LABEL_ATTRIBUTE);
+ }
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Utilities.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Utilities.java
index a1b57001f..e84e8100b 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Utilities.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Utilities.java
@@ -17,14 +17,18 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
+import org.eclipse.compare.internal.CompareMessages;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.patch.ReaderCreator;
import org.eclipse.core.resources.IEncodedStorage;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
public class Utilities {
@@ -43,17 +47,36 @@ public class Utilities {
return ResourcesPlugin.getWorkspace().getRoot().getProject(
diffProject.getName());
}
-
- public static ReaderCreator getReaderCreator(final IStorage storage){
- return new ReaderCreator(){
+
+ public static ReaderCreator getReaderCreator(final IStorage storage) {
+ return new ReaderCreator() {
public Reader createReader() throws CoreException {
return Utilities.createReader(storage);
- }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.compare.patch.ReaderCreator#canCreateReader()
+ */
+ public boolean canCreateReader() {
+ if (storage != null && storage instanceof IFile
+ && !((IFile) storage).isAccessible()) {
+ return false;
+ }
+ return true;
+ }
};
}
-
+
public static BufferedReader createReader(IStorage storage)
throws CoreException {
+ if (storage != null && storage instanceof IFile
+ && !((IFile) storage).isAccessible()) {
+ throw new CoreException(new Status(IStatus.WARNING,
+ CompareUIPlugin.PLUGIN_ID,
+ CompareMessages.ReaderCreator_fileIsNotAccessible));
+ }
String charset = null;
if (storage instanceof IEncodedStorage) {
IEncodedStorage es = (IEncodedStorage) storage;
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 b52898939..6fb2a5e3a 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2008 IBM Corporation and others.
+# Copyright (c) 2000, 2009 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -224,3 +224,7 @@ ValidateEdit.error.stillReadonly= File ''{0}'' is read-only.
context.description = Comparing in an Editor
context.name = Comparing in an Editor
+
+BinaryCompare.label=Binary Compare
+TextCompare.label=Text Compare
+ImageCompare.label=Image Compare
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 844a64108..0cf7b3573 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
@@ -307,19 +307,22 @@
<extension
point="org.eclipse.compare.contentMergeViewers">
<viewer
- extensions="class,exe,dll,binary,zip,jar"
class="org.eclipse.compare.internal.BinaryCompareViewerCreator"
- id="org.eclipse.compare.BinaryCompareViewerCreator">
+ extensions="class,exe,dll,binary,zip,jar"
+ id="org.eclipse.compare.BinaryCompareViewerCreator"
+ label="%BinaryCompare.label">
</viewer>
<viewer
- extensions="txt"
class="org.eclipse.compare.internal.TextMergeViewerCreator"
- id="org.eclipse.compare.TextMergeViewerCreator">
+ extensions="txt"
+ id="org.eclipse.compare.TextMergeViewerCreator"
+ label="%TextCompare.label">
</viewer>
<viewer
- extensions="gif,jpg,jpeg,png,bmp,ico,tif,tiff"
class="org.eclipse.compare.internal.ImageMergeViewerCreator"
- id="org.eclipse.compare.ImageMergeViewerCreator">
+ extensions="gif,jpg,jpeg,png,bmp,ico,tif,tiff"
+ id="org.eclipse.compare.ImageMergeViewerCreator"
+ label="%ImageCompare.label">
</viewer>
<contentTypeBinding
contentTypeId="org.eclipse.core.runtime.text"
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd
index 244662a10..ee34a6dc5 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd
@@ -2,9 +2,9 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.compare" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.eclipse.compare" id="contentMergeViewers" name="ContentMerge Viewers"/>
- </appinfo>
+ </appInfo>
<documentation>
This extension point allows a plug-in to register compare/merge
viewers for specific content types. The viewer is expected to
@@ -17,9 +17,9 @@ for viewers &lt;samp&gt;org.eclipse.compare.IViewerCreator&lt;/samp&gt;.
<element name="extension">
<annotation>
- <appinfo>
+ <appInfo>
<meta.element />
- </appinfo>
+ </appInfo>
</annotation>
<complexType>
<sequence>
@@ -45,9 +45,9 @@ for viewers &lt;samp&gt;org.eclipse.compare.IViewerCreator&lt;/samp&gt;.
<documentation>
an optional name of the extension instance
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -68,9 +68,9 @@ for viewers &lt;samp&gt;org.eclipse.compare.IViewerCreator&lt;/samp&gt;.
a fully qualified name of a class that implements a factory for the
content merge viewer and implements &lt;samp&gt;org.eclipse.compare.IViewerCreator&lt;/samp&gt;
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.compare.IViewerCreator"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="extensions" type="string">
@@ -80,6 +80,16 @@ content merge viewer and implements &lt;samp&gt;org.eclipse.compare.IViewerCreat
</documentation>
</annotation>
</attribute>
+ <attribute name="label" type="string">
+ <annotation>
+ <documentation>
+ a translatable label that will be used in the UI for this viewer
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -95,9 +105,9 @@ content merge viewer and implements &lt;samp&gt;org.eclipse.compare.IViewerCreat
<documentation>
The id of a content type defined using the &lt;code&gt;org.eclipse.core.contenttype.contentTypes&lt;/code&gt; extension point.
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="contentMergeViewerId" type="string" use="required">
@@ -105,18 +115,18 @@ content merge viewer and implements &lt;samp&gt;org.eclipse.compare.IViewerCreat
<documentation>
The id of a merge viewer defined using the &lt;code&gt;viewer&lt;/code&gt; element of this extension point (i.e. &lt;code&gt;org.eclipse.compare.contentMergeViewers&lt;/code&gt;)
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.compare.contentMergeViewers/viewer/@id"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
The following is an example of a compare/merge viewer
for text files (extension &quot;txt&quot;):
@@ -135,9 +145,9 @@ for text files (extension &quot;txt&quot;):
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiInfo"/>
- </appinfo>
+ </appInfo>
<documentation>
The contributed class must implement &lt;code&gt;org.eclipse.compare.IViewerCreator&lt;/code&gt;
</documentation>
@@ -145,20 +155,20 @@ for text files (extension &quot;txt&quot;):
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="implementation"/>
- </appinfo>
+ </appInfo>
<documentation>
The Compare UI plugin defines content viewers for text, binary contents, and images.
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="copyright"/>
- </appinfo>
+ </appInfo>
<documentation>
- Copyright (c) 2000, 2008 IBM Corporation and others.&lt;br&gt;
+ Copyright (c) 2000, 2009 IBM Corporation and others.&lt;br&gt;
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
</documentation>
</annotation>
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AbstractPatchTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AbstractPatchTest.java
index 5e4664195..82ccafbb1 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AbstractPatchTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AbstractPatchTest.java
@@ -12,6 +12,9 @@ package org.eclipse.compare.tests;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -49,32 +52,53 @@ public abstract class AbstractPatchTest extends TestCase {
class StringStorage implements IStorage {
String fileName;
-
public StringStorage(String old) {
fileName = old;
}
-
public Object getAdapter(Class adapter) {
return null;
}
-
public boolean isReadOnly() {
return false;
}
-
public String getName() {
return fileName;
}
-
public IPath getFullPath() {
return null;
}
-
public InputStream getContents() throws CoreException {
return new BufferedInputStream(asInputStream(fileName));
}
}
+ class FileStorage implements IStorage {
+ File file;
+ public FileStorage(File file) {
+ this.file = file;
+ }
+ public InputStream getContents() throws CoreException {
+ try {
+ return new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ // ignore, should never happen
+ }
+ return null;
+ }
+ public IPath getFullPath() {
+ return new Path(file.getAbsolutePath());
+ }
+ public String getName() {
+ return file.getName();
+ }
+ public boolean isReadOnly() {
+ return true;
+ }
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+ }
+
protected abstract String getWorkingFolder();
protected BufferedReader getReader(String name) {
@@ -95,13 +119,13 @@ public abstract class AbstractPatchTest extends TestCase {
}
protected void patch(final String old, String patch, String expt)
- throws CoreException, IOException {
+ throws CoreException, IOException {
patcherPatch(old, patch, expt);
filePatch(old, patch, expt);
}
void filePatch(final String old, String patch, String expt)
- throws CoreException, IOException {
+ throws CoreException, IOException {
LineReader lr = new LineReader(getReader(expt));
List inLines = lr.readLines();
String expected = LineReader.createString(false, inLines);
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java
index 177f82030..a69656f33 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java
@@ -226,6 +226,9 @@ public class PatchBuilderTest extends TestCase {
" [b]", "-[c]", " [d]", " [e]", " [f]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -241,6 +244,9 @@ public class PatchBuilderTest extends TestCase {
"+[j2]", " [k]", " [l]", " [m]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -254,6 +260,9 @@ public class PatchBuilderTest extends TestCase {
String[] lines = new String[] { "+[aa]", "+[bb]", "+[cc]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -267,6 +276,9 @@ public class PatchBuilderTest extends TestCase {
String[] lines = new String[] { "-[aa]", "-[bb]", "-[cc]", "-[dd]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -287,6 +299,13 @@ public class PatchBuilderTest extends TestCase {
assertEquals(h1.getHunkType(true), h2.getHunkType(true));
}
+ private void assertLinesEquals(String[] expected, String[] actual) {
+ assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(expected[i], actual[i]);
+ }
+ }
+
private void addLineDelimiters(String[] lines) {
for (int i = 0; i < lines.length; i++) {
lines[i] = lines[i] + "\r\n";
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/UnifiedDiffFormatterTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/UnifiedDiffFormatterTest.java
index cd701f101..03455b8d9 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/UnifiedDiffFormatterTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/UnifiedDiffFormatterTest.java
@@ -37,7 +37,7 @@ public class UnifiedDiffFormatterTest extends AbstractPatchTest {
super(name);
}
- private static final String TESTPATCHFILE = "testPatch.txt";
+ private static final String TESTPATCHFILE = "#testPatch.txt";
protected void setUp() throws Exception {
super.setUp();

Back to the top