### Eclipse Workspace Patch 1.0
#P org.eclipse.compare
Index: compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/Attic/GenerateDiffFileWizard.java,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 GenerateDiffFileWizard.java
--- compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java 30 Mar 2009 15:53:03 -0000 1.1.2.7
+++ compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java 2 Apr 2009 10:25:18 -0000
@@ -81,8 +81,8 @@
public class GenerateDiffFileWizard extends Wizard {
//The initial size of this wizard.
- protected final static int INITIAL_WIDTH = 300;
- protected final static int INITIAL_HEIGHT = 350;
+ private final static int INITIAL_WIDTH = 300;
+ private final static int INITIAL_HEIGHT = 350;
public static void run(DocumentMerger merger, Shell shell, boolean rightToLeft) {
final String title = CompareMessages.GenerateLocalDiff_title;
@@ -93,7 +93,7 @@
dialog.open();
}
- protected class DirectionSelectionPage extends WizardPage {
+ public class DirectionSelectionPage extends WizardPage {
public final static int LEFT_OPTION = 1;
public final static int RIGHT_OPTION = 2;
@@ -184,7 +184,7 @@
* Page to select a patch file. Overriding validatePage was necessary to
* allow entering a file name that already exists.
*/
- protected class LocationPage extends WizardPage {
+ public class LocationPage extends WizardPage {
/**
* The possible locations to save a patch.
@@ -266,7 +266,7 @@
return control;
}
- protected Control createDialogArea(Composite parent) {
+ protected Control createDialogArea(Composite parent){
Composite parentComposite = (Composite) super.createDialogArea(parent);
// create a composite with standard margins and spacing
@@ -598,6 +598,7 @@
* selected to save the patch in the clipboard or file system.
*/
public String getWorkspaceLocation() {
+
if (pageValid && selectedLocation == WORKSPACE) {
final String filename= wsPathText.getText().trim();
return filename;
@@ -640,6 +641,15 @@
Dialog.applyDialogFont(parent);
+ /**
+ * Ensure the page is in a valid state.
+ */
+ /*if (!validatePage()) {
+ store.storeRadioSelection(CLIPBOARD);
+ initializeDefaultValues();
+ validatePage();
+ }
+ pageValid= true;*/
validatePage();
updateEnablements();
@@ -857,29 +867,39 @@
public final static int ROOT_WORKSPACE = 1;
public final static int ROOT_PROJECT = 2;
public final static int ROOT_SELECTION = 3;
- public final static int ROOT_CUSTOM = 4;
-
- protected boolean initialized = false;
-
- protected Button unifiedDiffOption;
- protected Button unified_workspaceRelativeOption; //multi-patch format
- protected Button unified_projectRelativeOption; //full project path
- protected Button unified_selectionRelativeOption; //use path of whatever is selected
- protected Button contextDiffOption;
- protected Button regularDiffOption;
-
- protected Group unifiedGroup;
- protected Group diffTypeGroup;
+ private Button unifiedDiffOption;
+ private Button unified_workspaceRelativeOption; //multi-patch format
+ private Button unified_projectRelativeOption; //full project path
+ private Button unified_selectionRelativeOption; //use path of whatever is selected
+ private Button contextDiffOption;
+ private Button regularDiffOption;
protected final RadioButtonGroup diffTypeRadioGroup = new RadioButtonGroup();
protected final RadioButtonGroup unifiedRadioGroup = new RadioButtonGroup();
+ protected Group unifiedGroup;
+ protected Group diffTypeGroup;
+
+ private boolean patchHasCommonRoot=true;
private final DefaultValuesStore store;
/**
* Constructor for PatchFileCreationOptionsPage.
+ *
+ * @param pageName
+ * the name of the page
+ *
+ * @param title
+ * the title for this wizard page, or null
if
+ * none
+ * @param titleImage
+ * the image descriptor for the title of this wizard page, or
+ * null
if none
+ * @param store
+ * the value store where the page stores it's data
*/
- protected OptionsPage(String pageName, String title, ImageDescriptor titleImage, DefaultValuesStore store) {
+ protected OptionsPage(String pageName, String title,
+ ImageDescriptor titleImage, DefaultValuesStore store) {
super(pageName, title, titleImage);
this.store = store;
}
@@ -917,7 +937,7 @@
diffTypeRadioGroup.add(FORMAT_CONTEXT, contextDiffOption);
diffTypeRadioGroup.add(FORMAT_STANDARD, regularDiffOption);
- // Unified Format Options
+ //Unified Format Options
unifiedGroup = new Group(composite, SWT.None);
layout = new GridLayout();
layout.numColumns = 2;
@@ -928,18 +948,12 @@
unified_workspaceRelativeOption = new Button(unifiedGroup, SWT.RADIO);
unified_workspaceRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_6);
- unified_workspaceRelativeOption.setLayoutData(new GridData(
- SWT.BEGINNING, SWT.CENTER, false, false, 2, 1));
unified_projectRelativeOption = new Button(unifiedGroup, SWT.RADIO);
unified_projectRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_7);
- unified_projectRelativeOption.setLayoutData(new GridData(
- SWT.BEGINNING, SWT.CENTER, false, false, 2, 1));
unified_selectionRelativeOption = new Button(unifiedGroup, SWT.RADIO);
unified_selectionRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_8);
- unified_selectionRelativeOption.setLayoutData(new GridData(
- SWT.BEGINNING, SWT.CENTER, false, true, 2, 1));
unifiedRadioGroup.add(ROOT_WORKSPACE, unified_workspaceRelativeOption);
unifiedRadioGroup.add(ROOT_PROJECT, unified_projectRelativeOption);
@@ -997,17 +1011,11 @@
updateEnablements();
- performSpecificActions();
-
// update selection
diffTypeRadioGroup.selectEnabledOnly();
unifiedRadioGroup.selectEnabledOnly();
}
- protected void performSpecificActions() {
- return;
- }
-
public int getFormatSelection() {
return diffTypeRadioGroup.getSelected();
}
@@ -1016,48 +1024,54 @@
return unifiedRadioGroup.getSelected();
}
- public String getPath() {
- return unified_customRelativeText.getText();
- }
-
private void initializeDefaultValues() {
// Radio buttons for format
diffTypeRadioGroup.setSelection(store.getFormatSelection(), true);
// Radio buttons for patch root
unifiedRadioGroup.setSelection(store.getRootSelection(), true);
- }
- protected void updateEnablements() {
- if(diffTypeRadioGroup.selected != FORMAT_UNIFIED)
+ if (store.getFormatSelection() != FORMAT_UNIFIED) {
setEnableUnifiedGroup(false);
+ }
}
- public void updateDiffTypeEnablements(int[] disabled, int enabled) {
- diffTypeRadioGroup.setEnablement(false, disabled, enabled);
- }
- public void updateUnifiedEnablements(int[] disabled, int enabled) {
- unifiedRadioGroup.setEnablement(false, disabled, enabled);
- }
+ protected void updateEnablements() {
+ if (!patchHasCommonRoot){
+ diffTypeRadioGroup.setEnablement(false, new int[] {
+ FORMAT_CONTEXT, FORMAT_STANDARD }, FORMAT_UNIFIED);
+ unifiedRadioGroup.setEnablement(false, new int[] {
+ ROOT_PROJECT, ROOT_SELECTION }, ROOT_WORKSPACE);
+ }
- protected void setEnableUnifiedGroup(boolean enabled) {
+ // temporary until we figure out best way to fix synchronize view
+ // selection
+ if (!unifiedSelectionEnabled)
+ unifiedRadioGroup.setEnablement(false, new int[] {ROOT_SELECTION});
+ }
+
+ protected void setEnableUnifiedGroup(boolean enabled){
unifiedRadioGroup.setEnablement(enabled, new int[] {
ROOT_WORKSPACE, ROOT_PROJECT, ROOT_SELECTION });
- }
+ //temporary until we figure out best way to fix synchronize view selection
+ if (!unifiedSelectionEnabled)
+ unifiedRadioGroup.setEnablement(false, new int[] {ROOT_SELECTION});
+ }
}
/**
* Class to retrieve and store the default selected values.
*/
- protected final class DefaultValuesStore {
+ private final class DefaultValuesStore {
- private static final String PREF_LAST_SELECTION = "org.eclipse.compare.internal.GenerateDiffFileWizard.PatchFileSelectionPage.lastselection"; //$NON-NLS-1$
- private static final String PREF_LAST_FS_PATH = "org.eclipse.compare.internal.GenerateDiffFileWizard.PatchFileSelectionPage.filesystem.path"; //$NON-NLS-1$
- private static final String PREF_LAST_WS_PATH = "org.eclipse.compare.internal.GenerateDiffFileWizard.PatchFileSelectionPage.workspace.path"; //$NON-NLS-1$
+ private static final String PREF_LAST_SELECTION= "org.eclipse.compare.internal.GenerateDiffFileWizard.PatchFileSelectionPage.lastselection"; //$NON-NLS-1$
+ private static final String PREF_LAST_FS_PATH= "org.eclipse.compare.internal.GenerateDiffFileWizard.PatchFileSelectionPage.filesystem.path"; //$NON-NLS-1$
+ private static final String PREF_LAST_WS_PATH= "org.eclipse.compare.internal.GenerateDiffFileWizard.PatchFileSelectionPage.workspace.path"; //$NON-NLS-1$
private static final String PREF_LAST_AO_FORMAT = "org.eclipse.compare.internal.GenerateDiffFileWizard.OptionsPage.diff.format"; //$NON-NLS-1$
private static final String PREF_LAST_AO_ROOT = "org.eclipse.compare.internal.GenerateDiffFileWizard.OptionsPage.patch.root"; //$NON-NLS-1$
+
private final IDialogSettings dialogSettings;
public DefaultValuesStore() {
@@ -1069,7 +1083,7 @@
try {
value= dialogSettings.getInt(PREF_LAST_SELECTION);
} catch (NumberFormatException e) {
- // do nothing
+ // ignore
}
switch (value) {
@@ -1151,7 +1165,7 @@
private DirectionSelectionPage directionSelectionPage;
private LocationPage locationPage;
private OptionsPage optionsPage;
-
+
private final DefaultValuesStore defaultValuesStore;
private DocumentMerger merger;
@@ -1163,14 +1177,14 @@
private boolean targetFileEdited = false;
- private Text unified_customRelativeText;
- private Button unified_customRelativeOption;
+ //temporary until we figure out best way to fix synchronize view selection
+ protected boolean unifiedSelectionEnabled = true;
public GenerateDiffFileWizard() {
super();
setWindowTitle(CompareMessages.GenerateLocalDiff_title);
initializeDefaultPageImageDescriptor();
- defaultValuesStore = new DefaultValuesStore();
+ defaultValuesStore= new DefaultValuesStore();
}
public GenerateDiffFileWizard(DocumentMerger merger, boolean rightToLeft) {
@@ -1206,6 +1220,11 @@
.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF),
defaultValuesStore) {
+ private Text unified_customRelativeText;
+ private Button unified_customRelativeOption;
+ public final static int ROOT_CUSTOM = 4;
+ protected boolean initialized = false;
+
public void setVisible(boolean visible) {
super.setVisible(visible);
if (!initialized && visible) {
@@ -1218,9 +1237,13 @@
}
validateCustomPatchRoot(this.getPath());
}
+
+ private String getPath() {
+ return unified_customRelativeText.getText();
+ }
private void validateCustomPatchRoot(String path) {
- if (this.getRootSelection() == OptionsPage.ROOT_CUSTOM
+ if (this.getRootSelection() == ROOT_CUSTOM
&& !ResourcesPlugin.getWorkspace().validatePath(path,
IResource.FILE).isOK()) {
this.setMessage(CompareMessages.GenerateLocalDiff_4,
@@ -1230,10 +1253,6 @@
this.setMessage(null);
}
- protected void performSpecificActions() {
- createCustomRelativeControl();
- }
-
protected void updateEnablements() {
diffTypeRadioGroup.setEnablement(false, new int[] { FORMAT_CONTEXT,
FORMAT_STANDARD }, FORMAT_UNIFIED);
@@ -1246,6 +1265,22 @@
ROOT_WORKSPACE, ROOT_PROJECT, ROOT_SELECTION });
}
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ createCustomRelativeControl();
+ updateEnablements();
+ diffTypeRadioGroup.selectEnabledOnly();
+ unifiedRadioGroup.selectEnabledOnly();
+ }
+
+ public void updateDiffTypeEnablements(int[] disabled, int enabled) {
+ diffTypeRadioGroup.setEnablement(false, disabled, enabled);
+ }
+
+ public void updateUnifiedEnablements(int[] disabled, int enabled) {
+ unifiedRadioGroup.setEnablement(false, disabled, enabled);
+ }
+
private void createCustomRelativeControl() {
unified_customRelativeOption = new Button(unifiedGroup, SWT.RADIO);
unified_customRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_13);
@@ -1266,14 +1301,14 @@
}
});
- unifiedRadioGroup.add(OptionsPage.ROOT_CUSTOM, unified_customRelativeOption);
+ unifiedRadioGroup.add(ROOT_CUSTOM, unified_customRelativeOption);
unified_customRelativeOption.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- unifiedRadioGroup.setSelection(OptionsPage.ROOT_CUSTOM, false);
+ unifiedRadioGroup.setSelection(ROOT_CUSTOM, false);
}
});
- optionsPage.updateDiffTypeEnablements(new int[] {OptionsPage.FORMAT_CONTEXT, OptionsPage.FORMAT_STANDARD}, OptionsPage.FORMAT_UNIFIED);
- optionsPage.updateUnifiedEnablements(new int[] {OptionsPage.ROOT_PROJECT, OptionsPage.ROOT_WORKSPACE, OptionsPage.ROOT_SELECTION}, OptionsPage.ROOT_CUSTOM);
+ updateDiffTypeEnablements(new int[] {OptionsPage.FORMAT_CONTEXT, OptionsPage.FORMAT_STANDARD}, OptionsPage.FORMAT_UNIFIED);
+ updateUnifiedEnablements(new int[] {OptionsPage.ROOT_PROJECT, OptionsPage.ROOT_WORKSPACE, OptionsPage.ROOT_SELECTION}, ROOT_CUSTOM);
}
};
optionsPage.setDescription(pageDescription);
@@ -1281,7 +1316,7 @@
}
/**
- * Declares the wizard banner image descriptor
+ * Declares the wizard banner iamge descriptor
*/
protected void initializeDefaultPageImageDescriptor() {
final String iconPath= "icons/full/"; //$NON-NLS-1$
@@ -1295,22 +1330,20 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#needsProgressMonitor()
+ /* (Non-javadoc)
+ * Method declared on IWizard.
*/
public boolean needsProgressMonitor() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ /**
+ * Completes processing of the wizard. If this method returns
+ * true
, the wizard will close; otherwise, it will stay active.
*/
public boolean performFinish() {
- final int location = locationPage.getSelectedLocation();
+
+ final int location= locationPage.getSelectedLocation();
final File file= location != LocationPage.CLIPBOARD? locationPage.getFile() : null;
@@ -1431,24 +1464,6 @@
return true;
}
- public boolean validateFile2(IFile file) {
- if (file == null)
- return false;
-
- // Consider file invalid if it doesn't exist.
- if (!file.exists()) {
- final String title = CompareMessages.GenerateLocalDiff_3;
- final String msg = CompareMessages.GenerateLocalDiff_4;
- final MessageDialog dialog = new MessageDialog(getShell(), title,
- null, msg, MessageDialog.ERROR,
- new String[] { IDialogConstants.OK_LABEL }, 0);
- dialog.open();
- return false;
- }
-
- return true;
- }
-
public LocationPage getLocationPage() {
return locationPage;
}