Author: adietish
Date: 2011-10-13 07:12:52 -0400 (Thu, 13 Oct 2011)
New Revision: 35613
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
Log:
[JBIDE-9793] added default repo destination (checkbox and model code)
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-13
11:05:30 UTC (rev 35612)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-13
11:12:52 UTC (rev 35613)
@@ -95,7 +95,6 @@
Group serverAdapterGroup = createAdapterGroup(parent);
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(serverAdapterGroup);
-
}
private Group createProjectGroup(Composite parent, DataBindingContext dbc) {
@@ -105,19 +104,25 @@
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(projectGroup);
GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(3).applyTo(projectGroup);
- Label cloneDirLabel = new Label(projectGroup, SWT.NONE);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(cloneDirLabel);
- cloneDirLabel.setText("Repository Destination");
- Text cloneDirText = new Text(projectGroup, SWT.BORDER);
+ Button defaultRepoPathButton = new Button(projectGroup, SWT.CHECK);
+ defaultRepoPathButton.setText("Use default destination");
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(cloneDirText);
+ .span(3, 1).align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).applyTo(defaultRepoPathButton);
+ defaultRepoPathButton.addSelectionListener(onDefaultRepoPath());
+
+ Label repoPathLabel = new Label(projectGroup, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(repoPathLabel);
+ repoPathLabel.setText("Repository Destination");
+ Text repoPathText = new Text(projectGroup, SWT.BORDER);
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(repoPathText);
DataBindingUtils.bindMandatoryTextField(
- cloneDirText, "Repository Destination",
AdapterWizardPageModel.PROPERTY_CLONEDIR, model, dbc);
- Button browseDestinationButton = new Button(projectGroup, SWT.PUSH);
- browseDestinationButton.setText("Browse");
+ repoPathText, "Repository path", AdapterWizardPageModel.PROPERTY_REPO_PATH,
model, dbc);
+ Button browseRepoPathButton = new Button(projectGroup, SWT.PUSH);
+ browseRepoPathButton.setText("Browse");
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).applyTo(browseDestinationButton);
- browseDestinationButton.addSelectionListener(onBrowseDestination());
+ .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseRepoPathButton);
+ browseRepoPathButton.addSelectionListener(onRepoPath());
Label branchLabel = new Label(projectGroup, SWT.NONE);
branchLabel.setText("Branch to clone");
@@ -128,11 +133,11 @@
.applyTo(branchText);
Binding branchNameBinding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(branchText)
- , BeanProperties.value(AdapterWizardPageModel.PROPERTY_BRANCHNAME).observe(model)
+ , BeanProperties.value(AdapterWizardPageModel.PROPERTY_REMOTE_NAME).observe(model)
, new UpdateValueStrategy().setAfterGetValidator(new BranchNameValidator())
, null);
ControlDecorationSupport.create(branchNameBinding, SWT.TOP | SWT.LEFT);
-
+
Button defaultBranchnameButton = new Button(projectGroup, SWT.PUSH);
defaultBranchnameButton.setText("Default");
GridDataFactory.fillDefaults()
@@ -142,15 +147,25 @@
return projectGroup;
}
- private SelectionListener onBrowseDestination() {
+ private SelectionListener onDefaultRepoPath() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
+ model.resetRepositoryPath();
+ }
+ };
+ }
+
+ private SelectionListener onRepoPath() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
- String cloneDir = dialog.open();
- if (cloneDir != null) {
- model.setCloneDirectory(cloneDir);
+ String repositoryPath = dialog.open();
+ if (repositoryPath != null) {
+ model.setRepositoryPath(repositoryPath);
}
}
};
@@ -161,7 +176,7 @@
@Override
public void widgetSelected(SelectionEvent e) {
- model.resetBranchname();
+ model.resetRemoteName();
}
};
}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-10-13
11:05:30 UTC (rev 35612)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-10-13
11:12:52 UTC (rev 35613)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
/**
@@ -18,11 +20,11 @@
*/
public class AdapterWizardPageModel extends ObservableUIPojo {
- private static final String BRANCHNAME_DEFAULT = "origin/master";
+ private static final String REMOTE_NAME_DEFAULT = "origin";
- public static final String PROPERTY_CLONEDIR = "cloneDirectory";
- public static final String PROPERTY_BRANCHNAME = "branchname";
-
+ public static final String PROPERTY_REPO_PATH = "repositoryPath";
+ public static final String PROPERTY_REMOTE_NAME = "remoteName";
+
public static final String CREATE_SERVER = "createServer";
public static final String MODE = "serverMode";
public static final String MODE_SOURCE = "serverModeSource";
@@ -30,39 +32,50 @@
public static final String RUNTIME_DELEGATE = "runtimeDelegate";
public static final String SERVER_TYPE = "serverType";
- private String cloneDir;
- private String branchname;
-
+ private String repositoryPath;
+ private String remoteName;
+
private ImportProjectWizardModel wizardModel;
public AdapterWizardPageModel(ImportProjectWizardModel wizardModel) {
this.wizardModel = wizardModel;
- this.branchname = BRANCHNAME_DEFAULT;
+ this.remoteName = REMOTE_NAME_DEFAULT;
}
-
- public String getCloneDirectory() {
- return cloneDir;
+
+ public String getRepositoryPath() {
+ return repositoryPath;
}
- public void setCloneDirectory(String cloneDir) {
- firePropertyChange(PROPERTY_CLONEDIR, this.cloneDir, this.cloneDir = cloneDir);
- wizardModel.setCloneDirectory(cloneDir);
+ public void setRepositoryPath(String repositoryPath) {
+ firePropertyChange(PROPERTY_REPO_PATH, this.repositoryPath, this.repositoryPath =
repositoryPath);
+ wizardModel.setCloneDirectory(repositoryPath);
}
- public String getBranchname() {
- return branchname;
+ public void resetRepositoryPath() {
+ setRepositoryPath(getEGitDefaultRepositoryPath() +
wizardModel.getApplication().getName());
}
- public void setBranchname(String branchname) {
- firePropertyChange(PROPERTY_BRANCHNAME, this.branchname, this.branchname =
branchname);
- wizardModel.setBranchname(branchname);
+ public String getEGitDefaultRepositoryPath() {
+ String destinationDir =
+ Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
+ return destinationDir;
}
- public void resetBranchname() {
- setBranchname(BRANCHNAME_DEFAULT);
+ public String getRemoteName() {
+ return remoteName;
}
- // TODO is this the best way? Or should we expose ONLY getters to the parent model?
+ public void setRemoteName(String remoteName) {
+ firePropertyChange(PROPERTY_REMOTE_NAME, this.remoteName, this.remoteName =
remoteName);
+ wizardModel.setRemoteName(remoteName);
+ }
+
+ public void resetRemoteName() {
+ setRemoteName(REMOTE_NAME_DEFAULT);
+ }
+
+ // TODO is this the best way? Or should we expose ONLY getters to the parent
+ // model?
public ImportProjectWizardModel getParentModel() {
return wizardModel;
}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-10-13
11:05:30 UTC (rev 35612)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-10-13
11:12:52 UTC (rev 35613)
@@ -55,7 +55,7 @@
private static final String USER = "user";
private static final String APPLICATION = "application";
- private static final String BRANCHNAME = "branchname";
+ private static final String REMOTE_NAME = "remoteName";
private static final String CLONE_DIR = "cloneDir";
public void setProperty(String key, Object value) {
@@ -78,12 +78,12 @@
return (IApplication) dataModel.get(APPLICATION);
}
- public void setBranchname(String branchname) {
- dataModel.put(BRANCHNAME, branchname);
+ public void setRemoteName(String remoteName) {
+ dataModel.put(REMOTE_NAME, remoteName);
}
- public String getBranchname() {
- return (String) dataModel.get(BRANCHNAME);
+ public String getRemoteName() {
+ return (String) dataModel.get(REMOTE_NAME);
}
public void setCloneDirectory(String cloneDir) {
@@ -158,11 +158,10 @@
}
ensureEgitUIIsStarted();
URIish gitUri = new URIish(uri);
- RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil();
-
CloneOperation cloneOperation =
- new CloneOperation(gitUri, true, null, destination, Constants.HEAD,
"origin", CLONE_TIMEOUT);
+ new CloneOperation(gitUri, true, null, destination, Constants.HEAD, getRemoteName(),
CLONE_TIMEOUT);
cloneOperation.run(monitor);
+ RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil();
repositoryUtil.addConfiguredRepository(new File(destination, Constants.DOT_GIT));
}