summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorDani Megert2012-02-22 16:16:25 (EST)
committer Matthias Sohn2012-02-22 16:16:25 (EST)
commit358e1bee1c409a67e7fa037fbaadd85d9be83087 (patch)
tree658038ee8075ad61c0a5872e3898ec7dbbf58ec1
parent99615d6bee5789c2cb3851b0c63922ac19935fdd (diff)
downloadegit-358e1bee1c409a67e7fa037fbaadd85d9be83087.zip
egit-358e1bee1c409a67e7fa037fbaadd85d9be83087.tar.gz
egit-358e1bee1c409a67e7fa037fbaadd85d9be83087.tar.bz2
Remember previously chosen location in 'Create Patch' wizardrefs/changes/37/5137/4
Bug 372217 Change-Id: Ic294d8235f9ce0d97aaab4f752ae44b5776b16a8 Signed-off-by: Dani Megert <Daniel_Megert@ch.ibm.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/LocationPage.java60
1 files changed, 34 insertions, 26 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/LocationPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/LocationPage.java
index e8966cf..2f00c34 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/LocationPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/LocationPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010-2012 SAP AG and others.
+ * Copyright (c) 2010, 2012 SAP AG and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> - Allow to save patches in Workspace
+ * Daniel Megert <daniel_megert@ch.ibm.com> - Create Patch... should remember previously chosen location
*******************************************************************************/
package org.eclipse.egit.ui.internal.history;
@@ -70,6 +71,11 @@ import org.eclipse.ui.views.navigator.ResourceComparator;
public class LocationPage extends WizardPage {
private static final String PATH_KEY = "GitCreatePatchWizard.LocationPage.path"; //$NON-NLS-1$
+ private static final String LOCATION_KEY = "GitCreatePatchWizard.LocationPage.location"; //$NON-NLS-1$
+ private static final String LOCATION_VALUE_CLIPBOARD = "clipboard"; //$NON-NLS-1$
+ private static final String LOCATION_VALUE_FILE_SYSTEM = "filesystem"; //$NON-NLS-1$
+ private static final String LOCATION_VALUE_WORKSPACE = "workspace"; //$NON-NLS-1$
+
private Button cpRadio;
@@ -103,10 +109,9 @@ public class LocationPage extends WizardPage {
return allProjects;
ArrayList<IProject> accessibleProjects = new ArrayList<IProject>();
- for (IProject project : allProjects) {
+ for (IProject project : allProjects)
if (project.isOpen())
accessibleProjects.add(project);
- }
return accessibleProjects.toArray();
}
return super.getChildren(element);
@@ -194,16 +199,15 @@ public class LocationPage extends WizardPage {
String label, boolean defaultButton) {
Button button = super.createButton(parent, id, label,
defaultButton);
- if (id == IDialogConstants.OK_ID) {
+ if (id == IDialogConstants.OK_ID)
button.setEnabled(false);
- }
return button;
}
private void validateDialog() {
String fileName = wsFilenameText.getText();
- if (fileName.equals("")) { //$NON-NLS-1$
+ if (fileName.equals("")) //$NON-NLS-1$
if (modified) {
setErrorMessage(UIText.GitCreatePatchWizard_WorkspacePatchDialogEnterFileName);
getButton(IDialogConstants.OK_ID).setEnabled(false);
@@ -213,7 +217,6 @@ public class LocationPage extends WizardPage {
getButton(IDialogConstants.OK_ID).setEnabled(false);
return;
}
- }
// make sure that the filename is valid
if (!(ResourcesPlugin.getWorkspace().validateName(fileName,
@@ -332,24 +335,29 @@ public class LocationPage extends WizardPage {
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
initializeDialogUnits(composite);
+ String selectedOption= getDialogSettings().get(LOCATION_KEY);
+ if (selectedOption == null)
+ selectedOption = LOCATION_VALUE_CLIPBOARD;
+
// clipboard
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 3;
cpRadio = new Button(composite, SWT.RADIO);
cpRadio.setText(UIText.GitCreatePatchWizard_Clipboard);
cpRadio.setLayoutData(gd);
- cpRadio.setSelection(true);
+ cpRadio.setSelection(LOCATION_VALUE_CLIPBOARD.equals(selectedOption));
// filesystem
+ boolean isFileSystemSelected = LOCATION_VALUE_FILE_SYSTEM.equals(selectedOption);
fsRadio = new Button(composite, SWT.RADIO);
fsRadio.setText(UIText.GitCreatePatchWizard_File);
- fsRadio.setSelection(false);
+ fsRadio.setSelection(isFileSystemSelected);
fsPathText = new Text(composite, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
fsPathText.setLayoutData(gd);
fsPathText.setText(createFileName());
- fsPathText.setEnabled(false);
+ fsPathText.setEnabled(isFileSystemSelected);
fsBrowseButton = new Button(composite, SWT.PUSH);
fsBrowseButton.setText(UIText.GitCreatePatchWizard_Browse);
@@ -359,21 +367,22 @@ public class LocationPage extends WizardPage {
SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
fsBrowseButton.setLayoutData(data);
- fsBrowseButton.setEnabled(false);
+ fsBrowseButton.setEnabled(isFileSystemSelected);
// workspace
+ boolean isWorkspaceSelected = LOCATION_VALUE_WORKSPACE.equals(selectedOption);
wsRadio = new Button(composite, SWT.RADIO);
wsRadio.setText(UIText.GitCreatePatchWizard_Workspace);
- wsRadio.setSelection(false);
+ wsRadio.setSelection(isWorkspaceSelected);
wsPathText = new Text(composite, SWT.BORDER);
wsPathText.setLayoutData(gd);
- wsPathText.setEnabled(false);
+ wsPathText.setEnabled(isWorkspaceSelected);
wsBrowseButton = new Button(composite, SWT.PUSH);
wsBrowseButton.setText(UIText.GitCreatePatchWizard_Browse);
wsBrowseButton.setLayoutData(data);
- wsBrowseButton.setEnabled(false);
+ wsBrowseButton.setEnabled(isWorkspaceSelected);
cpRadio.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
@@ -383,6 +392,7 @@ public class LocationPage extends WizardPage {
fsBrowseButton.setEnabled(false);
wsPathText.setEnabled(false);
wsBrowseButton.setEnabled(false);
+ getDialogSettings().put(LOCATION_KEY, LOCATION_VALUE_CLIPBOARD);
validatePage();
}
}
@@ -399,6 +409,7 @@ public class LocationPage extends WizardPage {
wsBrowseButton.setEnabled(false);
// set focus to filesystem input text control
fsPathText.setFocus();
+ getDialogSettings().put(LOCATION_KEY, LOCATION_VALUE_FILE_SYSTEM);
validatePage();
}
}
@@ -422,9 +433,8 @@ public class LocationPage extends WizardPage {
final File file = new File(fsPathText.getText());
dialog.setFilterPath(file.getParent());
dialog.setFileName(file.getName());
- } else {
+ } else
dialog.setFileName(""); //$NON-NLS-1$
- }
dialog.setText(""); //$NON-NLS-1$
final String path = dialog.open();
if (path != null)
@@ -444,6 +454,7 @@ public class LocationPage extends WizardPage {
wsBrowseButton.setEnabled(true);
// set focus to workspace input text control
wsPathText.setFocus();
+ getDialogSettings().put(LOCATION_KEY, LOCATION_VALUE_WORKSPACE);
validatePage();
}
}
@@ -498,13 +509,12 @@ public class LocationPage extends WizardPage {
* @return page is valid
*/
protected boolean validatePage() {
- if (wsRadio.getSelection()) {
+ if (wsRadio.getSelection())
pageValid = validateWorkspaceLocation();
- }else if (fsRadio.getSelection()) {
+ else if (fsRadio.getSelection())
pageValid = validateFilesystemLocation();
- } else if (cpRadio.getSelection()) {
+ else if (cpRadio.getSelection())
pageValid = true;
- }
/**
* Avoid draw flicker by clearing error message if all is valid.
@@ -599,12 +609,10 @@ public class LocationPage extends WizardPage {
if (wsRadio.getSelection())
setErrorMessage(UIText.GitCreatePatchWizard_WorkspacePatchProjectClosed);
return false;
- } else {
- if (ResourcesPlugin.getWorkspace().getRoot().getFolder(
- pathToWorkspaceFile).exists()) {
- setErrorMessage(UIText.GitCreatePatchWizard_WorkspacePatchFolderExists);
- return false;
- }
+ } else if (ResourcesPlugin.getWorkspace().getRoot().getFolder(
+ pathToWorkspaceFile).exists()) {
+ setErrorMessage(UIText.GitCreatePatchWizard_WorkspacePatchFolderExists);
+ return false;
}
} else {
setErrorMessage(status.getMessage());