JBoss Tools SVN: r37070 - in branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim: ui and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-12-07 13:12:30 -0500 (Wed, 07 Dec 2011)
New Revision: 37070
Modified:
branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg
branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
Log:
https://issues.jboss.org/browse/JBIDE-10400: BrowserSim : the widow size issues
Modified: branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg
===================================================================
--- branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg 2011-12-07 18:00:43 UTC (rev 37069)
+++ branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg 2011-12-07 18:12:30 UTC (rev 37070)
@@ -1,5 +1,5 @@
-0
-PC (Default) -1 -1
+3
+Desktop (Default User-Agent) 1024 768
Apple iPad 2 768 1024 Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5
Apple iPhone 3 320 480 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
Apple iPhone 4 640 960 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
Modified: branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
===================================================================
--- branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2011-12-07 18:00:43 UTC (rev 37069)
+++ branches/jbosstools-3.3.0.M5/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2011-12-07 18:12:30 UTC (rev 37070)
@@ -424,7 +424,7 @@
private void setBrowserSize(int width, int height) {
GridData data = (GridData) browser.getLayoutData();
- Rectangle clientArea = display.getClientArea();
+ Rectangle clientArea = getMonitorClientArea();
int shellWidthHint = SWT.DEFAULT;
if (width != Device.DEFAULT_SIZE) {
data.widthHint = width;
@@ -463,6 +463,19 @@
shell.setBounds(shellBounds);
}
+
+ private Rectangle getMonitorClientArea() {
+ Rectangle clientArea = shell.getMonitor().getClientArea();
+
+ /* on Linux returned monitor client area may be bigger
+ * than the monitor bounds when multiple monitors are used.
+ * The following code fixes this */
+ Rectangle bounds = shell.getMonitor().getBounds();
+ clientArea.width = Math.min(clientArea.width, bounds.width);
+ clientArea.height = Math.min(clientArea.height, bounds.height);
+
+ return clientArea;
+ }
private void initOrientation(int orientation) {
browser.execute("window.onorientationchange = null;"
14 years
JBoss Tools SVN: r37068 - in branches/jbosstools-3.3.0.M5/openshift/plugins: org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-12-07 12:57:26 -0500 (Wed, 07 Dec 2011)
New Revision: 37068
Added:
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
Modified:
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/build.properties
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java
Log:
[JBIDE-10171] implemented strategy to be able to push existing projects to OpenShift.
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -10,10 +10,15 @@
******************************************************************************/
package org.jboss.tools.openshift.egit.core;
+import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
+import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IProject;
@@ -24,24 +29,36 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.egit.core.EclipseGitProgressTransformer;
import org.eclipse.egit.core.IteratorService;
+import org.eclipse.egit.core.op.AddToIndexOperation;
import org.eclipse.egit.core.op.CommitOperation;
+import org.eclipse.egit.core.op.ConnectProviderOperation;
+import org.eclipse.egit.core.op.FetchOperation;
+import org.eclipse.egit.core.op.MergeOperation;
import org.eclipse.egit.core.op.PushOperation;
import org.eclipse.egit.core.op.PushOperationSpecification;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.UIText;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.InitCommand;
+import org.eclipse.jgit.api.MergeResult;
+import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.IndexDiff;
import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.UserConfig;
+import org.eclipse.jgit.merge.MergeStrategy;
+import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.team.core.RepositoryProvider;
import org.jboss.tools.openshift.egit.core.internal.EGitCoreActivator;
/**
@@ -56,26 +73,245 @@
private static final int PUSH_TIMEOUT = 10 * 1024;
+ private static final String EGIT_TEAM_PROVIDER_ID =
+ "org.eclipse.egit.core·GitProvider";
+
+ private EGitUtils() {
+ // inhibit instantiation
+ }
+
/**
- * Commits the given project to it's configured repository.
+ * Returns <code>true</code> if the given project is associated to any team
+ * provider (git, svn, cvs, etc.). Returns <code>false</code> otherwise.
*
* @param project
- * the project
+ * the project to check
+ * @return <code>true</code> if the project is associated with any team
+ * provider.
+ */
+ public static boolean isShared(IProject project) {
+ return RepositoryProvider.getProvider(project) != null;
+ }
+
+ /**
+ * Returns <code>true</code> if the given project is associated to the egit
+ * team provider. Returns <code>false</code> otherwise.
+ *
+ * @param project
+ * the project to check
+ * @return <code>true</code> if the project is associated with the git team
+ * provider.
+ */
+ public static boolean isSharedWithGit(IProject project) {
+ return EGIT_TEAM_PROVIDER_ID.equals(RepositoryProvider.getProvider(project));
+ }
+
+ /**
+ * Returns <code>true</code> if the given project exists and has a .git
+ * folder in it.
+ *
+ * @param project
+ * @return
+ */
+ public static boolean hasDotGitFolder(IProject project) {
+ if (project == null
+ || !project.exists()) {
+ return false;
+ }
+ return new File(project.getLocation().toOSString(), Constants.DOT_GIT).exists();
+ }
+
+ /**
+ * Shares the given project. A repository is created within the given
+ * project and the project is connected to the freshly created repository.
+ *
+ * @param project
* @param monitor
- * the monitor
+ * @return
* @throws CoreException
- * the core exception
*/
- public static void commit(IProject project, String commitMessage, IProgressMonitor monitor) throws CoreException {
- Assert.isLegal(project != null, "Cannot commit project. No project provided");
+ public static Repository share(IProject project, IProgressMonitor monitor) throws CoreException {
+ Repository repository = createRepository(project, monitor);
+ connect(project, repository, monitor);
+ addToRepository(project, repository, monitor);
+ commit(project, monitor);
+ // checkout("master", repository);
+ return repository;
+ }
+
+ /**
+ * Creates a repository for the given project. The repository is created in
+ * the .git directory within the given project. The project is not connected
+ * with the new repository
+ *
+ * @param project
+ * the project to create the repository for.
+ * @param monitor
+ * the monitor to report the progress to
+ * @return
+ * @throws CoreException
+ *
+ * @see #connect(IProject, Repository, IProgressMonitor)
+ */
+ public static Repository createRepository(IProject project, IProgressMonitor monitor) throws CoreException {
+ try {
+ InitCommand init = Git.init();
+ init.setBare(false).setDirectory(project.getLocation().toFile());
+ Git git = init.call();
+ return git.getRepository();
+ } catch (JGitInternalException e) {
+ throw new CoreException(EGitCoreActivator.createErrorStatus(
+ NLS.bind("Could not initialize a git repository at {0}: {1}",
+ getRepositoryPathFor(project),
+ e.getMessage()), e));
+ }
+ }
+
+ public static File getRepositoryPathFor(IProject project) {
+ return new File(project.getLocationURI().getPath(), Constants.DOT_GIT);
+ }
+
+ public static void addToRepository(IProject project, Repository repository, IProgressMonitor monitor)
+ throws CoreException {
+ AddToIndexOperation add = new AddToIndexOperation(Collections.singletonList(project));
+ add.execute(monitor);
+ }
+
+ /**
+ * Connects the given project to the repository within it.
+ *
+ * @param project
+ * the project to connect
+ * @param monitor
+ * the monitor to report progress to
+ * @throws CoreException
+ */
+ public static void connect(IProject project, IProgressMonitor monitor) throws CoreException {
+ connect(project, getRepositoryPathFor(project), monitor);
+ }
+
+ /**
+ * Connects the given project to the given repository.
+ *
+ * @param project
+ * the project to connect
+ * @param repository
+ * the repository to connect the project to
+ * @param monitor
+ * the monitor to report progress to
+ * @throws CoreException
+ */
+ private static void connect(IProject project, Repository repository, IProgressMonitor monitor) throws CoreException {
+ connect(project, repository.getDirectory(), monitor);
+ }
+
+ private static void connect(IProject project, File repositoryFolder, IProgressMonitor monitor) throws CoreException {
+ new ConnectProviderOperation(project, repositoryFolder).execute(monitor);
+ }
+
+ /**
+ * Merges the given uri to HEAD in the given repository. The given branch is
+ * the branch in the local repo the fetched HEAD is fetched to.
+ *
+ * @param branch
+ * @param uri
+ * @param repository
+ * @param monitor
+ * @throws CoreException
+ * @throws InvocationTargetException
+ */
+ public static void mergeWithRemote(URIish uri, String branch, Repository repository, IProgressMonitor monitor)
+ throws CoreException, InvocationTargetException {
+ RefSpec ref = new RefSpec().setSource(Constants.HEAD).setDestination(branch);
+ fetch(uri, Collections.singletonList(ref), repository, monitor);
+ merge(branch, repository, monitor);
+ }
+
+ /**
+ * Merges current master with the given branch. The strategy used is Resolve
+ * since egit does still not support the Recusive stragety.
+ *
+ * @param branch
+ * the branch to merge
+ * @param repository
+ * the repository the branch is in
+ * @param monitor
+ * the monitor to report the progress to
+ * @return the result of the merge
+ * @throws CoreException
+ *
+ * @see MergeStrategy#RESOLVE
+ * @link
+ * http://www.eclipse.org/forums/index.php/mv/msg/261278/753913/#msg_753913
+ * @link https://bugs.eclipse.org/bugs/show_bug.cgi?id=354099
+ * @link https://bugs.eclipse.org/bugs/show_bug.cgi?id=359951
+ */
+ private static MergeResult merge(String branch, Repository repository, IProgressMonitor monitor)
+ throws CoreException {
+ MergeOperation merge = new MergeOperation(repository, branch, MergeStrategy.RESOLVE.getName());
+ merge.execute(monitor);
+ return merge.getResult();
+ }
+
+ /**
+ * Fetches the source ref(s) (from the given ref spec(s)) from the given uri
+ * to the given destination(s) (in the given ref spec(s)) to the given
+ * repository.
+ *
+ * @param uri
+ * the uri to fetch from
+ * @param fetchRefsRefSpecs
+ * the references with the sources and destinations
+ * @param repository
+ * the repository to fetch to
+ * @param monitor
+ * the monitor to report progress to
+ * @return
+ * @throws InvocationTargetException
+ * @throws CoreException
+ */
+ private static Collection<Ref> fetch(URIish uri, List<RefSpec> fetchRefsRefSpecs, Repository repository,
+ IProgressMonitor monitor)
+ throws InvocationTargetException, CoreException {
+ FetchOperation fetch = new FetchOperation(repository, uri, fetchRefsRefSpecs, 10 * 1024, false);
+ fetch.run(monitor);
+ FetchResult result = fetch.getOperationResult();
+ return result.getAdvertisedRefs();
+ }
+
+ /**
+ * Commits the changes within the given project to it's configured
+ * repository. The project has to be connected to a repository.
+ *
+ * @param project
+ * the project whose changes shall be committed
+ * @param monitor
+ * the monitor to report progress to
+ * @throws CoreException
+ *
+ * @see #connect(IProject, Repository)
+ */
+ private static void commit(IProject project, String commitMessage, IProgressMonitor monitor) throws CoreException {
+ Repository repository = getRepository(project);
+ Assert.isLegal(repository != null, "Cannot commit project to repository. ");
+ commit(project, commitMessage, repository, monitor);
+ }
+
+ public static void commit(IProject project, IProgressMonitor monitor) throws CoreException {
+ commit(project, "Commit from JBoss Tools", monitor);
+ }
+
+ private static void commit(IProject project, String commitMessage, Repository repository, IProgressMonitor monitor)
+ throws CoreException {
+ Assert.isLegal(project != null, "Could not commit project. No project provided");
+ Assert.isLegal(
+ repository != null,
+ MessageFormat
+ .format("Could not commit. Project \"{0}\" is not connected to a repository (call #connect(project, repository) first)",
+ project.getName()));
/**
* TODO: add capability to commit selectively
*/
- Repository repository = getRepository(project);
- if (repository == null) {
- throw new CoreException(createStatus(null,
- "Could not commit. Project \"{0}\" is not attached to a git repo", project.getName()));
- }
UserConfig userConfig = getUserConfig(repository);
CommitOperation op = new CommitOperation(
null,
@@ -89,10 +325,6 @@
op.execute(monitor);
}
- public static void commit(IProject project, IProgressMonitor monitor) throws CoreException {
- commit(project, "Commit from JBoss Tools", monitor);
- }
-
/**
* Pushes the given repository to the remote repository it's current branch
* originates from.
@@ -449,26 +681,26 @@
}
return status;
}
-
+
public static int countCommitableChanges(IProject project, IProgressMonitor monitor) {
try {
Repository repo = getRepository(project);
-
+
EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);
IndexDiff indexDiff = new IndexDiff(repo, Constants.HEAD,
IteratorService.createInitialIterator(repo));
indexDiff.diff(jgitMonitor, 0, 0, NLS.bind(
UIText.CommitActionHandler_repository, repo.getDirectory().getPath()));
-// System.out.println(indexDiff.getAdded().size());
-// System.out.println(indexDiff.getChanged().size());
-// System.out.println(indexDiff.getConflicting().size());
-// System.out.println(indexDiff.getMissing().size());
-// System.out.println(indexDiff.getModified().size());
-// System.out.println(indexDiff.getRemoved().size());
-// System.out.println(indexDiff.getUntracked().size());
-
+ // System.out.println(indexDiff.getAdded().size());
+ // System.out.println(indexDiff.getChanged().size());
+ // System.out.println(indexDiff.getConflicting().size());
+ // System.out.println(indexDiff.getMissing().size());
+ // System.out.println(indexDiff.getModified().size());
+ // System.out.println(indexDiff.getRemoved().size());
+ // System.out.println(indexDiff.getUntracked().size());
+
return indexDiff.getModified().size();
- } catch( IOException ioe ) {
+ } catch (IOException ioe) {
}
return -1;
}
Added: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java (rev 0)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.egit.core;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jgit.lib.Constants;
+
+public class GitIgnore {
+
+ private List<String> entries;
+ private File baseDir;
+
+ public GitIgnore(File baseDir) {
+ this.baseDir = baseDir;
+ this.entries = new ArrayList<String>();
+ }
+
+ public GitIgnore add(String entry) {
+ this.entries.add(entry);
+ return this;
+ }
+
+ /**
+ * Writes the entries in this instance to the .gitignore file. Overwrites
+ * and existing file if the given overwrite is set to <code>true</code>,
+ * appends otherwise.
+ *
+ * @param overwrite
+ * overwrites an existing file if <code>true</code>, appends
+ * otherwise
+ * @throws IOException
+ */
+ public void write(boolean overwrite) throws IOException {
+ File file = getFile();
+ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file, !overwrite));
+ try {
+ for (String entry : entries) {
+ out.write(entry.getBytes());
+ out.write('\n');
+ }
+ out.flush();
+ } finally {
+ out.close();
+ }
+ }
+
+ public boolean exists() {
+ return getFile().exists();
+ }
+
+ private File getFile() {
+ File file = new File(baseDir, Constants.GITIGNORE_FILENAME);
+ return file;
+ }
+}
Property changes on: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.openshift.egit.core.internal;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -34,4 +36,16 @@
public void stop(BundleContext bundleContext) throws Exception {
EGitCoreActivator.context = null;
}
+
+ public static IStatus createErrorStatus(String message, Throwable throwable) {
+ return createStatus(IStatus.ERROR, message, throwable);
+ }
+
+ public static IStatus createStatus(int severity, String message, Throwable throwable) {
+ if (throwable == null) {
+ return new Status(severity, PLUGIN_ID, message);
+ } else {
+ return new Status(severity, PLUGIN_ID, message, throwable);
+ }
+ }
}
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF 2011-12-07 17:57:26 UTC (rev 37068)
@@ -4,9 +4,10 @@
Bundle-SymbolicName: org.jboss.tools.openshift.egit.ui;singleton:=true
Bundle-Version: 2.3.0.qualifier
Bundle-Activator: org.jboss.tools.openshift.egit.ui.EGitUIActivator
-Require-Bundle: org.eclipse.egit.core;bundle-version="1.0.0",
- org.eclipse.jgit;bundle-version="1.0.0",
- org.eclipse.ui,
+Require-Bundle: org.eclipse.egit.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.egit.ui;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jgit;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.ui;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.runtime,
org.eclipse.core.expressions;bundle-version="[3.4.300,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.7.100,4.0.0)",
@@ -15,3 +16,4 @@
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: JBoss by Red Hat
+Export-Package: org.jboss.tools.openshift.egit.ui.util
Added: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java (rev 0)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.egit.ui.util;
+
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
+
+public class EGitUIUtils {
+
+ public static String getEGitDefaultRepositoryPath() {
+ return Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
+ }
+
+}
Property changes on: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2011-12-07 17:57:26 UTC (rev 37068)
@@ -6,6 +6,9 @@
Bundle-Localization: plugin
Bundle-Activator: org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator
Require-Bundle: org.jboss.tools.openshift.express.client;bundle-version="2.3.0",
+ org.jboss.tools.openshift.egit.core;bundle-version="2.3.0",
+ org.jboss.tools.openshift.egit.ui;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.ui;bundle-version="[2.3.0,3.0.0)",
org.eclipse.egit.ui;bundle-version="[1.0.0,2.0.0)",
org.eclipse.egit.core;bundle-version="[1.1.0,2.0.0)",
org.eclipse.jgit;bundle-version="[1.1.0,2.1.0)",
@@ -22,19 +25,17 @@
org.eclipse.jface.databinding;bundle-version="[1.5.0,2.0.0)",
org.eclipse.wst.server.core;bundle-version="[1.1.3,2.0.0)",
org.eclipse.debug.core;bundle-version="[3.7.0,4.0.0)",
- org.jboss.ide.eclipse.as.ui;bundle-version="[2.3.0,3.0.0)",
org.eclipse.wst.server.ui;bundle-version="[1.1.3,2.0.0)",
org.eclipse.ui.ide;bundle-version="3.7.0",
org.eclipse.m2e.core.ui;bundle-version="1.0.100",
org.eclipse.wst.common.modulecore;bundle-version="1.2.100",
org.eclipse.team.ui;bundle-version="3.6.100",
- org.jboss.tools.openshift.egit.core;bundle-version="2.3.0",
org.eclipse.jdt.launching;bundle-version="3.6.0",
org.eclipse.debug.ui;bundle-version="3.7.0",
- com.jcraft.jsch.source;bundle-version="0.1.44";resolution:=optional,
org.eclipse.ui.navigator;bundle-version="3.5.100",
org.eclipse.ui.console;bundle-version="3.5.100",
- org.eclipse.core.expressions;bundle-version="3.4.300"
+ org.eclipse.core.expressions;bundle-version="3.4.300",
+ org.eclipse.wst.common.modulecore;bundle-version="1.2.101"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.common.databinding,
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/build.properties
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/build.properties 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/build.properties 2011-12-07 17:57:26 UTC (rev 37068)
@@ -5,4 +5,11 @@
pom.xml,\
META-INF/,\
bin/,\
- plugin.xml
+ plugin.xml,\
+ plugin.properties
+src.includes = plugin.properties,\
+ META-INF/,\
+ bin/,\
+ icons/,\
+ plugin.xml,\
+ pom.xml
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties 2011-12-07 17:57:26 UTC (rev 37068)
@@ -5,4 +5,4 @@
# Version Delegates
openshift.express.name=OpenShift Express Runtime
openshift.express.description=A server adapter for use interfacing with the OpenShift Express Framework
-openshift.express.runtime.name=OpenShift Express Runtime
+openshift.express.runtime.name = OpenShift Express Runtime
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2011-12-07 17:57:26 UTC (rev 37068)
@@ -212,7 +212,7 @@
type="org.eclipse.ui.console.MessageConsole">
</propertyTester>
</extension>
-
+
<extension point="org.eclipse.ui.editors.templates">
<template id="org.jboss.tools.maven.editor.xml.templates.profiles.openshift"
contextTypeId="org.eclipse.m2e.editor.xml.templates.contextType.profiles"
@@ -238,8 +238,5 @@
</build>
</profile></pattern>
</template>
- </extension>
-
-
-
+ </extension>
</plugin>
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -68,6 +68,10 @@
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e));
}
+ public static IStatus createErrorStatus(String message) {
+ return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, message);
+ }
+
public static IStatus createErrorStatus(String message, Throwable throwable) {
return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, message, throwable);
}
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -10,13 +10,24 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.common;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import org.eclipse.core.runtime.Assert;
+
/**
* @author André Dietisheim
*/
public class FileUtils {
+ private static final byte[] buffer = new byte[1024];
+
public static boolean canRead(String path) {
if (path == null) {
return false;
@@ -31,5 +42,140 @@
return file.canRead();
}
-
+ public static boolean exists(File file) {
+ return file != null
+ && file.exists();
+ }
+
+ public static boolean isDirectory(File file) {
+ return file != null
+ && file.isDirectory();
+ }
+
+ /**
+ * Copies the ginve source to the given destination recursively. Overwrites
+ * existing files/directory on the destination path if told so.
+ *
+ * @param source
+ * the source file/directory to copy
+ * @param destination
+ * the destination to copy to
+ * @param overwrite
+ * overwrites existing files/directories if <code>true</code>.
+ * Does not overwrite otherwise.
+ * @throws IOException
+ */
+ public static void copy(File source, File destination, boolean overwrite) throws IOException {
+ if (!exists(source)
+ || destination == null) {
+ return;
+ }
+
+ if (source.isDirectory()) {
+ copyDirectory(source, destination, overwrite);
+ } else {
+ copyFile(source, destination, overwrite);
+ }
+ }
+
+ private static void copyDirectory(File source, File destination, boolean overwrite) throws IOException {
+ Assert.isLegal(source != null);
+ Assert.isLegal(source.isDirectory());
+ Assert.isLegal(destination != null);
+
+ destination = getDestinationDirectory(source, destination);
+
+ if (!destination.exists()) {
+ destination.mkdir();
+ }
+
+ for (File content : source.listFiles()) {
+ if (content.isDirectory()) {
+ copyDirectory(content, new File(destination, content.getName()), overwrite);
+ } else {
+ copyFile(content, new File(destination, content.getName()), overwrite);
+ }
+ }
+ }
+
+ private static File getDestinationDirectory(File source, File destination) {
+ if (!source.getName().equals(destination.getName())) {
+ destination = new File(destination, source.getName());
+ }
+ return destination;
+ }
+
+ private static void copyFile(File source, File destination, boolean overwrite) throws IOException {
+ Assert.isLegal(source != null);
+ Assert.isLegal(source.isFile());
+ Assert.isLegal(destination != null);
+
+ destination = getDestinationFile(source, destination);
+
+ if (exists(destination)
+ && !overwrite) {
+ return;
+ }
+
+ if (isDirectory(destination)) {
+ if (!overwrite) {
+ return;
+ }
+ destination.delete();
+ }
+
+ writeTo(source, destination);
+ }
+
+ private static File getDestinationFile(File source, File destination) {
+ if (!source.getName().equals(destination.getName())) {
+ destination = new File(destination, source.getName());
+ }
+ return destination;
+ }
+
+ private static final void writeTo(File source, File destination) throws IOException {
+ Assert.isLegal(source != null);
+ Assert.isLegal(destination != null);
+
+ InputStream in = null;
+ writeTo(new BufferedInputStream(new FileInputStream(source)), destination);
+ }
+
+ private static final void writeTo(InputStream in, File destination) throws IOException {
+ Assert.isLegal(in != null);
+ Assert.isLegal(destination != null);
+
+ OutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(destination));
+ for (int read = -1; (read = in.read(buffer)) != -1; ) {
+ out.write(buffer, 0, read);
+ }
+ out.flush();
+ } finally {
+ silentlyClose(in);
+ silentlyClose(out);
+ }
+ }
+
+ private static void silentlyClose(InputStream in) {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ private static void silentlyClose(OutputStream out) {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -20,19 +20,21 @@
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.resources.IProject;
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.databinding.swt.WidgetProperties;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
@@ -55,20 +57,22 @@
*
*/
public class AdapterWizardPage extends AbstractOpenShiftWizardPage implements IWizardPage, PropertyChangeListener {
- private Text gitUriValueText;
private AdapterWizardPageModel model;
- private IServerType serverTypeToCreate;
+ private Text cloneUriValueText;
private Label domainValueLabel;
private Label modeValueLabel;
private Button serverAdapterCheckbox;
+ private IServerType serverTypeToCreate;
private IObservableValue serverAdapterCheckboxObservable;
+ private IObservableValue newProjectCheckboxIsEnabled;
public AdapterWizardPage(ImportProjectWizard wizard, ImportProjectWizardModel model) {
super(
- "Import Project",
- "Select the Git clone destination, the branch to clone "
+ "Import OpenShift application",
+ "Choose to create a new/use existing project, " +
+ "the GITbranch and clone destination, "
+ "and configure your server adapter ",
"Server Adapter",
wizard);
@@ -80,15 +84,86 @@
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().applyTo(parent);
- Group projectGroup = createCloneGroup(parent, dbc);
+ Group mergeGroup = createProjectGroup(parent, dbc);
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(projectGroup);
+ .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(mergeGroup);
+ Group cloneGroup = createCloneGroup(parent, dbc);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(cloneGroup);
+
Group serverAdapterGroup = createAdapterGroup(parent, dbc);
GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(serverAdapterGroup);
+ .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(serverAdapterGroup);
+
+ Label fillerLabel = new Label(parent, SWT.NONE);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(fillerLabel);
+
}
+ private Group createProjectGroup(Composite parent, DataBindingContext dbc) {
+ Group projectGroup = new Group(parent, SWT.BORDER);
+ projectGroup.setText("Project");
+ 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);
+
+ Button newProjectCheckbox = new Button(projectGroup, SWT.CHECK);
+ newProjectCheckbox.setText("Create new Project");
+ GridDataFactory.fillDefaults()
+ .span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, true).applyTo(newProjectCheckbox);
+ IObservableValue newProjectObservable =
+ BeanProperties.value(AdapterWizardPageModel.PROPERTY_NEW_PROJECT).observe(model);
+ ValueBindingBuilder
+ .bind(WidgetProperties.selection().observe(newProjectCheckbox))
+ .to(newProjectObservable)
+ .in(dbc);
+
+ this.newProjectCheckboxIsEnabled = WidgetProperties.enabled().observe(newProjectCheckbox);
+
+ Label existingProjectLabel = new Label(projectGroup, SWT.NONE);
+ existingProjectLabel.setText("Existing Project");
+ GridDataFactory
+ .fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(existingProjectLabel);
+ ValueBindingBuilder
+ .bind(WidgetProperties.enabled().observe(existingProjectLabel))
+ .notUpdating(newProjectObservable)
+ .converting(new InvertingBooleanConverter())
+ .in(dbc);
+ Text newProjectText = new Text(projectGroup, SWT.BORDER);
+ newProjectText.setEditable(false);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.CENTER).grab(true, true).applyTo(newProjectText);
+
+ IObservableValue newProjectNameObservable =
+ BeanProperties.value(AdapterWizardPageModel.PROPERTY_PROJECT_NAME).observe(model);
+ ValueBindingBuilder
+ .bind(WidgetProperties.text().observe(newProjectText))
+ .to(newProjectNameObservable)
+ .in(dbc);
+ ValueBindingBuilder
+ .bind(WidgetProperties.enabled().observe(newProjectText))
+ .notUpdating(newProjectObservable)
+ .converting(new InvertingBooleanConverter())
+ .in(dbc);
+ dbc.addValidationStatusProvider(
+ new NewProjectValidator(newProjectObservable, newProjectNameObservable));
+
+ Button browseProjectsButton = new Button(projectGroup, SWT.NONE);
+ browseProjectsButton.setText("Browse");
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseProjectsButton);
+ browseProjectsButton.addSelectionListener(onBrowseProjects());
+ ValueBindingBuilder
+ .bind(WidgetProperties.enabled().observe(browseProjectsButton))
+ .notUpdating(newProjectObservable)
+ .converting(new InvertingBooleanConverter())
+ .in(dbc);
+
+ return projectGroup;
+ }
+
private Group createCloneGroup(Composite parent, DataBindingContext dbc) {
Group cloneGroup = new Group(parent, SWT.BORDER);
cloneGroup.setText("Git clone");
@@ -100,16 +175,16 @@
gitUriLabel.setText("Cloning From");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(gitUriLabel);
- gitUriValueText = new Text(cloneGroup, SWT.BORDER);
- gitUriValueText.setEditable(false);
+ cloneUriValueText = new Text(cloneGroup, SWT.BORDER);
+ cloneUriValueText.setEditable(false);
GridDataFactory
- .fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(gitUriValueText);
+ .fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(cloneUriValueText);
ValueBindingBuilder
- .bind(WidgetProperties.text(SWT.Modify).observe(gitUriValueText))
- .notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_GIT_URI).observe(model))
+ .bind(WidgetProperties.text(SWT.Modify).observe(cloneUriValueText))
+ .notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_CLONE_URI).observe(model))
.in(dbc);
ValueBindingBuilder
- .bind(WidgetProperties.enabled().observe(gitUriValueText))
+ .bind(WidgetProperties.enabled().observe(cloneUriValueText))
.notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_LOADING).observe(model))
.converting(new InvertingBooleanConverter())
.in(dbc);
@@ -204,6 +279,24 @@
return cloneGroup;
}
+ private SelectionListener onBrowseProjects() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ SelectExistingProjectDialog dialog =
+ new SelectExistingProjectDialog(model.getApplicationName(), getShell());
+ if (dialog.open() == Dialog.OK) {
+ Object selectedProject = dialog.getFirstResult();
+ if (selectedProject instanceof IProject) {
+ model.setProjectName(((IProject) selectedProject).getName());
+ }
+ }
+ }
+
+ };
+ }
+
private SelectionListener onDefaultRepoPath() {
return new SelectionAdapter() {
@@ -251,79 +344,77 @@
private Group createAdapterGroup(Composite parent, DataBindingContext dbc) {
Group serverAdapterGroup = new Group(parent, SWT.BORDER);
- serverAdapterGroup.setText("JBoss Server adapter");
- FillLayout fillLayout = new FillLayout();
- fillLayout.marginHeight = 6;
- fillLayout.marginWidth = 6;
- serverAdapterGroup.setLayout(fillLayout);
- fillServerAdapterGroup(serverAdapterGroup);
+ serverAdapterGroup.setText("Server Adapter");
+ GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(serverAdapterGroup);
- return serverAdapterGroup;
- }
-
- protected void enableServerWidgets(boolean enabled) {
- domainValueLabel.setEnabled(enabled);
- modeValueLabel.setEnabled(enabled);
- }
-
- private void fillServerAdapterGroup(Group serverAdapterGroup) {
Composite c = new Composite(serverAdapterGroup, SWT.NONE);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(c);
GridLayoutFactory.fillDefaults().numColumns(3).spacing(12, 8).applyTo(c);
serverAdapterCheckbox = new Button(c, SWT.CHECK);
- serverAdapterCheckbox.setText("Create a JBoss server adapter");
- serverAdapterCheckbox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
- serverAdapterCheckbox.getSelection());
- enableServerWidgets(serverAdapterCheckbox.getSelection());
- }
+ serverAdapterCheckbox.setText("Create OpenShift Server Adapter");
+ GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER)
+ .grab(true, false).applyTo(serverAdapterCheckbox);
+ serverAdapterCheckbox.addSelectionListener(onCreateAdapter());
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
Label domainLabel = new Label(c, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(domainLabel);
domainLabel.setText("Host");
domainValueLabel = new Label(c, SWT.NONE);
- DataBindingContext dbc = getDataBindingContext();
+ GridDataFactory.fillDefaults()
+ .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(domainValueLabel);
ValueBindingBuilder
.bind(WidgetProperties.text().observe(domainValueLabel))
.notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_APPLICATION_URL).observe(model))
.in(dbc);
- // appLabel = new Label(c, SWT.NONE);
+
Label modeLabel = new Label(c, SWT.NONE);
modeLabel.setText("Mode");
+ GridDataFactory.fillDefaults()
+ .align(SWT.LEFT, SWT.CENTER).applyTo(modeLabel);
modeValueLabel = new Label(c, SWT.NONE);
+ GridDataFactory.fillDefaults()
+ .span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(modeValueLabel);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(domainLabel);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(modeLabel);
- GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER)
- .grab(true, false).applyTo(domainValueLabel);
- GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER)
- .grab(true, false).applyTo(serverAdapterCheckbox);
- GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER)
- .grab(true, false).applyTo(modeValueLabel);
-
- model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
- serverAdapterCheckbox.getSelection());
+ model.getWizardModel().setProperty(
+ AdapterWizardPageModel.CREATE_SERVER, serverAdapterCheckbox.getSelection());
this.serverAdapterCheckboxObservable =
WidgetProperties.selection().observe(serverAdapterCheckbox);
- SelectedRuntimeValidator selectedRuntimeValidator = new SelectedRuntimeValidator();
- dbc.addValidationStatusProvider(selectedRuntimeValidator);
+ return serverAdapterGroup;
}
+ private SelectionListener onCreateAdapter() {
+ return new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ model.getWizardModel().setProperty(
+ AdapterWizardPageModel.CREATE_SERVER, serverAdapterCheckbox.getSelection());
+ enableServerWidgets(serverAdapterCheckbox.getSelection());
+ }
+ };
+ }
+
+ protected void enableServerWidgets(boolean enabled) {
+ domainValueLabel.setEnabled(enabled);
+ modeValueLabel.setEnabled(enabled);
+ }
+
private IServerType getServerTypeToCreate() {
return ServerCore.findServerType("org.jboss.tools.openshift.express.openshift.server.type");
}
protected void onPageActivated(DataBindingContext dbc) {
+ // allow to enable a proj only for as7 openshift applications
+ setTitle(NLS.bind("Import OpenShift application {0}", model.getApplicationName()));
+
+ newProjectCheckboxIsEnabled.setValue(model.isJBossAS7Application());
+
model.resetRepositoryPath();
serverTypeToCreate = getServerTypeToCreate();
- model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
+ model.getWizardModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
modeValueLabel.setText("Source");
- model.getParentModel().setProperty(AdapterWizardPageModel.MODE, AdapterWizardPageModel.MODE_SOURCE);
+ model.getWizardModel().setProperty(AdapterWizardPageModel.MODE, AdapterWizardPageModel.MODE_SOURCE);
onPageActivatedBackground(dbc);
}
@@ -334,7 +425,9 @@
model.loadGitUri();
model.loadApplicationUrl();
} catch (OpenShiftException e) {
- OpenShiftUIActivator.log(OpenShiftUIActivator.createErrorStatus(e.getMessage(), e));
+ IStatus status = OpenShiftUIActivator.createErrorStatus(e.getMessage(), e);
+ OpenShiftUIActivator.log(status);
+ return status;
}
return Status.OK_STATUS;
}
@@ -356,12 +449,25 @@
serverAdapterCheckbox.setEnabled(canCreateServer);
serverAdapterCheckboxObservable.setValue(canCreateServer);
enableServerWidgets(canCreateServer);
- model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
- model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER, canCreateServer);
+ model.getWizardModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
+ model.getWizardModel().setProperty(AdapterWizardPageModel.CREATE_SERVER, canCreateServer);
}
- private class SelectedRuntimeValidator extends MultiValidator {
+ /**
+ * A multi validator that validates the state of the project that shall be
+ * (OpenShift) enabled
+ */
+ private class NewProjectValidator extends MultiValidator {
+ private IObservableValue newProjectObservable;
+ private IObservableValue newProjectNameObservable;
+
+ public NewProjectValidator(IObservableValue newProjectObservable,
+ IObservableValue newProjectNameObservable) {
+ this.newProjectObservable = newProjectObservable;
+ this.newProjectNameObservable = newProjectNameObservable;
+ }
+
@Override
protected IStatus validate() {
/**
@@ -370,10 +476,73 @@
* is tracking what observables are read to know when he has to
* recalculate it's state.
*/
- if (Boolean.FALSE.equals(serverAdapterCheckboxObservable.getValue())) {
+ if (Boolean.TRUE.equals(newProjectObservable.getValue())) {
return ValidationStatus.ok();
}
- return ValidationStatus.ok();
+
+ if (newProjectNameObservable.getValue() != null
+ && (!((String) newProjectNameObservable.getValue()).isEmpty())) {
+ return ValidationStatus.ok();
+ } else {
+ return ValidationStatus.error(
+ "Select an existing project to use with OpenShift");
+ }
}
}
+
+ // private static class GitUriLabelProvider implements ILabelProvider {
+ //
+ // @Override
+ // public void addListener(ILabelProviderListener listener) {
+ // }
+ //
+ // @Override
+ // public void dispose() {
+ // }
+ //
+ // @Override
+ // public boolean isLabelProperty(Object element, String property) {
+ // return true;
+ // }
+ //
+ // @Override
+ // public void removeListener(ILabelProviderListener listener) {
+ // }
+ //
+ // @Override
+ // public Image getImage(Object element) {
+ // return null;
+ // }
+ //
+ // @Override
+ // public String getText(Object element) {
+ // if (!(element instanceof GitUri)) {
+ // return null;
+ // }
+ // return ((GitUri) element).getLabel();
+ // }
+ // }
+
+ // private class MergeUriValidator implements IValidator {
+ //
+ // @Override
+ // public IStatus validate(Object value) {
+ // String mergeUri = (String) value;
+ // if (mergeUri == null
+ // || mergeUri.length() == 0) {
+ // return ValidationStatus
+ // .warning("You have to provide a git uri to merge with");
+ // }
+ // GitUri gitUri = model.getKnownMergeUri(mergeUri);
+ // if (gitUri == null) {
+ // return ValidationStatus
+ // .warning("You are not merging with an official example. Things may go wrong");
+ // }
+ // if (!model.isCompatibleToApplicationCartridge(gitUri.getCartridge())) {
+ // return ValidationStatus
+ // .warning("The example you've chosen is not compatible to your application");
+ // }
+ // return ValidationStatus.ok();
+ // }
+ // }
}
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -10,10 +10,10 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.UIPreferences;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.egit.ui.util.EGitUIUtils;
import org.jboss.tools.openshift.express.client.IApplication;
+import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.OpenShiftException;
/**
@@ -24,7 +24,10 @@
private static final String REMOTE_NAME_DEFAULT = "origin";
- public static final String PROPERTY_GIT_URI = "gitUri";
+ public static final String PROPERTY_NEW_PROJECT = "newProject";
+ public static final String PROPERTY_CLONE_URI = "cloneUri";
+// public static final String PROPERTY_MERGE_URI = "mergeUri";
+ public static final String PROPERTY_PROJECT_NAME = "projectName";
public static final String PROPERTY_APPLICATION_URL = "applicationUrl";
public static final String PROPERTY_REPO_PATH = "repositoryPath";
public static final String PROPERTY_REMOTE_NAME = "remoteName";
@@ -43,20 +46,103 @@
public AdapterWizardPageModel(ImportProjectWizardModel wizardModel) {
this.wizardModel = wizardModel;
setRemoteName(REMOTE_NAME_DEFAULT);
+ setNewProject(true);
}
+ public void setNewProject(boolean newProject) {
+ firePropertyChange(PROPERTY_NEW_PROJECT, wizardModel.isNewProject(), wizardModel.setNewProject(newProject));
+ }
+
+ public boolean isNewProject() {
+ return wizardModel.isNewProject();
+ }
+
+ public void setProjectName(String projectName) {
+ firePropertyChange(PROPERTY_PROJECT_NAME, wizardModel.getProjectName(), wizardModel.setProjectName(projectName));
+ }
+
+ public String getProjectName() {
+ return wizardModel.getProjectName();
+ }
+
+// public void setMergeUri(String mergeUri) {
+// firePropertyChange(PROPERTY_MERGE_URI, wizardModel.getMergeUri(), wizardModel.setMergeUri(mergeUri));
+// }
+//
+// public String getMergeUri() {
+// return wizardModel.getMergeUri();
+// }
+
+// public GitUri getKnownMergeUri(String uriOrLabel) {
+// GitUri gitUri = null;
+// if (isGitUri(uriOrLabel)) {
+// gitUri = getKnownMergeUriByUri(uriOrLabel);
+// } else {
+// gitUri = getKnownMergeUriByLabel(uriOrLabel);
+// }
+// return gitUri;
+// }
+
+// private boolean isGitUri(String gitUriString) {
+// try {
+// URIish uriish = new URIish(gitUriString);
+// return uriish.isRemote();
+// } catch (URISyntaxException e) {
+// return false;
+// }
+// }
+
+// private GitUri getKnownMergeUriByUri(String gitUriString) {
+// GitUri matchingGitUri = null;
+// for (GitUri gitUri : getMergeUris()) {
+// if (gitUri.getGitUri().equals(gitUriString)) {
+// matchingGitUri = gitUri;
+// break;
+// }
+// }
+// return matchingGitUri;
+// }
+
+// private GitUri getKnownMergeUriByLabel(String label) {
+// GitUri matchingGitUri = null;
+// for (GitUri gitUri : getMergeUris()) {
+// if (gitUri.getLabel().equals(label)) {
+// matchingGitUri = gitUri;
+// break;
+// }
+// }
+// return matchingGitUri;
+// }
+
+// public List<GitUri> getMergeUris() {
+// ArrayList<GitUri> mergeUris = new ArrayList<GitUri>();
+// mergeUris.add(new GitUri(
+// "seambooking-example", "git://github.com/openshift/seambooking-example.git",
+// ICartridge.JBOSSAS_7));
+// mergeUris.add(new GitUri(
+// "tweetstream-example", "git://github.com/openshift/tweetstream-example.git",
+// ICartridge.JBOSSAS_7));
+// mergeUris.add(new GitUri(
+// "sinatra-example", "git://github.com/openshift/sinatra-example.git",
+// new Cartridge("rack-1.1")));
+// mergeUris.add(new GitUri(
+// "sugarcrm-example", "git://github.com/openshift/sugarcrm-example.git",
+// new Cartridge("php-5.3")));
+// return mergeUris;
+// }
+
public void loadGitUri() throws OpenShiftException {
setLoading(true);
- setGitUri("Loading...");
- setGitUri(getGitUri());
+ setCloneUri("Loading...");
+ setCloneUri(getCloneUri());
setLoading(false);
}
- private void setGitUri(String gitUri) {
- firePropertyChange(PROPERTY_GIT_URI, null, gitUri);
+ private void setCloneUri(String gitUri) {
+ firePropertyChange(PROPERTY_CLONE_URI, null, gitUri);
}
- public String getGitUri() throws OpenShiftException {
+ public String getCloneUri() throws OpenShiftException {
IApplication application = wizardModel.getApplication();
if (application == null) {
return null;
@@ -79,6 +165,22 @@
return application.getApplicationUrl();
}
+ public String getApplicationName() {
+ IApplication application = wizardModel.getApplication();
+ if (application == null) {
+ return null;
+ }
+ return application.getName();
+ }
+
+ public boolean isJBossAS7Application() {
+ IApplication application = wizardModel.getApplication();
+ if (application == null) {
+ return false;
+ }
+ return ICartridge.JBOSSAS_7.equals(application.getCartridge());
+ }
+
public void setApplicationUrl(String applicationUrl) {
firePropertyChange(PROPERTY_APPLICATION_URL, null, applicationUrl);
}
@@ -98,13 +200,9 @@
}
private String getDefaultRepositoryPath() {
- return getEGitDefaultRepositoryPath();
+ return EGitUIUtils.getEGitDefaultRepositoryPath();
}
- private String getEGitDefaultRepositoryPath() {
- return Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
- }
-
public String getRemoteName() {
return wizardModel.getRemoteName();
}
@@ -120,7 +218,7 @@
}
// TODO should this stay?
- public ImportProjectWizardModel getParentModel() {
+ public ImportProjectWizardModel getWizardModel() {
return wizardModel;
}
@@ -132,4 +230,43 @@
firePropertyChange(PROPERTY_LOADING, this.loading, this.loading = loading);
}
+ public boolean isCompatibleToApplicationCartridge(ICartridge cartridge) {
+ IApplication application = wizardModel.getApplication();
+ return application != null
+ && application.getCartridge() != null
+ && application.getCartridge().equals(cartridge);
+ }
+
+ public static class GitUri {
+
+ private String label;
+ private String gitUri;
+ private ICartridge cartridge;
+
+ private GitUri(String label, String gitUri, ICartridge cartridge) {
+ this.label = label;
+ this.gitUri = gitUri;
+ this.cartridge = cartridge;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getGitUri() {
+ return gitUri;
+ }
+
+ public String toString() {
+ return getLabel();
+ }
+
+ public ICartridge getCartridge() {
+ return cartridge;
+ }
+
+ public boolean isCompatible(ICartridge cartridge) {
+ return this.cartridge.equals(cartridge);
+ }
+ }
}
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -1,48 +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.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()]);
- }
-
-}
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -10,21 +10,24 @@
******************************************************************************/
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.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
+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.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.errors.TransportException;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.jboss.tools.common.ui.WizardUtils;
@@ -51,41 +54,61 @@
public boolean performFinish() {
try {
final ArrayBlockingQueue<IStatus> queue = new ArrayBlockingQueue<IStatus>(1);
- WizardUtils.runInWizard(new Job("Cloning local git repo...") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- File repositoryFile = model.cloneRepository(monitor);
- model.importProject(repositoryFile, monitor);
- } catch (OpenShiftException e) {
- status = OpenShiftUIActivator.createErrorStatus(
- "An exception occurred while creating local git repository.", e);
- } catch (URISyntaxException e) {
- status = OpenShiftUIActivator.createErrorStatus(
- "The url of the remote git repository is not valid", e);
- } catch (InvocationTargetException e) {
- if (isTransportException(e)) {
- TransportException te = getTransportException(e);
- status = OpenShiftUIActivator.createErrorStatus(
- "Could not clone the repository. Authentication failed.\n"
- + " Please make sure that you added your private key to the ssh preferences.", te);
- } else {
- status = OpenShiftUIActivator.createErrorStatus(
- "An exception occurred while creating local git repository.", e);
+ WizardUtils.runInWizard(
+ new WorkspaceJob("Importing project to workspace...") {
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ IStatus status = Status.OK_STATUS;
+ status = performOperations(monitor, status);
+ if (!status.isOK()) {
+ OpenShiftUIActivator.log(status);
+ }
+ queue.offer(status);
+ return status;
}
- } catch (Exception e) {
- status = OpenShiftUIActivator.createErrorStatus(
- "An exception occurred while creating local git repository.", e);
- }
- if (!status.isOK()) {
- OpenShiftUIActivator.log(status);
- }
- queue.offer(status);
- return status;
- }
- }, getContainer());
+ private IStatus performOperations(IProgressMonitor monitor, IStatus status) {
+ try {
+ if (model.isNewProject()) {
+ model.importProject(monitor);
+ } else {
+ if (!askForConfirmation(model.getApplicationName(), model.getProjectName())) {
+ return Status.CANCEL_STATUS;
+ }
+ model.addToExistingProject(monitor);
+ }
+ return Status.OK_STATUS;
+ } catch (IOException e) {
+ status = OpenShiftUIActivator.createErrorStatus(
+ "Could not copy openshift configuration files to project {0}", e,
+ model.getProjectName());
+ return status;
+ } catch (OpenShiftException e) {
+ status = OpenShiftUIActivator.createErrorStatus(
+ "Could not import project to the workspace.", e);
+ } catch (URISyntaxException e) {
+ status = OpenShiftUIActivator.createErrorStatus(
+ "The url of the remote git repository is not valid", e);
+ } catch (InvocationTargetException e) {
+ if (isTransportException(e)) {
+ TransportException te = getTransportException(e);
+ status = OpenShiftUIActivator
+ .createErrorStatus(
+ "Could not clone the repository. Authentication failed.\n"
+ + " Please make sure that you added your private key to the ssh preferences.",
+ te);
+ } else {
+ status = OpenShiftUIActivator.createErrorStatus(
+ "An exception occurred while creating local git repository.", e);
+ }
+ } catch (Exception e) {
+ status = OpenShiftUIActivator.createErrorStatus(
+ "Could int import project to the workspace.", e);
+ }
+ return status;
+ }
+ }, getContainer());
IStatus status = queue.poll(10, TimeUnit.SECONDS);
return status != null
&& status.isOK();
@@ -97,6 +120,22 @@
}
}
+ private boolean askForConfirmation(final String applicationName, final String projectName) {
+ final boolean[] confirmed = new boolean[1];
+ getShell().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ confirmed[0] = MessageDialog.openConfirm(getShell(),
+ NLS.bind("Import OpenShift Application ", applicationName),
+ NLS.bind(
+ "OpenShift application {0} will be enabled on project {1} by copying OpenShift " +
+ "configuration and enable Git for the project.\n " +
+ "This cannot be undone. Do you wish to continue ?", applicationName, projectName));
+ }});
+ return confirmed[0];
+ }
+
@Override
public void addPages() {
this.model = new ImportProjectWizardModel();
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -11,7 +11,9 @@
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.MalformedURLException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -21,7 +23,8 @@
import java.util.List;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -29,9 +32,9 @@
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.lib.Repository;
import org.eclipse.jgit.transport.JschConfigSessionFactory;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.osgi.util.NLS;
@@ -45,12 +48,15 @@
import org.eclipse.wst.server.core.internal.Server;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
+import org.jboss.tools.openshift.egit.core.GitIgnore;
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;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.common.FileUtils;
import org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.GeneralProjectImportOperation;
import org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.MavenProjectImportOperation;
@@ -63,15 +69,23 @@
private HashMap<String, Object> dataModel = new HashMap<String, Object>();
+ public static final String NEW_PROJECT = "enableProject";
public static final String USER = "user";
public static final String APPLICATION = "application";
public static final String REMOTE_NAME = "remoteName";
public static final String REPOSITORY_PATH = "repositoryPath";
+ public static final String PROJECT_NAME = "projectName";
+ public static final String MERGE_URI = "mergeUri";
- public void setProperty(String key, Object value) {
+ public ImportProjectWizardModel() {
+ dataModel.put(NEW_PROJECT, false);
+ }
+
+ public Object setProperty(String key, Object value) {
Object oldVal = dataModel.get(key);
dataModel.put(key, value);
firePropertyChange(key, oldVal, value);
+ return value;
}
public Object getProperty(String key) {
@@ -83,7 +97,7 @@
}
public IUser getUser() {
- return (IUser)getProperty(USER);
+ return (IUser) getProperty(USER);
}
public IApplication getApplication() {
@@ -116,7 +130,7 @@
}
return cartridgeName;
}
-
+
public void setApplication(IApplication application) {
setProperty(APPLICATION, application);
}
@@ -131,76 +145,219 @@
}
public String setRepositoryPath(String repositoryPath) {
- setProperty(REPOSITORY_PATH, repositoryPath);
- return repositoryPath;
+ return (String) setProperty(REPOSITORY_PATH, repositoryPath);
}
public String getRepositoryPath() {
return (String) getProperty(REPOSITORY_PATH);
}
- public void importProject(final File projectFolder, IProgressMonitor monitor) throws OpenShiftException,
- CoreException,
- InterruptedException {
- new WorkspaceJob(NLS.bind("Importing projects from {0}", projectFolder.getAbsolutePath())) {
+ public boolean isNewProject() {
+ return (Boolean) getProperty(NEW_PROJECT);
+ }
- @Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- try {
- List<IProject> importedProjects = importMavenProject(projectFolder, monitor);
- connectToGitRepo(importedProjects, projectFolder, monitor);
- createServerAdapterIfRequired(importedProjects, monitor);
- 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;
- }
- }
+ public Boolean setNewProject(boolean newProject) {
+ return (Boolean) setProperty(NEW_PROJECT, newProject);
+ }
- }.schedule();
+ public String setProjectName(String projectName) {
+ return (String) setProperty(PROJECT_NAME, projectName);
}
- private List<IProject> importMavenProject(final File projectFolder, IProgressMonitor monitor)
+ public String getProjectName() {
+ return (String) getProperty(PROJECT_NAME);
+ }
+
+ public String setMergeUri(String mergeUri) {
+ return (String) setProperty(MERGE_URI, mergeUri);
+ }
+
+ public String getMergeUri() {
+ return (String) getProperty(MERGE_URI);
+ }
+
+ /**
+ * Shares (git enables) the user provided project.
+ *
+ * @param monitor
+ * the monitor to report progress to.
+ * @return
+ * @throws CoreException
+ */
+ private void shareProject(IProgressMonitor monitor) throws CoreException {
+ monitor.subTask(NLS.bind("Sharing project {0}...", getProjectName()));
+ EGitUtils.share(getProject(), monitor);
+ }
+
+ private void copyOpenshiftConfiguration(final File sourceFolder, IProgressMonitor monitor)
+ throws IOException {
+ IProject project = getProject();
+ File projectFolder = project.getLocation().toFile();
+ monitor.subTask(NLS.bind("Copying openshift configuration to project {0}...", getProjectName()));
+ FileUtils.copy(new File(sourceFolder, ".git"), projectFolder, false);
+ FileUtils.copy(new File(sourceFolder, ".openshift"), projectFolder, false);
+ FileUtils.copy(new File(sourceFolder, "deployments"), projectFolder, false);
+ FileUtils.copy(new File(sourceFolder, "pom.xml"), projectFolder, false);
+ createGitIgnore(projectFolder);
+ }
+
+ /**
+ * Creates the git ignore file with a predefined set of entries. An existing
+ * .gitignore file is not overwritten, we then just dont do anything.
+ *
+ * @param projectFolder
+ * @throws IOException
+ */
+ private void createGitIgnore(File projectFolder) throws IOException {
+ GitIgnore gitIgnore = new GitIgnore(projectFolder);
+ // TODO: merge existing .gitignore
+ // (https://issues.jboss.org/browse/JBIDE-10391)
+ if (gitIgnore.exists()) {
+ return;
+ }
+ gitIgnore.add("target")
+ .add(".settings")
+ .add(".project")
+ .add(".classpath")
+ .add(".factorypath");
+ gitIgnore.write(false);
+ }
+
+ /**
+ * Returns the user provided project.
+ *
+ * @throws OpenShiftException
+ *
+ * @see #getProjectName
+ */
+ private IProject getProject() {
+ String projectName = getProjectName();
+ IProject project = getProject(projectName);
+ Assert.isTrue(project != null && project.exists(),
+ NLS.bind("Could not find project {0} in your workspace.", projectName));
+ return project;
+ }
+
+ public void importProject(IProgressMonitor monitor)
+ throws OpenShiftException, CoreException, InterruptedException, URISyntaxException,
+ InvocationTargetException {
+ File repositoryFolder = cloneRepository(monitor);
+ List<IProject> importedProjects = importMavenProject(repositoryFolder, monitor);
+ connectToGitRepo(importedProjects, repositoryFolder, monitor);
+ createServerAdapterIfRequired(importedProjects, monitor);
+ }
+
+ /**
+ * Enables the user chosen project to be used on the chosen OpenShift
+ * application. Clones the application git repository, copies the
+ * configuration files to the user project (in the workspace), shares the
+ * user project with git and creates the server adapter.
+ *
+ * @param monitor
+ * the monitor to report progress to
+ * @throws URISyntaxException
+ * The OpenShift application repository could not be cloned,
+ * because the uri it is located at is not a valid git uri
+ * @throws OpenShiftException
+ *
+ * @throws InvocationTargetException
+ * The OpenShift application repository could not be cloned, the
+ * clone operation failed.
+ * @throws InterruptedException
+ * The OpenShift application repository could not be cloned, the
+ * clone operation was interrupted.
+ * @throws IOException
+ * The configuration files could not be copied from the git
+ * clone to the user project
+ * @throws CoreException
+ * The user project could not be shared with the git
+ *
+ * @see #cloneRepository
+ * @see #copyOpenshiftConfiguration
+ * @see #shareProject
+ * @see #createServerAdapterIfRequired
+ */
+ public void addToExistingProject(IProgressMonitor monitor)
+ throws OpenShiftException, InvocationTargetException, InterruptedException, IOException, CoreException,
+ URISyntaxException {
+ // File repositoryFile =
+ // model.cloneRepository(monitor);
+ // model.importProject(repositoryFile, monitor);
+ // Repository repository =
+ // model.shareProject(monitor);
+ // model.mergeWithApplicationRepository(repository,
+ // monitor);
+ File repositoryFile = cloneRepository(monitor);
+ copyOpenshiftConfiguration(repositoryFile, monitor);
+ shareProject(monitor);
+ createServerAdapterIfRequired(monitor);
+ }
+
+ public void mergeWithApplicationRepository(Repository repository, IProgressMonitor monitor)
+ throws MalformedURLException, URISyntaxException, IOException, OpenShiftException, CoreException,
+ InvocationTargetException {
+ String uri = getApplication().getGitUri();
+ EGitUtils.addRemoteTo("openshift", new URIish(uri), repository);
+ EGitUtils.mergeWithRemote(new URIish(uri), "refs/remotes/openshift/HEAD", repository, monitor);
+ }
+
+ private IProject getProject(String projectName) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ }
+
+ public boolean projectExists(final File gitProjectFolder) {
+ String projectName = gitProjectFolder.getName();
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ return project.exists();
+ }
+
+ private List<IProject> importMavenProject(final File gitProjectFolder, IProgressMonitor monitor)
throws CoreException, InterruptedException {
- MavenProjectImportOperation mavenImport = new MavenProjectImportOperation(projectFolder);
+ MavenProjectImportOperation mavenImport = new MavenProjectImportOperation(gitProjectFolder);
List<IProject> importedProjects = Collections.emptyList();
if (mavenImport.isMavenProject()) {
importedProjects = mavenImport.importToWorkspace(monitor);
} else {
- importedProjects = new GeneralProjectImportOperation(projectFolder).importToWorkspace(monitor);
+ importedProjects = new GeneralProjectImportOperation(gitProjectFolder).importToWorkspace(monitor);
}
return importedProjects;
}
-
+
private void connectToGitRepo(List<IProject> projects, File projectFolder, IProgressMonitor monitor)
throws CoreException {
- File gitFolder = new File(projectFolder, Constants.DOT_GIT);
for (IProject project : projects) {
if (project != null) {
- connectToGitRepo(project, gitFolder, monitor);
+ EGitUtils.connect(project, monitor);
}
}
}
- private void connectToGitRepo(IProject project, File gitFolder, IProgressMonitor monitor) throws CoreException {
- new ConnectProviderOperation(project, gitFolder).execute(monitor);
- }
-
- public File cloneRepository(IProgressMonitor monitor) throws URISyntaxException, OpenShiftException,
- InvocationTargetException,
- InterruptedException {
+ /**
+ * Clones the repository of the selected OpenShift application to the user
+ * provided path
+ *
+ * @param monitor
+ * the monitor to report progress to
+ * @return
+ * @throws URISyntaxException
+ * @throws OpenShiftException
+ * @throws InvocationTargetException
+ * @throws InterruptedException
+ *
+ * @see ImportProjectWizardModel#getApplication()
+ * @see #getRepositoryPath()
+ */
+ private File cloneRepository(IProgressMonitor monitor)
+ throws OpenShiftException, InvocationTargetException, InterruptedException, URISyntaxException {
IApplication application = getApplication();
+ monitor.subTask(NLS.bind("Cloning repository for application {0}...", application.getName()));
File destination = new File(getRepositoryPath(), application.getName());
cloneRepository(application.getGitUri(), destination, monitor);
return destination;
}
- private void cloneRepository(String uri, File destination, IProgressMonitor monitor) throws URISyntaxException,
- OpenShiftException,
- InvocationTargetException,
- InterruptedException {
+ private void cloneRepository(String uri, File destination, IProgressMonitor monitor)
+ throws OpenShiftException, URISyntaxException, InvocationTargetException, InterruptedException {
if (destination.exists()) {
FileUtil.completeDelete(destination);
}
@@ -234,17 +391,30 @@
Activator.getDefault();
}
+ /**
+ * creates an OpenShift server adapter for the user chosen project.
+ *
+ * @param monitor
+ * the monitor to report progress to.
+ * @throws OpenShiftException
+ */
+ private void createServerAdapterIfRequired(IProgressMonitor monitor) throws OpenShiftException {
+ monitor.subTask(NLS.bind("Creating server adapter for project {0}", getProjectName()));
+ createServerAdapterIfRequired(Collections.singletonList(getProject()), monitor);
+ }
+
private void createServerAdapterIfRequired(List<IProject> importedProjects, IProgressMonitor monitor) {
- Boolean b = (Boolean)getProperty(AdapterWizardPageModel.CREATE_SERVER);
- if( b != null && b.booleanValue() ) {
+ Boolean b = (Boolean) getProperty(AdapterWizardPageModel.CREATE_SERVER);
+ if (b != null && b.booleanValue()) {
try {
renameWebContextRoot(importedProjects);
IServer server = createServerAdapter();
addModules(getModules(importedProjects), server, monitor);
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
OpenShiftUIActivator.getDefault().getLog().log(ce.getStatus());
- } catch(OpenShiftException ose) {
- IStatus s = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Cannot create openshift server adapter", ose);
+ } catch (OpenShiftException ose) {
+ IStatus s = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
+ "Cannot create openshift server adapter", ose);
OpenShiftUIActivator.getDefault().getLog().log(s);
}
}
@@ -262,16 +432,16 @@
private IServer createServerAdapter() throws CoreException,
OpenShiftException {
- IServerType type = (IServerType)getProperty(AdapterWizardPageModel.SERVER_TYPE);
- IRuntime rt = (IRuntime)getProperty(AdapterWizardPageModel.RUNTIME_DELEGATE);
- String mode = (String)getProperty(AdapterWizardPageModel.MODE);
+ IServerType type = (IServerType) getProperty(AdapterWizardPageModel.SERVER_TYPE);
+ IRuntime rt = (IRuntime) getProperty(AdapterWizardPageModel.RUNTIME_DELEGATE);
+ String mode = (String) getProperty(AdapterWizardPageModel.MODE);
String serverNameBase = getApplication().getName() + " OpenShift Server";
String serverName = org.jboss.ide.eclipse.as.core.util.ServerUtil.getDefaultServerName(serverNameBase);
-
+
IServer server = ExpressServerUtils.createServer(rt, type, serverName);
- ExpressServerUtils.fillServerWithOpenShiftDetails(server, getApplication().getApplicationUrl(),
- getUser().getRhlogin(), getUser().getPassword(),
+ ExpressServerUtils.fillServerWithOpenShiftDetails(server, getApplication().getApplicationUrl(),
+ getUser().getRhlogin(), getUser().getPassword(),
getUser().getDomain().getNamespace(), getApplication().getName(), getApplication().getUUID(), mode);
return server;
}
@@ -285,16 +455,16 @@
IModule[] add = modules.toArray(new IModule[modules.size()]);
wc.modifyModules(add, new IModule[0], new NullProgressMonitor());
server = wc.save(true, monitor);
- ((Server)server).setModulePublishState(add, IServer.PUBLISH_STATE_NONE);
+ ((Server) server).setModulePublishState(add, IServer.PUBLISH_STATE_NONE);
}
private List<IModule> getModules(List<IProject> importedProjects) {
Iterator<IProject> i = importedProjects.iterator();
ArrayList<IModule> toAdd = new ArrayList<IModule>();
- while(i.hasNext()) {
+ while (i.hasNext()) {
IProject p = i.next();
IModule[] m = ServerUtil.getModules(p);
- if( m != null && m.length > 0 ) {
+ if (m != null && m.length > 0) {
toAdd.addAll(Arrays.asList(m));
}
}
Added: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java (rev 0)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.ArrayList;
+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.jface.viewers.LabelProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.ide.IDE.SharedImages;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class SelectExistingProjectDialog extends ElementListSelectionDialog {
+
+ public SelectExistingProjectDialog(String openShiftAppName, Shell shell) {
+ super(shell, new ProjectLabelProvider());
+ setTitle("Select Existing Project");
+ setMessage(NLS.bind(
+ "Select an existing project for {0}.\nOnly java projects which are not Team shared can be used.",
+ openShiftAppName));
+ setMultipleSelection(false);
+ setAllowDuplicates(false);
+ setElements(getProjects());
+ }
+
+ private Object[] getProjects() {
+ List<IProject> projects = new ArrayList<IProject>();
+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ if (isValid(project)) {
+ projects.add(project);
+ }
+ }
+ return projects.toArray();
+ }
+
+ private boolean isValid(IProject project) {
+ if (EGitUtils.isShared(project)) {
+ return false;
+ }
+
+ if (EGitUtils.hasDotGitFolder(project)) {
+ return false;
+ }
+
+ if (!hasModuleNature(project)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean hasModuleNature(IProject project) {
+ try {
+ return project.hasNature(IModuleConstants.MODULE_NATURE_ID);
+ } catch(CoreException e) {
+ return false;
+ }
+ }
+
+ private static class ProjectLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (!(element instanceof IProject)) {
+ return null;
+ }
+
+ return ((IProject) element).getName();
+ }
+
+ }
+
+}
Property changes on: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java
===================================================================
--- branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java 2011-12-07 17:56:55 UTC (rev 37067)
+++ branches/jbosstools-3.3.0.M5/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java 2011-12-07 17:57:26 UTC (rev 37068)
@@ -20,8 +20,19 @@
private static final int HTTP_SCHEME_MAX_LENGTH = 8;
private static final char HTTP_SCHEME_START_CHAR = 'h';
- private static final Pattern HTTP_SCHEME_REGEX = Pattern.compile("http?://");
-
+ private static final Pattern HTTP_SCHEME_REGEX = Pattern.compile("http[s]{0,1}://");
+
+ /**
+ * Returns an url that was found in the given text. It starts looking
+ * backwards from the given offset within the given string. Returns
+ * <code>null</code> if none was found.
+ *
+ * @param offset
+ * starting point to look back in the given text.
+ * @param text
+ * the text to search for an url
+ * @return the url that was found in the text
+ */
public static String getUrl(int offset, String text) {
int start = getUrlStart(offset, text);
if (start == -1) {
@@ -34,11 +45,19 @@
return text.substring(start, stop);
}
-
+
+ /**
+ * Steps back in the given text until the beginning of the text or an
+ * occurrence of http(s):// is found.
+ *
+ * @param offset the offset to start with stepping backwards
+ * @param text the text to search
+ * @return the index at which http(s):// was found
+ */
private static int getUrlStart(int offset, String text) {
for (int i = offset; i > 0; --i) {
- if (text.charAt(i) == HTTP_SCHEME_START_CHAR
- && (i + HTTP_SCHEME_MAX_LENGTH < text.length())) {
+ if (text.charAt(i) == HTTP_SCHEME_START_CHAR
+ && (i + HTTP_SCHEME_MAX_LENGTH < text.length())) {
Matcher matcher = HTTP_SCHEME_REGEX.matcher(text.substring(i, i + HTTP_SCHEME_MAX_LENGTH));
if (matcher.find()) {
return i;
14 years
JBoss Tools SVN: r37067 - trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-12-07 12:56:55 -0500 (Wed, 07 Dec 2011)
New Revision: 37067
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
Log:
Commented out references to missing Utils class to fix compilation errors in Maven UI SWTBot tests
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java 2011-12-07 16:53:38 UTC (rev 37066)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenProjectsTest.java 2011-12-07 17:56:55 UTC (rev 37067)
@@ -43,7 +43,7 @@
createSimpleMavenProject(projectName, "jar");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- Utils.isMavenProject(projectName);
+ //Utils.isMavenProject(projectName);
buildProject(projectName,"5 Maven build...");
}
@@ -53,7 +53,7 @@
createSimpleMavenProject(projectName, "war");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- Utils.isMavenProject(projectName);
+ //Utils.isMavenProject(projectName);
buildProject(projectName,"5 Maven build...");
}
@@ -63,7 +63,7 @@
createSimpleMavenProjectArchetype(projectName,"maven-archetype-quickstart", "Nexus Indexer");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- Utils.isMavenProject(projectName);
+ //Utils.isMavenProject(projectName);
buildProject(projectName, "6 Maven build...");
}
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2011-12-07 16:53:38 UTC (rev 37066)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2011-12-07 17:56:55 UTC (rev 37067)
@@ -214,7 +214,7 @@
waitForIdle();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
assertNoErrors(project);
- Utils.isMavenProject(projectName);
+ //Utils.isMavenProject(projectName);
}
private void buildProject(String projectName) throws CoreException{
14 years
JBoss Tools SVN: r37066 - in trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim: ui and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-12-07 11:53:38 -0500 (Wed, 07 Dec 2011)
New Revision: 37066
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
Log:
https://issues.jboss.org/browse/JBIDE-10400: BrowserSim : the widow size issues
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg 2011-12-07 16:47:14 UTC (rev 37065)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg 2011-12-07 16:53:38 UTC (rev 37066)
@@ -1,5 +1,5 @@
-0
-PC (Default) -1 -1
+3
+Desktop (Default User-Agent) 1024 768
Apple iPad 2 768 1024 Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5
Apple iPhone 3 320 480 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
Apple iPhone 4 640 960 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2011-12-07 16:47:14 UTC (rev 37065)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2011-12-07 16:53:38 UTC (rev 37066)
@@ -424,7 +424,7 @@
private void setBrowserSize(int width, int height) {
GridData data = (GridData) browser.getLayoutData();
- Rectangle clientArea = display.getClientArea();
+ Rectangle clientArea = getMonitorClientArea();
int shellWidthHint = SWT.DEFAULT;
if (width != Device.DEFAULT_SIZE) {
data.widthHint = width;
@@ -463,6 +463,19 @@
shell.setBounds(shellBounds);
}
+
+ private Rectangle getMonitorClientArea() {
+ Rectangle clientArea = shell.getMonitor().getClientArea();
+
+ /* on Linux returned monitor client area may be bigger
+ * than the monitor bounds when multiple monitors are used.
+ * The following code fixes this */
+ Rectangle bounds = shell.getMonitor().getBounds();
+ clientArea.width = Math.min(clientArea.width, bounds.width);
+ clientArea.height = Math.min(clientArea.height, bounds.height);
+
+ return clientArea;
+ }
private void initOrientation(int orientation) {
browser.execute("window.onorientationchange = null;"
14 years
JBoss Tools SVN: r37065 - in trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: psrna
Date: 2011-12-07 11:47:14 -0500 (Wed, 07 Dec 2011)
New Revision: 37065
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
Log:
* added pom.xml
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF 2011-12-07 16:30:48 UTC (rev 37064)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF 2011-12-07 16:47:14 UTC (rev 37065)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: Portal Tests
Bundle-SymbolicName: org.jboss.tools.portlet.ui.bot.test;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.2.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-Vendor:
JBoss by Red Hat
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml 2011-12-07 16:47:14 UTC (rev 37065)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.portlet</groupId>
+ <artifactId>tests</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.portlet.tests</groupId>
+ <artifactId>org.jboss.tools.portlet.ui.bot.test</artifactId>
+
+ <packaging>eclipse-test-plugin</packaging>
+
+ <properties>
+ <jbosstools.test.jboss-gatein.home></jbosstools.test.jboss-gatein.home> <!--TODO setup default path -->
+ <configurations.dir></configurations.dir> <!-- TODO setup default path -->
+ <systemProperties>-Djbosstools.test.jboss-gatein.home=${jbosstools.test.jboss-gatein.home} -Dtest.configurations.dir=${configurations.dir}</systemProperties>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <configuration>
+ <useUIThread>false</useUIThread>
+ <testSuite>org.jboss.tools.portlet.ui.bot.test</testSuite>
+ <testClass>org.jboss.tools.portlet.ui.bot.test.AllTestsSuite</testClass>
+ <skip>${swtbot.test.skip}</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
14 years
JBoss Tools SVN: r37064 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test: beansxml and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-12-07 11:30:48 -0500 (Wed, 07 Dec 2011)
New Revision: 37064
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedComponentsSearchingTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedRefactoringTest.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
Log:
NamedComponentSearchingTest added
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -13,7 +13,8 @@
import org.jboss.tools.cdi.bot.test.beansxml.BeansXMLCompletionTest;
import org.jboss.tools.cdi.bot.test.beansxml.BeansXMLValidationTest;
import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
-import org.jboss.tools.cdi.bot.test.jsf.NamedRefactoringTest;
+import org.jboss.tools.cdi.bot.test.named.NamedComponentsSearchingTest;
+import org.jboss.tools.cdi.bot.test.named.NamedRefactoringTest;
import org.jboss.tools.cdi.bot.test.openon.FindObserverForEventTest;
import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
import org.jboss.tools.cdi.bot.test.quickfix.injection.ProblemEligibleInjectionTest;
@@ -64,7 +65,8 @@
FacetTest.class,
WizardTest.class,
BeansEditorTest.class,
- NamedRefactoringTest.class,
+ NamedRefactoringTest.class,
+ NamedComponentsSearchingTest.class,
BeansXMLValidationTest.class,
BeansXMLCompletionTest.class,
ProblemEligibleInjectionTest.class,
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -25,8 +25,7 @@
import org.junit.runners.Suite.SuiteClasses;
/**
- * Test operates on beans validation in config file
- * beans.xml
+ * Test operates on beans validation in beans.xml
*
* @author Jaroslav Jankovic
*
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -0,0 +1,35 @@
+package org.jboss.tools.cdi.bot.test.decorator;
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on creating new decorator
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+@Require(clearProjects = true, perspective = "Java EE",
+ server = @Server(state = ServerState.NotRunning,
+ version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class DecoratorCreatingTest extends CDITestBase {
+
+ //https://issues.jboss.org/browse/JBIDE-3136
+
+ @Override
+ public String getProjectName() {
+ return "CDIDecoratorCreating";
+ }
+
+
+
+}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -42,6 +42,7 @@
import org.xml.sax.SAXException;
/**
+ * Test checks if Bean Editor works properly
* prerequisite - CDIAtWizardTest!!!
*
*
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.cdi.bot.test.jsf;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.uiutils.CollectionsUtil;
-import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
-import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
-import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on @Named refactoring
- *
- * @author Jaroslav Jankovic
- *
- */
-@Require(clearProjects = true, perspective = "Java EE",
- server = @Server(state = ServerState.NotRunning,
- version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class NamedRefactoringTest extends JSFTestBase {
-
- private static final String MANAGED_BEAN_1 = "ManagedBean1";
- private static final String MANAGED_BEAN_2 = "ManagedBean2";
- private static final String INDEX_XHTML_1= "index1.xhtml";
- private static final String INDEX_XHTML_2= "index2.xhtml";
- private static final String INDEX_XHTML_3= "index3.xhtml";
- private static final String NEW_NAMED_PARAM = "bean2";
-
- @Override
- public String getProjectName() {
- return "CDIRefactoring";
- }
-
- @After
- public void waitForJobs() {
- editResourceUtil.deletePackage(getProjectName(), getPackageName());
- editResourceUtil.deleteWebFolder(getProjectName(), WEB_FOLDER);
- util.waitForNonIgnoredJobs();
- }
-
- @Test
- public void testNamedAnnotationWithParamRefactor() {
-
- wizard.createCDIComponentWithContent(CDIWizardType.BEAN, MANAGED_BEAN_1,
- getPackageName(), null, "/resources/jsf/ManagedBeanParamNamed.java.cdi");
-
- createXHTMLPageWithContent(INDEX_XHTML_1, "/resources/jsf/index1.xhtml.cdi");
- createXHTMLPageWithContent(INDEX_XHTML_3, "/resources/jsf/index3.xhtml.cdi");
-
- bot.editorByTitle(MANAGED_BEAN_1 + ".java").show();
- setEd(bot.activeEditor().toTextEditor());
-
- Collection<String> affectedFiles = changeNamedAnnotation(MANAGED_BEAN_1,
- NEW_NAMED_PARAM);
- Collection<String> expectedAffectedFiles = Arrays.asList(
- MANAGED_BEAN_1 + ".java", INDEX_XHTML_1, INDEX_XHTML_3);
-
- for (String affectedFile : affectedFiles) {
- bot.editorByTitle(affectedFile).save();
- }
-
- assertEquals(expectedAffectedFiles.size(), affectedFiles.size());
- assertTrue(CollectionsUtil.compareTwoCollectionsEquality(
- expectedAffectedFiles, affectedFiles));
-
- assertTrue(bot.editorByTitle(MANAGED_BEAN_1 + ".java").toTextEditor().getText().
- contains("@Named(\"" + NEW_NAMED_PARAM + "\""));
-
- assertTrue(bot.editorByTitle(INDEX_XHTML_1).toTextEditor().getText().
- contains("#{" + NEW_NAMED_PARAM));
-
- assertTrue(bot.editorByTitle(INDEX_XHTML_3).toTextEditor().getText().
- contains("#{" + NEW_NAMED_PARAM));
-
- }
-
- @Test
- public void testNamedAnnotationWithoutParamRefactor() {
-
- wizard.createCDIComponentWithContent(CDIWizardType.BEAN, MANAGED_BEAN_2,
- getPackageName(), null, "/resources/jsf/ManagedBeanNoParamNamed.java.cdi");
-
- createXHTMLPageWithContent(INDEX_XHTML_2, "/resources/jsf/index2.xhtml.cdi");
- createXHTMLPageWithContent(INDEX_XHTML_3, "/resources/jsf/index3.xhtml.cdi");
-
- bot.editorByTitle(MANAGED_BEAN_2 + ".java").show();
- setEd(bot.activeEditor().toTextEditor());
-
- Collection<String> affectedFiles = changeNamedAnnotation(MANAGED_BEAN_2, NEW_NAMED_PARAM);
- Collection<String> expectedAffectedFiles = Arrays.asList(
- MANAGED_BEAN_2 + ".java", INDEX_XHTML_2, INDEX_XHTML_3);
-
- for (String affectedFile : affectedFiles) {
- bot.editorByTitle(affectedFile).save();
- }
-
- assertEquals(expectedAffectedFiles.size(), affectedFiles.size());
- assertTrue(CollectionsUtil.compareTwoCollectionsEquality(
- expectedAffectedFiles, affectedFiles));
-
- assertTrue(bot.editorByTitle(MANAGED_BEAN_2 + ".java").toTextEditor().getText().
- contains("@Named(\"" + NEW_NAMED_PARAM + "\""));
-
- assertTrue(bot.editorByTitle(INDEX_XHTML_2).toTextEditor().getText().
- contains("#{" + NEW_NAMED_PARAM));
-
- assertTrue(bot.editorByTitle(INDEX_XHTML_3).toTextEditor().getText().
- contains("#{" + NEW_NAMED_PARAM));
-
- }
-
- @Test
- public void testNamedAnnotationWithoutELRefactoring() {
-
- wizard.createCDIComponentWithContent(CDIWizardType.BEAN, MANAGED_BEAN_2,
- getPackageName(), null, "/resources/jsf/ManagedBeanNoParamNamed.java.cdi");
-
- createXHTMLPageWithContent(INDEX_XHTML_2, "/resources/jsf/index1.xhtml.cdi");
-
- bot.editorByTitle(MANAGED_BEAN_2 + ".java").show();
- setEd(bot.activeEditor().toTextEditor());
-
- Collection<String> affectedFiles = changeNamedAnnotation(MANAGED_BEAN_2, NEW_NAMED_PARAM);
- Collection<String> expectedAffectedFiles = Arrays.asList(MANAGED_BEAN_2 + ".java");
-
- for (String affectedFile : affectedFiles) {
- bot.editorByTitle(affectedFile).save();
- }
-
- assertEquals(expectedAffectedFiles.size(), affectedFiles.size());
- assertTrue(CollectionsUtil.compareTwoCollectionsEquality(
- expectedAffectedFiles, affectedFiles));
-
- assertTrue(bot.editorByTitle(MANAGED_BEAN_2 + ".java").toTextEditor().getText().
- contains("@Named(\"" + NEW_NAMED_PARAM + "\""));
-
- assertTrue(!bot.editorByTitle(INDEX_XHTML_2).toTextEditor().getText().
- contains("#{" + NEW_NAMED_PARAM));
-
- }
-
-
-
-}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedComponentsSearchingTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedComponentsSearchingTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedComponentsSearchingTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.cdi.bot.test.named;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBaseExt;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.SearchNamedDialogWizard;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on @Named searching
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+@Require(clearProjects = true, perspective = "Java EE",
+ server = @Server(state = ServerState.NotRunning,
+ version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class NamedComponentsSearchingTest extends CDITestBase {
+
+ private final CDIWizardBaseExt wizardExt = new CDIWizardBaseExt();
+ private final String beanName = "Bean1";
+ private final String stereotypeName = "Stereotype1";
+ private static SearchNamedDialogWizard namedDialog = null;
+
+ @Override
+ public String getProjectName() {
+ return "CDINamedSearching";
+ }
+
+ @After
+ public void waitForJobs() {
+ editResourceUtil.deletePackage(getProjectName(), getPackageName());
+ util.waitForNonIgnoredJobs();
+ }
+
+ @Test
+ public void testSearchDefaultNamedBean() {
+
+ wizardExt.bean(getPackageName(), beanName, true, false, false,
+ false, false, false, "", null, null, null).finish();
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(beanName);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+
+ }
+
+ @Test
+ public void testSearchNamedParameterBean() {
+
+ String namedParam = "someBean";
+
+ wizardExt.bean(getPackageName(), beanName, true, false, false,
+ false, false, false, namedParam, null, null, null).finish();
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(namedParam);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+
+ }
+
+ @Test
+ public void testSearchNamedParameterChangeBean() {
+
+ String namedParam = "someBean";
+ String changedNamedParam = "someOtherBean";
+
+ wizardExt.bean(getPackageName(), beanName, true, false, false,
+ false, false, false, namedParam, null, null, null).finish();
+ setEd(bot.activeEditor().toTextEditor());
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(namedParam);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+
+ editResourceUtil.replaceInEditor(namedParam, changedNamedParam);
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(namedParam);
+ assertTrue(namedDialog.matchingItems().size() == 0);
+ namedDialog = namedDialog.setNamedPrefix(changedNamedParam);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+
+ }
+
+ @Test
+ public void testSearchTwoSameNamedBean() {
+
+ String beanName2 = "Bean2";
+ String namedParam = "someBean";
+
+ wizardExt.bean(getPackageName(), beanName, true, false, false,
+ false, false, false, namedParam, null, null, null).finish();
+ wizardExt.bean(getPackageName(), beanName2, true, false, false,
+ false, false, false, namedParam, null, null, null).finish();
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(namedParam);
+ List<String> matchingItems = namedDialog.matchingItems();
+ assertTrue(matchingItems.size() == 2);
+ for (String matchingItem : matchingItems) {
+ if (matchingItem.contains(beanName)) {
+ namedDialog.setMatchingItems(matchingItem);
+ break;
+ }
+ }
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+
+ }
+
+ @Test
+ public void testSearchBeansWithSamePrefixNamedParam() {
+
+ String[] beansNames = {"SomeBean", "SomeBean1", "SomeBean2", "SomeBean22", "SomeOtherBean"};
+
+ Map<String, Integer> prefixesWithCount = new LinkedHashMap<String, Integer>();
+ prefixesWithCount.put(beansNames[0], 4);
+ prefixesWithCount.put(beansNames[1], 1);
+ prefixesWithCount.put(beansNames[2], 2);
+ prefixesWithCount.put(beansNames[3], 1);
+ prefixesWithCount.put("Some", 5);
+
+ for (String beanName : beansNames) {
+ wizardExt.bean(getPackageName(), beanName, true, false, false,
+ false, false, false, "", null, null, null).finish();
+ }
+
+ for (String prefix : prefixesWithCount.keySet()) {
+ namedDialog = openSearchNamedDialog().setNamedPrefix(prefix);
+ assertTrue(namedDialog.matchingItems().size() == prefixesWithCount.get(prefix));
+ namedDialog.cancel();
+ }
+
+ }
+
+ @Test
+ public void testSearchBeanWithStereotype() {
+
+ wizardExt.stereotype(getPackageName(), stereotypeName, null, null, false, true,
+ false, false, false).finish();
+
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, beanName, getPackageName(),
+ null, "/resources/named/BeanWithStereotype.java.cdi");
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(beanName);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+
+ }
+
+ @Test
+ public void testSearchBeanWithStereotypeAndNamedParam() {
+
+ String namedParam = "someBean";
+
+ wizardExt.stereotype(getPackageName(), stereotypeName, null, null, false, true,
+ false, false, false).finish();
+
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, beanName, getPackageName(),
+ null, "/resources/named/BeanWithStereotypeAndNamed.java.cdi");
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(beanName);
+ assertTrue(namedDialog.matchingItems().size() == 0);
+ namedDialog = namedDialog.setNamedPrefix(namedParam);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+ }
+
+ @Test
+ public void testSearchBeanWithStereotypeWithNamedParamChange() {
+
+ String namedParam = "someBean";
+ String changedNamedParam = "someOtherBean";
+
+ wizardExt.stereotype(getPackageName(), stereotypeName, null, null, false, true,
+ false, false, false).finish();
+
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, beanName, getPackageName(),
+ null, "/resources/named/BeanWithStereotypeAndNamed.java.cdi");
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(beanName);
+ assertTrue(namedDialog.matchingItems().size() == 0);
+ namedDialog = namedDialog.setNamedPrefix(namedParam);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+
+ editResourceUtil.replaceInEditor(namedParam, changedNamedParam);
+
+ namedDialog = openSearchNamedDialog().setNamedPrefix(namedParam);
+ assertTrue(namedDialog.matchingItems().size() == 0);
+ namedDialog = namedDialog.setNamedPrefix(changedNamedParam);
+ assertTrue(namedDialog.matchingItems().size() == 1);
+ namedDialog.ok();
+ assertTrue(bot.activeEditor().getTitle().equals(beanName + ".java"));
+ assertTrue(bot.activeEditor().toTextEditor().getSelection().equals(beanName));
+ }
+
+ private SearchNamedDialogWizard openSearchNamedDialog() {
+ bot.menu("Navigate").menu("Open CDI Named Bean").click();
+ bot.sleep(Timing.time500MS());
+ return new SearchNamedDialogWizard();
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedRefactoringTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedRefactoringTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/named/NamedRefactoringTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.cdi.bot.test.named;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.jsf.JSFTestBase;
+import org.jboss.tools.cdi.bot.test.uiutils.CollectionsUtil;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on @Named refactoring
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+@Require(clearProjects = true, perspective = "Java EE",
+ server = @Server(state = ServerState.NotRunning,
+ version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class NamedRefactoringTest extends JSFTestBase {
+
+ private static final String MANAGED_BEAN_1 = "ManagedBean1";
+ private static final String MANAGED_BEAN_2 = "ManagedBean2";
+ private static final String INDEX_XHTML_1= "index1.xhtml";
+ private static final String INDEX_XHTML_2= "index2.xhtml";
+ private static final String INDEX_XHTML_3= "index3.xhtml";
+ private static final String NEW_NAMED_PARAM = "bean2";
+
+ @Override
+ public String getProjectName() {
+ return "CDIRefactoring";
+ }
+
+ @After
+ public void waitForJobs() {
+ editResourceUtil.deletePackage(getProjectName(), getPackageName());
+ editResourceUtil.deleteWebFolder(getProjectName(), WEB_FOLDER);
+ util.waitForNonIgnoredJobs();
+ }
+
+ @Test
+ public void testNamedAnnotationWithParamRefactor() {
+
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, MANAGED_BEAN_1,
+ getPackageName(), null, "/resources/jsf/ManagedBeanParamNamed.java.cdi");
+
+ createXHTMLPageWithContent(INDEX_XHTML_1, "/resources/jsf/index1.xhtml.cdi");
+ createXHTMLPageWithContent(INDEX_XHTML_3, "/resources/jsf/index3.xhtml.cdi");
+
+ bot.editorByTitle(MANAGED_BEAN_1 + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+ Collection<String> affectedFiles = changeNamedAnnotation(MANAGED_BEAN_1,
+ NEW_NAMED_PARAM);
+ Collection<String> expectedAffectedFiles = Arrays.asList(
+ MANAGED_BEAN_1 + ".java", INDEX_XHTML_1, INDEX_XHTML_3);
+
+ for (String affectedFile : affectedFiles) {
+ bot.editorByTitle(affectedFile).save();
+ }
+
+ assertEquals(expectedAffectedFiles.size(), affectedFiles.size());
+ assertTrue(CollectionsUtil.compareTwoCollectionsEquality(
+ expectedAffectedFiles, affectedFiles));
+
+ assertTrue(bot.editorByTitle(MANAGED_BEAN_1 + ".java").toTextEditor().getText().
+ contains("@Named(\"" + NEW_NAMED_PARAM + "\""));
+
+ assertTrue(bot.editorByTitle(INDEX_XHTML_1).toTextEditor().getText().
+ contains("#{" + NEW_NAMED_PARAM));
+
+ assertTrue(bot.editorByTitle(INDEX_XHTML_3).toTextEditor().getText().
+ contains("#{" + NEW_NAMED_PARAM));
+
+ }
+
+ @Test
+ public void testNamedAnnotationWithoutParamRefactor() {
+
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, MANAGED_BEAN_2,
+ getPackageName(), null, "/resources/jsf/ManagedBeanNoParamNamed.java.cdi");
+
+ createXHTMLPageWithContent(INDEX_XHTML_2, "/resources/jsf/index2.xhtml.cdi");
+ createXHTMLPageWithContent(INDEX_XHTML_3, "/resources/jsf/index3.xhtml.cdi");
+
+ bot.editorByTitle(MANAGED_BEAN_2 + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+ Collection<String> affectedFiles = changeNamedAnnotation(MANAGED_BEAN_2, NEW_NAMED_PARAM);
+ Collection<String> expectedAffectedFiles = Arrays.asList(
+ MANAGED_BEAN_2 + ".java", INDEX_XHTML_2, INDEX_XHTML_3);
+
+ for (String affectedFile : affectedFiles) {
+ bot.editorByTitle(affectedFile).save();
+ }
+
+ assertEquals(expectedAffectedFiles.size(), affectedFiles.size());
+ assertTrue(CollectionsUtil.compareTwoCollectionsEquality(
+ expectedAffectedFiles, affectedFiles));
+
+ assertTrue(bot.editorByTitle(MANAGED_BEAN_2 + ".java").toTextEditor().getText().
+ contains("@Named(\"" + NEW_NAMED_PARAM + "\""));
+
+ assertTrue(bot.editorByTitle(INDEX_XHTML_2).toTextEditor().getText().
+ contains("#{" + NEW_NAMED_PARAM));
+
+ assertTrue(bot.editorByTitle(INDEX_XHTML_3).toTextEditor().getText().
+ contains("#{" + NEW_NAMED_PARAM));
+
+ }
+
+ @Test
+ public void testNamedAnnotationWithoutELRefactoring() {
+
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, MANAGED_BEAN_2,
+ getPackageName(), null, "/resources/jsf/ManagedBeanNoParamNamed.java.cdi");
+
+ createXHTMLPageWithContent(INDEX_XHTML_2, "/resources/jsf/index1.xhtml.cdi");
+
+ bot.editorByTitle(MANAGED_BEAN_2 + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+ Collection<String> affectedFiles = changeNamedAnnotation(MANAGED_BEAN_2, NEW_NAMED_PARAM);
+ Collection<String> expectedAffectedFiles = Arrays.asList(MANAGED_BEAN_2 + ".java");
+
+ for (String affectedFile : affectedFiles) {
+ bot.editorByTitle(affectedFile).save();
+ }
+
+ assertEquals(expectedAffectedFiles.size(), affectedFiles.size());
+ assertTrue(CollectionsUtil.compareTwoCollectionsEquality(
+ expectedAffectedFiles, affectedFiles));
+
+ assertTrue(bot.editorByTitle(MANAGED_BEAN_2 + ".java").toTextEditor().getText().
+ contains("@Named(\"" + NEW_NAMED_PARAM + "\""));
+
+ assertTrue(!bot.editorByTitle(INDEX_XHTML_2).toTextEditor().getText().
+ contains("#{" + NEW_NAMED_PARAM));
+
+ }
+
+
+
+}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -23,6 +23,13 @@
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
+/**
+ * Test checks if Quick Fix provides useful operations when
+ * ambiguous injection points
+ * @author jjankovi
+ *
+ */
+
@Require(clearProjects = true, perspective = "Java EE",
server = @Server(state = ServerState.NotRunning,
version = "6.0", operator = ">="))
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -39,6 +39,6 @@
return m;
}
});
- }
+ }
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -47,7 +47,9 @@
public List<String> matchingItems() {
int tableItemsCount = bot().table(0).rowCount();
for (int i = 0; i < tableItemsCount; i++) {
- matchingItems.add(bot().table(0).getTableItem(i).getText());
+ String itemInTable = bot().table(0).getTableItem(i).getText();
+ if (itemInTable.contains("Workspace matches")) continue;
+ matchingItems.add(itemInTable);
}
return matchingItems;
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java 2011-12-07 15:46:43 UTC (rev 37063)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java 2011-12-07 16:30:48 UTC (rev 37064)
@@ -32,6 +32,8 @@
import org.junit.runners.Suite.SuiteClasses;
/**
+ * Test checks all CDI components Wizards
+ *
* @author Lukas Jungmann
* @author jjankovi
*/
14 years
JBoss Tools SVN: r37062 - trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-12-07 10:27:05 -0500 (Wed, 07 Dec 2011)
New Revision: 37062
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java
Log:
new SearchNamedDialogWizard added
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/SearchNamedDialogWizard.java 2011-12-07 15:27:05 UTC (rev 37062)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.cdi.bot.test.uiutils.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class SearchNamedDialogWizard extends Wizard {
+
+ private static final String NAMED_SEARCH_TITLE = "Open CDI Named Bean";
+ private List<String> matchingItems = null;
+
+ public SearchNamedDialogWizard() {
+ super(new SWTBot().activeShell().widget);
+ assert (NAMED_SEARCH_TITLE).equals(getText());
+ matchingItems = new ArrayList<String>();
+ }
+
+ public SearchNamedDialogWizard setNamedPrefix(String prefix) {
+ bot().text().setText(prefix);
+ bot().sleep(Timing.time2S());
+ return this;
+ }
+
+ public void ok() {
+ clickButton("OK");
+ bot().sleep(Timing.time1S());
+ }
+
+ public SearchNamedDialogWizard setMatchingItems(String... items) {
+ bot().table(0).select(items);
+ return this;
+ }
+
+ public List<String> matchingItems() {
+ int tableItemsCount = bot().table(0).rowCount();
+ for (int i = 0; i < tableItemsCount; i++) {
+ matchingItems.add(bot().table(0).getTableItem(i).getText());
+ }
+ return matchingItems;
+ }
+
+}
14 years
JBoss Tools SVN: r37061 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources: named and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-12-07 10:26:31 -0500 (Wed, 07 Dec 2011)
New Revision: 37061
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotype.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotypeAndNamed.java.cdi
Log:
Resource files for NamedComponentsSearchingTest
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotype.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotype.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotype.java.cdi 2011-12-07 15:26:31 UTC (rev 37061)
@@ -0,0 +1,10 @@
+package cdi;
+
+@Stereotype1
+public class Bean1 {
+
+ public Bean1() {
+ // TODO Auto-generated constructor stub
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotypeAndNamed.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotypeAndNamed.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/named/BeanWithStereotypeAndNamed.java.cdi 2011-12-07 15:26:31 UTC (rev 37061)
@@ -0,0 +1,13 @@
+package cdi;
+
+import javax.inject.Named;
+
+@Stereotype1
+@Named("someBean")
+public class Bean1 {
+
+ public Bean1() {
+ // TODO Auto-generated constructor stub
+ }
+
+}
\ No newline at end of file
14 years