Author: adietish
Date: 2011-10-12 16:41:33 -0400 (Wed, 12 Oct 2011)
New Revision: 35583
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
Removed:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftDeployUI.java
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/ApplicationWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java
Log:
[JBIDE-9793] renamed ApplicationWizard to ImportProjectWizard, implementing
AdapterWizardPage
Modified: trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2011-10-12 20:24:56
UTC (rev 35582)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2011-10-12 20:41:33
UTC (rev 35583)
@@ -9,7 +9,7 @@
</category>
<wizard
category="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.category"
-
class="org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationWizard"
+
class="org.jboss.tools.openshift.express.internal.ui.wizard.ImportProjectWizard"
icon="icons/openshift-logo-white-icon.png"
id="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.NewServerAdapter"
name="OpenShift Express Application">
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftDeployUI.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftDeployUI.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenshiftDeployUI.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -9,7 +9,6 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.ide.eclipse.as.ui.UIUtil;
import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI;
-import org.jboss.ide.eclipse.as.ui.editor.ServerModeSection;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
public class OpenshiftDeployUI implements IDeploymentTypeUI {
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-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -17,6 +17,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.window.Window;
@@ -31,10 +32,12 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ListDialog;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
@@ -54,7 +57,7 @@
import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
public class AdapterWizardPage extends AbstractOpenshiftWizardPage implements IWizardPage
{
-
+
private AdapterWizardPageModel model;
private Combo suitableRuntimes;
private IServerType serverTypeToCreate;
@@ -62,8 +65,13 @@
private Label domainLabel;
private Label modeLabel;
- public AdapterWizardPage(ApplicationWizard wizard, ApplicationWizardModel model) {
- super("Server Adapter", "...", "Server Adapter",
wizard);
+ public AdapterWizardPage(ImportProjectWizard wizard, ImportProjectWizardModel model) {
+ super(
+ "Import Project",
+ "Please select the destination for your local copy of the OpenShift Express
repository, "
+ + "what branch to clone and setup your server adapter, ",
+ "Server Adapter",
+ wizard);
this.model = new AdapterWizardPageModel(model);
}
@@ -71,41 +79,107 @@
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().applyTo(parent);
+ Group projectGroup = createProjectGroup(parent, dbc);
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(projectGroup);
+
+ 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) {
Group projectGroup = new Group(parent, SWT.BORDER);
projectGroup.setText("Project setup");
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(projectGroup);
- GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(projectGroup);
+ GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(3).applyTo(projectGroup);
- Label projectNameLabel = new Label(projectGroup, SWT.NONE);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(projectNameLabel);
- projectNameLabel.setText("Project name");
- Text projectNameText = new Text(projectGroup, SWT.BORDER);
+ 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);
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(projectNameText);
+ .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(cloneDirText);
+ // DataBindingUtils.bindMandatoryTextField(
+ // cloneDirText, "Repository Destination",
+ // AdapterWizardPageModel.PROPERTY_CLONEDIR, model, dbc);
+ Button browseDestinationButton = new Button(projectGroup, SWT.PUSH);
+ browseDestinationButton.setText("Browse");
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).applyTo(browseDestinationButton);
+ browseDestinationButton.addSelectionListener(onBrowseDestination());
- Label branchNameLabel = new Label(projectGroup, SWT.NONE);
- branchNameLabel.setText("Name of remote branch");
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(branchNameLabel);
- Text branchNameText = new Text(projectGroup, SWT.BORDER);
+ 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.NONE);
+ branchText.setEditable(false);
+ branchText.setBackground(projectGroup.getBackground());
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(branchNameText);
+ .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false)
+ .applyTo(branchText);
+ Button selectBranchButton = new Button(projectGroup, SWT.PUSH);
+ selectBranchButton.setText("Select Branch");
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(selectBranchButton);
+ selectBranchButton.addSelectionListener(onSelectBranch());
+
+ return projectGroup;
+ }
+
+ private SelectionListener onBrowseDestination() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ String cloneDir = dialog.open();
+ if (cloneDir != null) {
+ model.setCloneDir(cloneDir);
+ }
+ }
+ };
+ }
+
+ private SelectionListener onSelectBranch() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ListDialog branchesDialog = new ListDialog(getShell());
+ branchesDialog.setContentProvider(new BranchNameContentProvider());
+ branchesDialog.setTitle("Branches");
+ if (Dialog.OK == branchesDialog.open()) {
+ Object[] selectedBranches = branchesDialog.getResult();
+ if (selectedBranches != null
+ && selectedBranches.length >= 1
+ && selectedBranches[1] instanceof String) {
+ model.setBranch((String) selectedBranches[1]);
+ }
+ }
+ }
+ };
+ }
+
+ private Group createAdapterGroup(Composite parent) {
Group serverAdapterGroup = new Group(parent, SWT.BORDER);
serverAdapterGroup.setText("JBoss Server adapter");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(serverAdapterGroup);
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = 6;
fillLayout.marginWidth = 6;
serverAdapterGroup.setLayout(fillLayout);
fillServerAdapterGroup(serverAdapterGroup);
+
+ return serverAdapterGroup;
}
-
+
protected void enableServerWidgets(boolean enabled) {
suitableRuntimes.setEnabled(enabled);
}
-
+
private void fillServerAdapterGroup(Group serverAdapterGroup) {
Composite c = new Composite(serverAdapterGroup, SWT.BORDER);
c.setLayout(new FormLayout());
@@ -114,31 +188,34 @@
final Button serverAdapterCheckbox2 = serverAdapterCheckbox;
serverAdapterCheckbox.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
serverAdapterCheckbox2.getSelection());
+ model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
+ serverAdapterCheckbox2.getSelection());
enableServerWidgets(serverAdapterCheckbox2.getSelection());
}
+
public void widgetDefaultSelected(SelectionEvent e) {
}
});
-
-
+
Label l = new Label(c, SWT.BORDER);
l.setText("Local Runtime: ");
-
+
suitableRuntimes = new Combo(c, SWT.READ_ONLY);
Link addRuntime = new Link(c, SWT.NONE);
addRuntime.setText("<a>" + Messages.addRuntime +
"</a>");
-
+
domainLabel = new Label(c, SWT.NONE);
- //appLabel = new Label(c, SWT.NONE);
+ // appLabel = new Label(c, SWT.NONE);
modeLabel = new Label(c, SWT.NONE);
-
- suitableRuntimes.addSelectionListener(new SelectionListener(){
+
+ suitableRuntimes.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
updateSelectedRuntimeDelegate();
}
+
public void widgetDefaultSelected(SelectionEvent e) {
- }});
+ }
+ });
addRuntime.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IRuntimeType type = getValidRuntimeType();
@@ -146,63 +223,65 @@
}
});
- serverAdapterCheckbox.setLayoutData(UIUtil.createFormData2(0,5,null,0,0,5,null,0));
- l.setLayoutData(
UIUtil.createFormData2(serverAdapterCheckbox,5,null,0,0,5,null,0));
+ serverAdapterCheckbox.setLayoutData(UIUtil.createFormData2(0, 5, null, 0, 0, 5, null,
0));
+ l.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0, 0, 5, null,
0));
addRuntime.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null, 0,
null, 0, 100, -5));
- suitableRuntimes.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox,5,null,0,l,5,addRuntime,-5));
+ suitableRuntimes.setLayoutData(UIUtil.createFormData2(serverAdapterCheckbox, 5, null,
0, l, 5, addRuntime, -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));
+ // appLabel.setLayoutData(UIUtil.createFormData2(domainLabel, 5, null,
+ // 0, 0, 5, 100, 0));
modeLabel.setLayoutData(UIUtil.createFormData2(domainLabel, 5, null, 0, 0, 5, 100,
0));
-
+
}
-
+
private void updateSelectedRuntimeDelegate() {
- if( suitableRuntimes.getSelectionIndex() != -1) {
+ if (suitableRuntimes.getSelectionIndex() != -1) {
runtimeDelegate =
ServerCore.findRuntime(suitableRuntimes.getItem(suitableRuntimes.getSelectionIndex()));
} else {
runtimeDelegate = null;
}
model.getParentModel().setProperty(AdapterWizardPageModel.RUNTIME_DELEGATE,
runtimeDelegate);
}
+
private IRuntimeType getValidRuntimeType() {
String cartridgeName =
model.getParentModel().getApplication().getCartridge().getName();
- if( ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
+ if (ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
return ServerCore.findRuntimeType(IJBossToolingConstants.AS_70);
}
return null;
}
+
private IServerType getServerTypeToCreate() {
String cartridgeName =
model.getParentModel().getApplication().getCartridge().getName();
- if( ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
+ if (ICartridge.JBOSSAS_7.getName().equals(cartridgeName)) {
return ServerCore.findServerType(IJBossToolingConstants.SERVER_AS_70);
}
return null;
}
-
private IRuntime[] getRuntimesOfType(String type) {
ArrayList<IRuntime> validRuntimes = new ArrayList<IRuntime>();
IRuntime[] allRuntimes = ServerCore.getRuntimes();
- for( int i = 0; i < allRuntimes.length; i++ ) {
- if( allRuntimes[i].getRuntimeType().getId().equals(type))
+ for (int i = 0; i < allRuntimes.length; i++) {
+ if (allRuntimes[i].getRuntimeType().getId().equals(type))
validRuntimes.add(allRuntimes[i]);
}
return validRuntimes.toArray(new IRuntime[validRuntimes.size()]);
}
-
+
private void fillRuntimeCombo(Combo combo, IRuntime[] runtimes) {
String[] names = new String[runtimes.length];
- for( int i = 0; i < runtimes.length; i++ ) {
+ for (int i = 0; i < runtimes.length; i++) {
names[i] = runtimes[i].getName();
}
combo.setItems(names);
}
-
+
protected void onPageActivated(DataBindingContext dbc) {
serverTypeToCreate = getServerTypeToCreate();
model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE,
serverTypeToCreate);
refreshValidRuntimes();
- if( suitableRuntimes.getItemCount() > 0 ) {
+ if (suitableRuntimes.getItemCount() > 0) {
suitableRuntimes.select(0);
updateSelectedRuntimeDelegate();
}
@@ -210,16 +289,17 @@
domainLabel.setText("Host: " +
model.getParentModel().getApplication().getApplicationUrl());
modeLabel.setText("Mode: Source");
model.getParentModel().setProperty(AdapterWizardPageModel.MODE,
AdapterWizardPageModel.MODE_SOURCE);
- } catch(OpenshiftException ose ) {
- OpenshiftUIActivator.getDefault().getLog().log(new Status(IStatus.ERROR,
OpenshiftUIActivator.PLUGIN_ID, ose.getMessage(), ose));
+ } catch (OpenshiftException ose) {
+ OpenshiftUIActivator.getDefault().getLog()
+ .log(new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID, ose.getMessage(),
ose));
}
}
-
+
protected void refreshValidRuntimes() {
IRuntime[] runtimes = getRuntimesOfType(getValidRuntimeType().getId());
fillRuntimeCombo(suitableRuntimes, runtimes);
}
-
+
/* Stolen from NewManualServerComposite */
protected int showRuntimeWizard(IRuntimeType runtimeType) {
WizardFragment fragment = null;
@@ -227,7 +307,7 @@
final WizardFragment fragment2 =
ServerUIPlugin.getWizardFragment(runtimeType.getId());
if (fragment2 == null)
return Window.CANCEL;
-
+
try {
IRuntimeWorkingCopy runtimeWorkingCopy = runtimeType.createRuntime(null, null);
taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy);
@@ -249,11 +329,11 @@
int returnValue = dialog.open();
refreshValidRuntimes();
if (returnValue != Window.CANCEL) {
- IRuntime rt = (IRuntime)taskModel.getObject(TaskModel.TASK_RUNTIME);
+ IRuntime rt = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME);
if (rt != null && rt.getName() != null &&
suitableRuntimes.indexOf(rt.getName()) != -1) {
suitableRuntimes.select(suitableRuntimes.indexOf(rt.getName()));
}
- }
+ }
return returnValue;
}
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-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -13,9 +13,13 @@
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
/**
+ * @author André Dietisheim
* @author Rob Stryker
*/
public class AdapterWizardPageModel extends ObservableUIPojo {
+ public static final String PROPERTY_CLONEDIR = "cloneDir";
+ public static final String PROPERTY_BRANCH = "branch";
+
public static final String CREATE_SERVER = "createServer";
public static final String MODE = "serverMode";
public static final String MODE_SOURCE = "serverModeSource";
@@ -23,15 +27,33 @@
public static final String RUNTIME_DELEGATE = "runtimeDelegate";
public static final String SERVER_TYPE = "serverType";
+ private String cloneDir;
+ private String branch;
+
+ private ImportProjectWizardModel wizardModel;
- private ApplicationWizardModel wizardModel;
-
- public AdapterWizardPageModel(ApplicationWizardModel wizardModel) {
+ public AdapterWizardPageModel(ImportProjectWizardModel wizardModel) {
this.wizardModel = wizardModel;
}
+ public String getCloneDir() {
+ return cloneDir;
+ }
+
+ public void setCloneDir(String cloneDir) {
+ firePropertyChange(PROPERTY_CLONEDIR, cloneDir, this.cloneDir = cloneDir);
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ public void setBranch(String branch) {
+ firePropertyChange(PROPERTY_BRANCH, branch, this.branch = branch);
+ }
+
// TODO is this the best way? Or should we expose ONLY getters to the parent model?
- public ApplicationWizardModel getParentModel() {
+ public ImportProjectWizardModel getParentModel() {
return wizardModel;
}
Deleted:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * 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.wizard;
-
-import java.io.File;
-import java.net.URISyntaxException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.openshift.express.client.OpenshiftException;
-import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
-
-/**
- * @author André Dietisheim
- */
-public class ApplicationWizard extends Wizard implements INewWizard {
-
- private ApplicationWizardModel model;
-
- public ApplicationWizard() {
- }
-
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- setWindowTitle("OpenShift application wizard");
- setNeedsProgressMonitor(true);
- }
-
- @Override
- public boolean performFinish() {
- try {
- WizardUtils.runInWizard(
- new Job("Creating local git repo...") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- File repositoryFile = model.cloneRepository(monitor);
- model.importProject(repositoryFile, monitor);
- return Status.OK_STATUS;
- } catch (OpenshiftException e) {
- return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- "An exception occurred while creating local git repository.", e);
- } catch (URISyntaxException e) {
- return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- "The url of the remote git repository is not valid", e);
- } catch (Exception e) {
- return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- "An exception occurred while creating local git repository.", e);
- }
- }
- }, getContainer());
- return true;
- } catch (Exception e) {
- ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.",
- new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- "An exception occurred while creating local git repository.", e));
- return false;
- }
- }
-
- @Override
- public void addPages() {
- this.model = new ApplicationWizardModel();
- addPage(new CredentialsWizardPage(this, model));
- addPage(new ApplicationWizardPage(this, model));
- addPage(new AdapterWizardPage(this, model));
- }
-}
Deleted:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * 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.wizard;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.egit.core.RepositoryUtil;
-import org.eclipse.egit.core.op.CloneOperation;
-import org.eclipse.egit.core.op.ConnectProviderOperation;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.transport.JschConfigSessionFactory;
-import org.eclipse.jgit.transport.URIish;
-import org.eclipse.osgi.util.NLS;
-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.IUser;
-import org.jboss.tools.openshift.express.client.OpenshiftException;
-import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.GeneralProjectImportOperation;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.MavenProjectImportOperation;
-
-/**
- * @author André Dietisheim <adietish(a)redhat.com>
- */
-public class ApplicationWizardModel extends ObservableUIPojo {
-
- private HashMap<String, Object> dataModel = new HashMap<String, Object>();
-
- private static final String USER = "user";
- private static final String APPLICATION = "application";
-
- public void setProperty(String key, Object value) {
- dataModel.put(key, value);
- }
-
- public Object getProperty(String key) {
- return dataModel.get(key);
- }
-
- public void setUser(IUser user) {
- dataModel.put(USER, user);
- }
-
- public IUser getUser() {
- return (IUser) dataModel.get(USER);
- }
-
- public IApplication getApplication() {
- return (IApplication) dataModel.get(APPLICATION);
- }
-
- public void setApplication(IApplication application) {
- dataModel.put(APPLICATION, application);
- }
-
- public void importProject(final File projectFolder, IProgressMonitor monitor) throws
OpenshiftException,
- CoreException,
- InterruptedException {
- new WorkspaceJob(NLS.bind("Importing projects from {0}",
projectFolder.getAbsolutePath())) {
-
- @Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- try {
- MavenProjectImportOperation mavenImport = new
MavenProjectImportOperation(projectFolder);
- List<IProject> importedProjects = Collections.emptyList();
- if (mavenImport.isMavenProject()) {
- importedProjects = mavenImport.importToWorkspace(monitor);
- } else {
- importedProjects = new
GeneralProjectImportOperation(projectFolder).importToWorkspace(monitor);
- }
-
- File gitFolder = new File(projectFolder, Constants.DOT_GIT);
- connectToGitRepo(importedProjects, gitFolder, monitor);
-
- createServerAdapterIfRequired();
- return Status.OK_STATUS;
- } catch (Exception e) {
- IStatus status = new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
- NLS.bind("Could not import projects from {0}",
projectFolder.getAbsolutePath()), e);
- OpenshiftUIActivator.log(status);
- return status;
- }
- }
- }.schedule();
- }
-
- private void connectToGitRepo(List<IProject> projects, File gitFolder,
IProgressMonitor monitor)
- throws CoreException {
- for (IProject project : projects) {
- connectToGitRepo(project, gitFolder, monitor);
- }
- }
-
- private void connectToGitRepo(IProject project, File gitFolder, IProgressMonitor
monitor) throws CoreException {
- new ConnectProviderOperation(project).execute(monitor);
- }
-
- public File cloneRepository(IProgressMonitor monitor) throws URISyntaxException,
OpenshiftException,
- InvocationTargetException,
- InterruptedException {
- File destination = getDestinationDirectory(getApplication());
- cloneRepository(getApplication().getGitUri(), destination, monitor);
- return destination;
- }
-
- private void cloneRepository(String uri, File destination, IProgressMonitor monitor)
throws URISyntaxException,
- OpenshiftException,
- InvocationTargetException,
- InterruptedException {
- if (destination.exists()) {
- FileUtil.completeDelete(destination);
- }
- ensureEgitUIIsStarted();
- URIish gitUri = new URIish(uri);
- RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil();
- CloneOperation cloneOperation =
- new CloneOperation(gitUri, true, null, destination, Constants.HEAD,
"origin", 10 * 1024);
- cloneOperation.run(null);
- File gitDirectory = new File(destination, Constants.DOT_GIT);
- repositoryUtil.addConfiguredRepository(gitDirectory);
- }
-
- /**
- * The EGit UI plugin initializes the ssh factory to present the user a
- * passphrase prompt if the ssh key was not read yet. If this initialization
- * is not executed, the ssh connection to the git repo would just fail with
- * an authentication error. We therefore have to make sure that the EGit UI
- * plugin is started and initializes the JSchConfigSessionFactory.
- * <p>
- * EGit initializes the SshSessionFactory with the EclipseSshSessionFactory.
- * The EclipseSshSessionFactory overrides JschConfigSessionFactory#configure
- * to present a UserInfoPrompter if the key passphrase was not entered
- * before.
- *
- * @see Activator#start(org.osgi.framework.BundleContext)
- * @see Activator#setupSSH
- * @see JschConfigSessionFactory#configure
- * @see EclipseSshSessionFactory#configure
- */
- private void ensureEgitUIIsStarted() {
- Activator.getDefault();
- }
-
- private File getDestinationDirectory(IApplication application) {
- String applicationDirectory = application.getName();
- // File workspace =
- // ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
- String userHome = System.getProperty("java.io.tmpdir");
- // File workDir = new File(workspace, applicationWorkingdir);
- return new File(userHome, applicationDirectory);
- }
-
- private void createServerAdapterIfRequired() {
- // TODO
- }
-}
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -68,9 +68,9 @@
private TableViewer viewer;
private ApplicationWizardPageModel model;
- private ApplicationWizardModel wizardModel;
+ private ImportProjectWizardModel wizardModel;
- protected ApplicationWizardPage(IWizard wizard, ApplicationWizardModel wizardModel) {
+ protected ApplicationWizardPage(IWizard wizard, ImportProjectWizardModel wizardModel) {
super("Application selection", "Please select an Openshift Express
application",
"Application selection", wizard);
this.wizardModel = wizardModel;
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -32,9 +32,9 @@
private String namespace;
private IDomain domain;
private IApplication selectedApplication;
- private ApplicationWizardModel wizardModel;
+ private ImportProjectWizardModel wizardModel;
- public ApplicationWizardPageModel(ApplicationWizardModel wizardModel) {
+ public ApplicationWizardPageModel(ImportProjectWizardModel wizardModel) {
this.wizardModel = wizardModel;
}
Added:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.util.Set;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jgit.lib.Repository;
+
+/**
+ * @author André Dietisheim
+ */
+public class BranchNameContentProvider implements IStructuredContentProvider {
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ if (!(inputElement instanceof Repository)) {
+ return new Object[] {};
+ }
+
+ return getBranches((Repository) inputElement);
+ }
+
+ private Object[] getBranches(Repository repository) {
+
+ Set<String> refNames = repository.getAllRefs().keySet();
+ return refNames.toArray(new String[refNames.size()]);
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.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/CredentialsWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -47,7 +47,7 @@
private CredentialsWizardPageModel model;
- public CredentialsWizardPage(IWizard wizard, ApplicationWizardModel wizardModel) {
+ public CredentialsWizardPage(IWizard wizard, ImportProjectWizardModel wizardModel) {
super("Server connetion", "Please provide the credentails of your user
account on Openshift Express",
"Server Connection", wizard);
this.model = new CredentialsWizardPageModel(wizardModel);
@@ -71,8 +71,8 @@
// dbc.bindValue(
// WidgetProperties.text(SWT.Modify).observe(serverUrlText),
// BeanProperties.value(
- // ApplicationWizardModel.class,
- // ApplicationWizardModel.PROPERTY_SERVER_URL).observe(model),
+ // ImportProjectWizardModel.class,
+ // ImportProjectWizardModel.PROPERTY_SERVER_URL).observe(model),
// new UpdateValueStrategy()
// .setAfterGetValidator(new
// MandatoryStringValidator("You have to provide a value for the server
url."))
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -44,9 +44,9 @@
private IUser user;
private StringPreferenceValue rhLoginPreferenceValue;
- private ApplicationWizardModel wizardModel;
+ private ImportProjectWizardModel wizardModel;
- public CredentialsWizardPageModel(ApplicationWizardModel model) {
+ public CredentialsWizardPageModel(ImportProjectWizardModel model) {
this.wizardModel = model;
this.serverUrl = IOpenshiftService.BASE_URL;
this.rhLoginPreferenceValue = new StringPreferenceValue(RHLOGIN_PREFS_KEY,
OpenshiftUIActivator.PLUGIN_ID);
Copied:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
(from rev 35581,
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java)
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.io.File;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+
+/**
+ * @author André Dietisheim
+ */
+public class ImportProjectWizard extends Wizard implements INewWizard {
+
+ private ImportProjectWizardModel model;
+
+ public ImportProjectWizard() {
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ setWindowTitle("OpenShift application wizard");
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public boolean performFinish() {
+ try {
+ WizardUtils.runInWizard(
+ new Job("Creating local git repo...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ File repositoryFile = model.cloneRepository(monitor);
+ model.importProject(repositoryFile, monitor);
+ return Status.OK_STATUS;
+ } catch (OpenshiftException e) {
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ "An exception occurred while creating local git repository.", e);
+ } catch (URISyntaxException e) {
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ "The url of the remote git repository is not valid", e);
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ "An exception occurred while creating local git repository.", e);
+ }
+ }
+ }, getContainer());
+ return true;
+ } catch (Exception e) {
+ ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.",
+ new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ "An exception occurred while creating local git repository.", e));
+ return false;
+ }
+ }
+
+ @Override
+ public void addPages() {
+ this.model = new ImportProjectWizardModel();
+ addPage(new CredentialsWizardPage(this, model));
+ addPage(new ApplicationWizardPage(this, model));
+ addPage(new AdapterWizardPage(this, model));
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
(from rev 35581,
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java)
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
(rev 0)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.egit.core.RepositoryUtil;
+import org.eclipse.egit.core.op.CloneOperation;
+import org.eclipse.egit.core.op.ConnectProviderOperation;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.transport.JschConfigSessionFactory;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.osgi.util.NLS;
+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.IUser;
+import org.jboss.tools.openshift.express.client.OpenshiftException;
+import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIActivator;
+import
org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.GeneralProjectImportOperation;
+import
org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.MavenProjectImportOperation;
+
+/**
+ * @author André Dietisheim <adietish(a)redhat.com>
+ */
+public class ImportProjectWizardModel extends ObservableUIPojo {
+
+ private HashMap<String, Object> dataModel = new HashMap<String, Object>();
+
+ private static final String USER = "user";
+ private static final String APPLICATION = "application";
+
+ public void setProperty(String key, Object value) {
+ dataModel.put(key, value);
+ }
+
+ public Object getProperty(String key) {
+ return dataModel.get(key);
+ }
+
+ public void setUser(IUser user) {
+ dataModel.put(USER, user);
+ }
+
+ public IUser getUser() {
+ return (IUser) dataModel.get(USER);
+ }
+
+ public IApplication getApplication() {
+ return (IApplication) dataModel.get(APPLICATION);
+ }
+
+ public void setApplication(IApplication application) {
+ dataModel.put(APPLICATION, application);
+ }
+
+ public void importProject(final File projectFolder, IProgressMonitor monitor) throws
OpenshiftException,
+ CoreException,
+ InterruptedException {
+ new WorkspaceJob(NLS.bind("Importing projects from {0}",
projectFolder.getAbsolutePath())) {
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ try {
+ MavenProjectImportOperation mavenImport = new
MavenProjectImportOperation(projectFolder);
+ List<IProject> importedProjects = Collections.emptyList();
+ if (mavenImport.isMavenProject()) {
+ importedProjects = mavenImport.importToWorkspace(monitor);
+ } else {
+ importedProjects = new
GeneralProjectImportOperation(projectFolder).importToWorkspace(monitor);
+ }
+
+ File gitFolder = new File(projectFolder, Constants.DOT_GIT);
+ connectToGitRepo(importedProjects, gitFolder, monitor);
+
+ createServerAdapterIfRequired();
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ IStatus status = new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID,
+ NLS.bind("Could not import projects from {0}",
projectFolder.getAbsolutePath()), e);
+ OpenshiftUIActivator.log(status);
+ return status;
+ }
+ }
+ }.schedule();
+ }
+
+ private void connectToGitRepo(List<IProject> projects, File gitFolder,
IProgressMonitor monitor)
+ throws CoreException {
+ for (IProject project : projects) {
+ connectToGitRepo(project, gitFolder, monitor);
+ }
+ }
+
+ private void connectToGitRepo(IProject project, File gitFolder, IProgressMonitor
monitor) throws CoreException {
+ new ConnectProviderOperation(project).execute(monitor);
+ }
+
+ public File cloneRepository(IProgressMonitor monitor) throws URISyntaxException,
OpenshiftException,
+ InvocationTargetException,
+ InterruptedException {
+ File destination = getDestinationDirectory(getApplication());
+ cloneRepository(getApplication().getGitUri(), destination, monitor);
+ return destination;
+ }
+
+ private void cloneRepository(String uri, File destination, IProgressMonitor monitor)
throws URISyntaxException,
+ OpenshiftException,
+ InvocationTargetException,
+ InterruptedException {
+ if (destination.exists()) {
+ FileUtil.completeDelete(destination);
+ }
+ ensureEgitUIIsStarted();
+ URIish gitUri = new URIish(uri);
+ RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil();
+ CloneOperation cloneOperation =
+ new CloneOperation(gitUri, true, null, destination, Constants.HEAD,
"origin", 10 * 1024);
+ cloneOperation.run(null);
+ File gitDirectory = new File(destination, Constants.DOT_GIT);
+ repositoryUtil.addConfiguredRepository(gitDirectory);
+ }
+
+ /**
+ * The EGit UI plugin initializes the ssh factory to present the user a
+ * passphrase prompt if the ssh key was not read yet. If this initialization
+ * is not executed, the ssh connection to the git repo would just fail with
+ * an authentication error. We therefore have to make sure that the EGit UI
+ * plugin is started and initializes the JSchConfigSessionFactory.
+ * <p>
+ * EGit initializes the SshSessionFactory with the EclipseSshSessionFactory.
+ * The EclipseSshSessionFactory overrides JschConfigSessionFactory#configure
+ * to present a UserInfoPrompter if the key passphrase was not entered
+ * before.
+ *
+ * @see Activator#start(org.osgi.framework.BundleContext)
+ * @see Activator#setupSSH
+ * @see JschConfigSessionFactory#configure
+ * @see EclipseSshSessionFactory#configure
+ */
+ private void ensureEgitUIIsStarted() {
+ Activator.getDefault();
+ }
+
+ private File getDestinationDirectory(IApplication application) {
+ String applicationDirectory = application.getName();
+ // File workspace =
+ // ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
+ String userHome = System.getProperty("java.io.tmpdir");
+ // File workDir = new File(workspace, applicationWorkingdir);
+ return new File(userHome, applicationDirectory);
+ }
+
+ private void createServerAdapterIfRequired() {
+ // TODO
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.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/NewDomainDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java 2011-10-12
20:24:56 UTC (rev 35582)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java 2011-10-12
20:41:33 UTC (rev 35583)
@@ -29,7 +29,7 @@
private String namespace;
private NewDomainWizardModel model;
- public NewDomainDialog(String namespace, ApplicationWizardModel wizardModel) {
+ public NewDomainDialog(String namespace, ImportProjectWizardModel wizardModel) {
this.namespace = namespace;
this.model = new NewDomainWizardModel(namespace, wizardModel.getUser());
setNeedsProgressMonitor(true);