diff options
author | Andrey Loskutov | 2016-11-04 17:37:48 +0000 |
---|---|---|
committer | Andrey Loskutov | 2016-11-04 20:18:45 +0000 |
commit | bf7292ed40eab1e600437a7521a99864c98299ad (patch) | |
tree | f44347b408186df22740428859a2bbb4e29588a1 /bundles/org.eclipse.compare/compare/org/eclipse/compare/internal | |
parent | f60954ba88fb4b106af2fd6056f69c93a54110b6 (diff) | |
download | eclipse.platform.team-bf7292ed40eab1e600437a7521a99864c98299ad.tar.gz eclipse.platform.team-bf7292ed40eab1e600437a7521a99864c98299ad.tar.xz eclipse.platform.team-bf7292ed40eab1e600437a7521a99864c98299ad.zip |
Bug 506732 - cleanup trailing spaces in compare pluginsY20161117-1000Y20161110-1000I20161122-2000I20161121-2000I20161120-2000I20161119-2000I20161118-2000I20161117-2000I20161116-2000I20161115-2000I20161114-2000I20161114-0355I20161113-2000I20161112-2000I20161112-0405I20161111-2000I20161111-1220I20161111-0900I20161111-0740I20161111-0510I20161110-2030I20161110-1630I20161110-1225I20161110-1130I20161110-0710I20161110-0510I20161109-2000I20161108-1015I20161108-0800
Change-Id: I2ed3512c294b06e85a63fab90a0934e611339e31
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'bundles/org.eclipse.compare/compare/org/eclipse/compare/internal')
77 files changed, 1156 insertions, 1156 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java index 95a739ea0..24f7ea9df 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AbstractViewer.java @@ -21,19 +21,19 @@ public abstract class AbstractViewer extends Viewer { public void setInput(Object input) { // empty default implementation } - + public Object getInput() { return null; } - + public ISelection getSelection() { return StructuredSelection.EMPTY; } - + public void setSelection(ISelection s, boolean reveal) { // empty default implementation } - + public void refresh() { // empty default implementation } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java index 1ee887caa..3215be92f 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java @@ -25,33 +25,33 @@ import org.eclipse.core.runtime.*; public class AddFromHistoryAction extends BaseCompareAction { - + private static final String BUNDLE_NAME= "org.eclipse.compare.internal.AddFromHistoryAction"; //$NON-NLS-1$ public AddFromHistoryAction() { // empty default implementation } - + protected boolean isEnabled(ISelection selection) { return Utilities.getResources(selection).length == 1; } protected void run(ISelection selection) { - + ResourceBundle bundle= ResourceBundle.getBundle(BUNDLE_NAME); String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$ - + Shell parentShell= CompareUIPlugin.getShell(); AddFromHistoryDialog dialog= null; Object[] s= Utilities.getResources(selection); - + for (int i= 0; i < s.length; i++) { Object o= s[i]; if (o instanceof IContainer) { IContainer container= (IContainer) o; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell); + + ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell); IProgressMonitor pm= pmdialog.getProgressMonitor(); IFile[] states= null; try { @@ -59,24 +59,24 @@ public class AddFromHistoryAction extends BaseCompareAction { } catch (CoreException ex) { pm.done(); } - + // There could be a recently deleted file at the same path as // the container. If such a file is the only one to restore, we // should not suggest to restore it, so set states to null. if (states.length == 1 && states[0].getFullPath().equals(container.getFullPath())) states = null; - + if (states == null || states.length <= 0) { String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$ MessageDialog.openInformation(parentShell, title, msg); return; } - + if (dialog == null) { dialog= new AddFromHistoryDialog(parentShell, bundle); dialog.setHelpContextId(ICompareContextIds.ADD_FROM_HISTORY_DIALOG); } - + if (dialog.select(container, states)) { AddFromHistoryDialog.HistoryInput[] selected = dialog .getSelected(); @@ -96,7 +96,7 @@ public class AddFromHistoryAction extends BaseCompareAction { } } } - + void createContainers(IResource resource) throws CoreException { IContainer container= resource.getParent(); if (container instanceof IFolder) { @@ -107,22 +107,22 @@ public class AddFromHistoryAction extends BaseCompareAction { } } } - + private void updateWorkspace(final ResourceBundle bundle, Shell shell, final AddFromHistoryDialog.HistoryInput[] selected) throws InvocationTargetException, InterruptedException { - + WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { public void execute(IProgressMonitor pm) throws InvocationTargetException { try { String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$ pm.beginTask(taskName, selected.length); - + for (int i= 0; i < selected.length; i++) { IFile file= selected[i].fFile; IFileState fileState= selected[i].fFileState; createContainers(file); - + SubProgressMonitor subMonitor= new SubProgressMonitor(pm, 1); try { file.create(fileState.getContents(), false, subMonitor); @@ -137,8 +137,8 @@ public class AddFromHistoryAction extends BaseCompareAction { } } }; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); - pmdialog.run(false, true, operation); + + ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); + pmdialog.run(false, true, operation); } } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java index 7be81d377..beaff9d30 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BaseCompareAction.java @@ -18,7 +18,7 @@ import org.eclipse.ui.IActionDelegate; public abstract class BaseCompareAction implements IActionDelegate { private ISelection fSelection; - + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @@ -34,10 +34,10 @@ public abstract class BaseCompareAction implements IActionDelegate { if (action != null) action.setEnabled(isEnabled(fSelection)); } - + protected boolean isEnabled(ISelection selection) { return false; } - + abstract protected void run(ISelection selection); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java index 54becc37b..c730b9768 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java @@ -37,7 +37,7 @@ import com.ibm.icu.text.MessageFormat; public class BinaryCompareViewer extends AbstractViewer { private static final String BUNDLE_NAME = "org.eclipse.compare.internal.BinaryCompareViewerResources"; //$NON-NLS-1$ - + private static final int EOF = -1; private ICompareInput fInput; private ResourceBundle fBundle; @@ -45,13 +45,13 @@ public class BinaryCompareViewer extends AbstractViewer { private Composite fComposite; private Label fMessage; private CompareConfiguration compareConfiguration; - + public BinaryCompareViewer(Composite parent, final CompareConfiguration cc) { - + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.BINARY_COMPARE_VIEW); fBundle= ResourceBundle.getBundle(BUNDLE_NAME); - + fComposite= new Composite(parent, SWT.NONE); RowLayout rowLayout = new RowLayout(); rowLayout.type = SWT.VERTICAL; @@ -59,7 +59,7 @@ public class BinaryCompareViewer extends AbstractViewer { fMessage= new Label(fComposite, SWT.WRAP); fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$ - + compareConfiguration = cc != null ? cc : new CompareConfiguration(); if (compareConfiguration.getContainer() instanceof CompareEditorInput) { @@ -80,12 +80,12 @@ public class BinaryCompareViewer extends AbstractViewer { InputStream left= null; InputStream right= null; - + String message= null; try { left= getStream(fInput.getLeft()); right= getStream(fInput.getRight()); - + if (left != null && right != null) { int pos= 0; while (true) { diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java index 2b3da3a4e..aea48782b 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedCanvas.java @@ -22,7 +22,7 @@ public abstract class BufferedCanvas extends Canvas { //private static final boolean USE_DOUBLE_BUFFER= !"carbon".equals(SWT.getPlatform()); //$NON-NLS-1$ private static final boolean USE_DOUBLE_BUFFER= true; - + /** The drawable for double buffering */ Image fBuffer; @@ -61,7 +61,7 @@ public abstract class BufferedCanvas extends Canvas { * Double buffer drawing. */ void doubleBufferPaint(GC dest) { - + if (!USE_DOUBLE_BUFFER) { doPaint(dest); return; diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java index cf9afd304..582aa099d 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java @@ -21,10 +21,10 @@ import org.eclipse.compare.structuremergeviewer.IStructureComparator; * A buffer for a workspace resource. */ public class BufferedResourceNode extends ResourceNode { - + private boolean fDirty= false; private IFile fDeleteFile; - + /** * Creates a <code>ResourceNode</code> for the given resource. * @@ -33,34 +33,34 @@ public class BufferedResourceNode extends ResourceNode { public BufferedResourceNode(IResource resource) { super(resource); } - + /* * Returns <code>true</code> if buffer contains uncommitted changes. */ public boolean isDirty() { return fDirty; } - + protected IStructureComparator createChild(IResource child) { return new BufferedResourceNode(child); } - + public void setContent(byte[] contents) { fDirty= true; super.setContent(contents); - } + } /* * Commits buffered contents to resource. */ public void commit(IProgressMonitor pm) throws CoreException { if (fDirty) { - + if (fDeleteFile != null) { fDeleteFile.delete(true, true, pm); return; } - + IResource resource= getResource(); if (resource instanceof IFile) { @@ -84,9 +84,9 @@ public class BufferedResourceNode extends ResourceNode { } } } - + public ITypedElement replace(ITypedElement child, ITypedElement other) { - + if (child == null) { // add resource // create a node without a resource behind it! IResource resource= getResource(); @@ -96,7 +96,7 @@ public class BufferedResourceNode extends ResourceNode { child= new BufferedResourceNode(file); } } - + if (other == null) { // delete resource IResource resource= getResource(); if (resource instanceof IFolder) { @@ -109,10 +109,10 @@ public class BufferedResourceNode extends ResourceNode { } return null; } - + if (other instanceof IStreamContentAccessor && child instanceof IEditableContent) { IEditableContent dst= (IEditableContent) child; - + try { InputStream is= ((IStreamContentAccessor)other).getContents(); byte[] bytes= Utilities.readBytes(is); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java index 7efc7b371..bdea732b0 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java @@ -56,7 +56,7 @@ public class ChangePropertyAction extends Action implements IPropertyChangeListe super.setChecked(state); Utilities.initToggleAction(this, fBundle, fPrefix, state); } - + public void setCompareConfiguration(CompareConfiguration cc) { if (fCompareConfiguration != null) fCompareConfiguration.removePropertyChangeListener(this); @@ -71,12 +71,12 @@ public class ChangePropertyAction extends Action implements IPropertyChangeListe setChecked(Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false)); } } - + public void dispose(){ if (fCompareConfiguration != null) fCompareConfiguration.removePropertyChangeListener(this); } - + public void widgetDisposed(DisposeEvent e) { dispose(); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java index b9a557f3c..54c30e356 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java @@ -50,10 +50,10 @@ public class CompareAction extends BaseCompareAction implements IObjectActionDel // buffered merge mode: don't ask for confirmation // when switching between modified resources cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, Boolean.FALSE); - + // uncomment following line to have separate outline view //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, Boolean.TRUE); - + fInput= new ResourceCompareInput(cc); } return fInput.isEnabled(selection); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java index ba9ea7baa..59c19608d 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java @@ -23,7 +23,7 @@ import org.eclipse.ui.*; import org.eclipse.ui.services.IServiceLocator; public class CompareContainer implements ICompareContainer { - + private WorkerJob worker; /* (non-Javadoc) @@ -32,7 +32,7 @@ public class CompareContainer implements ICompareContainer { public void setStatusMessage(String message) { // Do nothing, by default } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareContainer#addCompareInputChangeListener(org.eclipse.compare.structuremergeviewer.ICompareInput, org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener) */ @@ -40,7 +40,7 @@ public class CompareContainer implements ICompareContainer { ICompareInputChangeListener listener) { input.addCompareInputChangeListener(listener); } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareContainer#removeCompareInputChangeListener(org.eclipse.compare.structuremergeviewer.ICompareInput, org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener) */ @@ -48,7 +48,7 @@ public class CompareContainer implements ICompareContainer { ICompareInputChangeListener listener) { input.removeCompareInputChangeListener(listener); } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareContainer#registerContextMenu(org.eclipse.jface.action.MenuManager, org.eclipse.jface.viewers.ISelectionProvider) */ @@ -56,14 +56,14 @@ public class CompareContainer implements ICompareContainer { ISelectionProvider selectionProvider) { // Nothing to do } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareContainer#getServiceLocator() */ public IServiceLocator getServiceLocator() { return null; } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareContainer#getActionBars() */ @@ -79,7 +79,7 @@ public class CompareContainer implements ICompareContainer { throws InvocationTargetException, InterruptedException { PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable); } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareContainer#getNavigator() */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java index cf303c42d..aff33c041 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java @@ -36,19 +36,19 @@ import org.eclipse.ui.PlatformUI; * This is a dialog that can host a {@link CompareEditorInput}. * <p> * This class can be used as is or can be subclassed. - * + * * @since 3.3 */ public class CompareDialog extends TrayDialog implements IPropertyChangeListener { - + private final CompareEditorInput fCompareEditorInput; private Button fCommitButton; private Label statusLabel; boolean hasSettings = true; private final DialogCompareContainer fContainer = new DialogCompareContainer(); - + private class DialogCompareContainer extends CompareContainer { - + /* (non-Javadoc) * @see org.eclipse.jface.operation.IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress) */ @@ -58,7 +58,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.run(fork, cancelable, runnable); } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareContainer#setStatusMessage(java.lang.String) */ @@ -72,7 +72,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener } } } - + /** * Create a dialog to host the given input. * @param shell a shell @@ -84,7 +84,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener Assert.isNotNull(input); fCompareEditorInput= input; } - + /* (non-Javadoc) * @see org.eclipse.compare.internal.ResizableDialog#close() */ @@ -96,7 +96,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener } return false; } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ @@ -134,7 +134,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener * @see CompareConfiguration#isRightEditable() */ protected boolean isInputEditable() { - return fCompareEditorInput.getCompareConfiguration().isLeftEditable() + return fCompareEditorInput.getCompareConfiguration().isLeftEditable() || fCompareEditorInput.getCompareConfiguration().isRightEditable(); } @@ -160,7 +160,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener return getSelectedElement() != null; return true; } - + private Object getSelectedElement() { return fCompareEditorInput.getSelectedEdition(); } @@ -169,22 +169,22 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ protected Control createDialogArea(Composite parent2) { - + Composite parent= (Composite) super.createDialogArea(parent2); Control c= fCompareEditorInput.createContents(parent); c.setLayoutData(new GridData(GridData.FILL_BOTH)); - + statusLabel = new Label(parent, SWT.NONE); statusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - + Shell shell= c.getShell(); shell.setText(fCompareEditorInput.getTitle()); shell.setImage(fCompareEditorInput.getTitleImage()); applyDialogFont(parent); return parent; } - + /* (non-Javadoc) * @see org.eclipse.jface.window.Window#open() */ @@ -195,7 +195,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener fCompareEditorInput.setContainer(fContainer); return super.open(); } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) */ @@ -222,7 +222,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener } return dialogSettings; } - + /* (non-Javadoc) * @see org.eclipse.compare.internal.ResizableDialog#configureShell(org.eclipse.swt.widgets.Shell) */ @@ -241,7 +241,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener public String getHelpContextId() { return ICompareContextIds.COMPARE_DIALOG; } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() */ @@ -255,7 +255,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener /** * If we don't have settings we need to come up with a reasonable default - * since we can't depend on the compare editor input layout returning a + * since we can't depend on the compare editor input layout returning a * good default size. * @return the default size of the dialog */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java index 10de7cef5..2c8fe0ede 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java @@ -34,7 +34,7 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; public class CompareEditorContributor extends EditorActionBarContributor { - + public final static String FILTER_SEPARATOR = "compare.filters"; //$NON-NLS-1$ public final static String BUILTIN_SEPARATOR = "compare.builtin"; //$NON-NLS-1$ @@ -43,27 +43,27 @@ public class CompareEditorContributor extends EditorActionBarContributor { private ChangePropertyAction fIgnoreWhitespace; private NavigationAction fNext; private NavigationAction fPrevious; - + private NavigationAction fToolbarNext; private NavigationAction fToolbarPrevious; public CompareEditorContributor() { ResourceBundle bundle= CompareUI.getResourceBundle(); - + IWorkbenchHelpSystem helpSystem= PlatformUI.getWorkbench().getHelpSystem(); - + fIgnoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(bundle, null); helpSystem.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION); - + fNext= new NavigationAction(bundle, true); helpSystem.setHelp(fNext, ICompareContextIds.GLOBAL_NEXT_DIFF_ACTION); - + fPrevious= new NavigationAction(bundle, false); helpSystem.setHelp(fPrevious, ICompareContextIds.GLOBAL_PREVIOUS_DIFF_ACTION); - + fToolbarNext= new NavigationAction(bundle, true); helpSystem.setHelp(fToolbarNext, ICompareContextIds.NEXT_DIFF_ACTION); - + fToolbarPrevious= new NavigationAction(bundle, false); helpSystem.setHelp(fToolbarPrevious, ICompareContextIds.PREVIOUS_DIFF_ACTION); } @@ -78,7 +78,7 @@ public class CompareEditorContributor extends EditorActionBarContributor { tbm.appendToGroup(BUILTIN_SEPARATOR, fToolbarNext); tbm.appendToGroup(BUILTIN_SEPARATOR, fToolbarPrevious); } - + /* * @see EditorActionBarContributor#contributeToMenu(IMenuManager) */ @@ -87,12 +87,12 @@ public class CompareEditorContributor extends EditorActionBarContributor { } public void setActiveEditor(IEditorPart targetEditor) { - + if (fActiveEditorPart == targetEditor) return; - + fActiveEditorPart= targetEditor; - + if (fActiveEditorPart != null) { IEditorInput input= fActiveEditorPart.getEditorInput(); if (input instanceof CompareEditorInput) { @@ -105,19 +105,19 @@ public class CompareEditorContributor extends EditorActionBarContributor { // End fix http://bugs.eclipse.org/bugs/show_bug.cgi?id=20105 } } - + if (targetEditor instanceof CompareEditor) { IActionBars actionBars= getActionBars(); - + CompareEditor editor= (CompareEditor) targetEditor; editor.setActionBars(actionBars); - + actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNext); actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPrevious); actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNext); actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPrevious); - + CompareConfiguration cc= editor.getCompareConfiguration(); fIgnoreWhitespace.setCompareConfiguration(cc); @@ -181,7 +181,7 @@ public class CompareEditorContributor extends EditorActionBarContributor { actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, null); } } - + public void dispose() { setActiveEditor(null); super.dispose(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java index 5a4162591..07c8c9e3f 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java @@ -25,7 +25,7 @@ public class CompareEditorInputNavigator extends CompareNavigator { // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 private boolean fNextFirstTime= true; private Object[] fPanes; - + /** * Create a navigator for navigating the given panes * @param panes the panes to navigate. @@ -33,7 +33,7 @@ public class CompareEditorInputNavigator extends CompareNavigator { public CompareEditorInputNavigator(Object[] panes) { fPanes= panes; } - + /** * Return the set of panes that this navigator is navigating. * The {@link INavigatable} is obtain from each pane using the @@ -43,7 +43,7 @@ public class CompareEditorInputNavigator extends CompareNavigator { public Object[] getPanes() { return fPanes; } - + protected INavigatable[] getNavigatables() { List result = new ArrayList(); Object[] panes = getPanes(); @@ -55,7 +55,7 @@ public class CompareEditorInputNavigator extends CompareNavigator { } return (INavigatable[]) result.toArray(new INavigatable[result.size()]); } - + /* (non-Javadoc) * @see org.eclipse.compare.ICompareNavigator#selectChange(boolean) */ @@ -68,7 +68,7 @@ public class CompareEditorInputNavigator extends CompareNavigator { } return super.selectChange(next); } - + /* * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 */ @@ -84,7 +84,7 @@ public class CompareEditorInputNavigator extends CompareNavigator { } return true; } - + /* * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java index 7f45f1e3f..1d71169d7 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java @@ -33,7 +33,7 @@ import org.eclipse.jface.text.TextViewer; /** * A selection provider for view parts with more that one viewer. Tracks the * focus of the viewers to provide the correct selection. - * + * * This is a modified version of * org.eclipse.jdt.internal.ui.viewsupport.SelectionProviderMediator */ @@ -82,7 +82,7 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider { fPostSelectionChangedListeners = new ListenerList(); // nothing more to do here, Compare Editor is initializing } - + /** * @param viewers All viewers that can provide a selection * @param viewerInFocus the viewer currently in focus or <code>null</code> @@ -92,7 +92,7 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider { fViewers= viewers; InternalListener listener= new InternalListener(); fViewerInFocus= viewerInFocus; - + for (int i= 0; i < fViewers.length; i++) { TextViewer viewer= fViewers[i]; viewer.addSelectionChangedListener(listener); @@ -110,7 +110,7 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider { } } } - + final void doPostSelectionChanged(SelectionChangedEvent event) { ISelectionProvider provider= event.getSelectionProvider(); if (provider == fViewerInFocus) { @@ -213,7 +213,7 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider { /** * Resets the visible region for all text viewers of this selection provider. - * + * * @since 3.6 */ private void resetVisibleRegion() { @@ -226,7 +226,7 @@ public class CompareEditorSelectionProvider implements IPostSelectionProvider { /** * Tells whether the given selection is inside the text viewer's visible region. - * + * * @param textViewer the text viewer * @param selection the selection * @return <code>true</code> if the selection is inside the text viewer's visible region diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java index a3b4d4fcc..085ebd839 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java @@ -24,7 +24,7 @@ import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.services.IServiceLocator; public class CompareHandlerService { - + private final List fActivations = new ArrayList(); private final Expression fExpression; private ICompareContainer fContainer; @@ -49,14 +49,14 @@ public class CompareHandlerService { } return new CompareHandlerService(null, null); } - + private CompareHandlerService(ICompareContainer container, Expression expression) { fContainer = container; fExpression = expression; initialize(); } - + public void registerAction(IAction action, String commandId) { IHandlerService handlerService = getHandlerService(); if (handlerService == null) @@ -72,7 +72,7 @@ public class CompareHandlerService { fActivations .add(activation); } } - + private IHandlerService getHandlerService() { if (fDisposed) return null; @@ -114,7 +114,7 @@ public class CompareHandlerService { if (actionHandler != null) actionHandler.setActionDefinitionId(null); } - + private void updateActionBars() { IActionBars bars = getActionBars(); if (bars != null) @@ -130,7 +130,7 @@ public class CompareHandlerService { } } } - + private IActionBars getActionBars() { return fContainer.getActionBars(); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java index dafaef4f3..cfbfe4330 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java @@ -33,7 +33,7 @@ public class CompareOutlinePage extends Page implements IContentOutlinePage, IPr private Control fControl; private CompareViewerSwitchingPane fStructurePane; private OutlineViewerCreator fCreator; - + CompareOutlinePage(CompareEditor editor) { fCompareEditor= editor; } @@ -56,7 +56,7 @@ public class CompareOutlinePage extends Page implements IContentOutlinePage, IPr h.layout(); reset(); } - + private Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent) { OutlineViewerCreator creator = getCreator(); if (creator != null) @@ -103,7 +103,7 @@ public class CompareOutlinePage extends Page implements IContentOutlinePage, IPr if (fStructurePane != null) fStructurePane.setSelection(selection); } - + private void setInput(Object input) { if (fStructurePane != null) { fStructurePane.setInput(input); @@ -127,7 +127,7 @@ public class CompareOutlinePage extends Page implements IContentOutlinePage, IPr ((Splitter)fControl).layout(); } } - + @Override public void dispose() { super.dispose(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java index cd262b46e..ec37c74c3 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java @@ -60,11 +60,11 @@ import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; public class ComparePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - + class FakeInput implements ITypedElement, IEncodedStreamContentAccessor { static final String UTF_16= "UTF-16"; //$NON-NLS-1$ String fContent; - + FakeInput(String name) { fContent= loadPreviewContentFromFile(name); } @@ -93,7 +93,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP public static final String INITIALLY_SHOW_ANCESTOR_PANE= PREFIX + "InitiallyShowAncestorPane"; //$NON-NLS-1$ public static final String PREF_SAVE_ALL_EDITORS= PREFIX + "SaveAllEditors"; //$NON-NLS-1$ public static final String IGNORE_WHITESPACE= PREFIX + "IgnoreWhitespace"; //$NON-NLS-1$ - + //public static final String USE_SPLINES= PREFIX + "UseSplines"; //$NON-NLS-1$ public static final String USE_SINGLE_LINE= PREFIX + "UseSingleLine"; //$NON-NLS-1$ public static final String HIGHLIGHT_TOKEN_CHANGES= PREFIX + "HighlightTokenChanges"; //$NON-NLS-1$ @@ -103,7 +103,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP public static final String ADDED_LINES_REGEX= PREFIX + "AddedLinesRegex"; //$NON-NLS-1$ public static final String REMOVED_LINES_REGEX= PREFIX + "RemovedLinesRegex"; //$NON-NLS-1$ public static final String SWAPPED = PREFIX + "Swapped"; //$NON-NLS-1$ - + private TextMergeViewer fPreviewViewer; private IPropertyChangeListener fPreferenceChangeListener; @@ -116,7 +116,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP private SelectionListener fCheckBoxListener; - public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] { + public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] { new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, OPEN_STRUCTURE_COMPARE), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_OUTLINE_VIEW), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING), @@ -139,8 +139,8 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP private List<FieldEditor> editors = new ArrayList<>(); private TabItem fTextCompareTab; private Button fDisableCappingCheckBox; - - + + public static void initDefaults(IPreferenceStore store) { store.setDefault(OPEN_STRUCTURE_COMPARE, true); store.setDefault(USE_OUTLINE_VIEW, false); @@ -163,11 +163,11 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP } public ComparePreferencePage() { - + //setDescription(Utilities.getString("ComparePreferencePage.description")); //$NON-NLS-1$ - + setPreferenceStore(CompareUIPlugin.getDefault().getPreferenceStore()); - + fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys); fPreferenceChangeListener= new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { @@ -182,13 +182,13 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP }; fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener); } - + /* * @see IWorkbenchPreferencePage#init() */ public void init(IWorkbench workbench) { // empty - } + } /* * @see PreferencePage#performOk() @@ -205,23 +205,23 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP ComparePreferencePage.CAPPING_DISABLED)); return true; } - + /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { - + fOverlayStore.loadDefaults(); initializeFields(); super.performDefaults(); } - + /* * @see DialogPage#dispose() */ public void dispose() { - + if (fOverlayStore != null) { if (fPreferenceChangeListener != null) { fOverlayStore.removePropertyChangeListener(fPreferenceChangeListener); @@ -230,7 +230,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP fOverlayStore.stop(); fOverlayStore= null; } - + super.dispose(); } @@ -238,52 +238,52 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore(); return store.getBoolean(PREF_SAVE_ALL_EDITORS); } - + static public void setSaveAllEditors(boolean value) { IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore(); store.setValue(PREF_SAVE_ALL_EDITORS, value); - } + } /* * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { - + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.COMPARE_PREFERENCE_PAGE); - + fOverlayStore.load(); fOverlayStore.start(); - + TabFolder folder= new TabFolder(parent, SWT.NONE); - folder.setLayout(new TabFolderLayout()); + folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - + TabItem item= new TabItem(folder, SWT.NONE); item.setText(Utilities.getString("ComparePreferencePage.generalTab.label")); //$NON-NLS-1$ //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); item.setControl(createGeneralPage(folder)); - + item= new TabItem(folder, SWT.NONE); item.setText(Utilities.getString("ComparePreferencePage.textCompareTab.label")); //$NON-NLS-1$ //item.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CFILE)); item.setControl(createTextComparePage(folder)); fTextCompareTab = item; - + initializeFields(); Dialog.applyDialogFont(folder); return folder; } - + private Control createGeneralPage(Composite parent) { Composite composite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 1; composite.setLayout(layout); - + addCheckBox(composite, "ComparePreferencePage.structureCompare.label", OPEN_STRUCTURE_COMPARE, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.structureOutline.label", USE_OUTLINE_VIEW, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.ignoreWhitespace.label", IGNORE_WHITESPACE, 0); //$NON-NLS-1$ - + // a spacer new Label(composite, SWT.NONE); @@ -291,22 +291,22 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP // a spacer new Label(composite, SWT.NONE); - + Label l= new Label(composite, SWT.WRAP); l.setText(Utilities.getString("ComparePreferencePage.regex.description")); //$NON-NLS-1$ - + Composite c2= new Composite(composite, SWT.NONE); c2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout= new GridLayout(2, false); layout.marginWidth= 0; c2.setLayout(layout); - + l= new Label(c2, SWT.NONE); l.setText(Utilities.getString("ComparePreferencePage.regexAdded.label")); //$NON-NLS-1$ addedLinesRegex = new Text(c2, SWT.BORDER); addedLinesRegex.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addedLinesRegex.setText(fOverlayStore.getString(ADDED_LINES_REGEX)); - + l= new Label(c2, SWT.NONE); l.setText(Utilities.getString("ComparePreferencePage.regexRemoved.label")); //$NON-NLS-1$ removedLinesRegex = new Text(c2, SWT.BORDER); @@ -315,19 +315,19 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP // a spacer new Label(composite, SWT.NONE); - + l= new Label(composite, SWT.WRAP); l.setText(Utilities.getString("ComparePreferencePage.filter.description")); //$NON-NLS-1$ - + Composite c3= new Composite(composite, SWT.NONE); c3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout= new GridLayout(2, false); layout.marginWidth= 0; c3.setLayout(layout); - + l= new Label(c3, SWT.NONE); l.setText(Utilities.getString("ComparePreferencePage.filter.label")); //$NON-NLS-1$ - + fFilters= new Text(c3, SWT.BORDER); fFilters.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fFilters.setText(fOverlayStore.getString(PATH_FILTER)); @@ -343,28 +343,28 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP } } ); - + return composite; } - + private Control createTextComparePage(Composite parent) { - + Composite composite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 1; composite.setLayout(layout); - + addCheckBox(composite, "ComparePreferencePage.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$ - + //addCheckBox(composite, "ComparePreferencePage.useSplines.label", USE_SPLINES, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.useSingleLine.label", USE_SINGLE_LINE, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.highlightTokenChanges.label", HIGHLIGHT_TOKEN_CHANGES, 0); //$NON-NLS-1$ //addCheckBox(composite, "ComparePreferencePage.useResolveUI.label", USE_RESOLVE_UI, 0); //$NON-NLS-1$ fDisableCappingCheckBox = addCheckBox(composite, "ComparePreferencePage.disableCapping.label", CAPPING_DISABLED, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.swapped.label", SWAPPED, 0); //$NON-NLS-1$ - + Composite radioGroup = new Composite(composite, SWT.NULL); radioGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); RadioGroupFieldEditor editor = new RadioGroupFieldEditor( @@ -380,43 +380,43 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP editor.setPreferenceStore(fOverlayStore); editor.fillIntoGrid(radioGroup, 1); editors.add(editor); - + // a spacer Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setVisible(false); - + Label previewLabel= new Label(composite, SWT.NULL); previewLabel.setText(Utilities.getString("ComparePreferencePage.preview.label")); //$NON-NLS-1$ - + Control previewer= createPreviewer(composite); GridData gd= new GridData(GridData.FILL_BOTH); gd.widthHint= convertWidthInCharsToPixels(60); gd.heightHint= convertHeightInCharsToPixels(13); previewer.setLayoutData(gd); - + PreferenceLinkArea area = new PreferenceLinkArea(composite, SWT.NONE, "org.eclipse.ui.preferencePages.ColorsAndFonts", Utilities.getString("ComparePreferencePage.colorAndFontLink"), //$NON-NLS-1$ //$NON-NLS-2$ (IWorkbenchPreferenceContainer)getContainer(), "selectCategory:org.eclipse.compare.contentmergeviewer.TextMergeViewer"); //$NON-NLS-1$ GridData data= new GridData(SWT.FILL, SWT.CENTER, false, false); area.getControl().setLayoutData(data); - + return composite; } - + private Control createPreviewer(Composite parent) { - + fCompareConfiguration= new CompareConfiguration(fOverlayStore); fCompareConfiguration.setAncestorLabel(Utilities.getString("ComparePreferencePage.ancestor.label")); //$NON-NLS-1$ - + fCompareConfiguration.setLeftLabel(Utilities.getString("ComparePreferencePage.left.label")); //$NON-NLS-1$ fCompareConfiguration.setLeftEditable(false); - + fCompareConfiguration.setRightLabel(Utilities.getString("ComparePreferencePage.right.label")); //$NON-NLS-1$ fCompareConfiguration.setRightEditable(false); - + fPreviewViewer= new TextMergeViewer(parent, SWT.BORDER, fCompareConfiguration); - + fPreviewViewer.setInput( new DiffNode(Differencer.CONFLICTING, new FakeInput("ComparePreferencePage.previewAncestor"), //$NON-NLS-1$ @@ -432,42 +432,42 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP fCompareConfiguration.dispose(); } }); - + return c; } - + private void initializeFields() { - + Iterator<Button> e = fCheckBoxes.keySet().iterator(); while (e.hasNext()) { Button b = e.next(); String key= fCheckBoxes.get(b); b.setSelection(fOverlayStore.getBoolean(key)); } - + if (fFilters != null) fFilters.setText(fOverlayStore.getString(PATH_FILTER)); if (addedLinesRegex != null) addedLinesRegex.setText(fOverlayStore.getString(ADDED_LINES_REGEX)); if (removedLinesRegex != null) removedLinesRegex.setText(fOverlayStore.getString(REMOVED_LINES_REGEX)); - + editors.forEach(editor -> editor.load()); } // overlay stuff - + private Button addCheckBox(Composite parent, String labelKey, String key, int indentation) { - + String label= Utilities.getString(labelKey); - + Button checkBox= new Button(parent, SWT.CHECK); checkBox.setText(label); - + GridData gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent= indentation; checkBox.setLayoutData(gd); - + if (fCheckBoxListener == null) { fCheckBoxListener= new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @@ -477,14 +477,14 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP }; } checkBox.addSelectionListener(fCheckBoxListener); - + fCheckBoxes.put(checkBox, key); - + return checkBox; } private String loadPreviewContentFromFile(String key) { - + String preview= Utilities.getString(key); String separator= System.getProperty("line.separator"); //$NON-NLS-1$ StringBuffer buffer= new StringBuffer(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareResourceFilter.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareResourceFilter.java index eb5529f5e..38dc8fa42 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareResourceFilter.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareResourceFilter.java @@ -22,11 +22,11 @@ import com.ibm.icu.text.MessageFormat; public class CompareResourceFilter { private static final char[][] NO_CHAR_CHAR= new char[0][]; - + private char[][] fExtraResourceFileFilters; private String[] fExtraResourceFolderFilters; - + public CompareResourceFilter() { // nothing to do } @@ -61,14 +61,14 @@ public class CompareResourceFilter { resourceType= IResource.FOLDER; } IStatus status= workspace.validateName(fileName, resourceType); - if (status.matches(IStatus.ERROR)) { + if (status.matches(IStatus.ERROR)) { String format= Utilities.getString("ComparePreferencePage.filter.invalidsegment.error"); //$NON-NLS-1$ return MessageFormat.format(format, status.getMessage()); } } return null; } - + public void setFilters(String filterSequence) { char[][] filters= filterSequence != null && filterSequence.length() > 0 ? splitAndTrimOn(',', filterSequence.toCharArray()) @@ -102,7 +102,7 @@ public class CompareResourceFilter { } ///////// - + private static String[] getTokens(String text, String separator) { StringTokenizer tok= new StringTokenizer(text, separator); int nTokens= tok.countTokens(); @@ -110,43 +110,43 @@ public class CompareResourceFilter { for (int i= 0; i < res.length; i++) res[i]= tok.nextToken().trim(); return res; - } - + } + /** * Answers true if the pattern matches the given name, false otherwise. * This char[] pattern matching accepts wild-cards '*' and '?'. - * + * * When not case sensitive, the pattern is assumed to already be * lowercased, the name will be lowercased character per character as * comparing. If name is null, the answer is false. If pattern is null, the * answer is true if name is not null. <br><br>For example: * <ol> * <li> - * + * * <pre> * pattern = { '?', 'b', '*' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => true * </pre> - * - * + * + * * </li> * <li> - * + * * <pre> * pattern = { '?', 'b', '?' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => false * </pre> - * - * + * + * * </li> * <li> - * + * * <pre> * pattern = { 'b', '*' } name = { 'a', 'b', 'c' , 'd' } isCaseSensitive = true result => false * </pre> - * - * + * + * * </li> * </ol> - * + * * @param pattern * the given pattern * @param name @@ -174,23 +174,23 @@ public class CompareResourceFilter { * character as comparing. <br><br>For example: * <ol> * <li> - * + * * <pre> * pattern = { '?', 'b', '*' } patternStart = 1 patternEnd = 3 name = { 'a', 'b', 'c' , 'd' } nameStart = 1 nameEnd = 4 isCaseSensitive = true result => true * </pre> - * - * + * + * * </li> * <li> - * + * * <pre> * pattern = { '?', 'b', '*' } patternStart = 1 patternEnd = 2 name = { 'a', 'b', 'c' , 'd' } nameStart = 1 nameEnd = 2 isCaseSensitive = true result => false * </pre> - * - * + * + * * </li> * </ol> - * + * * @param pattern * the given pattern * @param patternStart @@ -273,39 +273,39 @@ public class CompareResourceFilter { * <br><br>For example: * <ol> * <li> - * + * * <pre> * divider = 'b' array = { 'a' , 'b', 'b', 'a', 'b', 'a' } result => { { 'a' }, { }, { 'a' }, { 'a' } } * </pre> - * - * + * + * * </li> * <li> - * + * * <pre> * divider = 'c' array = { 'a' , 'b', 'b', 'a', 'b', 'a' } result => { { 'a', 'b', 'b', 'a', 'b', 'a' } } * </pre> - * - * + * + * * </li> * <li> - * + * * <pre> * divider = 'b' array = { 'a' , ' ', 'b', 'b', 'a', 'b', 'a' } result => { { 'a' }, { }, { 'a' }, { 'a' } } * </pre> - * - * + * + * * </li> * <li> - * + * * <pre> * divider = 'c' array = { ' ', ' ', 'a' , 'b', 'b', 'a', 'b', 'a', ' ' } result => { { 'a', 'b', 'b', 'a', 'b', 'a' } } * </pre> - * - * + * + * * </li> * </ol> - * + * * @param divider * the given divider * @param array @@ -355,23 +355,23 @@ public class CompareResourceFilter { * <br><br>For example: * <ol> * <li> - * + * * <pre> * array = { 'a' , 'b' } start = 0 end = 1 result => { 'a' } * </pre> - * - * + * + * * </li> * <li> - * + * * <pre> * array = { 'a', 'b' } start = 0 end = -1 result => { 'a' , 'b' } * </pre> - * - * + * + * * </li> * </ol> - * + * * @param array * the given array * @param start diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java index 5f2564a63..eb4fbe73e 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java @@ -122,7 +122,7 @@ public class CompareStructureViewerSwitchingPane extends }); return composite; } - + protected boolean inputChanged(Object input) { return getInput() != input || fCompareEditorInput.getStructureViewerDescriptor() != fSelectedViewerDescriptor; @@ -144,7 +144,7 @@ public class CompareStructureViewerSwitchingPane extends private void showMenu() { if (!(getInput() instanceof ICompareInput)) return; - + ViewerDescriptor[] vd = CompareUIPlugin.getDefault() .findStructureViewerDescriptor(getViewer(), (ICompareInput) getInput(), getCompareConfiguration()); @@ -160,7 +160,7 @@ public class CompareStructureViewerSwitchingPane extends defaultItem.setSelection(fSelectedViewerDescriptor == null); new MenuItem(menu, SWT.SEPARATOR); - + // add others for (int i = 0; i < vd.length; i++) { final ViewerDescriptor vdi = vd[i]; @@ -177,14 +177,14 @@ public class CompareStructureViewerSwitchingPane extends item.addSelectionListener(createSelectionListener(vdi)); item.setSelection(vdi == fSelectedViewerDescriptor); } - + // 2. show Rectangle bounds = toolBar.getItem(0).getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = toolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); - + // 3. dispose on close menu.addMenuListener(new MenuAdapter() { public void menuHidden(MenuEvent e) { @@ -242,7 +242,7 @@ public class CompareStructureViewerSwitchingPane extends } } } - + public void addMouseListener(MouseListener listener) { Composite c = (Composite) getTopLeft(); Control[] children = c.getChildren(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java index 0d0abb819..0cc84dcd1 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithEditionAction.java @@ -11,7 +11,7 @@ package org.eclipse.compare.internal; public class CompareWithEditionAction extends EditionAction { - + public CompareWithEditionAction() { super(false, "org.eclipse.compare.internal.CompareWithEditionAction"); //$NON-NLS-1$ this.fHelpContextId= ICompareContextIds.COMPARE_WITH_EDITION_DIALOG; diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java index f322b95da..fb20ee888 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java @@ -16,7 +16,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; /** * The "Compare with other resource" action. - * + * * @deprecated Temporarily replaced by CompareWithOtherResourceHandler. See bug * 264498. */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java index 635b31866..533ada409 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java @@ -69,7 +69,7 @@ import org.eclipse.ui.part.ResourceTransfer; * This is a dialog that can invoke the compare editor on chosen files. */ public class CompareWithOtherResourceDialog extends TitleAreaDialog { - + private int MIN_WIDTH = 320; private int MIN_HEIGHT_WITH_ANCESTOR = 320; private int MIN_HEIGHT_WITHOUT_ANCESTOR = 238; @@ -169,28 +169,28 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { } } - + private abstract class ContentTypeElement { - + private Button radioButton; protected Button mainButton; protected Text text; private String type; protected InternalSection section; private IResource resource; - + public ContentTypeElement(Composite parent, String type, InternalSection section) { this.type = type; this.section = section; createContents(parent); } - + private void createContents(Composite parent) { createRadioButton(parent); createText(parent); createMainButton(parent); } - + private void createRadioButton(Composite parent) { radioButton = new Button(parent, SWT.RADIO); radioButton.setText(type); @@ -201,30 +201,30 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); text.setEditable(false); } - + protected void createMainButton(Composite parent) { mainButton = new Button(parent, SWT.PUSH); mainButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); } - + protected Button getRadioButton() { return radioButton; } - + protected String getText() { return text.getText(); } - + protected void setText(String string) { text.setText(string); } - + protected void setEnabled(boolean enabled) { radioButton.setSelection(enabled); mainButton.setEnabled(enabled); text.setEnabled(enabled); } - + protected void setResource(IResource resource) { this.resource = resource; section.setResource(resource); @@ -233,32 +233,32 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { public IResource getResource() { return resource; } - + void clearResource() { resource = null; text.setText(""); //$NON-NLS-1$ } - + } - + private class WorkspaceContent extends ContentTypeElement { - + public WorkspaceContent(Composite parent, InternalSection section) { super(parent, CompareMessages.CompareWithOtherResourceDialog_workspaceRadioButton, section); } - + protected void createMainButton(Composite parent) { super.createMainButton(parent); mainButton.setText(CompareMessages.CompareWithOtherResourceDialog_workspaceMainButton); // temporarily hide this button. For more information about supporting for browsing workspace see bug 243744. mainButton.setVisible(false); } - + protected void createText(Composite parent) { - + super.createText(parent); text.setEditable(true); - + text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { section.setResource(text.getText()); @@ -275,7 +275,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { updateErrorInfo(); } }); - + initDrag(); initDrop(); } @@ -302,15 +302,15 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { target.setTransfer(types); target.addDropListener(new FileTextDropListener(this)); } - + } - + private class ExternalFileContent extends ContentTypeElement { - + public ExternalFileContent(Composite parent, InternalSection section) { super(parent, CompareMessages.CompareWithOtherResourceDialog_externalFileRadioButton, section); } - + protected void createMainButton(Composite parent) { super.createMainButton(parent); mainButton.setText(CompareMessages.CompareWithOtherResourceDialog_externalFileMainButton); @@ -320,7 +320,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { } public void widgetSelected(SelectionEvent e) { IResource r = tmpProject.getExternalFile(); - if (r == null) + if (r == null) return; setResource(r); } @@ -331,15 +331,15 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { super.setResource(resource); text.setText(resource.getLocation().toOSString()); } - + } - + private class ExternalFolderContent extends ContentTypeElement { - + public ExternalFolderContent(Composite parent, InternalSection section) { super(parent, CompareMessages.CompareWithOtherResourceDialog_externalFolderRadioButton, section); } - + protected void createMainButton(Composite parent) { super.createMainButton(parent); mainButton.setText(CompareMessages.CompareWithOtherResourceDialog_externalFolderMainButton); @@ -360,11 +360,11 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { super.setResource(resource); text.setText(resource.getLocation().toOSString()); } - + } private abstract class InternalSection { - + // there is no "enum" support in Java 1.4. Sigh... public static final int WORKSPACE = 0; public static final int EXTERNAL_FILE = 1; @@ -372,11 +372,11 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { protected Group group; private IResource resource; - + ExternalFileContent externalFileContent; ExternalFolderContent externalFolderContent; WorkspaceContent workspaceContent; - + private InternalSection() { // not to instantiate } @@ -386,16 +386,16 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { group = new Group(parent, SWT.NONE); group.setLayout(new GridLayout(3, false)); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - + workspaceContent = new WorkspaceContent(group, this); externalFileContent = new ExternalFileContent(group, this); externalFolderContent = new ExternalFolderContent(group, this); - + addListenersToRadioButtons(); } - + private void addListenersToRadioButtons() { - final ContentTypeElement[] elements = new ContentTypeElement[] { workspaceContent, + final ContentTypeElement[] elements = new ContentTypeElement[] { workspaceContent, externalFileContent, externalFolderContent }; for (int i = 0; i < elements.length; i++) { elements[i].getRadioButton().addListener(SWT.Selection, new Listener() { @@ -425,9 +425,9 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { protected void setResource(String s) { IResource tmp = ResourcesPlugin.getWorkspace().getRoot() .findMember(s); - if (tmp instanceof IWorkspaceRoot) + if (tmp instanceof IWorkspaceRoot) resource = null; - else + else resource = tmp; updateErrorInfo(); } @@ -439,10 +439,10 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { externalFolderContent.clearResource(); updateErrorInfo(); } - + protected void setContentType(int type) { switch(type) { - case WORKSPACE: + case WORKSPACE: workspaceContent.setEnabled(true); externalFileContent.setEnabled(false); externalFolderContent.setEnabled(false); @@ -521,15 +521,15 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { expandable.setLayoutData(layoutData); } } - + private class ExternalResourcesProject { - + // Implementation based on org.eclipse.jdt.internal.core.ExternalFoldersManager - + private int counter = 0; - + private static final String TMP_PROJECT_NAME = ".org.eclipse.compare.tmp"; //$NON-NLS-1$ - + private final static String TMP_PROJECT_FILE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$ + "<projectDescription>\n" //$NON-NLS-1$ + "\t<name>" + TMP_PROJECT_NAME + "\t</name>\n" //$NON-NLS-1$ //$NON-NLS-2$ @@ -540,13 +540,13 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { + "\t</buildSpec>\n" //$NON-NLS-1$ + "\t<natures>\n" + "\t</natures>\n" //$NON-NLS-1$//$NON-NLS-2$ + "</projectDescription>"; //$NON-NLS-1$ - + private final static String TMP_FOLDER_NAME = "tmpFolder"; //$NON-NLS-1$ - + private ExternalResourcesProject() { // nothing to do here } - + private IProject createTmpProject() throws CoreException { IProject project = getTmpProject(); if (!project.isAccessible()) { @@ -582,14 +582,14 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { project.setHidden(true); return project; } - + private IFolder getTmpFolder(IProject project) throws CoreException { IFolder folder = project.getFolder(TMP_FOLDER_NAME); if (!folder.exists()) folder.create(IResource.NONE, true, null); return folder; } - + private IFile getExternalFile() { FileDialog dialog = new FileDialog(getShell()); String path = dialog.open(); @@ -605,7 +605,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { return (IFolder) linkResource(new Path(path)); return null; } - + private IResource linkResource(IPath path) { IResource r = null; String resourceName = path.lastSegment(); @@ -617,7 +617,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { r = getTmpFolder(project).getFile(resourceName); if (r.exists()) { // add a number to file's name when there already is a file with that name in a folder String extension = path.getFileExtension(); - String fileName = path.removeFileExtension().lastSegment(); + String fileName = path.removeFileExtension().lastSegment(); r = getTmpFolder(project).getFile(getName(fileName, extension)); } ((IFile)r).createLink(path, IResource.REPLACE, null); @@ -636,11 +636,11 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { } return r; } - + /** * This method is used to prevent duplicating names of linked resources. * It adds a suffix based on the <code>counter</code> value. - * + * * @param name * @param extension optional * @return @@ -658,13 +658,13 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { // don't change the name if counter equals 0 return name; } - + private IProject getTmpProject() { return ResourcesPlugin.getWorkspace().getRoot().getProject( TMP_PROJECT_NAME); } } - + private Button okButton; private InternalGroup rightPanel, leftPanel; private InternalExpandable ancestorPanel; @@ -673,7 +673,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { /** * Creates the dialog. - * + * * @param shell * a shell * @param selection @@ -689,7 +689,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets * .Composite) @@ -730,7 +730,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse * .swt.widgets.Composite) @@ -800,13 +800,13 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog { } } } - + /** * Returns table with selected resources. If any resource wasn't chosen in * the ancestor panel, table has only two elements -- resources chosen in * left and right panel. In the other case table contains all three * resources. - * + * * @return table with selected resources */ public IResource[] getResult() { diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceHandler.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceHandler.java index 74a57deb1..35508b697 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceHandler.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceHandler.java @@ -26,16 +26,16 @@ import org.eclipse.ui.handlers.HandlerUtil; * available from "Compare With > Other Resource...". See bug 264498. */ public class CompareWithOtherResourceHandler extends AbstractHandler { - + public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelection(event); IWorkbenchPage workbenchPage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); - + // CompareAction#isEnabled(ISelection) CompareConfiguration cc = new CompareConfiguration(); cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, Boolean.FALSE); ResourceCompareInput input = new ResourceCompareInput(cc); - + int selectionSize = 0; if (selection instanceof IStructuredSelection) { selectionSize = ((IStructuredSelection) selection).toArray().length; diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java index d598889d1..bfcb297f8 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ContentChangeNotifier.java @@ -24,7 +24,7 @@ public class ContentChangeNotifier implements IContentChangeNotifier { private ListenerList fListenerList; private final IContentChangeNotifier element; - + public ContentChangeNotifier(IContentChangeNotifier element) { this.element = element; } @@ -37,7 +37,7 @@ public class ContentChangeNotifier implements IContentChangeNotifier { fListenerList= new ListenerList(); fListenerList.add(listener); } - + /* (non-Javadoc) * see IContentChangeNotifier.removeChangeListener */ @@ -48,7 +48,7 @@ public class ContentChangeNotifier implements IContentChangeNotifier { fListenerList= null; } } - + /** * Notifies all registered <code>IContentChangeListener</code>s of a content change. */ @@ -82,7 +82,7 @@ public class ContentChangeNotifier implements IContentChangeNotifier { /** * Return whether this notifier is empty (i.e. has no listeners). - * @return whether this notifier is empty + * @return whether this notifier is empty */ public boolean isEmpty() { return fListenerList == null || fListenerList.isEmpty(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImageDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImageDescriptor.java index b602b8f75..3f21ad964 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImageDescriptor.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DiffImageDescriptor.java @@ -53,7 +53,7 @@ public class DiffImageDescriptor extends CompositeImageDescriptor { } return h1 + h2 + fWidth; } - + private int calculateHash(ImageData baseImageData) { byte[] data = baseImageData.data; int hash = baseImageData.width + baseImageData.height; @@ -80,7 +80,7 @@ public class DiffImageDescriptor extends CompositeImageDescriptor { if (fBaseImageData != null) { drawImage(fBaseImageData, fWidth - fBaseImageData.width, 0); } - + if (fOverlayImage != null) { ImageData overlay= fOverlayImage.getImageData(); if (overlay == null) @@ -91,7 +91,7 @@ public class DiffImageDescriptor extends CompositeImageDescriptor { if (fBaseImageData != null) { drawImage(fBaseImageData, 0, 0); } - + if (fOverlayImage != null) { ImageData overlay= fOverlayImage.getImageData(); if (overlay == null) @@ -100,7 +100,7 @@ public class DiffImageDescriptor extends CompositeImageDescriptor { } } } - + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @@ -118,13 +118,13 @@ public class DiffImageDescriptor extends CompositeImageDescriptor { DiffImageDescriptor other = (DiffImageDescriptor) obj; return (other.hashCode == hashCode && isEqual(other.fOverlayImage, fOverlayImage) - && other.fWidth == fWidth + && other.fWidth == fWidth && other.fLeft == fLeft && isEqual(other.fBaseImageData, fBaseImageData)); } return false; } - + private boolean isEqual(ImageData i1, ImageData i2) { if (isEqual((Object) i1, (Object) i2)) { return true; @@ -143,7 +143,7 @@ public class DiffImageDescriptor extends CompositeImageDescriptor { && equals(i1.data,i2.data) && equals(i1.maskData, i2.maskData) && equals(i1.alphaData, i2.alphaData)); } - + private boolean equals(byte[] data, byte[] data2) { if (isEqual(data, data2)) return true; diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java index c0a4e1abd..1ceaf7444 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java @@ -56,7 +56,7 @@ public class DocLineComparator implements ITokenComparator { * ignoreWhiteSpace controls whether comparing lines (in method * <code>rangesEqual<code>) should ignore whitespace. Compare filters may be used * to affect the detection of line differences. - * + * * @param document * the document from which the lines are taken * @param region @@ -181,7 +181,7 @@ public class DocLineComparator implements ITokenComparator { /** * Aborts the comparison if the number of tokens is too large. - * + * * @param length a number on which to base the decision whether to return * <code>true</code> or <code>false</code> * @param maxLength another number on which to base the decision whether to return @@ -192,9 +192,9 @@ public class DocLineComparator implements ITokenComparator { public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { return false; } - + //---- private methods - + private String[] extract(int thisIndex, int otherIndex, DocLineComparator other, boolean includeSeparator) { @@ -268,9 +268,9 @@ public class DocLineComparator implements ITokenComparator { int l2= s2.length(); int c1= 0, c2= 0; int i1= 0, i2= 0; - + while (c1 != -1) { - + c1= -1; while (i1 < l1) { char c= s1.charAt(i1++); @@ -279,7 +279,7 @@ public class DocLineComparator implements ITokenComparator { break; } } - + c2= -1; while (i2 < l2) { char c= s2.charAt(i2++); @@ -288,7 +288,7 @@ public class DocLineComparator implements ITokenComparator { break; } } - + if (c1 != c2) return false; } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java index 15ce8915e..3fc20f1c1 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocumentManager.java @@ -18,21 +18,21 @@ import org.eclipse.jface.text.IDocument; * No API yet. */ public class DocumentManager { - + private static final boolean DEBUG= false; - + private static ArrayList fgKeys= new ArrayList(); private static ArrayList fgValues= new ArrayList(); - + public static IDocument get(Object o) { - + for (int i= 0; i < fgKeys.size(); i++) { if (fgKeys.get(i) == o) return (IDocument) fgValues.get(i); } return null; } - + public static void put(Object o, IDocument document) { if (DEBUG) System.out.println("DocumentManager.put: " + document); //$NON-NLS-1$ for (int i= 0; i < fgKeys.size(); i++) { @@ -42,9 +42,9 @@ public class DocumentManager { } } fgKeys.add(o); - fgValues.add(document); + fgValues.add(document); } - + public static void remove(IDocument document) { if (document != null) { if (DEBUG) System.out.println("DocumentManager.remove: " + document); //$NON-NLS-1$ @@ -58,7 +58,7 @@ public class DocumentManager { if (DEBUG) System.out.println("DocumentManager.remove: not found"); //$NON-NLS-1$ } } - + public static void dump() { if (DEBUG) System.out.println("DocumentManager: managed docs:" + fgValues.size()); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java index 08fbe6286..fd91e95e9 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java @@ -48,24 +48,24 @@ public class EditionAction extends BaseCompareAction { private static final String UTF_16= "UTF-16"; //$NON-NLS-1$ private IDocument fDocument; private IFile fFile; - + DocumentBufferNode(IDocument document, IFile file) { fDocument= document; fFile= file; } - + public String getName() { return fFile.getName(); } - + public String getType() { return fFile.getFileExtension(); } - + public Image getImage() { return null; } - + public InputStream getContents() { return new ByteArrayInputStream(Utilities.getBytes(fDocument.get(), UTF_16)); } @@ -79,7 +79,7 @@ public class EditionAction extends BaseCompareAction { private boolean fReplaceMode; protected boolean fPrevious= false; protected String fHelpContextId; - + EditionAction(boolean replaceMode, String bundleName) { fReplaceMode= replaceMode; fBundleName= bundleName; @@ -96,33 +96,33 @@ public class EditionAction extends BaseCompareAction { } private void doFromHistory(final IFile file) { - + ResourceBundle bundle= ResourceBundle.getBundle(fBundleName); String title= Utilities.getString(bundle, "title"); //$NON-NLS-1$ - + Shell parentShell= CompareUIPlugin.getShell(); - + IFileState states[]= null; try { states= file.getHistory(null); - } catch (CoreException ex) { + } catch (CoreException ex) { MessageDialog.openError(parentShell, title, ex.getMessage()); return; } - + if (states == null || states.length <= 0) { String msg= Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$ MessageDialog.openInformation(parentShell, title, msg); return; } - + ITypedElement base= new ResourceNode(file); - + IDocument document= getDocument(file); ITypedElement target= base; if (document != null) target= new DocumentBufferNode(document, file); - + ITypedElement[] editions= new ITypedElement[states.length+1]; editions[0]= base; for (int i= 0; i < states.length; i++) @@ -134,29 +134,29 @@ public class EditionAction extends BaseCompareAction { //d.setHideIdenticalEntries(false); if (fHelpContextId != null) d.setHelpContextId(fHelpContextId); - + if (fReplaceMode) { - + ITypedElement ti= null; if (fPrevious) ti= d.selectPreviousEdition(target, editions, null); else ti= d.selectEdition(target, editions, null); - + if (ti instanceof IStreamContentAccessor) { IStreamContentAccessor sa= (IStreamContentAccessor)ti; - + if (Utilities.validateResource(file, parentShell, title)) { try { - + if (document != null) - updateDocument(document, sa); + updateDocument(document, sa); else updateWorkspace(bundle, parentShell, sa, file); - + } catch (InterruptedException x) { // Do nothing. Operation has been canceled by user. - + } catch (InvocationTargetException x) { String reason= x.getTargetException().getMessage(); MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$ @@ -166,13 +166,13 @@ public class EditionAction extends BaseCompareAction { } else { d.setCompareMode(true); - d.selectEdition(target, editions, null); + d.selectEdition(target, editions, null); } } - + private void updateWorkspace(final ResourceBundle bundle, Shell shell, final IStreamContentAccessor sa, final IFile file) - throws InvocationTargetException, InterruptedException { + throws InvocationTargetException, InterruptedException { WorkspaceModifyOperation operation= new WorkspaceModifyOperation() { public void execute(IProgressMonitor pm) throws InvocationTargetException { try { @@ -186,11 +186,11 @@ public class EditionAction extends BaseCompareAction { } } }; - - ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); - pmdialog.run(false, true, operation); + + ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(shell); + pmdialog.run(false, true, operation); } - + private void updateDocument(IDocument document, IStreamContentAccessor sa) throws InvocationTargetException { try { String text= Utilities.readString(sa); @@ -201,7 +201,7 @@ public class EditionAction extends BaseCompareAction { throw new InvocationTargetException(e); } } - + private IDocument getDocument(IFile file) { IWorkbench wb= PlatformUI.getWorkbench(); if (wb == null) @@ -209,9 +209,9 @@ public class EditionAction extends BaseCompareAction { IWorkbenchWindow[] ws= wb.getWorkbenchWindows(); if (ws == null) return null; - + FileEditorInput test= new FileEditorInput(file); - + for (int i= 0; i < ws.length; i++) { IWorkbenchWindow w= ws[i]; IWorkbenchPage[] wps= w.getPages(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java index e8c81e2e0..a9390209e 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ExceptionHandler.java @@ -32,20 +32,20 @@ import org.eclipse.jface.dialogs.MessageDialog; public class ExceptionHandler { private static ExceptionHandler fgInstance= new ExceptionHandler(); - + /* * Logs the given exception using the platform's logging mechanism. The exception is * logged as an error with the error code <code>JavaStatusConstants.INTERNAL_ERROR</code>. */ public static void log(Throwable t, String message) { - CompareUIPlugin.log(new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), + CompareUIPlugin.log(new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), CompareUIPlugin.INTERNAL_ERROR, message, t)); } - + /** * Handles the given <code>CoreException</code>. The workbench shell is used as a parent * for the dialog window. - * + * * @param e the <code>CoreException</code> to be handled * @param title the dialog window's window title * @param message message to be displayed by the dialog window @@ -53,10 +53,10 @@ public class ExceptionHandler { public static void handle(CoreException e, String title, String message) { handle(e, CompareUIPlugin.getShell(), title, message); } - + /** - * Handles the given <code>CoreException</code>. - * + * Handles the given <code>CoreException</code>. + * * @param e the <code>CoreException</code> to be handled * @param parent the dialog window's parent shell * @param title the dialog window's window title @@ -65,11 +65,11 @@ public class ExceptionHandler { public static void handle(CoreException e, Shell parent, String title, String message) { fgInstance.perform(e, parent, title, message); } - + /** - * Handles the given <code>InvocationTargetException</code>. The workbench shell is used + * Handles the given <code>InvocationTargetException</code>. The workbench shell is used * as a parent for the dialog window. - * + * * @param e the <code>InvocationTargetException</code> to be handled * @param title the dialog window's window title * @param message message to be displayed by the dialog window @@ -77,10 +77,10 @@ public class ExceptionHandler { public static void handle(InvocationTargetException e, String title, String message) { handle(e, CompareUIPlugin.getShell(), title, message); } - + /** - * Handles the given <code>InvocationTargetException</code>. - * + * Handles the given <code>InvocationTargetException</code>. + * * @param e the <code>InvocationTargetException</code> to be handled * @param parent the dialog window's parent shell * @param title the dialog window's window title @@ -91,7 +91,7 @@ public class ExceptionHandler { } //---- Hooks for subclasses to control exception handling ------------------------------------ - + protected void perform(CoreException e, Shell shell, String title, String message) { CompareUIPlugin.log(e); IStatus status= e.getStatus(); @@ -117,7 +117,7 @@ public class ExceptionHandler { } //---- Helper methods ----------------------------------------------------------------------- - + private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) { StringWriter msg= new StringWriter(); if (message != null) { @@ -125,9 +125,9 @@ public class ExceptionHandler { msg.write("\n\n"); //$NON-NLS-1$ } if (exceptionMessage == null || exceptionMessage.length() == 0) - msg.write(CompareMessages.ExceptionDialog_seeErrorLogMessage); + msg.write(CompareMessages.ExceptionDialog_seeErrorLogMessage); else msg.write(exceptionMessage); - MessageDialog.openError(shell, title, msg.toString()); - } + MessageDialog.openError(shell, title, msg.toString()); + } } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java index 804e72023..ae2047f7d 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareContextIds.java @@ -18,12 +18,12 @@ import org.eclipse.compare.CompareUI; * This interface contains constants only; it is not intended to be implemented * or extended. * </p> - * + * */ public interface ICompareContextIds { - + public static final String PREFIX= CompareUI.PLUGIN_ID + '.'; - + // Dialogs public static final String EDITION_DIALOG= PREFIX + "edition_dialog_context"; //$NON-NLS-1$ @@ -34,13 +34,13 @@ public interface ICompareContextIds { public static final String COMPARE_DIALOG= PREFIX + "compare_dialog_context"; //$NON-NLS-1$ public static final String COMPARE_WITH_EDITION_DIALOG= PREFIX + "compare_with_edition_dialog_context"; //$NON-NLS-1$ public static final String REPLACE_WITH_EDITION_DIALOG= PREFIX + "replace_with_edition_dialog_context"; //$NON-NLS-1$ - + // Viewer public static final String TEXT_MERGE_VIEW= PREFIX + "text_merge_view_context"; //$NON-NLS-1$ public static final String IMAGE_COMPARE_VIEW= PREFIX + "image_compare_view_context"; //$NON-NLS-1$ public static final String BINARY_COMPARE_VIEW= PREFIX + "binary_compare_view_context"; //$NON-NLS-1$ public static final String DIFF_VIEW= PREFIX + "diff_view_context"; //$NON-NLS-1$ - + // Actions public static final String GLOBAL_NEXT_DIFF_ACTION= PREFIX + "global_next_diff_action_context"; //$NON-NLS-1$ public static final String GLOBAL_PREVIOUS_DIFF_ACTION= PREFIX + "global_previous_diff_action_context"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IFlushable2.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IFlushable2.java index 8439d4e3c..d86c37505 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IFlushable2.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IFlushable2.java @@ -16,9 +16,9 @@ import org.eclipse.core.runtime.IProgressMonitor; /** * Interface which provides the ability to flush the contents from the specified * side of the viewer. - * + * * @see IFlushable - * + * * @since 3.7 */ public interface IFlushable2 { diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IMergeViewerTestAdapter.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IMergeViewerTestAdapter.java index bccb14d82..6617fe0f7 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IMergeViewerTestAdapter.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IMergeViewerTestAdapter.java @@ -27,7 +27,7 @@ public interface IMergeViewerTestAdapter { /** * Returns the number of changes in merge viewer - * + * * @return the number of changes */ public int getChangesCount(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavingSaveable.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavingSaveable.java index 851cd3101..6cee06265 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavingSaveable.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ISavingSaveable.java @@ -15,7 +15,7 @@ import org.eclipse.ui.Saveable; /** * Interface defines API for checking if an object, preferably an instance of * {@link Saveable}, is being saved. - * + * * @since 3.7 */ public interface ISavingSaveable { diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java index 6f45898a9..e05912347 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java @@ -28,17 +28,17 @@ import org.eclipse.compare.contentmergeviewer.ContentMergeViewer; /** */ public class ImageMergeViewer extends ContentMergeViewer { - + private static final String BUNDLE_NAME= "org.eclipse.compare.internal.ImageMergeViewerResources"; //$NON-NLS-1$ - + private Object fLeftImage; private Object fRightImage; private ImageCanvas fAncestor; private ImageCanvas fLeft; private ImageCanvas fRight; - - + + public ImageMergeViewer(Composite parent, int styles, CompareConfiguration mp) { super(styles, ResourceBundle.getBundle(BUNDLE_NAME), mp); @@ -50,23 +50,23 @@ public class ImageMergeViewer extends ContentMergeViewer { } protected void updateContent(Object ancestor, Object left, Object right) { - + setInput(fAncestor, ancestor); - + fLeftImage= left; setInput(fLeft, left); - + fRightImage= right; setInput(fRight, right); } - + /* * We can't modify the contents of either side we just return null. */ protected byte[] getContents(boolean left) { return null; } - + public void createControls(Composite composite) { fAncestor= new ImageCanvas(composite, SWT.NO_FOCUS); fLeft= new ImageCanvas(composite, SWT.NO_FOCUS); @@ -87,8 +87,8 @@ public class ImageMergeViewer extends ContentMergeViewer { } } } - - Image image= null; + + Image image= null; Display display= canvas.getDisplay(); if (stream != null) { try { @@ -104,7 +104,7 @@ public class ImageMergeViewer extends ContentMergeViewer { } else { canvas.setBackground(null); } - + if (stream != null) { try { stream.close(); @@ -114,7 +114,7 @@ public class ImageMergeViewer extends ContentMergeViewer { } } } - + protected void handleResizeAncestor(int x, int y, int width, int height) { if (width > 0) { fAncestor.setVisible(true); @@ -128,7 +128,7 @@ public class ImageMergeViewer extends ContentMergeViewer { fLeft.setBounds(x, y, width1, height); fRight.setBounds(x+width1+centerWidth, y, width2, height); } - + protected void copy(boolean leftToRight) { if (leftToRight) { fRightImage= fLeftImage; diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java index 10a3c6717..7ffc504f9 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ListContentProvider.java @@ -15,16 +15,16 @@ import java.util.List; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; -/** +/** * A specialized content provider to show a list of editor parts. - */ + */ public class ListContentProvider implements IStructuredContentProvider { - List fContents; + List fContents; public ListContentProvider() { // nothing to do } - + public Object[] getElements(Object input) { if (fContents != null && fContents == input) return fContents.toArray(); @@ -32,7 +32,7 @@ public class ListContentProvider implements IStructuredContentProvider { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (newInput instanceof List) + if (newInput instanceof List) fContents= (List)newInput; else fContents= null; @@ -42,7 +42,7 @@ public class ListContentProvider implements IStructuredContentProvider { public void dispose() { // empty default implementation } - + public boolean isDeleted(Object o) { return fContents != null && !fContents.contains(o); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java index 7fe0365c6..d923936e0 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java @@ -105,7 +105,7 @@ import org.eclipse.compare.ICompareContainer; */ public class MergeSourceViewer implements ISelectionChangedListener, ITextListener, IMenuListener, IOperationHistoryListener, IAdaptable { - + public static final String UNDO_ID= "undo"; //$NON-NLS-1$ public static final String REDO_ID= "redo"; //$NON-NLS-1$ public static final String CUT_ID= "cut"; //$NON-NLS-1$ @@ -118,13 +118,13 @@ public class MergeSourceViewer implements ISelectionChangedListener, public static final String CHANGE_ENCODING_ID= "changeEncoding"; //$NON-NLS-1$ class TextOperationAction extends MergeViewerAction { - + private int fOperationCode; - + TextOperationAction(int operationCode, boolean mutable, boolean selection, boolean content) { this(operationCode, null, mutable, selection, content); } - + public TextOperationAction(int operationCode, String actionDefinitionId, boolean mutable, boolean selection, boolean content) { super(mutable, selection, content); if (actionDefinitionId != null) @@ -141,7 +141,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, public boolean isEnabled() { return fOperationCode != -1 && getSourceViewer().canDoOperation(fOperationCode); } - + public void update() { setEnabled(isEnabled()); } @@ -153,7 +153,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, * embedded TextEditor in a similar way JDT has it done for Java compare. */ class TextEditorAdapter implements ITextEditor { - + public void close(boolean save) { // defining interface method } @@ -266,7 +266,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, public void selectAndReveal(int start, int length) { selectAndReveal(start, length, start, length); } - + /* * @see org.eclipse.ui.texteditor.AbstractTextEditor#selectAndReveal(int, int, int, int) */ @@ -298,7 +298,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, private void markInNavigationHistory() { getSite().getPage().getNavigationHistory().markLocation(this); } - + /* * @see org.eclipse.ui.texteditor.AbstractTextEditor#adjustHighlightRange(int, int) */ @@ -438,10 +438,10 @@ public class MergeSourceViewer implements ISelectionChangedListener, private boolean fEnabled= true; private HashMap fActions= new HashMap(); private IDocument fRememberedDocument; - + private boolean fAddSaveAction= true; private boolean isConfigured = false; - + // line number ruler support private IPropertyChangeListener fPreferenceChangeListener; private boolean fShowLineNumber=false; @@ -454,14 +454,14 @@ public class MergeSourceViewer implements ISelectionChangedListener, fSourceViewer= sourceViewer; fResourceBundle= bundle; fContainer = container; - + MenuManager menu= new MenuManager(); menu.setRemoveAllWhenShown(true); menu.addMenuListener(this); StyledText te= getSourceViewer().getTextWidget(); te.setMenu(menu.createContextMenu(te)); fContainer.registerContextMenu(menu, getSourceViewer()); - + // for listening to editor show/hide line number preference value fPreferenceChangeListener= new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { @@ -473,7 +473,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, if(fShowLineNumber){ updateLineNumberRuler(); } - + IOperationHistory history = getHistory(); if (history != null) history.addOperationHistoryListener(this); @@ -481,22 +481,22 @@ public class MergeSourceViewer implements ISelectionChangedListener, // don't add save when in a dialog, IWorkbenchPart is null in dialog containers fAddSaveAction = fContainer.getWorkbenchPart() != null; } - + public void rememberDocument(IDocument doc) { // if (doc != null && fRememberedDocument != null) { // System.err.println("MergeSourceViewer.rememberDocument: fRememberedDocument != null: shouldn't happen"); //$NON-NLS-1$ // } fRememberedDocument= doc; } - + public IDocument getRememberedDocument() { return fRememberedDocument; } - + public void hideSaveAction() { fAddSaveAction= false; } - + public void setFont(Font font) { StyledText te= getSourceViewer().getTextWidget(); if (te != null) @@ -506,7 +506,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, layoutViewer(); } } - + public void setBackgroundColor(Color color) { StyledText te= getSourceViewer().getTextWidget(); if (te != null) @@ -514,13 +514,13 @@ public class MergeSourceViewer implements ISelectionChangedListener, if (fLineNumberColumn != null) fLineNumberColumn.setBackground(color); } - + public void setForegroundColor(Color color) { StyledText te= getSourceViewer().getTextWidget(); if (te != null) te.setForeground(color); } - + public void setEnabled(boolean enabled) { if (enabled != fEnabled) { fEnabled= enabled; @@ -532,7 +532,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, } } } - + public boolean getEnabled() { return fEnabled; } @@ -540,29 +540,29 @@ public class MergeSourceViewer implements ISelectionChangedListener, public void setRegion(Position region) { fRegion= region; } - + public Position getRegion() { return fRegion; } - + public boolean isControlOkToUse() { StyledText t= getSourceViewer().getTextWidget(); return t != null && !t.isDisposed(); } - + public void setSelection(Position position) { if (position != null) getSourceViewer().setSelectedRange(position.getOffset(), position.getLength()); } - + public void setLineBackground(Position position, Color c) { StyledText t= getSourceViewer().getTextWidget(); if (t != null && !t.isDisposed()) { Point region= new Point(0, 0); getLineRange(position, region); - + region.x-= getDocumentRegionOffset(); - + try { t.setLineBackground(region.x, region.y, c); } catch (IllegalArgumentException ex) { @@ -570,7 +570,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, } } } - + public void resetLineBackground() { StyledText t= getSourceViewer().getTextWidget(); if (t != null && !t.isDisposed()) { @@ -578,7 +578,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, t.setLineBackground(0, lines, null); } } - + /* * Returns number of lines in document region. */ @@ -588,7 +588,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, int length= region.getLength(); if (length == 0) return 0; - + IDocument doc= getSourceViewer().getDocument(); int startLine= 0; int endLine= 0; @@ -604,10 +604,10 @@ public class MergeSourceViewer implements ISelectionChangedListener, } catch(BadLocationException ex) { // silently ignored } - + return endLine-startLine+1; } - + public int getViewportLines() { StyledText te= getSourceViewer().getTextWidget(); Rectangle clArea= te.getClientArea(); @@ -623,7 +623,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, return clArea.height; return 0; } - + /* * Returns lines */ @@ -639,7 +639,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, } return 0; } - + public int getVerticalScrollOffset() { StyledText st= getSourceViewer().getTextWidget(); int lineHeight= st.getLineHeight(); @@ -651,27 +651,27 @@ public class MergeSourceViewer implements ISelectionChangedListener, * Starting line number is 0 based. */ public Point getLineRange(Position p, Point region) { - + IDocument doc= getSourceViewer().getDocument(); - + if (p == null || doc == null) { region.x= 0; region.y= 0; return region; } - + int start= p.getOffset(); int length= p.getLength(); - + int startLine= 0; try { startLine= doc.getLineOfOffset(start); } catch (BadLocationException e) { // silently ignored } - + int lineCount= 0; - + if (length == 0) { // // if range length is 0 and if range starts a new line // try { @@ -681,7 +681,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, // } catch (BadLocationException e) { // lines--; // } - + } else { int endLine= 0; try { @@ -691,12 +691,12 @@ public class MergeSourceViewer implements ISelectionChangedListener, } lineCount= endLine-startLine+1; } - + region.x= startLine; region.y= lineCount; return region; } - + /* * Scroll TextPart to the given line. */ @@ -715,11 +715,11 @@ public class MergeSourceViewer implements ISelectionChangedListener, getSourceViewer().setTopIndex(line + getDocumentRegionOffset()); } } - + public void addAction(String actionId, MergeViewerAction action) { fActions.put(actionId, action); } - + public IAction getAction(String actionId) { IAction action= (IAction) fActions.get(actionId); if (action == null) { @@ -732,11 +732,11 @@ public class MergeSourceViewer implements ISelectionChangedListener, getSourceViewer().addTextListener(this); if (mva.isSelectionDependent()) getSourceViewer().addSelectionChangedListener(this); - + Utilities.initAction(action, fResourceBundle, "action." + actionId + "."); //$NON-NLS-1$ //$NON-NLS-2$ } addAction(actionId, action); - + } if (action instanceof MergeViewerAction) { MergeViewerAction mva = (MergeViewerAction) action; @@ -745,7 +745,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, } return action; } - + protected IAction createAction(String actionId) { if (UNDO_ID.equals(actionId)) return new TextOperationAction(ITextOperationTarget.UNDO, IWorkbenchCommandConstants.EDIT_UNDO, true, false, true); @@ -763,7 +763,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, return new TextOperationAction(ITextOperationTarget.SELECT_ALL, IWorkbenchCommandConstants.EDIT_SELECT_ALL, false, false, false); return null; } - + public void selectionChanged(SelectionChangedEvent event) { Iterator e= fActions.values().iterator(); while (e.hasNext()) { @@ -775,7 +775,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, } } } - + public void textChanged(TextEvent event) { updateContentDependantActions(); } @@ -791,12 +791,12 @@ public class MergeSourceViewer implements ISelectionChangedListener, } } } - + /* * Allows the viewer to add menus and/or tools to the context menu. */ public void menuAboutToShow(IMenuManager menu) { - + menu.add(new Separator("undo")); //$NON-NLS-1$ addMenu(menu, UNDO_ID); addMenu(menu, REDO_ID); @@ -804,7 +804,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, if (fAddSaveAction) addSave(menu); menu.add(new Separator("file")); //$NON-NLS-1$ - + menu.add(new Separator("ccp")); //$NON-NLS-1$ addMenu(menu, CUT_ID); addMenu(menu, COPY_ID); @@ -816,32 +816,32 @@ public class MergeSourceViewer implements ISelectionChangedListener, addMenu(menu, CHANGE_ENCODING_ID); menu.add(new Separator("find")); //$NON-NLS-1$ addMenu(menu, FIND_ID); - + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - + menu.add(new Separator("text")); //$NON-NLS-1$ for (Iterator iterator = textActions.iterator(); iterator.hasNext();) { IAction action = (IAction) iterator.next(); menu.add(action); } - + menu.add(new Separator("rest")); //$NON-NLS-1$ - + // update all actions // to get undo redo right updateActions(); } - + private void addMenu(IMenuManager menu, String actionId) { IAction action= getAction(actionId); if (action != null) menu.add(action); } - + private void addSave(IMenuManager menu) { ICommandService commandService = fContainer.getWorkbenchPart().getSite().getService(ICommandService.class); final Command command= commandService.getCommand(IWorkbenchCommandConstants.FILE_SAVE); - + final IHandler handler = command.getHandler(); if (handler != null) { if (fSaveContributionItem == null) { @@ -867,12 +867,12 @@ public class MergeSourceViewer implements ISelectionChangedListener, getSourceViewer().removeTextListener(this); getSourceViewer().removeSelectionChangedListener(this); EditorsUI.getPreferenceStore().removePropertyChangeListener(fPreferenceChangeListener); - + IOperationHistory history = getHistory(); if (history != null) history.removeOperationHistoryListener(this); } - + /** * update all actions independent of their type * @@ -893,14 +893,14 @@ public class MergeSourceViewer implements ISelectionChangedListener, } } } - + public void configure(SourceViewerConfiguration configuration) { if (isConfigured ) getSourceViewer().unconfigure(); isConfigured = true; getSourceViewer().configure(configuration); } - + /** * specific implementation to support a vertical ruler * @param x @@ -915,15 +915,15 @@ public class MergeSourceViewer implements ISelectionChangedListener, getSourceViewer().getTextWidget().setBounds(x, y, width, height); } } - + /** * handle show/hide line numbers from editor preferences * @param event */ protected void handlePropertyChangeEvent(PropertyChangeEvent event) { - + String key= event.getProperty(); - + if(key.equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)){ boolean b= EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER); if (b != fShowLineNumber){ @@ -963,17 +963,17 @@ public class MergeSourceViewer implements ISelectionChangedListener, fLineNumberColumn.redraw(); } } - + private void layoutViewer() { Control parent= getSourceViewer().getControl(); if (parent instanceof Composite && !parent.isDisposed()) ((Composite) parent).layout(true); } - + private ISharedTextColors getSharedColors() { return EditorsUI.getSharedTextColors(); } - + private RGB getColorFromStore(IPreferenceStore store, String key) { RGB rgb= null; if (store.contains(key)) { @@ -991,7 +991,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, private void toggleLineNumberRuler() { fShowLineNumber=!fShowLineNumber; - + updateLineNumberRuler(); } @@ -1006,7 +1006,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, public void addAction(String id, IAction action) { fActions.put(id, action); } - + private IOperationHistory getHistory() { if (PlatformUI.getWorkbench() == null) { return null; @@ -1034,14 +1034,14 @@ public class MergeSourceViewer implements ISelectionChangedListener, return ((IUndoManagerExtension)undoManager).getUndoContext(); return null; } - + /** * @return the wrapped viewer */ public SourceViewer getSourceViewer() { return fSourceViewer; } - + public Object getAdapter(Class adapter) { if (adapter == ITextEditor.class) { return new TextEditorAdapter(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java index 0ffcebb0e..99f9c8410 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java @@ -15,11 +15,11 @@ import org.eclipse.jface.action.Action; public abstract class MergeViewerAction extends Action implements IUpdate { - + private boolean fMutable; private boolean fSelection; private boolean fContent; - + public MergeViewerAction(boolean mutable, boolean selection, boolean content) { fMutable= mutable; fSelection= selection; @@ -29,15 +29,15 @@ public abstract class MergeViewerAction extends Action implements IUpdate { public boolean isSelectionDependent() { return fSelection; } - + public boolean isContentDependent() { return fContent; } - + public boolean isEditableDependent() { return fMutable; } - + public void update() { // empty default implementation } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java index 66d55b4c7..4a90f1906 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java @@ -21,56 +21,56 @@ import org.eclipse.swt.graphics.Image; * e.g. a <code>DiffNode</code>. */ public class MergeViewerContentProvider implements IMergeViewerContentProvider { - + public static final char ANCESTOR_CONTRIBUTOR = 'A'; public static final char RIGHT_CONTRIBUTOR = 'R'; public static final char LEFT_CONTRIBUTOR = 'L'; - + private CompareConfiguration fCompareConfiguration; private String fAncestorError; private String fLeftError; private String fRightError; - + public MergeViewerContentProvider(CompareConfiguration cc) { fCompareConfiguration= cc; } - + private boolean hasError() { return fAncestorError != null || fLeftError != null || fRightError != null; } - + public void dispose() { // empty default implementation } - + public void inputChanged(Viewer v, Object o1, Object o2) { // we are not interested since we have no state } - + //---- ancestor - + public void setAncestorError(String errorMessage) { fAncestorError= errorMessage; } - + public String getAncestorLabel(Object element) { if (fAncestorError != null) return fAncestorError; return fCompareConfiguration.getAncestorLabel(element); } - + public Image getAncestorImage(Object element) { if (fAncestorError != null) return null; return fCompareConfiguration.getAncestorImage(element); } - + public Object getAncestorContent(Object element) { if (element instanceof ICompareInput) return ((ICompareInput) element).getAncestor(); return null; } - + public boolean showAncestor(Object element) { if (element instanceof ICompareInput) return true; // fix for #45239: Show ancestor for incoming and outgoing changes @@ -79,29 +79,29 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider { } //---- left - + public void setLeftError(String errorMessage) { fLeftError= errorMessage; } - + public String getLeftLabel(Object element) { if (fLeftError != null) return fLeftError; return fCompareConfiguration.getLeftLabel(element); } - + public Image getLeftImage(Object element) { if (fLeftError != null) return null; return fCompareConfiguration.getLeftImage(element); } - - public Object getLeftContent(Object element) { + + public Object getLeftContent(Object element) { if (element instanceof ICompareInput) return ((ICompareInput) element).getLeft(); return null; } - + public boolean isLeftEditable(Object element) { if (hasError()) return false; @@ -134,34 +134,34 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider { ((ResourceCompareInput.MyDiffNode)node).fireChange(); } else { node.copy(false); - } + } } } - + //---- right - + public void setRightError(String errorMessage) { fRightError= errorMessage; } - + public String getRightLabel(Object element) { if (fRightError != null) return fRightError; return fCompareConfiguration.getRightLabel(element); } - + public Image getRightImage(Object element) { if (fRightError != null) return null; return fCompareConfiguration.getRightImage(element); } - + public Object getRightContent(Object element) { if (element instanceof ICompareInput) return ((ICompareInput) element).getRight(); return null; } - + public boolean isRightEditable(Object element) { if (hasError()) return false; @@ -177,7 +177,7 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider { } return false; } - + public void saveRightContent(Object element, byte[] bytes) { if (element instanceof ICompareInput) { ICompareInput node= (ICompareInput) element; @@ -194,7 +194,7 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider { ((ResourceCompareInput.MyDiffNode)node).fireChange(); } else { node.copy(true); - } + } } } } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NavigationEndDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NavigationEndDialog.java index af56d2a98..0cb023fad 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NavigationEndDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NavigationEndDialog.java @@ -16,7 +16,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.*; public class NavigationEndDialog extends MessageDialogWithToggle { - + private final String[][] labelsAndValues; private RadioGroupFieldEditor editor; @@ -27,7 +27,7 @@ public class NavigationEndDialog extends MessageDialogWithToggle { CompareMessages.NavigationEndDialog_0, false); this.labelsAndValues = labelsAndValues; } - + protected Control createCustomArea(Composite parent) { editor = new RadioGroupFieldEditor(ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL, CompareMessages.NavigationEndDialog_1, 1, labelsAndValues, @@ -37,7 +37,7 @@ public class NavigationEndDialog extends MessageDialogWithToggle { editor.load(); return parent; } - + protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { editor.store(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java index bdb26d0fd..a81ef156a 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java @@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Composite; /** - * Class which allows content merge viewer to provide a structure viewer that can be used in the outline + * Class which allows content merge viewer to provide a structure viewer that can be used in the outline * view. */ public abstract class OutlineViewerCreator { @@ -28,9 +28,9 @@ public abstract class OutlineViewerCreator { * Property constant that identifies the input of the outline view. */ public static final String PROP_INPUT = "org.eclipse.compare.OutlineInput"; //$NON-NLS-1$ - + private ListenerList listeners = new ListenerList(ListenerList.IDENTITY); - + /** * Method called by the editor to create a structure viewer for the current content merge viewer. * @param oldViewer the current viewer that is being used to show the structure @@ -41,9 +41,9 @@ public abstract class OutlineViewerCreator { */ public abstract Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent, CompareConfiguration configuration); - + public abstract boolean hasViewerFor(Object input); - + public void addPropertyChangeListener(IPropertyChangeListener listener) { listeners.add(listener); } @@ -51,7 +51,7 @@ public abstract class OutlineViewerCreator { public void removePropertyChangeListener(IPropertyChangeListener listener) { listeners.remove(listener); } - + public void fireInputChange(Object oldInput, Object newInput) { Object[] list = listeners.getListeners(); final PropertyChangeEvent event = new PropertyChangeEvent(this, PROP_INPUT, oldInput, newInput); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java index f0e7320a2..afc30e194 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java @@ -19,58 +19,58 @@ import org.eclipse.jface.util.PropertyChangeEvent; * An overlaying preference store. */ public class OverlayPreferenceStore implements IPreferenceStore { - - + + public static final class TypeDescriptor { private TypeDescriptor() { // nothing to do } } - + public static final TypeDescriptor BOOLEAN= new TypeDescriptor(); public static final TypeDescriptor DOUBLE= new TypeDescriptor(); public static final TypeDescriptor FLOAT= new TypeDescriptor(); public static final TypeDescriptor INT= new TypeDescriptor(); public static final TypeDescriptor LONG= new TypeDescriptor(); public static final TypeDescriptor STRING= new TypeDescriptor(); - + public static class OverlayKey { - + TypeDescriptor fDescriptor; String fKey; - + public OverlayKey(TypeDescriptor descriptor, String key) { fDescriptor= descriptor; fKey= key; } } - + private class PropertyListener implements IPropertyChangeListener { - + /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { OverlayKey key= findOverlayKey(event.getProperty()); if (key != null) - propagateProperty(fParent, key, fStore); + propagateProperty(fParent, key, fStore); } } - - + + private IPreferenceStore fParent; private IPreferenceStore fStore; private OverlayKey[] fOverlayKeys; - + private PropertyListener fPropertyListener; - - + + public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { fParent= parent; fOverlayKeys= overlayKeys; fStore= new PreferenceStore(); } - + private OverlayKey findOverlayKey(String key) { for (int i= 0; i < fOverlayKeys.length; i++) { if (fOverlayKeys[i].fKey.equals(key)) @@ -78,41 +78,41 @@ public class OverlayPreferenceStore implements IPreferenceStore { } return null; } - + private boolean covers(String key) { return (findOverlayKey(key) != null); } - + private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { - + if (orgin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) target.setToDefault(key.fKey); return; } - + TypeDescriptor d= key.fDescriptor; if (BOOLEAN == d) { - + boolean originValue= orgin.getBoolean(key.fKey); boolean targetValue= target.getBoolean(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); - + } else if (DOUBLE == d) { - + double originValue= orgin.getDouble(key.fKey); double targetValue= target.getDouble(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); - + } else if (FLOAT == d) { - + float originValue= orgin.getFloat(key.fKey); float targetValue= target.getFloat(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); - + } else if (INT == d) { int originValue= orgin.getInt(key.fKey); @@ -136,97 +136,97 @@ public class OverlayPreferenceStore implements IPreferenceStore { } } - + public void propagate() { for (int i= 0; i < fOverlayKeys.length; i++) propagateProperty(fStore, fOverlayKeys[i], fParent); } - + private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { TypeDescriptor d= key.fDescriptor; if (BOOLEAN == d) { - + if (forceInitialization) target.setValue(key.fKey, true); target.setValue(key.fKey, orgin.getBoolean(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); - + } else if (DOUBLE == d) { - + if (forceInitialization) target.setValue(key.fKey, 1.0D); target.setValue(key.fKey, orgin.getDouble(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); - + } else if (FLOAT == d) { - + if (forceInitialization) target.setValue(key.fKey, 1.0F); target.setValue(key.fKey, orgin.getFloat(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); - + } else if (INT == d) { - + if (forceInitialization) target.setValue(key.fKey, 1); target.setValue(key.fKey, orgin.getInt(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); - + } else if (LONG == d) { - + if (forceInitialization) target.setValue(key.fKey, 1L); target.setValue(key.fKey, orgin.getLong(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); - + } else if (STRING == d) { - + if (forceInitialization) target.setValue(key.fKey, "1"); //$NON-NLS-1$ target.setValue(key.fKey, orgin.getString(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); - + } } - + public void load() { for (int i= 0; i < fOverlayKeys.length; i++) loadProperty(fParent, fOverlayKeys[i], fStore, true); } - + public void loadDefaults() { for (int i= 0; i < fOverlayKeys.length; i++) setToDefault(fOverlayKeys[i].fKey); } - + public void start() { if (fPropertyListener == null) { fPropertyListener= new PropertyListener(); fParent.addPropertyChangeListener(fPropertyListener); } } - + public void stop() { if (fPropertyListener != null) { fParent.removePropertyChangeListener(fPropertyListener); fPropertyListener= null; } } - + /* * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener) */ public void addPropertyChangeListener(IPropertyChangeListener listener) { fStore.addPropertyChangeListener(listener); } - + /* * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener) */ public void removePropertyChangeListener(IPropertyChangeListener listener) { fStore.removePropertyChangeListener(listener); } - + /* * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object) */ @@ -240,7 +240,7 @@ public class OverlayPreferenceStore implements IPreferenceStore { public boolean contains(String name) { return fStore.contains(name); } - + /* * @see IPreferenceStore#getBoolean(String) */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java index 3c4277f15..306e591cc 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithEditionAction.java @@ -12,7 +12,7 @@ package org.eclipse.compare.internal; public class ReplaceWithEditionAction extends EditionAction { - + public ReplaceWithEditionAction() { super(true, "org.eclipse.compare.internal.ReplaceWithEditionAction"); //$NON-NLS-1$ fHelpContextId= ICompareContextIds.REPLACE_WITH_EDITION_DIALOG; diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java index 67ecb9783..73b112404 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ReplaceWithPreviousEditionAction.java @@ -12,7 +12,7 @@ package org.eclipse.compare.internal; public class ReplaceWithPreviousEditionAction extends EditionAction { - + public ReplaceWithPreviousEditionAction() { super(true, "org.eclipse.compare.internal.ReplaceWithEditionAction"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java index e65639195..f5dfa9f9a 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java @@ -33,7 +33,7 @@ public abstract class ResizableDialog extends Dialog { private static final String Y= "y"; //$NON-NLS-1$ private static final String WIDTH= "width"; //$NON-NLS-1$ private static final String HEIGHT= "height"; //$NON-NLS-1$ - + protected ResourceBundle fBundle; private Rectangle fNewBounds; private IDialogSettings fSettings; @@ -43,12 +43,12 @@ public abstract class ResizableDialog extends Dialog { public ResizableDialog(Shell parent, ResourceBundle bundle) { super(parent); setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX); - + fBundle= bundle; - + fSettings= CompareUIPlugin.getDefault().getDialogSettings(); } - + public void setHelpContextId(String contextId) { fContextId= contextId; } @@ -61,12 +61,12 @@ public abstract class ResizableDialog extends Dialog { if (fContextId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, fContextId); } - + protected Point getInitialSize() { - + int width= 0; int height= 0; - + final Shell s= getShell(); if (s != null) { s.addControlListener( @@ -80,7 +80,7 @@ public abstract class ResizableDialog extends Dialog { } ); } - + IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); if (bounds == null) { if (fBundle != null) { @@ -117,14 +117,14 @@ public abstract class ResizableDialog extends Dialog { } catch (NumberFormatException e) { height= 500; } - } - + } + return new Point(width, height); } - + protected Point getInitialLocation(Point initialSize) { Point loc= super.getInitialLocation(initialSize); - + IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); if (bounds != null) { try { @@ -140,7 +140,7 @@ public abstract class ResizableDialog extends Dialog { } return loc; } - + public boolean close() { boolean closed= super.close(); if (closed && fNewBounds != null) diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java index 8c0807f2f..c6ebbf8b4 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java @@ -60,9 +60,9 @@ import com.ibm.icu.text.MessageFormat; * A two-way or three-way compare for arbitrary IResources. */ class ResourceCompareInput extends CompareEditorInput { - + private static final boolean NORMALIZE_CASE= true; - + private boolean fThreeWay= false; private Object fRoot; private IStructureComparator fAncestor; @@ -73,14 +73,14 @@ class ResourceCompareInput extends CompareEditorInput { private IResource fRightResource; private DiffTreeViewer fDiffViewer; private IAction fOpenAction; - + class MyDiffNode extends DiffNode { - + private boolean fDirty= false; private ITypedElement fLastId; private String fLastName; - - + + public MyDiffNode(IDiffContainer parent, int description, ITypedElement ancestor, ITypedElement left, ITypedElement right) { super(parent, description, ancestor, left, right); } @@ -101,7 +101,7 @@ class ResourceCompareInput extends CompareEditorInput { return '<' + fLastName + '>'; return fLastName; } - + public ITypedElement getId() { ITypedElement id= super.getId(); if (id == null) @@ -110,7 +110,7 @@ class ResourceCompareInput extends CompareEditorInput { return id; } } - + static class FilteredBufferedResourceNode extends BufferedResourceNode { FilteredBufferedResourceNode(IResource resource) { super(resource); @@ -122,18 +122,18 @@ class ResourceCompareInput extends CompareEditorInput { return new FilteredBufferedResourceNode(child); } } - + /* * Creates an compare editor input for the given selection. */ ResourceCompareInput(CompareConfiguration config) { super(config); } - + public Viewer createDiffViewer(Composite parent) { fDiffViewer= new DiffTreeViewer(parent, getCompareConfiguration()) { protected void fillContextMenu(IMenuManager manager) { - + if (fOpenAction == null) { fOpenAction= new Action() { public void run() { @@ -142,7 +142,7 @@ class ResourceCompareInput extends CompareEditorInput { }; Utilities.initAction(fOpenAction, getBundle(), "action.CompareContents."); //$NON-NLS-1$ } - + boolean enable= false; ISelection selection= getSelection(); if (selection instanceof IStructuredSelection) { @@ -158,9 +158,9 @@ class ResourceCompareInput extends CompareEditorInput { } } fOpenAction.setEnabled(enable); - + manager.add(fOpenAction); - + super.fillContextMenu(manager); } }; @@ -172,9 +172,9 @@ class ResourceCompareInput extends CompareEditorInput { IResource ancestorResource; IResource leftResource; IResource rightResource; - + private Button[] buttons; - + public SelectAncestorDialog(Shell parentShell, IResource[] theResources) { super(parentShell, CompareMessages.SelectAncestorDialog_title, null, CompareMessages.SelectAncestorDialog_message, @@ -183,7 +183,7 @@ class ResourceCompareInput extends CompareEditorInput { IDialogConstants.CANCEL_LABEL }, 0); this.theResources = theResources; } - + protected Control createCustomArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); @@ -206,7 +206,7 @@ class ResourceCompareInput extends CompareEditorInput { leftResource = theResources[i == 0 ? 1 : 0]; rightResource = theResources[i == 2 ? 1 : 2]; } - + private SelectionListener selectionListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button selectedButton = (Button) e.widget; @@ -231,14 +231,14 @@ class ResourceCompareInput extends CompareEditorInput { IResource[] selection= Utilities.getResources(s); fThreeWay= selection.length == 3; - + if (fThreeWay) { SelectAncestorDialog dialog = new SelectAncestorDialog(shell, selection); int code = dialog.open(); if (code != Window.OK) return false; - + fAncestorResource= dialog.ancestorResource; fAncestor= getStructure(fAncestorResource); fLeftResource= dialog.leftResource; @@ -290,23 +290,23 @@ class ResourceCompareInput extends CompareEditorInput { * Returns true if compare can be executed for the given selection. */ public boolean isEnabled(ISelection s) { - + IResource[] selection= Utilities.getResources(s); if (selection.length < 2 || selection.length > 3) return false; boolean threeWay= selection.length == 3; - + if (threeWay) // It only makes sense if they're all mutually comparable. // If not, the user should compare two of them. return comparable(selection[0], selection[1]) && comparable(selection[0], selection[2]) && comparable(selection[1], selection[2]); - + return comparable(selection[0], selection[1]); } - + /** * Initializes the images in the compare configuration. */ @@ -320,27 +320,27 @@ class ResourceCompareInput extends CompareEditorInput { cc.setRightLabel(buildLabel(fRightResource)); cc.setRightImage(CompareUIPlugin.getImage(fRightResource)); } - if (fThreeWay && fAncestorResource != null) { + if (fThreeWay && fAncestorResource != null) { cc.setAncestorLabel(buildLabel(fAncestorResource)); cc.setAncestorImage(CompareUIPlugin.getImage(fAncestorResource)); } } - + /* * Returns true if both resources are either structured or unstructured. */ private boolean comparable(IResource c1, IResource c2) { return hasStructure(c1) == hasStructure(c2); } - + /* * Returns true if the given argument has a structure. */ private boolean hasStructure(IResource input) { - + if (input instanceof IContainer) return true; - + if (input instanceof IFile) { IFile file= (IFile) input; String type= file.getFileExtension(); @@ -349,20 +349,20 @@ class ResourceCompareInput extends CompareEditorInput { return "JAR".equals(type) || "ZIP".equals(type); //$NON-NLS-2$ //$NON-NLS-1$ } } - + return false; } - + /* * Creates a <code>IStructureComparator</code> for the given input. * Returns <code>null</code> if no <code>IStructureComparator</code> * can be found for the <code>IResource</code>. */ private IStructureComparator getStructure(IResource input) { - + if (input instanceof IContainer) return new FilteredBufferedResourceNode(input); - + if (input instanceof IFile) { IStructureComparator rn= new FilteredBufferedResourceNode(input); IFile file= (IFile) input; @@ -373,57 +373,57 @@ class ResourceCompareInput extends CompareEditorInput { } return null; } - + /* * Performs a two-way or three-way diff on the current selection. */ public Object prepareInput(IProgressMonitor pm) throws InvocationTargetException { - + try { - // fix for PR 1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty + // fix for PR 1GFMLFB: ITPUI:WIN2000 - files that are out of sync with the file system appear as empty fLeftResource.refreshLocal(IResource.DEPTH_INFINITE, pm); fRightResource.refreshLocal(IResource.DEPTH_INFINITE, pm); if (fThreeWay && fAncestorResource != null) fAncestorResource.refreshLocal(IResource.DEPTH_INFINITE, pm); - // end fix - + // end fix + pm.beginTask(Utilities.getString("ResourceCompare.taskName"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ String leftLabel= fLeftResource.getName(); String rightLabel= fRightResource.getName(); - + String title; - if (fThreeWay) { + if (fThreeWay) { String format= Utilities.getString("ResourceCompare.threeWay.title"); //$NON-NLS-1$ String ancestorLabel= fAncestorResource.getName(); - title= MessageFormat.format(format, ancestorLabel, leftLabel, rightLabel); + title= MessageFormat.format(format, ancestorLabel, leftLabel, rightLabel); } else { String format= Utilities.getString("ResourceCompare.twoWay.title"); //$NON-NLS-1$ title= MessageFormat.format(format, leftLabel, rightLabel); } setTitle(title); - + Differencer d= new Differencer() { protected Object visit(Object parent, int description, Object ancestor, Object left, Object right) { return new MyDiffNode((IDiffContainer) parent, description, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right); } }; - + fRoot= d.findDifferences(fThreeWay, pm, null, fAncestor, fLeft, fRight); return fRoot; - + } catch (CoreException ex) { throw new InvocationTargetException(ex); } finally { pm.done(); } } - + public String getToolTipText() { if (fLeftResource != null && fRightResource != null) { String leftLabel= fLeftResource.getFullPath().makeRelative().toString(); - String rightLabel= fRightResource.getFullPath().makeRelative().toString(); - if (fThreeWay) { + String rightLabel= fRightResource.getFullPath().makeRelative().toString(); + if (fThreeWay) { String format= Utilities.getString("ResourceCompare.threeWay.tooltip"); //$NON-NLS-1$ String ancestorLabel= fAncestorResource.getFullPath().makeRelative().toString(); return MessageFormat.format(format, ancestorLabel, leftLabel, rightLabel); @@ -434,7 +434,7 @@ class ResourceCompareInput extends CompareEditorInput { // fall back return super.getToolTipText(); } - + private String buildLabel(IResource r) { // for a linked resource in a hidden project use its local file system location if (r.isLinked() && r.getProject().isHidden()) @@ -444,7 +444,7 @@ class ResourceCompareInput extends CompareEditorInput { return n.substring(1); return n; } - + public void saveChanges(IProgressMonitor pm) throws CoreException { super.saveChanges(pm); if (fRoot instanceof DiffNode) { @@ -452,24 +452,24 @@ class ResourceCompareInput extends CompareEditorInput { commit(pm, (DiffNode) fRoot); } finally { if (fDiffViewer != null) - fDiffViewer.refresh(); + fDiffViewer.refresh(); setDirty(false); } } } - + /* * Recursively walks the diff tree and commits all changes. */ private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException { - - if (node instanceof MyDiffNode) + + if (node instanceof MyDiffNode) ((MyDiffNode)node).clearDirty(); - + ITypedElement left= node.getLeft(); if (left instanceof BufferedResourceNode) ((BufferedResourceNode) left).commit(pm); - + ITypedElement right= node.getRight(); if (right instanceof BufferedResourceNode) ((BufferedResourceNode) right).commit(pm); @@ -483,7 +483,7 @@ class ResourceCompareInput extends CompareEditorInput { } } } - + /* (non Javadoc) * see IAdaptable.getAdapter */ @@ -504,11 +504,11 @@ class ResourceCompareInput extends CompareEditorInput { } return super.getAdapter(adapter); } - + private void collectDirtyResources(Object o, Set collector) { if (o instanceof DiffNode) { DiffNode node= (DiffNode) o; - + ITypedElement left= node.getLeft(); if (left instanceof BufferedResourceNode) { BufferedResourceNode bn= (BufferedResourceNode) left; @@ -528,7 +528,7 @@ class ResourceCompareInput extends CompareEditorInput { collector.add(resource); } } - + IDiffElement[] children= node.getChildren(); if (children != null) { for (int i= 0; i < children.length; i++) { @@ -539,13 +539,13 @@ class ResourceCompareInput extends CompareEditorInput { } } } - + private static String normalizeCase(String s) { if (NORMALIZE_CASE && s != null) return s.toUpperCase(); return s; } - + public boolean canRunAsJob() { return true; } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java index 02ce74f42..ff56bd8e5 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java @@ -58,7 +58,7 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction { fNeedsPainters = needsPainters; synchronizeWithPreference(); } - + /* * (non-Javadoc) * @see org.eclipse.compare.internal.TextEditorPropertyAction#synchronizeWithPreference() @@ -115,13 +115,13 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction { } return true; } - + private synchronized Map getPainters() { if (fPainters == null) fPainters = new HashMap(); return fPainters; } - + private void showWhitespace() { if (isWhitespaceShowing) return; @@ -147,7 +147,7 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction { isWhitespaceShowing = true; } } - + private void hideWhitespace() { Map painters = getPainters(); for (Iterator iterator = painters.keySet().iterator(); iterator.hasNext();) { @@ -161,5 +161,5 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction { painters.clear(); isWhitespaceShowing = false; } - + } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java index 12f86fc1b..64d4c6da7 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java @@ -23,20 +23,20 @@ import org.eclipse.compare.structuremergeviewer.ICompareInput; public class SimpleTextViewer extends AbstractViewer { - + private SourceViewer fSourceViewer; private ICompareInput fInput; - - + + SimpleTextViewer(Composite parent) { fSourceViewer= new SourceViewer(parent, null, SWT.H_SCROLL | SWT.V_SCROLL); fSourceViewer.setEditable(false); } - + public Control getControl() { return fSourceViewer.getTextWidget(); } - + public void setInput(Object input) { if (input instanceof IStreamContentAccessor) { fSourceViewer.setDocument(new Document(getString(input))); @@ -46,13 +46,13 @@ public class SimpleTextViewer extends AbstractViewer { fSourceViewer.setDocument(new Document(getString(left))); } } - + public Object getInput() { return fInput; } - + private String getString(Object input) { - + if (input instanceof IStreamContentAccessor) { try { return Utilities.readString((IStreamContentAccessor) input); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java index 3b6a1944a..551a2532a 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java @@ -19,12 +19,12 @@ import org.eclipse.compare.structuremergeviewer.IStructureCreator; * A factory proxy for creating a StructureCreator. */ public class StructureCreatorDescriptor { - + private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - + private IConfigurationElement fElement; - + /* * Creates a new sorter node with the given configuration element. */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java index 07ed78ab0..166621276 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TabFolderLayout.java @@ -22,7 +22,7 @@ public class TabFolderLayout extends Layout { protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) return new Point(wHint, hHint); - + Control [] children = composite.getChildren (); int count = children.length; int maxWidth = 0, maxHeight = 0; @@ -32,19 +32,19 @@ public class TabFolderLayout extends Layout { maxWidth = Math.max (maxWidth, pt.x); maxHeight = Math.max (maxHeight, pt.y); } - + if (wHint != SWT.DEFAULT) maxWidth= wHint; if (hHint != SWT.DEFAULT) maxHeight= hHint; - - return new Point(maxWidth, maxHeight); - + + return new Point(maxWidth, maxHeight); + } - + protected void layout (Composite composite, boolean flushCache) { Rectangle rect= composite.getClientArea(); - + Control[] children = composite.getChildren(); for (int i = 0; i < children.length; i++) { children[i].setBounds(rect); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java index bf83fd27a..2d4b97189 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java @@ -22,7 +22,7 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL private final MergeSourceViewer[] viewers; private final String preferenceKey; private IPreferenceStore store; - + public TextEditorPropertyAction(String label, MergeSourceViewer[] viewers, String preferenceKey) { super(label, IAction.AS_CHECK_BOX); this.viewers = viewers; @@ -44,13 +44,13 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL public MergeSourceViewer[] getViewers() { return viewers; } - + public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(getPreferenceKey())) { synchronizeWithPreference(); } } - + protected void synchronizeWithPreference() { boolean checked = false; if (store != null) { @@ -65,18 +65,18 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL public String getPreferenceKey() { return preferenceKey; } - + public void run() { toggleState(isChecked()); if (store != null) store.setValue(getPreferenceKey(), isChecked()); } - + public void dispose() { if (store != null) store.removePropertyChangeListener(this); } - + /** * @param checked * new state diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java index 5145ef68d..9c6b04971 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java @@ -40,7 +40,7 @@ public class ViewerDescriptor implements IViewerDescriptor { //System.out.println("reused viewer: " + currentViewer.getClass().getName()); return currentViewer; } - + if (fViewerCreator == null) { try { fViewerCreator= (IViewerCreator) fConfiguration.createExecutableExtension(CLASS_ATTRIBUTE); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java index 43670e2e6..55b3a07fe 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java @@ -21,7 +21,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress; * previous location and aded to the end of the queue. */ public class WorkQueue { - + private List runnables = new ArrayList(); public boolean add(IRunnableWithProgress runnable) { diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java index 3582c1b31..614ac02be 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java @@ -34,7 +34,7 @@ public class Worker implements IRunnableWithProgress { private WorkProgressMonitor currentMonitor; private IRunnableWithProgress currentTask; private final String taskName; - + /** * Progress monitor that supports local cancellation of a task. */ @@ -54,11 +54,11 @@ public class Worker implements IRunnableWithProgress { return localCancel || super.isCanceled(); } } - + public Worker(String taskName) { this.taskName = taskName; } - + @Override public void run(IProgressMonitor monitor) { errors.clear(); @@ -98,7 +98,7 @@ public class Worker implements IRunnableWithProgress { private void handleError(Throwable targetException) { errors.add(targetException); } - + public Throwable[] getErrors() { return errors.toArray(new Throwable[errors.size()]); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java index 04f107e9a..d25e52e7a 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkerJob.java @@ -20,7 +20,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress; public class WorkerJob extends Job { private final Worker worker; - + public WorkerJob(String name) { super(name); worker = new Worker(name); @@ -33,7 +33,7 @@ public class WorkerJob extends Job { schedule(); return result; } - + private IStatus getResult(Worker w) { Throwable[] errors = w.getErrors(); if (errors.length == 0) @@ -47,11 +47,11 @@ public class WorkerJob extends Job { } return new MultiStatus(CompareUIPlugin.PLUGIN_ID, 0, (IStatus[]) statii.toArray(new IStatus[statii.size()]), CompareMessages.WorkerJob_0, null); } - + public boolean shouldRun() { return worker.hasWork(); } - + public void add(IRunnableWithProgress runnable) { worker.add(runnable); schedule(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java index 43738a7a9..40c0fc6e7 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java @@ -55,27 +55,27 @@ import org.eclipse.compare.structuremergeviewer.Differencer; /** * A document merger manages the differences between two documents - * for either a 2-way or 3-way comparison. + * for either a 2-way or 3-way comparison. * <p> * This class should not have any UI dependencies. */ public class DocumentMerger { private static final String DIFF_RANGE_CATEGORY = CompareUIPlugin.PLUGIN_ID + ".DIFF_RANGE_CATEGORY"; //$NON-NLS-1$ - + /** Selects between smartTokenDiff and mergingTokenDiff */ private static final boolean USE_MERGING_TOKEN_DIFF= false; - + /** if true copying conflicts from one side to other concatenates both sides */ private static final boolean APPEND_CONFLICT= true; - + /** All diffs for calculating scrolling position (includes line ranges without changes) */ private ArrayList fAllDiffs; /** Subset of above: just real differences. */ private ArrayList fChangeDiffs; - + private IDocumentMergerInput fInput; - + /** * Interface that defines that input to the document merge process */ @@ -92,7 +92,7 @@ public class DocumentMerger { CompareConfiguration getCompareConfiguration(); ITokenComparator createTokenComparator(String s); - + boolean isHunkOnLeft(); int getHunkStart(); @@ -103,7 +103,7 @@ public class DocumentMerger { boolean isPatchHunkOk(); } - + public class Diff { /** character range in ancestor document */ Position fAncestorPos; @@ -112,7 +112,7 @@ public class DocumentMerger { /** character range in right document */ Position fRightPos; /** if this is a TokenDiff fParent points to the enclosing LineDiff */ - Diff fParent; + Diff fParent; /** if Diff has been resolved */ boolean fResolved; int fDirection; @@ -129,13 +129,13 @@ public class DocumentMerger { IDocument rightDoc, Position rRange, int rightStart, int rightEnd) { fParent= parent != null ? parent : this; fDirection= dir; - + fLeftPos= createPosition(leftDoc, lRange, leftStart, leftEnd); fRightPos= createPosition(rightDoc, rRange, rightStart, rightEnd); if (ancestorDoc != null) fAncestorPos= createPosition(ancestorDoc, aRange, ancestorStart, ancestorEnd); } - + public Position getPosition(char type) { switch (type) { case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: @@ -147,30 +147,30 @@ public class DocumentMerger { } return null; } - + boolean isInRange(char type, int pos) { Position p= getPosition(type); return (pos >= p.offset) && (pos < (p.offset+p.length)); } - + public String changeType() { boolean leftEmpty= fLeftPos.length == 0; boolean rightEmpty= fRightPos.length == 0; - + if (fDirection == RangeDifference.LEFT) { if (!leftEmpty && rightEmpty) - return CompareMessages.TextMergeViewer_changeType_addition; + return CompareMessages.TextMergeViewer_changeType_addition; if (leftEmpty && !rightEmpty) - return CompareMessages.TextMergeViewer_changeType_deletion; + return CompareMessages.TextMergeViewer_changeType_deletion; } else { if (leftEmpty && !rightEmpty) - return CompareMessages.TextMergeViewer_changeType_addition; + return CompareMessages.TextMergeViewer_changeType_addition; if (!leftEmpty && rightEmpty) - return CompareMessages.TextMergeViewer_changeType_deletion; + return CompareMessages.TextMergeViewer_changeType_deletion; } - return CompareMessages.TextMergeViewer_changeType_change; + return CompareMessages.TextMergeViewer_changeType_change; } - + public Image getImage() { int code= Differencer.CHANGE; switch (fDirection) { @@ -189,27 +189,27 @@ public class DocumentMerger { return getCompareConfiguration().getImage(code); return null; } - + Position createPosition(IDocument doc, Position range, int start, int end) { try { int l= end-start; if (range != null) { int dl= range.length; if (l > dl) - l= dl; + l= dl; } else { int dl= doc.getLength(); if (start+l > dl) l= dl-start; } - + Position p= null; try { p= new Position(start, l); } catch (RuntimeException ex) { p= new Position(0, 0); } - + try { doc.addPosition(DIFF_RANGE_CATEGORY, p); } catch (BadPositionCategoryException ex) { @@ -227,13 +227,13 @@ public class DocumentMerger { fDiffs= new ArrayList<>(); fDiffs.add(d); } - + public boolean isDeleted() { if (fAncestorPos != null && fAncestorPos.isDeleted()) return true; return fLeftPos.isDeleted() || fRightPos.isDeleted(); } - + void setResolved(boolean r) { fResolved= r; if (r) @@ -252,7 +252,7 @@ public class DocumentMerger { } return fResolved; } - + Position getPosition(int contributor) { if (contributor == MergeViewerContentProvider.LEFT_CONTRIBUTOR) return fLeftPos; @@ -262,7 +262,7 @@ public class DocumentMerger { return fAncestorPos; return null; } - + /* * Returns true if given character range overlaps with this Diff. */ @@ -278,7 +278,7 @@ public class DocumentMerger { } return false; } - + public int getMaxDiffHeight() { Point region= new Point(0, 0); int h= getLineRange(getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR), fLeftPos, region).y; @@ -286,19 +286,19 @@ public class DocumentMerger { h= Math.max(h, getLineRange(getDocument(MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR), fAncestorPos, region).y); return Math.max(h, getLineRange(getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR), fRightPos, region).y); } - + public int getAncestorHeight() { - Point region= new Point(0, 0); + Point region= new Point(0, 0); return getLineRange(getDocument(MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR), fAncestorPos, region).y; } public int getLeftHeight() { - Point region= new Point(0, 0); + Point region= new Point(0, 0); return getLineRange(getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR), fLeftPos, region).y; } public int getRightHeight() { - Point region= new Point(0, 0); + Point region= new Point(0, 0); return getLineRange(getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR), fRightPos, region).y; } @@ -345,40 +345,40 @@ public class DocumentMerger { return fDiffs.iterator(); } } - + public DocumentMerger(IDocumentMergerInput input) { this.fInput = input; } - + /** * Perform a two level 2- or 3-way diff. * The first level is based on line comparison, the second level on token comparison. - * @throws CoreException + * @throws CoreException */ public void doDiff() throws CoreException { - + fChangeDiffs= new ArrayList(); IDocument lDoc = getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR); IDocument rDoc = getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); - + if (lDoc == null || rDoc == null) return; - + Position lRegion= getRegion(MergeViewerContentProvider.LEFT_CONTRIBUTOR); Position rRegion= getRegion(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); - + IDocument aDoc = null; Position aRegion= null; if (isThreeWay() && !isIgnoreAncestor()) { aDoc= getDocument(MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR); aRegion= getRegion(MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR); } - + resetPositions(lDoc); resetPositions(rDoc); resetPositions(aDoc); - - boolean ignoreWhiteSpace= isIgnoreWhitespace(); + + boolean ignoreWhiteSpace= isIgnoreWhitespace(); ICompareFilter[] compareFilters = getCompareFilters(); DocLineComparator sright = new DocLineComparator(rDoc, @@ -418,7 +418,7 @@ public class DocumentMerger { monitor.done(); } }; - + RangeDifference[] e= null; try { getCompareConfiguration().getContainer().run(true, true, runnable); @@ -428,8 +428,8 @@ public class DocumentMerger { Diff diff= new Diff(null, RangeDifference.NOCHANGE, aDoc, aRegion, 0, aDoc != null ? aDoc.getLength() : 0, lDoc, lRegion, 0, lDoc.getLength(), - rDoc, rRegion, 0, rDoc.getLength()); - + rDoc, rRegion, 0, rDoc.getLength()); + fAllDiffs = new ArrayList(); fAllDiffs.add(diff); throw new CoreException(new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, CompareMessages.DocumentMerger_1, ex.getTargetException())); @@ -438,8 +438,8 @@ public class DocumentMerger { Diff diff= new Diff(null, RangeDifference.NOCHANGE, aDoc, aRegion, 0, aDoc != null ? aDoc.getLength() : 0, lDoc, lRegion, 0, lDoc.getLength(), - rDoc, rRegion, 0, rDoc.getLength()); - + rDoc, rRegion, 0, rDoc.getLength()); + fAllDiffs = new ArrayList(); fAllDiffs.add(diff); return; @@ -457,17 +457,17 @@ public class DocumentMerger { ArrayList newAllDiffs = new ArrayList(); for (int i= 0; i < e.length; i++) { RangeDifference es= e[i]; - + int ancestorStart= 0; int ancestorEnd= 0; if (sancestor != null) { ancestorStart= sancestor.getTokenStart(es.ancestorStart()); ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); } - + int leftStart= sleft.getTokenStart(es.leftStart()); int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); - + int rightStart= sright.getTokenStart(es.rightStart()); int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength()); @@ -482,32 +482,32 @@ public class DocumentMerger { Diff diff= new Diff(null, es.kind(), aDoc, aRegion, ancestorStart, ancestorEnd, lDoc, lRegion, leftStart, leftEnd, - rDoc, rRegion, rightStart, rightEnd); - + rDoc, rRegion, rightStart, rightEnd); + newAllDiffs.add(diff); // remember all range diffs for scrolling - + if (isPatchHunk()) { if (useChange(diff)) { recordChangeDiff(diff); } } else { if (ignoreWhiteSpace || useChange(es.kind())) { - + // Extract the string for each contributor. String a= null; if (sancestor != null) a= extract2(aDoc, sancestor, es.ancestorStart(), es.ancestorLength()); String s= extract2(lDoc, sleft, es.leftStart(), es.leftLength()); String d= extract2(rDoc, sright, es.rightStart(), es.rightLength()); - + // Indicate whether all contributors are whitespace - if (ignoreWhiteSpace - && (a == null || a.trim().length() == 0) - && s.trim().length() == 0 + if (ignoreWhiteSpace + && (a == null || a.trim().length() == 0) + && s.trim().length() == 0 && d.trim().length() == 0) { diff.fIsWhitespace= true; } - + // If the diff is of interest, record it and generate the token diffs if (useChange(diff)) { recordChangeDiff(diff); @@ -541,31 +541,31 @@ public class DocumentMerger { } public Diff findDiff(char type, int pos) throws CoreException { - + IDocument aDoc= null; IDocument lDoc= getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR); IDocument rDoc= getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); if (lDoc == null || rDoc == null) return null; - + Position aRegion= null; Position lRegion= null; Position rRegion= null; - + boolean threeWay= isThreeWay(); - + if (threeWay && !isIgnoreAncestor()) aDoc= getDocument(MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR); boolean ignoreWhiteSpace= isIgnoreWhitespace(); ICompareFilter[] compareFilters = getCompareFilters(); - DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.RIGHT_CONTRIBUTOR); + DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.RIGHT_CONTRIBUTOR); DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.LEFT_CONTRIBUTOR); DocLineComparator sancestor= null; if (aDoc != null) sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR); - + final Object[] result= new Object[1]; final DocLineComparator sa= sancestor, sl= sleft, sr= sright; IRunnableWithProgress runnable= new IRunnableWithProgress() { @@ -584,7 +584,7 @@ public class DocumentMerger { } }; IProgressService progressService= PlatformUI.getWorkbench().getProgressService(); - + RangeDifference[] e= null; try { progressService.run(true, true, runnable); @@ -592,45 +592,45 @@ public class DocumentMerger { } catch (InvocationTargetException ex) { throw new CoreException(new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, CompareMessages.DocumentMerger_3, ex.getTargetException())); } catch (InterruptedException ex) { - // + // } - + if (e != null) { for (int i= 0; i < e.length; i++) { RangeDifference es= e[i]; - + int kind= es.kind(); - + int ancestorStart= 0; int ancestorEnd= 0; if (sancestor != null) { ancestorStart= sancestor.getTokenStart(es.ancestorStart()); ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); } - + int leftStart= sleft.getTokenStart(es.leftStart()); int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); - + int rightStart= sright.getTokenStart(es.rightStart()); int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength()); - + Diff diff= new Diff(null, kind, aDoc, aRegion, ancestorStart, ancestorEnd, lDoc, lRegion, leftStart, leftEnd, - rDoc, rRegion, rightStart, rightEnd); + rDoc, rRegion, rightStart, rightEnd); if (diff.isInRange(type, pos)) return diff; } } - + return null; } - + private void recordChangeDiff(Diff diff) { fChangeDiffs.add(diff); // here we remember only the real diffs } - + /*private boolean isHunkOnLeft() { return fInput.isHunkOnLeft(); } @@ -678,7 +678,7 @@ public class DocumentMerger { public CompareConfiguration getCompareConfiguration() { return fInput.getCompareConfiguration(); } - + /* * Returns true if kind of change should be shown. */ @@ -698,18 +698,18 @@ public class DocumentMerger { return fInput.isShowPseudoConflicts(); return true; } - + private int getTokenEnd(ITokenComparator tc, int start, int count) { if (count <= 0) return tc.getTokenStart(start); int index= start + count - 1; return tc.getTokenStart(index) + tc.getTokenLength(index); } - + private static int getTokenEnd2(ITokenComparator tc, int start, int length) { return tc.getTokenStart(start + length); } - + /** * Returns the content of lines in the specified range as a String. * This includes the line separators. @@ -722,19 +722,19 @@ public class DocumentMerger { private String extract2(IDocument doc, ITokenComparator tc, int start, int length) { int count= tc.getRangeCount(); if (length > 0 && count > 0) { - -// + +// // int startPos= tc.getTokenStart(start); // int endPos= startPos; -// +// // if (length > 1) // endPos= tc.getTokenStart(start + (length-1)); // endPos+= tc.getTokenLength(start + (length-1)); -// +// int startPos= tc.getTokenStart(start); int endPos; - + if (length == 1) { endPos= startPos + tc.getTokenLength(start); } else { @@ -750,18 +750,18 @@ public class DocumentMerger { } return ""; //$NON-NLS-1$ } - + private static IRegion toRegion(Position position) { if (position != null) return new Region(position.getOffset(), position.getLength()); return null; } - + /* * Performs a "smart" token based 3-way diff on the character range specified by the given baseDiff. * It is "smart" because it tries to minimize the number of token diffs by merging them. */ - private void mergingTokenDiff(Diff baseDiff, + private void mergingTokenDiff(Diff baseDiff, IDocument ancestorDoc, String a, IDocument rightDoc, String d, IDocument leftDoc, String s) { @@ -771,13 +771,13 @@ public class DocumentMerger { sa= createTokenComparator(a); ancestorStart= baseDiff.fAncestorPos.getOffset(); } - - int rightStart= baseDiff.fRightPos.getOffset(); + + int rightStart= baseDiff.fRightPos.getOffset(); ITokenComparator sm= createTokenComparator(d); - + int leftStart= baseDiff.fLeftPos.getOffset(); ITokenComparator sy= createTokenComparator(s); - + RangeDifference[] r= RangeDifferencer.findRanges(sa, sy, sm); for (int i= 0; i < r.length; i++) { RangeDifference es= r[i]; @@ -804,7 +804,7 @@ public class DocumentMerger { } } int end= i; - + // find first diff from left RangeDifference first= null; for (int ii= start; ii < end; ii++) { @@ -814,7 +814,7 @@ public class DocumentMerger { break; } } - + // find first diff from mine RangeDifference last= null; for (int ii= end-1; ii >= start; ii--) { @@ -824,31 +824,31 @@ public class DocumentMerger { break; } } - + if (first != null && last != null) { - + int ancestorStart2= 0; int ancestorEnd2= 0; if (ancestorDoc != null) { ancestorStart2= ancestorStart+sa.getTokenStart(first.ancestorStart()); ancestorEnd2= ancestorStart+getTokenEnd(sa, last.ancestorStart(), last.ancestorLength()); } - + int leftStart2= leftStart+sy.getTokenStart(first.leftStart()); int leftEnd2= leftStart+getTokenEnd(sy, last.leftStart(), last.leftLength()); - + int rightStart2= rightStart+sm.getTokenStart(first.rightStart()); int rightEnd2= rightStart+getTokenEnd(sm, last.rightStart(), last.rightLength()); Diff diff= new Diff(baseDiff, first.kind(), ancestorDoc, null, ancestorStart2, ancestorEnd2, leftDoc, null, leftStart2, leftEnd2, - rightDoc, null, rightStart2, rightEnd2); + rightDoc, null, rightStart2, rightEnd2); diff.fIsToken= true; baseDiff.add(diff); } } } - + /* * Performs a token based 3-way diff on the character range specified by the given baseDiff. */ @@ -863,37 +863,37 @@ public class DocumentMerger { ancestorStart= baseDiff.fAncestorPos.getOffset(); sa= createTokenComparator(a); } - - int rightStart= baseDiff.fRightPos.getOffset(); + + int rightStart= baseDiff.fRightPos.getOffset(); ITokenComparator sm= createTokenComparator(d); - + int leftStart= baseDiff.fLeftPos.getOffset(); ITokenComparator sy= createTokenComparator(s); - + RangeDifference[] e= RangeDifferencer.findRanges(sa, sy, sm); for (int i= 0; i < e.length; i++) { RangeDifference es= e[i]; int kind= es.kind(); if (kind != RangeDifference.NOCHANGE) { - + int ancestorStart2= ancestorStart; int ancestorEnd2= ancestorStart; if (ancestorDoc != null) { ancestorStart2 += sa.getTokenStart(es.ancestorStart()); ancestorEnd2 += getTokenEnd(sa, es.ancestorStart(), es.ancestorLength()); } - + int leftStart2= leftStart + sy.getTokenStart(es.leftStart()); int leftEnd2= leftStart + getTokenEnd(sy, es.leftStart(), es.leftLength()); - + int rightStart2= rightStart + sm.getTokenStart(es.rightStart()); int rightEnd2= rightStart + getTokenEnd(sm, es.rightStart(), es.rightLength()); - + Diff diff= new Diff(baseDiff, kind, ancestorDoc, null, ancestorStart2, ancestorEnd2, leftDoc, null, leftStart2, leftEnd2, rightDoc, null, rightStart2, rightEnd2); - + // ensure that token diff is smaller than basediff int leftS= baseDiff.fLeftPos.offset; int leftE= baseDiff.fLeftPos.offset+baseDiff.fLeftPos.length; @@ -908,11 +908,11 @@ public class DocumentMerger { } } } - + private ITokenComparator createTokenComparator(String s) { return fInput.createTokenComparator(s); } - + private static int maxWork(IRangeComparator a, IRangeComparator l, IRangeComparator r) { int ln= l.getRangeCount(); int rn= r.getRangeCount(); @@ -922,7 +922,7 @@ public class DocumentMerger { } return 2 * Math.max(ln, rn); } - + private void resetPositions(IDocument doc) { if (doc == null) return; @@ -939,25 +939,25 @@ public class DocumentMerger { * Starting line number is 0 based. */ protected Point getLineRange(IDocument doc, Position p, Point region) { - + if (p == null || doc == null) { region.x= 0; region.y= 0; return region; } - + int start= p.getOffset(); int length= p.getLength(); - + int startLine= 0; try { startLine= doc.getLineOfOffset(start); } catch (BadLocationException e) { // silently ignored } - + int lineCount= 0; - + if (length == 0) { // // if range length is 0 and if range starts a new line // try { @@ -967,7 +967,7 @@ public class DocumentMerger { // } catch (BadLocationException e) { // lines--; // } - + } else { int endLine= 0; try { @@ -977,12 +977,12 @@ public class DocumentMerger { } lineCount= endLine-startLine+1; } - + region.x= startLine; region.y= lineCount; return region; } - + public Diff findDiff(Position p, boolean left) { for (Iterator iterator = fAllDiffs.iterator(); iterator.hasNext();) { Diff diff = (Diff) iterator.next(); @@ -1006,7 +1006,7 @@ public class DocumentMerger { fChangeDiffs= null; fAllDiffs= null; } - + /** * Returns the virtual position for the given view position. * @param contributor @@ -1017,11 +1017,11 @@ public class DocumentMerger { if (fAllDiffs == null) return vpos; - + int viewPos= 0; // real view position int virtualPos= 0; // virtual position Point region= new Point(0, 0); - + Iterator e= fAllDiffs.iterator(); while (e.hasNext()) { Diff diff= (Diff) e.next(); @@ -1043,22 +1043,22 @@ public class DocumentMerger { } return virtualPos; } - + /** - * maps given virtual position into a real view position of this view. + * maps given virtual position into a real view position of this view. * @param contributor * @param v * @return the real view position */ public int virtualToRealPosition(char contributor, int v) { - + if (fAllDiffs == null) return v; - + int virtualPos= 0; int viewPos= 0; Point region= new Point(0, 0); - + Iterator e= fAllDiffs.iterator(); while (e.hasNext()) { Diff diff= (Diff) e.next(); @@ -1079,7 +1079,7 @@ public class DocumentMerger { } return viewPos; } - + /* * Calculates virtual height (in lines) of views by adding the maximum of corresponding diffs. */ @@ -1094,7 +1094,7 @@ public class DocumentMerger { } return h; } - + /* * Calculates height (in lines) of right view by adding the height of the right diffs. */ @@ -1109,7 +1109,7 @@ public class DocumentMerger { } return h; } - + public int findInsertionPoint(Diff diff, char type) { if (diff != null) { switch (type) { @@ -1129,7 +1129,7 @@ public class DocumentMerger { } return 0; } - + public Diff[] getChangeDiffs(char contributor, IRegion region) { if (fChangeDiffs == null) return new Diff[0]; @@ -1144,12 +1144,12 @@ public class DocumentMerger { } return (Diff[]) intersectingDiffs.toArray(new Diff[intersectingDiffs.size()]); } - + public Diff findDiff(int viewportHeight, boolean synchronizedScrolling, Point size, int my) { - int virtualHeight= synchronizedScrolling ? getVirtualHeight() : getRightHeight(); + int virtualHeight= synchronizedScrolling ? getVirtualHeight() : getRightHeight(); if (virtualHeight < viewportHeight) return null; - + int yy, hh; int y= 0; if (fAllDiffs != null) { @@ -1159,12 +1159,12 @@ public class DocumentMerger { int h= synchronizedScrolling ? diff.getMaxDiffHeight() : diff.getRightHeight(); if (useChange(diff.getKind()) && !diff.fIsWhitespace) { - + yy= (y*size.y)/virtualHeight; hh= (h*size.y)/virtualHeight; if (hh < 3) hh= 3; - + if (my >= yy && my < yy+hh) return diff; } @@ -1177,19 +1177,19 @@ public class DocumentMerger { public boolean hasChanges() { return fChangeDiffs != null && !fChangeDiffs.isEmpty(); } - + public Iterator changesIterator() { if (fChangeDiffs == null) return new ArrayList().iterator(); return fChangeDiffs.iterator(); } - + public Iterator rangesIterator() { if (fAllDiffs == null) return new ArrayList().iterator(); return fAllDiffs.iterator(); } - + public boolean isFirstChildDiff(char contributor, int childStart, Diff diff) { if (!diff.hasChildren()) return false; @@ -1197,7 +1197,7 @@ public class DocumentMerger { Position p= d.getPosition(contributor); return (p.getOffset() >= childStart); } - + public Diff getWrappedDiff(Diff diff, boolean down) { if (fChangeDiffs != null && fChangeDiffs.size() > 0) { if (down) @@ -1206,14 +1206,14 @@ public class DocumentMerger { } return null; } - + /* * Copy the contents of the given diff from one side to the other but * doesn't reveal anything. * Returns true if copy was successful. */ public boolean copy(Diff diff, boolean leftToRight) { - + if (diff != null) { Position fromPos= null; Position toPos= null; @@ -1231,18 +1231,18 @@ public class DocumentMerger { fromDoc= getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); toDoc= getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR); } - + if (fromDoc != null) { - + int fromStart= fromPos.getOffset(); int fromLen= fromPos.getLength(); - + int toStart= toPos.getOffset(); int toLen= toPos.getLength(); try { String s= null; - + switch (diff.getKind()) { case RangeDifference.RIGHT: case RangeDifference.LEFT: @@ -1262,16 +1262,16 @@ public class DocumentMerger { break; } if (s != null) { - toDoc.replace(toStart, toLen, s); + toDoc.replace(toStart, toLen, s); toPos.setOffset(toStart); toPos.setLength(s.length()); - } - + } + } catch (BadLocationException e) { // silently ignored } } - + diff.setResolved(true); return true; } @@ -1283,7 +1283,7 @@ public class DocumentMerger { return 0; return fChangeDiffs.size(); } - + public Diff findDiff(char contributor, int rangeStart, int rangeEnd) { if (hasChanges()) { for (Iterator iterator = changesIterator(); iterator.hasNext();) { @@ -1296,17 +1296,17 @@ public class DocumentMerger { } return null; } - + public Diff findDiff(char contributor, Position range) { int start= range.getOffset(); int end= start + range.getLength(); return findDiff(contributor, start, end); } - + public Diff findNext(char contributor, int start, int end, boolean deep) { return findNext(contributor, fChangeDiffs, start, end, deep); } - + private Diff findNext(char contributor, List v, int start, int end, boolean deep) { if (v == null) return null; @@ -1332,11 +1332,11 @@ public class DocumentMerger { } return null; } - + public Diff findPrev(char contributor, int start, int end, boolean deep) { return findPrev(contributor, fChangeDiffs, start, end, deep); } - + private Diff findPrev(char contributor, List v, int start, int end, boolean deep) { if (v == null) return null; @@ -1359,7 +1359,7 @@ public class DocumentMerger { // A whole diff is selected so we'll fall through // and go the the last change in the previous diff } else if (start >= startOffset) { - // If we are at or before the first diff, select the + // If we are at or before the first diff, select the // entire diff so next and previous are symmetrical if (isFirstChildDiff(contributor, start, diff)) { return diff; @@ -1373,5 +1373,5 @@ public class DocumentMerger { } return null; } - + } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java index 7fb8c4331..c5fd8ba24 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java @@ -22,7 +22,7 @@ class LineComparator implements IRangeComparator { private String[] fLines; public LineComparator(InputStream is, String encoding) throws IOException { - + BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding)); String line; ArrayList ar = new ArrayList(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java index 7f91e2150..0616aaef4 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextStreamMerger.java @@ -29,7 +29,7 @@ public class TextStreamMerger implements IStreamMerger { /* * (non-Javadoc) - * + * * @see org.eclipse.compare.internal.merge.IAutoMerger#automerge(java.io.OutputStream, * org.eclipse.core.resources.IEncodedStorage, * org.eclipse.core.resources.IEncodedStorage, diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java index 325b1f97d..75cfe7582 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java @@ -4,7 +4,7 @@ * 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 *******************************************************************************/ @@ -34,7 +34,7 @@ class DecoratorOverlayIcon extends CompositeImageDescriptor { /** * OverlayIcon constructor. - * + * * @param baseImage the base image * @param overlaysArray the overlay images * @param sizeValue the size @@ -112,7 +112,7 @@ class DecoratorOverlayIcon extends CompositeImageDescriptor { protected Point getSize() { return size; } - + /* (non-Javadoc) * @see org.eclipse.jface.resource.CompositeImageDescriptor#getTransparentPixel() */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FilePatch.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FilePatch.java index 871fd0b94..e8e873a10 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FilePatch.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/FilePatch.java @@ -27,7 +27,7 @@ public class FilePatch extends FilePatch2 implements IFilePatch { /* * (non-Javadoc) - * + * * @see * org.eclipse.compare.patch.IFilePatch#apply(org.eclipse.core.resources * .IStorage, org.eclipse.compare.patch.PatchConfiguration, diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java index 9e892a772..805306116 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java @@ -23,11 +23,11 @@ public class HunkDiffNode extends PatchDiffNode { public static HunkDiffNode createDiffNode(PatchFileDiffNode parent, HunkResult result, boolean fullContext) { return createDiffNode(parent, result, fullContext, fullContext, fullContext); } - + public static HunkDiffNode createDiffNode(PatchFileDiffNode parent, HunkResult result, boolean ancestorFullContext, boolean leftFullContext, boolean rightFullContext) { return new HunkDiffNode(result, parent, Differencer.CHANGE, getAncestorElement(result, ancestorFullContext), getLeftElement(result, leftFullContext), getRightElement(result, rightFullContext)); } - + public static ITypedElement getRightElement(HunkResult result, boolean fullContext) { return new HunkTypedElement(result, true /* isResult */, fullContext); } @@ -72,11 +72,11 @@ public class HunkDiffNode extends PatchDiffNode { } return false; } - + public boolean isFuzzUsed() { return result.getFuzz() > 0; } - + public boolean isAllContextIgnored() { int fuzz = result.getFuzz(); if (fuzz > 0) { @@ -97,7 +97,7 @@ public class HunkDiffNode extends PatchDiffNode { if (contextLines > 0 && fuzz >= contextLines) { return true; } - + } return false; } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java index 07b35c4e1..65eb612c8 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java @@ -54,7 +54,7 @@ public class HunkTypedElement implements ITypedElement, IEncodedStreamContentAcc public static Image getHunkErrorImage(Image baseImage, LocalResourceManager imageCache, boolean onLeft) { return getHunkOverlayImage(baseImage, imageCache, ICompareUIConstants.ERROR_OVERLAY, onLeft); } - + private static Image getHunkOverlayImage(Image baseImage, LocalResourceManager imageCache, String path, boolean onLeft) { ImageDescriptor desc = new DiffImageDescriptor(baseImage, CompareUIPlugin.getImageDescriptor(path), ICompareUIConstants.COMPARE_IMAGE_WIDTH, onLeft); Image image = imageCache.createImage(desc); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java index 73b8d60c6..f3d822485 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java @@ -85,14 +85,14 @@ public class InputPatchPage extends WizardPage { // constants protected static final int SIZING_TEXT_FIELD_WIDTH= 250; protected static final int COMBO_HISTORY_LENGTH= 5; - + // dialog store id constants - private final static String PAGE_NAME= "PatchWizardPage1"; //$NON-NLS-1$ + private final static String PAGE_NAME= "PatchWizardPage1"; //$NON-NLS-1$ private final static String STORE_PATCH_FILES_ID= PAGE_NAME+".PATCH_FILES"; //$NON-NLS-1$ private final static String STORE_PATCH_URLS_ID= PAGE_NAME+".PATCH_URLS"; //$NON-NLS-1$ private final static String STORE_INPUT_METHOD_ID= PAGE_NAME+".INPUT_METHOD"; //$NON-NLS-1$ private final static String STORE_WORKSPACE_PATH_ID= PAGE_NAME+".WORKSPACE_PATH"; //$NON-NLS-1$ - + //patch input constants protected final static int CLIPBOARD= 1; protected final static int FILE= 2; @@ -119,7 +119,7 @@ public class InputPatchPage extends WizardPage { private Combo fPatchURLField; private Label fWorkspaceSelectLabel; private TreeViewer fTreeViewer; - + class ActivationListener extends ShellAdapter { public void shellActivated(ShellEvent e) { // allow error messages if the selected input actually has something selected in it @@ -138,13 +138,13 @@ public class InputPatchPage extends WizardPage { updateWidgetEnablements(); } } - + public InputPatchPage(PatchWizard pw) { super(INPUTPATCHPAGE_NAME, PatchMessages.InputPatchPage_title, null); fPatchWizard= pw; setMessage(PatchMessages.InputPatchPage_message); } - + /* * Get a path from the supplied text widget. * @return org.eclipse.core.runtime.IPath @@ -158,34 +158,34 @@ public class InputPatchPage extends WizardPage { return PatchMessages.InputPatchPage_Clipboard; return getPatchFilePath(); } - + public void createControl(Composite parent) { - + Composite composite= new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); setControl(composite); initializeDialogUnits(parent); - + buildPatchFileGroup(composite); - - // by default, whatever was used last was selected or + + // by default, whatever was used last was selected or // default to File if nothing has been selected restoreWidgetValues(); - + // see if there are any better options presently selected (i.e workspace // or clipboard or URL from clipboard) adjustToCurrentTarget(); - + // No error for dialog opening fShowError= false; clearErrorMessage(); updateWidgetEnablements(); - + Shell shell= getShell(); shell.addShellListener(fActivationListener); - + Dialog.applyDialogFont(composite); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE); } @@ -194,7 +194,7 @@ public class InputPatchPage extends WizardPage { * Returns the next page depending on what type of patch is being applied: * i) If the patch is a Workspace patch then it will proceed right to the PreviewPatchPage * ii) If the patch is a single project patch then it will proceed to the PatchTargetPage, which - * allows the user to specify where to root the patch + * allows the user to specify where to root the patch * @return PreviewPatchPage if multi-project patch, PatchTargetPage if single project patch */ public IWizardPage getNextPage() { @@ -202,13 +202,13 @@ public class InputPatchPage extends WizardPage { return this; WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher(); - + // guess prefix count int guess= 0; // guessPrefix(diffs); patcher.setStripPrefixSegments(guess); - // If this is a workspace patch we don't need to set a target as the targets will be figured out from - // all of the projects that make up the patch and continue on to final preview page + // If this is a workspace patch we don't need to set a target as the targets will be figured out from + // all of the projects that make up the patch and continue on to final preview page if (patcher.isWorkspacePatch()) { // skip 'Patch Target' page IWizardPage page = super.getNextPage(); @@ -276,8 +276,8 @@ public class InputPatchPage extends WizardPage { reader= new FileReader(patchFilePath); } catch (FileNotFoundException ex) { MessageDialog.openError(null, - PatchMessages.InputPatchPage_PatchErrorDialog_title, - PatchMessages.InputPatchPage_PatchFileNotFound_message); + PatchMessages.InputPatchPage_PatchErrorDialog_title, + PatchMessages.InputPatchPage_PatchFileNotFound_message); } } fPatchSource= PatchMessages.InputPatchPage_PatchFile_title; @@ -313,7 +313,7 @@ public class InputPatchPage extends WizardPage { } fPatchSource= PatchMessages.InputPatchPage_WorkspacePatch_title; } - + // parse the input if (reader != null) { try { @@ -345,7 +345,7 @@ public class InputPatchPage extends WizardPage { // the next page is quite expensive. So we say yes if the page is complete. return isPageComplete(); } - + private void setEnablePatchFile(boolean enable) { fPatchFileNameField.setEnabled(enable); fPatchFileBrowseButton.setEnabled(enable); @@ -417,7 +417,7 @@ public class InputPatchPage extends WizardPage { public void widgetSelected(SelectionEvent e) { if (!fUseClipboardButton.getSelection()) return; - + clearErrorMessage(); fShowError= true; int state= getInputMethod(); @@ -425,10 +425,10 @@ public class InputPatchPage extends WizardPage { setEnableURLPatch(state == URL); setEnableWorkspacePatch(state == WORKSPACE); updateWidgetEnablements(); - fPatchRead = false; + fPatchRead = false; } }); - + fUsePatchFileButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fUsePatchFileButton.getSelection()) @@ -441,7 +441,7 @@ public class InputPatchPage extends WizardPage { setEnableURLPatch(state == URL); setEnableWorkspacePatch(state == WORKSPACE); updateWidgetEnablements(); - fPatchRead = false; + fPatchRead = false; } }); fPatchFileNameField.addSelectionListener(new SelectionAdapter() { @@ -496,7 +496,7 @@ public class InputPatchPage extends WizardPage { setEnableURLPatch(state == URL); setEnableWorkspacePatch(state == WORKSPACE); updateWidgetEnablements(); - fPatchRead = false; + fPatchRead = false; } }); @@ -506,7 +506,7 @@ public class InputPatchPage extends WizardPage { updateWidgetEnablements(); } }); - + fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { ISelection selection= event.getSelection(); @@ -534,10 +534,10 @@ public class InputPatchPage extends WizardPage { layout.marginLeft= 16; // align w/ lable of check button newComp.setLayout(layout); newComp.setLayoutData(new GridData(GridData.FILL_BOTH)); - + fWorkspaceSelectLabel= new Label(newComp, SWT.LEFT); fWorkspaceSelectLabel.setText(PatchMessages.InputPatchPage_WorkspaceSelectPatch_text); - + fTreeViewer= new TreeViewer(newComp, SWT.BORDER); fTreeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); @@ -552,7 +552,7 @@ public class InputPatchPage extends WizardPage { * Updates the enable state of this page's controls. */ private void updateWidgetEnablements() { - + String error= null; boolean gotPatch= false; @@ -568,9 +568,9 @@ public class InputPatchPage extends WizardPage { if (s.length() > 0) gotPatch= true; else - error= PatchMessages.InputPatchPage_ClipboardIsEmpty_message; + error= PatchMessages.InputPatchPage_ClipboardIsEmpty_message; } else - error= PatchMessages.InputPatchPage_NoTextInClipboard_message; + error= PatchMessages.InputPatchPage_NoTextInClipboard_message; } else error= PatchMessages.InputPatchPage_CouldNotReadClipboard_message; } else if (inputMethod==FILE) { @@ -579,9 +579,9 @@ public class InputPatchPage extends WizardPage { File file= new File(path); gotPatch= file.exists() && file.isFile() && file.length() > 0; if (!gotPatch) - error= PatchMessages.InputPatchPage_CannotLocatePatch_message + path; + error= PatchMessages.InputPatchPage_CannotLocatePatch_message + path; } else { - error= PatchMessages.InputPatchPage_NoFileName_message; + error= PatchMessages.InputPatchPage_NoFileName_message; } } else if (inputMethod == URL) { String urlText = fPatchURLField.getText(); @@ -623,10 +623,10 @@ public class InputPatchPage extends WizardPage { if (fShowError) setErrorMessage(error); } - + protected void handlePatchFileBrowseButtonPressed() { FileDialog dialog= new FileDialog(getShell(), SWT.NONE); - dialog.setText(PatchMessages.InputPatchPage_SelectPatchFileDialog_title); + dialog.setText(PatchMessages.InputPatchPage_SelectPatchFileDialog_title); String patchFilePath= getPatchFilePath(); if (patchFilePath != null) { int lastSegment= patchFilePath.lastIndexOf(SEPARATOR); @@ -638,17 +638,17 @@ public class InputPatchPage extends WizardPage { String res= dialog.open(); if (res == null) return; - + patchFilePath= dialog.getFileName(); IPath filterPath= new Path(dialog.getFilterPath()); - IPath path= filterPath.append(patchFilePath).makeAbsolute(); + IPath path= filterPath.append(patchFilePath).makeAbsolute(); patchFilePath= path.toOSString(); //fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, filterPath.toOSString()); - + fPatchFileNameField.setText(patchFilePath); //setSourceName(patchFilePath); } - + /** * Sets the source name of the import to be the supplied path. * Adds the name of the path to the list of items in the @@ -657,15 +657,15 @@ public class InputPatchPage extends WizardPage { * @param path the path to be added */ protected void setSourceName(String path) { - + if (path.length() > 0) { - + String[] currentItems= fPatchFileNameField.getItems(); int selectionIndex= -1; for (int i= 0; i < currentItems.length; i++) if (currentItems[i].equals(path)) selectionIndex= i; - + if (selectionIndex < 0) { // not found in history int oldLength= currentItems.length; String[] newItems= new String[oldLength + 1]; @@ -675,11 +675,11 @@ public class InputPatchPage extends WizardPage { selectionIndex= oldLength; } fPatchFileNameField.select(selectionIndex); - + //resetSelection(); } } - + /** * The Finish button was pressed. Try to do the required work now and answer * a boolean indicating success. If false is returned then the wizard will @@ -690,30 +690,30 @@ public class InputPatchPage extends WizardPage { public boolean finish() { // if (!ensureSourceIsValid()) // return false; - + saveWidgetValues(); - + // Iterator resourcesEnum= getSelectedResources().iterator(); // List fileSystemObjects= new ArrayList(); // while (resourcesEnum.hasNext()) { // fileSystemObjects.add( // ((FileSystemElement) resourcesEnum.next()).getFileSystemObject()); // } -// +// // if (fileSystemObjects.size() > 0) // return importResources(fileSystemObjects); -// +// // MessageDialog // .openInformation( // getContainer().getShell(), // DataTransferMessages.getString("DataTransfer.information"), //$NON-NLS-1$ // DataTransferMessages.getString("FileImport.noneSelected")); //$NON-NLS-1$ -// +// // return false; return true; } - + /** * Use the dialog store to restore widget values to the values that they held * last time this wizard was used to completion @@ -737,12 +737,12 @@ public class InputPatchPage extends WizardPage { for (int i= 0; i < sourceNames.length; i++) if (sourceNames[i] != null && sourceNames[i].length() > 0) fPatchFileNameField.add(sourceNames[i]); - + // set patch file path String patchFilePath= settings.get(STORE_PATCH_FILES_ID); if (patchFilePath != null) setSourceName(patchFilePath); - + // set URLs history String[] sourceURLs= settings.getArray(STORE_PATCH_URLS_ID); if (sourceURLs != null) @@ -758,7 +758,7 @@ public class InputPatchPage extends WizardPage { inputMethod= FILE; fPatchFileNameField.deselectAll(); } - + //set the workspace patch selection String workspaceSetting= settings.get(STORE_WORKSPACE_PATH_ID); if (workspaceSetting != null && workspaceSetting.length() > 0) { @@ -772,10 +772,10 @@ public class InputPatchPage extends WizardPage { } } catch (RuntimeException e) { // Ignore. The setting was invalid - } + } } else { //check to see if the current input is set to workspace - if it is switch it - //back to clipboard since there is no corresponding element to go along with + //back to clipboard since there is no corresponding element to go along with //the tree viewer if (inputMethod == WORKSPACE) inputMethod= FILE; @@ -785,7 +785,7 @@ public class InputPatchPage extends WizardPage { // set radio buttons state setInputButtonState(inputMethod); } - + /** * Since Finish was pressed, write widget values to the dialog store so that they * will persist into the next invocation of this wizard page @@ -796,15 +796,15 @@ public class InputPatchPage extends WizardPage { settings.put(STORE_INPUT_METHOD_ID, getInputMethod()); settings.put(STORE_PATCH_FILES_ID, getPatchFilePath()); - + // update source names history String[] sourceNames= settings.getArray(STORE_PATCH_FILES_ID); if (sourceNames == null) sourceNames= new String[0]; - + sourceNames= addToHistory(sourceNames, getPatchFilePath()); settings.put(STORE_PATCH_FILES_ID, sourceNames); - + // update source URLs history String[] sourceURLs= settings.getArray(STORE_PATCH_URLS_ID); if (sourceURLs == null) @@ -815,10 +815,10 @@ public class InputPatchPage extends WizardPage { // save the workspace selection settings.put(STORE_WORKSPACE_PATH_ID, getWorkspacePath()); - + } } - + private String getWorkspacePath() { if (fTreeViewer != null){ IResource[] resources= Utilities.getResources(fTreeViewer.getSelection()); @@ -826,7 +826,7 @@ public class InputPatchPage extends WizardPage { IResource patchFile= resources[0]; return patchFile.getFullPath().toString(); } - + } return ""; //$NON-NLS-1$ } @@ -836,7 +836,7 @@ public class InputPatchPage extends WizardPage { /** * Checks to see if the file that has been selected for Apply Patch is * actually a patch - * + * * @return true if the file selected to run Apply Patch on in the workspace * is a patch file or if the clipboard contains a patch or if the * clipboard contains an URL (we assume it points to a patch ) @@ -874,7 +874,7 @@ public class InputPatchPage extends WizardPage { } } } - } + } // check out clipboard contents Reader reader = null; Control c = getControl(); @@ -910,7 +910,7 @@ public class InputPatchPage extends WizardPage { } } return false; - } + } private boolean isPatchFile(Reader reader) { WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher(); @@ -926,14 +926,14 @@ public class InputPatchPage extends WizardPage { return false; return true; } - + /* * Clears the dialog message box */ private void clearErrorMessage(){ setErrorMessage(null); } - + private void setInputButtonState(int state) { switch (state) { @@ -985,7 +985,7 @@ public class InputPatchPage extends WizardPage { if (fPatchFileNameField != null) return fPatchFileNameField.getText(); return ""; //$NON-NLS-1$ - } + } /* * Adds an entry to a history, while taking care of duplicate history items @@ -1000,12 +1000,12 @@ public class InputPatchPage extends WizardPage { l.remove(newEntry); l.add(0,newEntry); - + // since only one new item was added, we can be over the limit // by at most one item if (l.size() > COMBO_HISTORY_LENGTH) l.remove(COMBO_HISTORY_LENGTH); - + return (String[]) l.toArray(new String[l.size()]); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java index 578c0e187..9a14edafd 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java @@ -82,7 +82,7 @@ public class LineReader { 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(); + lr.ignoreSingleCR(); lines = lr.readLines(); return lines; } @@ -151,7 +151,7 @@ public class LineReader { * 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 diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java index 185e5e034..4ce115d03 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java @@ -58,21 +58,21 @@ import org.eclipse.swt.widgets.Composite; public abstract class PatchCompareEditorInput extends CompareEditorInput { private static final String IMAGE_CACHE_KEY = "IMAGE_CACHE"; //$NON-NLS-1$ - + public static ImageDescriptor createOverlay(Image baseImage, ImageDescriptor overlayImage, int quadrant) { return new DecoratorOverlayIcon(baseImage, createArrayFrom(overlayImage, quadrant), new Point(Math.max(baseImage.getBounds().width, 16), Math.max(baseImage.getBounds().height, 16))); } - + private static ImageDescriptor[] createArrayFrom( ImageDescriptor overlayImage, int quadrant) { ImageDescriptor[] descs = new ImageDescriptor[] { null, null, null, null, null }; descs[quadrant] = overlayImage; return descs; } - + class PatcherCompareEditorLabelProvider extends LabelProvider { private ILabelProvider wrappedProvider; - + public PatcherCompareEditorLabelProvider(ILabelProvider labelProvider) { wrappedProvider = labelProvider; } @@ -88,7 +88,7 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { } } if (!node.isEnabled()) { - return NLS.bind(PatchMessages.Diff_2Args, + return NLS.bind(PatchMessages.Diff_2Args, new String[]{text, PatchMessages.PatcherCompareEditorInput_NotIncluded}); } if (node instanceof PatchFileDiffNode) { @@ -107,19 +107,19 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { } if (hunkNode.isFuzzUsed()) { text = NLS.bind(PatchMessages.Diff_2Args, - new String[] { text, + new String[] { text, NLS.bind(hunkNode.isAllContextIgnored() ? PatchMessages.PreviewPatchPage_AllContextIgnored : PatchMessages.PreviewPatchPage_FuzzUsed, new String[] { hunkNode.getHunkResult().getFuzz() + ""}) }); //$NON-NLS-1$ } } - if (getPatcher().isRetargeted(node.getPatchElement())) - return NLS.bind(PatchMessages.Diff_2Args, + if (getPatcher().isRetargeted(node.getPatchElement())) + return NLS.bind(PatchMessages.Diff_2Args, new String[]{getPatcher().getOriginalPath(node.getPatchElement()).toString(), NLS.bind(PatchMessages.PreviewPatchPage_Target, new String[]{node.getName()})}); } return text; } - + public Image getImage(Object element) { Image image = wrappedProvider.getImage(element); if (element instanceof PatchDiffNode){ @@ -139,17 +139,17 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { return image; } } - + private final DiffNode root; private final WorkspacePatcher patcher; private TreeViewer viewer; private boolean fShowAll; private boolean showMatched = false; - + /** * Creates a new PatchCompareEditorInput and makes use of the passed in CompareConfiguration * to configure the UI elements. - * @param patcher + * @param patcher * @param configuration */ public PatchCompareEditorInput(WorkspacePatcher patcher, CompareConfiguration configuration) { @@ -167,13 +167,13 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { private void initializeImageCache() { initializeImageCache(patcher.getConfiguration()); } - + private static LocalResourceManager initializeImageCache(PatchConfiguration patchConfiguration) { LocalResourceManager imageCache = new LocalResourceManager(JFaceResources.getResources()); patchConfiguration.setProperty(IMAGE_CACHE_KEY, imageCache); return imageCache; } - + protected void handleDispose() { super.handleDispose(); getImageCache(getPatcher().getConfiguration()).dispose(); @@ -191,7 +191,7 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { initLabels(); return root; } - + private void initLabels() { CompareConfiguration cc = getCompareConfiguration(); // set left editable so that unmatched hunks can be edited @@ -211,34 +211,34 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { if (getViewer() != null && !getViewer().getControl().isDisposed()) getViewer().refresh(true); } - + /** * Build the diff tree. */ protected void buildTree(){ - + // Reset the input node so it is empty if (getRoot().hasChildren()) { resetRoot(); } // Reset the input of the viewer so the old state is no longer used getViewer().setInput(getRoot()); - + // Refresh the patcher state getPatcher().refresh(); - + // Build the diff tree if (getPatcher().isWorkspacePatch()){ processProjects(getPatcher().getDiffProjects()); } else { processDiffs(getPatcher().getDiffs()); } - + // Refresh the viewer getViewer().refresh(); } - - private void processDiffs(FilePatch2[] diffs) { + + private void processDiffs(FilePatch2[] diffs) { for (int i = 0; i < diffs.length; i++) { processDiff(diffs[i], getRoot()); } @@ -290,7 +290,7 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { PatchCompareEditorInput.this.fillContextMenu(manager); } }; - + viewer.setLabelProvider(new PatcherCompareEditorLabelProvider((ILabelProvider)viewer.getLabelProvider())); viewer.getTree().setData(CompareUI.COMPARE_VIEWER_TITLE, PatchMessages.PatcherCompareEditorInput_PatchContents); viewer.addOpenListener(new IOpenListener() { @@ -310,13 +310,13 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { getCompareConfiguration().setRightLabel(PatchMessages.PatcherCompareEditorInput_AfterPatch); } } - + }); viewer.setFilters(getFilters()); viewer.setInput(root); return viewer; } - + private ViewerFilter[] getFilters() { return new ViewerFilter[] { new ViewerFilter() { public boolean select(Viewer v, Object parentElement, Object element) { @@ -332,7 +332,7 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { protected boolean isShowAll() { return fShowAll; } - + protected void setShowAll(boolean show) { fShowAll = show; } @@ -349,25 +349,25 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { ToolBarManager tbm= CompareViewerPane.getToolBarManager(viewer.getControl().getParent()); if (tbm != null) { tbm.removeAll(); - + tbm.add(new Separator("contributed")); //$NON-NLS-1$ - + for (int i = 0; i < actions.length; i++) { tbm.appendToGroup("contributed", actions[i]); //$NON-NLS-1$ } - + tbm.update(true); } } - + public TreeViewer getViewer() { return viewer; } - + public DiffNode getRoot() { return root; } - + public void resetRoot() { IDiffElement[] children = root.getChildren(); for (int i = 0; i < children.length; i++) { @@ -379,7 +379,7 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { public WorkspacePatcher getPatcher() { return patcher; } - + public boolean confirmRebuild(String message) { if (getPatcher().hasCachedContents()) { if (promptToDiscardCachedChanges(message)) { @@ -422,9 +422,9 @@ public abstract class PatchCompareEditorInput extends CompareEditorInput { } return false; } - + protected abstract void fillContextMenu(IMenuManager manager); - + public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent) { if (org.eclipse.compare.internal.Utilities.isHunk(input)) diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java index c6ce4ee9b..76722c7b8 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java @@ -49,7 +49,7 @@ public abstract class PatchDiffNode extends DiffNode implements IResourceProvide } protected abstract PatchConfiguration getConfiguration(); - + public boolean equals(Object other) { if (other instanceof PatchDiffNode) { PatchDiffNode node = (PatchDiffNode) other; @@ -57,7 +57,7 @@ public abstract class PatchDiffNode extends DiffNode implements IResourceProvide } return super.equals(other); } - + public int hashCode() { return getPatchElement().hashCode(); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java index 652b2c360..896d9186b 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchErrorDialog.java @@ -11,9 +11,9 @@ package org.eclipse.compare.internal.patch; public class PatchErrorDialog { - + private PatchErrorDialog() { // no instance. } - + } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java index 0f2ed66e5..0705d804c 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java @@ -29,7 +29,7 @@ public class PatchFileDiffNode extends PatchDiffNode implements IContentChangeLi public static PatchFileDiffNode createDiffNode(DiffNode parent, FileDiffResult result) { return new PatchFileDiffNode(result, parent, getKind(result), getAncestorElement(result), getLeftElement(result), getRightElement(result)); } - + public static int getKind(FileDiffResult result) { if (!result.hasMatches()) return Differencer.NO_CHANGE; @@ -78,11 +78,11 @@ public class PatchFileDiffNode extends PatchDiffNode implements IContentChangeLi public FileDiffResult getDiffResult() { return result; } - + protected PatchConfiguration getConfiguration() { return result.getConfiguration(); } - + /* (non-Javadoc) * @see org.eclipse.compare.structuremergeviewer.DiffContainer#add(org.eclipse.compare.structuremergeviewer.IDiffElement) */ @@ -105,7 +105,7 @@ public class PatchFileDiffNode extends PatchDiffNode implements IContentChangeLi public void contentChanged(IContentChangeNotifier source) { fireChange(); } - + public int getKind() { int kind = super.getKind(); if (kind == Differencer.NO_CHANGE && getPatcher().hasCachedContents(getDiffResult().getDiff())) { diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java index ed468befa..06c7ad733 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileTypedElement.java @@ -73,7 +73,7 @@ public class PatchFileTypedElement implements ITypedElement, /* * (non-Javadoc) - * + * * @see org.eclipse.compare.ITypedElement#getName() */ @Override @@ -83,7 +83,7 @@ public class PatchFileTypedElement implements ITypedElement, /* * (non-Javadoc) - * + * * @see org.eclipse.compare.ITypedElement#getType() */ @Override diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java index 5e41aafcf..e2f56404c 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java @@ -32,14 +32,14 @@ public class PatchProjectDiffNode extends PatchDiffNode { this.project = project; this.configuration = configuration; } - + /* (non-Javadoc) * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName() */ public String getName() { return project.getName(); } - + /* (non-Javadoc) * @see org.eclipse.compare.structuremergeviewer.DiffNode#getImage() */ @@ -71,7 +71,7 @@ public class PatchProjectDiffNode extends PatchDiffNode { public String getType() { return ITypedElement.FOLDER_TYPE; } - + protected PatchConfiguration getConfiguration() { return configuration; } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java index 44688f292..78a50f9da 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java @@ -81,17 +81,17 @@ public class PatchTargetPage extends WizardPage { composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); setControl(composite); - - useWorkspaceAsTarget = createRadioButton(composite, PatchMessages.PatchTargetPage_0, 1); - selectTarget = createRadioButton(composite, PatchMessages.InputPatchPage_SelectInput, 1); - + + useWorkspaceAsTarget = createRadioButton(composite, PatchMessages.PatchTargetPage_0, 1); + selectTarget = createRadioButton(composite, PatchMessages.InputPatchPage_SelectInput, 1); + buildInputGroup(composite); updateWidgetEnablements(); Dialog.applyDialogFont(composite); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE); - + useWorkspaceAsTarget.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { fShowError = true; @@ -124,7 +124,7 @@ public class PatchTargetPage extends WizardPage { button.setLayoutData(data); return button; } - + /* (non-JavaDoc) * Method declared in IWizardPage. */ @@ -177,7 +177,7 @@ public class PatchTargetPage extends WizardPage { fPatchTargets.setContentProvider(new WorkbenchContentProvider()); fPatchTargets.setComparator(new ResourceComparator(ResourceComparator.NAME)); fPatchTargets.setInput(ResourcesPlugin.getWorkspace().getRoot()); - + IResource target = fPatcher.getTarget(); if (target != null && !(target instanceof IWorkspaceRoot)) { fPatchTargets.expandToLevel(target, 0); @@ -192,7 +192,7 @@ public class PatchTargetPage extends WizardPage { updateWidgetEnablements(); } }); - + fPatchTargets.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { ((PatchWizard)getWizard()).showPage(getNextPage()); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java index 1daddd07e..31efd3795 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java @@ -43,18 +43,18 @@ public class PatchWizard extends Wizard { private final static String DIALOG_SETTINGS_KEY= "PatchWizard"; //$NON-NLS-1$ private boolean fHasNewDialogSettings; - + protected InputPatchPage fPatchWizardPage; protected PatchTargetPage fPatchTargetPage; protected PreviewPatchPage2 fPreviewPage2; - + private final WorkspacePatcher fPatcher; - + private CompareConfiguration fConfiguration; private IStorage patch; private boolean patchReadIn = false; - + public PatchWizard(IStorage patch, IResource target, CompareConfiguration configuration) { Assert.isNotNull(configuration); this.fConfiguration = configuration; @@ -69,16 +69,16 @@ public class PatchWizard extends Wizard { patchReadIn = true; } catch (IOException e) { MessageDialog.openError(null, - PatchMessages.InputPatchPage_PatchErrorDialog_title, - PatchMessages.InputPatchPage_ParseError_message); + PatchMessages.InputPatchPage_PatchErrorDialog_title, + PatchMessages.InputPatchPage_ParseError_message); } catch (CoreException e) { ErrorDialog.openError(getShell(), - PatchMessages.InputPatchPage_PatchErrorDialog_title, + PatchMessages.InputPatchPage_PatchErrorDialog_title, PatchMessages.InputPatchPage_PatchFileNotFound_message, e.getStatus()); } } } - + private void initializeDialogSettings() { IDialogSettings workbenchSettings= CompareUIPlugin.getDefault().getDialogSettings(); IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY); @@ -101,7 +101,7 @@ public class PatchWizard extends Wizard { IResource getTarget() { return fPatcher.getTarget(); } - + /* (non-Javadoc) * Method declared on IWizard. */ @@ -115,24 +115,24 @@ public class PatchWizard extends Wizard { fPreviewPage2 = new PreviewPatchPage2(fPatcher, fConfiguration); addPage(fPreviewPage2); } - + /* (non-Javadoc) * Method declared on IWizard. */ public boolean performFinish() { - + IWizardPage currentPage = getContainer().getCurrentPage(); if (currentPage.getName().equals(PreviewPatchPage2.PREVIEWPATCHPAGE_NAME)){ PreviewPatchPage2 previewPage = (PreviewPatchPage2) currentPage; previewPage.ensureContentsSaved(); } - + if (fPatchWizardPage != null){ // make sure that the patch has been read if (!fPatchWizardPage.isPatchRead()) fPatchWizardPage.readInPatch(); fPatcher.refresh(); - + // make sure that the patch is not invalid if (!fPatchWizardPage.checkPageComplete()) return false; @@ -143,18 +143,18 @@ public class PatchWizard extends Wizard { //make sure that the patch has been read in Assert.isTrue(patchReadIn); } - + if (!currentPage.getName().equals(PreviewPatchPage2.PREVIEWPATCHPAGE_NAME) && fPatcher.hasRejects()){ if (!MessageDialog.openConfirm(getShell(), PatchMessages.PatchWizard_0, PatchMessages.PatchWizard_1)) { return false; } } - + try { // create scheduling rule based on the type of patch - single or workspace ISchedulingRule scheduleRule = null; if (fPatcher.isWorkspacePatch()) { - // workspace patch + // workspace patch ISchedulingRule[] projectRules = fPatcher.getTargetProjects(); scheduleRule = new MultiRule(projectRules); } else { @@ -206,7 +206,7 @@ public class PatchWizard extends Wizard { public void showPage(IWizardPage page) { getContainer().showPage(page); } - + public IWizardPage getNextPage(IWizardPage page) { //no patch has been read in yet, input patch page if (!patchReadIn) @@ -225,7 +225,7 @@ public class PatchWizard extends Wizard { /** * Used to report that the patch has - * + * */ protected void patchReadIn() { patchReadIn = true; @@ -234,7 +234,7 @@ public class PatchWizard extends Wizard { public CompareConfiguration getCompareConfiguration() { return fConfiguration; } - + public boolean canFinish() { IWizardPage currentPage = getContainer().getCurrentPage(); if (currentPage.getName().equals(PreviewPatchPage2.PREVIEWPATCHPAGE_NAME)){ @@ -242,5 +242,5 @@ public class PatchWizard extends Wizard { } return super.canFinish(); } - + } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizardDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizardDialog.java index 9979f6f31..8273a1c43 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizardDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizardDialog.java @@ -22,17 +22,17 @@ public class PatchWizardDialog extends WizardDialog { public PatchWizardDialog(Shell parent, IWizard wizard) { super(parent, wizard); - + setShellStyle(getShellStyle() | SWT.RESIZE); setMinimumPageSize(700, 500); } - + protected IDialogSettings getDialogBoundsSettings() { IDialogSettings settings = CompareUIPlugin.getDefault().getDialogSettings(); IDialogSettings section = settings.getSection(PATCH_WIZARD_SETTINGS_SECTION); if (section == null) { section = settings.addNewSection(PATCH_WIZARD_SETTINGS_SECTION); - } + } return section; } } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java index 17d5afac0..1477cc21f 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java @@ -58,7 +58,7 @@ import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.text.TextUtilities; /** - * A Patcher + * A Patcher * - knows how to parse various patch file formats into some in-memory structure, * - holds onto the parsed data and the options to use when applying the patches, * - knows how to apply the patches to files and folders. @@ -73,7 +73,7 @@ public class Patcher implements IHunkFilter { * Property used to associate a patcher with a {@link PatchConfiguration} */ public static final String PROP_PATCHER = "org.eclipse.compare.patcher"; //$NON-NLS-1$ - + public interface IFileValidator { boolean validateResources(IFile[] array); } @@ -83,7 +83,7 @@ public class Patcher implements IHunkFilter { // private static final int ED= 1; // private static final int NORMAL= 2; // private static final int UNIFIED= 3; - + private FilePatch2[] fDiffs; private IResource fTarget; // patch options @@ -94,13 +94,13 @@ public class Patcher implements IHunkFilter { private final PatchConfiguration configuration; private boolean fGenerateRejectFile = false; - + public Patcher() { configuration = new PatchConfiguration(); configuration.setProperty(PROP_PATCHER, this); configuration.addHunkFilter(this); } - + /* * Returns an array of Diffs after a successful call to <code>parse</code>. * If <code>parse</code> hasn't been called returns <code>null</code>. @@ -110,7 +110,7 @@ public class Patcher implements IHunkFilter { return new FilePatch2[0]; return fDiffs; } - + public IPath getPath(FilePatch2 diff) { return diff.getStrippedPath(getStripPrefixSegments(), isReversed()); } @@ -125,11 +125,11 @@ public class Patcher implements IHunkFilter { } return false; } - + int getStripPrefixSegments() { return getConfiguration().getPrefixSegmentStripCount(); } - + /* * Returns <code>true</code> if new value differs from old. */ @@ -140,11 +140,11 @@ public class Patcher implements IHunkFilter { } return false; } - + public int getFuzz(){ return getConfiguration().getFuzz(); } - + /* * Returns <code>true</code> if new value differs from old. */ @@ -155,11 +155,11 @@ public class Patcher implements IHunkFilter { } return false; } - + public boolean isIgnoreWhitespace() { return getConfiguration().isIgnoreWhitespace(); } - + public boolean isGenerateRejectFile() { return fGenerateRejectFile; } @@ -167,7 +167,7 @@ public class Patcher implements IHunkFilter { public void setGenerateRejectFile(boolean generateRejectFile) { fGenerateRejectFile = generateRejectFile; } - + //---- parsing patch files public void parse(IStorage storage) throws IOException, CoreException { @@ -181,7 +181,7 @@ public class Patcher implements IHunkFilter { } } } - + public void parse(BufferedReader reader) throws IOException { PatchReader patchReader = new PatchReader() { @Override @@ -197,7 +197,7 @@ public class Patcher implements IHunkFilter { protected void patchParsed(PatchReader patchReader) { fDiffs = patchReader.getDiffs(); } - + public void countLines() { FilePatch2[] fileDiffs = getDiffs(); for (int i = 0; i < fileDiffs.length; i++) { @@ -223,13 +223,13 @@ public class Patcher implements IHunkFilter { fileDiff.setRemovedLines(removedLines); } } - + //---- applying a patch file public void applyAll(IProgressMonitor pm, IFileValidator validator) throws CoreException { - + int i; - + IFile singleFile= null; // file to be patched IContainer container= null; if (fTarget instanceof IContainer) @@ -240,7 +240,7 @@ public class Patcher implements IHunkFilter { } else { Assert.isTrue(false); } - + // get all files to be modified in order to call validateEdit List list= new ArrayList(); if (singleFile != null) @@ -260,30 +260,30 @@ public class Patcher implements IHunkFilter { if (! validator.validateResources((IFile[])list.toArray(new IFile[list.size()]))) { return; } - + final int WORK_UNIT= 10; if (pm != null) { - String message= Messages.Patcher_0; + String message= Messages.Patcher_0; pm.beginTask(message, fDiffs.length*WORK_UNIT); } - + for (i= 0; i < fDiffs.length; i++) { - + int workTicks= WORK_UNIT; - + FilePatch2 diff= fDiffs[i]; if (isEnabled(diff)) { - + IPath path= getPath(diff); if (pm != null) pm.subTask(path.toString()); - + IFile file= singleFile != null ? singleFile : createPath(container, path); - + List failed= new ArrayList(); - + int type= diff.getDiffType(isReversed()); switch (type) { case FilePatch2.ADDITION: @@ -313,7 +313,7 @@ public class Patcher implements IHunkFilter { store(getRejected(failed), file, pm); try { IMarker marker= file.createMarker(MARKER_TYPE); - marker.setAttribute(IMarker.MESSAGE, Messages.Patcher_1); + marker.setAttribute(IMarker.MESSAGE, Messages.Patcher_1); marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH); } catch (CoreException ex) { // NeedWork @@ -321,7 +321,7 @@ public class Patcher implements IHunkFilter { } } } - + if (pm != null) { if (pm.isCanceled()) break; @@ -340,7 +340,7 @@ public class Patcher implements IHunkFilter { pp= new Path(path.lastSegment() + REJECT_FILE_EXTENSION); return pp; } - + List apply(FilePatch2 diff, IFile file, boolean create, List failedHunks) { FileDiffResult result = getDiffResult(diff); List<String> lines = LineReader.load(file, create); @@ -355,7 +355,7 @@ public class Patcher implements IHunkFilter { } return result.getLines(); } - + /* * Converts the string into bytes and stores them in the given file. */ @@ -380,7 +380,7 @@ public class Patcher implements IHunkFilter { // uses default encoding bytes= contents.getBytes(); } - + store(bytes,file, pm); } @@ -423,7 +423,7 @@ public class Patcher implements IHunkFilter { public static String getRejected(List failedHunks) { if (failedHunks.size() <= 0) return null; - + String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$ StringBuffer sb= new StringBuffer(); Iterator iter= failedHunks.iterator(); @@ -435,7 +435,7 @@ public class Patcher implements IHunkFilter { } return sb.toString(); } - + /* * Ensures that a file with the given path exists in * the given container. Folder are created as necessary. @@ -469,16 +469,16 @@ public class Patcher implements IHunkFilter { public void setTarget(IResource target) { fTarget= target; } - + public IFile getTargetFile(FilePatch2 diff) { IPath path = diff.getStrippedPath(getStripPrefixSegments(), isReversed()); return existsInTarget(path); } - + /** * Iterates through all of the resources contained in the Patch Wizard target - * and looks to for a match to the passed in file + * and looks to for a match to the passed in file * @param path * @return IFile which matches the passed in path or null if none found */ @@ -497,8 +497,8 @@ public class Patcher implements IHunkFilter { /** * Returns true if path completely matches the end of fullpath - * @param fullpath - * @param path + * @param fullpath + * @param path * @return true if path matches, false otherwise */ private boolean matches(IPath fullpath, IPath path) { @@ -523,14 +523,14 @@ public class Patcher implements IHunkFilter { } return length; } - + public void addDiff(FilePatch2 newDiff){ FilePatch2[] temp = new FilePatch2[fDiffs.length + 1]; System.arraycopy(fDiffs,0, temp, 0, fDiffs.length); temp[fDiffs.length] = newDiff; fDiffs = temp; } - + public void removeDiff(FilePatch2 diffToRemove){ FilePatch2[] temp = new FilePatch2[fDiffs.length - 1]; int counter = 0; @@ -541,23 +541,23 @@ public class Patcher implements IHunkFilter { } fDiffs = temp; } - + public void setEnabled(Object element, boolean enabled) { - if (element instanceof DiffProject) + if (element instanceof DiffProject) setEnabledProject((DiffProject) element, enabled); - if (element instanceof FilePatch2) + if (element instanceof FilePatch2) setEnabledFile((FilePatch2)element, enabled); - if (element instanceof Hunk) + if (element instanceof Hunk) setEnabledHunk((Hunk) element, enabled); } - + private void setEnabledProject(DiffProject projectDiff, boolean enabled) { FilePatch2[] diffFiles = projectDiff.getFileDiffs(); for (int i = 0; i < diffFiles.length; i++) { setEnabledFile(diffFiles[i], enabled); } } - + private void setEnabledFile(FilePatch2 fileDiff, boolean enabled) { IHunk[] hunks = fileDiff.getHunks(); for (int i = 0; i < hunks.length; i++) { @@ -588,7 +588,7 @@ public class Patcher implements IHunkFilter { } public boolean isEnabled(Object element) { - if (disabledElements.contains(element)) + if (disabledElements.contains(element)) return false; Object parent = getElementParent(element); if (parent == null) @@ -603,7 +603,7 @@ public class Patcher implements IHunkFilter { } return null; } - + /** * Calculate the fuzz factor that will allow the most hunks to be matched. * @param monitor a progress monitor @@ -632,12 +632,12 @@ public class Patcher implements IHunkFilter { monitor.done(); } } - + public void refresh() { diffResults.clear(); refresh(getDiffs()); } - + public void refresh(FilePatch2[] diffs) { for (int i = 0; i < diffs.length; i++) { FilePatch2 diff = diffs[i]; @@ -645,7 +645,7 @@ public class Patcher implements IHunkFilter { ((WorkspaceFileDiffResult)result).refresh(); } } - + public FileDiffResult getDiffResult(FilePatch2 diff) { FileDiffResult result = (FileDiffResult)diffResults.get(diff); if (result == null) { @@ -680,15 +680,15 @@ public class Patcher implements IHunkFilter { } return false; } - + public boolean isReversed() { return getConfiguration().isReversed(); } - + /** * Cache the contents for the given file diff. These contents * will be used for the diff when the patch is applied. When the - * patch is applied, it is assumed that the provided contents + * patch is applied, it is assumed that the provided contents * already have all relevant hunks applied. * @param diff the file diff * @param contents the contents for the file diff @@ -696,9 +696,9 @@ public class Patcher implements IHunkFilter { public void cacheContents(FilePatch2 diff, byte[] contents) { contentCache.put(diff, contents); } - + /** - * Return whether contents have been cached for the + * Return whether contents have been cached for the * given file diff. * @param diff the file diff * @return whether contents have been cached for the file diff @@ -709,7 +709,7 @@ public class Patcher implements IHunkFilter { } /** - * Return the content lines that are cached for the given + * Return the content lines that are cached for the given * file diff. * @param diff the file diff * @return the content lines that are cached for the file diff @@ -733,7 +733,7 @@ public class Patcher implements IHunkFilter { public byte[] getCachedContents(FilePatch2 diff) { return (byte[])contentCache.get(diff); } - + /** * Return whether the patcher has any cached contents. * @return whether the patcher has any cached contents @@ -749,11 +749,11 @@ public class Patcher implements IHunkFilter { contentCache.clear(); mergedHunks.clear(); } - + public void setProperty(String key, Object value) { getConfiguration().setProperty(key, value); } - + public Object getProperty(String key) { return getConfiguration().getProperty(key); } @@ -765,7 +765,7 @@ public class Patcher implements IHunkFilter { public void setManuallyMerged(Hunk hunk, boolean merged) { if (merged) mergedHunks.add(hunk); - else + else mergedHunks.remove(hunk); } @@ -784,7 +784,7 @@ public class Patcher implements IHunkFilter { public static Patcher getPatcher(PatchConfiguration configuration) { return (Patcher)configuration.getProperty(PROP_PATCHER); } - + public boolean hasRejects() { for (Iterator iterator = diffResults.values().iterator(); iterator.hasNext();) { FileDiffResult result = (FileDiffResult) iterator.next(); diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java index 5d03024fb..3028911d0 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java @@ -76,28 +76,28 @@ public class PreviewPatchPage2 extends WizardPage { private static final String EXPAND_PATCH_OPTIONS = "expandPatchOptions"; //$NON-NLS-1$ private static final String GENERATE_REJECTS = "generateRejects"; //$NON-NLS-1$ - + final WorkspacePatcher fPatcher; private final CompareConfiguration fConfiguration; private PatchCompareEditorInput fInput; - + private Combo fStripPrefixSegments; private Text fFuzzField; private Label addedRemovedLines; - + private Action fExcludeAction; private Action fIncludeAction; private Action fIgnoreWhiteSpace; private Action fReversePatch; private Action fMoveAction; - + protected boolean pageRecalculate= true; private IDialogSettings settings; private ExpandableComposite patchOptions; private Button generateRejects; private FormToolkit fToolkit; - + public PreviewPatchPage2(WorkspacePatcher patcher, CompareConfiguration configuration) { super(PREVIEWPATCHPAGE_NAME, PatchMessages.PreviewPatchPage_title, null); setDescription(PatchMessages.PreviewPatchPage2_8); @@ -117,13 +117,13 @@ public class PreviewPatchPage2 extends WizardPage { public void createControl(Composite parent) { fToolkit = new FormToolkit(parent.getDisplay()); fToolkit.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); - + final Form form = fToolkit.createForm(parent); Composite composite = form.getBody(); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); initializeDialogUnits(parent); - + fInput = new PatchCompareEditorInput(getPatcher(), getCompareConfiguration()) { protected void fillContextMenu(IMenuManager manager) { if (isShowAll()) { @@ -134,16 +134,16 @@ public class PreviewPatchPage2 extends WizardPage { manager.add(fMoveAction); } }; - + buildPatchOptionsGroup(form); - + // Initialize the input try { fInput.run(null); } catch (InterruptedException e) {//ignore } catch (InvocationTargetException e) {//ignore } - + Label label = new Label(composite, SWT.NONE); label.setText(PatchMessages.PreviewPatchPage2_9); Control c = fInput.createContents(composite); @@ -161,18 +161,18 @@ public class PreviewPatchPage2 extends WizardPage { }}); c.setLayoutData(new GridData(GridData.FILL_BOTH)); - + addedRemovedLines = new Label(composite, SWT.NONE); addedRemovedLines.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); - + setControl(composite); - + restoreWidgetValues(); - + Dialog.applyDialogFont(composite); } - + private void updateActions(IStructuredSelection ss) { fExcludeAction.setEnabled(false); fIncludeAction.setEnabled(false); @@ -187,7 +187,7 @@ public class PreviewPatchPage2 extends WizardPage { } } } - + /** * Makes sure that at least one hunk is checked off in the tree before * allowing the patch to be applied. @@ -198,13 +198,13 @@ public class PreviewPatchPage2 extends WizardPage { atLeastOneIsEnabled = fInput.hasResultToApply(); setPageComplete(atLeastOneIsEnabled); } - + private Action[] getContributedActions() { return new Action[]{ fIgnoreWhiteSpace }; } private void initializeActions() { - + fMoveAction = new Action(PatchMessages.PreviewPatchPage2_RetargetAction, null) { public void run() { Shell shell = getShell(); @@ -244,7 +244,7 @@ public class PreviewPatchPage2 extends WizardPage { fMoveAction.setEnabled(enable); } }); - + fExcludeAction = new Action(PatchMessages.PreviewPatchPage2_0) { public void run() { ISelection selection = fInput.getViewer().getSelection(); @@ -257,7 +257,7 @@ public class PreviewPatchPage2 extends WizardPage { PatchDiffNode node = ((PatchDiffNode) obj); node.setEnabled(false); // TODO: This may require a rebuild if matched hunks are shown - } + } } updateActions(treeSelection); } @@ -265,7 +265,7 @@ public class PreviewPatchPage2 extends WizardPage { } }; fExcludeAction.setEnabled(true); - + fIncludeAction = new Action(PatchMessages.PreviewPatchPage2_1) { public void run() { ISelection selection = fInput.getViewer().getSelection(); @@ -278,7 +278,7 @@ public class PreviewPatchPage2 extends WizardPage { PatchDiffNode node = ((PatchDiffNode) obj); node.setEnabled(true); // TODO: This may require a rebuild if matched hunks are shown - } + } } updateActions(treeSelection); } @@ -286,7 +286,7 @@ public class PreviewPatchPage2 extends WizardPage { } }; fIncludeAction.setEnabled(true); - + fIgnoreWhiteSpace = new Action(PatchMessages.PreviewPatchPage2_IgnoreWSAction, CompareUIPlugin.getImageDescriptor(ICompareUIConstants.IGNORE_WHITESPACE_ENABLED)){ public void run(){ try { @@ -313,7 +313,7 @@ public class PreviewPatchPage2 extends WizardPage { fIgnoreWhiteSpace.setChecked(false); fIgnoreWhiteSpace.setToolTipText(PatchMessages.PreviewPatchPage2_IgnoreWSTooltip); fIgnoreWhiteSpace.setDisabledImageDescriptor(CompareUIPlugin.getImageDescriptor(ICompareUIConstants.IGNORE_WHITESPACE_DISABLED)); - + fReversePatch = new Action(PatchMessages.PreviewPatchPage_ReversePatch_text){ public void run(){ try { @@ -335,14 +335,14 @@ public class PreviewPatchPage2 extends WizardPage { } catch (InvocationTargetException e) { //ignore } catch (InterruptedException e) { //ignore } - + } - + }; fReversePatch.setChecked(false); fReversePatch.setToolTipText(PatchMessages.PreviewPatchPage_ReversePatch_text); } - + public void setVisible(boolean visible) { super.setVisible(visible); //Need to handle input and rebuild tree only when becoming visible @@ -363,7 +363,7 @@ public class PreviewPatchPage2 extends WizardPage { getShell().getDefaultButton().setFocus(); } } - + private boolean promptToRebuild(final String promptToConfirm){ final Control ctrl = getControl(); final boolean[] result = new boolean[] { false }; @@ -388,7 +388,7 @@ public class PreviewPatchPage2 extends WizardPage { } return result[0]; } - + private void rebuildTree(){ final Control ctrl = getControl(); if (ctrl != null && !ctrl.isDisposed()){ @@ -434,7 +434,7 @@ public class PreviewPatchPage2 extends WizardPage { */ private void buildPatchOptionsGroup(final Form form) { Composite parent = form.getBody(); - + patchOptions = fToolkit.createExpandableComposite(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT); patchOptions.setText(PatchMessages.PreviewPatchPage_PatchOptions_title); patchOptions.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); @@ -477,7 +477,7 @@ public class PreviewPatchPage2 extends WizardPage { } } ); - + fFuzzField.addModifyListener( new ModifyListener() { @@ -522,7 +522,7 @@ public class PreviewPatchPage2 extends WizardPage { // Reset the fuzz. We don't use HunkResult.MAXIMUM_FUZZ_FACTOR on purpose here, // in order to refresh the tree the result of the calculation needs to be different // than the fuzz set in the configuration (see fFuzzField modify listener). - patcher.setFuzz(-1); + patcher.setFuzz(-1); int fuzz= guessFuzzFactor(patcher); if (fuzz>=0) fFuzzField.setText(Integer.toString(fuzz)); @@ -533,7 +533,7 @@ public class PreviewPatchPage2 extends WizardPage { gd= new GridData(GridData.VERTICAL_ALIGN_CENTER); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = b.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); - gd.widthHint = Math.max(widthHint, minSize.x); + gd.widthHint = Math.max(widthHint, minSize.x); b.setLayoutData(gd); } @@ -552,7 +552,7 @@ public class PreviewPatchPage2 extends WizardPage { generateRejects.setSelection(false); generateRejects.setLayoutData(gd); } - + private void createShowRemovedToggle(Composite pair) { final Button showRemoved = new Button(pair, SWT.CHECK); showRemoved.setText(PatchMessages.PreviewPatchPage2_7); @@ -568,7 +568,7 @@ public class PreviewPatchPage2 extends WizardPage { showRemoved.setSelection(fInput.isShowAll()); showRemoved.setLayoutData(gd); } - + private void createReversePatchToggle(Composite pair) { final Button reversePatch = new Button(pair, SWT.CHECK); reversePatch.setText(PatchMessages.PreviewPatchPage_ReversePatch_text); @@ -592,7 +592,7 @@ public class PreviewPatchPage2 extends WizardPage { private void createStripSegmentCombo(Composite parent) { final WorkspacePatcher patcher= getPatcher(); - + Composite pair= new Composite(parent, SWT.NONE); GridLayout gl= new GridLayout(); gl.numColumns= 2; gl.marginHeight= gl.marginWidth= 0; pair.setLayout(gl); @@ -612,7 +612,7 @@ public class PreviewPatchPage2 extends WizardPage { gd= new GridData(GridData.VERTICAL_ALIGN_CENTER|GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL); fStripPrefixSegments.setLayoutData(gd); } - + private void createShowMatchedToggle(Composite parent) { final Button showMatched = new Button(parent, SWT.CHECK); showMatched.setText(PatchMessages.PreviewPatchPage2_ShowMatched); @@ -628,7 +628,7 @@ public class PreviewPatchPage2 extends WizardPage { showMatched.setSelection(fInput.isShowMatched()); showMatched.setLayoutData(gd); } - + public int getFuzzFactor() { int fuzzFactor= 0; if (fFuzzField!=null) { @@ -641,7 +641,7 @@ public class PreviewPatchPage2 extends WizardPage { } return fuzzFactor; } - + public int getStripPrefixSegments() { int stripPrefixSegments= 0; if (fStripPrefixSegments!=null) { @@ -654,7 +654,7 @@ public class PreviewPatchPage2 extends WizardPage { } return stripPrefixSegments; } - + private int guessFuzzFactor(final WorkspacePatcher patcher) { final int[] result= new int[] { -1 }; try { @@ -672,7 +672,7 @@ public class PreviewPatchPage2 extends WizardPage { } return result[0]; } - + public void ensureContentsSaved() { try { fInput.saveChanges(new NullProgressMonitor()); @@ -688,7 +688,7 @@ public class PreviewPatchPage2 extends WizardPage { public CompareConfiguration getCompareConfiguration() { return fConfiguration; } - + private void restoreWidgetValues() { IDialogSettings dialogSettings = CompareUI.getPlugin().getDialogSettings(); settings = dialogSettings.getSection(PREVIEWPATCHPAGE_NAME); @@ -703,30 +703,30 @@ public class PreviewPatchPage2 extends WizardPage { getPatcher().setGenerateRejectFile(generateRejects.getSelection()); } } - } - + } + void saveWidgetValues() { settings.put(EXPAND_PATCH_OPTIONS, patchOptions.isExpanded()); settings.put(GENERATE_REJECTS, generateRejects.getSelection()); } - + private String countLines() { int added = 0, removed = 0; - + IPreferenceStore store = CompareUIPlugin.getDefault().getPreferenceStore(); String addedLinesRegex = store.getString(ComparePreferencePage.ADDED_LINES_REGEX); String removedLinesRegex = store.getString(ComparePreferencePage.REMOVED_LINES_REGEX); - + if ((addedLinesRegex == null || "".equals(addedLinesRegex)) //$NON-NLS-1$ && (removedLinesRegex == null || "".equals(removedLinesRegex))) { //$NON-NLS-1$ - + fPatcher.countLines(); FilePatch2[] fileDiffs = fPatcher.getDiffs(); for (int i = 0; i < fileDiffs.length; i++) { added += fileDiffs[i].getAddedLines(); removed += fileDiffs[i].getRemovedLines(); } - + } else { Pattern addedPattern = Pattern.compile(addedLinesRegex); @@ -747,7 +747,7 @@ public class PreviewPatchPage2 extends WizardPage { } } } - + return NLS.bind(PatchMessages.PreviewPatchPage2_AddedRemovedLines, new String[] { added + "", removed + "" }); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java index e2cd72814..425aa0b2e 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/RetargetPatchElementDialog.java @@ -31,7 +31,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.views.navigator.ResourceComparator; class RetargetPatchElementDialog extends Dialog { - + private static class RetargetPatchContentProvider extends BaseWorkbenchContentProvider { private final PatchDiffNode node; public RetargetPatchContentProvider(PatchDiffNode node) { @@ -56,12 +56,12 @@ class RetargetPatchElementDialog extends Dialog { return super.getChildren(element); } } - + private final PatchDiffNode fSelectedNode; private final WorkspacePatcher fPatcher; private TreeViewer fViewer; private IResource fSelectedResource; - + public RetargetPatchElementDialog(Shell shell, WorkspacePatcher patcher, PatchDiffNode node) { super(shell); Assert.isNotNull(patcher); @@ -77,7 +77,7 @@ class RetargetPatchElementDialog extends Dialog { okButton.setEnabled(false); return control; } - + protected Control createDialogArea(Composite parent) { Composite composite= (Composite) super.createDialogArea(parent); @@ -88,7 +88,7 @@ class RetargetPatchElementDialog extends Dialog { GridLayout layout= new GridLayout(); layout.numColumns= 1; layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); composite.setLayout(layout); final GridData data= new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(data); @@ -124,7 +124,7 @@ class RetargetPatchElementDialog extends Dialog { return ResourcesPlugin.getWorkspace().getRoot(); return fPatcher.getTarget(); } - + private IResource getInitialSelection() { if (fSelectedNode instanceof PatchFileDiffNode) { PatchFileDiffNode node = (PatchFileDiffNode) fSelectedNode; @@ -174,7 +174,7 @@ class RetargetPatchElementDialog extends Dialog { fPatcher.retargetHunk(node.getHunkResult().getHunk(), (IFile)fSelectedResource); } } - super.okPressed(); + super.okPressed(); } void setupListeners() { diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java index a4923b4c0..6efb9f35d 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/UnmatchedHunkTypedElement.java @@ -30,7 +30,7 @@ import org.eclipse.core.runtime.CoreException; public class UnmatchedHunkTypedElement extends HunkTypedElement implements IContentChangeNotifier, IEditableContent { private ContentChangeNotifier changeNotifier; - + public UnmatchedHunkTypedElement(HunkResult result) { // An unmatched hunk element is always used for the before state and is full context super(result, false, true); @@ -86,7 +86,7 @@ public class UnmatchedHunkTypedElement extends HunkTypedElement implements ICont private Patcher getPatcher() { return Patcher.getPatcher(getConfiguration()); } - + /* (non-Javadoc) * @see org.eclipse.compare.internal.patch.HunkTypedElement#getContents() */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java index 2c95ff86b..659e8b833 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspaceFileDiffResult.java @@ -27,17 +27,17 @@ public class WorkspaceFileDiffResult extends FileDiffResult { PatchConfiguration configuration) { super(diff, configuration); } - + protected boolean canCreateTarget(IStorage storage) { IProject project = getPatcher().getTargetProject(getDiff()); return project != null && project.isAccessible(); } - + protected boolean targetExists(IStorage storage) { IFile file= (IFile)storage; return file != null && file.isAccessible(); } - + protected List getLines(IStorage storage, boolean create) { IFile file= getTargetFile(); List lines = LineReader.load(file, create); @@ -51,7 +51,7 @@ public class WorkspaceFileDiffResult extends FileDiffResult { public IFile getTargetFile() { return getPatcher().getTargetFile(getDiff()); } - + public void refresh() { refresh(Utilities.getReaderCreator(getTargetFile()), null); } diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java index d63a246dc..611a7aaa6 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java @@ -39,7 +39,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.MultiRule; /** - * A Patcher + * A Patcher * - knows how to parse various patch file formats into some in-memory structure, * - holds onto the parsed data and the options to use when applying the patches, * - knows how to apply the patches to files and folders. @@ -58,14 +58,14 @@ public class WorkspacePatcher extends Patcher { public WorkspacePatcher(IResource target) { setTarget(target); } - + protected void patchParsed(PatchReader patchReader) { super.patchParsed(patchReader); fDiffProjects = patchReader.getDiffProjects(); fIsWorkspacePatch = patchReader.isWorkspacePatch(); fIsGitPatch = patchReader.isGitPatch() && calculateStripGitPrefixSegments() > -1; } - + public DiffProject[] getDiffProjects() { return fDiffProjects; } @@ -172,15 +172,15 @@ public class WorkspacePatcher extends Patcher { } } } - + private boolean isAccessible(FilePatch2 diff) { return isEnabled(diff) && Utilities.getProject(diff.getProject()).isAccessible(); } /** - * Returns the target files of all the Diffs contained by this + * Returns the target files of all the Diffs contained by this * DiffProject. - * @param project + * @param project * @return An array of IFiles that are targeted by the Diffs */ public IFile[] getTargetFiles(DiffProject project) { @@ -202,7 +202,7 @@ public class WorkspacePatcher extends Patcher { return Utilities.getProject(project).getFile(path); return super.getTargetFile(diff); } - + private IPath getFullPath(FilePatch2 diff) { IPath path = diff.getStrippedPath(getStripPrefixSegments(), isReversed()); DiffProject project = getProject(diff); @@ -214,7 +214,7 @@ public class WorkspacePatcher extends Patcher { public ISchedulingRule[] getTargetProjects() { List projects= new ArrayList(); IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory(); - // Determine the appropriate scheduling rules + // Determine the appropriate scheduling rules for (int i= 0; i < fDiffProjects.length; i++) { IProject tempProject= Utilities.getProject(fDiffProjects[i]); // The goal here is to lock as little of the workspace as necessary @@ -226,7 +226,7 @@ public class WorkspacePatcher extends Patcher { MultiRule multiRule= new MultiRule(new ISchedulingRule[] { scheduleRule, tempProject } ); projects.add(multiRule); } - + return (ISchedulingRule[]) projects.toArray(new ISchedulingRule[projects.size()]); } @@ -244,8 +244,8 @@ public class WorkspacePatcher extends Patcher { } } fDiffProjects = temp; - } - + } + protected Object getElementParent(Object element) { if (element instanceof FilePatch2 && fDiffProjects != null) { FilePatch2 diff = (FilePatch2) element; @@ -261,7 +261,7 @@ public class WorkspacePatcher extends Patcher { public boolean isRetargeted(Object object) { return retargetedDiffs.containsKey(object); } - + public IPath getOriginalPath(Object object) { return (IPath)retargetedDiffs.get(object); } @@ -269,7 +269,7 @@ public class WorkspacePatcher extends Patcher { public void retargetDiff(FilePatch2 diff, IFile file) { retargetedDiffs.put(diff, diff.getPath(false)); IHunk[] hunks = diff.getHunks(); - + if (isWorkspacePatch()){ //since the diff has no more hunks to apply, remove it from the parent and the patcher diff.getProject().remove(diff); @@ -310,7 +310,7 @@ public class WorkspacePatcher extends Patcher { return fileDiff; } } - + // Create a new diff for the file IPath path = getDiffPath(file); FilePatch2 newDiff = new FilePatch2(path, 0, path, 0); @@ -361,7 +361,7 @@ public class WorkspacePatcher extends Patcher { // Since the project has been retargeted, remove it from the patcher removeProject(project); } - + /** * Return the diff project for the given project * or <code>null</code> if the diff project doesn't exist @@ -380,7 +380,7 @@ public class WorkspacePatcher extends Patcher { } return null; } - + public int getStripPrefixSegments() { // Segments are never stripped from a workspace patch if (isWorkspacePatch()) |