[jbosstools-commits] JBoss Tools SVN: r35618 - in trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: wizard and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Oct 13 09:28:01 EDT 2011
Author: adietish
Date: 2011-10-13 09:28:00 -0400 (Thu, 13 Oct 2011)
New Revision: 35618
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/StringUtils.java
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] implementing default clone destination, default remote name
Added: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/StringUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/StringUtils.java (rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/StringUtils.java 2011-10-13 13:28:00 UTC (rev 35618)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.common;
+
+/**
+ * @author André Dietisheim
+ */
+public class StringUtils {
+
+ public static String null2emptyString(String value) {
+ if (value != null) {
+ return value;
+ }
+ return "";
+ }
+
+}
Property changes on: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/StringUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 12:01:07 UTC (rev 35617)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-13 13:28:00 UTC (rev 35618)
@@ -14,21 +14,12 @@
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
-import java.util.regex.Pattern;
-import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
-import org.eclipse.core.databinding.beans.BeanProperties;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
-import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
-import org.eclipse.core.databinding.validation.IValidator;
-import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
@@ -63,6 +54,7 @@
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.ui.UIUtil;
import org.jboss.tools.common.ui.databinding.DataBindingUtils;
+import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.OpenshiftException;
import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
@@ -105,64 +97,64 @@
private Group createProjectGroup(Composite parent, DataBindingContext dbc) {
Group projectGroup = new Group(parent, SWT.BORDER);
- projectGroup.setText("Project setup");
+ projectGroup.setText("Git clone");
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(projectGroup);
- GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(3).applyTo(projectGroup);
-
+ GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(4).applyTo(projectGroup);
+
+ Label repoPathLabel = new Label(projectGroup, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(repoPathLabel);
+ repoPathLabel.setText("Location");
+
Button defaultRepoPathButton = new Button(projectGroup, SWT.CHECK);
- defaultRepoPathButton.setText("Use default destination");
+ defaultRepoPathButton.setText("default");
GridDataFactory.fillDefaults()
- .span(3, 1).align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(defaultRepoPathButton);
+ .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(
- repoPathText, "Repository path", AdapterWizardPageModel.PROPERTY_REPO_PATH, model, dbc);
- IObservableValue selectionObservable = WidgetProperties.selection().observe(defaultRepoPathButton);
- selectionObservable.addValueChangeListener(new IValueChangeListener() {
-
- @Override
- public void handleValueChange(ValueChangeEvent event) {
- System.err.println("selected!! = " + event.diff.getNewValue());
- }
- });
- dbc.bindValue(
- selectionObservable
- , WidgetProperties.enabled().observe(repoPathText)
- , null
- , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
+ repoPathText, "Location", 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(browseRepoPathButton);
browseRepoPathButton.addSelectionListener(onRepoPath());
-
- Label branchLabel = new Label(projectGroup, SWT.NONE);
- branchLabel.setText("Branch to clone");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(branchLabel);
- Text branchText = new Text(projectGroup, SWT.BORDER);
+
+ dbc.bindValue(
+ WidgetProperties.selection().observe(defaultRepoPathButton)
+ , WidgetProperties.enabled().observe(repoPathText)
+ , new UpdateValueStrategy().setConverter(new InvertingBooleanConverter())
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
+ defaultRepoPathButton.setSelection(true);
+
+ Label remoteNameLabel = new Label(projectGroup, SWT.NONE);
+ remoteNameLabel.setText("Remote name");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(remoteNameLabel);
+
+ Button defaultRemoteNameButton = new Button(projectGroup, SWT.CHECK);
+ defaultRemoteNameButton.setText("default");
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false)
- .applyTo(branchText);
- Binding branchNameBinding = dbc.bindValue(
- WidgetProperties.text(SWT.Modify).observe(branchText)
- , BeanProperties.value(AdapterWizardPageModel.PROPERTY_REMOTE_NAME).observe(model)
- , new UpdateValueStrategy().setAfterGetValidator(new BranchNameValidator())
- , null);
- ControlDecorationSupport.create(branchNameBinding, SWT.TOP | SWT.LEFT);
+ .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(defaultRemoteNameButton);
+ defaultRemoteNameButton.addSelectionListener(onDefaultRemoteName());
- Button defaultBranchnameButton = new Button(projectGroup, SWT.PUSH);
- defaultBranchnameButton.setText("Default");
+ Text remoteNameText = new Text(projectGroup, SWT.BORDER);
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(defaultBranchnameButton);
- defaultBranchnameButton.addSelectionListener(onBranchnameDefault());
+ .span(2, 1).align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false)
+ .applyTo(remoteNameText);
+ DataBindingUtils.bindMandatoryTextField(
+ remoteNameText, "Remote name", AdapterWizardPageModel.PROPERTY_REMOTE_NAME, model, dbc);
+ dbc.bindValue(
+ WidgetProperties.selection().observe(defaultRemoteNameButton)
+ , WidgetProperties.enabled().observe(remoteNameText)
+ , new UpdateValueStrategy().setConverter(new InvertingBooleanConverter())
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
+ defaultRemoteNameButton.setSelection(true);
+
return projectGroup;
}
@@ -182,6 +174,7 @@
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
+ dialog.setMessage("Choose the location to store your repository clone to...");
String repositoryPath = dialog.open();
if (repositoryPath != null) {
model.setRepositoryPath(repositoryPath);
@@ -190,7 +183,7 @@
};
}
- private SelectionListener onBranchnameDefault() {
+ private SelectionListener onDefaultRemoteName() {
return new SelectionAdapter() {
@Override
@@ -259,15 +252,16 @@
addRuntimeLink.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IRuntimeType type = getValidRuntimeType();
- if( type != null )
+ if (type != null)
showRuntimeWizard(type);
}
});
-
+
serverAdapterCheckbox.setLayoutData(UIUtil.createFormData2(0, 5, null, 0, 0, 5, null, 0));
runtimeLabel.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0, 0, 5, null, 0));
addRuntimeLink.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0, null, 0, 100, -5));
- suitableRuntimes.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0, runtimeLabel, 5, addRuntimeLink, -5));
+ suitableRuntimes.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0, runtimeLabel, 5,
+ addRuntimeLink, -5));
domainLabel.setLayoutData(UIUtil.createFormData2(suitableRuntimes, 5, null, 0, 0, 5, 100, 0));
// appLabel.setLayoutData(UIUtil.createFormData2(domainLabel, 5, null,
// 0, 0, 5, 100, 0));
@@ -287,7 +281,7 @@
}
private IRuntimeType getValidRuntimeType() {
- String cartridgeName = model.getParentModel().getApplication().getCartridge().getName();
+ String cartridgeName = model.getParentModel().getApplicationCartridgeName();
if (ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
return ServerCore.findRuntimeType(IJBossToolingConstants.AS_70);
}
@@ -295,7 +289,7 @@
}
private IServerType getServerTypeToCreate() {
- String cartridgeName = model.getParentModel().getApplication().getCartridge().getName();
+ String cartridgeName = model.getParentModel().getApplicationCartridgeName();
if (ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
return ServerCore.findServerType(IJBossToolingConstants.SERVER_AS_70);
}
@@ -321,6 +315,12 @@
}
protected void onPageActivated(DataBindingContext dbc) {
+ /*
+ * this needs to be initialized at page visibility since the default
+ * repository path default
+ */
+ model.resetRepositoryPath();
+
serverTypeToCreate = getServerTypeToCreate();
model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
refreshValidRuntimes();
@@ -343,7 +343,7 @@
protected void refreshValidRuntimes() {
IRuntimeType type = getValidRuntimeType();
- if( type != null ) {
+ if (type != null) {
IRuntime[] runtimes = getRuntimesOfType(type.getId());
fillRuntimeCombo(suitableRuntimes, runtimes);
} else {
@@ -386,35 +386,13 @@
return returnValue;
}
- private static class BranchNameValidator implements IValidator {
-
- private static final Pattern BRANCH_PATTERN = Pattern.compile(".+\\/.+");
-
- @Override
- public IStatus validate(Object value) {
- if (value == null
- || ((String) value).length() == 0) {
- return ValidationStatus.error("you have to provide a branch to clone");
- }
-
- if (!isValidBranch((String) value)) {
- return ValidationStatus.error("you have to provide a valid branch name (ex. origin/master)");
- }
- return ValidationStatus.ok();
- }
-
- private boolean isValidBranch(String branchname) {
- return BRANCH_PATTERN.matcher(branchname).matches();
- }
- }
-
@Override
public void propertyChange(PropertyChangeEvent evt) {
- if( ImportProjectWizardModel.APPLICATION.equals(evt.getPropertyName())) {
+ if (ImportProjectWizardModel.APPLICATION.equals(evt.getPropertyName())) {
handleApplicationChanged();
}
}
-
+
private void handleApplicationChanged() {
// we need to enable or disable all the server widgets depending on
// if we can make a server out of this
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 12:01:07 UTC (rev 35617)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-10-13 13:28:00 UTC (rev 35618)
@@ -15,6 +15,7 @@
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.internal.ui.common.StringUtils;
/**
* @author André Dietisheim
@@ -52,9 +53,13 @@
}
public void resetRepositoryPath() {
- setRepositoryPath(getEGitDefaultRepositoryPath()
+ setRepositoryPath(getDefaultRepositoryPath());
+ }
+
+ private String getDefaultRepositoryPath() {
+ return getEGitDefaultRepositoryPath()
+ File.separatorChar
- + wizardModel.getApplication().getName());
+ + StringUtils.null2emptyString(wizardModel.getApplicationName());
}
public String getEGitDefaultRepositoryPath() {
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 12:01:07 UTC (rev 35617)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-10-13 13:28:00 UTC (rev 35618)
@@ -37,6 +37,7 @@
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.client.IApplication;
+import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.IUser;
import org.jboss.tools.openshift.express.client.OpenshiftException;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
@@ -80,6 +81,33 @@
return (IApplication) getProperty(APPLICATION);
}
+ public String getApplicationName() {
+ String applicationName = null;
+ IApplication application = getApplication();
+ if (application != null) {
+ applicationName = application.getName();
+ }
+ return applicationName;
+ }
+
+ public ICartridge getApplicationCartridge() {
+ ICartridge cartridge = null;
+ IApplication application = getApplication();
+ if (application != null) {
+ cartridge = application.getCartridge();
+ }
+ return cartridge;
+ }
+
+ public String getApplicationCartridgeName() {
+ String cartridgeName = null;
+ ICartridge cartridge = getApplicationCartridge();
+ if (cartridge != null) {
+ cartridgeName = cartridge.getName();
+ }
+ return cartridgeName;
+ }
+
public void setApplication(IApplication application) {
setProperty(APPLICATION, application);
}
More information about the jbosstools-commits
mailing list