JBoss Tools SVN: r40150 - in trunk: examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2012-04-12 04:42:07 -0400 (Thu, 12 Apr 2012)
New Revision: 40150
Added:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/DependencyKey.java
Removed:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenProjectConstants.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java
Log:
JBIDE-11242: Users should be warned when WFK maven repo is missing
https://issues.jboss.org/browse/JBIDE-11242
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExample.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -50,6 +50,7 @@
private String defaultProfiles = ""; //$NON-NLS-1$
private int priority;
private Set<String> tags;
+ private Set<String> essentialEnterpriseDependencies;
private String iconPath;
public ProjectExample() {
@@ -334,4 +335,13 @@
}
return -1;
}
+
+ public void setEssentialEnterpriseDependencyGavs(Set<String> gavs) {
+ essentialEnterpriseDependencies = gavs;
+ }
+
+
+ public Set<String> getEssentialEnterpriseDependencyGavs() {
+ return essentialEnterpriseDependencies;
+ }
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectExampleUtil.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -391,6 +391,8 @@
if (path != null) {
project.setIconPath(path);
}
+ } else if (nodeName.equals("essentialEnterpriseDependencies")) {
+ parseEssentialEnterpriseDependencies(project, child);
}
}
}
@@ -405,6 +407,24 @@
return list;
}
+ private static void parseEssentialEnterpriseDependencies(
+ ProjectExample project, Element enterpriseDependenciesElement) {
+
+ String tagsValue = enterpriseDependenciesElement.getTextContent();
+ if (tagsValue != null) {
+ StringTokenizer tokenizer = new StringTokenizer(tagsValue.trim(),",");//$NON-NLS-1$
+ Set<String> gavs = new HashSet<String>();
+ while (tokenizer.hasMoreTokens()) {
+ String gav = tokenizer.nextToken().trim();
+ if (gav.length() > 0) {
+ gavs.add(gav);
+ }
+ }
+ project.setEssentialEnterpriseDependencyGavs(gavs);
+ }
+
+ }
+
public static Set<URL> getCategoryURLs() {
if (categoryUrls == null) {
categoryUrls = new HashSet<URL>();
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard2.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -109,8 +109,8 @@
} else {
// FIXME
}
+ String type = projectExample.getImportType();
for (IProjectExamplesWizardPage contributedPage:contributedPages) {
- String type = projectExample.getImportType();
if (type == null || !type.equals(contributedPage.getProjectExampleType())) {
continue;
}
@@ -171,18 +171,14 @@
Set<String> keySet = extensionPages.keySet();
for (String key:keySet) {
List<ContributedPage> contributions = extensionPages.get(key);
+ boolean canSetProjectExample = isCentral && projectExample != null && key.equals(projectExample.getImportType());
for(ContributedPage page:contributions) {
try {
- if (!isCentral) {
- IProjectExamplesWizardPage contributedPage = (IProjectExamplesWizardPage) page.getConfigurationElement().createExecutableExtension(ProjectExamplesActivator.CLASS);
- contributedPages.add(contributedPage);
- } else {
- if (projectExample != null && key.equals(projectExample.getImportType())) {
- IProjectExamplesWizardPage contributedPage = (IProjectExamplesWizardPage) page.getConfigurationElement().createExecutableExtension(ProjectExamplesActivator.CLASS);
- contributedPage.setProjectExample(projectExample);
- contributedPages.add(contributedPage);
- }
+ IProjectExamplesWizardPage contributedPage = (IProjectExamplesWizardPage) page.getConfigurationElement().createExecutableExtension(ProjectExamplesActivator.CLASS);
+ if (canSetProjectExample) {
+ contributedPage.setProjectExample(projectExample);
}
+ contributedPages.add(contributedPage);
} catch (CoreException e) {
ProjectExamplesActivator.log(e);
}
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/WizardContext.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -43,8 +43,8 @@
}
}
- public void getProperty(String key) {
- context.get(key);
+ public Object getProperty(String key) {
+ return context.get(key);
}
private void fireChangeEvent(String key, Object value) {
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenArchetypeProjectExampleDelegate.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -60,10 +60,9 @@
includedProjects.add(projectName);
String artifactId = (String) propertiesMap.get(ProjectExamplesActivator.PROPERTY_ARTIFACT_ID);
IPath location = (IPath) propertiesMap.get(ProjectExamplesActivator.PROPERTY_LOCATION_PATH);
- String projectFolder = location.append(artifactId).toFile()
- .getAbsolutePath();
- MavenModelManager mavenModelManager = MavenPlugin
- .getMavenModelManager();
+ String projectFolder = location.append(artifactId).toFile().getAbsolutePath();
+ MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager();
+
LocalProjectScanner scanner = new LocalProjectScanner(location.toFile(),
projectFolder, true, mavenModelManager);
try {
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/Messages.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -12,6 +12,7 @@
public static String ArchetypeExamplesWizardFirstPage_Target_Runtime_Label;
public static String ArchetypeExamplesWizardFirstPage_Title;
public static String ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo;
+ public static String ArchetypeExamplesWizardFirstPage_Unresolved_WFK_Repo;
public static String ArchetypeExamplesWizardFirstPage_Error_Package;
static {
// initialize resource bundle
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/messages.properties 2012-04-12 08:42:07 UTC (rev 40150)
@@ -1,9 +1,10 @@
-ArchetypeExamplesWizardFirstPage_Existing_Project=Project already exists
+ArchetypeExamplesWizardFirstPage_Existing_Project=Invalid project name: Project "{0}" already exists.
ArchetypeExamplesWizardFirstPage_No_TargetRuntime=<none>
ArchetypeExamplesWizardFirstPage_Package_Label=Package
ArchetypeExamplesWizardFirstPage_ProjectName_Cant_Be_Empty=The project name can not be empty
ArchetypeExamplesWizardFirstPage_ProjectName_Label=Project name
ArchetypeExamplesWizardFirstPage_Target_Runtime_Label=Target Runtime
ArchetypeExamplesWizardFirstPage_Title=Create a new Java EE project
-ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo={0} cannot be found.\n This indicates you do not have access to a JBoss Enterprise Maven repository.\n This can cause build problems. Follow this <a href\="http\://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories">link</a> for more details.
+ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo={0} cannot be found. This indicates you do not have access to a JBoss Enterprise Maven repository.\nThis can cause build problems. Follow this <a href\="http\://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories">link</a> for more details.
+ArchetypeExamplesWizardFirstPage_Unresolved_WFK_Repo=The enterprise version of this project has a dependency on {0} which cannot be found. This indicates you do not have access to a JBoss WFK Maven repository or that repository is incomplete.\nThis can cause build problems. Follow this <a href\="http\://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories">link</a> for more details.
ArchetypeExamplesWizardFirstPage_Error_Package=Invalid package name
\ No newline at end of file
Copied: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java (from rev 40076, trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java)
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/utils/MavenArtifactHelper.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -0,0 +1,94 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.project.examples.utils;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
+import org.jboss.tools.maven.project.examples.Messages;
+import org.jboss.tools.maven.project.examples.xpl.DependencyKey;
+import org.jboss.tools.project.examples.model.ProjectExample;
+
+public class MavenArtifactHelper {
+
+ private static final DependencyKey ENTERPRISE_JBOSS_SPEC = DependencyKey.fromPortableString("org.jboss.spec:jboss-javaee-web-6.0:pom:3.0.0.Beta1-redhat-1::"); //$NON-NLS-1$
+
+ /**
+ * Checks if the EAP repository is available
+ *
+ * @return true if org.jboss.spec:jboss-javaee-web-6.0:pom:3.0.0.Beta1-redhat-1 can be resolved
+ */
+ public static boolean isEnterpriseRepositoryAvailable() {
+ boolean isRepoAvailable = isArtifactAvailable(ENTERPRISE_JBOSS_SPEC); //$NON-NLS-1$
+ return isRepoAvailable;
+ }
+
+ /**
+ * Checks if an artifact can be resolved
+ * @param dependencyKey
+ * @return true is the dependencyKey can be resolved to an artifact.
+ */
+ public static boolean isArtifactAvailable(String dependencyKey) {
+ DependencyKey key = DependencyKey.fromPortableString(dependencyKey);
+ return isArtifactAvailable(key);
+ }
+
+ public static boolean isArtifactAvailable(DependencyKey key) {
+ boolean isRepoAvailable = false;
+ try {
+ IMaven maven = MavenPlugin.getMaven();
+ ArrayList<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
+ repos.addAll(maven.getArtifactRepositories());
+ IProgressMonitor nullProgressMonitor = new NullProgressMonitor();
+ Artifact a = MavenPlugin.getMaven().resolve(
+ key.getGroupId(), key.getArtifactId(), key.getVersion(),
+ key.getType(), key.getClassifier(), repos, nullProgressMonitor);
+ isRepoAvailable = a != null && a.isResolved();
+ } catch (CoreException e) {
+ System.err.println(e.getLocalizedMessage());
+ }
+ return isRepoAvailable;
+ }
+
+
+ public static IStatus checkEnterpriseRequirementsAvailable(ProjectExample project) {
+ if (!isEnterpriseRepositoryAvailable()) {
+ return new Status(IStatus.ERROR,
+ MavenProjectExamplesActivator.PLUGIN_ID,
+ NLS.bind(Messages.ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo, ENTERPRISE_JBOSS_SPEC));
+ }
+ if (project != null) {
+ Set<String> requirements = project.getEssentialEnterpriseDependencyGavs();
+ if (requirements != null) {
+ for (String gav : requirements) {
+ DependencyKey key = DependencyKey.fromPortableString(gav);
+ if (!isArtifactAvailable(key)) {
+ return new Status(IStatus.ERROR,
+ MavenProjectExamplesActivator.PLUGIN_ID,
+ NLS.bind(Messages.ArchetypeExamplesWizardFirstPage_Unresolved_WFK_Repo, key));
+ }
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -11,7 +11,6 @@
package org.jboss.tools.maven.project.examples.wizard;
import java.lang.reflect.Field;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -20,6 +19,7 @@
import java.util.Set;
import java.util.regex.Pattern;
+import org.apache.maven.model.Model;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -27,10 +27,6 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
@@ -40,8 +36,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
@@ -51,7 +45,6 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
@@ -62,6 +55,7 @@
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
import org.jboss.tools.maven.project.examples.Messages;
+import org.jboss.tools.maven.project.examples.utils.MavenArtifactHelper;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.ProjectExample;
import org.jboss.tools.project.examples.wizard.IProjectExamplesWizardPage;
@@ -76,21 +70,22 @@
*/
public class ArchetypeExamplesWizardFirstPage extends MavenProjectWizardLocationPage implements IProjectExamplesWizardPage {
- private static final String TARGET_RUNTIME = "targetRuntime";
+ private static final String TARGET_RUNTIME = "targetRuntime"; //$NON-NLS-1$
private Label projectNameLabel;
private Combo projectNameCombo;
private Label packageLabel;
private Combo packageCombo;
private Combo serverTargetCombo;
private Map<String, IRuntime> serverRuntimes;
- private Composite warningLink;
+ private MissingRepositoryWarningComponent warningComponent;
private boolean initialized;
- private Boolean isEnterpriseRepoAvailable;
+ private IStatus enterpriseRepoStatus;
private ProjectExample projectDescription;
private ProjectExample projectExample;
private WizardContext context;
private IRuntimeLifecycleListener listener;
+ private Link warninglink;
public ArchetypeExamplesWizardFirstPage() {
super(new ProjectImportConfiguration(), "", "",new ArrayList<IWorkingSet>());
@@ -183,7 +178,7 @@
@Override
protected void createAdvancedSettings(Composite composite, GridData gridData) {
- createMissingRepositoriesWarning(composite, gridData);
+ warningComponent = new MissingRepositoryWarningComponent(composite, false);
}
protected void createServerTargetComposite(Composite parent) {
@@ -249,7 +244,7 @@
}
//Need to be called first, or error message would be overwritten
super.validate();
-
+
String errorMessage = validateInputs();
setErrorMessage(errorMessage);
setMessage(null);
@@ -269,16 +264,18 @@
return Messages.ArchetypeExamplesWizardFirstPage_ProjectName_Cant_Be_Empty;
}
+ final String resolvedName = getImportConfiguration().getProjectName(getModel());
+
// check whether the project name is valid
- final IStatus nameStatus = workspace.validateName(name, IResource.PROJECT);
+ final IStatus nameStatus = workspace.validateName(resolvedName, IResource.PROJECT);
if(!nameStatus.isOK()) {
return nameStatus.getMessage();
}
// check whether project already exists
- final IProject handle = workspace.getRoot().getProject(name);
+ final IProject handle = workspace.getRoot().getProject(resolvedName);
if(handle.exists()) {
- return Messages.ArchetypeExamplesWizardFirstPage_Existing_Project;
+ return NLS.bind(Messages.ArchetypeExamplesWizardFirstPage_Existing_Project, resolvedName);
}
//check if the package is valid
@@ -297,10 +294,20 @@
}
protected void validateEnterpriseRepo() {
-
- boolean isWarningLinkVisible = (isEnterpriseTargetRuntime() && !assertEnterpriseRepoAccessible());
- if (warningLink != null) {
- warningLink.setVisible(isWarningLinkVisible);
+ if (warningComponent != null) {
+ boolean isWarningLinkVisible = false;
+ if (isEnterpriseTargetRuntime()) {
+ if (enterpriseRepoStatus == null) {
+ enterpriseRepoStatus = MavenArtifactHelper.checkEnterpriseRequirementsAvailable(projectExample);
+ }
+ isWarningLinkVisible = !enterpriseRepoStatus.isOK();
+ if (isWarningLinkVisible) {
+ warningComponent.setLinkText(enterpriseRepoStatus.getMessage());
+ //warninglink.setText(enterpriseRepoStatus.getMessage());
+ //warningComponent.getParent().layout(true, true);
+ }
+ }
+ warningComponent.setVisible(isWarningLinkVisible);
}
}
@@ -353,48 +360,6 @@
validate();
}
- private void createMissingRepositoriesWarning(Composite parent,
- GridData gridData) {
- //TODO make that damn component align correctly
- //warningLink = new MissingRepositoryWarningComponent(parent);
-
- //TODO delete that code
- warningLink = new Composite(parent, SWT.NONE);
-
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1)
- .applyTo(warningLink);
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(warningLink);
-
- Label warningImg = new Label(warningLink, SWT.CENTER | SWT.TOP);
- warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
-
- Link link = new Link(warningLink, SWT.NONE);
- link.setText(NLS.bind(Messages.ArchetypeExamplesWizardFirstPage_Unresolved_Enterprise_Repo, MavenArtifactHelper.ENTERPRISE_JBOSS_SPEC));
- link.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- // Open default external browser
- PlatformUI.getWorkbench().getBrowserSupport()
- .getExternalBrowser().openURL(new URL(e.text));
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- });
-
- warningLink.setVisible(false);
- }
-
-
-
- private boolean assertEnterpriseRepoAccessible() {
- if (isEnterpriseRepoAvailable == null) {
- isEnterpriseRepoAvailable = MavenArtifactHelper.isEnterpriseRepositoryAvailable();
- }
- return isEnterpriseRepoAvailable.booleanValue();
- }
-
protected Map<String, IRuntime> getServerRuntimes(
IProjectFacetVersion facetVersion) {
Set<org.eclipse.wst.common.project.facet.core.runtime.IRuntime> runtimesSet;
@@ -468,13 +433,6 @@
if (projectExample.getDescription() != null) {
setDescription(ProjectExamplesActivator.getShortDescription(projectExample.getDescription()));
}
- ProjectImportConfiguration configuration = getImportConfiguration();
- if (configuration != null) {
- String profiles = projectExample.getDefaultProfiles();
- if (profiles != null && profiles.trim().length() > 0) {
- configuration.getResolverConfiguration().setActiveProfiles(profiles);
- }
- }
initDefaultValues();
}
}
@@ -545,5 +503,14 @@
this.context = context;
}
+ @Override
+ public ProjectImportConfiguration getImportConfiguration() {
+ ProjectImportConfiguration importConfiguration = (ProjectImportConfiguration) context.getProperty(MavenProjectConstants.IMPORT_PROJECT_CONFIGURATION);
+ return importConfiguration;
+ }
+ private Model getModel() {
+ return (Model) context.getProperty(MavenProjectConstants.MAVEN_MODEL);
+ }
+
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -11,7 +11,6 @@
package org.jboss.tools.maven.project.examples.wizard;
import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -34,14 +33,11 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
@@ -50,18 +46,13 @@
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.PlatformUI;
import org.jboss.tools.maven.project.examples.MavenProjectExamplesActivator;
+import org.jboss.tools.maven.project.examples.utils.MavenArtifactHelper;
import org.jboss.tools.maven.project.examples.wizard.xpl.MavenProjectWizardArchetypeParametersPage;
import org.jboss.tools.maven.ui.Activator;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
@@ -79,24 +70,17 @@
MavenProjectWizardArchetypeParametersPage implements IProjectExamplesWizardPage {
private ProjectExample projectDescription;
- private Composite warningLink;
- private Boolean isEnterpriseRepoAvailable;
private ProjectExample projectExample;
private boolean initialized = false;
private Map<String, Object> propertiesMap = new HashMap<String, Object>();
private WizardContext context;
+ private MissingRepositoryWarningComponent warningComponent;
+ private IStatus enterpriseRepoStatus;
public ArchetypeExamplesWizardPage() {
super(new ProjectImportConfiguration());
}
- public ArchetypeExamplesWizardPage(
- ProjectImportConfiguration configuration, ProjectExample projectDescription) {
- super(configuration);
- setTitle(projectDescription.getShortDescription());
- this.projectDescription = projectDescription;
- }
-
@Override
public void createControl(Composite parent) {
super.createControl(parent);
@@ -165,46 +149,9 @@
protected void createAdvancedSettings(Composite composite, GridData gridData) {
// TODO Auto-generated method stub
super.createAdvancedSettings(composite, gridData);
- createMissingRepositoriesWarning(composite, gridData);
+ warningComponent = new MissingRepositoryWarningComponent(composite, false);
}
- private void createMissingRepositoriesWarning(Composite parent,
- GridData gridData) {
- //TODO make that damn component align correctly
- //warningLink = new MissingRepositoryWarningComponent(parent);
-
- //TODO delete that code
- warningLink = new Composite(parent, SWT.NONE);
-
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1)
- .applyTo(warningLink);
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(warningLink);
-
- Label warningImg = new Label(warningLink, SWT.CENTER | SWT.TOP);
- warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
-
- Link link = new Link(warningLink, SWT.NONE);
- String message = "Artifacts needed from JBoss Enterprise Maven repository do not seem to be available.\nThis might cause build problems. "
- + "Follow this <a href=\"http://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories\">link</a> for more details.";
- link.setText(message);
- link.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- // Open default external browser
- PlatformUI.getWorkbench().getBrowserSupport()
- .getExternalBrowser().openURL(new URL(e.text));
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- });
-
- warningLink.setVisible(false);
- }
-
-
-
public Archetype getArchetype() {
return archetype;
}
@@ -332,7 +279,7 @@
}
private void checkEnterpriseProperty() {
- if (warningLink == null) {
+ if (warningComponent == null) {
//Not initialized yet
return;
}
@@ -340,27 +287,27 @@
for(int i = 0; i < propertiesTable.getItemCount(); i++ ) {
TableItem item = propertiesTable.getItem(i);
String value = item.getText(VALUE_INDEX);
- if (item.getText(KEY_INDEX).equals("enterprise")
+ if (item.getText(KEY_INDEX).equals("enterprise") //$NON-NLS-1$
&& (Boolean.TRUE.toString().equalsIgnoreCase(value)
|| "y".equalsIgnoreCase(value)
|| "yes".equalsIgnoreCase(value))
- && !assertEnterpriseRepoAccessible()) {
- warningLink.setVisible(true);
- return;
+ ) {
+
+ boolean isWarningLinkVisible = false;
+ if (enterpriseRepoStatus == null) {
+ enterpriseRepoStatus = MavenArtifactHelper.checkEnterpriseRequirementsAvailable(projectExample);
+ }
+ isWarningLinkVisible = !enterpriseRepoStatus.isOK();
+ if (isWarningLinkVisible) {
+ warningComponent.setLinkText(enterpriseRepoStatus.getMessage());
+ }
+ warningComponent.setVisible(isWarningLinkVisible);
+ return;
}
}
- warningLink.setVisible(false);
+ warningComponent.setVisible(false);
}
- private boolean assertEnterpriseRepoAccessible() {
- if (isEnterpriseRepoAvailable != null) {
- return isEnterpriseRepoAvailable.booleanValue();
- }
-
- isEnterpriseRepoAvailable = MavenArtifactHelper.isEnterpriseRepositoryAvailable();
- return isEnterpriseRepoAvailable.booleanValue();
- }
-
private Throwable getRootCause(Throwable ex) {
if (ex == null) return null;
Throwable rootCause = getRootCause(ex.getCause());
@@ -497,6 +444,13 @@
setDescription(ProjectExamplesActivator
.getShortDescription(projectExample.getDescription()));
}
+ ProjectImportConfiguration configuration = getImportConfiguration();
+ if (configuration != null) {
+ String profiles = projectExample.getDefaultProfiles();
+ if (profiles != null && profiles.trim().length() > 0) {
+ configuration.getResolverConfiguration().setActiveProfiles(profiles);
+ }
+ }
projectDescription = projectExample;
if (getContainer() != null) {
initialize();
@@ -527,6 +481,31 @@
@Override
public void setWizardContext(WizardContext context) {
this.context = context;
+ context.setProperty(MavenProjectConstants.IMPORT_PROJECT_CONFIGURATION, getImportConfiguration());
+ context.setProperty(MavenProjectConstants.MAVEN_MODEL, getDynamicModel());
}
+
+ /** Returns a dynamic Model that can be shared across wizard pages. */
+ private Model getDynamicModel() {
+ Model model = new Model() {
+ public String getModelVersion() {
+ return "4.0.0"; //$NON-NLS-1$
+ }
+
+ public String getGroupId() {
+ return groupIdCombo.getText();
+ }
+
+ public String getArtifactId(){
+ return artifactIdCombo.getText();
+ }
+
+ public String getVersion(){
+ return versionCombo.getText();
+ }
+ };
+ return model;
+ }
+
}
Deleted: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenArtifactHelper.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -1,63 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.maven.project.examples.wizard;
-
-import java.util.ArrayList;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.embedder.ArtifactKey;
-import org.eclipse.m2e.core.embedder.IMaven;
-
-public class MavenArtifactHelper {
-
- public static final String ENTERPRISE_JBOSS_SPEC = "org.jboss.spec:jboss-javaee-web-6.0:3.0.0.Beta1-redhat-1"; //$NON-NLS-1$
-
- private static final String ENTERPRISE_JBOSS_SPEC_KEYSTRING = ENTERPRISE_JBOSS_SPEC+"::"; //$NON-NLS-1$
-
- /**
- * Checks if the EAP repository is available
- *
- * @return true if org.jboss.spec:jboss-javaee-web-6.0:3.0.0.Beta1-redhat-1 can be resolved
- */
- public static boolean isEnterpriseRepositoryAvailable() {
- boolean isRepoAvailable = isArtifactAvailable(ENTERPRISE_JBOSS_SPEC_KEYSTRING, "pom"); //$NON-NLS-1$
- return isRepoAvailable;
- }
-
- /**
- * Checks if an artifact can be resolved
- * @param artifactKey
- * @return true is the artifactKey can be resolved to an artifact.
- */
- public static boolean isArtifactAvailable(String artifactKey, String type) {
- boolean isRepoAvailable = false;
- try {
- IMaven maven = MavenPlugin.getMaven();
- ArrayList<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
- repos.addAll(maven.getArtifactRepositories());
- IProgressMonitor nullProgressMonitor = new NullProgressMonitor();
- ArtifactKey key = ArtifactKey.fromPortableString(artifactKey);
- Artifact a = MavenPlugin.getMaven().resolve(
- key.getGroupId(), key.getArtifactId(), key.getVersion(),
- type, key.getClassifier(), repos, nullProgressMonitor);
- isRepoAvailable = a != null && a.isResolved();
- } catch (CoreException e) {
- System.err.println(e.getLocalizedMessage());
- }
- return isRepoAvailable;
- }
-
-}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenProjectConstants.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenProjectConstants.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MavenProjectConstants.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -8,6 +8,10 @@
public final static String ENTERPRISE_TARGET = "enterprise";
+ public final static String IMPORT_PROJECT_CONFIGURATION = "importProjectConfiguration";
+
+ public static final String MAVEN_MODEL = "mavenModel";
+
private MavenProjectConstants(){
}
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java 2012-04-12 06:56:59 UTC (rev 40149)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/MissingRepositoryWarningComponent.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -19,38 +19,31 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.PlatformUI;
public class MissingRepositoryWarningComponent extends Composite {
- private Composite warningLink;
+ private Link warninglink;
- public MissingRepositoryWarningComponent(Composite parent) {
+ public MissingRepositoryWarningComponent(Composite parent, boolean visibleInitially) {
super(parent, SWT.NORMAL);
- warningLink = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).span(3, 1)
+ .applyTo(this);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(this);
- Display display = Display.getCurrent();
- Color color = display.getSystemColor(SWT.COLOR_BLUE);
-
- warningLink.setBackground(color);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1)
- .applyTo(warningLink);
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(warningLink);
+ Label warningImg = new Label(this, SWT.CENTER | SWT.TOP);
+ Image warningIcon = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(warningImg);
+ warningImg.setImage(warningIcon);
- Label warningImg = new Label(warningLink, SWT.CENTER | SWT.TOP);
- warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
-
- Link link = new Link(warningLink, SWT.NONE);
- String message = "Artifacts needed from JBoss Enterprise Maven repository do not seem to be available.\nThis might cause build problems. "
- + "Follow this <a href=\"http://community.jboss.org/wiki/SettingUpTheJBossEnterpriseRepositories\">link</a> for more details.";
- link.setText(message);
- link.addSelectionListener(new SelectionAdapter() {
+ warninglink = new Link(this, SWT.NONE | SWT.FILL);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(warninglink);
+ warninglink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
@@ -62,19 +55,19 @@
}
}
});
- link.setBackground(display.getSystemColor(SWT.COLOR_RED));
+
+ setVisible(visibleInitially);
}
@Override
- public void setVisible(boolean visible) {
- warningLink.setVisible(visible);
- super.setVisible(visible);
- }
-
- @Override
public void dispose() {
- warningLink.dispose();
super.dispose();
}
+ public void setLinkText(String text) {
+ if (warninglink != null) {
+ warninglink.setText(text);
+ getParent().layout(true, true);
+ }
+ }
}
Added: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/DependencyKey.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/DependencyKey.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/xpl/DependencyKey.java 2012-04-12 08:42:07 UTC (rev 40150)
@@ -0,0 +1,123 @@
+package org.jboss.tools.maven.project.examples.xpl;
+
+import java.io.Serializable;
+
+import org.eclipse.osgi.util.NLS;
+
+public class DependencyKey implements Serializable {
+ private static final long serialVersionUID = -8984509272834024387L;
+
+ private final String groupId;
+ private final String type;
+ private final String artifactId;
+ private final String version;
+ private final String classifier;
+
+ public DependencyKey(String groupId, String artifactId, String version, String classifier, String type) {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ this.classifier = classifier;
+ this.type = type;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o instanceof DependencyKey) {
+ DependencyKey other = (DependencyKey) o;
+ return equals(groupId, other.groupId)
+ && equals(artifactId, other.artifactId)
+ && equals(version, other.version)
+ && equals(type, other.type)
+ && equals(classifier, other.classifier);
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ int hash = 17;
+ hash = hash * 31 + (groupId != null? groupId.hashCode(): 0);
+ hash = hash * 31 + (artifactId != null? artifactId.hashCode(): 0);
+ hash = hash * 31 + (version != null? version.hashCode(): 0);
+ hash = hash * 31 + (type != null? type.hashCode(): 0);
+ hash = hash * 31 + (classifier != null? classifier.hashCode(): 0);
+ return hash;
+ }
+
+ private static boolean equals(Object o1, Object o2) {
+ return o1 == null? o2 == null: o1.equals(o2);
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(groupId).append(':').append(artifactId).append(':')
+ .append(type).append(':').append(version);
+ if(classifier != null) {
+ sb.append(':').append(classifier);
+ }
+ return sb.toString();
+ }
+
+ public static DependencyKey fromPortableString(String str) {
+ int p, c;
+
+ p = 0; c = nextColonIndex(str, p);
+ String groupId = substring(str, p, c);
+
+ p = c + 1; c = nextColonIndex(str, p);
+ String artifactId = substring(str, p, c);
+
+ p = c + 1; c = nextColonIndex(str, p);
+ String type = substring(str, p, c);
+
+ p = c + 1; c = nextColonIndex(str, p);
+ String version = substring(str, p, c);
+
+ p = c + 1; c = nextColonIndex(str, p);
+ String classifier = substring(str, p, c);
+
+ return new DependencyKey(groupId, artifactId, version, classifier, type);
+ }
+
+ private static String substring(String str, int start, int end) {
+ String substring = str.substring(start, end);
+ return "".equals(substring)? null: substring; //$NON-NLS-1$
+ }
+
+ private static int nextColonIndex(String str, int pos) {
+ int idx = str.indexOf(':', pos);
+ if (idx < 0) throw new IllegalArgumentException(NLS.bind("Invalid portable string: {0}", str));
+ return idx;
+ }
+
+ public String toPortableString() {
+ StringBuilder sb = new StringBuilder();
+ if (groupId != null) sb.append(groupId); sb.append(':');
+ if (artifactId != null) sb.append(artifactId); sb.append(':');
+ if (type != null) sb.append(type); sb.append(':');
+ if (version != null) sb.append(version); sb.append(':');
+ if (classifier != null) sb.append(classifier); sb.append(':');
+ return sb.toString();
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getClassifier() {
+ return classifier;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+}
13 years, 12 months
JBoss Tools SVN: r40149 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2012-04-12 02:56:59 -0400 (Thu, 12 Apr 2012)
New Revision: 40149
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java
Log:
https://issues.jboss.org/browse/JBIDE-8965 -- When user didn't drag to any side of the element highlight one side by default.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java 2012-04-11 23:19:56 UTC (rev 40148)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java 2012-04-12 06:56:59 UTC (rev 40149)
@@ -89,7 +89,22 @@
&& mouseY < bounds.y + bounds.height) {
highlightedDropTarget = DropTarget.END;
} else {
- highlightedDropTarget = null;
+ /*
+ * https://issues.jboss.org/browse/JBIDE-8965
+ * When user didn't drag to any side of the element
+ * highlight one side by default.
+ */
+ if (dropTargets.contains(DropTarget.END)) {
+ highlightedDropTarget = DropTarget.END;
+ } else if (dropTargets.contains(DropTarget.AFTER)) {
+ highlightedDropTarget = DropTarget.AFTER;
+ } else if (dropTargets.contains(DropTarget.BEFORE)) {
+ highlightedDropTarget = DropTarget.BEFORE;
+ } else if (dropTargets.contains(DropTarget.BEGIN)) {
+ highlightedDropTarget = DropTarget.BEGIN;
+ } else {
+ highlightedDropTarget = null;
+ }
}
}
13 years, 12 months
JBoss Tools SVN: r40148 - trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-04-11 19:19:56 -0400 (Wed, 11 Apr 2012)
New Revision: 40148
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java
Log:
https://issues.jboss.org/browse/JBIDE-11472 Adding a XHTML targets "target/m2e-wtp/web resources
Modified: trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java 2012-04-11 23:10:25 UTC (rev 40147)
+++ trunk/jst/tests/org.jboss.tools.jst.web.ui.test/src/org/jboss/tools/jst/web/ui/test/WebWizardsTest.java 2012-04-11 23:19:56 UTC (rev 40148)
@@ -84,7 +84,7 @@
try {
dialog.open();
IWizardPage htmlWizardNewFileCreationPage = dialog.getCurrentPage();
- assertEquals("The Page should be","HTMLWizardNewFileCreationPage", htmlWizardNewFileCreationPage.getName()); //$NON-NLS-1$//$NON-NLS-2$
+ assertEquals("The Page should be","XHTMLWizardNewFileCreationPage", htmlWizardNewFileCreationPage.getName()); //$NON-NLS-1$//$NON-NLS-2$
IWizardPage newXHTMLTemplatesWizardPage=htmlWizardNewFileCreationPage.getNextPage();
assertEquals("The Page should be","NewXHTMLTemplatesWizardPage", newXHTMLTemplatesWizardPage.getName()); //$NON-NLS-1$//$NON-NLS-2$
if (newXHTMLTemplatesWizardPage.canFlipToNextPage()) {
13 years, 12 months
JBoss Tools SVN: r40147 - in trunk/jst/plugins/org.jboss.tools.jst.web.ui: src/org/jboss/tools/jst/web/ui/wizards/newfile and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-04-11 19:10:25 -0400 (Wed, 11 Apr 2012)
New Revision: 40147
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLFileWizardPage.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java
Log:
https://issues.jboss.org/browse/JBIDE-11472 Adding a XHTML targets "target/m2e-wtp/web resources
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2012-04-11 21:45:29 UTC (rev 40146)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2012-04-11 23:10:25 UTC (rev 40147)
@@ -28,7 +28,7 @@
org.jboss.tools.jst.web,
org.eclipse.ui.navigator;bundle-version="3.5.0",
org.eclipse.jdt.ui;bundle-version="3.7.0",
- org.eclipse.wst.common.frameworks;visibility:=reexport;bundle-version="1.2.0",
+ org.eclipse.wst.common.frameworks;bundle-version="1.2.0";visibility:=reexport,
org.eclipse.wst.server.core;bundle-version="1.1.302",
org.eclipse.wst.server.ui;bundle-version="1.1.305",
org.eclipse.jst.j2ee.web;bundle-version="1.1.500",
@@ -50,7 +50,8 @@
org.apache.ant;bundle-version="1.7.1",
org.eclipse.datatools.connectivity.ui.dse;bundle-version="1.1.4",
org.eclipse.datatools.connectivity.db.generic.ui;bundle-version="1.0.1",
- org.jboss.tools.common.el.ui
+ org.jboss.tools.common.el.ui,
+ org.eclipse.wst.html.core;bundle-version="1.1.502"
Bundle-Version: 3.3.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
Added: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLFileWizardPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLFileWizardPage.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLFileWizardPage.java 2012-04-11 23:10:25 UTC (rev 40147)
@@ -0,0 +1,283 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.jst.web.ui.wizards.newfile;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jst.jsp.core.internal.util.FacetModuleCoreSupport;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
+import org.jboss.tools.common.web.WebUtils;
+import org.jboss.tools.jst.web.ui.WebUiPlugin;
+import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML;
+
+/**
+ * Copied from NewHTMLFileWizardPage because we can't extend it but we need to fix https://issues.jboss.org/browse/JBIDE-11472 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=375605).
+ *
+ * @author Alexey Kazakov
+ */
+public class NewXHTMLFileWizardPage extends WizardNewFileCreationPage {
+
+ private static final String defaultName = "NewFile"; //$NON-NLS-1$
+ private IContentType fContentType;
+ private List fValidExtensions = null;
+
+ public NewXHTMLFileWizardPage(String pageName, IStructuredSelection selection) {
+ super(pageName, selection);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ // inherit default container and name specification widgets
+ super.createControl(parent);
+ setFileName(computeDefaultFileName());
+ setPageComplete(validatePage());
+ }
+
+ protected String computeDefaultFileName() {
+ int count = 0;
+ String fileName = addDefaultExtension(defaultName);
+ IPath containerFullPath = getContainerFullPath();
+ if (containerFullPath != null) {
+ while (true) {
+ IPath path = containerFullPath.append(fileName);
+ if (ResourcesPlugin.getWorkspace().getRoot().exists(path)) {
+ count++;
+ fileName = addDefaultExtension(defaultName + count);
+ }
+ else {
+ break;
+ }
+ }
+ }
+ return fileName;
+ }
+
+ /**
+ * This method is overridden to set the selected folder to web contents
+ * folder if the current selection is outside the web contents folder.
+ */
+ protected void initialPopulateContainerNameField() {
+ super.initialPopulateContainerNameField();
+
+ IPath fullPath = getContainerFullPath();
+ IProject project = getProjectFromPath(fullPath);
+ IPath[] webContentPaths = WebUtils.getWebContentPaths(project);
+ boolean withinWebContent = false;
+ for (int i = 0; webContentPaths != null && i < webContentPaths.length; i++) {
+ if (webContentPaths[i].isPrefixOf(fullPath)) {
+ withinWebContent = true;
+ break;
+ }
+ }
+ if(!withinWebContent && webContentPaths.length>0) {
+ setContainerFullPath(webContentPaths[0]);
+ }
+ }
+
+ /**
+ * This method is overridden to set additional validation specific to
+ * html files.
+ */
+ protected boolean validatePage() {
+ setMessage(null);
+ setErrorMessage(null);
+
+ if (!super.validatePage()) {
+ return false;
+ }
+
+ String fileName = getFileName();
+ IPath fullPath = getContainerFullPath();
+ if ((fullPath != null) && (fullPath.isEmpty() == false) && (fileName != null)) {
+ // check that filename does not contain invalid extension
+ if (!extensionValidForContentType(fileName)) {
+ setErrorMessage(NLS.bind(HTMLUIMessages._ERROR_FILENAME_MUST_END_HTML, getValidExtensions().toString()));
+ return false;
+ }
+ // no file extension specified so check adding default
+ // extension doesn't equal a file that already exists
+ if (fileName.lastIndexOf('.') == -1) {
+ String newFileName = addDefaultExtension(fileName);
+ IPath resourcePath = fullPath.append(newFileName);
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IStatus result = workspace.validatePath(resourcePath.toString(), IResource.FOLDER);
+ if (!result.isOK()) {
+ // path invalid
+ setErrorMessage(result.getMessage());
+ return false;
+ }
+
+ if ((workspace.getRoot().getFolder(resourcePath).exists() || workspace.getRoot().getFile(resourcePath).exists())) {
+ setErrorMessage(HTMLUIMessages.ResourceGroup_nameExists);
+ return false;
+ }
+ }
+
+ // get the IProject for the selection path
+ IProject project = getProjectFromPath(fullPath);
+ // if inside web project, check if inside webContent folder
+ if (project != null && isWebProject(project)) {
+ // check that the path is inside the webContent folder
+ IPath[] webContentPaths = FacetModuleCoreSupport.getAcceptableRootPaths(project);
+ boolean isPrefix = false;
+ for (int i = 0; !isPrefix && i < webContentPaths.length; i++) {
+ isPrefix |= webContentPaths[i].isPrefixOf(fullPath);
+ }
+ if (!isPrefix) {
+ setMessage(HTMLUIMessages._WARNING_FOLDER_MUST_BE_INSIDE_WEB_CONTENT, WARNING);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Get content type associated with this new file wizard
+ *
+ * @return IContentType
+ */
+ private IContentType getContentType() {
+ if (fContentType == null)
+ fContentType = Platform.getContentTypeManager().getContentType(ContentTypeIdForHTML.ContentTypeID_HTML);
+ return fContentType;
+ }
+
+ /**
+ * Get list of valid extensions for HTML Content type
+ *
+ * @return
+ */
+ private List getValidExtensions() {
+ if (fValidExtensions == null) {
+ IContentType type = getContentType();
+ fValidExtensions = new ArrayList(Arrays.asList(type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
+ }
+ return fValidExtensions;
+ }
+
+ /**
+ * Verifies if fileName is valid name for content type. Takes base content
+ * type into consideration.
+ *
+ * @param fileName
+ * @return true if extension is valid for this content type
+ */
+ private boolean extensionValidForContentType(String fileName) {
+ boolean valid = false;
+
+ IContentType type = getContentType();
+ // there is currently an extension
+ if (fileName.lastIndexOf('.') != -1) {
+ // check what content types are associated with current extension
+ IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(fileName);
+ int i = 0;
+ while (i < types.length && !valid) {
+ valid = types[i].isKindOf(type);
+ ++i;
+ }
+ }
+ else
+ valid = true; // no extension so valid
+ return valid;
+ }
+
+ /**
+ * Adds default extension to the filename
+ *
+ * @param filename
+ * @return
+ */
+ String addDefaultExtension(String filename) {
+ StringBuffer newFileName = new StringBuffer(filename);
+
+// Preferences preference = HTMLCorePlugin.getDefault().getPluginPreferences();
+// String ext = preference.getString(HTMLCorePreferenceNames.DEFAULT_EXTENSION);
+ String ext = "xhtml";
+
+ newFileName.append("."); //$NON-NLS-1$
+ newFileName.append(ext);
+
+ return newFileName.toString();
+ }
+
+ /**
+ * Returns the project that contains the specified path
+ *
+ * @param path the path which project is needed
+ * @return IProject object. If path is <code>null</code> the return value
+ * is also <code>null</code>.
+ */
+ private IProject getProjectFromPath(IPath path) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = null;
+
+ if (path != null) {
+ if (workspace.validatePath(path.toString(), IResource.PROJECT).isOK()) {
+ project = workspace.getRoot().getProject(path.toString());
+ } else {
+ project = workspace.getRoot().getFile(path).getProject();
+ }
+ }
+
+ return project;
+ }
+
+ /**
+ * Checks if the specified project is a web project.
+ *
+ * @param project project to be checked
+ * @return true if the project is web project, otherwise false
+ */
+ private boolean isWebProject(IProject project) {
+// return FacetModuleCoreSupport.isWebProject(project);
+ if (project == null) {
+ return false;
+ }
+ boolean is = false;
+ IFacetedProject faceted;
+ try {
+ faceted = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ WebUiPlugin.getDefault().logError(e);
+ return false;
+ }
+ if (ProjectFacetsManager.isProjectFacetDefined("jst.web")) {
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet("jst.web");
+ is = is || (faceted != null && faceted.hasProjectFacet(facet));
+ }
+ if (ProjectFacetsManager.isProjectFacetDefined("wst.web")) {
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet("wst.web");
+ is = is || (faceted != null && faceted.hasProjectFacet(facet));
+ }
+ return is;
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLFileWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java 2012-04-11 21:45:29 UTC (rev 40146)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/newfile/NewXHTMLWizard.java 2012-04-11 23:10:25 UTC (rev 40147)
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
@@ -34,7 +35,6 @@
import org.eclipse.wst.sse.core.utils.StringUtils;
import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
import org.jboss.tools.common.model.XModelException;
-import org.jboss.tools.common.model.files.handlers.CreateFileSupport;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.wizard.newfile.NewFileContextEx;
import org.jboss.tools.common.model.ui.wizard.newfile.NewXHTMLFileWizard;
@@ -54,30 +54,33 @@
private WizardNewFileCreationPage fNewFilePage;
private NewXHTMLTemplatesWizardPage fNewFileTemplatesPage;
private NewXHTMLFileWizard newXHTMLFileWizard;
- private NewXHTMLWizardSelectTagLibrariesPage newXHTMLWizardSelectTagLibrariesPage;
-
-
-
+ private NewXHTMLWizardSelectTagLibrariesPage newXHTMLWizardSelectTagLibrariesPage;
+ private IStructuredSelection fSelection;
+
@Override
public void addPages() {
super.addPages();
- this.fNewFilePage = (WizardNewFileCreationPage) getPage(NewXHTMLWizard.HTMLWizardNewFileCreationPage);
+// this.fNewFilePage = (WizardNewFileCreationPage) getPage(NewXHTMLWizard.HTMLWizardNewFileCreationPage);
+ this.fNewFilePage = new NewXHTMLFileWizardPage("XHTMLWizardNewFileCreationPage", new StructuredSelection(IDE.computeSelectedResources(fSelection))); //$NON-NLS-1$
this.fNewFilePage.setTitle(Messages.UI_WIZARD_XHTML_NEW_TITLE);
this.fNewFilePage.setDescription(Messages.UI_WIZARD_XHTML_NEW_Description);
-
+ addPage(this.fNewFilePage);
+
NewFileContextEx newFileContext = newXHTMLFileWizard.getFileContext();
CreateJSPFileSupport jspFileSupport = (CreateJSPFileSupport)newFileContext.getSupport();
this.fNewFileTemplatesPage = new NewXHTMLTemplatesWizardPage(jspFileSupport);
-
+
addPage(this.fNewFileTemplatesPage);
this.newXHTMLWizardSelectTagLibrariesPage = getURISelectionPage();
if(jspFileSupport.getTaglibs()!=null&&jspFileSupport.getTaglibs().getDescriptions().length>0)
addPage(this.newXHTMLWizardSelectTagLibrariesPage);
}
+
@Override
public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) {
super.init(aWorkbench, aSelection);
+ fSelection = aSelection;
setWindowTitle(Messages.UI_WIZARD_XHTML_NEW_TITLE);
setNewXHTMLFileWizard(new NewXHTMLFileWizard());
getNewXHTMLFileWizard().init(aWorkbench, aSelection);
@@ -87,7 +90,7 @@
*/
@Override
public void addPage(IWizardPage page) {
- if(!NewXHTMLWizard.NewHTMLTemplatesWizardPage.equalsIgnoreCase(page.getName())){
+ if(!NewXHTMLWizard.NewHTMLTemplatesWizardPage.equalsIgnoreCase(page.getName()) && !NewXHTMLWizard.HTMLWizardNewFileCreationPage.equalsIgnoreCase(page.getName())){
super.addPage(page);
}
}
13 years, 12 months
JBoss Tools SVN: r40146 - trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/project/facet.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2012-04-11 17:45:29 -0400 (Wed, 11 Apr 2012)
New Revision: 40146
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/project/facet/MavenFacetInstallPage.java
Log:
JBIDE-11044 - Created server runtime isnt shown in target runtime combo box when Maven Integration facet is selected
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/project/facet/MavenFacetInstallPage.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/project/facet/MavenFacetInstallPage.java 2012-04-11 19:51:16 UTC (rev 40145)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/project/facet/MavenFacetInstallPage.java 2012-04-11 21:45:29 UTC (rev 40146)
@@ -130,9 +130,8 @@
packaging.setItems(items);
synchHelper.synchCombo(packaging, IJBossMavenConstants.PACKAGING, null);
- IFacetedProjectWorkingCopy fpwc = null;
try {
- fpwc = (IFacetedProjectWorkingCopy) getDataModel().getProperty(IFacetDataModelProperties.FACETED_PROJECT_WORKING_COPY);
+ IFacetedProjectWorkingCopy fpwc = (IFacetedProjectWorkingCopy) getDataModel().getProperty(IFacetDataModelProperties.FACETED_PROJECT_WORKING_COPY);
if (!mavenProjectExists) {
if (fpwc.hasProjectFacet(WebFacetUtils.WEB_FACET)) {
packaging.select(0);
@@ -171,10 +170,6 @@
}
} catch (Exception e) {
Activator.log(e);
- } finally {
- if (fpwc != null) {
- fpwc.dispose();
- }
}
if (mavenProjectExists) {
13 years, 12 months
JBoss Tools SVN: r40145 - workspace/yradtsevich/browsersim/region-finder.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-04-11 15:51:16 -0400 (Wed, 11 Apr 2012)
New Revision: 40145
Modified:
workspace/yradtsevich/browsersim/region-finder/region-finder.js
Log:
JBIDE-10945 BrowserSim: create more skins
Modified: workspace/yradtsevich/browsersim/region-finder/region-finder.js
===================================================================
--- workspace/yradtsevich/browsersim/region-finder/region-finder.js 2012-04-11 19:46:34 UTC (rev 40144)
+++ workspace/yradtsevich/browsersim/region-finder/region-finder.js 2012-04-11 19:51:16 UTC (rev 40145)
@@ -14,6 +14,7 @@
context.fillText("Drop an image here", 240, 200);
context.fillText("The visible area of the image must touch the top image border", 240, 240);
context.fillText("(i.e. the first row of the image must have at least 1 filled pixel).", 240, 255);
+ context.fillText("WORKS IN GOOGLE CHROME ONLY!", 240, 275);
canvas.addEventListener("drop", function (evt) {
var files = evt.dataTransfer.files;
13 years, 12 months
JBoss Tools SVN: r40144 - workspace/yradtsevich/browsersim/region-finder.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-04-11 15:46:34 -0400 (Wed, 11 Apr 2012)
New Revision: 40144
Modified:
workspace/yradtsevich/browsersim/region-finder/region-finder.html
workspace/yradtsevich/browsersim/region-finder/region-finder.js
Log:
JBIDE-10945 BrowserSim: create more skins
- added MIME types
Property changes on: workspace/yradtsevich/browsersim/region-finder/region-finder.html
___________________________________________________________________
Added: svn:mime-type
+ text/html
Property changes on: workspace/yradtsevich/browsersim/region-finder/region-finder.js
___________________________________________________________________
Added: svn:mime-type
+ text/javascript
13 years, 12 months
JBoss Tools SVN: r40143 - in workspace/yradtsevich/browsersim: region-finder and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-04-11 15:42:02 -0400 (Wed, 11 Apr 2012)
New Revision: 40143
Added:
workspace/yradtsevich/browsersim/region-finder/
workspace/yradtsevich/browsersim/region-finder/region-finder.html
workspace/yradtsevich/browsersim/region-finder/region-finder.js
Log:
JBIDE-10945 BrowserSim: create more skins
- created HTML application to create visible regions for images (needed for BrowserSim skins)
Added: workspace/yradtsevich/browsersim/region-finder/region-finder.html
===================================================================
--- workspace/yradtsevich/browsersim/region-finder/region-finder.html (rev 0)
+++ workspace/yradtsevich/browsersim/region-finder/region-finder.html 2012-04-11 19:42:02 UTC (rev 40143)
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <script type="text/javascript" src="region-finder.js"></script>
+ <style>
+ canvas {
+ position: relative;
+ border: 1px solid #000;
+ }
+ #outputId {
+ background-color: yellow;
+ border: 1px solid #000;
+ }
+ </style>
+ <title></title>
+</head>
+<body onload="main()">
+ <canvas id="canvasId" width="700px" height="600px"></canvas>
+ <div></div>Visible area region (pairs of (x, y)):</div>
+ <div id="outputId"></div>
+</body>
+</html>
\ No newline at end of file
Added: workspace/yradtsevich/browsersim/region-finder/region-finder.js
===================================================================
--- workspace/yradtsevich/browsersim/region-finder/region-finder.js (rev 0)
+++ workspace/yradtsevich/browsersim/region-finder/region-finder.js 2012-04-11 19:42:02 UTC (rev 40143)
@@ -0,0 +1,104 @@
+/**
+ * Created by JetBrains WebStorm.
+ * User: yradtsevich
+ * Date: 11.4.12
+ * Time: 18.32
+ * To change this template use File | Settings | File Templates.
+ */
+// Get the CanvasPixelArray from the given coordinates and dimensions.
+function main() {
+ var img = new Image();
+// img.src = 'orig.png';
+ var canvas = document.getElementById("canvasId");
+ var context = canvas.getContext("2d");
+ context.fillText("Drop an image here", 240, 200);
+ context.fillText("The visible area of the image must touch the top image border", 240, 240);
+ context.fillText("(i.e. the first row of the image must have at least 1 filled pixel).", 240, 255);
+
+ canvas.addEventListener("drop", function (evt) {
+ var files = evt.dataTransfer.files;
+ if (files.length > 0) {
+ var file = files[0];
+ if (typeof FileReader !== "undefined" && file.type.indexOf("image") != -1) {
+ var reader = new FileReader();
+ // Note: addEventListener doesn't work in Google Chrome for this event
+ reader.onload = function (evt) {
+ img.src = evt.target.result;
+ };
+ reader.readAsDataURL(file);
+ }
+ }
+ evt.preventDefault();
+ }, false);
+
+ img.onload = function() {
+ canvas.width = img.width;
+ canvas.height = img.height;
+ context.drawImage(img, 0, 0);
+ var imgd = context.getImageData(0, 0, img.width, img.height);
+ var pix = imgd.data;
+
+ var fullPath = findPath(img.width, img.height, function(point) {
+ if (point.x < 0 || point.x >= img.width
+ ||point.y < 0 || point.y >= img.height) {
+ return true;
+ }
+ var alphaP = pix[(point.y * img.width + point.x) * 4 + 3];
+ return alphaP == 0;
+ });
+
+ var packedPath = packPath(fullPath);
+ var output = document.getElementById("outputId");
+ output.innerHTML = "<B>int[] path = {</B>";
+ for (var i = 0; i < packedPath.length - 1; i++) {
+ output.innerHTML += packedPath[i].x + ', ' + packedPath[i].y + ', ';
+ }
+ var lastIndex = packedPath.length - 1;
+ output.innerHTML += packedPath[lastIndex].x + ', ' + packedPath[lastIndex].y + "<B>};</B>";
+ }
+
+ var findPath = function(width, height, isEmpty) {
+ var directions = [{x : 1, y : 0}, {x : 1, y : 1}, {x : 0, y : 1}, {x : -1, y : 1}, {x : -1, y : 0}, {x : -1, y : -1}, {x : 0, y : -1}, {x : 1, y : -1}];
+ for (var i = 0; i < directions.length; i++) {
+ directions[i].next = directions[(i + 1) % directions.length];
+ directions[i].opposite = directions[(i + directions.length / 2) % directions.length];
+ }
+
+ var initialDirection = directions[0];
+ var startPoint = {x:0, y:0};
+ var point = startPoint;
+ while (isEmpty(point)) {
+ point.x += initialDirection.x;
+ point.y += initialDirection.y;
+ }
+
+ var path = [point];
+ var direction = initialDirection;
+
+ do {
+ direction = direction.opposite;
+ do {
+ var newPoint = {};
+ direction = direction.next;
+ newPoint.x = point.x + direction.x;
+ newPoint.y = point.y + direction.y;
+ } while (isEmpty(newPoint));
+ point = newPoint;
+ path.push(point);
+ } while (startPoint.x != point.x || startPoint.y != point.y);
+
+ return path;
+ }
+
+ var packPath = function(path) {
+ var packed = [path[0]];
+ for (var i = 1; i < path.length - 1; i++) {
+ if (((path[i].x - path[i - 1].x) != (path[i + 1].x - path[i].x))
+ ||((path[i].y - path[i - 1].y) != (path[i + 1].y - path[i].y))) {
+ packed.push(path[i]);
+ }
+ }
+
+ return packed;
+ }
+}
13 years, 12 months
JBoss Tools SVN: r40142 - trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/android.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-04-11 15:34:21 -0400 (Wed, 11 Apr 2012)
New Revision: 40142
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/android/AndroidResizableSkin.java
Log:
JBIDE-10945 BrowserSim: create more skins
- added visible region for Android skin
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/android/AndroidResizableSkin.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/android/AndroidResizableSkin.java 2012-04-11 19:08:41 UTC (rev 40141)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/android/AndroidResizableSkin.java 2012-04-11 19:34:21 UTC (rev 40142)
@@ -12,6 +12,13 @@
public class AndroidResizableSkin extends AppleIPhone3ResizableSkin {
private static final Point NORMAL_SKREEN_SIZE = new Point(240, 1);
private static final Point NORMAL_SKIN_SIZE = new Point(339, 186);
+ public static final int[] VISIBLE_REGION_VERTICAL = {20, 0, 318, 0, 319, 1, 321, 1, 322, 2, 323, 2, 325, 4, 326, 4,
+ 328, 6, 329, 6, 332, 9, 332, 10, 335, 13, 335, 14, 336, 15, 336, 17, 337, 18, 337, 20, 338, 21, 338, 163, 337,
+ 164, 337, 166, 336, 167, 336, 169, 335, 170, 335, 171, 333, 173, 333, 174, 327, 180, 326, 180, 325, 181, 324,
+ 181, 323, 182, 322, 182, 321, 183, 320, 183, 318, 185, 20, 185, 18, 183, 17, 183, 16, 182, 15, 182, 14, 181,
+ 13, 181, 12, 180, 11, 180, 5, 174, 5, 173, 3, 171, 3, 170, 2, 169, 2, 167, 1, 166, 1, 164, 0, 163, 0, 21, 1,
+ 20, 1, 18, 2, 17, 2, 15, 3, 14, 3, 13, 6, 10, 6, 9, 7, 9, 9, 7, 9, 6, 10, 6, 12, 4, 13, 4, 15, 2, 16, 2, 17, 1,
+ 19, 1};
private static final Point VERTICAL_BORDERS_SIZE = new Point(NORMAL_SKIN_SIZE.x - NORMAL_SKREEN_SIZE.x, NORMAL_SKIN_SIZE.y - NORMAL_SKREEN_SIZE.y);
private static final Point HORIZONTAL_BORDERS_SIZE = new Point(VERTICAL_BORDERS_SIZE.y, VERTICAL_BORDERS_SIZE.x);
private static final IPhoneSkinDescriptor VERTICAL_IPHONE3_DESCRIPTOR;
@@ -95,19 +102,6 @@
@Override
protected int[] getNormalRegion(boolean vertical) {
- int[] normalRegion = new int[8];
- normalRegion[0] = 0;
- normalRegion[1] = 0;
-
- normalRegion[2] = 339;
- normalRegion[3] = 0;
-
- normalRegion[4] = 339;
- normalRegion[5] = 186;
-
- normalRegion[6] = 0;
- normalRegion[7] = 186;
-
- return normalRegion;
+ return VISIBLE_REGION_VERTICAL;
}
}
13 years, 12 months