JBoss Tools SVN: r33875 - trunk/maven/site.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-08-12 19:33:33 -0400 (Fri, 12 Aug 2011)
New Revision: 33875
Modified:
trunk/maven/site/site.xml
Log:
JBIDE-9127 : Added maven project configurator for jboss-sar packages
Modified: trunk/maven/site/site.xml
===================================================================
--- trunk/maven/site/site.xml 2011-08-12 23:33:15 UTC (rev 33874)
+++ trunk/maven/site/site.xml 2011-08-12 23:33:33 UTC (rev 33875)
@@ -29,6 +29,9 @@
<feature url="features/org.jboss.tools.maven.jaxrs.feature_0.0.0.jar" id="org.jboss.tools.maven.jaxrs.feature" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
</feature>
+ <feature url="features/org.jboss.tools.maven.jbosspackaging.feature_0.0.0.jar" id="org.jboss.tools.maven.jbosspackaging.feature" version="0.0.0">
+ <category name="JBoss Tools maven Nightly Build Update Site"/>
+ </feature>
<feature url="features/org.jboss.tools.maven.tests.feature_0.0.0.jar" id="org.jboss.tools.maven.tests.feature" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
</feature>
14 years, 8 months
JBoss Tools SVN: r33874 - in trunk/maven/features: org.jboss.tools.maven.jbosspackaging.feature and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-08-12 19:33:15 -0400 (Fri, 12 Aug 2011)
New Revision: 33874
Added:
trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/
trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/.project
trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/build.properties
trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.properties
trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.xml
trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/license.html
trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/pom.xml
Modified:
trunk/maven/features/pom.xml
Log:
JBIDE-9127 : Added maven project configurator for jboss-sar packages
Added: trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/.project
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/.project (rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/.project 2011-08-12 23:33:15 UTC (rev 33874)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.jbosspackaging.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Added: trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/build.properties
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/build.properties (rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/build.properties 2011-08-12 23:33:15 UTC (rev 33874)
@@ -0,0 +1,3 @@
+bin.includes = feature.xml,\
+ license.html,\
+ feature.properties
Added: trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.properties
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.properties (rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.properties 2011-08-12 23:33:15 UTC (rev 33874)
@@ -0,0 +1,53 @@
+###############################################################################
+# Copyright (c) 2010-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.
+##############################################################################
+# feature.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=JBoss Packaging Maven Configurators
+
+# "providerName" property - name of the company that provides the feature
+providerName=JBoss by Red Hat
+
+# "updateSiteName" property - label for the update site
+updateSiteName=JBossTools Update Site
+
+# "description" property - description of the feature
+description=SAR project configurator for the jboss-packaging-maven-plugin
+
+# "copyright" property - text of the "Feature Update Copyright"
+copyright=Copyright (c) 2010-2011 Red Hat, Inc. and others.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http\://www.eclipse.org/legal/epl-v10.html\n\nContributors\:\n\
+JBoss by Red Hat - Initial implementation.
+ ############### end of copyright property ####################################
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# START NON-TRANSLATABLE
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=Red Hat, Inc. licenses these features and plugins to you under \
+certain open source licenses (or aggregations of such licenses), which \
+in a particular case may include the Eclipse Public License, the GNU \
+Lesser General Public License, and/or certain other open source \
+licenses. For precise licensing details, consult the corresponding \
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive, \
+Raleigh NC 27606 USA.
+# END NON-TRANSLATABLE
+########### end of license property ##########################################
Added: trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.xml
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.xml (rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/feature.xml 2011-08-12 23:33:15 UTC (rev 33874)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.tools.maven.jbosspackaging.feature"
+ label="%featureName"
+ version="1.3.0.qualifier"
+ provider-name="%providerName"
+ plugin="org.jboss.tools.maven.jbosspackaging">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <requires>
+ <import feature="org.eclipse.m2e.feature" version="1.0" match="greaterOrEqual"/>
+ <import feature="org.maven.ide.eclipse.wtp.feature" version="0.13.0" match="greaterOrEqual"/>
+ <import feature="org.jboss.ide.eclipse.as.feature" version="2.3.0" match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="org.jboss.tools.maven.jbosspackaging"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
Added: trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/license.html
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/license.html (rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/license.html 2011-08-12 23:33:15 UTC (rev 33874)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+
+<body>
+<p>Red Hat, Inc. licenses these features and plugins to you under
+certain open source licenses (or aggregations of such licenses), which
+in a particular case may include the Eclipse Public License, the GNU
+Lesser General Public License, and/or certain other open source
+licenses. For precise licensing details, consult the corresponding
+source code, or contact Red Hat Legal Affairs, 1801 Varsity Drive,
+Raleigh NC 27606 USA.
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/pom.xml
===================================================================
--- trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/pom.xml (rev 0)
+++ trunk/maven/features/org.jboss.tools.maven.jbosspackaging.feature/pom.xml 2011-08-12 23:33:15 UTC (rev 33874)
@@ -0,0 +1,13 @@
+<?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.maven</groupId>
+ <artifactId>features</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.maven.features</groupId>
+ <artifactId>org.jboss.tools.maven.jbosspackaging.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+</project>
\ No newline at end of file
Modified: trunk/maven/features/pom.xml
===================================================================
--- trunk/maven/features/pom.xml 2011-08-12 23:32:31 UTC (rev 33873)
+++ trunk/maven/features/pom.xml 2011-08-12 23:33:15 UTC (rev 33874)
@@ -22,6 +22,7 @@
<module>org.jboss.tools.maven.project.examples.feature</module>
<module>org.jboss.tools.maven.tests.feature</module>
<module>org.jboss.tools.maven.jaxrs.feature</module>
+ <module>org.jboss.tools.maven.jbosspackaging.feature</module>
</modules>
</project>
14 years, 8 months
JBoss Tools SVN: r33873 - in trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test: refactoring and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-08-12 19:32:31 -0400 (Fri, 12 Aug 2011)
New Revision: 33873
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/JSF2RefactoringTest.java
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsInClassFolderTest.java
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsValidatorTest.java
Log:
https://issues.jboss.org/browse/JBIDE-9532
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java 2011-08-12 23:32:23 UTC (rev 33872)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java 2011-08-12 23:32:31 UTC (rev 33873)
@@ -14,11 +14,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jdt.internal.core.JavaModelManager;
-import org.eclipse.wst.validation.internal.operations.ValidatorManager;
import org.jboss.tools.jsf.model.pv.test.JSFPromptingProviderTest;
import org.jboss.tools.jsf.model.pv.test.JsfJbide7975Test;
import org.jboss.tools.jsf.test.project.facet.JSFFacetOnExistingProjectTest;
@@ -30,7 +26,7 @@
import org.jboss.tools.jsf.test.validation.JSF2ComponentsInClassFolderTest;
import org.jboss.tools.jsf.test.validation.JSF2ComponentsValidatorTest;
import org.jboss.tools.jsf.test.validation.WebContentTest;
-import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.jst.jsp.test.ValidationProjectTestSetup;
import org.jboss.tools.test.util.ProjectImportTestSetup;
public class JsfAllTests {
@@ -74,7 +70,7 @@
MessagePropertyRefactoringTest.class), "org.jboss.tools.jsf.test", //$NON-NLS-1$
new String[] { "projects/JSFKickStartOldFormat" }, //$NON-NLS-1$
new String[] { "JSFKickStartOldFormat" })); //$NON-NLS-1$
- suite.addTest(new ProjectImportTestSetup(new TestSuite(
+ suite.addTest(new ValidationProjectTestSetup(new TestSuite(
JSF2ComponentsValidatorTest.class,
JSF2ComponentsInClassFolderTest.class), "org.jboss.tools.jsf.test", //$NON-NLS-1$
new String[] { "projects/JSF2ComponentsValidator" }, //$NON-NLS-1$
@@ -87,17 +83,7 @@
// I18nValidatorTest.class), "org.jboss.tools.jsf.test", //$NON-NLS-1$
// new String[] { "projects/i18nTestProject" }, //$NON-NLS-1$
// new String[] { "i18nTestProject" })); //$NON-NLS-1$
- suite.addTest(new ProjectImportTestSetup(new TestSuite(ELValidatorTest.class),"org.jboss.tools.jsf.test","projects/JSFKickStartOldFormat","JSFKickStartOldFormat") {
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- IProject project = (IProject)ResourcesPlugin.getWorkspace().getRoot().findMember("JSFKickStartOldFormat");
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- JobUtils.waitForIdle();
-
- ValidatorManager.addProjectBuildValidationSupport(project);
- }
- } );
+ suite.addTest(new ValidationProjectTestSetup(new TestSuite(ELValidatorTest.class),"org.jboss.tools.jsf.test","projects/JSFKickStartOldFormat","JSFKickStartOldFormat"));
return new DisableJavaIndexingSetup(suite);
}
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/JSF2RefactoringTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/JSF2RefactoringTest.java 2011-08-12 23:32:23 UTC (rev 33872)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/JSF2RefactoringTest.java 2011-08-12 23:32:31 UTC (rev 33873)
@@ -6,31 +6,27 @@
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ltk.internal.core.refactoring.resource.MoveResourcesProcessor;
import org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor;
import org.jboss.tools.jsf.jsf2.refactoring.JSF2RenameParticipant;
import org.jboss.tools.jsf.jsf2.refactoring.JSf2MoveParticipant;
-import org.jboss.tools.test.util.JobUtils;
-import org.jboss.tools.test.util.ProjectImportTestSetup;
import org.jboss.tools.tests.AbstractRefactorTest;
public class JSF2RefactoringTest extends AbstractRefactorTest {
- static String projectName = "JSF2ComponentsValidator";
- static IProject project;
+ static String PROJECT_NAME = "JSF2ComponentsValidator";
+ IProject project;
public JSF2RefactoringTest(){
super("Refactor JSF2 Composite Components Test");
}
-
+
+ @Override
protected void setUp() throws Exception {
- project = ProjectImportTestSetup.loadProject(projectName);
- project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- JobUtils.waitForIdle(2000);
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
}
-
+
public void testRenameCompositeComponentFile() throws CoreException {
ArrayList<TestChangeStructure> list = new ArrayList<TestChangeStructure>();
@@ -40,15 +36,15 @@
list.add(structure);
IFile sourceFile = project.getProject().getFile("/WebContent/resources/demo/input.xhtml");
-
+
RenameResourceProcessor processor = new RenameResourceProcessor(sourceFile);
processor.setNewResourceName("input2.xhtml");
-
+
JSF2RenameParticipant participant = new JSF2RenameParticipant();
checkRename(processor, sourceFile, "input2.xhtml", participant, list);
}
-
+
public void testRenameCompositeComponentFolder() throws CoreException {
ArrayList<TestChangeStructure> list = new ArrayList<TestChangeStructure>();
@@ -58,15 +54,15 @@
list.add(structure);
IFolder sourceFolder = project.getProject().getFolder("/WebContent/resources/demo");
-
+
RenameResourceProcessor processor = new RenameResourceProcessor(sourceFolder);
processor.setNewResourceName("demo2");
-
+
JSF2RenameParticipant participant = new JSF2RenameParticipant();
checkRename(processor, sourceFolder, "demo2", participant, list);
}
-
+
public void testMoveCompositeComponentFile() throws CoreException {
ArrayList<TestChangeStructure> list = new ArrayList<TestChangeStructure>();
@@ -104,5 +100,4 @@
checkMove(processor, sourceFolder, destinationFolder, participant, list);
}
-
-}
+}
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsInClassFolderTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsInClassFolderTest.java 2011-08-12 23:32:23 UTC (rev 33872)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsInClassFolderTest.java 2011-08-12 23:32:31 UTC (rev 33873)
@@ -13,14 +13,12 @@
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
-import org.jboss.tools.test.util.ProjectImportTestSetup;
/**
*
@@ -29,8 +27,7 @@
*/
public class JSF2ComponentsInClassFolderTest extends TestCase {
- private static String projectName = "JSF2ComponentsValidator"; //$NON-NLS-1$
- private static IProject project;
+ private IProject project;
public JSF2ComponentsInClassFolderTest() {
super("JSF 2 Components In Class Folder Test"); //$NON-NLS-1$
@@ -38,9 +35,7 @@
@Override
protected void setUp() throws Exception {
- project = ProjectImportTestSetup.loadProject(projectName);
- project.build(IncrementalProjectBuilder.FULL_BUILD,
- new NullProgressMonitor());
+ project = project = ResourcesPlugin.getWorkspace().getRoot().getProject(JSF2ComponentsValidatorTest.PROJECT_NAME);
}
public void testJSF2ComponentsInClassFolder() throws Exception {
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsValidatorTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsValidatorTest.java 2011-08-12 23:32:23 UTC (rev 33872)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/JSF2ComponentsValidatorTest.java 2011-08-12 23:32:31 UTC (rev 33873)
@@ -8,7 +8,6 @@
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
******************************************************************************/
-
package org.jboss.tools.jsf.test.validation;
import java.io.IOException;
@@ -21,15 +20,13 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.validation.ValidationFramework;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
import org.jboss.tools.jsf.web.validation.JSFValidationMessage;
-import org.jboss.tools.test.util.JobUtils;
-import org.jboss.tools.test.util.ProjectImportTestSetup;
import org.jboss.tools.tests.AbstractResourceMarkerTest;
/**
@@ -37,22 +34,20 @@
* @author yzhishko
*
*/
-
public class JSF2ComponentsValidatorTest extends TestCase {
- private static String projectName = "JSF2ComponentsValidator"; //$NON-NLS-1$
- private static IProject project;
+ public static String PROJECT_NAME = "JSF2ComponentsValidator"; //$NON-NLS-1$
+ private IProject project;
public JSF2ComponentsValidatorTest() {
super("JSF 2 Components Validator Test"); //$NON-NLS-1$
}
+ @Override
protected void setUp() throws Exception {
- project = ProjectImportTestSetup.loadProject(projectName);
- project.build(IncrementalProjectBuilder.FULL_BUILD,
- new NullProgressMonitor());
- JobUtils.waitForIdle();
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
}
+
//junit test add to check JBIDE-7016 by Maksim Areshkau
public void testCreatingFile() throws CoreException, IOException{
final IFile createdFile = JSF2ResourceUtil
14 years, 8 months
JBoss Tools SVN: r33872 - in trunk/maven/plugins: org.jboss.tools.maven.jbosspackaging and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-08-12 19:32:23 -0400 (Fri, 12 Aug 2011)
New Revision: 33872
Added:
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.classpath
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.project
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.jdt.core.prefs
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.m2e.core.prefs
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/META-INF/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.html
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.ini
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.mappings
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.properties
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/build.properties
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/jboss_about.png
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/lifecycle-mapping-metadata.xml
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.properties
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/pom.xml
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/MavenJBossPackagingActivator.java
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/SarLifecycleMapping.java
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingArchiverConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingPluginConfiguration.java
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/MavenSarConstants.java
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/ResourceCleaner.java
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarArchiverConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarProjectConfigurator.java
Modified:
trunk/maven/plugins/pom.xml
Log:
JBIDE-9127 : Added maven project configurator for jboss-sar packages
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.classpath
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.classpath (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.classpath 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.project
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.project (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.project 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.jbosspackaging</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.jdt.core.prefs 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,8 @@
+#Sat Jul 03 23:59:47 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.m2e.core.prefs
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.m2e.core.prefs (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/.settings/org.eclipse.m2e.core.prefs 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,5 @@
+#Tue Jun 28 11:43:06 CEST 2011
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/META-INF/MANIFEST.MF (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/META-INF/MANIFEST.MF 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.jboss.tools.maven.jbosspackaging;singleton:=true
+Bundle-Version: 1.3.0.qualifier
+Bundle-Activator: org.jboss.tools.maven.jbosspackaging.MavenJBossPackagingActivator
+Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
+ org.eclipse.core.runtime;bundle-version="3.7.0",
+ org.jboss.tools.maven.core,
+ org.jboss.tools.maven.ui,
+ org.jboss.tools.common.model,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.j2ee,
+ org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.2.100",
+ org.sonatype.m2e.mavenarchiver;bundle-version="0.14.0",
+ org.jboss.ide.eclipse.as.ui.mbeans;bundle-version="2.3.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: plugin
+Export-Package: org.jboss.tools.maven.jbosspackaging,
+ org.jboss.tools.maven.jbosspackaging.configurators
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.html
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.html (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.html 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>JBoss Packaging Maven Configurators</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>JBoss Packaging Maven Configurators</h1>
+
+<p>
+This plugin is part of the JBoss Tools developed by the <a href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a href="http://www.jboss.org/tools">JBoss Tools project page</a></p>
+
+<p>
+This software is distributed under the terms of the Eclipse Public License - v 1.0
+(see <a href="www.eclipse.org/legal/epl-v10.html">Eclipse Public License - Version 1.0</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.ini
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.ini (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.ini 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=jboss_about.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.mappings
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.mappings (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.mappings 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.properties (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/about.properties 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,2 @@
+blurb=JBoss Packaging Maven Configurators\n\nVersion\: {featureVersion}\n\n(c) Copyright JBoss by Red Hat, contributors and others 2004 - 2010. All rights reserved.\nVisit http\://jboss.org/tools
+
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/build.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/build.properties (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/build.properties 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,12 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties,\
+ jboss_about.png,\
+ lifecycle-mapping-metadata.xml
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/jboss_about.png
===================================================================
(Binary files differ)
Property changes on: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/jboss_about.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/lifecycle-mapping-metadata.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/lifecycle-mapping-metadata.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/lifecycle-mapping-metadata.xml 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lifecycleMappingMetadata>
+ <lifecycleMappings>
+ <lifecycleMapping>
+ <packagingType>jboss-sar</packagingType>
+ <lifecycleMappingId>org.jboss.tools.maven.jbosspackaging.SarLifecycleMapping</lifecycleMappingId>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-packaging-maven-plugin</artifactId>
+ <versionRange>[1.0,)</versionRange>
+ <goals>
+ <goal>sar</goal>
+ <goal>sar-exploded</goal>
+ <goal>sar-inplace</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <configurator>
+ <id>org.jboss.tools.maven.jbosspackaging.sarconfigurator</id>
+ </configurator>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-packaging-maven-plugin</artifactId>
+ <versionRange>[1.0,)</versionRange>
+ <goals>
+ <goal>sar</goal>
+ <goal>sar-exploded</goal>
+ <goal>sar-inplace</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <configurator>
+ <id>org.jboss.tools.maven.jbosspackaging.sararchiverconfigurator</id>
+ </configurator>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMapping>
+ </lifecycleMappings>
+</lifecycleMappingMetadata>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.properties (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.properties 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,6 @@
+Bundle-Vendor = JBoss by Red Hat
+Bundle-Name = JBoss Packaging Maven Configurator
+SAR_Project_configurator = SAR
+SAR_MavenArchiver_configurator = SAR Maven Archiver
+Maven_Configuration_Problem=Maven Configuration Problem
+Maven_Configuration_Problems=Maven Configuration Problems
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/plugin.xml 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
+ </extension>
+
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappings">
+ <lifecycleMapping
+ class="org.jboss.tools.maven.jbosspackaging.SarLifecycleMapping"
+ id="org.jboss.tools.maven.jbosspackaging.SarLifecycleMapping"
+ name="SAR Lifecycle mapping">
+ </lifecycleMapping>
+ </extension>
+
+ <extension point="org.eclipse.m2e.core.projectConfigurators">
+ <configurator
+ id="org.jboss.tools.maven.jbosspackaging.sarconfigurator"
+ class="org.jboss.tools.maven.jbosspackaging.configurators.SarProjectConfigurator"
+ name="%SAR_Project_configurator"
+ />
+ </extension>
+ <extension point="org.eclipse.m2e.core.projectConfigurators">
+ <configurator
+ id="org.jboss.tools.maven.jbosspackaging.sararchiverconfigurator"
+ class="org.jboss.tools.maven.jbosspackaging.configurators.SarArchiverConfigurator"
+ name="%SAR_MavenArchiver_configurator"
+ secondaryTo="org.jboss.tools.maven.jbosspackaging.sarconfigurator"
+ />
+ </extension>
+
+ <extension point="org.eclipse.core.resources.markers"
+ id="org.jbosstools.maven.configuration.jboss.sar"
+ name="%Maven_Configuration_Problem">
+ <super type="org.eclipse.m2e.core.maven2Problem.configuration"/>
+ <persistent value="true"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.ide.markerSupport">
+ <markerTypeCategory
+ name="%Maven_Configuration_Problems">
+ <markerTypeReference
+ id="org.jbosstools.maven.configuration.jboss.sar">
+ </markerTypeReference>
+ </markerTypeCategory>
+ </extension>
+</plugin>
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/pom.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/pom.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/pom.xml 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,14 @@
+<?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.maven</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.maven.plugins</groupId>
+ <artifactId>org.jboss.tools.maven.jbosspackaging</artifactId>
+
+ <packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/MavenJBossPackagingActivator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/MavenJBossPackagingActivator.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/MavenJBossPackagingActivator.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.maven.jbosspackaging;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class MavenJBossPackagingActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.maven.jbosspackaging"; //$NON-NLS-1$
+
+ // The shared instance
+ private static MavenJBossPackagingActivator plugin;
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ MavenJBossPackagingActivator.plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ MavenJBossPackagingActivator.plugin = null;
+ super.stop(bundleContext);
+ }
+
+ public static MavenJBossPackagingActivator getDefault() {
+ return plugin;
+ }
+
+ public static void log(Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e);
+ getDefault().getLog().log(status);
+ }
+
+ public static void log(String message) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message);
+ getDefault().getLog().log(status);
+ }
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/SarLifecycleMapping.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/SarLifecycleMapping.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/SarLifecycleMapping.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.maven.jbosspackaging;
+
+import org.eclipse.m2e.core.project.configurator.AbstractCustomizableLifecycleMapping;
+
+/**
+ * @author Fred Bricon
+ */
+public class SarLifecycleMapping extends AbstractCustomizableLifecycleMapping {
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingArchiverConfigurator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingArchiverConfigurator.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingArchiverConfigurator.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,33 @@
+package org.jboss.tools.maven.jbosspackaging.configurators;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
+import org.sonatype.m2e.mavenarchiver.internal.JarArchiverConfigurator;
+
+public abstract class JBossPackagingArchiverConfigurator extends JarArchiverConfigurator {
+
+ @Override
+ protected MojoExecutionKey getExecutionKey() {
+ MojoExecutionKey key = new MojoExecutionKey("org.codehaus.mojo", "jboss-packaging-maven-plugin", "", getGoal(),
+ null, null);
+ return key;
+ }
+
+ protected abstract String getGoal();
+
+ @Override
+ public void generateManifest(IMavenProjectFacade mavenFacade, IFile manifest, IProgressMonitor monitor)
+ throws CoreException {
+ super.generateManifest(mavenFacade, manifest, monitor);
+ }
+
+ @Override
+ protected boolean needsNewManifest(IFile manifest, IMavenProjectFacade oldFacade, IMavenProjectFacade newFacade,
+ IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return super.needsNewManifest(manifest, oldFacade, newFacade, monitor);
+ }
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingPluginConfiguration.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingPluginConfiguration.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/JBossPackagingPluginConfiguration.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,130 @@
+package org.jboss.tools.maven.jbosspackaging.configurators;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+public class JBossPackagingPluginConfiguration {
+
+ private static final String DEFAULT_LIB_DIRECTORY = "/lib";
+
+ protected final MavenProject mavenProject;
+
+ protected Set<String> excludes = null;
+
+ protected Boolean excludeAll;
+
+ protected Boolean removeDependencyVersions;
+
+ protected Xpp3Dom configuration;
+
+ protected String libDirectory;
+
+ public JBossPackagingPluginConfiguration(MavenProject mavenProject) {
+ this.mavenProject = mavenProject;
+ Plugin plugin = mavenProject.getPlugin("org.codehaus.mojo:jboss-packaging-maven-plugin");
+ if (plugin != null) {
+ configuration =(Xpp3Dom) plugin.getConfiguration();
+ }
+ }
+
+
+ public String getLibDirectory() {
+ if (libDirectory == null) {
+ if (configuration != null) {
+ Xpp3Dom libDom = configuration.getChild("libDirectory");
+ if(libDom != null) {
+ libDirectory = libDom.getValue();
+ }
+ }
+ if (StringUtils.isEmpty(libDirectory)) {
+ libDirectory = DEFAULT_LIB_DIRECTORY;
+ }
+ }
+ return libDirectory;
+ }
+
+ public boolean isExcludeAll() {
+ if (excludeAll == null) {
+ if (configuration != null) {
+ Xpp3Dom excludeAllDom = configuration.getChild("excludeAll");
+ if(excludeAllDom != null) {
+ excludeAll = Boolean.valueOf(excludeAllDom.getValue());
+ }
+ }
+ if (excludeAll == null) {
+ excludeAll = Boolean.FALSE;
+ }
+ }
+ return excludeAll.booleanValue();
+ }
+
+ public boolean isRemoveDependencyVersions() {
+ if (removeDependencyVersions == null) {
+ if (configuration != null) {
+ Xpp3Dom removeVersionDom = configuration.getChild("removeDependencyVersions");
+ if(removeVersionDom != null) {
+ removeDependencyVersions = Boolean.valueOf(removeVersionDom.getValue());
+ }
+ }
+ if (removeDependencyVersions == null) {
+ removeDependencyVersions = Boolean.FALSE;
+ }
+ }
+ return removeDependencyVersions.booleanValue();
+ }
+
+ public boolean isExcluded(Artifact artifact) {
+ if (isExcludeAll() || !artifact.getArtifactHandler().isAddedToClasspath()) {
+ return true;
+ }
+ if (getExcludes() != null) {
+ for (String groupIdArtifactId : excludes) {
+ if (groupIdArtifactId.equals(artifact.getGroupId()+":"+artifact.getArtifactId())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private Set<String> getExcludes() {
+ if (excludes == null) {
+ excludes = new HashSet<String>();
+ if (configuration != null) {
+ Xpp3Dom excludesDom = configuration.getChild("excludes");
+ if(excludesDom != null) {
+ for (Xpp3Dom excludeDom : excludesDom.getChildren("exclude")) {
+ if (excludeDom != null) {
+ String exclude = excludeDom.getValue();
+ if (StringUtils.isNotEmpty(exclude)) {
+ excludes.add(exclude);
+ }
+ }
+ }
+ }
+ }
+ }
+ return excludes;
+ }
+
+
+ public String mapFileName(Artifact artifact) {
+ StringBuilder fileName = new StringBuilder(artifact.getArtifactId());
+ String classifier = artifact.getClassifier();
+ if (classifier != null) {
+ fileName.append("-").append(classifier);
+ }
+ if (!isRemoveDependencyVersions()) {
+ fileName.append("-").append(artifact.getVersion());
+ }
+ fileName.append(".").append(artifact.getArtifactHandler().getExtension());
+ return fileName.toString();
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/MavenSarConstants.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/MavenSarConstants.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/MavenSarConstants.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,11 @@
+package org.jboss.tools.maven.jbosspackaging.configurators;
+
+public class MavenSarConstants {
+
+ public static final String SAR_CONFIGURATION_ERROR_MARKER_ID = "org.jbosstools.maven.configuration.jboss.sar";
+ /**
+ * Private constructor to prevent instanciation.
+ */
+ private MavenSarConstants() {}
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/ResourceCleaner.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/ResourceCleaner.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/ResourceCleaner.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * 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
+ *******************************************************************************/
+
+package org.jboss.tools.maven.jbosspackaging.configurators;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+/**
+ * ResourceCleaner
+ *
+ * @author Fred Bricon
+ */
+public class ResourceCleaner {
+
+ private final IProject project;
+
+ private Map<IFolder, Boolean> folders = new LinkedHashMap<IFolder, Boolean>();
+
+ private Map<IFile, Boolean> files = new LinkedHashMap<IFile, Boolean>();
+
+ private Set<IFolder> keepers = new HashSet<IFolder>();
+
+ /**
+ * @param project
+ */
+ public ResourceCleaner(IProject project) {
+ this.project = project;
+ }
+
+ public ResourceCleaner(IProject project, IFolder ... foldersToKeep) {
+ this.project = project;
+ if (foldersToKeep != null) {
+ for (IFolder folder : foldersToKeep) {
+ if (folder != null) {
+ keepers.add(folder);
+ IContainer parent = folder.getParent();
+ while (parent instanceof IFolder) {
+ keepers.add((IFolder)parent);
+ parent = parent.getParent();
+ }
+ }
+ }
+ }
+ }
+
+
+ public void addFolder(IPath folderPath, boolean deleteEmptyParents) {
+ if (folderPath == null) {
+ return;
+ }
+ addFolder(project.getFolder(folderPath), deleteEmptyParents);
+ }
+
+
+ public void addFolders(Collection<IPath> folderPaths) {
+ if (folderPaths == null) {
+ return;
+ }
+ for (IPath path : folderPaths) {
+ addFolder(path, false);
+ }
+ }
+
+ public void addFolder(IFolder folder, boolean deleteEmptyParents) {
+ if (folder != null && !folder.exists()) {
+ folders.put(folder, deleteEmptyParents);
+ addInexistentParentFolders(folder);
+ }
+ }
+
+ public void addFiles(IPath ... filePaths) {
+ if (filePaths == null) {
+ return;
+ }
+ for (IPath fileName : filePaths) {
+ IFile fileToDelete = project.getFile(fileName);
+ if (!fileToDelete.exists()) {
+ files.put(fileToDelete, false);
+ addInexistentParentFolders(fileToDelete);
+ }
+ }
+ }
+
+ public void cleanUp() throws CoreException {
+ IProgressMonitor monitor = new NullProgressMonitor();
+ for (IFile file : files.keySet()) {
+ if (file.exists()) {
+ file.delete(true, monitor);
+ }
+ }
+ for (IFolder folder : folders.keySet()) {
+ if (folder.exists() && folder.members().length == 0) {
+ folder.delete(true, monitor);
+ }
+ }
+ }
+
+ protected void addInexistentParentFolders(IResource resource) {
+ IContainer parent = resource.getParent();
+ IFolder firstInexistentParent = null;
+ while (parent instanceof IFolder) {
+ if (keepers.contains(parent)
+ || parent.exists()) {
+ break;
+ }
+ firstInexistentParent = (IFolder)parent;
+ parent = parent.getParent();
+ }
+ if (firstInexistentParent != null) {
+ folders.put(firstInexistentParent, true);
+ }
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarArchiverConfigurator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarArchiverConfigurator.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarArchiverConfigurator.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,14 @@
+package org.jboss.tools.maven.jbosspackaging.configurators;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+public class SarArchiverConfigurator extends JBossPackagingArchiverConfigurator {
+
+ @Override
+ protected String getGoal() {
+ return "sar";
+ }
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarProjectConfigurator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarProjectConfigurator.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.jbosspackaging/src/org/jboss/tools/maven/jbosspackaging/configurators/SarProjectConfigurator.java 2011-08-12 23:32:23 UTC (rev 33872)
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * 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.maven.jbosspackaging.configurators;
+
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+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.Path;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
+import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
+import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
+import org.eclipse.m2e.jdt.internal.MavenClasspathHelpers;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.ide.eclipse.as.ui.mbeans.project.IJBossSARFacetDataModelProperties;
+import org.jboss.ide.eclipse.as.ui.mbeans.project.JBossSARFacetDataModelProvider;
+import org.jboss.tools.maven.core.IJBossMavenConstants;
+import org.jboss.tools.maven.core.internal.project.facet.MavenFacetInstallDataModelProvider;
+import org.maven.ide.eclipse.wtp.ArtifactHelper;
+import org.maven.ide.eclipse.wtp.ResourceCleaner;
+import org.maven.ide.eclipse.wtp.WTPProjectsUtil;
+
+/**
+ *
+ * @author Fred Bricon
+ *
+ */
+public class SarProjectConfigurator extends AbstractProjectConfigurator {
+
+ public static final IProjectFacet JBOSS_SAR_FACET;
+ public static final IProjectFacetVersion JBOSS_SAR_FACET_VERSION_1_0;
+ public static final ArtifactFilter SCOPE_FILTER_RUNTIME = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+ protected static final IProjectFacet m2Facet;
+ protected static final IProjectFacetVersion m2Version;
+ private static final IClasspathAttribute NONDEPENDENCY_ATTRIBUTE = JavaCore.newClasspathAttribute(
+ IClasspathDependencyConstants.CLASSPATH_COMPONENT_NON_DEPENDENCY, "");
+ static {
+ JBOSS_SAR_FACET = ProjectFacetsManager.getProjectFacet("jst.jboss.sar");
+ JBOSS_SAR_FACET_VERSION_1_0 = JBOSS_SAR_FACET.getVersion("1.0");//$NON-NLS-1$
+ m2Facet = ProjectFacetsManager.getProjectFacet("jboss.m2"); //$NON-NLS-1$
+ m2Version = m2Facet.getVersion("1.0"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
+
+ MavenProject mavenProject = request.getMavenProject();
+ IProject project = request.getProject();
+
+ markerManager.deleteMarkers(project, MavenSarConstants.SAR_CONFIGURATION_ERROR_MARKER_ID);
+
+ if (!getExpectedPackage().equals(mavenProject.getPackaging())) {
+ return;
+ }
+
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
+
+ Set<Action> actions = new LinkedHashSet<Action>();
+
+ IMavenProjectFacade facade = request.getMavenProjectFacade();
+
+ ResourceCleaner fileCleaner = new ResourceCleaner(project);
+ addFilesToClean(fileCleaner, facade.getResourceLocations());
+ addFilesToClean(fileCleaner, facade.getTestResourceLocations());
+ addFilesToClean(fileCleaner, facade.getCompileSourceLocations());
+ addFilesToClean(fileCleaner, facade.getTestCompileSourceLocations());
+
+ IPath source = facade.getResourceLocations()[0];
+
+ WTPProjectsUtil.installJavaFacet(actions, project, facetedProject);
+ if (!actions.isEmpty()) {
+ facetedProject.modify(actions, monitor);
+ }
+ installSarFacet(facetedProject, source, monitor);
+
+ installM2Facet(facetedProject, monitor);
+
+ ModuleCoreNature.addModuleCoreNatureIfNecessary(project, monitor);
+
+ WTPProjectsUtil.removeTestFolderLinks(project, mavenProject, monitor, "/");
+
+ setNonDependencyAttributeToContainer(project, monitor);
+
+ WTPProjectsUtil.removeWTPClasspathContainer(project);
+
+ fileCleaner.cleanUp();
+ }
+
+ private void installM2Facet(IFacetedProject fproj, IProgressMonitor monitor) throws CoreException {
+ if (!fproj.hasProjectFacet(m2Facet)) {
+ IDataModel config = (IDataModel) new MavenFacetInstallDataModelProvider().create();
+ config.setBooleanProperty(IJBossMavenConstants.MAVEN_PROJECT_EXISTS, true);
+ fproj.installProjectFacet(m2Version, config, monitor);
+ }
+ }
+
+ private void installSarFacet(IFacetedProject fproj, IPath source, IProgressMonitor monitor) throws CoreException {
+ if (!fproj.hasProjectFacet(JBOSS_SAR_FACET)) {
+ IProjectFacetVersion facetVersion = JBOSS_SAR_FACET_VERSION_1_0;
+ IStatus status = facetVersion.getConstraint().check(fproj.getProjectFacets());
+ if (status.isOK()) {
+ IDataModel config = (IDataModel) new JBossSARFacetDataModelProvider().create();
+ config.setProperty(IJBossSARFacetDataModelProperties.SAR_CONTENT_FOLDER, source.toPortableString());
+ fproj.installProjectFacet(facetVersion, config, monitor);
+ } else {
+ addErrorMarker(fproj.getProject(), facetVersion + " can not be installed : "+ status.getMessage());
+ for (IStatus st : status.getChildren()) {
+ addErrorMarker(fproj.getProject(), st.getMessage());
+ }
+ }
+ }
+ }
+
+ private void addErrorMarker(IProject project, String message) {
+ markerManager.addMarker(project,
+ MavenSarConstants.SAR_CONFIGURATION_ERROR_MARKER_ID,
+ message
+ ,-1, IMarker.SEVERITY_ERROR);
+ }
+
+ protected String getExpectedPackage() {
+ return "jboss-sar";
+ }
+
+
+ public void setModuleDependencies(IProject project, MavenProject mavenProject, IProgressMonitor monitor)
+ throws CoreException {
+
+ IVirtualComponent sarComponent = ComponentCore.createComponent(project);
+ if (sarComponent == null) {
+ return;
+ }
+
+ Set<IVirtualReference> newRefs = new LinkedHashSet<IVirtualReference>();
+
+ JBossPackagingPluginConfiguration config = new JBossPackagingPluginConfiguration(mavenProject);
+
+ if (!config.isExcludeAll()) {
+ Set<Artifact> artifacts = mavenProject.getArtifacts();
+
+ for (Artifact artifact : artifacts) {
+ // Don't deploy pom, non runtime or optional dependencies
+ if ("pom".equals(artifact.getType()) || !SCOPE_FILTER_RUNTIME.include(artifact)
+ || artifact.isOptional() || config.isExcluded(artifact)) {
+ continue;
+ }
+
+ IMavenProjectFacade workspaceDependency = projectManager.getMavenProject(artifact.getGroupId(),
+ artifact.getArtifactId(), artifact.getVersion());
+
+ IVirtualComponent depComponent;
+ if (workspaceDependency != null && !workspaceDependency.getProject().equals(project)
+ && workspaceDependency.getFullPath(artifact.getFile()) != null) {
+ // artifact dependency is a workspace project
+ depComponent = ComponentCore.createComponent(workspaceDependency.getProject());
+ } else {
+ // artifact dependency should be added as a JEE module,
+ // referenced with M2_REPO variable
+ String artifactPath = ArtifactHelper.getM2REPOVarPath(artifact);
+ depComponent = ComponentCore.createArchiveComponent(sarComponent.getProject(), artifactPath);
+ }
+ IVirtualReference reference = ComponentCore.createReference(sarComponent, depComponent);
+ reference.setArchiveName(config.mapFileName(artifact));
+ reference.setRuntimePath(new Path(config.getLibDirectory()));
+ newRefs.add(reference);
+ }
+ }
+ IVirtualReference[] newRefsArray = new IVirtualReference[newRefs.size()];
+ newRefs.toArray(newRefsArray);
+
+ // Only change the project references if they've changed
+ if (WTPProjectsUtil.hasChanged(sarComponent.getReferences(), newRefsArray)) {
+ sarComponent.setReferences(newRefsArray);
+ }
+ }
+
+ protected void setNonDependencyAttributeToContainer(IProject project, IProgressMonitor monitor)
+ throws JavaModelException {
+ updateContainerAttributes(project, NONDEPENDENCY_ATTRIBUTE,
+ IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY, monitor);
+ }
+
+ protected void updateContainerAttributes(IProject project, IClasspathAttribute attributeToAdd,
+ String attributeToDelete, IProgressMonitor monitor) throws JavaModelException {
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject == null)
+ return;
+ IClasspathEntry[] cp = javaProject.getRawClasspath();
+ for (int i = 0; i < cp.length; i++) {
+ if (IClasspathEntry.CPE_CONTAINER == cp[i].getEntryKind()
+ && MavenClasspathHelpers.isMaven2ClasspathContainer(cp[i].getPath())) {
+ LinkedHashMap<String, IClasspathAttribute> attrs = new LinkedHashMap<String, IClasspathAttribute>();
+ for (IClasspathAttribute attr : cp[i].getExtraAttributes()) {
+ if (!attr.getName().equals(attributeToDelete)) {
+ attrs.put(attr.getName(), attr);
+ }
+ }
+ attrs.put(attributeToAdd.getName(), attributeToAdd);
+ IClasspathAttribute[] newAttrs = attrs.values().toArray(new IClasspathAttribute[attrs.size()]);
+ cp[i] = JavaCore.newContainerEntry(cp[i].getPath(), cp[i].getAccessRules(), newAttrs,
+ cp[i].isExported());
+ break;
+ }
+ }
+ javaProject.setRawClasspath(cp, monitor);
+ }
+
+ @Override
+ public void mavenProjectChanged(MavenProjectChangedEvent event, IProgressMonitor monitor) throws CoreException {
+ setModuleDependencies(event.getMavenProject().getProject(), event.getMavenProject().getMavenProject(), monitor);
+ }
+
+ private void addFilesToClean(ResourceCleaner cleaner, IPath[] paths) {
+ for (IPath resourceFolderPath : paths) {
+ cleaner.addFiles(resourceFolderPath.append("META-INF/MANIFEST.MF"));
+ }
+ }
+
+}
Modified: trunk/maven/plugins/pom.xml
===================================================================
--- trunk/maven/plugins/pom.xml 2011-08-12 22:08:25 UTC (rev 33871)
+++ trunk/maven/plugins/pom.xml 2011-08-12 23:32:23 UTC (rev 33872)
@@ -22,6 +22,7 @@
<module>org.jboss.tools.maven.portlet</module>
<module>org.jboss.tools.maven.project.examples</module>
<module>org.jboss.tools.maven.jaxrs</module>
+ <module>org.jboss.tools.maven.jbosspackaging</module>
</modules>
</project>
14 years, 8 months
JBoss Tools SVN: r33871 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/project.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2011-08-12 18:08:25 -0400 (Fri, 12 Aug 2011)
New Revision: 33871
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/project/JBossSARFacetInstallationDelegate.java
Log:
JBIDE-9497 : Make sure parent folders exist / are created when creating the META-INF folder
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/project/JBossSARFacetInstallationDelegate.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/project/JBossSARFacetInstallationDelegate.java 2011-08-12 22:05:46 UTC (rev 33870)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/project/JBossSARFacetInstallationDelegate.java 2011-08-12 22:08:25 UTC (rev 33871)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.ui.mbeans.project;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -18,6 +19,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
@@ -71,7 +73,7 @@
final IVirtualFolder jbiRoot = newComponent.getRootFolder();
- // Map the esbcontent to root for deploy
+ // Map the sarcontent to root for deploy
String resourcesFolder = model.getStringProperty(
IJBossSARFacetDataModelProperties.SAR_CONTENT_FOLDER);
jbiRoot.createLink(new Path("/" + resourcesFolder), 0, null); //$NON-NLS-1$
@@ -120,12 +122,26 @@
e.printStackTrace();
}
- IFolder esbContent = project.getFolder(strContentFolder);
- if(!esbContent.exists()) {
- esbContent.create(true, true, null);
- }
-
- esbContent.getFolder(IJBossSARFacetDataModelProperties.META_INF).create(true, true, null);
+ IFolder sarContent = project.getFolder(strContentFolder);
+ IProgressMonitor monitor = new NullProgressMonitor();
+ createFolder(sarContent.getFolder(IJBossSARFacetDataModelProperties.META_INF), monitor);
project.refreshLocal(IResource.DEPTH_ZERO, null);
}
+
+ /**
+ * Creates the underlying folder if it doesn't exist.
+ * It also recursively creates parent folders if necessary
+ * @param folder the folder to create
+ * @throws CoreException
+ */
+ //TODO Check if that kind of method exists elsewhere to avoid duplication
+ private void createFolder(IFolder folder, IProgressMonitor monitor) throws CoreException {
+ if(!folder.exists()) {
+ IContainer parent = folder.getParent();
+ if(parent != null && !parent.exists()) {
+ createFolder((IFolder) parent, monitor);
+ }
+ folder.create(true, true, monitor);
+ }
+ }
}
14 years, 8 months
JBoss Tools SVN: r33870 - in trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp: contentassist/computers and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2011-08-12 18:05:46 -0400 (Fri, 12 Aug 2011)
New Revision: 33870
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/AbstractXmlCompletionProposalComputer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlTagCompletionProposalComputer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/FaceletTagInfoHoverProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
Log:
(JBIDE-9501) Some JST/VPE editos classes use deprecated content assist processors code
Deprecated classes were removed
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -1,1245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.jsp.contentassist;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.jboss.tools.common.el.core.model.ELInstance;
-import org.jboss.tools.common.el.core.model.ELInvocationExpression;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.model.ELUtil;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.el.core.resolver.ELResolver;
-import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.internal.KbProject;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-@Deprecated
-@SuppressWarnings("restriction")
-abstract public class AbstractXMLContentAssistProcessor extends AbstractContentAssistProcessor {
- private static final char[] PROPOSAL_AUTO_ACTIVATION_CHARS = new char[] {
- '<', '=', '"', '\'', '.', '{'
- };
-
- private IDocument fDocument;
- private int fDocumentPosition;
- private ELContext fContext;
-
- protected final static ICompletionProposal[] EMPTY_PROPOSAL_LIST = new ICompletionProposal[0];
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
- */
- @Override
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
- int offset) {
- this.fDocument = (viewer == null ? null : viewer.getDocument());
- this.fDocumentPosition = offset;
- this.fContext = createContext();
-
- IFile resource = fContext == null ? null : fContext.getResource();
- KbProject.checkKBBuilderInstalled(resource);
- return super.computeCompletionProposals(viewer, offset);
- }
-
- /**
- * The reason of overriding is that the method returns wrong region in case of incomplete tag (a tag with no '>'-closing char)
- * In this case we have to return that previous incomplete tag instead of the current tag)
- */
- public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- IStructuredDocumentRegion sdRegion = null;
- if (fDocument == null)
- return null;
-
- int lastOffset = pos;
- IStructuredDocument doc = (IStructuredDocument) fDocument;
-
- do {
- sdRegion = doc.getRegionAtCharacterOffset(lastOffset);
- if (sdRegion != null) {
- ITextRegion region = sdRegion.getRegionAtCharacterOffset(lastOffset);
- if (region != null && region.getType() == DOMRegionContext.XML_TAG_OPEN &&
- sdRegion.getStartOffset(region) == lastOffset) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) && (sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
-// sdRegion = sdRegion.getPrevious();
- sdRegion = null;
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(lastOffset - 1);
- if ((previousRegion != null) && (previousRegion != region) && (previousRegion.getTextLength() == previousRegion.getLength())) {
-// sdRegion = sdRegion.getPrevious();
- sdRegion = null;
- }
- }
- }
- }
- lastOffset--;
- } while (sdRegion == null && lastOffset >= 0);
- return sdRegion;
- }
-
- /**
- * The reason of overriding is that the method returns wrong region in case of incomplete tag (a tag with no '>'-closing char)
- * In this case we have to return that previous incomplete tag instead of the current tag)
- */
- protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
- if (domnode == null) {
- return null;
- }
- // Get the original WTP Structured Document Region
- IStructuredDocumentRegion sdNormalRegion = super.getStructuredDocumentRegion(documentPosition);
- // Get Fixed Structured Document Region
- IStructuredDocumentRegion sdFixedRegion = this.getStructuredDocumentRegion(documentPosition);
-
- // If original and fixed regions are different we have to replace domnode with its parent node
- if (sdFixedRegion != null && !sdFixedRegion.equals(sdNormalRegion)) {
- Node prevnode = domnode.getParentNode();
- if (prevnode != null) {
- domnode = prevnode;
- }
- }
-
- return super.getCompletionRegion(documentPosition, domnode);
- }
-
- protected ITextRegion getCompletionRegion(int offset, IStructuredDocumentRegion sdRegion) {
- ITextRegion region = super.getCompletionRegion(offset, sdRegion);
- if (region != null && region.getType() == DOMRegionContext.UNDEFINED) {
- // FIX: JBIDE-2332 CA with proposal list for comonent's atributes doesn't work before double quotes.
- // Sometimes, especially if we have a broken XML node, the region returned has UNDEFINED type.
- // If so, we're try to use the prevoius region, which probably will be the region of type XML_TAG_NAME.
-
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(offset - 1);
- if ((previousRegion != null) && (previousRegion != region) && (previousRegion.getTextLength() < previousRegion.getLength())) {
- region = previousRegion;
- }
- }
- return region;
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#computeTagNameProposals(int, java.lang.String, org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion, org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode, org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)
- */
- protected ContentAssistRequest computeTagNameProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()) {
- // completing the *first* tag in "<tagname1 |<tagname2"
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- if (actualNode != null) {
- if (actualNode.getFirstStructuredDocumentRegion() == sdRegion) {
- // start tag
- if ((documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) &&
- (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength())){
- // it's attributes
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- if (node.getStructuredDocument().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getType() == DOMRegionContext.XML_TAG_OPEN) {
- addAttributeNameProposals(contentAssistRequest);
- }
- addTagCloseProposals(contentAssistRequest);
- }
- else {
- // it's name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(actualNode));
- }
- }
- else {
- if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // insert name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // replace name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest);
- }
- }
- }
- else {
- if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
- // unclosed tag with only a name; should prompt for attributes
- // and a close instead
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- addAttributeNameProposals(contentAssistRequest);
- addTagCloseProposals(contentAssistRequest);
- }
- else {
- if (sdRegion.getRegions().get(0).getType() != DOMRegionContext.XML_END_TAG_OPEN) {
- int replaceLength = documentPosition - sdRegion.getStartOffset(completionRegion);
- contentAssistRequest = newContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), replaceLength, matchString);
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- }
- else {
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(documentPosition);
- if (actualNode != null) {
- if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest);
- }
- }
- }
- }
- return contentAssistRequest;
- }
-
- private int getElementPositionForModelQuery(Node child) {
- return getElementPosition(child);
- // return -1;
- }
- /**
- * Helper method to reuse functionality for getting context when no proposals are needed.
- * @param viewer
- * @param offset
- */
- public void createContext(ITextViewer viewer, int offset) {
- this.fDocument = (viewer == null ? null : viewer.getDocument());
- this.fDocumentPosition = offset;
- this.fContext = createContext();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
- */
- @Override
- public IContextInformation[] computeContextInformation(ITextViewer viewer,
- int offset) {
- this.fDocument = (viewer == null ? null : viewer.getDocument());
- this.fDocumentPosition = offset;
- this.fContext = createContext();
-
- return super.computeContextInformation(viewer, offset);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#getMatchString(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion, org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion, int)
- */
- @Override
- protected String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
- if (aRegion == null) return ""; //$NON-NLS-1$
- String matchString = super.getMatchString(parent, aRegion, offset);
- String regionType = aRegion.getType();
- if(regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && matchString.startsWith("\"")) { //$NON-NLS-1$
- matchString = matchString.substring(1);
- }
- return matchString;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- @Override
- public char[] getCompletionProposalAutoActivationCharacters() {
- return PROPOSAL_AUTO_ACTIVATION_CHARS;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- @Override
- public char[] getContextInformationAutoActivationCharacters() {
- return super.getContextInformationAutoActivationCharacters();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#getContextInformationValidator()
- */
- @Override
- public IContextInformationValidator getContextInformationValidator() {
- return super.getContextInformationValidator();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#getErrorMessage()
- */
- @Override
- public String getErrorMessage() {
- return super.getErrorMessage();
- }
-
-
-
- /* the methods to be overriden in derived classes */
-
-
-
- /**
- * Calculates and adds the attribute name proposals to the Content Assist Request object
- */
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- }
-
- /**
- * Calculates and adds the attribute value proposals to the Content Assist Request object
- */
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
-// System.out.println("AbstractXMLContentAssistProcessor: addAttributeValueProposals() invoked"); //$NON-NLS-1$
-/*
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
-
- // Find the attribute region and name for which this position should
- // have a value proposed
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if (i < 0) {
- return;
- }
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- break;
- }
- }
-
- // the name region is REQUIRED to do anything useful
- if (nameRegion != null) {
- // Retrieve the declaration
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
-
- // String attributeName = nameRegion.getText();
- String attributeName = open.getText(nameRegion);
- String currentValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();
- String currentValueText = ((IDOMAttr)node.getAttributes().getNamedItem(attributeName)).getValueRegionText();
- ITextRegion currentValueRegion = ((IDOMAttr)node.getAttributes().getNamedItem(attributeName)).getValueRegion();
-
-
-
- ITextRegion invokeRegion = contentAssistRequest.getRegion();
- int pos = contentAssistRequest.getRegion().getStart();
- int replBegin = contentAssistRequest.getReplacementBeginPosition();
- int invokeRegionEnd = invokeRegion.getStart() + invokeRegion.getLength();
- IDOMAttr attrNode = (IDOMAttr)node.getAttributes().getNamedItem(attributeName);
- int valueRegionStartOffset = attrNode.getValueRegionStartOffset();
- ITextRegion eqRegion = attrNode.getEqualRegion();
- int eqRegionEnd= eqRegion.getStart() + eqRegion.getLength();
- int attrValueEnd=eqRegionEnd + currentValueText.length();
- int attrTextEnd = invokeRegion.getTextEnd();
- // attrNode.getValueRegionText()
- }
- else {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
- */
- }
-
- /*
- * Calculates and adds the comment proposals to the Content Assist Request object
- */
- protected void addCommentProposal(ContentAssistRequest contentAssistRequest) {
- }
-
- /*
- * Calculates and adds the doc type proposals to the Content Assist Request object
- */
- protected void addDocTypeProposal(ContentAssistRequest contentAssistRequest) {
- }
-
- /*
- * Calculates and adds the empty document proposals to the Content Assist Request object
- */
- protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
- }
-
- /*
- * Calculates and adds the tag name proposals to the Content Assist Request object
- */
- protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest) {
- }
-
- /*
- * Calculates and adds the end tag proposals to the Content Assist Request object
- */
- protected void addEndTagProposals(ContentAssistRequest contentAssistRequest) {
- }
-
- /*
- * Calculates and adds the enttity proposals to the Content Assist Request object
- */
- protected void addEntityProposals(ContentAssistRequest contentAssistRequest, int documentPosition, ITextRegion completionRegion, IDOMNode treeNode) {
- super.addEntityProposals(contentAssistRequest, documentPosition, completionRegion, treeNode);
- }
-
- /*
- * Calculates and adds the PCDATA proposals to the Content Assist Request object
- */
- protected void addPCDATAProposal(String nodeName, ContentAssistRequest contentAssistRequest) {
- }
-
- /*
- * Calculates and adds the start document proposals to the Content Assist Request object
- */
- protected void addStartDocumentProposals(ContentAssistRequest contentAssistRequest) {
- }
-
- /*
- * Calculates and adds the tag close proposals to the Content Assist Request object
- *
- */
- protected void addTagCloseProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- int contentType = CMElementDeclaration.ANY;
- // if it's XML and content doesn't HAVE to be element, add "/>"
- // proposal.
- boolean endWithSlashBracket = (getXML(node) && (contentType != CMElementDeclaration.ELEMENT));
-
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
-
- // is the start tag ended properly?
- if ((contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion()) && !(node.getFirstStructuredDocumentRegion()).isEnded()) {
- setErrorMessage(null);
- // prompt with a close for the start tag
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, ">", //$NON-NLS-1$
- getOffset(),
- 0, 2, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, null, TextProposal.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
-
- // prompt with the closer for the start tag and an end tag
- // if one is not present
- if (node.getEndStructuredDocumentRegion() == null) {
- // make sure tag name is actually what it thinks it
- // is...(eg. <%@ vs. <jsp:directive)
- IStructuredDocumentRegion sdr = contentAssistRequest.getDocumentRegion();
- String openingTagText = (sdr != null) ? sdr.getFullText() : ""; //$NON-NLS-1$
- if ((openingTagText != null) && (openingTagText.indexOf(node.getNodeName()) != -1)) {
- proposal = new AutoContentAssistantProposal(true, "></" + node.getNodeName() + ">", //$NON-NLS-2$//$NON-NLS-1$
- getOffset(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[]{node.getNodeName()})), null, null, TextProposal.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- // prompt with slash bracket "/>" incase if it's a self
- // ending tag
- if (endWithSlashBracket) {
- proposal = new AutoContentAssistantProposal(true, "/>", //$NON-NLS-1$
- getOffset(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" \"/>\""})), //$NON-NLS-1$
- null, null, TextProposal.R_CLOSE_TAG + 1); // +1 to bring to top of list
- contentAssistRequest.addProposal(proposal);
- }
- }
- else if ((contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion()) && !node.getLastStructuredDocumentRegion().isEnded()) {
- setErrorMessage(null);
- // prompt with a closing end character for the end tag
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, ">", //$NON-NLS-1$
- getOffset(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, null, TextProposal.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
- }
-
- /*
- * Calculates and adds the tag insertion proposals to the Content Assist Request object
- */
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- }
-
- /**
- * Calculates and adds the tag name proposals to the Content Assist Request object
- *
- * @param contentAssistRequest
- * @param childPosition
- */
- abstract protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int childPosition);
-
-
- /**
- * Calculates and adds the EL proposals in attribute value to the Content Assist Request object
- *
- * @param contentAssistRequest
- */
- abstract protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest);
-
- /**
- * Calculates and adds the EL proposals in text to the Content Assist Request object
- *
- * @param contentAssistRequest
- */
- abstract protected void addTextELProposals(ContentAssistRequest contentAssistRequest);
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor#computeCompletionProposals(int, java.lang.String, org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion, org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode, org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)
- */
- protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) {
- ContentAssistRequest contentAssistRequest = super.computeCompletionProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- if (contentAssistRequest == null) {
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- contentAssistRequest = newContentAssistRequest((Node) treeNode, treeNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
- }
-
- String regionType = completionRegion.getType();
-
- /*
- * Jeremy: Add attribute name proposals before empty tag close
- */
- if ((xmlnode.getNodeType() == Node.ELEMENT_NODE) || (xmlnode.getNodeType() == Node.DOCUMENT_NODE)) {
- if (regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- addAttributeNameProposals(contentAssistRequest);
- } else if ((regionType == DOMRegionContext.XML_CONTENT)
- || (regionType == DOMRegionContext.XML_CHAR_REFERENCE)
- || (regionType == DOMRegionContext.XML_ENTITY_REFERENCE)
- || (regionType == DOMRegionContext.XML_PE_REFERENCE)
- || (regionType == DOMRegionContext.BLOCK_TEXT)
- || (regionType == DOMRegionContext.XML_END_TAG_OPEN)) {
- addTextELProposals(contentAssistRequest);
- }
- }
-
- return contentAssistRequest;
- }
-
-
- protected ContentAssistRequest computeAttributeValueProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = super.computeAttributeValueProposals(documentPosition, matchString, completionRegion, nodeAtOffset, node);
-
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if ((documentPosition <= sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) ||
- (sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() == sdRegion.getStartOffset(completionRegion) + completionRegion.getLength())) {
- // setup to replace the existing value
- if (nodeAtOffset.getFirstStructuredDocumentRegion().isEnded() || (documentPosition >= sdRegion.getStartOffset(completionRegion))) {
- addAttributeValueELProposals(contentAssistRequest);
- }
- }
- return contentAssistRequest;
- }
-
- /**
- * Creates and fulfills the <code>org.jboss.tools.common.el.core.resolver.ELContext</code>
- * instance
- *
- * @return
- */
- abstract protected ELContext createContext();
-
-
- /**
- * Creates and fulfills the <code>org.jboss.tools.jst.web.kb.KbQuery</code>
- * instance
- * Important: the Context is to be set before any call to createKbQuery
- *
- * @return
- */
-
- /**
- * Returns the <code>org.jboss.tools.jst.web.kb.KbQuery</code> instance. The prefix and URI for the tags
- * are calculated from the current node
- *
- * @param type One of the <code>org.jboss.tools.jst.web.kb.KbQuery.Type</code> values
- * @param query The value for query
- * @param stringQuery the full text of the query value
- *
- * @return The <code>org.jboss.tools.jst.web.kb.KbQuery</code> instance
- */
- abstract protected KbQuery createKbQuery(Type type, String query, String stringQuery);
-
- /**
- * Returns the <code>org.jboss.tools.jst.web.kb.KbQuery</code> instance
- *
- * @param type One of the <code>org.jboss.tools.jst.web.kb.KbQuery.Type</code> values
- * @param query The value for query
- * @param prefix the prefix for the tag
- * @param uri the URI for the tag
- *
- * @return The <code>org.jboss.tools.jst.web.kb.KbQuery</code> instance
- */
- abstract protected KbQuery createKbQuery(Type type, String query, String stringQuery, String prefix, String uri);
-
- /**
- * Returns the <code>org.jboss.tools.common.el.core.resolver.ELContext</code> instance
- *
- * @return
- */
- protected ELContext getContext() {
- return this.fContext;
- }
-
- /**
- * Returns the document position where the CA is invoked
- * @return
- */
- protected int getOffset() {
- return this.fDocumentPosition;
- }
-
- /**
- * Returns the document
- *
- * @return
- */
- protected IDocument getDocument() {
- return this.fDocument;
- }
-
- /**
- * Returns IFile resource of the document
- *
- * @return
- */
- protected IFile getResource() {
- IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- try {
- if (sModel != null) {
- String baseLocation = sModel.getBaseLocation();
- IPath location = new Path(baseLocation).makeAbsolute();
- return FileBuffers.getWorkspaceFileAtLocation(location);
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- return null;
- }
-
- /**
- * Returns array of the <code>org.jboss.tools.common.el.core.resolver.ELResolver</code>
- * instances.
- *
- * @param resource
- * @return
- */
- protected ELResolver[] getELResolvers(IResource resource) {
- if (resource == null)
- return null;
-
- ELResolverFactoryManager elrfm = ELResolverFactoryManager.getInstance();
- return elrfm.getResolvers(resource);
- }
-
- private static final String[] EMPTY_TAGS = new String[0];
- /**
- * Returns array of the parent tags
- *
- * @return
- */
- public String[] getParentTags(boolean includeThisTag) {
- List<String> parentTags = new ArrayList<String>();
-
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
- try {
- if (sModel == null)
- return EMPTY_TAGS;
-
- Document xmlDocument = (sModel instanceof IDOMModel)
- ? ((IDOMModel) sModel).getDocument()
- : null;
-
- if (xmlDocument == null)
- return EMPTY_TAGS;
-
-
- Node n = null;
- if (includeThisTag) {
- n = findNodeForOffset(xmlDocument, getOffset());
- } else {
- // Get Fixed Structured Document Region
- IStructuredDocumentRegion sdFixedRegion = this.getStructuredDocumentRegion(getOffset());
- if (sdFixedRegion == null)
- return EMPTY_TAGS;
-
- n = findNodeForOffset(xmlDocument, sdFixedRegion.getStartOffset());
- }
- if (n == null)
- return EMPTY_TAGS;
-
- // Find the first parent tag
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- } else {
- n = n.getParentNode();
- }
- } else if (!includeThisTag) {
- n = n.getParentNode();
- }
-
- // Store all the parents
- while (n != null && n instanceof Element) {
- String tagName = getTagName(n);
- parentTags.add(0, tagName);
- n = n.getParentNode();
- }
-
- return (String[])parentTags.toArray(new String[parentTags.size()]);
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- protected String getTagName(Node tag) {
- return tag.getNodeName();
- }
-
- /**
- * Returns name of the parent attribute/tag name
- *
- * @return
- */
- protected String getParent(boolean returnAttributeName, boolean returnThisElement) {
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
- try {
- if (sModel == null)
- return null;
-
- Document xmlDocument = (sModel instanceof IDOMModel)
- ? ((IDOMModel) sModel).getDocument()
- : null;
-
- if (xmlDocument == null)
- return null;
-
- Node n = null;
- if (returnAttributeName) {
- n = findNodeForOffset(xmlDocument, getOffset());
- } else {
- // Get Fixed Structured Document Region
- IStructuredDocumentRegion sdFixedRegion = this.getStructuredDocumentRegion(getOffset());
- if (sdFixedRegion == null)
- return null;
-
- n = findNodeForOffset(xmlDocument, sdFixedRegion.getStartOffset());
- }
-
- if (n == null)
- return null;
-
- // Find the first parent tag
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- if (returnAttributeName) {
- String parentAttrName = n.getNodeName();
- return parentAttrName;
- }
- n = ((Attr) n).getOwnerElement();
- } else {
- n = n.getParentNode();
- }
- } else {
- if (!returnThisElement)
- n = n.getParentNode();
- }
- if (n == null)
- return null;
-
- String parentTagName = getTagName(n);
- return parentTagName;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- /**
- * Returns URI for the current/parent tag
- * @return
- */
- public String getTagPrefix() {
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
- try {
- if (sModel == null)
- return null;
-
- Document xmlDocument = (sModel instanceof IDOMModel)
- ? ((IDOMModel) sModel).getDocument()
- : null;
-
- if (xmlDocument == null)
- return null;
-
- // Get Fixed Structured Document Region
- IStructuredDocumentRegion sdFixedRegion = this.getStructuredDocumentRegion(getOffset());
- if (sdFixedRegion == null)
- return null;
-
- Node n = findNodeForOffset(xmlDocument, sdFixedRegion.getStartOffset());
- if (n == null)
- return null;
-
-
- if (!(n instanceof Element) && !(n instanceof Attr))
- return null;
-
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- }
-
- if (n == null)
- return null;
-
- String nodePrefix = ((Element)n).getPrefix();
- return nodePrefix;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- /**
- * Returns URI for the current/parent tag
- * @return
- */
- public String getTagUri() {
- String nodePrefix = getTagPrefix();
- return getUri(nodePrefix);
- }
-
- /**
- * Returns URI string for the prefix specified
- *
- * @param prefix
- * @return
- */
- abstract protected String getUri(String prefix);
-
- /* Utility functions */
- Node findNodeForOffset(IDOMNode node, int offset) {
- if(node == null) return null;
- if (!node.contains(offset)) return null;
-
- if (node.hasChildNodes()) {
- // Try to find the node in children
- NodeList children = node.getChildNodes();
- for (int i = 0; children != null && i < children.getLength(); i++) {
- IDOMNode child = (IDOMNode)children.item(i);
- if (child.contains(offset)) {
- return findNodeForOffset(child, offset);
- }
- }
- }
- // Not found in children or nave no children
- if (node.hasAttributes()) {
- // Try to find in the node attributes
- NamedNodeMap attributes = node.getAttributes();
-
- for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
- IDOMNode attr = (IDOMNode)attributes.item(i);
- if (attr.contains(offset)) {
- return attr;
- }
- }
- }
- // Return the node itself
- return node;
- }
-
- Node findNodeForOffset(Node node, int offset) {
- return (node instanceof IDOMNode) ? findNodeForOffset((IDOMNode)node, offset) : null;
- }
-
- /**
- * this is the position the cursor should be in after the proposal is
- * applied
- *
- * @param proposedText
- * @return the position the cursor should be in after the proposal is
- * applied
- */
- protected int getCursorPositionForProposedText(String proposedText) {
- int cursorAdjustment;
- cursorAdjustment = proposedText.indexOf("\"\"") + 1; //$NON-NLS-1$
- // otherwise, after the first tag
- if (cursorAdjustment == 0) {
- cursorAdjustment = proposedText.indexOf('>') + 1;
- }
- if (cursorAdjustment == 0) {
- cursorAdjustment = proposedText.length();
- }
-
- return cursorAdjustment;
- }
-
- /**
- * Returns EL Prefix Text Region Information Object
- *
- * @return
- */
- protected TextRegion getELPrefix(ContentAssistRequest request) {
- if (!DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(request.getRegion().getType()) &&
- !DOMRegionContext.XML_CONTENT.equals(request.getRegion().getType()) &&
- !DOMRegionContext.BLOCK_TEXT.equals(request.getRegion().getType()))
- return null;
-
- String text = request.getDocumentRegion().getFullText(request.getRegion());
- int startOffset = request.getDocumentRegion().getStartOffset() + request.getRegion().getStart();
-
- boolean isAttributeValue = false;
- boolean hasOpenQuote = false;
- boolean hasCloseQuote = false;
- char quoteChar = (char)0;
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(request.getRegion().getType())) {
- isAttributeValue = true;
- if (text.startsWith("\"") || text.startsWith("'")) {//$NON-NLS-1$ //$NON-NLS-2$
- quoteChar = text.charAt(0);
- hasOpenQuote = true;
- }
- if (hasOpenQuote && text.trim().endsWith(String.valueOf(quoteChar))) {
- hasCloseQuote = true;
- }
- }
-
- int inValueOffset = getOffset() - startOffset;
- if (text != null && text.length() < inValueOffset) { // probably, the attribute value ends before the document position
- return null;
- }
- if (inValueOffset<0) {
- return null;
- }
-
-// String matchString = text.substring(0, inValueOffset);
-
- ELParser p = ELParserUtil.getJbossFactory().createParser();
- ELModel model = p.parse(text);
-
- ELInstance is = ELUtil.findInstance(model, inValueOffset);// ELInstance
- ELInvocationExpression ie = ELUtil.findExpression(model, inValueOffset);// ELExpression
-
- boolean isELStarted = (model != null && is != null && (model.toString().startsWith("#{") || //$NON-NLS-1$
- model.toString().startsWith("${"))); //$NON-NLS-1$
- boolean isELClosed = (model != null && is != null && model.toString().endsWith("}")); //$NON-NLS-1$
-
-// boolean insideEL = startOffset + model.toString().length()
- TextRegion tr = new TextRegion(startOffset, ie == null ? inValueOffset : ie.getStartPosition(),
- ie == null ? 0 : inValueOffset - ie.getStartPosition(), ie == null ? "" : ie.getText(), //$NON-NLS-1$
- isELStarted, isELClosed,
- isAttributeValue, hasOpenQuote, hasCloseQuote, quoteChar);
-
- return tr;
- }
-
- /**
- * Returns EL Predicate Text Region Information Object
- *
- *
- * @return
- */
- protected TextRegion getELPredicatePrefix(ContentAssistRequest request) {
- if (request == null || request.getRegion() == null)
- return null;
-
- IStructuredDocumentRegion documentRegion = request.getDocumentRegion();
- ITextRegion completionRegion = request.getRegion();
- String regionType = completionRegion.getType();
-
- if (DOMRegionContext.XML_END_TAG_OPEN.equals(regionType) || DOMRegionContext.XML_TAG_OPEN.equals(regionType)) {
- documentRegion = documentRegion.getPrevious();
- completionRegion = getCompletionRegion(request.getDocumentRegion().getStartOffset() + request.getRegion().getStart() - 1, request.getParent());
- }
- if (!DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(completionRegion.getType()) &&
- !DOMRegionContext.XML_CONTENT.equals(completionRegion.getType()) &&
- !DOMRegionContext.BLOCK_TEXT.equals(completionRegion.getType())) {
- return null;
- }
- String text = documentRegion.getFullText(completionRegion);
- int startOffset = documentRegion.getStartOffset() + completionRegion.getStart();
-
- boolean isAttributeValue = false;
- boolean hasOpenQuote = false;
- boolean hasCloseQuote = false;
- char quoteChar = (char)0;
- if (DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(request.getRegion().getType())) {
- isAttributeValue = true;
- if (text.startsWith("\"") || text.startsWith("'")) {//$NON-NLS-1$ //$NON-NLS-2$
- quoteChar = text.charAt(0);
- hasOpenQuote = true;
- }
- if (hasOpenQuote && text.trim().endsWith(String.valueOf(quoteChar))) {
- hasCloseQuote = true;
- }
- }
-
- int inValueOffset = getOffset() - startOffset;
- if (inValueOffset<0 || // There is no a word part before cursor
- (text != null && text.length() < inValueOffset)) { // probably, the attribute value ends before the document position
- return null;
- }
-
- String matchString = getELPredicateMatchString(text, inValueOffset);
- if (matchString == null)
- return null;
-
- TextRegion tr = new TextRegion(startOffset, getOffset() - matchString.length() - startOffset,
- matchString.length(), matchString, false, false,
- isAttributeValue, hasOpenQuote, hasCloseQuote, quoteChar);
-
- return tr;
- }
-
- /**
- * Returns predicate string for the EL-related query.
- * The predicate string is the word/part of word right before the cursor position, including the '.' and '_' characters,
- * which is to be replaced by the EL CA proposal ('#{' and '}' character sequences are to be inserted too)
- *
- * @param text
- * @param offset
- * @return
- */
- protected String getELPredicateMatchString(String text, int offset) {
- int beginningOffset = offset - 1;
- while(beginningOffset >=0 &&
- (Character.isJavaIdentifierPart(text.charAt(beginningOffset)) ||
- '.' == text.charAt(beginningOffset) ||
- '_' == text.charAt(beginningOffset))) {
- beginningOffset--;
- }
- beginningOffset++; // move it to point the first valid character
- return text.substring(beginningOffset, offset);
- }
-
- /**
- * Returns EL Prefix Text Region Information Object
- *
- * @deprecated
- * @return
- */
- protected TextRegion getELPrefix() {
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
- try {
- if (sModel == null)
- return null;
-
- Document xmlDocument = (sModel instanceof IDOMModel)
- ? ((IDOMModel) sModel).getDocument()
- : null;
-
- if (xmlDocument == null)
- return null;
-
- Node n = findNodeForOffset(xmlDocument, getOffset());
- if (n == null)
- return null;
-
- String text = null;
- ITextRegion region = null;
- int startOffset = -1;
- int offset = getOffset();
- while (n != null && startOffset == -1) {
- if (n instanceof IDOMAttr) {
- text = ((IDOMAttr)n).getValueRegionText();
- region = ((IDOMAttr)n).getValueRegion();
- startOffset = ((IndexedRegion)((IDOMAttr)n).getOwnerElement()).getStartOffset();
- if(region != null) {
- startOffset += region.getStart();
- } else {
- region = ((IDOMAttr)n).getEqualRegion();
- if(region != null) {
- startOffset += region.getStart() + region.getLength();
- } else {
- startOffset = ((IDOMAttr)n).getEndOffset();
- }
- }
- } else if (n instanceof IDOMText) {
- text = ((IDOMText)n).getNodeValue();
- region = ((IDOMText)n).getFirstStructuredDocumentRegion();
- startOffset = ((IDOMText)n).getStartOffset();
- } else {
- // The EL may appear only in TEXT and ATTRIBUTE VALUE types of node
- // But if the current offset is start of a tag - we should treat it as part of previous region
- if (n instanceof IDOMElement) {
- IDOMElement elem = (IDOMElement)n;
- if ((elem.hasEndTag() && elem.getEndStartOffset() == offset) ||
- elem.getStartOffset() == offset) {
- n = findNodeForOffset(xmlDocument, --offset);
- continue;
- }
- }
-
- return null;
- }
- }
-
- int inValueOffset = getOffset() - startOffset;
- if (text != null && text.length() < inValueOffset) { // probably, the attribute value ends before the document position
- return null;
- }
- if (inValueOffset<0) {
- return null;
- }
-
-// String matchString = text.substring(0, inValueOffset);
-
- ELParser p = ELParserUtil.getJbossFactory().createParser();
- ELModel model = p.parse(text);
-
- ELInstance is = ELUtil.findInstance(model, inValueOffset);// ELInstance
- ELInvocationExpression ie = ELUtil.findExpression(model, inValueOffset);// ELExpression
-
- boolean isELStarted = (model != null && is != null && (model.toString().startsWith("#{") || //$NON-NLS-1$
- model.toString().startsWith("${"))); //$NON-NLS-1$
- boolean isELClosed = (model != null && is != null && model.toString().endsWith("}")); //$NON-NLS-1$
-
-// boolean insideEL = startOffset + model.toString().length()
- TextRegion tr = new TextRegion(startOffset, ie == null ? inValueOffset : ie.getStartPosition(), ie == null ? 0 : inValueOffset - ie.getStartPosition(), ie == null ? "" : ie.getText(), isELStarted, isELClosed); //$NON-NLS-1$
-
- return tr;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- public static class TextRegion {
- private int startOffset;
- private int offset;
- private int length;
- private String text;
- private boolean isELStarted;
- private boolean isELClosed;
- private boolean isAttributeValue;
- private boolean hasOpenQuote;
- private boolean hasCloseQuote;
- private char quoteChar;
-
- TextRegion(int startOffset, int offset, int length, String text, boolean isELStarted, boolean isELClosed) {
- this(startOffset, offset, length, text, isELStarted, isELClosed, false, false, false, (char)0);
- }
-
- public TextRegion(int startOffset, int offset, int length, String text, boolean isELStarted, boolean isELClosed,
- boolean isAttributeValue, boolean hasOpenQuote, boolean hasCloseQuote, char quoteChar) {
- this.startOffset = startOffset;
- this.offset = offset;
- this.length = length;
- this.text = text;
- this.isELStarted = isELStarted;
- this.isELClosed = isELClosed;
- this.isAttributeValue = isAttributeValue;
- this.hasOpenQuote = hasOpenQuote;
- this.hasCloseQuote = hasCloseQuote;
- this.quoteChar = quoteChar;
- }
-
- public int getStartOffset() {
- return startOffset;
- }
-
- public int getOffset() {
- return offset;
- }
-
- public int getLength() {
- return length;
- }
-
- public String getText() {
- StringBuffer sb = new StringBuffer(length);
- sb = sb.append(text.substring(0, length));
- sb.setLength(length);
- return sb.toString();
- }
-
- public boolean isELStarted() {
- return isELStarted;
- }
-
- public boolean isELClosed() {
- return isELClosed;
- }
-
- public boolean isAttributeValue() {
- return isAttributeValue;
- }
-
- public char getQuoteChar() {
- return quoteChar;
- }
-
- public boolean hasOpenQuote() {
- return hasOpenQuote;
- }
-
- public boolean hasCloseQuote() {
- return hasCloseQuote;
- }
- }
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.jsp.contentassist;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.jboss.tools.common.el.core.ca.ELTextProposal;
-import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.jsp.messages.JstUIMessages;
-import org.jboss.tools.jst.web.kb.IFaceletPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageContextFactory;
-import org.jboss.tools.jst.web.kb.PageProcessor;
-import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author Jeremy
- *
- */
-@Deprecated
-@SuppressWarnings("restriction")
-public class FaceletPageContectAssistProcessor extends JspContentAssistProcessor {
- private static final String JSFC_ATTRIBUTE_NAME = "jsfc"; //$NON-NLS-1$
- private boolean replaceJsfcTags;
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
- */
- @Override
- protected ELContext createContext() {
- return PageContextFactory.createPageContext(getResource(), PageContextFactory.FACELETS_PAGE_CONTEXT_TYPE);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#getContext()
- */
- @Override
- public IFaceletPageContext getContext() {
- return (IFaceletPageContext)super.getContext();
- }
-
- /**
- * Calculates and adds the tag proposals to the Content Assist Request object
- * The method is to be overridden here because xhtml allows to use EL-s inside a text region
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
-
- @Override
- protected void addTagInsertionProposals(
- ContentAssistRequest contentAssistRequest, int childPosition) {
-
- // Need to check if an EL Expression is opened here.
- // If it is true we don't need to start any new tag proposals
- TextRegion prefix = getELPrefix(contentAssistRequest);
- if (prefix != null && prefix.isELStarted()) {
- return;
- }
-
- addTagNameProposals(contentAssistRequest, childPosition, true);
- addELPredicateProposals(contentAssistRequest, TextProposal.R_TAG_INSERTION, true);
- }
-
- /**
- * Calculates and adds the EL proposals to the Content Assist Request object
- */
- @Override
- protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
- if (!isELCAToBeShown())
- return;
-
- TextRegion prefix = getELPrefix(contentAssistRequest);
- if (prefix == null || !prefix.isELStarted()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression, null,
- JstUIMessages.FaceletPageContectAssistProcessor_NewELExpressionTextInfo, TextProposal.R_TAG_INSERTION + 1);
-
- contentAssistRequest.addProposal(proposal);
- return;
- }
- String matchString = "#{" + prefix.getText(); //$NON-NLS-1$
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
-
- int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
-
- KbQuery kbQuery = createKbQuery(Type.TEXT, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
- if (proposals == null || proposals.length == 0)
- return;
-
- for (TextProposal textProposal : proposals) {
- int replacementOffset = beginChangeOffset;
- int replacementLength = prefix.getLength();
- String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- int cursorPosition = replacementString.length();
-
- if (!prefix.isELClosed()) {
- replacementString += "}"; //$NON-NLS-1$
- }
-
- Image image = textProposal.getImage();
-
- // JBIDE-512, JBIDE-2541 related changes ===>>>
-// String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- String displayString = textProposal.getLabel();
- if (displayString == null)
- displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
-
- // <<<=== JBIDE-512, JBIDE-2541 related changes
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
- }
-
- AutoContentAssistantProposal proposal = null;
- if (textProposal instanceof ELTextProposal) {
- IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
-
- proposal = new AutoELContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, javaElements, relevance);
- } else {
- String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
-
- proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, additionalProposalInfo, relevance);
- }
-
- contentAssistRequest.addProposal(proposal);
- }
-
- if (prefix.isELStarted() && !prefix.isELClosed()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal("}", //$NON-NLS-1$
- getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
- null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
-
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#addAttributeNameProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest)
- */
- @Override
- protected void addAttributeNameProposals(
- ContentAssistRequest contentAssistRequest) {
- super.addAttributeNameProposals(contentAssistRequest);
- if (isExistingAttribute(JSFC_ATTRIBUTE_NAME)) {
- this.replaceJsfcTags = true;
- super.addAttributeNameProposals(contentAssistRequest);
- this.replaceJsfcTags = false;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#addAttributeValueProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest)
- */
- @Override
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- super.addAttributeValueProposals(contentAssistRequest);
- if (isExistingAttribute(JSFC_ATTRIBUTE_NAME)) {
- this.replaceJsfcTags = true;
- super.addAttributeValueProposals(contentAssistRequest);
- this.replaceJsfcTags = false;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#getTagName(org.w3c.dom.Node)
- */
- @Override
- protected String getTagName(Node tag) {
- String tagName = tag.getNodeName();
- if(replaceJsfcTags) {
- // Only HTML tags
- if(tagName.indexOf(':')>0) {
- return tagName;
- }
- if (!(tag instanceof Element))
- return tagName;
-
- Element element = (Element)tag;
-
- NamedNodeMap attributes = element.getAttributes();
- Node jsfC = attributes.getNamedItem(JSFC_ATTRIBUTE_NAME);
- if(jsfC==null || (!(jsfC instanceof Attr))) {
- return tagName;
- }
- Attr jsfCAttribute = (Attr)jsfC;
- String jsfTagName = jsfCAttribute.getValue();
- if(jsfTagName==null || jsfTagName.indexOf(':')<1) {
- return tagName;
- }
- tagName = jsfTagName;
- }
- return tagName;
- }
-}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -35,7 +35,7 @@
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
+import org.jboss.tools.jst.jsp.contentassist.computers.AbstractXmlCompletionProposalComputer.TextRegion;
import org.jboss.tools.jst.jsp.contentassist.computers.JspELCompletionProposalComputer;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009-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.jst.jsp.contentassist;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.common.el.core.parser.ELParserFactory;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
-import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.el.core.resolver.ELContextImpl;
-import org.jboss.tools.common.el.core.resolver.ELResolution;
-import org.jboss.tools.common.el.core.resolver.ELResolutionImpl;
-import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
-import org.jboss.tools.common.el.core.resolver.IRelevanceCheck;
-import org.jboss.tools.common.el.core.resolver.Var;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageContextFactory;
-import org.jboss.tools.jst.web.kb.PageProcessor;
-import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author Jeremy
- *
- */
-@Deprecated
-@SuppressWarnings("restriction")
-public class JspContentAssistProcessor extends XmlContentAssistProcessor {
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
- */
- @Override
- protected ELContext createContext() {
- return PageContextFactory.createPageContext(getResource(), PageContextFactory.JSP_PAGE_CONTEXT_TYPE);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#getContext()
- */
- @Override
- public IPageContext getContext() {
- return (IPageContext)super.getContext();
- }
-
- /**
- * Returns URI string for the prefix specified using the namespaces collected for
- * the {@link IPageContext} context.
- * Important: The context must be created using createContext() method before using this method.
- *
- * @param prefix
- * @return
- */
- @Override
- public String getUri(String prefix) {
- if (prefix == null)
- return null;
-
- Map<String, List<INameSpace>> nameSpaces = getContext().getNameSpaces(getOffset());
- if (nameSpaces == null || nameSpaces.isEmpty())
- return null;
-
- for (List<INameSpace> nameSpace : nameSpaces.values()) {
- for (INameSpace n : nameSpace) {
- if (prefix.equals(n.getPrefix())) {
- return n.getURI();
- }
- }
- }
- return null;
- }
-
- /*
- * Checks if the specified attribute exists
- *
- * @param attrName Name of attribute to check
- */
- protected boolean isExistingAttribute(String attrName) {
- IStructuredModel sModel = StructuredModelManager.getModelManager()
- .getExistingModelForRead(getDocument());
- try {
- if (sModel == null)
- return false;
-
- Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
- .getDocument()
- : null;
-
- if (xmlDocument == null)
- return false;
-
- // Get Fixed Structured Document Region
- IStructuredDocumentRegion sdFixedRegion = this.getStructuredDocumentRegion(getOffset());
- if (sdFixedRegion == null)
- return false;
-
- Node n = findNodeForOffset(xmlDocument, sdFixedRegion.getStartOffset());
- if (n == null)
- return false;
-
- // Find the first parent tag
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- } else {
- return false;
- }
- }
-
- if (n == null)
- return false;
-
- return (((Element)n).getAttributeNode(attrName) != null);
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- /**
- * Calculates and adds the tag proposals to the Content Assist Request object
- * The method is to be overridden here because jsp disallows to use EL-s inside a text region
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
-
- @Override
- protected void addTagInsertionProposals(
- ContentAssistRequest contentAssistRequest, int childPosition) {
-
- // Need to check if an EL Expression is opened here.
- // If it is true we don't need to start any new tag proposals
- TextRegion prefix = getELPrefix(contentAssistRequest);
- if (prefix != null && prefix.isELStarted()) {
- return;
- }
-
- addTagNameProposals(contentAssistRequest, childPosition, true);
- }
-
- /**
- * Calculates and adds the attribute name proposals to the Content Assist Request object
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- String matchString = contentAssistRequest.getMatchString();
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
-
- KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_NAME, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
- if (isExistingAttribute(textProposal.getLabel()))
- continue;
-
- String replacementString = textProposal.getReplacementString() + "=\"\""; //$NON-NLS-1$
-
- int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- int cursorPosition = getCursorPositionForProposedText(replacementString);
- Image image = textProposal.getImage();
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- }
-
- String displayString = textProposal.getLabel() == null ?
- replacementString :
- textProposal.getLabel();
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance();
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
-
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- /**
- * Calculates and adds the EL proposals to the Content Assist Request object
- */
- @Override
- protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
- }
-
- protected void setVars(ELContextImpl context, IFile file) {
- ELCompletionEngine fakeEngine = new ELCompletionEngine() {
-
- public ELResolution resolveELOperand(IFile file,
- ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher, int offset)
- throws BadLocationException, StringIndexOutOfBoundsException {
- return new ELResolutionImpl(operand);
- }
-
- public ELParserFactory getParserFactory() {
- return ELParserUtil.getJbossFactory();
- }
-
- public List<TextProposal> getProposals(ELContext context, String el, int offset) {
- return Collections.emptyList();
- }
-
- public ELResolution resolve(ELContext context, ELExpression operand, int offset) {
- return new ELResolutionImpl(operand);
- }
-
- public List<TextProposal> getProposals(ELContext context, int offset) {
- return Collections.emptyList();
- }
-
- public IRelevanceCheck createRelevanceCheck(IJavaElement element) {
- return null;
- }
- };
- ElVarSearcher varSearcher = new ElVarSearcher(file, fakeEngine);
- List<Var> vars = varSearcher.findAllVars(file, getOffset());
-
- if (vars != null) {
- for (Var var : vars) {
- context.addVar(new Region(getOffset(), 0), var);
- }
- }
- }
-}
\ No newline at end of file
Deleted: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -1,558 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.jsp.contentassist;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.jboss.tools.common.el.core.ca.ELTextProposal;
-import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.el.core.resolver.ELResolver;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.messages.JstUIMessages;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageContextFactory;
-import org.jboss.tools.jst.web.kb.PageProcessor;
-import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-
-/**
- *
- * @author Jeremy
- *
- */
-@Deprecated
-@SuppressWarnings("restriction")
-public class XmlContentAssistProcessor extends AbstractXMLContentAssistProcessor {
- protected static final Image JSF_EL_PROPOSAL_IMAGE = JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
- */
- @Override
- protected ELContext createContext() {
- return PageContextFactory.createPageContext(getResource(), PageContextFactory.XML_PAGE_CONTEXT_TYPE);
- }
-
- @Override
- protected KbQuery createKbQuery(Type type, String query, String stringQuery) {
- return createKbQuery(type, query, stringQuery, getTagPrefix(), getTagUri());
- }
-
- @Override
- protected KbQuery createKbQuery(Type type, String query, String stringQuery, String prefix, String uri) {
- KbQuery kbQuery = new KbQuery();
-
- String[] parentTags = getParentTags(type == Type.ATTRIBUTE_NAME || type == Type.ATTRIBUTE_VALUE);
- String parent = getParent(type == Type.ATTRIBUTE_VALUE, type == Type.ATTRIBUTE_NAME);
- String queryValue = query;
- String queryStringValue = stringQuery;
-
- kbQuery.setPrefix(prefix);
- kbQuery.setUri(uri);
- kbQuery.setParentTags(parentTags);
- kbQuery.setParent(parent);
- kbQuery.setMask(true);
- kbQuery.setType(type);
- kbQuery.setOffset(getOffset());
- kbQuery.setValue(queryValue);
- kbQuery.setStringQuery(queryStringValue);
-
- return kbQuery;
- }
-
- /**
- * Returns URI string for the prefix specified using the namespaces collected for
- * the {@link IPageContext} context.
- *
- * @Override org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#getUri(String)
- */
- protected String getUri(String prefix) {
- return null;
- }
-
- /**
- * Calculates and adds the tag proposals to the Content Assist Request object
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
-
- @Override
- protected void addTagInsertionProposals(
- ContentAssistRequest contentAssistRequest, int childPosition) {
-
- // Need to check if an EL Expression is opened here.
- // If it is true we don't need to start any new tag proposals
- TextRegion prefix = getELPrefix(contentAssistRequest);
- if (prefix != null && prefix.isELStarted()) {
- return;
- }
-
- addTagNameProposals(contentAssistRequest, childPosition, true);
- addELPredicateProposals(contentAssistRequest, TextProposal.R_TAG_INSERTION, true);
- }
-
- private void addTagNameProposalsForPrefix(
- ContentAssistRequest contentAssistRequest,
- int childPosition,
- String query,
- String prefix,
- String uri,
- int defaultRelevance,
- boolean insertTagOpenningCharacter) {
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = "<" + query; //$NON-NLS-1$
-
- KbQuery kbQuery = createKbQuery(Type.TAG_NAME, query, stringQuery, prefix, uri);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
- String replacementString = textProposal.getReplacementString();
- String closingTag = textProposal.getLabel();
- if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
- closingTag = closingTag.substring(1);
- }
-
- if (!insertTagOpenningCharacter && replacementString.startsWith("<")) { //$NON-NLS-1$
- // Because the tag starting char is already in the text
- replacementString = replacementString.substring(1);
- }
- if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
- replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- int cursorPosition = getCursorPositionForProposedText(replacementString);
- Image image = textProposal.getImage();
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- String displayString = closingTag;
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = defaultRelevance == TextProposal.R_NONE? TextProposal.R_TAG_INSERTION : defaultRelevance;
- }
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
-
- contentAssistRequest.addProposal(proposal);
- }
- }
-
-
- /**
- * Calculates and adds the tag name proposals to the Content Assist Request object
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
- @Override
- protected void addTagNameProposals(
- ContentAssistRequest contentAssistRequest, int childPosition) {
- addTagNameProposals(contentAssistRequest, childPosition, false);
- }
-
- /**
- * Calculates and adds the tag name proposals to the Content Assist Request object
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
- protected void addTagNameProposals(
- ContentAssistRequest contentAssistRequest, int childPosition, boolean insertTagOpenningCharacter) {
-
- String mainPrefix = getTagPrefix();
- String mainURI = getTagUri();
-
- String query = contentAssistRequest.getMatchString();
- addTagNameProposalsForPrefix(contentAssistRequest, childPosition, query, mainPrefix, mainURI, TextProposal.R_TAG_INSERTION, insertTagOpenningCharacter);
-
- if (query == null || query.length() == 0 || query.contains(":")) //$NON-NLS-1$
- return;
-
- // Make an additional proposals to allow prefixed tags to be entered with no prefix typed
- ELContext elContext = getContext();
- if (elContext instanceof IPageContext) {
- IPageContext pageContext = (IPageContext)elContext;
- Map<String, List<INameSpace>> nsMap = pageContext.getNameSpaces(contentAssistRequest.getReplacementBeginPosition());
- if (nsMap == null) return;
-
- for (List<INameSpace> namespaces : nsMap.values()) {
- if (namespaces == null) continue;
-
- for (INameSpace namespace : namespaces) {
- String possiblePrefix = namespace.getPrefix();
- if (possiblePrefix == null || possiblePrefix.length() == 0)
- continue; // Don't query proposals for the default value here
-
- String possibleURI = namespace.getURI();
- String possibleQuery = namespace.getPrefix() + ":" + query; //$NON-NLS-1$
- addTagNameProposalsForPrefix(contentAssistRequest, childPosition,
- possibleQuery, possiblePrefix, possibleURI,
- TextProposal.R_TAG_INSERTION - 1,
- insertTagOpenningCharacter);
- }
- }
- }
- }
-
-
-
- @Override
- public String getTagPrefix() {
- String prefix = super.getTagPrefix();
- if (prefix != null)
- return prefix;
-
- String uri = getUri(""); //$NON-NLS-1$
- return uri == null ? null : ""; //$NON-NLS-1$
- }
-
- /**
- * Calculates and adds the attribute value proposals to the Content Assist Request object
- */
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- // Need to check if an EL Expression is opened here.
- // If it is true we don't need to start any new tag proposals
- TextRegion prefix = getELPrefix(contentAssistRequest);
- if (prefix != null && prefix.isELStarted()) {
- return;
- }
-
- String matchString = contentAssistRequest.getMatchString();
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
-
- KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
- int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- if(textProposal.getStart() >= 0 && textProposal.getEnd() >= 0) {
- replacementOffset += textProposal.getStart() + 1;
- replacementLength = textProposal.getEnd() - textProposal.getStart();
- }
- String replacementString = "\"" + textProposal.getReplacementString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- if(textProposal.getStart() >= 0 && textProposal.getEnd() >= 0) {
- replacementString = textProposal.getReplacementString();
- }
- int cursorPosition = getCursorPositionForProposedText(replacementString);
- Image image = textProposal.getImage();
- String displayString = textProposal.getLabel() == null ?
- replacementString :
- textProposal.getLabel();
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_JSP_ATTRIBUTE_VALUE;
- }
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
-
- contentAssistRequest.addProposal(proposal);
- }
-
- addELPredicateProposals(contentAssistRequest, TextProposal.R_JSP_ATTRIBUTE_VALUE, false);
- }
-
- /**
- * Calculates and adds EL predicate proposals based on the last word typed
- * To be used only outside the EL.
- *
- * @param contentAssistRequest
- */
- protected void addELPredicateProposals(ContentAssistRequest contentAssistRequest, int baseRelevance, boolean shiftRelevanceAgainstTagNameProposals) {
- if (!isELCAToBeShown())
- return;
-
- // Need to check if the cursor is placed right after a word part.
- // If there is no word part found then just quit
- TextRegion prefix = getELPredicatePrefix(contentAssistRequest);
- if (prefix == null || prefix.isELStarted()) {
- return;
- }
- String matchString = "#{" + prefix.getText(); //$NON-NLS-1$
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
- int relevanceShift = -2; // Fix for JBIDE-5987: Relevance for predicate proposals is shifted down by default to show EL proposals lower than attr-value proposals
- if (shiftRelevanceAgainstTagNameProposals) {
- relevanceShift += prefix.getText() != null && prefix.getText().trim().length() > 0 ? (XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION - baseRelevance + 2): -2;
- }
-
- int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
-
- KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- if (proposals == null || proposals.length == 0)
- return;
-
- for (TextProposal textProposal : proposals) {
- int replacementOffset = beginChangeOffset;
- int replacementLength = prefix.getLength();
- String replacementString = "#{" + prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString(); //$NON-NLS-1$
-
- char quoteChar = prefix.isAttributeValue() && prefix.hasOpenQuote() ? prefix.getQuoteChar() : '"';
- int cursorPosition = replacementString.length();
-
- if (!prefix.isELClosed()) {
- replacementString += "}"; //$NON-NLS-1$
- }
-
- if (prefix.isAttributeValue() && prefix.hasOpenQuote() && !prefix.hasCloseQuote()) {
- replacementString += String.valueOf(quoteChar);
- }
-
- Image image = textProposal.getImage();
-
- // JBIDE-512, JBIDE-2541 related changes ===>>>
-// String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- String displayString = textProposal.getLabel();
- if (displayString == null)
- displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
- // <<<=== JBIDE-512, JBIDE-2541 related changes
-
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = baseRelevance;
- }
- relevance += relevanceShift;
-
- AutoContentAssistantProposal proposal = null;
- if (textProposal instanceof ELTextProposal) {
- IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
-
- proposal = new AutoELContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, javaElements, relevance);
- } else {
- String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
-
- proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, additionalProposalInfo, relevance);
- }
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- @Override
- protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest) {
- if (!isELCAToBeShown())
- return;
-
- TextRegion prefix = getELPrefix(contentAssistRequest);
- if (prefix == null) {
- return;
- }
-
- if(!prefix.isELStarted()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true,
- "#{}" + (prefix.isAttributeValue() && prefix.hasOpenQuote() && !prefix.hasCloseQuote() ? String.valueOf(prefix.getQuoteChar()) : ""), //$NON-NLS-1$ //$NON-NLS-2$
- getOffset(), 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression,
- null, JstUIMessages.JspContentAssistProcessor_NewELExpressionAttrInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
-
- contentAssistRequest.addProposal(proposal);
- return;
- }
- String matchString = "#{" + prefix.getText(); //$NON-NLS-1$
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
-
- int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
-
- KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- if (proposals == null || proposals.length == 0)
- return;
-
- for (TextProposal textProposal : proposals) {
- int replacementOffset = beginChangeOffset;
- int replacementLength = prefix.getLength();
- String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
-
- char quoteChar = prefix.isAttributeValue() && prefix.hasOpenQuote() ? prefix.getQuoteChar() : '"';
-// if (prefix.isAttributeValue() && !prefix.hasOpenQuote()) {
-// replacementString = String.valueOf(quoteChar) + replacementString;
-// }
- int cursorPosition = replacementString.length();
-
- if (!prefix.isELClosed()) {
- replacementString += "}"; //$NON-NLS-1$
- }
-
- if (prefix.isAttributeValue() && prefix.hasOpenQuote() && !prefix.hasCloseQuote()) {
- replacementString += String.valueOf(quoteChar);
- }
-
- Image image = textProposal.getImage();
-
- // JBIDE-512, JBIDE-2541 related changes ===>>>
-// String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- String displayString = textProposal.getLabel();
- if (displayString == null)
- displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
- // <<<=== JBIDE-512, JBIDE-2541 related changes
-
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
- }
-
- AutoContentAssistantProposal proposal = null;
- if (textProposal instanceof ELTextProposal) {
- IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
-
- proposal = new AutoELContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, javaElements, relevance);
- } else {
- String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
-
- proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, additionalProposalInfo, relevance);
- }
- contentAssistRequest.addProposal(proposal);
- }
-
- if (prefix.isELStarted() && !prefix.isELClosed()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(
- "}" + (prefix.isAttributeValue() && prefix.hasOpenQuote() && !prefix.hasCloseQuote() ? String.valueOf(prefix.getQuoteChar()) : ""), //$NON-NLS-1$ //$NON-NLS-2$
- getOffset(), 0, 0, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
- null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE + 1); //
-
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- @Override
- protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
- if (!isELCAToBeShown())
- return;
-
- TextRegion prefix = getELPrefix(contentAssistRequest);
- if (prefix == null || !prefix.isELStarted()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression, null,
- JstUIMessages.FaceletPageContectAssistProcessor_NewELExpressionTextInfo, TextProposal.R_TAG_INSERTION + 1);
-
- contentAssistRequest.addProposal(proposal);
- return;
- }
- String matchString = "#{" + prefix.getText(); //$NON-NLS-1$
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
-
- int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
-
- KbQuery kbQuery = createKbQuery(Type.TEXT, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- if (proposals == null || proposals.length == 0)
- return;
-
- for (TextProposal textProposal : proposals) {
- int replacementOffset = beginChangeOffset;
- int replacementLength = prefix.getLength();
- String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- int cursorPosition = replacementString.length();
-
- if (!prefix.isELClosed()) {
- replacementString += "}"; //$NON-NLS-1$
- }
-
- Image image = textProposal.getImage();
-
- // JBIDE-512, JBIDE-2541 related changes ===>>>
-// String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- String displayString = textProposal.getLabel();
- if (displayString == null)
- displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
-
- // <<<=== JBIDE-512, JBIDE-2541 related changes
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
- }
-
- AutoContentAssistantProposal proposal = null;
- if (textProposal instanceof ELTextProposal) {
- IJavaElement[] javaElements = ((ELTextProposal)textProposal).getAllJavaElements();
-
- proposal = new AutoELContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, javaElements, relevance);
- } else {
- String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
-
- proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- null, additionalProposalInfo, relevance);
- }
- contentAssistRequest.addProposal(proposal);
- }
-
- if (prefix.isELStarted() && !prefix.isELClosed()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal("}", //$NON-NLS-1$
- getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
- null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
-
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- /**
- * Checks is we need to show EL proposals
- *
- * @return
- */
- protected boolean isELCAToBeShown() {
- ELResolver[] resolvers = getContext().getElResolvers();
- return (resolvers != null && resolvers.length > 0);
- }
-}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/AbstractXmlCompletionProposalComputer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/AbstractXmlCompletionProposalComputer.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/AbstractXmlCompletionProposalComputer.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -733,4 +733,79 @@
protected boolean endsWithELBeginning(String text) {
return (text != null && text.endsWith(EL_SUFFIX));
}
+
+ public static class TextRegion {
+ private int startOffset;
+ private int offset;
+ private int length;
+ private String text;
+ private boolean isELStarted;
+ private boolean isELClosed;
+ private boolean isAttributeValue;
+ private boolean hasOpenQuote;
+ private boolean hasCloseQuote;
+ private char quoteChar;
+
+ public TextRegion(int startOffset, int offset, int length, String text, boolean isELStarted, boolean isELClosed) {
+ this(startOffset, offset, length, text, isELStarted, isELClosed, false, false, false, (char)0);
+ }
+
+ public TextRegion(int startOffset, int offset, int length, String text, boolean isELStarted, boolean isELClosed,
+ boolean isAttributeValue, boolean hasOpenQuote, boolean hasCloseQuote, char quoteChar) {
+ this.startOffset = startOffset;
+ this.offset = offset;
+ this.length = length;
+ this.text = text;
+ this.isELStarted = isELStarted;
+ this.isELClosed = isELClosed;
+ this.isAttributeValue = isAttributeValue;
+ this.hasOpenQuote = hasOpenQuote;
+ this.hasCloseQuote = hasCloseQuote;
+ this.quoteChar = quoteChar;
+ }
+
+ public int getStartOffset() {
+ return startOffset;
+ }
+
+ public int getOffset() {
+ return offset;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public String getText() {
+ StringBuffer sb = new StringBuffer(length);
+ sb = sb.append(text.substring(0, length));
+ sb.setLength(length);
+ return sb.toString();
+ }
+
+ public boolean isELStarted() {
+ return isELStarted;
+ }
+
+ public boolean isELClosed() {
+ return isELClosed;
+ }
+
+ public boolean isAttributeValue() {
+ return isAttributeValue;
+ }
+
+ public char getQuoteChar() {
+ return quoteChar;
+ }
+
+ public boolean hasOpenQuote() {
+ return hasOpenQuote;
+ }
+
+ public boolean hasCloseQuote() {
+ return hasCloseQuote;
+ }
+ }
+
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -13,10 +13,6 @@
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument;
import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
@@ -29,18 +25,9 @@
import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.jboss.tools.common.el.core.ca.ELTextProposal;
import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
-import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
-import org.jboss.tools.jst.jsp.contentassist.AutoELContentAssistantProposal;
-import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
-import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.KbQuery.Type;
import org.jboss.tools.jst.web.kb.PageContextFactory;
-import org.jboss.tools.jst.web.kb.PageProcessor;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -40,7 +40,6 @@
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
import org.jboss.tools.common.el.core.ca.ELTextProposal;
import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
@@ -53,7 +52,6 @@
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.contentassist.AutoELContentAssistantProposal;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlTagCompletionProposalComputer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlTagCompletionProposalComputer.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlTagCompletionProposalComputer.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -666,80 +666,6 @@
public static class ELXMLContentModelGenerator extends XMLContentModelGenerator {
}
-
- public static class TextRegion {
- private int startOffset;
- private int offset;
- private int length;
- private String text;
- private boolean isELStarted;
- private boolean isELClosed;
- private boolean isAttributeValue;
- private boolean hasOpenQuote;
- private boolean hasCloseQuote;
- private char quoteChar;
-
- TextRegion(int startOffset, int offset, int length, String text, boolean isELStarted, boolean isELClosed) {
- this(startOffset, offset, length, text, isELStarted, isELClosed, false, false, false, (char)0);
- }
- public TextRegion(int startOffset, int offset, int length, String text, boolean isELStarted, boolean isELClosed,
- boolean isAttributeValue, boolean hasOpenQuote, boolean hasCloseQuote, char quoteChar) {
- this.startOffset = startOffset;
- this.offset = offset;
- this.length = length;
- this.text = text;
- this.isELStarted = isELStarted;
- this.isELClosed = isELClosed;
- this.isAttributeValue = isAttributeValue;
- this.hasOpenQuote = hasOpenQuote;
- this.hasCloseQuote = hasCloseQuote;
- this.quoteChar = quoteChar;
- }
-
- public int getStartOffset() {
- return startOffset;
- }
-
- public int getOffset() {
- return offset;
- }
-
- public int getLength() {
- return length;
- }
-
- public String getText() {
- StringBuffer sb = new StringBuffer(length);
- sb = sb.append(text.substring(0, length));
- sb.setLength(length);
- return sb.toString();
- }
-
- public boolean isELStarted() {
- return isELStarted;
- }
-
- public boolean isELClosed() {
- return isELClosed;
- }
-
- public boolean isAttributeValue() {
- return isAttributeValue;
- }
-
- public char getQuoteChar() {
- return quoteChar;
- }
-
- public boolean hasOpenQuote() {
- return hasOpenQuote;
- }
-
- public boolean hasCloseQuote() {
- return hasCloseQuote;
- }
- }
-
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/FaceletTagInfoHoverProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/FaceletTagInfoHoverProcessor.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/FaceletTagInfoHoverProcessor.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -54,8 +54,8 @@
import org.jboss.tools.common.el.core.resolver.ELSegment;
import org.jboss.tools.common.el.core.resolver.JavaMemberELSegmentImpl;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
import org.jboss.tools.jst.jsp.contentassist.Utils;
+import org.jboss.tools.jst.jsp.contentassist.computers.AbstractXmlCompletionProposalComputer.TextRegion;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPContentOutlineConfiguration.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -44,15 +44,13 @@
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
import org.jboss.tools.common.model.ui.editors.dnd.context.DropContext;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.computers.JspELCompletionProposalComputer;
import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
import org.jboss.tools.jst.jsp.editor.IViewerDropAdapterFactory;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.internal.taglib.CustomTagLibComponent;
+import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
import org.jboss.tools.jst.web.kb.taglib.ICustomTagLibComponent;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -43,16 +43,14 @@
import org.eclipse.wst.xml.ui.internal.properties.EnumeratedStringPropertyDescriptor;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.contentassist.FaceletPageContectAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.computers.FaceletsELCompletionProposalComputer;
import org.jboss.tools.jst.jsp.contentassist.computers.JspELCompletionProposalComputer;
import org.jboss.tools.jst.jsp.editor.IVisualController;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2011-08-12 22:04:57 UTC (rev 33869)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2011-08-12 22:05:46 UTC (rev 33870)
@@ -33,7 +33,6 @@
import org.jboss.tools.common.model.project.IPromptingProvider;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
-import org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.computers.FaceletsELCompletionProposalComputer;
import org.jboss.tools.jst.jsp.contentassist.computers.JspELCompletionProposalComputer;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResource;
14 years, 8 months
JBoss Tools SVN: r33869 - trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-08-12 18:04:57 -0400 (Fri, 12 Aug 2011)
New Revision: 33869
Modified:
trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ResourcesUtils.java
trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java
Log:
https://issues.jboss.org/browse/JBIDE-9532
Modified: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ResourcesUtils.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ResourcesUtils.java 2011-08-12 22:04:45 UTC (rev 33868)
+++ trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ResourcesUtils.java 2011-08-12 22:04:57 UTC (rev 33869)
@@ -312,7 +312,6 @@
// VPETestPlugin.getDefault().logError(ie);
ie.printStackTrace();
} catch (CoreException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
Modified: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java 2011-08-12 22:04:45 UTC (rev 33868)
+++ trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java 2011-08-12 22:04:57 UTC (rev 33869)
@@ -17,6 +17,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
@@ -58,6 +59,7 @@
} else {
project = ResourcesUtils.importProject(bundleName, projectPath, name, null);
}
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
}
} catch (IOException e) {
throw new CoreException(new Status(Status.ERROR,bundleName,e.getMessage(),e));
14 years, 8 months
JBoss Tools SVN: r33868 - in trunk: jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-08-12 18:04:45 -0400 (Fri, 12 Aug 2011)
New Revision: 33868
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/WebContentTest.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide6061Test.java
Log:
https://issues.jboss.org/browse/JBIDE-9532
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/WebContentTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/WebContentTest.java 2011-08-12 22:03:50 UTC (rev 33867)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/WebContentTest.java 2011-08-12 22:04:45 UTC (rev 33868)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.jst.web.kb.internal.validation.ELValidationMessages;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.ResourcesUtils;
@@ -40,6 +41,7 @@
if(!project.exists()) {
project = ResourcesUtils.importProject(PLUGIN_ID, PROJECT_PATH);
}
+ TestUtil._waitForValidation(project);
}
/* (non-Javadoc)
@@ -48,7 +50,6 @@
@Override
protected void tearDown() throws Exception {
boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
- JobUtils.waitForIdle();
project.delete(true, true, null);
JobUtils.waitForIdle();
ResourcesUtils.setBuildAutomatically(saveAutoBuild);
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2011-08-12 22:03:50 UTC (rev 33867)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2011-08-12 22:04:45 UTC (rev 33868)
@@ -19,24 +19,27 @@
import org.jboss.tools.jst.jsp.test.ca.JstJspJbide1585Test;
import org.jboss.tools.jst.jsp.test.ca.JstJspJbide1641Test;
import org.jboss.tools.jst.jsp.test.selbar.SelectionBarTest;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
public class JstJspAllTests {
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.jboss.tools.jst.jsp.test"); //$NON-NLS-1$
-
+ suite.addTest(new ProjectImportTestSetup(new TestSuite(
+ Jbide6061Test.class),
+ "org.jboss.tools.jst.jsp.test", "projects/Jbide6061Test", //$NON-NLS-1$ //$NON-NLS-2$
+ "Jbide6061Test")); //$NON-NLS-1$
+
suite.addTestSuite(JstJspJbide1585Test.class);
suite.addTestSuite(JstJspJbide1641Test.class);
-
+
suite.addTestSuite(Jbide1791Test.class);
suite.addTestSuite(Jbide9092Test.class);
- suite.addTestSuite(Jbide6061Test.class);
-
+
suite.addTestSuite(JspPreferencesPageTest.class);
suite.addTestSuite(SelectionBarTest.class);
-
+
return suite;
}
-
-}
+}
\ No newline at end of file
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide6061Test.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide6061Test.java 2011-08-12 22:03:50 UTC (rev 33867)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/Jbide6061Test.java 2011-08-12 22:04:45 UTC (rev 33868)
@@ -13,11 +13,11 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.jboss.tools.test.util.TestProjectProvider;
/**
* Test cast testing http://jira.jboss.com/jira/browse/JBIDE-6061 issue.
@@ -30,7 +30,6 @@
private static final String JSP_PAGE_NAME = "/WebContent/pages/jsp_page.jsp"; //$NON-NLS-1$
private static final String XHTML_PAGE_NAME = "/WebContent/pages/xhtml_page.xhtml"; //$NON-NLS-1$
private static final String HTML_PAGE_NAME = "/WebContent/pages/html_page.html"; //$NON-NLS-1$
- private TestProjectProvider provider = null;
private final String[] CSSCLASS_PROPOSALS = new String[]{
"errors", //$NON-NLS-1$
"cls1", //$NON-NLS-1$
@@ -48,16 +47,9 @@
}
public void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test", null, PROJECT_NAME,false); //$NON-NLS-1$
- project = provider.getProject();
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
}
- protected void tearDown() throws Exception {
- if(provider != null) {
- provider.dispose();
- }
- }
-
public void testJbide6061OnJspPage(){
for (String textToFind : STRINGS_TO_FIND_IN_JSP) {
doTheCSSClassValuesTest(JSP_PAGE_NAME, textToFind, CSSCLASS_PROPOSALS);
@@ -119,4 +111,4 @@
}
return r;
}
-}
+}
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r33867 - in trunk: cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-08-12 18:03:50 -0400 (Fri, 12 Aug 2011)
New Revision: 33867
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/ELReferencesQueryParticipantTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java
Log:
https://issues.jboss.org/browse/JBIDE-9473
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF 2011-08-12 21:36:57 UTC (rev 33866)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF 2011-08-12 22:03:50 UTC (rev 33867)
@@ -28,5 +28,6 @@
org.eclipse.search;bundle-version="3.7.0",
org.jboss.tools.common.el.core;bundle-version="3.3.0",
org.jboss.tools.jst.web.kb,
- org.eclipse.wst.validation;bundle-version="1.2.300"
+ org.eclipse.wst.validation;bundle-version="1.2.300",
+ org.jboss.tools.jst.web.kb.test
Export-Package: org.jboss.tools.cdi.ui.test
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-08-12 21:36:57 UTC (rev 33866)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-08-12 22:03:50 UTC (rev 33867)
@@ -35,6 +35,7 @@
import org.jboss.tools.cdi.ui.test.perspective.CDIPerspectiveTest;
import org.jboss.tools.cdi.ui.test.preferences.CDIPreferencePageTest;
import org.jboss.tools.cdi.ui.test.search.CDISearchParticipantTest;
+import org.jboss.tools.cdi.ui.test.search.ELReferencesQueryParticipantTest;
import org.jboss.tools.cdi.ui.test.wizard.AddQualifiersToBeanWizardTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIClassWizardFactoryTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIWizardTest;
@@ -68,6 +69,7 @@
suite.addTestSuite(CDISearchParticipantTest.class);
+ suite.addTestSuite(ELReferencesQueryParticipantTest.class);
suiteAll.addTest(new CDICoreTestSetup(suite) {
@Override
protected void setUp() throws Exception {
Added: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/ELReferencesQueryParticipantTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/ELReferencesQueryParticipantTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/ELReferencesQueryParticipantTest.java 2011-08-12 22:03:50 UTC (rev 33867)
@@ -0,0 +1,49 @@
+package org.jboss.tools.cdi.ui.test.search;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.cdi.ui.test.TCKUITest;
+import org.jboss.tools.jst.web.kb.refactoring.ELReferencesQueryParticipant;
+import org.jboss.tools.jst.web.kb.test.QueryParticipantTestUtils;
+import org.jboss.tools.jst.web.kb.test.QueryParticipantTestUtils.MatchStructure;
+
+public class ELReferencesQueryParticipantTest extends TCKUITest{
+
+ public void testELReferencesQueryParticipantForType() throws CoreException{
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ //matches.add(new MatchStructure("/tck/JavaSource/org/jboss/jsr299/tck/tests/lookup/el/integration/JSFTestPage.jsp", "sheep"));
+ matches.add(new MatchStructure("/tck/WebContent/test.jsp", "sheep"));
+ matches.add(new MatchStructure("/tck/WebContent/el/integration/JSFTestPage.jsp", "sheep"));
+ matches.add(new MatchStructure("/tck/WebContent/tests/lookup/el/integration/JSFTestPage.jsp", "sheep"));
+// matches.add(new MatchStructure("/tck/JavaSource/org/jboss/jsr299/tck/tests/lookup/el/integration/JSFTestPage.jsp", "sheep"));
+
+
+ QueryParticipantTestUtils.testSearchParticipant(tckProject,
+ "JavaSource/org/jboss/jsr299/tck/tests/lookup/el/integration/Sheep.java",
+ QueryParticipantTestUtils.TYPE_SEARCH,
+ "Sheep",
+ "",
+ new ELReferencesQueryParticipant(),
+ matches);
+ }
+
+ public void testELReferencesQueryParticipantForMethod() throws CoreException{
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ //matches.add(new MatchStructure("/tck/JavaSource/org/jboss/jsr299/tck/tests/lookup/el/integration/JSFTestPage.jsp", "name"));
+ matches.add(new MatchStructure("/tck/WebContent/test.jsp", "name"));
+ matches.add(new MatchStructure("/tck/WebContent/el/integration/JSFTestPage.jsp", "name"));
+ matches.add(new MatchStructure("/tck/WebContent/tests/lookup/el/integration/JSFTestPage.jsp", "name"));
+// matches.add(new MatchStructure("/tck/JavaSource/org/jboss/jsr299/tck/tests/lookup/el/integration/JSFTestPage.jsp", "name"));
+
+ QueryParticipantTestUtils.testSearchParticipant(tckProject,
+ "JavaSource/org/jboss/jsr299/tck/tests/lookup/el/integration/Sheep.java",
+ QueryParticipantTestUtils.METHOD_SEARCH,
+ "getName",
+ "",
+ new ELReferencesQueryParticipant(),
+ matches);
+ }
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/ELReferencesQueryParticipantTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java 2011-08-12 21:36:57 UTC (rev 33866)
+++ trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java 2011-08-12 22:03:50 UTC (rev 33867)
@@ -90,24 +90,28 @@
private static void checkMatches(List<Match> matchesForCheck, List<MatchStructure> matchList) throws CoreException {
for(Match match : matchesForCheck){
assertTrue("Match must return IFile", match.getElement() instanceof IFile);
- MatchStructure ms = findMatch(matchList, match);
- assertNotNull("Unexpected match found (file - "+((IFile)match.getElement()).getFullPath()+")", ms);
+
+ IFile file = (IFile)match.getElement();
+ String filePath = file.getFullPath().toString();
+ String text = FileUtil.getContentFromEditorOrFile(file);
+ String name = text.substring(match.getOffset(), match.getOffset()+match.getLength());
+
+ MatchStructure ms = findMatch(matchList, match, filePath, name);
+
+ assertNotNull("Unexpected match found (file - "+filePath+" name - "+name+")", ms);
ms.checked = true;
}
for(MatchStructure ms : matchList){
- assertTrue("Match not found (file - "+ms.path+")", ms.checked);
+ assertTrue("Match not found (file - "+ms.path+" name - "+ms.name+")", ms.checked);
}
}
- protected static MatchStructure findMatch(List<MatchStructure> matchList, Match match){
- IFile file = (IFile)match.getElement();
- String filePath = file.getFullPath().toString();
- String text = FileUtil.getContentFromEditorOrFile(file);
- String name = text.substring(match.getOffset(), match.getOffset()+match.getLength());
+ protected static MatchStructure findMatch(List<MatchStructure> matchList, Match match, String filePath, String name){
+
for(MatchStructure ms : matchList){
if(!ms.checked && ms.path.equals(filePath) && ms.name.equals(name)){
- System.out.println("found!");
+ //System.out.println("Match found (file - "+ms.path+" name - "+ms.name+")");
return ms;
}
}
14 years, 8 months
JBoss Tools SVN: r33866 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-08-12 17:36:57 -0400 (Fri, 12 Aug 2011)
New Revision: 33866
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java
Log:
JBIDE-7892
https://issues.jboss.org/browse/JBIDE-7892
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java 2011-08-12 21:05:40 UTC (rev 33865)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/OpenCDINamedBeanDialog.java 2011-08-12 21:36:57 UTC (rev 33866)
@@ -44,7 +44,6 @@
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.internal.core.event.CDIProjectChangeEvent;
import org.jboss.tools.cdi.internal.core.event.ICDIProjectChangeListener;
-import org.jboss.tools.cdi.internal.core.impl.CDIElement;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.cdi.ui.CDIUiImages;
@@ -179,7 +178,7 @@
if (cdiProject != null) {
Set<IBean> iter = cdiProject.getNamedBeans(false);
for (IBean bean: iter) {
- if (bean instanceof CDIElement && cdiProject == ((CDIElement)bean).getDeclaringProject()) {
+ if (cdiProject == bean.getDeclaringProject()) {
contentProvider.add(new CDINamedBeanWrapper(bean
.getName(), project.getName(), bean),
itemsFilter);
14 years, 8 months