Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2009-02-24 13:05:57 +0000
committerTomasz Zarna2009-02-24 13:05:57 +0000
commit829ffb925b2184ce82d4a192def6af92bb88a19d (patch)
tree95f38b8e2b6d29c2a16fdf91e860dfbc530c9086
parentd73580ccfe6ce867144efb5b54ede39e16e27770 (diff)
downloadeclipse.platform.team-829ffb925b2184ce82d4a192def6af92bb88a19d.tar.gz
eclipse.platform.team-829ffb925b2184ce82d4a192def6af92bb88a19d.tar.xz
eclipse.platform.team-829ffb925b2184ce82d4a192def6af92bb88a19d.zip
Rebasing.
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/.settings/.api_filters28
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java19
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java14
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java14
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java39
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java90
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FileDiffWrapper.java78
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java17
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java253
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java29
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java23
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java15
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Utilities.java81
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java26
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java42
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/IFilePatch.java86
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java5
28 files changed, 665 insertions, 238 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 41ac7f451..3a3acc948 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
@@ -1,5 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.compare" version="2">
+ <resource path="compare/org/eclipse/compare/CompareViewerSwitchingPane.java" type="org.eclipse.compare.CompareViewerSwitchingPane">
+ <filter id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.compare.CompareViewerSwitchingPane"/>
+ <message_argument value="setTitleArgument(String)"/>
+ </message_arguments>
+ </filter>
+ <filter id="338944126">
+ <message_arguments>
+ <message_argument value="org.eclipse.compare.CompareViewerSwitchingPane"/>
+ <message_argument value="getTitleArgument()"/>
+ </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>
<resource path="META-INF/MANIFEST.MF" type="org.eclipse.compare.patch.IHunk">
<filter id="403853384">
<message_arguments>
@@ -21,11 +42,4 @@
</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/META-INF/MANIFEST.MF b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/META-INF/MANIFEST.MF
index 5ceee9f64..559dc6a17 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/META-INF/MANIFEST.MF
@@ -23,7 +23,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.editors;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.compare.core;bundle-version="[1.0.0,2.0.0)";visibility:=reexport
+ org.eclipse.compare.core;bundle-version="[3.5.0,4.0.0)";visibility:=reexport
Bundle-ActivationPolicy: lazy
Import-Package: com.ibm.icu.util,
com.ibm.icu.text
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 22a79d359..bc2892da8 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
@@ -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
@@ -168,12 +168,13 @@ public abstract class CompareViewerSwitchingPane extends CompareViewerPane {
}
/**
- * Returns the optional title argument that has been set with <code>setTitelArgument</code>
- * or <code>null</code> if no optional title argument has been set.
- * <p>
- * Note: this method is for internal use only. Clients should not call this method.
+ * Returns the optional title argument that has been set with
+ * <code>setTitelArgument</code> or <code>null</code> if no optional title
+ * argument has been set.
*
* @return the optional title argument or <code>null</code>
+ * @noreference This method is for internal use only. Clients should not
+ * call this method.
*/
public String getTitleArgument() {
return fTitleArgument;
@@ -278,9 +279,11 @@ public abstract class CompareViewerSwitchingPane extends CompareViewerPane {
/**
* Sets an additional and optional argument for the pane's title.
- * Note: this method is for internal use only. Clients should not call this method.
- *
- * @param argument an optional argument for the pane's title
+ *
+ * @param argument
+ * an optional argument for the pane's title
+ * @noreference This method is for internal use only. Clients should not
+ * call this method.
*/
public void setTitleArgument(String argument) {
fTitleArgument= argument;
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 e1bea0bae..8fe36201d 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
@@ -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
@@ -130,6 +130,10 @@ public class EditionSelectionDialog extends ResizableDialog {
}
return super.equals(other);
}
+
+ public int hashCode() {
+ return getContent().hashCode();
+ }
}
// Configuration options
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 6dfe9b810..b73e30fbc 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
@@ -1651,12 +1651,10 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (RESOLVED == null)
RESOLVED= new RGB(0, 255, 0); // GREEN
- updatePresentation(display);
+ updatePresentation();
}
- private void updatePresentation(Display display) {
- if (display == null)
- display= fComposite.getDisplay();
+ private void updatePresentation() {
refreshBirdsEyeView();
invalidateLines();
invalidateTextPresentation();
@@ -3315,6 +3313,8 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
//---- update UI stuff
private void updateControls() {
+ if (getControl().isDisposed())
+ return;
boolean leftToRight= false;
boolean rightToLeft= false;
@@ -3694,7 +3694,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
} else if (key.equals(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES)) {
fHighlightTokenChanges= fPreferenceStore.getBoolean(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES);
updateResolveStatus();
- updatePresentation(null);
+ updatePresentation();
// } else if (key.equals(ComparePreferencePage.USE_RESOLVE_UI)) {
// fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI);
@@ -4424,8 +4424,6 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (fCenterButton != null && !fCenterButton.isDisposed())
fCenterButton.setVisible(false);
- Diff oldDiff= fCurrentDiff;
-
if (d != null && revealAndSelect) {
// before we set fCurrentDiff we change the selection
@@ -4980,7 +4978,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
updateControls();
updateVScrollBar();
- updatePresentation(null);
+ updatePresentation();
}
private void resetDiffs() {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
index 811a5fcd4..412ee2b50 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.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
@@ -55,7 +55,7 @@ public class BinaryCompareViewer extends AbstractViewer {
fComposite.setLayout(rowLayout);
fMessage= new Label(fComposite, SWT.WRAP);
- fMessage.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$
+ fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$
fLeftIsLocal= Utilities.getBoolean(cc, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java
index 6f77e0593..b7125fc2f 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 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
@@ -194,9 +194,7 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider {
* @see ISelectionProvider#setSelection
*/
public void setSelection(ISelection selection) {
- if (fViewerInFocus != null) {
- fViewerInFocus.setSelection(selection);
- }
+ setSelection(selection, true);
}
public void setSelection(ISelection selection, boolean reveal) {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
index 2ef8feb13..87573971a 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
@@ -219,10 +219,6 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
text.setText(string);
}
- protected InternalSection getSection() {
- return section;
- }
-
protected void setEnabled(boolean enabled) {
radioButton.setSelection(enabled);
mainButton.setEnabled(enabled);
@@ -381,10 +377,6 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
ExternalFolderContent externalFolderContent;
WorkspaceContent workspaceContent;
- public InternalSection(Composite parent) {
- createContents(parent);
- }
-
private InternalSection() {
// not to instantiate
}
@@ -405,18 +397,20 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
private void addListenersToRadioButtons() {
final ContentTypeElement[] elements = new ContentTypeElement[] { workspaceContent,
externalFileContent, externalFolderContent };
- for (int i = 0; i < elements.length; i++)
+ for (int i = 0; i < elements.length; i++) {
elements[i].getRadioButton().addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
- for (int j = 0; j < elements.length; j++)
+ for (int j = 0; j < elements.length; j++) {
if (event.widget != elements[j].getRadioButton())
elements[j].setEnabled(false);
else {
elements[j].setEnabled(true);
setResource(elements[j].getResource());
}
+ }
}
});
+ }
}
protected IResource getResource() {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java
index fb4806a49..f24d969d0 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java
@@ -871,14 +871,8 @@ public class GenerateDiffFileWizard extends Wizard {
protected final RadioButtonGroup diffTypeRadioGroup = new RadioButtonGroup();
protected final RadioButtonGroup unifiedRadioGroup = new RadioButtonGroup();
- protected IPath patchRoot=ResourcesPlugin.getWorkspace().getRoot().getFullPath();
-
private final DefaultValuesStore store;
- public IPath getPatchRoot() {
- return patchRoot;
- }
-
/**
* Constructor for PatchFileCreationOptionsPage.
*/
@@ -1027,43 +1021,10 @@ public class GenerateDiffFileWizard extends Wizard {
return unifiedGroup;
}
- public Group getDiffTypeGroup() {
- return diffTypeGroup;
- }
-
- public RadioButtonGroup getDiffTypeRadioGroup() {
- return diffTypeRadioGroup;
- }
-
public RadioButtonGroup getUnifiedRadioGroup() {
return unifiedRadioGroup;
}
-
- public Button getUnifiedDiffOption() {
- return unifiedDiffOption;
- }
-
- public Button getContextDiffOption() {
- return contextDiffOption;
- }
-
- public Button getRegularDiffOption() {
- return regularDiffOption;
- }
-
- public Button getUnified_workspaceRelativeOption() {
- return unified_workspaceRelativeOption;
- }
-
- public Button getUnified_projectRelativeOption() {
- return unified_projectRelativeOption;
- }
-
- public Button getUnified_selectionRelativeOption() {
- return unified_selectionRelativeOption;
- }
-
private void initializeDefaultValues() {
// Radio buttons for format
diffTypeRadioGroup.setSelection(store.getFormatSelection(), true);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java
deleted file mode 100644
index e9fd35210..000000000
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ListDialog.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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 org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.*;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.*;
-
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-public class ListDialog extends SelectionDialog {
-
- private IStructuredContentProvider fContentProvider;
- private ILabelProvider fLabelProvider;
- private Object fInput;
- private TableViewer fTableViewer;
- private boolean fAddCancelButton;
-
- public ListDialog(Shell parent) {
- super(parent);
- fAddCancelButton= false;
- }
-
- public void setInput(Object input) {
- fInput= input;
- }
-
- public void setContentProvider(IStructuredContentProvider sp){
- fContentProvider= sp;
- }
-
- public void setLabelProvider(ILabelProvider lp){
- fLabelProvider= lp;
- }
-
- public void setAddCancelButton(boolean addCancelButton) {
- fAddCancelButton= addCancelButton;
- }
-
- public TableViewer getTableViewer(){
- return fTableViewer;
- }
-
- public boolean hasFilters(){
- return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0;
- }
-
- public void create() {
- setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
- super.create();
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- if (! fAddCancelButton)
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- else
- super.createButtonsForButtonBar(parent);
- }
-
- protected Control createDialogArea(Composite container) {
- Composite parent= (Composite) super.createDialogArea(container);
- createMessageArea(parent);
- fTableViewer= new TableViewer(parent, getTableStyle());
- fTableViewer.setContentProvider(fContentProvider);
- Table table= fTableViewer.getTable();
- fTableViewer.setLabelProvider(fLabelProvider);
- fTableViewer.setInput(fInput);
- GridData gd= new GridData(GridData.FILL_BOTH);
- gd.heightHint= convertHeightInCharsToPixels(15);
- gd.widthHint= convertWidthInCharsToPixels(55);
- table.setLayoutData(gd);
- applyDialogFont(parent);
- return parent;
- }
-
- protected int getTableStyle() {
- return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
- }
-}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
index a24c27080..0a2302f00 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
@@ -837,7 +837,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
private void addSave(IMenuManager menu) {
ICommandService commandService = (ICommandService) fContainer.getWorkbenchPart().getSite().getService(ICommandService.class);
- final Command command = commandService.getCommand("org.eclipse.ui.file.save");
+ final Command command = commandService.getCommand("org.eclipse.ui.file.save"); //$NON-NLS-1$
final IHandler handler = command.getHandler();
if (handler != null) {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java
index 08f6d7549..ac50eb781 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java
@@ -47,7 +47,8 @@ class DecoratorOverlayIcon extends CompositeImageDescriptor {
}
/**
- * Draw the overlays for the reciever.
+ * Draw the overlays for the receiver.
+ * @param overlaysArray the overlay images
*/
protected void drawOverlays(ImageDescriptor[] overlaysArray) {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FileDiffWrapper.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FileDiffWrapper.java
new file mode 100644
index 000000000..6d3991953
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FileDiffWrapper.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.patch;
+
+import org.eclipse.compare.internal.core.patch.FileDiff;
+import org.eclipse.compare.patch.IFilePatch;
+import org.eclipse.compare.patch.IFilePatchResult;
+import org.eclipse.compare.patch.IHunk;
+import org.eclipse.compare.patch.PatchConfiguration;
+import org.eclipse.compare.patch.ReaderCreator;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class FileDiffWrapper implements IFilePatch {
+
+ private FileDiff fileDiff;
+
+ public FileDiffWrapper(FileDiff fileDiff) {
+ this.fileDiff = fileDiff;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.compare.patch.IFilePatch#apply(org.eclipse.core.resources
+ * .IStorage, org.eclipse.compare.patch.PatchConfiguration,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IFilePatchResult apply(IStorage content,
+ PatchConfiguration configuration, IProgressMonitor monitor) {
+ return fileDiff.apply(content != null ? Utilities
+ .getReaderCreator(content) : null, configuration, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.compare.patch.IFilePatch2#apply(org.eclipse.compare.patch
+ * .ReaderCreator, org.eclipse.compare.patch.PatchConfiguration,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IFilePatchResult apply(ReaderCreator content,
+ PatchConfiguration configuration, IProgressMonitor monitor) {
+ return fileDiff.apply(content, configuration, monitor);
+ }
+
+ public long getAfterDate() {
+ return fileDiff.getAfterDate();
+ }
+
+ public long getBeforeDate() {
+ return fileDiff.getBeforeDate();
+ }
+
+ public String getHeader() {
+ return fileDiff.getHeader();
+ }
+
+ public IPath getTargetPath(PatchConfiguration configuration) {
+ return fileDiff.getTargetPath(configuration);
+ }
+
+ public IHunk[] getHunks() {
+ return fileDiff.getHunks();
+ }
+
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java
index 6a4b0320c..4ff4ab349 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 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,14 +10,19 @@
*******************************************************************************/
package org.eclipse.compare.internal.patch;
-import java.io.*;
+import java.io.InputStream;
import org.eclipse.compare.IEncodedStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.internal.*;
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.DiffImageDescriptor;
+import org.eclipse.compare.internal.ICompareUIConstants;
+import org.eclipse.compare.internal.core.patch.FileDiffResult;
import org.eclipse.compare.internal.core.patch.HunkResult;
import org.eclipse.compare.patch.IHunk;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.swt.graphics.Image;
@@ -71,7 +76,7 @@ public class HunkTypedElement implements ITypedElement, IEncodedStreamContentAcc
* @see org.eclipse.compare.ITypedElement#getName()
*/
public String getName() {
- return fHunkResult.getLabel();
+ return fHunkResult.getHunk().getLabel();
}
/* (non-Javadoc)
@@ -86,7 +91,7 @@ public class HunkTypedElement implements ITypedElement, IEncodedStreamContentAcc
*/
public InputStream getContents() throws CoreException {
String contents = fHunkResult.getContents(fIsAfterState, fFullContext);
- return fHunkResult.asInputStream(contents);
+ return FileDiffResult.asInputStream(contents, fHunkResult.getCharset());
}
public String getCharset() throws CoreException {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java
new file mode 100644
index 000000000..735b1c3d3
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Brock Janiczak <brockj@tpg.com.au> - Bug 181919 LineReader creating unneeded garbage
+ *******************************************************************************/
+package org.eclipse.compare.internal.patch;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+
+public class LineReader {
+
+ /*
+ * Reads the contents from the given file and returns them as a List of
+ * lines.
+ */
+ public static List load(IStorage file, boolean create) {
+ List lines = null;
+ if (!create && file != null && exists(file)) {
+ // read current contents
+ String charset = Utilities.getCharset(file);
+ InputStream is = null;
+ try {
+ is = file.getContents();
+
+ Reader streamReader = null;
+ try {
+ streamReader = new InputStreamReader(is, charset);
+ } catch (UnsupportedEncodingException x) {
+ // use default encoding
+ streamReader = new InputStreamReader(is);
+ }
+
+ BufferedReader reader = new BufferedReader(streamReader);
+ lines = readLines(reader);
+ } catch (CoreException ex) {
+ // TODO
+ CompareUIPlugin.log(ex);
+ } finally {
+ if (is != null)
+ try {
+ is.close();
+ } catch (IOException ex) {
+ // silently ignored
+ }
+ }
+ }
+
+ if (lines == null)
+ lines = new ArrayList();
+ return lines;
+ }
+
+ private static boolean exists(IStorage file) {
+ if (file instanceof IFile) {
+ return ((IFile) file).exists();
+ }
+ return true;
+ }
+
+ public static List readLines(BufferedReader reader) {
+ List lines;
+ LineReader lr = new LineReader(reader);
+ if (!Platform.WS_CARBON.equals(Platform.getWS()))
+ // Don't treat single CRs as line feeds to be consistent with command line patch
+ lr.ignoreSingleCR();
+ lines = lr.readLines();
+ return lines;
+ }
+
+ /*
+ * Concatenates all strings found in the given List.
+ */
+ public static String createString(boolean preserveLineDelimeters, List lines) {
+ StringBuffer sb = new StringBuffer();
+ Iterator iter = lines.iterator();
+ if (preserveLineDelimeters) {
+ while (iter.hasNext())
+ sb.append((String) iter.next());
+ } else {
+ String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
+ while (iter.hasNext()) {
+ String line = (String) iter.next();
+ int l = length(line);
+ if (l < line.length()) { // line has delimiter
+ sb.append(line.substring(0, l));
+ sb.append(lineSeparator);
+ } else {
+ sb.append(line);
+ }
+ }
+ }
+ return sb.toString();
+ }
+
+ /*
+ * Returns the length (excluding a line delimiter CR, LF, CR/LF) of the
+ * given string.
+ */
+ /* package */static int length(String s) {
+ int l = s.length();
+ if (l > 0) {
+ char c = s.charAt(l - 1);
+ if (c == '\r')
+ return l - 1;
+ if (c == '\n') {
+ if (l > 1 && s.charAt(l - 2) == '\r')
+ return l - 2;
+ return l - 1;
+ }
+ }
+ return l;
+ }
+
+ private boolean fHaveChar = false;
+ private int fLastChar;
+ private boolean fSawEOF = false;
+ private BufferedReader fReader;
+ private boolean fIgnoreSingleCR = false;
+ private StringBuffer fBuffer = new StringBuffer();
+
+ public LineReader(BufferedReader reader) {
+ fReader = reader;
+ Assert.isNotNull(reader);
+ }
+
+ public void ignoreSingleCR() {
+ fIgnoreSingleCR = true;
+ }
+
+ /**
+ * Reads a line of text. A line is considered to be terminated by any one of
+ * a line feed ('\n'), a carriage return ('\r'), or a carriage return
+ * followed immediately by a line-feed.
+ *
+ * @return A string containing the contents of the line including the
+ * line-termination characters, or <code>null</code> if the end of
+ * the stream has been reached
+ * @exception IOException
+ * If an I/O error occurs
+ */
+ /* package */String readLine() throws IOException {
+ try {
+ while (!fSawEOF) {
+ int c = readChar();
+ if (c == -1) {
+ fSawEOF = true;
+ break;
+ }
+ fBuffer.append((char) c);
+ if (c == '\n')
+ break;
+ if (c == '\r') {
+ c = readChar();
+ if (c == -1) {
+ fSawEOF = true;
+ break; // EOF
+ }
+ if (c != '\n') {
+ if (fIgnoreSingleCR) {
+ fBuffer.append((char) c);
+ continue;
+ }
+ fHaveChar = true;
+ fLastChar = c;
+ } else
+ fBuffer.append((char) c);
+ break;
+ }
+ }
+
+ if (fBuffer.length() != 0) {
+ return fBuffer.toString();
+ }
+ return null;
+ } finally {
+ fBuffer.setLength(0);
+ }
+ }
+
+ /* package */void close() {
+ try {
+ fReader.close();
+ } catch (IOException ex) {
+ // silently ignored
+ }
+ }
+
+ public List readLines() {
+ try {
+ List lines = new ArrayList();
+ String line;
+ while ((line = readLine()) != null)
+ lines.add(line);
+ return lines;
+ } catch (IOException ex) {
+ // NeedWork
+ // System.out.println("error while reading file: " + fileName + "("
+ // + ex + ")");
+ } finally {
+ close();
+ }
+ return null;
+ }
+
+ /*
+ * Returns the number of characters in the given string without counting a
+ * trailing line separator.
+ */
+ /* package */int lineContentLength(String line) {
+ if (line == null)
+ return 0;
+ int length = line.length();
+ for (int i = length - 1; i >= 0; i--) {
+ char c = line.charAt(i);
+ if (c == '\n' || c == '\r')
+ length--;
+ else
+ break;
+ }
+ return length;
+ }
+
+ // ---- private
+
+ private int readChar() throws IOException {
+ if (fHaveChar) {
+ fHaveChar = false;
+ return fLastChar;
+ }
+ return fReader.read();
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java
index 278296a00..28cd43e9d 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -59,7 +59,7 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput {
PatchDiffNode node = (PatchDiffNode) element;
if (node instanceof PatchProjectDiffNode) {
PatchProjectDiffNode projectNode = (PatchProjectDiffNode) node;
- if (!projectNode.getDiffProject().getProject().exists()) {
+ if (!Utilities.getProject(projectNode.getDiffProject()).exists()) {
text = NLS.bind(PatchMessages.Diff_2Args, new String[]{text, PatchMessages.PreviewPatchLabelDecorator_ProjectDoesNotExist});
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
index 6f99a65bc..51876e3ae 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -21,7 +21,6 @@ import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
-import org.eclipse.compare.internal.core.patch.LineReader;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -29,7 +28,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.swt.graphics.Image;
-public class PatchFileTypedElement implements ITypedElement, IEncodedStreamContentAccessor {
+public class PatchFileTypedElement implements ITypedElement,
+ IEncodedStreamContentAccessor {
private final FileDiffResult result;
private final boolean isAfterState;
@@ -45,11 +45,13 @@ public class PatchFileTypedElement implements ITypedElement, IEncodedStreamConte
// We don't get a target file if the file doesn't exist
DiffProject project = result.getDiff().getProject();
if (project != null) {
- file = project.getFile(result.getDiff().getPath(result.getConfiguration().isReversed()));
+ file = Utilities.getProject(project).getFile(
+ result.getDiff().getPath(
+ result.getConfiguration().isReversed()));
} else {
IResource target = getPatcher().getTarget();
if (target instanceof IFile) {
- file = (IFile) target;
+ file = (IFile) target;
} else if (target instanceof IContainer) {
IContainer container = (IContainer) target;
file = container.getFile(result.getTargetPath());
@@ -61,20 +63,25 @@ public class PatchFileTypedElement implements ITypedElement, IEncodedStreamConte
image = CompareUI.getImage(file);
}
if (result.containsProblems()) {
- LocalResourceManager imageCache = PatchCompareEditorInput.getImageCache(result.getConfiguration());
+ LocalResourceManager imageCache = PatchCompareEditorInput
+ .getImageCache(result.getConfiguration());
image = HunkTypedElement.getHunkErrorImage(image, imageCache, true);
}
return image;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.compare.ITypedElement#getName()
*/
public String getName() {
return result.getTargetPath().toString();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.compare.ITypedElement#getType()
*/
public String getType() {
@@ -89,7 +96,8 @@ public class PatchFileTypedElement implements ITypedElement, IEncodedStreamConte
public InputStream getContents() throws CoreException {
// If there are cached contents, use them
if (isAfterState && getPatcher().hasCachedContents(result.getDiff()))
- return new ByteArrayInputStream(getPatcher().getCachedContents(result.getDiff()));
+ return new ByteArrayInputStream(getPatcher().getCachedContents(
+ result.getDiff()));
// Otherwise, get the lines from the diff result
List lines;
if (isAfterState) {
@@ -97,7 +105,8 @@ public class PatchFileTypedElement implements ITypedElement, IEncodedStreamConte
} else {
lines = result.getBeforeLines();
}
- String contents = LineReader.createString(getPatcher().isPreserveLineDelimeters(), lines);
+ String contents = LineReader.createString(getPatcher()
+ .isPreserveLineDelimeters(), lines);
String charSet = getCharset();
byte[] bytes = null;
if (charSet != null) {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java
index 4c6834f5f..2f8f58a69 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -40,7 +40,7 @@ public class PatchProjectDiffNode extends PatchDiffNode {
* @see org.eclipse.compare.structuremergeviewer.DiffNode#getImage()
*/
public Image getImage() {
- Image image = CompareUI.getImage(project.getProject());
+ Image image = CompareUI.getImage(Utilities.getProject(project));
if (containsProblems()) {
LocalResourceManager imageCache = PatchCompareEditorInput.getImageCache(getConfiguration());
image = HunkTypedElement.getHunkErrorImage(image, imageCache, true);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index f2a7179b1..9fb1787d2 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -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
@@ -31,10 +31,9 @@ import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FileDiff;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
import org.eclipse.compare.internal.core.patch.Hunk;
-import org.eclipse.compare.internal.core.patch.IHunkFilter;
-import org.eclipse.compare.internal.core.patch.LineReader;
import org.eclipse.compare.internal.core.patch.PatchReader;
-import org.eclipse.compare.internal.core.patch.Utilities;
+import org.eclipse.compare.patch.IHunk;
+import org.eclipse.compare.patch.IHunkFilter;
import org.eclipse.compare.patch.PatchConfiguration;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -92,7 +91,7 @@ public class Patcher implements IHunkFilter {
public Patcher() {
configuration = new PatchConfiguration();
configuration.setProperty(PROP_PATCHER, this);
- configuration.setProperty(IHunkFilter.HUNK_FILTER_PROPERTY, this);
+ configuration.addHunkFilter(this);
}
/*
@@ -165,7 +164,7 @@ public class Patcher implements IHunkFilter {
//---- parsing patch files
public void parse(IStorage storage) throws IOException, CoreException {
- BufferedReader reader = LineReader.createReader(storage);
+ BufferedReader reader = Utilities.createReader(storage);
try {
parse(reader);
} finally {
@@ -193,8 +192,8 @@ public class Patcher implements IHunkFilter {
int removedLines = 0;
FileDiff fileDiff = fileDiffs[i];
for (int j = 0; j < fileDiff.getHunkCount(); j++) {
- Hunk hunk = fileDiff.getHunks()[j];
- String[] lines = hunk.getLines();
+ IHunk hunk = fileDiff.getHunks()[j];
+ String[] lines = ((Hunk) hunk).getLines();
for (int k = 0; k < lines.length; k++) {
char c = lines[k].charAt(0);
switch (c) {
@@ -518,9 +517,9 @@ public class Patcher implements IHunkFilter {
}
private void setEnabledFile(FileDiff fileDiff, boolean enabled) {
- Hunk[] hunks = fileDiff.getHunks();
+ IHunk[] hunks = fileDiff.getHunks();
for (int i = 0; i < hunks.length; i++) {
- setEnabledHunk(hunks[i], enabled);
+ setEnabledHunk((Hunk) hunks[i], enabled);
}
}
@@ -731,7 +730,7 @@ public class Patcher implements IHunkFilter {
public IProject getTargetProject(FileDiff diff) {
DiffProject dp = getProject(diff);
if (dp != null)
- return dp.getProject();
+ return Utilities.getProject(dp);
IResource tr = getTarget();
if (tr instanceof IWorkspaceRoot) {
IWorkspaceRoot root = (IWorkspaceRoot) tr;
@@ -753,7 +752,7 @@ public class Patcher implements IHunkFilter {
return false;
}
- public boolean select(Hunk hunk) {
+ public boolean select(IHunk hunk) {
return isEnabled(hunk);
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
index 4ca0638b8..49db581a9 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -21,6 +21,7 @@ import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.ICompareUIConstants;
import org.eclipse.compare.internal.core.patch.FileDiff;
import org.eclipse.compare.internal.core.patch.Hunk;
+import org.eclipse.compare.patch.IHunk;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -94,6 +95,7 @@ public class PreviewPatchPage2 extends WizardPage {
private IDialogSettings settings;
private ExpandableComposite patchOptions;
private Button generateRejects;
+ private FormToolkit toolkit;
public PreviewPatchPage2(WorkspacePatcher patcher, CompareConfiguration configuration) {
super(PREVIEWPATCHPAGE_NAME, PatchMessages.PreviewPatchPage_title, null);
@@ -112,7 +114,7 @@ public class PreviewPatchPage2 extends WizardPage {
}
public void createControl(Composite parent) {
- FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+ toolkit = new FormToolkit(parent.getDisplay());
toolkit.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
final ScrolledForm form = toolkit.createScrolledForm(parent);
@@ -716,9 +718,9 @@ public class PreviewPatchPage2 extends WizardPage {
FileDiff[] fileDiffs = fPatcher.getDiffs();
for (int i = 0; i < fileDiffs.length; i++) {
- Hunk[] hunks = fileDiffs[i].getHunks();
+ IHunk[] hunks = fileDiffs[i].getHunks();
for (int j = 0; j < hunks.length; j++) {
- String[] lines = hunks[j].getLines();
+ String[] lines = ((Hunk) hunks[j]).getLines();
for (int k = 0; k < lines.length; k++) {
String line = lines[k];
if (addedPattern.matcher(line).find())
@@ -734,5 +736,8 @@ public class PreviewPatchPage2 extends WizardPage {
new String[] { added + "", removed + "" }); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+ public void dispose() {
+ toolkit.dispose();
+ super.dispose();
+ }
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java
index 8ec175c90..3a515616f 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -135,7 +135,7 @@ class RetargetPatchElementDialog extends Dialog {
} else if (fSelectedNode instanceof PatchProjectDiffNode) {
PatchProjectDiffNode node = (PatchProjectDiffNode) fSelectedNode;
DiffProject diffProject = node.getDiffProject();
- return diffProject.getProject();
+ return Utilities.getProject(diffProject);
}
return null;
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java
index 1588fb9b3..e0e33b62e 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -23,7 +23,6 @@ import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.ContentChangeNotifier;
import org.eclipse.compare.internal.core.patch.FileDiff;
import org.eclipse.compare.internal.core.patch.HunkResult;
-import org.eclipse.compare.internal.core.patch.LineReader;
import org.eclipse.compare.patch.PatchConfiguration;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
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
new file mode 100644
index 000000000..a1b57001f
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Utilities.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 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.patch;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+
+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.IProject;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+public class Utilities {
+
+ public static String getCharset(Object resource) {
+ if (resource instanceof IEncodedStorage) {
+ try {
+ return ((IEncodedStorage) resource).getCharset();
+ } catch (CoreException ex) {
+ CompareUIPlugin.log(ex);
+ }
+ }
+ return ResourcesPlugin.getEncoding();
+ }
+
+ public static IProject getProject(DiffProject diffProject) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(
+ diffProject.getName());
+ }
+
+ public static ReaderCreator getReaderCreator(final IStorage storage){
+ return new ReaderCreator(){
+ public Reader createReader() throws CoreException {
+ return Utilities.createReader(storage);
+ }
+ };
+ }
+
+ public static BufferedReader createReader(IStorage storage)
+ throws CoreException {
+ String charset = null;
+ if (storage instanceof IEncodedStorage) {
+ IEncodedStorage es = (IEncodedStorage) storage;
+ charset = es.getCharset();
+ }
+ InputStreamReader in = null;
+ if (charset != null) {
+ InputStream contents = storage.getContents();
+ try {
+ in = new InputStreamReader(contents, charset);
+ } catch (UnsupportedEncodingException e) {
+ CompareUIPlugin.log(e);
+ try {
+ contents.close();
+ } catch (IOException e1) {
+ // Ignore
+ }
+ }
+ }
+ if (in == null) {
+ in = new InputStreamReader(storage.getContents());
+ }
+ return new BufferedReader(in);
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java
index dd816ae61..abaaa48cb 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -14,7 +14,6 @@ import java.util.List;
import org.eclipse.compare.internal.core.patch.FileDiff;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
-import org.eclipse.compare.internal.core.patch.LineReader;
import org.eclipse.compare.patch.PatchConfiguration;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -52,7 +51,6 @@ public class WorkspaceFileDiffResult extends FileDiffResult {
}
public void refresh() {
- refresh(getTargetFile(), null);
+ refresh(Utilities.getReaderCreator(getTargetFile()), null);
}
-
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java
index 84ff8deb4..4bed69672 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.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
@@ -20,8 +20,8 @@ import org.eclipse.compare.internal.core.Messages;
import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.internal.core.patch.FileDiff;
import org.eclipse.compare.internal.core.patch.Hunk;
-import org.eclipse.compare.internal.core.patch.LineReader;
import org.eclipse.compare.internal.core.patch.PatchReader;
+import org.eclipse.compare.patch.IHunk;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -83,7 +83,7 @@ public class WorkspacePatcher extends Patcher {
List list= new ArrayList();
for (int j= 0; j < fDiffProjects.length; j++) {
DiffProject diffProject= fDiffProjects[j];
- if (diffProject.getProject().isAccessible())
+ if (Utilities.getProject(diffProject).isAccessible())
list.addAll(Arrays.asList(getTargetFiles(diffProject)));
}
// validate the files for editing
@@ -165,7 +165,7 @@ public class WorkspacePatcher extends Patcher {
}
private boolean isAccessible(FileDiff diff) {
- return isEnabled(diff) && diff.getProject().getProject().isAccessible();
+ return isEnabled(diff) && Utilities.getProject(diff.getProject()).isAccessible();
}
/**
@@ -190,7 +190,7 @@ public class WorkspacePatcher extends Patcher {
IPath path = diff.getStrippedPath(getStripPrefixSegments(), isReversed());
DiffProject project = getProject(diff);
if (project != null)
- return project.getFile(path);
+ return Utilities.getProject(project).getFile(path);
return super.getTargetFile(diff);
}
@@ -198,7 +198,7 @@ public class WorkspacePatcher extends Patcher {
IPath path = diff.getStrippedPath(getStripPrefixSegments(), isReversed());
DiffProject project = getProject(diff);
if (project != null)
- return project.getFile(path).getFullPath();
+ return Utilities.getProject(project).getFile(path).getFullPath();
return getTarget().getFullPath().append(path);
}
@@ -207,7 +207,7 @@ public class WorkspacePatcher extends Patcher {
IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
// Determine the appropriate scheduling rules
for (int i= 0; i < fDiffProjects.length; i++) {
- IProject tempProject= fDiffProjects[i].getProject();
+ IProject tempProject= Utilities.getProject(fDiffProjects[i]);
// The goal here is to lock as little of the workspace as necessary
// but still allow the patcher to obtain the locks it needs.
// As such, we need to get the modify rules from the rule factory for the .project file. A pessimistic
@@ -259,7 +259,7 @@ public class WorkspacePatcher extends Patcher {
public void retargetDiff(FileDiff diff, IFile file) {
retargetedDiffs.put(diff, diff.getPath(false));
- Hunk[] hunks = diff.getHunks();
+ IHunk[] hunks = diff.getHunks();
if (isWorkspacePatch()){
//since the diff has no more hunks to apply, remove it from the parent and the patcher
@@ -268,7 +268,7 @@ public class WorkspacePatcher extends Patcher {
removeDiff(diff);
FileDiff newDiff = getDiffForFile(file);
for (int i = 0; i < hunks.length; i++) {
- Hunk hunk = hunks[i];
+ Hunk hunk = (Hunk) hunks[i];
newDiff.add(hunk);
}
}
@@ -281,7 +281,7 @@ public class WorkspacePatcher extends Patcher {
IProject project = file.getProject();
DiffProject[] diffProjects = getDiffProjects();
for (int i = 0; i < diffProjects.length; i++) {
- if (diffProjects[i].getProject().equals(project)){
+ if (Utilities.getProject(diffProjects[i]).equals(project)){
diffProject = diffProjects[i];
break;
}
@@ -326,7 +326,7 @@ public class WorkspacePatcher extends Patcher {
private DiffProject addDiffProjectForProject(IProject project) {
DiffProject[] diffProjects = getDiffProjects();
- DiffProject diffProject = new DiffProject(project);
+ DiffProject diffProject = new DiffProject(project.getName());
DiffProject[] newProjectArray = new DiffProject[diffProjects.length + 1];
System.arraycopy(diffProjects, 0, newProjectArray, 0, diffProjects.length);
newProjectArray[diffProjects.length] = diffProject;
@@ -340,7 +340,7 @@ public class WorkspacePatcher extends Patcher {
}
public void retargetProject(DiffProject project, IProject targetProject) {
- retargetedDiffs.put(project, project.getProject().getFullPath());
+ retargetedDiffs.put(project, Utilities.getProject(project).getFullPath());
FileDiff[] diffs = project.getFileDiffs();
DiffProject selectedProject = getDiffProject(targetProject);
if (selectedProject == null)
@@ -366,7 +366,7 @@ public class WorkspacePatcher extends Patcher {
return null;
DiffProject[] projects = getDiffProjects();
for (int i = 0; i < projects.length; i++) {
- if (projects[i].getProject().equals(project))
+ if (Utilities.getProject(projects[i]).equals(project))
return projects[i];
}
return null;
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java
index 13447df03..470d54499 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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,16 +10,25 @@
*******************************************************************************/
package org.eclipse.compare.patch;
+import java.io.BufferedReader;
+import java.io.IOException;
+
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.internal.ComparePreferencePage;
import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.core.patch.FileDiff;
+import org.eclipse.compare.internal.core.patch.PatchReader;
+import org.eclipse.compare.internal.patch.FileDiffWrapper;
import org.eclipse.compare.internal.patch.PatchWizard;
import org.eclipse.compare.internal.patch.PatchWizardDialog;
+import org.eclipse.compare.internal.patch.Utilities;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
@@ -76,7 +85,7 @@ public class ApplyPatchOperation implements Runnable {
* @throws CoreException if an error occurs reading the contents from the storage
*/
public static boolean isPatch(IStorage storage) throws CoreException {
- return PatchParser.parsePatch(storage).length > 0;
+ return internalParsePatch(storage).length > 0;
}
/**
@@ -86,7 +95,7 @@ public class ApplyPatchOperation implements Runnable {
* @throws CoreException if an error occurs reading the contents from the storage
*/
public static IFilePatch[] parsePatch(IStorage storage) throws CoreException {
- return PatchParser.parsePatch(storage);
+ return internalParsePatch(storage);
}
/**
@@ -131,7 +140,6 @@ public class ApplyPatchOperation implements Runnable {
* This method must be called from the UI thread.
*/
public void openWizard() {
-
saveAllEditors();
if (saveAllEditors) {
@@ -192,4 +200,30 @@ public class ApplyPatchOperation implements Runnable {
openWizard();
}
+ private static IFilePatch[] internalParsePatch(IStorage storage)
+ throws CoreException {
+ BufferedReader reader = Utilities.createReader(storage);
+ try {
+ PatchReader patchReader = new PatchReader();
+ patchReader.parse(reader);
+ FileDiff[] fileDiffs = patchReader.getAdjustedDiffs();
+
+ IFilePatch[] filePatch = new IFilePatch[fileDiffs.length];
+ for (int i = 0; i < fileDiffs.length; i++) {
+ filePatch[i] = new FileDiffWrapper(fileDiffs[i]);
+ }
+
+ return filePatch;
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ CompareUIPlugin.PLUGIN_ID, 0, e.getMessage(), e));
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) { // ignored
+ }
+ }
+ }
+
+
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/IFilePatch.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/IFilePatch.java
new file mode 100644
index 000000000..f1377392e
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/patch/IFilePatch.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 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.patch;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * A representation of a file patch that can be applied to an input stream.
+ *
+ * @see ApplyPatchOperation#parsePatch(org.eclipse.core.resources.IStorage)
+ * @since 3.3
+ * @noimplement This interface is not intended to be implemented by clients.
+ * Clients can obtain file patches by calling
+ * {@link ApplyPatchOperation#parsePatch(org.eclipse.core.resources.IStorage)}.
+ */
+public interface IFilePatch extends IFilePatch2 {
+
+ /**
+ * Special constant that will be returned from get getBeforeDate() or
+ * getAfterDate() if the date is unknown. Equal to Midnight, Jan 1, 1970
+ * GMT.
+ *
+ * @since 3.4
+ */
+ public static long DATE_UNKNOWN = 0;
+
+ /**
+ * Return the target path for this patch. The target path may differ
+ * depending on whether the patch is being reversed or not.
+ *
+ * @param configuration the patch configuration
+ * @return the target path for this patch
+ * @see PatchConfiguration#isReversed()
+ */
+ public IPath getTargetPath(PatchConfiguration configuration);
+
+ /**
+ * Apply this patch to the given file contents. The result provides the
+ * original and patch contents and also indicates whether some portions of
+ * the patch (called hunks) failed to apply.
+ *
+ * @param contents the file contents
+ * @param configuration the patch configuration
+ * @param monitor a progress monitor
+ * @return the result of the patch application
+ */
+ public IFilePatchResult apply(IStorage contents,
+ PatchConfiguration configuration, IProgressMonitor monitor);
+
+ /**
+ * Return the header information of the patch or
+ * <code>null</code> if there was no header text.
+ * The header may be multi-line.
+ * @return the header information of the patch or
+ * <code>null</code>
+ */
+ public String getHeader();
+
+ /**
+ * Returns the milliseconds time value of the before date from the patch, or
+ * DATE_UNKNOWN if the date is unknown.
+ *
+ * @return milliseconds time value of the before date from the patch
+ * @since 3.4
+ */
+ public long getBeforeDate();
+
+ /**
+ * Returns the milliseconds time value of the after date from the patch, or
+ * DATE_UNKNOWN if the date is unknown.
+ *
+ * @return milliseconds time value of the after date from the patch
+ * @since 3.4
+ */
+ public long getAfterDate();
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
index ea0b2b750..4b8700659 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java
@@ -98,10 +98,7 @@ public class StructureDiffViewer extends DiffTreeViewer {
((IContentChangeNotifier)fInput).removeContentChangeListener(fContentChangedListener);
fInput= newInput;
if (fInput == null) {
- if (fStructureComparator instanceof IDisposable) {
- IDisposable disposable = (IDisposable) fStructureComparator;
- disposable.dispose();
- }
+ dispose(); // destroy fStructureComparator
fStructureComparator= null;
} else {
refresh(monitor);

Back to the top