|
Lines 29-34
Link Here
|
| 29 |
import org.eclipse.jface.dialogs.Dialog; |
29 |
import org.eclipse.jface.dialogs.Dialog; |
| 30 |
import org.eclipse.jface.dialogs.IDialogSettings; |
30 |
import org.eclipse.jface.dialogs.IDialogSettings; |
| 31 |
import org.eclipse.jface.dialogs.MessageDialog; |
31 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
|
32 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
| 33 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
| 32 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
34 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 33 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
35 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 34 |
import org.eclipse.jface.viewers.StructuredSelection; |
36 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
Lines 97-102
Link Here
|
| 97 |
|
99 |
|
| 98 |
protected final static String INPUTPATCHPAGE_NAME= "InputPatchPage"; //$NON-NLS-1$ |
100 |
protected final static String INPUTPATCHPAGE_NAME= "InputPatchPage"; //$NON-NLS-1$ |
| 99 |
|
101 |
|
|
|
102 |
private String patchSource = null; |
| 103 |
|
| 104 |
private boolean patchRead = false; |
| 105 |
|
| 100 |
class ActivationListener extends ShellAdapter { |
106 |
class ActivationListener extends ShellAdapter { |
| 101 |
public void shellActivated(ShellEvent e) { |
107 |
public void shellActivated(ShellEvent e) { |
| 102 |
//Allow error messages if the selected input actually has something selected in it |
108 |
//Allow error messages if the selected input actually has something selected in it |
|
Lines 173-181
Link Here
|
| 173 |
public IWizardPage getNextPage() { |
179 |
public IWizardPage getNextPage() { |
| 174 |
|
180 |
|
| 175 |
WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher(); |
181 |
WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher(); |
|
|
182 |
|
| 183 |
//Read in the patch |
| 184 |
readInPatch(); |
| 185 |
|
| 186 |
Diff[] diffs= patcher.getDiffs(); |
| 187 |
if (diffs == null || diffs.length == 0) { |
| 188 |
String format= PatchMessages.InputPatchPage_NoDiffsFound_format; |
| 189 |
String message= MessageFormat.format(format, new String[] { patchSource }); |
| 190 |
MessageDialog.openInformation(null, |
| 191 |
PatchMessages.InputPatchPage_PatchErrorDialog_title, message); |
| 192 |
return this; |
| 193 |
} |
| 194 |
|
| 195 |
// guess prefix count |
| 196 |
int guess= 0; // guessPrefix(diffs); |
| 197 |
patcher.setStripPrefixSegments(guess); |
| 198 |
|
| 199 |
//If this is a workspace patch we don't need to set a target as the targets will be figured out from |
| 200 |
//all of the projects that make up the patch and continue on to final preview page |
| 201 |
//else go on to target selection page |
| 202 |
if (patcher.isWorkspacePatch()) { |
| 203 |
return fPatchWizard.getPage(PreviewPatchPage.PREVIEWPATCHPAGE_NAME); |
| 204 |
} |
| 176 |
|
205 |
|
| 177 |
String source= ""; //$NON-NLS-1$ |
206 |
return super.getNextPage(); |
|
|
207 |
} |
| 178 |
|
208 |
|
|
|
209 |
/* |
| 210 |
* Reads in the patch contents |
| 211 |
*/ |
| 212 |
public void readInPatch(){ |
| 213 |
WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher(); |
| 179 |
// Create a reader for the input |
214 |
// Create a reader for the input |
| 180 |
Reader reader= null; |
215 |
Reader reader= null; |
| 181 |
try { |
216 |
try { |
|
Lines 189-195
Link Here
|
| 189 |
if (o instanceof String) |
224 |
if (o instanceof String) |
| 190 |
reader= new StringReader((String)o); |
225 |
reader= new StringReader((String)o); |
| 191 |
} |
226 |
} |
| 192 |
source= PatchMessages.InputPatchPage_Clipboard_title; |
227 |
patchSource= PatchMessages.InputPatchPage_Clipboard_title; |
| 193 |
} else if (inputMethod==FILE) { |
228 |
} else if (inputMethod==FILE) { |
| 194 |
String patchFilePath= getPatchFilePath(); |
229 |
String patchFilePath= getPatchFilePath(); |
| 195 |
if (patchFilePath != null) { |
230 |
if (patchFilePath != null) { |
|
Lines 201-207
Link Here
|
| 201 |
PatchMessages.InputPatchPage_PatchFileNotFound_message); |
236 |
PatchMessages.InputPatchPage_PatchFileNotFound_message); |
| 202 |
} |
237 |
} |
| 203 |
} |
238 |
} |
| 204 |
source= PatchMessages.InputPatchPage_PatchFile_title; |
239 |
patchSource= PatchMessages.InputPatchPage_PatchFile_title; |
| 205 |
} else if (inputMethod==WORKSPACE) { |
240 |
} else if (inputMethod==WORKSPACE) { |
| 206 |
//Get the selected patch file (tree will only allow for one selection) |
241 |
//Get the selected patch file (tree will only allow for one selection) |
| 207 |
IResource[] resources= Utilities.getResources(fTreeViewer.getSelection()); |
242 |
IResource[] resources= Utilities.getResources(fTreeViewer.getSelection()); |
|
Lines 216-228
Link Here
|
| 216 |
MessageDialog.openError(null, PatchMessages.InputPatchPage_PatchErrorDialog_title, PatchMessages.InputPatchPage_PatchFileNotFound_message); |
251 |
MessageDialog.openError(null, PatchMessages.InputPatchPage_PatchErrorDialog_title, PatchMessages.InputPatchPage_PatchFileNotFound_message); |
| 217 |
} |
252 |
} |
| 218 |
} |
253 |
} |
| 219 |
source= PatchMessages.InputPatchPage_WorkspacePatch_title; |
254 |
patchSource= PatchMessages.InputPatchPage_WorkspacePatch_title; |
| 220 |
} |
255 |
} |
| 221 |
|
256 |
|
| 222 |
// parse the input |
257 |
// parse the input |
| 223 |
if (reader != null) { |
258 |
if (reader != null) { |
| 224 |
try { |
259 |
try { |
| 225 |
patcher.parse(new BufferedReader(reader)); |
260 |
patcher.parse(new BufferedReader(reader)); |
|
|
261 |
patchRead=true; |
| 226 |
} catch (IOException ex) { |
262 |
} catch (IOException ex) { |
| 227 |
MessageDialog.openError(null, |
263 |
MessageDialog.openError(null, |
| 228 |
PatchMessages.InputPatchPage_PatchErrorDialog_title, |
264 |
PatchMessages.InputPatchPage_PatchErrorDialog_title, |
|
Lines 238-267
Link Here
|
| 238 |
} |
274 |
} |
| 239 |
} |
275 |
} |
| 240 |
} |
276 |
} |
| 241 |
|
|
|
| 242 |
Diff[] diffs= patcher.getDiffs(); |
| 243 |
if (diffs == null || diffs.length == 0) { |
| 244 |
String format= PatchMessages.InputPatchPage_NoDiffsFound_format; |
| 245 |
String message= MessageFormat.format(format, new String[] { source }); |
| 246 |
MessageDialog.openInformation(null, |
| 247 |
PatchMessages.InputPatchPage_PatchErrorDialog_title, message); |
| 248 |
return this; |
| 249 |
} |
| 250 |
|
| 251 |
// guess prefix count |
| 252 |
int guess= 0; // guessPrefix(diffs); |
| 253 |
patcher.setStripPrefixSegments(guess); |
| 254 |
|
| 255 |
//If this is a workspace patch we don't need to set a target as the targets will be figured out from |
| 256 |
//all of the projects that make up the patch and continue on to final preview page |
| 257 |
//else go on to target selection page |
| 258 |
if (patcher.isWorkspacePatch()) { |
| 259 |
return fPatchWizard.getPage(PreviewPatchPage.PREVIEWPATCHPAGE_NAME); |
| 260 |
} |
| 261 |
|
| 262 |
return super.getNextPage(); |
| 263 |
} |
277 |
} |
| 264 |
|
278 |
|
| 265 |
/* (non-JavaDoc) |
279 |
/* (non-JavaDoc) |
| 266 |
* Method declared in IWizardPage. |
280 |
* Method declared in IWizardPage. |
| 267 |
*/ |
281 |
*/ |
|
Lines 386-391
Link Here
|
| 386 |
updateWidgetEnablements(); |
400 |
updateWidgetEnablements(); |
| 387 |
} |
401 |
} |
| 388 |
}); |
402 |
}); |
|
|
403 |
|
| 404 |
fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { |
| 405 |
public void doubleClick(DoubleClickEvent event) { |
| 406 |
fPatchWizard.showPage(getNextPage()); |
| 407 |
} |
| 408 |
}); |
| 389 |
} |
409 |
} |
| 390 |
|
410 |
|
| 391 |
private void addWorkspaceControls(Composite composite) { |
411 |
private void addWorkspaceControls(Composite composite) { |
|
Lines 812-816
Link Here
|
| 812 |
|
832 |
|
| 813 |
return (String[]) l.toArray(new String[l.size()]); |
833 |
return (String[]) l.toArray(new String[l.size()]); |
| 814 |
} |
834 |
} |
|
|
835 |
|
| 836 |
public boolean isPatchRead() { |
| 837 |
return patchRead; |
| 838 |
} |
| 815 |
} |
839 |
} |
| 816 |
|
840 |
|