[jbosstools-commits] JBoss Tools SVN: r35574 - in trunk/as/plugins/org.jboss.tools.openshift.express.ui: src/org/jboss/tools/openshift/express/internal/ui/wizard and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Oct 12 11:24:11 EDT 2011


Author: adietish
Date: 2011-10-12 11:24:10 -0400 (Wed, 12 Oct 2011)
New Revision: 35574

Added:
   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
Removed:
   trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.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/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
   trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/projectimport/GeneralProjectImportOperation.java
Log:
[JBIDE-9793] renamed serveradapter wizard to application wizard

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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/plugin.xml	2011-10-12 15:24:10 UTC (rev 35574)
@@ -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.ServerAdapterWizard"
+            class="org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationWizard"
             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/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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -62,7 +62,7 @@
 	private Label domainLabel;
 	private Label modeLabel;
 
-	public AdapterWizardPage(ServerAdapterWizard wizard, ServerAdapterWizardModel model) {
+	public AdapterWizardPage(ApplicationWizard wizard, ApplicationWizardModel model) {
 		super("Server Adapter", "...", "Server Adapter", wizard);
 		this.model = new AdapterWizardPageModel(model);
 	}

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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -13,7 +13,7 @@
 import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
 
 /**
- * @author André Dietisheim
+ * @author Rob Stryker
  */
 public class AdapterWizardPageModel extends ObservableUIPojo {
 	public static final String CREATE_SERVER = "createServer";
@@ -24,14 +24,14 @@
 	public static final String SERVER_TYPE = "serverType";
 
 
-	private ServerAdapterWizardModel wizardModel;
+	private ApplicationWizardModel wizardModel;
 
-	public AdapterWizardPageModel(ServerAdapterWizardModel wizardModel) {
+	public AdapterWizardPageModel(ApplicationWizardModel wizardModel) {
 		this.wizardModel = wizardModel;
 	}
 	
 	// TODO is this the best way? Or should we expose ONLY getters to the parent model?
-	public ServerAdapterWizardModel getParentModel() {
+	public ApplicationWizardModel getParentModel() {
 		return wizardModel;
 	}
 

Copied: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java (from rev 35563, trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java)
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java	                        (rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -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 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));
+	}
+}


Property changes on: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizard.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/ApplicationWizardModel.java (from rev 35569, trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizardModel.java)
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java	                        (rev 0)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * 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.io.IOException;
+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.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.egit.core.op.CloneOperation;
+import org.eclipse.egit.core.op.ConnectProviderOperation;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.InitCommand;
+import org.eclipse.jgit.api.errors.CheckoutConflictException;
+import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
+import org.eclipse.jgit.api.errors.InvalidMergeHeadsException;
+import org.eclipse.jgit.api.errors.NoHeadException;
+import org.eclipse.jgit.api.errors.NoMessageException;
+import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.merge.MergeStrategy;
+import org.eclipse.jgit.transport.URIish;
+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.wizard.projectimport.GeneralProjectImportOperation;
+import org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.MavenProjectImportOperation;
+
+/**
+ * @author André Dietisheim <adietish at 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(File projectFolder, IProgressMonitor monitor) throws OpenshiftException, CoreException, InterruptedException {
+		MavenProjectImportOperation mavenImport = new MavenProjectImportOperation(projectFolder);
+		List<IProject> importedProjects = Collections.emptyList();
+		if (mavenImport.isMavenProject()) {
+			importedProjects = mavenImport.importToWorkspace(monitor);
+		} else {
+			importedProjects = new GeneralProjectImportOperation(projectFolder).importToWorkspace(monitor);
+		}
+
+		connectToGitRepo(importedProjects, monitor);
+
+		createServerAdapterIfRequired();
+	}
+
+	private void connectToGitRepo(List<IProject> projects, IProgressMonitor monitor) throws CoreException {
+		for (IProject project : projects) {
+			connectToGitRepo(project, monitor);
+		}
+	}
+
+	private void connectToGitRepo(IProject project, 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);
+		}
+		URIish gitUri = new URIish(uri);
+		CloneOperation cloneOperation =
+				new CloneOperation(gitUri, true, null, destination, Constants.HEAD, "origin", 10 * 1024);
+		cloneOperation.run(null);
+		File gitDirectory = new File(destination, Constants.DOT_GIT);
+		Activator.getDefault().getRepositoryUtil().addConfiguredRepository(gitDirectory);
+	}
+
+	private File getDestinationDirectory(IApplication application) {
+		String applicationDirectory = "openshift-" + 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 mergeWithRemote(Git git, String remoteName) throws CoreException, NoHeadException,
+			ConcurrentRefUpdateException, CheckoutConflictException, InvalidMergeHeadsException,
+			WrongRepositoryStateException, NoMessageException, IOException {
+		Repository repository = git.getRepository();
+		ObjectId objectId = repository.resolve("HEAD");
+		git.merge().include(objectId).setStrategy(MergeStrategy.OURS).call();
+	}
+
+	private void createServerAdapterIfRequired() {
+		// TODO
+	}
+
+	private Git createGit(File repositoryFile) throws IOException {
+		InitCommand init = Git.init();
+		init.setDirectory(repositoryFile);
+		init.setBare(false);
+		return init.call();
+	}
+
+	private File createRepositoryFile(String name) {
+		IPath workspace = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+		IPath gitRepoProject = workspace.append(name);
+		File repositoryFile = new File(gitRepoProject.toFile(), Constants.DOT_GIT);
+		return repositoryFile;
+	}
+
+
+}


Property changes on: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardModel.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/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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -68,9 +68,9 @@
 
 	private TableViewer viewer;
 	private ApplicationWizardPageModel model;
-	private ServerAdapterWizardModel wizardModel;
+	private ApplicationWizardModel wizardModel;
 
-	protected ApplicationWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
+	protected ApplicationWizardPage(IWizard wizard, ApplicationWizardModel 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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPageModel.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -32,9 +32,9 @@
 	private String namespace;
 	private IDomain domain;
 	private IApplication selectedApplication;
-	private ServerAdapterWizardModel wizardModel;
+	private ApplicationWizardModel wizardModel;
 
-	public ApplicationWizardPageModel(ServerAdapterWizardModel wizardModel) {
+	public ApplicationWizardPageModel(ApplicationWizardModel wizardModel) {
 		this.wizardModel = wizardModel;
 	}
 

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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -47,7 +47,7 @@
 
 	private CredentialsWizardPageModel model;
 
-	public CredentialsWizardPage(IWizard wizard, ServerAdapterWizardModel wizardModel) {
+	public CredentialsWizardPage(IWizard wizard, ApplicationWizardModel 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(
-		// ServerAdapterWizardModel.class,
-		// ServerAdapterWizardModel.PROPERTY_SERVER_URL).observe(model),
+		// ApplicationWizardModel.class,
+		// ApplicationWizardModel.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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -44,9 +44,9 @@
 	private IUser user;
 	private StringPreferenceValue rhLoginPreferenceValue;
 
-	private ServerAdapterWizardModel wizardModel;
+	private ApplicationWizardModel wizardModel;
 
-	public CredentialsWizardPageModel(ServerAdapterWizardModel model) {
+	public CredentialsWizardPageModel(ApplicationWizardModel model) {
 		this.wizardModel = model;
 		this.serverUrl = IOpenshiftService.BASE_URL;
 		this.rhLoginPreferenceValue = new StringPreferenceValue(RHLOGIN_PREFS_KEY, OpenshiftUIActivator.PLUGIN_ID);

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 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -29,7 +29,7 @@
 	private String namespace;
 	private NewDomainWizardModel model;
 
-	public NewDomainDialog(String namespace, ServerAdapterWizardModel wizardModel) {
+	public NewDomainDialog(String namespace, ApplicationWizardModel wizardModel) {
 		this.namespace = namespace;
 		this.model = new NewDomainWizardModel(namespace, wizardModel.getUser());
 		setNeedsProgressMonitor(true);

Deleted: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java	2011-10-12 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ServerAdapterWizard.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -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 ServerAdapterWizard extends Wizard implements INewWizard {
-
-	private ServerAdapterWizardModel model;
-
-	public ServerAdapterWizard() {
-	}
-
-	@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 ServerAdapterWizardModel();
-		addPage(new CredentialsWizardPage(this, model));
-		addPage(new ApplicationWizardPage(this, model));
-		addPage(new AdapterWizardPage(this, model));
-	}
-}

Modified: trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/projectimport/GeneralProjectImportOperation.java
===================================================================
--- trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/projectimport/GeneralProjectImportOperation.java	2011-10-12 14:57:03 UTC (rev 35573)
+++ trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/projectimport/GeneralProjectImportOperation.java	2011-10-12 15:24:10 UTC (rev 35574)
@@ -11,22 +11,23 @@
 package org.jboss.tools.openshift.express.internal.ui.wizard.projectimport;
 
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
 import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.m2e.core.internal.jobs.IBackgroundProcessingQueue;
+import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
-import org.eclipse.ui.wizards.datatransfer.ImportOperation;
 
 /**
  * @author Andre Dietisheim <adietish at redhat.com>
@@ -40,29 +41,36 @@
 
 	public List<IProject> importToWorkspace(IProgressMonitor monitor)
 			throws CoreException, InterruptedException {
-		
-		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-		IProject project = workspaceRoot.getProject(getProjectDirectory().getName());
+
+		IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		IProject project = workspace.getRoot().getProject(getProjectDirectory().getName());
 		overwriteExistingProject(project, monitor);
+		importToWorkspace(getProjectDirectory(), workspace, monitor);
 		return Collections.singletonList(project);
 	}
 
-	private void importToNewProject(File projectDirectory, IProject project, IProgressMonitor monitor)
-			throws CoreException, InvocationTargetException, InterruptedException {
-		project.create(monitor);
-		project.open(monitor);
-		ImportOperation operation =
-				new ImportOperation(
-						project.getFullPath()
-						, projectDirectory
-						, FileSystemStructureProvider.INSTANCE
-						, new IOverwriteQuery() {
-							public String queryOverwrite(String file) {
-								return IOverwriteQuery.ALL;
-							}
-						});
-		operation.setCreateContainerStructure(false);
-		operation.run(monitor);
+	private void importToWorkspace(File projectDirectory, IWorkspace workspace, IProgressMonitor monitor) throws CoreException {
+		String projectName = projectDirectory.getName();
+		IProjectDescription description = workspace.newProjectDescription(projectName);
+		description.setLocation(new Path(projectDirectory.toString()));
+		IProject project = workspace.getRoot().getProject(projectName);
+		project.create(description, monitor);
+		project.open(IResource.BACKGROUND_REFRESH, monitor);
+		// project.create(monitor);
+		// project.open(IResource.BACKGROUND_REFRESH, monitor);
+		// ImportOperation operation =
+		// new ImportOperation(
+		// project.getFullPath()
+		// , projectDirectory
+		// , FileSystemStructureProvider.INSTANCE
+		// , new IOverwriteQuery() {
+		// public String queryOverwrite(String file) {
+		// return IOverwriteQuery.ALL;
+		// }
+		// });
+		// operation.setCreateContainerStructure(false);
+		// operation.run(monitor);
+
 	}
 
 	private void overwriteExistingProject(final IProject project, IProgressMonitor monitor)



More information about the jbosstools-commits mailing list