Lines 45-55
Link Here
|
45 |
import org.eclipse.ui.forms.events.ExpansionAdapter; |
45 |
import org.eclipse.ui.forms.events.ExpansionAdapter; |
46 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
46 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
47 |
import org.eclipse.ui.forms.widgets.ExpandableComposite; |
47 |
import org.eclipse.ui.forms.widgets.ExpandableComposite; |
|
|
48 |
import org.eclipse.ui.internal.ide.dialogs.OpenResourceDialog; |
48 |
import org.eclipse.ui.part.ResourceTransfer; |
49 |
import org.eclipse.ui.part.ResourceTransfer; |
49 |
|
50 |
|
50 |
/** |
51 |
/** |
51 |
* This is a dialog that can invoke the compare editor on chosen files. |
52 |
* This is a dialog that can invoke the compare editor on chosen files. |
52 |
* |
53 |
* |
53 |
* @since 3.4 |
54 |
* @since 3.4 |
54 |
*/ |
55 |
*/ |
55 |
public class CompareWithOtherResourceDialog extends TitleAreaDialog { |
56 |
public class CompareWithOtherResourceDialog extends TitleAreaDialog { |
Lines 57-62
Link Here
|
57 |
private int CLEAR_RETURN_CODE = 150; // any number != 0 |
58 |
private int CLEAR_RETURN_CODE = 150; // any number != 0 |
58 |
private int MIN_WIDTH = 300; |
59 |
private int MIN_WIDTH = 300; |
59 |
private int MIN_HEIGHT = 175; |
60 |
private int MIN_HEIGHT = 175; |
|
|
61 |
private int OPEN_RESOURCE_BUTTON_RETURN_CODE = 152; // any number != 0 |
60 |
|
62 |
|
61 |
private class FileTextDragListener implements DragSourceListener { |
63 |
private class FileTextDragListener implements DragSourceListener { |
62 |
|
64 |
|
Lines 159-164
Link Here
|
159 |
protected Group group; |
161 |
protected Group group; |
160 |
protected Text fileText; |
162 |
protected Text fileText; |
161 |
private IResource resource; |
163 |
private IResource resource; |
|
|
164 |
private Button openResourceButton; |
162 |
|
165 |
|
163 |
public InternalSection(Composite parent) { |
166 |
public InternalSection(Composite parent) { |
164 |
createContents(parent); |
167 |
createContents(parent); |
Lines 172-177
Link Here
|
172 |
createGroup(parent); |
175 |
createGroup(parent); |
173 |
createFileLabel(); |
176 |
createFileLabel(); |
174 |
createFileCombo(); |
177 |
createFileCombo(); |
|
|
178 |
createOpenResourceButton(group); |
175 |
initDrag(); |
179 |
initDrag(); |
176 |
initDrop(); |
180 |
initDrop(); |
177 |
} |
181 |
} |
Lines 256-261
Link Here
|
256 |
final Label fileLabel = new Label(group, SWT.NONE); |
260 |
final Label fileLabel = new Label(group, SWT.NONE); |
257 |
fileLabel.setText(CompareMessages.CompareWithOther_fileLabel); |
261 |
fileLabel.setText(CompareMessages.CompareWithOther_fileLabel); |
258 |
} |
262 |
} |
|
|
263 |
|
264 |
protected void createOpenResourceButton(Composite parent) { |
265 |
openResourceButton = createButton(parent, |
266 |
OPEN_RESOURCE_BUTTON_RETURN_CODE, CompareMessages.CompareWithOther_openResourceButton, false); |
267 |
openResourceButton.addSelectionListener(new SelectionListener() { |
268 |
public void widgetDefaultSelected(SelectionEvent e) { |
269 |
widgetSelected(e); |
270 |
} |
271 |
public void widgetSelected(SelectionEvent e) { |
272 |
setResource(getResourceFromDialog()); |
273 |
} |
274 |
}); |
275 |
} |
276 |
|
277 |
private IResource getResourceFromDialog() { |
278 |
IResource r = null; |
279 |
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); |
280 |
OpenResourceDialog dialog = new OpenResourceDialog(getShell(), |
281 |
root, IResource.FILE); |
282 |
int returnCode = dialog.open(); |
283 |
|
284 |
if (returnCode != IDialogConstants.OK_ID) |
285 |
return null; |
286 |
|
287 |
Object[] result = dialog.getResult(); |
288 |
if (result.length > 0) |
289 |
r = (IResource) result[0]; |
290 |
|
291 |
return r; |
292 |
} |
259 |
} |
293 |
} |
260 |
|
294 |
|
261 |
private class InternalGroup extends InternalSection { |
295 |
private class InternalGroup extends InternalSection { |
Lines 286-291
Link Here
|
286 |
createGroup(parent); |
320 |
createGroup(parent); |
287 |
createFileLabel(); |
321 |
createFileLabel(); |
288 |
createFileCombo(); |
322 |
createFileCombo(); |
|
|
323 |
createOpenResourceButton(group); |
289 |
createClearButton(group); |
324 |
createClearButton(group); |
290 |
initDrag(); |
325 |
initDrag(); |
291 |
initDrop(); |
326 |
initDrop(); |
Lines 335-341
Link Here
|
335 |
|
370 |
|
336 |
/** |
371 |
/** |
337 |
* Creates the dialog. |
372 |
* Creates the dialog. |
338 |
* |
373 |
* |
339 |
* @param shell |
374 |
* @param shell |
340 |
* a shell |
375 |
* a shell |
341 |
* @param selection |
376 |
* @param selection |
Lines 351-357
Link Here
|
351 |
|
386 |
|
352 |
/* |
387 |
/* |
353 |
* (non-Javadoc) |
388 |
* (non-Javadoc) |
354 |
* |
389 |
* |
355 |
* @see |
390 |
* @see |
356 |
* org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets |
391 |
* org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets |
357 |
* .Composite) |
392 |
* .Composite) |
Lines 387-393
Link Here
|
387 |
|
422 |
|
388 |
/* |
423 |
/* |
389 |
* (non-Javadoc) |
424 |
* (non-Javadoc) |
390 |
* |
425 |
* |
391 |
* @see |
426 |
* @see |
392 |
* org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse |
427 |
* org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse |
393 |
* .swt.widgets.Composite) |
428 |
* .swt.widgets.Composite) |
Lines 462-468
Link Here
|
462 |
* the ancestor panel, table has only two elements -- resources chosen in |
497 |
* the ancestor panel, table has only two elements -- resources chosen in |
463 |
* left and right panel. In the other case table contains all three |
498 |
* left and right panel. In the other case table contains all three |
464 |
* resources. |
499 |
* resources. |
465 |
* |
500 |
* |
466 |
* @return table with selected resources |
501 |
* @return table with selected resources |
467 |
*/ |
502 |
*/ |
468 |
public IResource[] getResult() { |
503 |
public IResource[] getResult() { |