### Eclipse Workspace Patch 1.0 #P org.eclipse.compare Index: compare/org/eclipse/compare/internal/CompareMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java,v retrieving revision 1.17.4.2 diff -u -r1.17.4.2 CompareMessages.java --- compare/org/eclipse/compare/internal/CompareMessages.java 16 Jul 2008 10:45:52 -0000 1.17.4.2 +++ compare/org/eclipse/compare/internal/CompareMessages.java 21 Jul 2008 13:51:02 -0000 @@ -116,11 +116,8 @@ public static String CompareWithOther_dialogMessage; public static String CompareWithOther_error_not_comparable; public static String CompareWithOther_error_empty; - public static String CompareWithOther_clearAll; public static String CompareWithOther_clear; - public static String CompareWithOther_clipboard; - public static String CompareWithOther_tmp_file_path; - public static String CompareWithOther_clipboard_files; + public static String CompareWithOther_warning_two_way; static { NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class); Index: compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Attic/CompareWithOtherResourceDialog.java,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 CompareWithOtherResourceDialog.java --- compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java 16 Jul 2008 10:45:52 -0000 1.1.2.2 +++ compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java 21 Jul 2008 13:51:02 -0000 @@ -49,14 +49,14 @@ /** * This is a dialog that can invoke the compare editor on chosen files. - *

- * This class can be used as is or can be subclassed. - * + * * @since 3.4 */ public class CompareWithOtherResourceDialog extends TitleAreaDialog { private int CLEAR_RETURN_CODE = 150; // any number != 0 + private int MIN_WIDTH = 300; + private int MIN_HEIGHT = 175; private class FileTextDragListener implements DragSourceListener { @@ -71,7 +71,9 @@ } public void dragSetData(DragSourceEvent event) { - if (TextTransfer.getInstance().isSupportedType(event.dataType)) + if (TextTransfer.getInstance().isSupportedType(event.dataType)) { + event.data = section.fileText.getText(); + } else event.data = section.fileText.getText(); } @@ -103,7 +105,8 @@ } for (int i = 0; i < event.dataTypes.length; i++) { - if (resourceTransfer.isSupportedType(event.dataTypes[i])) { + if (resourceTransfer.isSupportedType(event.dataTypes[i]) + || textTransfer.isSupportedType(event.dataTypes[i])) { event.currentDataType = event.dataTypes[i]; if (event.detail != DND.DROP_COPY) event.detail = DND.DROP_NONE; @@ -156,9 +159,8 @@ private abstract class InternalSection { protected Group group; - private Text fileText; + protected Text fileText; private IResource resource; - private Button clearButton; public InternalSection(Composite parent) { createContents(parent); @@ -172,7 +174,6 @@ createGroup(parent); createFileLabel(); createFileCombo(); - createClearButton(group); initDrag(); initDrop(); } @@ -205,7 +206,7 @@ protected void initDrag() { DragSource source = new DragSource(fileText, DND.DROP_MOVE - | DND.DROP_COPY); + | DND.DROP_COPY | DND.DROP_DEFAULT); Transfer[] types = new Transfer[] { TextTransfer.getInstance(), ResourceTransfer.getInstance() }; source.setTransfer(types); @@ -224,13 +225,13 @@ protected void createGroup(Composite parent) { group = new Group(parent, SWT.NONE); group.setLayout(new GridLayout(3, false)); - group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); } protected void createFileCombo() { fileText = new Text(group, SWT.BORDER); - fileText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - false)); + fileText + .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); fileText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { @@ -257,20 +258,6 @@ final Label fileLabel = new Label(group, SWT.NONE); fileLabel.setText(CompareMessages.CompareWithOther_fileLabel); } - - protected void createClearButton(Composite parent) { - clearButton = createButton(parent, CLEAR_RETURN_CODE, - CompareMessages.CompareWithOther_clear, false); - clearButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - - public void widgetSelected(SelectionEvent e) { - clearResource(); - } - }); - } } private class InternalGroup extends InternalSection { @@ -291,11 +278,21 @@ private class InternalExpandable extends InternalSection { private ExpandableComposite expandable; + private Button clearButton; public InternalExpandable(Composite parent) { createContents(parent); } + public void createContents(Composite parent) { + createGroup(parent); + createFileLabel(); + createFileCombo(); + createClearButton(group); + initDrag(); + initDrop(); + } + public void createGroup(Composite parent) { final Composite p = parent; expandable = new ExpandableComposite(parent, SWT.NONE, @@ -304,7 +301,21 @@ expandable.setClient(group); expandable.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { - p.getShell().pack(); + p.layout(); + } + }); + } + + protected void createClearButton(Composite parent) { + clearButton = createButton(parent, CLEAR_RETURN_CODE, + CompareMessages.CompareWithOther_clear, false); + clearButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + public void widgetSelected(SelectionEvent e) { + clearResource(); } }); } @@ -319,14 +330,14 @@ } } - private Button okButton, clearAllButton; + private Button okButton; private InternalGroup rightPanel, leftPanel; private InternalExpandable ancestorPanel; private ISelection fselection; /** * Creates the dialog. - * + * * @param shell * a shell * @param selection @@ -342,7 +353,7 @@ /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets * .Composite) @@ -355,51 +366,37 @@ ancestorPanel = new InternalExpandable(mainPanel); ancestorPanel.setText(CompareMessages.CompareWithOther_ancestor); - GridData ancestorGD = new GridData(SWT.FILL, SWT.FILL, true, true); + GridData ancestorGD = new GridData(SWT.FILL, SWT.FILL, true, false); ancestorGD.horizontalSpan = 2; ancestorPanel.setLayoutData(ancestorGD); - rightPanel = new InternalGroup(mainPanel); - rightPanel.setText(CompareMessages.CompareWithOther_rightPanel); - rightPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - leftPanel = new InternalGroup(mainPanel); leftPanel.setText(CompareMessages.CompareWithOther_leftPanel); - leftPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + leftPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + rightPanel = new InternalGroup(mainPanel); + rightPanel.setText(CompareMessages.CompareWithOther_rightPanel); + rightPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); setSelection(fselection); getShell().setText(CompareMessages.CompareWithOther_dialogTitle); setTitle(CompareMessages.CompareWithOther_dialogMessage); + getShell().setMinimumSize(convertHorizontalDLUsToPixels(MIN_WIDTH), + convertVerticalDLUsToPixels(MIN_HEIGHT)); return mainPanel; } /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse * .swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); okButton = getButton(IDialogConstants.OK_ID); - - clearAllButton = createButton(parent, CLEAR_RETURN_CODE, - CompareMessages.CompareWithOther_clearAll, false); - clearAllButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - - public void widgetSelected(SelectionEvent e) { - leftPanel.clearResource(); - rightPanel.clearResource(); - ancestorPanel.clearResource(); - } - }); - updateErrorInfo(); } @@ -444,6 +441,10 @@ setMessage(CompareMessages.CompareWithOther_error_empty, IMessageProvider.ERROR); okButton.setEnabled(false); + } else if (ancestorPanel.getResource() == null + && ancestorPanel.fileText.getText() != "") { //$NON-NLS-1$ + setMessage(CompareMessages.CompareWithOther_warning_two_way, + IMessageProvider.WARNING); } else if (!comparePossible()) { setMessage( CompareMessages.CompareWithOther_error_not_comparable, @@ -461,7 +462,7 @@ * 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() { Index: compare/org/eclipse/compare/internal/CompareMessages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties,v retrieving revision 1.27.4.2 diff -u -r1.27.4.2 CompareMessages.properties --- compare/org/eclipse/compare/internal/CompareMessages.properties 16 Jul 2008 10:45:51 -0000 1.27.4.2 +++ compare/org/eclipse/compare/internal/CompareMessages.properties 21 Jul 2008 13:51:02 -0000 @@ -122,14 +122,11 @@ CompareWithOther_fileLabel=File: CompareWithOther_ancestor=Ancestor -CompareWithOther_rightPanel=Right panel -CompareWithOther_leftPanel=Left panel -CompareWithOther_dialogTitle=Compare with Other Resource... +CompareWithOther_rightPanel=Right +CompareWithOther_leftPanel=Left +CompareWithOther_dialogTitle=Compare with Other Resource CompareWithOther_dialogMessage=Select resources to compare CompareWithOther_error_not_comparable=Selected resources are not comparable. -CompareWithOther_error_empty=Both left and right panel must contain a valid path to resource from workspace. -CompareWithOther_clearAll=Clear All -CompareWithOther_clear=Clear -CompareWithOther_clipboard=From clipboard -CompareWithOther_tmp_file_path=clipboard -CompareWithOther_clipboard_files=ClipboardTmpFiles \ No newline at end of file +CompareWithOther_error_empty=Both left and right panel must contain a valid path. +CompareWithOther_warning_two_way=Ancestor is not a valid resource. Two-way compare will be performed. +CompareWithOther_clear=Clear \ No newline at end of file