Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 28602 Details for
Bug 110481
Ability for Apply Patch wizard to work with multiple-project patches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Apply Patch Fixes
ApplyPatchFixes.patch (text/plain), 29.26 KB, created by
Bogdan Gheorghe
on 2005-10-21 10:40:02 EDT
(
hide
)
Description:
Apply Patch Fixes
Filename:
MIME Type:
Creator:
Bogdan Gheorghe
Created:
2005-10-21 10:40:02 EDT
Size:
29.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/patch/Hunk.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Hunk.java,v >retrieving revision 1.11 >diff -u -r1.11 Hunk.java >--- compare/org/eclipse/compare/internal/patch/Hunk.java 6 Oct 2005 17:18:00 -0000 1.11 >+++ compare/org/eclipse/compare/internal/patch/Hunk.java 21 Oct 2005 14:39:03 -0000 >@@ -165,4 +165,8 @@ > return this; > return null; > } >+ >+ protected boolean getHunkProblem() { >+ return fHunkProblem; >+ } > } >Index: compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java,v >retrieving revision 1.30 >diff -u -r1.30 PreviewPatchPage.java >--- compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java 6 Oct 2005 17:18:00 -0000 1.30 >+++ compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java 21 Oct 2005 14:39:03 -0000 >@@ -338,11 +338,31 @@ > DiffProject proj = null; > if (obj instanceof DiffProject){ > proj = (DiffProject) obj; >+ //Check to see if any of the Diffs contained by the DiffProject >+ //have their diff problems set >+ Object[] diffs = proj.getChildren(null); >+ for (int i= 0; i<diffs.length; i++) { >+ if (((Diff) diffs[i]).containsProblems()){ >+ checked.setChecked(obj, false); >+ break; >+ } >+ } > } else if (obj instanceof Diff){ > proj = ((Diff) obj).getProject(); >+ //If Diff has any diff problems set, at least one hunk underneath >+ //does not match - so don't allow entire tree to be checked >+ if (((Diff) obj).containsProblems()){ >+ checked.setChecked(obj, false); >+ } > } else if (obj instanceof Hunk){ > Diff diff = (Diff) ((Hunk) obj).getParent(null); > proj = diff.getProject(); >+ //Check to see if this hunk has any problems OR >+ //if its parent has any problems >+ if( diff.getDiffProblem() || >+ ((Hunk) obj).getHunkProblem()){ >+ checked.setChecked(obj, false); >+ } > } > if (proj!= null && > !proj.getProject().exists()){ >Index: compare/org/eclipse/compare/internal/patch/PatchTargetPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java,v >retrieving revision 1.1 >diff -u -r1.1 PatchTargetPage.java >--- compare/org/eclipse/compare/internal/patch/PatchTargetPage.java 6 Oct 2005 17:18:00 -0000 1.1 >+++ compare/org/eclipse/compare/internal/patch/PatchTargetPage.java 21 Oct 2005 14:39:03 -0000 >@@ -38,7 +38,7 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.model.WorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; >-import org.eclipse.ui.model.WorkbenchViewerSorter; >+import org.eclipse.ui.views.navigator.ResourceSorter; > > /*** > * This page only shows up if the user is trying to apply >@@ -141,7 +141,7 @@ > fPatchTargets = new CheckboxTreeViewer(tree); > fPatchTargets.setLabelProvider(new WorkbenchLabelProvider()); > fPatchTargets.setContentProvider(new WorkbenchContentProvider()); >- fPatchTargets.setSorter(new WorkbenchViewerSorter()); >+ fPatchTargets.setSorter(new ResourceSorter(ResourceSorter.NAME)); > fPatchTargets.setInput(ResourcesPlugin.getWorkspace().getRoot()); > > PatchWizard pw = (PatchWizard) getWizard(); >@@ -154,7 +154,7 @@ > // register listeners > fPatchTargets.addSelectionChangedListener(new ISelectionChangedListener() { > public void selectionChanged(SelectionChangedEvent event) { >- fPatchWizard.setTarget(Utilities.getResource(event.getSelection())); >+ fPatchWizard.setTarget(Utilities.getFirstResource(event.getSelection())); > updateWidgetEnablements(); > } > }); >Index: compare/org/eclipse/compare/internal/patch/Diff.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Diff.java,v >retrieving revision 1.10 >diff -u -r1.10 Diff.java >--- compare/org/eclipse/compare/internal/patch/Diff.java 6 Oct 2005 17:18:00 -0000 1.10 >+++ compare/org/eclipse/compare/internal/patch/Diff.java 21 Oct 2005 14:39:03 -0000 >@@ -159,7 +159,9 @@ > if (hunkFailed) > this.fMatches= false; > hunk.reset(hunkFailed); >- if (!hunkFailed && projectExistsInWorkspace) >+ //If the hunk can be applied and the project exists in the workspace and >+ //there are no problems with the hunk's containing diff, then check the hunk >+ if (!hunkFailed && projectExistsInWorkspace && !fDiffProblem) > hunksToCheck.add(hunk); > } > return hunksToCheck; >@@ -252,6 +254,28 @@ > return this; > return null; > } >+ >+ protected boolean getDiffProblem() { >+ return fDiffProblem; >+ } >+ >+ /** >+ * Returns whether this Diff has any problems >+ * @return true if this Diff or any of its children Hunks have a problem, false if it doesn't >+ */ >+ protected boolean containsProblems() { >+ >+ if (fDiffProblem) >+ return true; >+ >+ for (Iterator iter = fHunks.iterator(); iter.hasNext();) { >+ Hunk element = (Hunk) iter.next(); >+ if (element.getHunkProblem()) { >+ return true; >+ } >+ } >+ return false; >+ } > > } > >Index: compare/org/eclipse/compare/internal/patch/PatchWizard.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java,v >retrieving revision 1.24 >diff -u -r1.24 PatchWizard.java >--- compare/org/eclipse/compare/internal/patch/PatchWizard.java 6 Oct 2005 17:18:00 -0000 1.24 >+++ compare/org/eclipse/compare/internal/patch/PatchWizard.java 21 Oct 2005 14:39:03 -0000 >@@ -45,7 +45,7 @@ > setWindowTitle(PatchMessages.PatchWizard_title); > > fPatcher= new WorkspacePatcher(); >- setTarget(Utilities.getResource(selection)); >+ setTarget(Utilities.getFirstResource(selection)); > > IDialogSettings workbenchSettings= CompareUIPlugin.getDefault().getDialogSettings(); > IDialogSettings section= workbenchSettings.getSection(DIALOG_SETTINGS_KEY); >Index: compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java,v >retrieving revision 1.17 >diff -u -r1.17 CompareWithPatchAction.java >--- compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java 14 Apr 2005 13:53:03 -0000 1.17 >+++ compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java 21 Oct 2005 14:39:03 -0000 >@@ -13,6 +13,29 @@ > import java.lang.reflect.InvocationTargetException; > import java.util.Arrays; > >+import org.eclipse.compare.internal.BaseCompareAction; >+import org.eclipse.compare.internal.ComparePreferencePage; >+import org.eclipse.compare.internal.CompareUIPlugin; >+import org.eclipse.compare.internal.ExceptionHandler; >+import org.eclipse.compare.internal.ListContentProvider; >+import org.eclipse.compare.internal.ListDialog; >+import org.eclipse.compare.internal.Utilities; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceDescription; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.dialogs.ProgressMonitorDialog; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.util.Assert; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.IWizard; >+import org.eclipse.jface.wizard.WizardDialog; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; >@@ -21,33 +44,30 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Shell; >- >-import org.eclipse.jface.dialogs.ProgressMonitorDialog; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.jface.util.Assert; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.jface.window.Window; >-import org.eclipse.jface.wizard.IWizard; >-import org.eclipse.jface.wizard.WizardDialog; >- >-import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.*; >- > import org.eclipse.ui.IEditorPart; > >-import org.eclipse.compare.internal.*; >- > > public class CompareWithPatchAction extends BaseCompareAction { > > static class PatchWizardDialog extends WizardDialog { > >+ private static final String PATCH_WIZARD_SETTINGS_SECTION = "PatchWizard"; //$NON-NLS-1$ >+ > 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; >+ } > } > > protected boolean isEnabled(ISelection selection) { >Index: compare/org/eclipse/compare/internal/patch/PatchMessages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchMessages.properties,v >retrieving revision 1.24 >diff -u -r1.24 PatchMessages.properties >--- compare/org/eclipse/compare/internal/patch/PatchMessages.properties 6 Oct 2005 17:18:00 -0000 1.24 >+++ compare/org/eclipse/compare/internal/patch/PatchMessages.properties 21 Oct 2005 14:39:03 -0000 >@@ -29,16 +29,16 @@ > # InputPatchPage > # > InputPatchPage_title= Patch Input Specification >-InputPatchPage_message= Define the resource to patch and the patch to apply >+InputPatchPage_message= Select the patch location. > InputPatchPage_Clipboard=Clipboard >-InputPatchPage_SelectInput=Select a single file or folder to patch: >+InputPatchPage_SelectInput=&Select a single file or folder to patch: > InputPatchPage_PatchErrorDialog_title=Patch Error > InputPatchPage_SelectPatch_title=Select Patch > InputPatchPage_FileButton_text=Fil&e > InputPatchPage_ChooseFileButton_text=&Browse... > InputPatchPage_UseClipboardButton_text=&Clipboard > InputPatchPage_UseWorkspaceButton_text=&Workspace >-InputPatchPage_WorkspaceSelectPatch_text=Select the location of the patch >+InputPatchPage_WorkspaceSelectPatch_text=&Select the location of the patch > InputPatchPage_NothingSelected_message=Select a file or folder to be patched > InputPatchPage_ClipboardIsEmpty_message=Clipboard is empty > InputPatchPage_NoTextInClipboard_message=Clipboard does not contain text >Index: compare/org/eclipse/compare/internal/patch/InputPatchPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java,v >retrieving revision 1.27 >diff -u -r1.27 InputPatchPage.java >--- compare/org/eclipse/compare/internal/patch/InputPatchPage.java 6 Oct 2005 17:18:00 -0000 1.27 >+++ compare/org/eclipse/compare/internal/patch/InputPatchPage.java 21 Oct 2005 14:39:03 -0000 >@@ -21,6 +21,7 @@ > > import org.eclipse.compare.internal.ICompareContextIds; > import org.eclipse.compare.internal.Utilities; >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.IPath; >@@ -30,6 +31,7 @@ > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.ISelectionChangedListener; > import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.viewers.TreeViewer; > import org.eclipse.jface.wizard.IWizardPage; > import org.eclipse.jface.wizard.WizardPage; >@@ -40,6 +42,8 @@ > import org.eclipse.swt.events.ModifyListener; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.ShellAdapter; >+import org.eclipse.swt.events.ShellEvent; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >@@ -48,11 +52,14 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.FileDialog; > import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.model.WorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; >-import org.eclipse.ui.model.WorkbenchViewerSorter; >+import org.eclipse.ui.views.navigator.ResourceSorter; >+ >+ > > /* package */ class InputPatchPage extends WizardPage { > >@@ -64,6 +71,7 @@ > 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_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; >@@ -85,12 +93,33 @@ > > private PatchWizard fPatchWizard; > >+ private ActivationListener fActivationListener = new ActivationListener(); >+ > protected final static String INPUTPATCHPAGE_NAME= "InputPatchPage"; //$NON-NLS-1$ >- >+ >+ class ActivationListener extends ShellAdapter { >+ public void shellActivated(ShellEvent e) { >+ //Allow error messages if the selected input actually has something selected in it >+ fShowError=true; >+ switch(getInputMethod()){ >+ case FILE: >+ fShowError = (fPatchFileNameField.getText() != ""); //$NON-NLS-1$ >+ break; >+ >+ case WORKSPACE: >+ fShowError = (!fTreeViewer.getSelection().isEmpty()); >+ break; >+ >+ } >+ updateWidgetEnablements(); >+ } >+ } >+ >+ > InputPatchPage(PatchWizard pw) { > super(INPUTPATCHPAGE_NAME, PatchMessages.InputPatchPage_title, null); > fPatchWizard= pw; >- setMessage(PatchMessages.InputPatchPage_message); >+ setMessage(PatchMessages.InputPatchPage_message); > } > > /* >@@ -115,11 +144,21 @@ > setControl(composite); > > buildPatchFileGroup(composite); >- >- restoreWidgetValues(); >- >+ >+ //see if there are any better options presently selected >+ if(!adjustToCurrentTarget()){ >+ //get the persisted values >+ restoreWidgetValues(); >+ } >+ >+ //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); > } >@@ -282,9 +321,24 @@ > addWorkspaceControls(parent); > > // Add listeners >- fUsePatchFileButton.addSelectionListener(new SelectionAdapter() { >+ fUseClipboardButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >+ if (!fUseClipboardButton.getSelection()) >+ return; >+ >+ clearErrorMessage(); > fShowError= true; >+ updateWidgetEnablements(); >+ } >+ }); >+ >+ fUsePatchFileButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (!fUsePatchFileButton.getSelection()) >+ return; >+ //If there is anything typed in at all >+ clearErrorMessage(); >+ fShowError = (fPatchFileNameField.getText() != ""); //$NON-NLS-1$ > int state= getInputMethod(); > setEnablePatchFile(state==FILE); > setEnableWorkspacePatch(state==WORKSPACE); >@@ -299,19 +353,26 @@ > }); > fPatchFileNameField.addModifyListener(new ModifyListener() { > public void modifyText(ModifyEvent e) { >+ clearErrorMessage(); > fShowError= true; > updateWidgetEnablements(); > } > }); > fPatchFileBrowseButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >+ clearErrorMessage(); >+ fShowError= true; > handlePatchFileBrowseButtonPressed(); > updateWidgetEnablements(); > } > }); > fUseWorkspaceButton.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- fShowError= true; >+ if (!fUseWorkspaceButton.getSelection()) >+ return; >+ clearErrorMessage(); >+ //If there is anything typed in at all >+ fShowError = (!fTreeViewer.getSelection().isEmpty()); > int state= getInputMethod(); > setEnablePatchFile(state==FILE); > setEnableWorkspacePatch(state==WORKSPACE); >@@ -321,6 +382,7 @@ > > fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { > public void selectionChanged(SelectionChangedEvent event) { >+ clearErrorMessage(); > updateWidgetEnablements(); > } > }); >@@ -328,9 +390,18 @@ > > private void addWorkspaceControls(Composite composite) { > >- new Label(composite, SWT.LEFT).setText(PatchMessages.InputPatchPage_WorkspaceSelectPatch_text); >- >- fTreeViewer= new TreeViewer(composite, SWT.BORDER); >+ >+ Composite newComp = new Composite(composite, SWT.NONE); >+ GridLayout layout= new GridLayout(1, false); >+ layout.marginWidth = 15; >+ layout.marginHeight = 0; >+ layout.marginLeft = 5; >+ newComp.setLayout(layout); >+ newComp.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ >+ new Label(newComp, SWT.LEFT).setText(PatchMessages.InputPatchPage_WorkspaceSelectPatch_text); >+ >+ fTreeViewer= new TreeViewer(newComp, SWT.BORDER); > final GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true); > gd.widthHint= 0; > gd.heightHint= 0; >@@ -338,10 +409,11 @@ > > fTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); > fTreeViewer.setContentProvider(new WorkbenchContentProvider()); >- fTreeViewer.setSorter(new WorkbenchViewerSorter()); >+ fTreeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); > fTreeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); > } > >+ > /** > * Updates the enable state of this page's controls. > */ >@@ -495,7 +567,7 @@ > */ > private void restoreWidgetValues() { > >- int inputMethod= CLIPBOARD; >+ int inputMethod= FILE; > > IDialogSettings settings= getDialogSettings(); > if (settings != null) { >@@ -517,6 +589,33 @@ > String patchFilePath= settings.get(STORE_PATCH_FILES_ID); > if (patchFilePath != null) > setSourceName(patchFilePath); >+ >+ //If the previous apply patch was used with a clipboard, we need to check >+ //if there is a valid patch on the clipboard. This will be done in adjustToCurrentTarget() >+ //so just set it to FILE now and, if there exists a patch on the clipboard, then clipboard >+ //will be selected automatically >+ if (inputMethod == CLIPBOARD){ >+ inputMethod=FILE; >+ fPatchFileNameField.deselectAll(); >+ } >+ >+ //set the workspace patch selection >+ String workspaceSetting = settings.get(STORE_WORKSPACE_PATH_ID); >+ if (workspaceSetting != null && !workspaceSetting.equals("")){ //$NON-NLS-1$ >+ //See if this resource still exists in the workspace >+ IPath path = new Path(workspaceSetting); >+ IFile targetFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path); >+ if (fTreeViewer != null && targetFile.exists()){ >+ fTreeViewer.expandToLevel(targetFile, 0); >+ fTreeViewer.setSelection(new StructuredSelection(targetFile)); >+ } >+ } 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 >+ //the tree viewer >+ if (inputMethod == WORKSPACE) >+ inputMethod=FILE; >+ } > } > > // set radio buttons state >@@ -541,24 +640,135 @@ > > sourceNames= addToHistory(sourceNames, getPatchFilePath()); > settings.put(STORE_PATCH_FILES_ID, sourceNames); >+ >+ //save the workspace selection >+ settings.put(STORE_WORKSPACE_PATH_ID, getWorkspacePath()); >+ > } > } > >+ private String getWorkspacePath() { >+ if (fTreeViewer != null){ >+ IResource[] resources= Utilities.getResources(fTreeViewer.getSelection()); >+ if (resources.length > 0){ >+ IResource patchFile= resources[0]; >+ return patchFile.getFullPath().toString(); >+ } >+ >+ } >+ return ""; //$NON-NLS-1$ >+ } >+ > // static helpers >+ >+ /** >+ * 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 >+ */ >+ private boolean adjustToCurrentTarget() { >+ //Readjust selection if there is a patch selected in the workspace or on the clipboard >+ //Check workspace first >+ IResource patchTarget = fPatchWizard.getTarget(); >+ if (patchTarget instanceof IFile) { >+ Reader reader = null; >+ try { >+ try { >+ reader = new FileReader(patchTarget.getRawLocation().toFile()); >+ } catch (FileNotFoundException ex) {/*silently ignored*/ >+ } catch (NullPointerException nex) {/*silently ignored*/ >+ } > >+ if (isPatchFile(reader)) { >+ //Set choice to workspace >+ setInputButtonState(WORKSPACE); >+ if (fTreeViewer != null && patchTarget.exists()) { >+ fTreeViewer.expandToLevel(patchTarget, 0); >+ fTreeViewer.setSelection(new StructuredSelection(patchTarget)); >+ } >+ return true; >+ } >+ } finally { >+ if (reader != null) { >+ try { >+ reader.close(); >+ } catch (IOException x) {/*silently ignored*/ >+ } >+ } >+ } >+ } else { >+ //check out clipboard contents >+ Reader reader = null; >+ Control c = getControl(); >+ if (c != null) { >+ Clipboard clipboard = new Clipboard(c.getDisplay()); >+ Object o = clipboard.getContents(TextTransfer.getInstance()); >+ clipboard.dispose(); >+ try { >+ if (o instanceof String) { >+ reader = new StringReader((String) o); >+ if (isPatchFile(reader)) { >+ setInputButtonState(CLIPBOARD); >+ return true; >+ } >+ } >+ } finally { >+ if (reader != null) { >+ try { >+ reader.close(); >+ } catch (IOException x) {/*silently ignored*/ >+ } >+ } >+ } >+ } >+ } >+ return false; >+ } >+ >+ >+ >+ private boolean isPatchFile(Reader reader){ >+ WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher(); >+ >+ try { >+ patcher.parse(new BufferedReader(reader)); >+ } catch (IOException ex) {return false;} >+ >+ Diff[] diffs= patcher.getDiffs(); >+ if (diffs == null || diffs.length == 0) { >+ return false; >+ } >+ >+ return true; >+ } >+ >+ /* >+ * Clears the dialog message box >+ */ >+ private void clearErrorMessage(){ >+ setErrorMessage(null); >+ } >+ > private void setInputButtonState(int state) { > > switch (state) { > case CLIPBOARD : > fUseClipboardButton.setSelection(true); >+ fUsePatchFileButton.setSelection(false); >+ fUseWorkspaceButton.setSelection(false); > break; > > case FILE : >+ fUseClipboardButton.setSelection(false); > fUsePatchFileButton.setSelection(true); >+ fUseWorkspaceButton.setSelection(false); > break; > > case WORKSPACE : >- fUsePatchFileButton.setSelection(true); >+ fUseClipboardButton.setSelection(false); >+ fUsePatchFileButton.setSelection(false); >+ fUseWorkspaceButton.setSelection(true); > break; > } > >Index: compare/org/eclipse/compare/internal/Utilities.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java,v >retrieving revision 1.41 >diff -u -r1.41 Utilities.java >--- compare/org/eclipse/compare/internal/Utilities.java 6 Oct 2005 17:18:00 -0000 1.41 >+++ compare/org/eclipse/compare/internal/Utilities.java 21 Oct 2005 14:39:03 -0000 >@@ -594,7 +594,7 @@ > } > } > >- public static IResource getResource(ISelection selection) { >+ public static IResource getFirstResource(ISelection selection) { > IResource[] resources = getResources(selection); > if (resources.length > 0) > return resources[0]; >Index: compare/org/eclipse/compare/CompareUI.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/CompareUI.java,v >retrieving revision 1.26 >diff -u -r1.26 CompareUI.java >--- compare/org/eclipse/compare/CompareUI.java 6 Oct 2005 17:18:00 -0000 1.26 >+++ compare/org/eclipse/compare/CompareUI.java 21 Oct 2005 14:39:03 -0000 >@@ -14,9 +14,7 @@ > > import org.eclipse.compare.internal.CompareUIPlugin; > import org.eclipse.compare.internal.DocumentManager; >-import org.eclipse.compare.internal.patch.WorkspacePatcher; > import org.eclipse.compare.structuremergeviewer.ICompareInput; >-import org.eclipse.core.resources.IProject; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.jface.resource.ImageDescriptor; >@@ -358,39 +356,5 @@ > DocumentManager.remove(document); > } > >- /** >- * Returns a string that must be the first line of a workspace patch (a multi-project patch >- * that is understood by the Apply Patch wizard). Each project to be included in the patch >- * must be prefixed by the line obtained from the <code>getWorkspacePatchProjectHeader()</code>. >- * This snippet outlines how the a workspace patch is to be created: >- * <pre> >- * //Write out workspace patch header >- * stream.println(CompareUI.getWorkspacePatchHeader()); >- * for (int i=0; i<projects.length; i++){ >- * //Write out project header >- * stream.println(CompareUI.getWorkspacePatchProjectHeader(projects[i]); >- * //Write out patches in Unified Diff format >- * } >- * </pre> >- * @return String >- * @see CompareUI#getWorkspacePatchProjectHeader(IProject) >- * @since 3.2 >- */ >- public static String getWorkspacePatchHeader() { >- return WorkspacePatcher.MULTIPROJECTPATCH_HEADER+" "+WorkspacePatcher.MULTIPROJECTPATCH_VERSION; //$NON-NLS-1$ >- } >- >- /** >- * Returns the project header that must appear before any patches that apply to that >- * project. All patches that are encountered after this header and before the next header >- * are understood to belong the the project. >- * @param project project to be patched >- * @return String >- * @see CompareUI#getWorkspacePatchHeader() >- * @since 3.2 >- */ >- public static String getWorkspacePatchProjectHeader(IProject project) { >- return WorkspacePatcher.MULTIPROJECTPATCH_PROJECT+" "+ project.getName(); //$NON-NLS-1$ >- } > } > >Index: compare/org/eclipse/compare/patch/WorkspacePatcherUI.java >=================================================================== >RCS file: compare/org/eclipse/compare/patch/WorkspacePatcherUI.java >diff -N compare/org/eclipse/compare/patch/WorkspacePatcherUI.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compare/org/eclipse/compare/patch/WorkspacePatcherUI.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+package org.eclipse.compare.patch; >+ >+import org.eclipse.compare.internal.patch.WorkspacePatcher; >+import org.eclipse.core.resources.IProject; >+ >+public class WorkspacePatcherUI { >+ /** >+ * Returns a string that must be the first line of a workspace patch (a multi-project patch >+ * that is understood by the Apply Patch wizard). Each project to be included in the patch >+ * must be prefixed by the line obtained from the <code>getWorkspacePatchProjectHeader()</code>. >+ * This snippet outlines how the a workspace patch is to be created: >+ * <pre> >+ * //Write out workspace patch header >+ * stream.println(CompareUI.getWorkspacePatchHeader()); >+ * for (int i=0; i<projects.length; i++){ >+ * //Write out project header >+ * stream.println(CompareUI.getWorkspacePatchProjectHeader(projects[i]); >+ * //Write out patches in Unified Diff format >+ * } >+ * </pre> >+ * @return String >+ * @see WorkspacePatcherUI#getWorkspacePatchProjectHeader(IProject) >+ * @since 3.2 >+ */ >+ public static String getWorkspacePatchHeader() { >+ return WorkspacePatcher.MULTIPROJECTPATCH_HEADER+" "+WorkspacePatcher.MULTIPROJECTPATCH_VERSION; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Returns the project header that must appear before any patches that apply to that >+ * project. All patches that are encountered after this header and before the next header >+ * are understood to belong the the project. >+ * @param project project to be patched >+ * @return String >+ * @see WorkspacePatcherUI#getWorkspacePatchHeader() >+ * @since 3.2 >+ */ >+ public static String getWorkspacePatchProjectHeader(IProject project) { >+ return WorkspacePatcher.MULTIPROJECTPATCH_PROJECT+" "+ project.getName(); //$NON-NLS-1$ >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 110481
:
27460
|
27925
| 28602