JBoss Tools SVN: r22612 - trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-06-07 14:55:33 -0400 (Mon, 07 Jun 2010)
New Revision: 22612
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6418
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-07 18:09:50 UTC (rev 22611)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-07 18:55:33 UTC (rev 22612)
@@ -16,6 +16,7 @@
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IParametedType;
+import org.jboss.tools.cdi.core.IProducerMethod;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
@@ -81,6 +82,20 @@
/**
* Section 5.2 - Typesafe resolution
+ * j) Test with an array type.
+ *
+ * @throws CoreException
+ */
+ public void testResolveByTypeWithArray() throws CoreException {
+ IType type = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.SpiderProducer");
+ IParametedType parametedType = cdiProject.getNature().getTypeFactory().getParametedType(type, "[QSpider;");
+ Set<IBean> beans = cdiProject.getBeans(true, parametedType, new IQualifierDeclaration[0]);
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ assertTrue("The bean should be a producer method.", beans.iterator().next() instanceof IProducerMethod);
+ }
+
+ /**
+ * Section 5.2 - Typesafe resolution
* ld) Test with matching beans with matching qualifier with same annotation member value for each member which is not annotated @javax.enterprise.util.NonBinding.
*
* @throws CoreException
14 years, 7 months
JBoss Tools SVN: r22611 - trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/tools/smooks/core/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2010-06-07 14:09:50 -0400 (Mon, 07 Jun 2010)
New Revision: 22611
Modified:
trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/tools/smooks/core/test/SmooksCoreAllTests.java
Log:
https://jira.jboss.org/browse/JBDS-1202 problems running tests
fix test errors for smooks plug-in loading test
Modified: trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/tools/smooks/core/test/SmooksCoreAllTests.java
===================================================================
--- trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/tools/smooks/core/test/SmooksCoreAllTests.java 2010-06-07 18:06:57 UTC (rev 22610)
+++ trunk/smooks/tests/org.jboss.tools.smooks.core.test/src/org/jboss/tools/smooks/core/test/SmooksCoreAllTests.java 2010-06-07 18:09:50 UTC (rev 22611)
@@ -4,6 +4,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.core.runtime.Platform;
import org.jboss.tools.smooks.test.csvparser.CsvParserTest;
import org.jboss.tools.smooks.test.ediparser.EDIParserTest;
import org.jboss.tools.smooks.test.jsonparse.JsonParserTest;
@@ -33,8 +34,8 @@
public SmooksPluginsLoadTest() {}
- public void testBirtPluginsAreResolvedAndActivated() {
- testBundlesAreLoadedFor("org.jboss.tools.smooks.feature");
+ public void testOrgJbossToolsSmooksCorePluginIsResolvedAndActivated() {
+ assertPluginResolved(Platform.getBundle("org.jboss.tools.smooks.core"));
}
}
}
14 years, 7 months
JBoss Tools SVN: r22610 - in branches/3.2.helios/seam: tests and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-06-07 14:06:57 -0400 (Mon, 07 Jun 2010)
New Revision: 22610
Removed:
branches/3.2.helios/seam/tests/org.jboss.tools.seam.text.ext.test/
branches/3.2.helios/seam/tests/org.jboss.tools.seam.ui.pages.test/
branches/3.2.helios/seam/tests/org.jboss.tools.seam.xml.ui.test/
Modified:
branches/3.2.helios/seam/features/org.jboss.tools.seam.test.feature/feature.xml
branches/3.2.helios/seam/tests/pom.xml
Log:
https://jira.jboss.org/browse/JBIDE-6421 Removed empty tests plug-ins
Modified: branches/3.2.helios/seam/features/org.jboss.tools.seam.test.feature/feature.xml
===================================================================
--- branches/3.2.helios/seam/features/org.jboss.tools.seam.test.feature/feature.xml 2010-06-07 18:04:36 UTC (rev 22609)
+++ branches/3.2.helios/seam/features/org.jboss.tools.seam.test.feature/feature.xml 2010-06-07 18:06:57 UTC (rev 22610)
@@ -30,20 +30,6 @@
version="0.0.0"/>
<plugin
- id="org.jboss.tools.seam.text.ext.test"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.jboss.tools.seam.ui.pages.test"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
id="org.jboss.tools.seam.ui.test"
download-size="0"
install-size="0"
@@ -56,11 +42,4 @@
version="0.0.0"
unpack="false"/>
- <plugin
- id="org.jboss.tools.seam.xml.ui.test"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
</feature>
Modified: branches/3.2.helios/seam/tests/pom.xml
===================================================================
--- branches/3.2.helios/seam/tests/pom.xml 2010-06-07 18:04:36 UTC (rev 22609)
+++ branches/3.2.helios/seam/tests/pom.xml 2010-06-07 18:06:57 UTC (rev 22610)
@@ -14,12 +14,9 @@
<modules>
<module>org.jboss.tools.seam.core.test</module>
<module>org.jboss.tools.seam.pages.xml.test</module>
- <module>org.jboss.tools.seam.text.ext.test</module>
<module>org.jboss.tools.seam.ui.bot.test</module>
- <module>org.jboss.tools.seam.ui.pages.test</module>
<module>org.jboss.tools.seam.ui.test</module>
<module>org.jboss.tools.seam.xml.test</module>
- <module>org.jboss.tools.seam.xml.ui.test</module>
</modules>
</project>
14 years, 7 months
JBoss Tools SVN: r22609 - in trunk/seam: tests and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-06-07 14:04:36 -0400 (Mon, 07 Jun 2010)
New Revision: 22609
Removed:
trunk/seam/tests/org.jboss.tools.seam.text.ext.test/
trunk/seam/tests/org.jboss.tools.seam.ui.pages.test/
trunk/seam/tests/org.jboss.tools.seam.xml.ui.test/
Modified:
trunk/seam/features/org.jboss.tools.seam.test.feature/feature.xml
trunk/seam/tests/pom.xml
Log:
https://jira.jboss.org/browse/JBIDE-6421 Removed empty tests plug-ins
Modified: trunk/seam/features/org.jboss.tools.seam.test.feature/feature.xml
===================================================================
--- trunk/seam/features/org.jboss.tools.seam.test.feature/feature.xml 2010-06-07 18:03:38 UTC (rev 22608)
+++ trunk/seam/features/org.jboss.tools.seam.test.feature/feature.xml 2010-06-07 18:04:36 UTC (rev 22609)
@@ -30,20 +30,6 @@
version="0.0.0"/>
<plugin
- id="org.jboss.tools.seam.text.ext.test"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.jboss.tools.seam.ui.pages.test"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
id="org.jboss.tools.seam.ui.test"
download-size="0"
install-size="0"
@@ -56,11 +42,4 @@
version="0.0.0"
unpack="false"/>
- <plugin
- id="org.jboss.tools.seam.xml.ui.test"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
</feature>
Modified: trunk/seam/tests/pom.xml
===================================================================
--- trunk/seam/tests/pom.xml 2010-06-07 18:03:38 UTC (rev 22608)
+++ trunk/seam/tests/pom.xml 2010-06-07 18:04:36 UTC (rev 22609)
@@ -14,12 +14,9 @@
<modules>
<module>org.jboss.tools.seam.core.test</module>
<module>org.jboss.tools.seam.pages.xml.test</module>
- <module>org.jboss.tools.seam.text.ext.test</module>
<module>org.jboss.tools.seam.ui.bot.test</module>
- <module>org.jboss.tools.seam.ui.pages.test</module>
<module>org.jboss.tools.seam.ui.test</module>
<module>org.jboss.tools.seam.xml.test</module>
- <module>org.jboss.tools.seam.xml.ui.test</module>
</modules>
</project>
14 years, 7 months
JBoss Tools SVN: r22608 - in trunk/portlet/tests/org.jboss.tools.portlet.core.test: META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2010-06-07 14:03:38 -0400 (Mon, 07 Jun 2010)
New Revision: 22608
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF
trunk/portlet/tests/org.jboss.tools.portlet.core.test/pom.xml
trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/test/PortletPluginsLoadTest.java
Log:
https://jira.jboss.org/browse/JBDS-1202 problems running tests
fix test errors for portlet plug-in loading test
Modified: trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF 2010-06-07 18:02:00 UTC (rev 22607)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/META-INF/MANIFEST.MF 2010-06-07 18:03:38 UTC (rev 22608)
@@ -6,5 +6,6 @@
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.jboss.tools.tests;bundle-version="2.0.0",
org.junit;bundle-version="3.8.2",
- org.jboss.tools.portlet.core;bundle-version="1.0.0"
+ org.jboss.tools.portlet.core;bundle-version="1.0.0",
+ org.eclipse.core.runtime;bundle-version="3.5.0"
Export-Package: org.jboss.tools.portlet.core.test
Modified: trunk/portlet/tests/org.jboss.tools.portlet.core.test/pom.xml
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/pom.xml 2010-06-07 18:02:00 UTC (rev 22607)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/pom.xml 2010-06-07 18:03:38 UTC (rev 22608)
@@ -11,15 +11,4 @@
<artifactId>org.jboss.tools.portlet.core.test</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.sonatype.tycho</groupId>
- <artifactId>maven-osgi-test-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
Modified: trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/test/PortletPluginsLoadTest.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/test/PortletPluginsLoadTest.java 2010-06-07 18:02:00 UTC (rev 22607)
+++ trunk/portlet/tests/org.jboss.tools.portlet.core.test/src/org/jboss/tools/portlet/core/test/PortletPluginsLoadTest.java 2010-06-07 18:03:38 UTC (rev 22608)
@@ -1,10 +1,16 @@
package org.jboss.tools.portlet.core.test;
+import org.eclipse.core.runtime.Platform;
import org.jboss.tools.tests.AbstractPluginsLoadTest;
public class PortletPluginsLoadTest extends AbstractPluginsLoadTest {
- public void testPortlrtPlugisAreResolvedAndActivated() {
- testBundlesAreLoadedFor("org.jboss.tools.portlet.feature");
+ public void testOrgJbossPortletCorePluginIsActivated() {
+ assertPluginResolved(Platform.getBundle("org.jboss.tools.portlet.core"));
}
+
+ public void testOrgJbossPortletUiPluginIsActivated() {
+ assertPluginResolved(Platform.getBundle("org.jboss.tools.portlet.ui"));
+ }
+
}
14 years, 7 months
JBoss Tools SVN: r22607 - trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2010-06-07 14:02:00 -0400 (Mon, 07 Jun 2010)
New Revision: 22607
Added:
trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java
Modified:
trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java
Log:
https://jira.jboss.org/browse/JBDS-1202 problems running tests
add assert function to check if plug-in is loaded and activated
Modified: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java 2010-06-07 17:46:33 UTC (rev 22606)
+++ trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java 2010-06-07 18:02:00 UTC (rev 22607)
@@ -37,9 +37,9 @@
* @author eskimo
*
*/
-public class AbstractPluginsLoadTest extends TestCase {
+public class AbstractPluginsLoadTest extends AbstractRuntimeTest {
- public static final String BUNDLE_GROUP_PROVIDER_NAME = "Update Manager Configurator";
+
private static final String PLUGIN_TAG_NAME = "plugin";
private static final String ID_ATTRIBUTE_NAME = "id";
@@ -80,43 +80,7 @@
}
}
- /**
- * @param featureId
- */
- private Bundle getFirstBundleFor(String featureId) {
- IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
- System.out.println(providers.length);
- for (IBundleGroupProvider iBundleGroupProvider : providers) {
- System.out.println(iBundleGroupProvider.getName());
- IBundleGroup[] bundleGroups = iBundleGroupProvider.getBundleGroups();
- if(BUNDLE_GROUP_PROVIDER_NAME.equals(iBundleGroupProvider.getName())) {
- for (IBundleGroup iBundleGroup : bundleGroups) {
- if(iBundleGroup.getIdentifier().equals(featureId)) {
- Bundle[] bundles = iBundleGroup.getBundles();
- for (Bundle bundle : bundles) {
- return bundle;
- }
- }
- }
- }
- }
- return null;
- }
-
- private boolean isPluginResolved(String pluginId) {
- Bundle bundle = Platform.getBundle(pluginId);
- assertNotNull(pluginId + " failed to load.", bundle); //$NON-NLS-1$
- try {
- // this line is needed to to force plug-in loading and to change it state to ACTIVE
- bundle.loadClass("fake class"); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- // It happens always because loaded class doesn't not exist
- }
- return ((bundle.getState() & Bundle.RESOLVED) > 0)
- || ((bundle.getState() & Bundle.ACTIVE) > 0);
- }
-
- private void assertPluginsResolved(Bundle[] bundles) {
+ public void assertPluginsResolved(Bundle[] bundles) {
for (Bundle bundle : bundles) {
assertTrue("Plugin '" + bundle.getSymbolicName() + "' is not resolved", //$NON-NLS-1$ //$NON-NLS-2$
isPluginResolved(bundle.getSymbolicName()));
@@ -124,15 +88,7 @@
}
}
-// public void testAsComp() throws IOException {
-// testBundlesAreLoadedFor("org.jboss.ide.eclipse.as.feature");
-// }
-//
-// public void testJdtComp() throws IOException {
-// testBundlesAreLoadedFor("org.eclipse.jdt");
-// }
-//
-// public void testRichfacesComp() throws IOException {
-// testBundlesAreLoadedFor("org.jboss.tools.richfaces.feature");
-// }
+ public void assertPluginResolved(Bundle bundle) {
+ assertPluginsResolved(new Bundle[] {bundle});
+ }
}
Added: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java 2010-06-07 18:02:00 UTC (rev 22607)
@@ -0,0 +1,60 @@
+package org.jboss.tools.tests;
+
+import org.eclipse.core.runtime.IBundleGroup;
+import org.eclipse.core.runtime.IBundleGroupProvider;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+import junit.framework.TestCase;
+
+public class AbstractRuntimeTest extends TestCase{
+
+ public static final String BUNDLE_GROUP_PROVIDER_NAME = "Update Manager Configurator";
+
+ /**
+ * @param featureId
+ */
+ public Bundle getFirstBundleFor(String featureId) {
+ IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
+ System.out.println(providers.length);
+ IBundleGroup iBundleGroup = getFirstBundleGroupFor(featureId);
+ Bundle[] bundles = iBundleGroup.getBundles();
+ for (Bundle bundle : bundles) {
+ return bundle;
+ }
+ return null;
+ }
+
+
+ public IBundleGroup getFirstBundleGroupFor(String featureId) {
+ IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
+ System.out.println(providers.length);
+ for (IBundleGroupProvider iBundleGroupProvider : providers) {
+ System.out.println(iBundleGroupProvider.getName());
+ IBundleGroup[] bundleGroups = iBundleGroupProvider.getBundleGroups();
+ if(BUNDLE_GROUP_PROVIDER_NAME.equals(iBundleGroupProvider.getName())) {
+ for (IBundleGroup iBundleGroup : bundleGroups) {
+ if(iBundleGroup.getIdentifier().equals(featureId)) {
+ return iBundleGroup;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+
+ public boolean isPluginResolved(String pluginId) {
+ Bundle bundle = Platform.getBundle(pluginId);
+ assertNotNull(pluginId + " failed to load.", bundle); //$NON-NLS-1$
+ try {
+ // this line is needed to to force plug-in loading and to change it state to ACTIVE
+ bundle.loadClass("fake class"); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ // It happens always because loaded class doesn't not exist
+ }
+ return ((bundle.getState() & Bundle.RESOLVED) > 0)
+ || ((bundle.getState() & Bundle.ACTIVE) > 0);
+ }
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRuntimeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 7 months
JBoss Tools SVN: r22606 - in trunk/cdi: tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-06-07 13:46:33 -0400 (Mon, 07 Jun 2010)
New Revision: 22606
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6418
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2010-06-07 17:05:44 UTC (rev 22605)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2010-06-07 17:46:33 UTC (rev 22606)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * 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,
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java 2010-06-07 17:05:44 UTC (rev 22605)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParametedTypeFactory.java 2010-06-07 17:46:33 UTC (rev 22606)
@@ -1,6 +1,15 @@
+/*******************************************************************************
+ * 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.cdi.internal.core.impl.definition;
-
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
@@ -11,6 +20,7 @@
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.internal.core.impl.ParametedType;
import org.jboss.tools.cdi.internal.core.impl.TypeDeclaration;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
@@ -36,7 +46,7 @@
try {
r = type.getNameRange();
} catch (CoreException e) {
- //ignore
+ CDICorePlugin.getDefault().logError(e);
}
if(r != null) {
parametedType = new TypeDeclaration(parametedType, r.getOffset(), r.getLength());
@@ -138,5 +148,4 @@
public void clean() {
cache.clear();
}
-
}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-07 17:05:44 UTC (rev 22605)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-07 17:46:33 UTC (rev 22606)
@@ -13,9 +13,12 @@
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
/**
* @author Alexey Kazakov
@@ -24,6 +27,60 @@
/**
* Section 5.2 - Typesafe resolution
+ * lb) Test with beans without required qualifiers.
+ *
+ * @throws CoreException
+ */
+ public void testDefaultBindingTypeAssumed() throws CoreException {
+ Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ assertContainsBeanType(beans.iterator().next(), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
+ }
+
+ /**
+ * Section 5.2 - Typesafe resolution
+ * hc) Check multiple types resolve to a single getBeans().
+ *
+ * @throws CoreException
+ */
+ public void testResolveByType() throws CoreException {
+ Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna", "javax.enterprise.inject.Default");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Animal", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.FishILike");
+ assertEquals("Wrong number of the beans", 3, beans.size());
+ assertContainsBeanClasses(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Salmon", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.SeaBass", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Haddock");
+ }
+
+ /**
+ * Section 5.2 - Typesafe resolution
+ * lc) Test with matching beans with matching qualifier with same type.
+ *
+ * @throws CoreException
+ */
+ public void testAllQualifiersSpecifiedForResolutionMustAppearOnBean() throws CoreException {
+ Set<IBean> beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Animal", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Chunky", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Whitefish");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ beans = getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.ScottishFish", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Whitefish");
+ assertEquals("Wrong number of the beans", 2, beans.size());
+ assertContainsBeanClasses(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cod", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Sole");
+ }
+
+ /**
+ * Section 5.2 - Typesafe resolution
+ * ka) Test with a parameterized type.
+ *
+ * @throws CoreException
+ */
+ public void testResolveByTypeWithTypeParameter() throws CoreException {
+ IType type = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.ScottishFishFarmer");
+ IParametedType parametedType = cdiProject.getNature().getTypeFactory().getParametedType(type, "QFarmer<QScottishFish;>;");
+ Set<IBean> beans = cdiProject.getBeans(true, parametedType, new IQualifierDeclaration[0]);
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ assertContainsBeanClasses(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.ScottishFishFarmer");
+ }
+
+ /**
+ * Section 5.2 - Typesafe resolution
* ld) Test with matching beans with matching qualifier with same annotation member value for each member which is not annotated @javax.enterprise.util.NonBinding.
*
* @throws CoreException
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-07 17:05:44 UTC (rev 22605)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-07 17:46:33 UTC (rev 22606)
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.FileFilter;
+import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
@@ -108,11 +109,17 @@
return project;
}
- protected Set<IBean> getBeans(String typeName) throws JavaModelException {
+ protected Set<IBean> getBeans(String typeName, String... qualifierNames) throws JavaModelException {
IParametedType type = getType(typeName);
assertNotNull("Can't find " + typeName + " type.", type);
- Set<IBean> beans = cdiProject.getBeans(true, type, new IType[0]);
- assertNotNull("There is no eny beans with " + typeName + " type", beans);
+ Set<IType> qualifiers = new HashSet<IType>();
+ for (String name : qualifierNames) {
+ IType qualifier = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()), name);
+ assertNotNull("Can't find " + name + " type.", qualifier);
+ qualifiers.add(qualifier);
+ }
+ Set<IBean> beans = cdiProject.getBeans(true, type, qualifiers.toArray(new IType[0]));
+ assertNotNull("There is no beans with " + typeName + " type", beans);
return beans;
}
14 years, 7 months
JBoss Tools SVN: r22605 - trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2010-06-07 13:05:44 -0400 (Mon, 07 Jun 2010)
New Revision: 22605
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConcoleConfigurationAdapter.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
Log:
https://jira.jboss.org/browse/JBIDE-6403 - fixed
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConcoleConfigurationAdapter.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConcoleConfigurationAdapter.java 2010-06-07 17:01:26 UTC (rev 22604)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConcoleConfigurationAdapter.java 2010-06-07 17:05:44 UTC (rev 22605)
@@ -11,7 +11,6 @@
package org.hibernate.console;
import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
/**
* This adapter class provides default implementations for the
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java 2010-06-07 17:05:44 UTC (rev 22605)
@@ -0,0 +1,457 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.console;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.dom4j.DocumentException;
+import org.dom4j.Node;
+import org.dom4j.io.DOMWriter;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.NamingStrategy;
+import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
+import org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.resolver.DialectFactory;
+import org.hibernate.util.ConfigHelper;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.util.StringHelper;
+import org.hibernate.util.XMLHelper;
+import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+public class ConfigurationFactory {
+
+ private ConsoleConfigurationPreferences prefs;
+ private Map<String, FakeDelegatingDriver> fakeDrivers;
+ private boolean rejectProfileRefresh;
+
+ public ConfigurationFactory(ConsoleConfigurationPreferences prefs,
+ Map<String, FakeDelegatingDriver> fakeDrivers, boolean rejectProfileRefresh) {
+ this.prefs = prefs;
+ this.fakeDrivers = fakeDrivers;
+ this.rejectProfileRefresh = rejectProfileRefresh;
+ }
+
+ public ConsoleConfigurationPreferences getPreferences() {
+ return prefs;
+ }
+
+ public Configuration createConfiguration(Configuration localCfg, boolean includeMappings) {
+ Properties properties = prefs.getProperties();
+
+ if (properties != null) {
+ // in case the transaction manager is empty then we need to inject a faketm since
+ // hibernate will still try and instantiate it.
+ String str = properties.getProperty("hibernate.transaction.manager_lookup_class"); //$NON-NLS-1$
+ if (str != null && StringHelper.isEmpty(str)) {
+ properties
+ .setProperty(
+ "hibernate.transaction.manager_lookup_class", "org.hibernate.console.FakeTransactionManagerLookup"); //$NON-NLS-1$ //$NON-NLS-2$
+ // properties.setProperty( "hibernate.transaction.factory_class", "");
+ }
+ }
+ if (localCfg == null) {
+ localCfg = buildConfiguration(properties, includeMappings);
+ } else {
+ // Properties origProperties = cfg.getProperties();
+ // origProperties.putAll(properties);
+ // cfg.setProperties(origProperties);
+ // TODO: this is actually only for jdbc reveng...
+ // localCfg = configureStandardConfiguration( includeMappings, localCfg, properties );
+ }
+
+ // here both setProperties and configxml have had their chance to tell which databasedriver
+ // is needed.
+ registerFakeDriver(localCfg.getProperty(Environment.DRIVER));
+ // autoConfigureDialect(localCfg); Disabled for now since it causes very looong timeouts for
+ // non-running databases + i havent been needed until now...
+
+ // TODO: jpa configuration ?
+ if (includeMappings) {
+ File[] mappingFiles = prefs.getMappingFiles();
+
+ for (int i = 0; i < mappingFiles.length; i++) {
+ File hbm = mappingFiles[i];
+ localCfg = localCfg.addFile(hbm);
+ }
+ }
+ // TODO: HBX-
+ localCfg.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false"); //$NON-NLS-1$//$NON-NLS-2$
+ localCfg.setProperty(Environment.HBM2DDL_AUTO, "false"); //$NON-NLS-1$
+ // to fix: JBIDE-5839 & JBIDE-5997 - setup this property: false is default value
+ // to make hibernate tools diff hibernate versions compatible:
+ // if the property not set get NoSuchMethodError with FullTextIndexEventListener
+ if (localCfg.getProperty("hibernate.search.autoregister_listeners") == null) { //$NON-NLS-1$
+ localCfg.setProperty("hibernate.search.autoregister_listeners", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return localCfg;
+ }
+
+ @SuppressWarnings("unused")
+ private void autoConfigureDialect(Configuration localCfg) {
+ if (localCfg.getProperty(Environment.DIALECT) == null) {
+ String url = localCfg.getProperty(Environment.URL);
+ String user = localCfg.getProperty(Environment.USER);
+ String pass = localCfg.getProperty(Environment.PASS);
+ Connection connection = null;
+ try {
+ connection = DriverManager.getConnection(url, user, pass);
+ // SQL Dialect:
+ Dialect dialect = DialectFactory.buildDialect(localCfg.getProperties(), connection);
+ localCfg.setProperty(Environment.DIALECT, dialect.toString());
+ } catch (SQLException e) {
+ // can't determine dialect
+ }
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ // TODO: delegate to some extension point
+ private Configuration buildConfiguration(Properties properties, boolean includeMappings) {
+ Configuration localCfg = null;
+ if (prefs.getConfigurationMode().equals(ConfigurationMode.ANNOTATIONS)) {
+ try {
+ localCfg = buildAnnotationConfiguration();
+ localCfg = configureStandardConfiguration(includeMappings, localCfg, properties);
+ } catch (HibernateConsoleRuntimeException he) {
+ throw he;
+ } catch (Exception e) {
+ throw new HibernateConsoleRuntimeException(
+ ConsoleMessages.ConsoleConfiguration_could_not_load_annotationconfiguration,
+ e);
+ }
+ } else if (prefs.getConfigurationMode().equals(ConfigurationMode.JPA)) {
+ try {
+ localCfg = buildJPAConfiguration(getPreferences().getPersistenceUnitName(),
+ properties, prefs.getEntityResolverName(), includeMappings);
+ } catch (HibernateConsoleRuntimeException he) {
+ throw he;
+ } catch (Exception e) {
+ throw new HibernateConsoleRuntimeException(
+ ConsoleMessages.ConsoleConfiguration_could_not_load_jpa_configuration, e);
+ }
+ } else {
+ localCfg = new Configuration();
+ localCfg = configureStandardConfiguration(includeMappings, localCfg, properties);
+ }
+ return localCfg;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Configuration buildAnnotationConfiguration() throws ClassNotFoundException,
+ InstantiationException, IllegalAccessException {
+ Class<Configuration> clazz = ReflectHelper
+ .classForName("org.hibernate.cfg.AnnotationConfiguration"); //$NON-NLS-1$
+ Configuration newInstance = clazz.newInstance();
+ return newInstance;
+ }
+
+ private Configuration buildJPAConfiguration(String persistenceUnit, Properties properties,
+ String entityResolver, boolean includeMappings) {
+ if (StringHelper.isEmpty(persistenceUnit)) {
+ persistenceUnit = null;
+ }
+ try {
+ Map<Object, Object> overrides = new HashMap<Object, Object>();
+ if (properties != null) {
+ overrides.putAll(properties);
+ }
+ if (StringHelper.isNotEmpty(prefs.getNamingStrategy())) {
+ overrides.put("hibernate.ejb.naming_strategy", prefs.getNamingStrategy()); //$NON-NLS-1$
+ }
+ if (StringHelper.isNotEmpty(prefs.getDialectName())) {
+ overrides.put("hibernate.dialect", prefs.getDialectName()); //$NON-NLS-1$
+ }
+ if (!includeMappings) {
+ overrides.put("hibernate.archive.autodetection", "none"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ Class<?> clazz = ReflectHelper.classForName(
+ "org.hibernate.ejb.Ejb3Configuration", ConsoleConfiguration.class); //$NON-NLS-1$
+ Object ejb3cfg = clazz.newInstance();
+ if (StringHelper.isNotEmpty(entityResolver)) {
+ Class<?> resolver = ReflectHelper.classForName(entityResolver, this.getClass());
+ Object object = resolver.newInstance();
+ Method method = clazz.getMethod(
+ "setEntityResolver", new Class[] { EntityResolver.class });//$NON-NLS-1$
+ method.invoke(ejb3cfg, new Object[] { object });
+ }
+ Method method = clazz.getMethod("configure", new Class[] { String.class, Map.class }); //$NON-NLS-1$
+ if (method.invoke(ejb3cfg, new Object[] { persistenceUnit, overrides }) == null) {
+ String out = NLS.bind(
+ ConsoleMessages.ConsoleConfiguration_persistence_unit_not_found,
+ persistenceUnit);
+ throw new HibernateConsoleRuntimeException(out);
+ }
+ method = clazz.getMethod("getHibernateConfiguration", new Class[0]);//$NON-NLS-1$
+ Configuration invoke = (Configuration) method.invoke(ejb3cfg, (Object[]) null);
+ invoke = configureConnectionProfile(invoke);
+ return invoke;
+ } catch (HibernateConsoleRuntimeException he) {
+ throw he;
+ } catch (Exception e) {
+ throw new HibernateConsoleRuntimeException(
+ ConsoleMessages.ConsoleConfiguration_could_not_create_jpa_based_configuration,
+ e);
+ }
+ }
+
+ private Configuration configureStandardConfiguration(final boolean includeMappings,
+ Configuration localCfg, Properties properties) {
+ if (properties != null) {
+ localCfg = localCfg.setProperties(properties);
+ }
+ EntityResolver entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
+ if (StringHelper.isNotEmpty(prefs.getEntityResolverName())) {
+ try {
+ entityResolver = (EntityResolver) ReflectHelper.classForName(
+ prefs.getEntityResolverName()).newInstance();
+ } catch (Exception c) {
+ throw new HibernateConsoleRuntimeException(
+ ConsoleMessages.ConsoleConfiguration_could_not_configure_entity_resolver
+ + prefs.getEntityResolverName(), c);
+ }
+ }
+ localCfg.setEntityResolver(entityResolver);
+ if (StringHelper.isNotEmpty(prefs.getNamingStrategy())) {
+ try {
+ NamingStrategy ns = (NamingStrategy) ReflectHelper.classForName(
+ prefs.getNamingStrategy()).newInstance();
+ localCfg.setNamingStrategy(ns);
+ } catch (Exception c) {
+ throw new HibernateConsoleRuntimeException(
+ ConsoleMessages.ConsoleConfiguration_could_not_configure_naming_strategy
+ + prefs.getNamingStrategy(), c);
+ }
+ }
+ localCfg = loadConfigurationXML(localCfg, includeMappings, entityResolver);
+ localCfg = configureConnectionProfile(localCfg);
+ // replace dialect if it is set in preferences
+ if (StringHelper.isNotEmpty(prefs.getDialectName())) {
+ localCfg.setProperty("hibernate.dialect", prefs.getDialectName()); //$NON-NLS-1$
+ }
+ return localCfg;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Configuration loadConfigurationXML(Configuration localCfg, boolean includeMappings,
+ EntityResolver entityResolver) {
+ File configXMLFile = prefs.getConfigXMLFile();
+ if (!includeMappings) {
+ org.dom4j.Document doc;
+ XMLHelper xmlHelper = new XMLHelper();
+ InputStream stream = null;
+ String resourceName = "<unknown>"; //$NON-NLS-1$
+ if (configXMLFile != null) {
+ resourceName = configXMLFile.toString();
+ try {
+ stream = new FileInputStream(configXMLFile);
+ } catch (FileNotFoundException e1) {
+ throw new HibernateConsoleRuntimeException(
+ ConsoleMessages.ConsoleConfiguration_could_not_access + configXMLFile,
+ e1);
+ }
+ } else {
+ resourceName = "/hibernate.cfg.xml"; //$NON-NLS-1$
+ if (checkHibernateResoureExistence(resourceName)) {
+ stream = ConfigHelper.getResourceAsStream(resourceName); // simulate hibernate's
+ // default look up
+ } else {
+ return localCfg;
+ }
+ }
+ try {
+ List<Throwable> errors = new ArrayList<Throwable>();
+ doc = xmlHelper.createSAXReader(resourceName, errors, entityResolver).read(
+ new InputSource(stream));
+ if (errors.size() != 0) {
+ throw new MappingException(
+ ConsoleMessages.ConsoleConfiguration_invalid_configuration, errors
+ .get(0));
+ }
+ List<Node> list = doc.getRootElement()
+ .element("session-factory").elements("mapping"); //$NON-NLS-1$ //$NON-NLS-2$
+ for (Node element : list) {
+ element.getParent().remove(element);
+ }
+ DOMWriter dw = new DOMWriter();
+ Document document = dw.write(doc);
+ return localCfg.configure(document);
+
+ } catch (DocumentException e) {
+ throw new HibernateException(
+ ConsoleMessages.ConsoleConfiguration_could_not_parse_configuration
+ + resourceName, e);
+ } finally {
+ try {
+ if (stream != null)
+ stream.close();
+ } catch (IOException ioe) {
+ // log.warn( "could not close input stream for: " + resourceName, ioe );
+ }
+ }
+ } else {
+ if (configXMLFile != null) {
+ return localCfg.configure(configXMLFile);
+ } else {
+ Configuration resultCfg = localCfg;
+ if (checkHibernateResoureExistence("/hibernate.cfg.xml")) { //$NON-NLS-1$
+ resultCfg = localCfg.configure();
+ }
+ return resultCfg;
+ }
+ }
+ }
+
+ private boolean checkHibernateResoureExistence(String resource) {
+ InputStream is = null;
+ try {
+ is = ConfigHelper.getResourceAsStream(resource);
+ } catch (HibernateException e) {
+ // just ignore
+ } finally {
+ try {
+ if (is != null)
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return (is != null);
+ }
+
+ private Configuration configureConnectionProfile(Configuration localCfg) {
+ String connectionProfile = prefs.getConnectionProfileName();
+ if (connectionProfile == null) {
+ return localCfg;
+ }
+ IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(
+ connectionProfile);
+ if (profile != null) {
+ if (!rejectProfileRefresh) {
+ ConnectionProfileUtil.refreshProfile(profile);
+ }
+ //
+ final Properties invokeProperties = localCfg.getProperties();
+ // set this property to null!
+ invokeProperties.remove(Environment.DATASOURCE);
+ localCfg.setProperties(invokeProperties);
+ Properties cpProperties = profile.getProperties(profile.getProviderId());
+ // seems we should not setup dialect here
+ // String dialect =
+ // "org.hibernate.dialect.HSQLDialect";//cpProperties.getProperty("org.eclipse.datatools.connectivity.db.driverClass");
+ // invoke.setProperty(Environment.DIALECT, dialect);
+ String driver = cpProperties
+ .getProperty("org.eclipse.datatools.connectivity.db.driverClass"); //$NON-NLS-1$
+ localCfg.setProperty(Environment.DRIVER, driver);
+ // TODO:
+ @SuppressWarnings("unused")
+ String driverJarPath = cpProperties.getProperty("jarList"); //$NON-NLS-1$
+ String url = cpProperties.getProperty("org.eclipse.datatools.connectivity.db.URL"); //$NON-NLS-1$
+ // url += "/";// +
+ // cpProperties.getProperty("org.eclipse.datatools.connectivity.db.databaseName");
+ localCfg.setProperty(Environment.URL, url);
+ String user = cpProperties
+ .getProperty("org.eclipse.datatools.connectivity.db.username"); //$NON-NLS-1$
+ if (null != user && user.length() > 0) {
+ localCfg.setProperty(Environment.USER, user);
+ }
+ String pass = cpProperties
+ .getProperty("org.eclipse.datatools.connectivity.db.password"); //$NON-NLS-1$
+ if (null != pass && pass.length() > 0) {
+ localCfg.setProperty(Environment.PASS, pass);
+ }
+ } else {
+ String out = NLS.bind(
+ ConsoleMessages.ConsoleConfiguration_connection_profile_not_found,
+ connectionProfile);
+ throw new HibernateConsoleRuntimeException(out);
+ }
+ return localCfg;
+ }
+
+ /**
+ * DriverManager checks what classloader a class is loaded from thus we register a FakeDriver
+ * that we know is loaded "properly" which delegates all it class to the real driver. By doing
+ * so we can convince DriverManager that we can use any dynamically loaded driver.
+ *
+ * @param driverClassName
+ */
+ @SuppressWarnings("unchecked")
+ private void registerFakeDriver(String driverClassName) {
+ if (driverClassName != null) {
+ try {
+ Class<Driver> driverClass = ReflectHelper.classForName(driverClassName);
+ if (!fakeDrivers.containsKey(driverClassName)) { // To avoid "double registration"
+ FakeDelegatingDriver fakeDelegatingDriver = new FakeDelegatingDriver(
+ driverClass.newInstance());
+ DriverManager.registerDriver(fakeDelegatingDriver);
+ fakeDrivers.put(driverClassName, fakeDelegatingDriver);
+ }
+ } catch (ClassNotFoundException e) {
+ String out =
+ NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ } catch (InstantiationException e) {
+ String out =
+ NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ } catch (IllegalAccessException e) {
+ String out =
+ NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ } catch (SQLException e) {
+ String out =
+ NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ }
+ }
+ }
+}
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConnectionProfileUtil.java 2010-06-07 17:05:44 UTC (rev 22605)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.hibernate.console;
+
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+
+public class ConnectionProfileUtil {
+
+ public static void refreshProfile(IConnectionProfile profile) {
+ // refresh profile (refresh jpa connection):
+ // get fresh information about current db structure and update error markers
+ if (profile.getConnectionState() == IConnectionProfile.CONNECTED_STATE){
+ profile.disconnect(null);
+ }
+ profile.connect(null);
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2010-06-07 17:01:26 UTC (rev 22604)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2010-06-07 17:05:44 UTC (rev 22605)
@@ -22,19 +22,12 @@
package org.hibernate.console;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.sql.Connection;
-import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -44,35 +37,18 @@
import java.util.Map;
import java.util.Properties;
-import org.dom4j.DocumentException;
-import org.dom4j.Node;
-import org.dom4j.io.DOMWriter;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.osgi.util.NLS;
-import org.hibernate.HibernateException;
-import org.hibernate.MappingException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.Settings;
import org.hibernate.console.execution.DefaultExecutionContext;
import org.hibernate.console.execution.ExecutionContext;
import org.hibernate.console.execution.ExecutionContextHolder;
import org.hibernate.console.execution.ExecutionContext.Command;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
-import org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.resolver.DialectFactory;
-import org.hibernate.util.ConfigHelper;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.util.StringHelper;
-import org.hibernate.util.XMLHelper;
-import org.w3c.dom.Document;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
public class ConsoleConfiguration implements ExecutionContextHolder {
@@ -101,10 +77,8 @@
return executionContext.execute(c);
}
-
public ConsoleConfigurationPreferences prefs = null;
-
/**
* Reset so a new configuration or sessionfactory is needed.
*
@@ -114,8 +88,7 @@
configuration = null;
closeSessionFactory();
if (executionContext != null) {
- executionContext.execute(new ExecutionContext.Command() {
-
+ executionContext.execute(new Command() {
public Object execute() {
Iterator<FakeDelegatingDriver> it = fakeDrivers.values().iterator();
while (it.hasNext()) {
@@ -151,77 +124,6 @@
fireConfigurationBuilt();
}
- private Configuration buildJPAConfiguration(String persistenceUnit, Properties properties, String entityResolver, boolean includeMappings) {
- if(StringHelper.isEmpty( persistenceUnit )) {
- persistenceUnit = null;
- }
- try {
- Map<Object,Object> overrides = new HashMap<Object,Object>();
- if(properties!=null) {
- overrides.putAll( properties );
- }
- if(StringHelper.isNotEmpty( prefs.getNamingStrategy())) {
- overrides.put( "hibernate.ejb.naming_strategy", prefs.getNamingStrategy() ); //$NON-NLS-1$
- }
-
- if(StringHelper.isNotEmpty( prefs.getDialectName())) {
- overrides.put( "hibernate.dialect", prefs.getDialectName() ); //$NON-NLS-1$
- }
-
- if(!includeMappings) {
- overrides.put( "hibernate.archive.autodetection", "none" ); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- Class<?> clazz = ReflectHelper.classForName("org.hibernate.ejb.Ejb3Configuration", ConsoleConfiguration.class); //$NON-NLS-1$
- Object ejb3cfg = clazz.newInstance();
-
- if(StringHelper.isNotEmpty(entityResolver)) {
- Class<?> resolver = ReflectHelper.classForName(entityResolver, this.getClass());
- Object object = resolver.newInstance();
- Method method = clazz.getMethod("setEntityResolver", new Class[] { EntityResolver.class });//$NON-NLS-1$
- method.invoke(ejb3cfg, new Object[] { object } );
- }
-
- Method method = clazz.getMethod("configure", new Class[] { String.class, Map.class }); //$NON-NLS-1$
- if ( method.invoke(ejb3cfg, new Object[] { persistenceUnit, overrides } ) == null ) {
- String out = NLS.bind(ConsoleMessages.ConsoleConfiguration_persistence_unit_not_found, persistenceUnit);
- throw new HibernateConsoleRuntimeException(out);
- }
-
- method = clazz.getMethod("getHibernateConfiguration", new Class[0]);//$NON-NLS-1$
- Configuration invoke = (Configuration) method.invoke(ejb3cfg, (Object[])null);
- invoke = configureConnectionProfile(invoke);
-
- return invoke;
- }
- catch (HibernateConsoleRuntimeException he) {
- throw he;
- }
- catch (Exception e) {
- throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_create_jpa_based_configuration,e);
- }
- }
-
- @SuppressWarnings("unchecked")
- private Configuration buildAnnotationConfiguration() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
- Class<Configuration> clazz = ReflectHelper
- .classForName( "org.hibernate.cfg.AnnotationConfiguration" ); //$NON-NLS-1$
- Configuration newInstance = clazz.newInstance();
- return newInstance;
- }
-
- protected void refreshProfile(IConnectionProfile profile) {
- if (rejectProfileRefresh) {
- return;
- }
- // refresh profile (refresh jpa connection):
- // get fresh information about current db structure and update error markers
- if (profile.getConnectionState() == IConnectionProfile.CONNECTED_STATE){
- profile.disconnect(null);
- }
- profile.connect(null);
- }
-
/*
* try get a path to the sql driver jar file from DTP connection profile
*/
@@ -234,7 +136,9 @@
if (profile == null) {
return null;
}
- refreshProfile(profile);
+ if (!rejectProfileRefresh) {
+ ConnectionProfileUtil.refreshProfile(profile);
+ }
//
Properties cpProperties = profile.getProperties(profile.getProviderId());
String driverJarPath = cpProperties.getProperty("jarList"); //$NON-NLS-1$
@@ -272,8 +176,7 @@
customClassPathURLs, 0, customClassPathURLsTmp.length);
// insert DTP connection profile driver jar file URL after the default classpath entries
customClassPathURLs[customClassPathURLsTmp.length] = url;
- }
- else {
+ } else {
customClassPathURLs = customClassPathURLsTmp;
}
return customClassPathURLs;
@@ -318,230 +221,23 @@
*
*/
public Configuration buildWith(final Configuration cfg, final boolean includeMappings) {
- if (classLoader == null) {
- classLoader = createClassLoader();
+ if (classLoader == null) {
+ classLoader = createClassLoader();
+ }
+ executionContext = new DefaultExecutionContext(getName(), classLoader);
+ Configuration result = (Configuration)execute(new Command() {
+ public Object execute() {
+ ConfigurationFactory csf = new ConfigurationFactory(prefs, fakeDrivers, rejectProfileRefresh);
+ return csf.createConfiguration(cfg, includeMappings);
}
- executionContext = new DefaultExecutionContext(getName(), classLoader);
-
- Configuration result = (Configuration) executionContext.execute(new ExecutionContext.Command() {
-
- public Object execute() {
- Configuration localCfg = cfg;
-
- Properties properties = prefs.getProperties();
-
- if(properties!=null) {
- // in case the transaction manager is empty then we need to inject a faketm since hibernate will still try and instantiate it.
- String str = properties.getProperty( "hibernate.transaction.manager_lookup_class" ); //$NON-NLS-1$
- if(str != null && StringHelper.isEmpty( str )) {
- properties.setProperty( "hibernate.transaction.manager_lookup_class", "org.hibernate.console.FakeTransactionManagerLookup"); //$NON-NLS-1$ //$NON-NLS-2$
- //properties.setProperty( "hibernate.transaction.factory_class", "");
- }
- }
-
-
- if(localCfg==null) {
- localCfg = buildConfiguration( properties, includeMappings );
- } else {
- //Properties origProperties = cfg.getProperties();
- //origProperties.putAll(properties);
- //cfg.setProperties(origProperties);
- // TODO: this is actually only for jdbc reveng...
- //localCfg = configureStandardConfiguration( includeMappings, localCfg, properties );
- }
-
- // here both setProperties and configxml have had their chance to tell which databasedriver is needed.
- registerFakeDriver(localCfg.getProperty(Environment.DRIVER) );
- //autoConfigureDialect(localCfg); Disabled for now since it causes very looong timeouts for non-running databases + i havent been needed until now...
-
- // TODO: jpa configuration ?
- if(includeMappings) {
- File[] mappingFiles = prefs.getMappingFiles();
-
- for (int i = 0; i < mappingFiles.length; i++) {
- File hbm = mappingFiles[i];
- localCfg = localCfg.addFile(hbm);
- }
- }
- // TODO: HBX-
- localCfg.setProperty( "hibernate.temp.use_jdbc_metadata_defaults", "false" ); //$NON-NLS-1$//$NON-NLS-2$
- localCfg.setProperty( Environment.HBM2DDL_AUTO, "false" ); //$NON-NLS-1$
- // to fix: JBIDE-5839 & JBIDE-5997 - setup this property: false is default value
- // to make hibernate tools diff hibernate versions compatible:
- // if the property not set get NoSuchMethodError with FullTextIndexEventListener
- if (localCfg.getProperty("hibernate.search.autoregister_listeners") == null) { //$NON-NLS-1$
- localCfg.setProperty("hibernate.search.autoregister_listeners", "false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return localCfg;
- }
-
- private void autoConfigureDialect(Configuration localCfg) {
- if (localCfg.getProperty(Environment.DIALECT) == null){
- String url = localCfg.getProperty(Environment.URL);
- String user = localCfg.getProperty(Environment.USER);
- String pass = localCfg.getProperty(Environment.PASS);
- Connection connection = null;
- try {
- connection = DriverManager.getConnection(url, user, pass);
- //SQL Dialect:
- Dialect dialect = DialectFactory.buildDialect( localCfg.getProperties(), connection );
- localCfg.setProperty(Environment.DIALECT, dialect.toString());
- } catch (SQLException e) {
- //can't determine dialect
- }
- if (connection != null) {
- try {
- connection.close();
- } catch (SQLException e) {
- // ignore
- }
- }
- }
- }
-
- });
-
-
+ });
return result;
}
- @SuppressWarnings("unchecked")
- private Configuration loadConfigurationXML(Configuration localCfg, boolean includeMappings, EntityResolver entityResolver) {
- File configXMLFile = prefs.getConfigXMLFile();
- if(!includeMappings) {
- org.dom4j.Document doc;
- XMLHelper xmlHelper = new XMLHelper();
- InputStream stream = null;
- String resourceName = "<unknown>"; //$NON-NLS-1$
- if(configXMLFile!=null) {
- resourceName = configXMLFile.toString();
- try {
- stream = new FileInputStream( configXMLFile );
- }
- catch (FileNotFoundException e1) {
- throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_access + configXMLFile, e1);
- }
- } else {
- resourceName = "/hibernate.cfg.xml"; //$NON-NLS-1$
- if (checkHibernateResoureExistence(resourceName)) {
- stream = ConfigHelper.getResourceAsStream( resourceName ); // simulate hibernate's default look up
- }
- else {
- return localCfg;
- }
- }
-
- try {
- List<Throwable> errors = new ArrayList<Throwable>();
-
- doc = xmlHelper.createSAXReader( resourceName, errors, entityResolver )
- .read( new InputSource( stream ) );
- if ( errors.size() != 0 ) {
- throw new MappingException(
- ConsoleMessages.ConsoleConfiguration_invalid_configuration,
- errors.get( 0 )
- );
- }
-
-
- List<Node> list = doc.getRootElement().element("session-factory").elements("mapping"); //$NON-NLS-1$ //$NON-NLS-2$
- for (Node element : list) {
- element.getParent().remove(element);
- }
-
- DOMWriter dw = new DOMWriter();
- Document document = dw.write(doc);
- return localCfg.configure( document );
-
- }
- catch (DocumentException e) {
- throw new HibernateException(
- ConsoleMessages.ConsoleConfiguration_could_not_parse_configuration + resourceName, e
- );
- }
- finally {
- try {
- if (stream!=null) stream.close();
- }
- catch (IOException ioe) {
- //log.warn( "could not close input stream for: " + resourceName, ioe );
- }
- }
- } else {
- if(configXMLFile!=null) {
- return localCfg.configure(configXMLFile);
- } else {
- Configuration resultCfg = localCfg;
- if (checkHibernateResoureExistence("/hibernate.cfg.xml")) { //$NON-NLS-1$
- resultCfg = localCfg.configure();
- }
- return resultCfg;
- }
- }
- }
-
- protected boolean checkHibernateResoureExistence(String resource) {
- InputStream is = null;
- try {
- is = ConfigHelper.getResourceAsStream(resource);
- }
- catch (HibernateException e) {
- // just ignore
- }
- finally {
- try {
- if (is != null) is.close();
- }
- catch (IOException e) {
- // ignore
- }
- }
- return (is != null);
- }
-
- /**
- * DriverManager checks what classloader a class is loaded from thus
- * we register a FakeDriver that we know is loaded "properly" which delegates all it class
- * to the real driver.
- *
- * By doing so we can convince DriverManager that we can use any dynamically loaded driver.
- *
- * @param driverClassName
- */
- @SuppressWarnings("unchecked")
- private void registerFakeDriver(String driverClassName) {
-
- if(driverClassName!=null) {
- try {
- Class<Driver> driverClass = ReflectHelper.classForName(driverClassName);
- if(!fakeDrivers.containsKey(driverClassName) ) { // To avoid "double registration"
- FakeDelegatingDriver fakeDelegatingDriver = new FakeDelegatingDriver( driverClass.newInstance() );
- DriverManager.registerDriver(fakeDelegatingDriver);
- fakeDrivers.put(driverClassName,fakeDelegatingDriver);
- }
- }
- catch (ClassNotFoundException e) {
- String out = NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
- throw new HibernateConsoleRuntimeException(out, e);
- }
- catch (InstantiationException e) {
- String out = NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
- throw new HibernateConsoleRuntimeException(out, e);
- }
- catch (IllegalAccessException e) {
- String out = NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
- throw new HibernateConsoleRuntimeException(out, e);
- }
- catch (SQLException e) {
- String out = NLS.bind(ConsoleMessages.ConsoleConfiguration_problems_while_loading_database_driverclass, driverClassName);
- throw new HibernateConsoleRuntimeException(out, e);
- }
- }
- }
protected ClassLoader getParentClassLoader() {
- return Thread.currentThread().getContextClassLoader();
+ return ConsoleConfiguration.class.getClassLoader();
}
+
public Configuration getConfiguration() {
return configuration;
}
@@ -549,13 +245,13 @@
* @return
*/
public boolean hasConfiguration() {
- return configuration!=null;
+ return configuration != null;
}
public void buildSessionFactory() {
- execute(new ExecutionContext.Command() {
+ execute(new Command() {
public Object execute() {
- if(sessionFactory!=null) {
+ if (sessionFactory != null) {
throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_factory_not_closed_before_build_new_factory);
}
sessionFactory = getConfiguration().buildSessionFactory();
@@ -578,9 +274,7 @@
}
public QueryPage executeHQLQuery(final String hql, final QueryInputModel queryParameters) {
-
- return (QueryPage) executionContext.execute(new ExecutionContext.Command() {
-
+ return (QueryPage)execute(new Command() {
public Object execute() {
Session session = getSessionFactory().openSession();
QueryPage qp = new HQLQueryPage(ConsoleConfiguration.this,hql,queryParameters);
@@ -590,13 +284,11 @@
fireQueryPageCreated(qp);
return qp;
}
-
});
}
public QueryPage executeBSHQuery(final String queryString, final QueryInputModel model) {
- return (QueryPage) executionContext.execute(new ExecutionContext.Command() {
-
+ return (QueryPage)execute(new Command() {
public Object execute() {
Session session = getSessionFactory().openSession();
QueryPage qp = new JavaPage(ConsoleConfiguration.this,queryString,model);
@@ -606,7 +298,6 @@
fireQueryPageCreated(qp);
return qp;
}
-
});
}
@@ -654,7 +345,7 @@
public boolean isSessionFactoryCreated() {
- return sessionFactory!=null;
+ return sessionFactory != null;
}
public ConsoleConfigurationPreferences getPreferences() {
@@ -702,7 +393,7 @@
}
public void closeSessionFactory() {
- if(sessionFactory!=null) {
+ if (sessionFactory != null) {
fireFactoryClosing(sessionFactory);
sessionFactory.close();
sessionFactory = null;
@@ -711,119 +402,12 @@
public Settings getSettings(final Configuration cfg) {
return (Settings) execute(new Command() {
-
public Object execute() {
return cfg.buildSettings();
}
-
});
}
- // TODO: delegate to some extension point
- private Configuration buildConfiguration(Properties properties, boolean includeMappings) {
- Configuration localCfg = null;
- if(prefs.getConfigurationMode().equals( ConfigurationMode.ANNOTATIONS )) {
- try {
- localCfg = buildAnnotationConfiguration();
- localCfg = configureStandardConfiguration( includeMappings, localCfg, properties );
- }
- catch (HibernateConsoleRuntimeException he) {
- throw he;
- }
- catch (Exception e) {
- throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_load_annotationconfiguration,e);
- }
- } else if(prefs.getConfigurationMode().equals( ConfigurationMode.JPA )) {
- try {
- localCfg = buildJPAConfiguration( getPreferences().getPersistenceUnitName(), properties, prefs.getEntityResolverName(), includeMappings );
- }
- catch (HibernateConsoleRuntimeException he) {
- throw he;
- }
- catch (Exception e) {
- throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_load_jpa_configuration,e);
- }
- } else {
- localCfg = new Configuration();
- localCfg = configureStandardConfiguration( includeMappings, localCfg, properties );
- }
- return localCfg;
- }
-
- private Configuration configureStandardConfiguration(final boolean includeMappings, Configuration localCfg, Properties properties) {
- if(properties!=null) {
- localCfg = localCfg.setProperties(properties);
- }
- EntityResolver entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
- if(StringHelper.isNotEmpty(prefs.getEntityResolverName())) {
- try {
- entityResolver = (EntityResolver) ReflectHelper.classForName(prefs.getEntityResolverName()).newInstance();
- } catch (Exception c) {
- throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_configure_entity_resolver + prefs.getEntityResolverName(), c);
- }
- }
- localCfg.setEntityResolver(entityResolver);
-
- if(StringHelper.isNotEmpty( prefs.getNamingStrategy())) {
- try {
- NamingStrategy ns = (NamingStrategy) ReflectHelper.classForName(prefs.getNamingStrategy()).newInstance();
- localCfg.setNamingStrategy( ns );
- } catch (Exception c) {
- throw new HibernateConsoleRuntimeException(ConsoleMessages.ConsoleConfiguration_could_not_configure_naming_strategy + prefs.getNamingStrategy(), c);
- }
- }
-
- localCfg = loadConfigurationXML( localCfg, includeMappings, entityResolver );
- localCfg = configureConnectionProfile(localCfg);
-
- // replace dialect if it is set in preferences
- if(StringHelper.isNotEmpty( prefs.getDialectName())) {
- localCfg.setProperty("hibernate.dialect", prefs.getDialectName()); //$NON-NLS-1$
- }
-
- return localCfg;
- }
-
- private Configuration configureConnectionProfile(Configuration localCfg) {
- String connectionProfile = prefs.getConnectionProfileName();
- if(connectionProfile==null) {
- return localCfg;
- }
-
- IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(connectionProfile);
- if (profile != null) {
- refreshProfile(profile);
- //
- final Properties invokeProperties = localCfg.getProperties();
- // set this property to null!
- invokeProperties.remove(Environment.DATASOURCE);
- localCfg.setProperties(invokeProperties);
- Properties cpProperties = profile.getProperties(profile.getProviderId());
- // seems we should not setup dialect here
- //String dialect = "org.hibernate.dialect.HSQLDialect";//cpProperties.getProperty("org.eclipse.datatools.connectivity.db.driverClass");
- //invoke.setProperty(Environment.DIALECT, dialect);
- String driver = cpProperties.getProperty("org.eclipse.datatools.connectivity.db.driverClass"); //$NON-NLS-1$
- localCfg.setProperty(Environment.DRIVER, driver);
- // TODO:
- String driverJarPath = cpProperties.getProperty("jarList"); //$NON-NLS-1$
- String url = cpProperties.getProperty("org.eclipse.datatools.connectivity.db.URL"); //$NON-NLS-1$
- //url += "/";// + cpProperties.getProperty("org.eclipse.datatools.connectivity.db.databaseName");
- localCfg.setProperty(Environment.URL, url);
- String user = cpProperties.getProperty("org.eclipse.datatools.connectivity.db.username"); //$NON-NLS-1$
- if (null != user && user.length() > 0) {
- localCfg.setProperty(Environment.USER, user);
- }
- String pass = cpProperties.getProperty("org.eclipse.datatools.connectivity.db.password"); //$NON-NLS-1$
- if (null != pass && pass.length() > 0) {
- localCfg.setProperty(Environment.PASS, pass);
- }
- } else {
- String out = NLS.bind(ConsoleMessages.ConsoleConfiguration_connection_profile_not_found, connectionProfile);
- throw new HibernateConsoleRuntimeException(out);
- }
- return localCfg;
- }
-
public boolean isRejectProfileRefresh() {
return rejectProfileRefresh;
}
14 years, 7 months
JBoss Tools SVN: r22604 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229 and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2010-06-07 13:01:26 -0400 (Mon, 07 Jun 2010)
New Revision: 22604
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/JBIDE-5042-6229.html
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042_JBIDE6229_Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/AbstractDraggableFragment.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableElement.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableTextSelection.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/IDraggableFragment.java
Removed:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/JBIDE-5042.html
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042Test.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
Log:
https://jira.jboss.org/browse/JBIDE-6229
Implement DnD support for selected text in VPE
- DnD for selected text has been implemented
- JUnits have been added
- Method XPCOM.printAllContractIDs has been created
Copied: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229 (from rev 22595, trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042)
Copied: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/JBIDE-5042-6229.html (from rev 22595, trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042/JBIDE-5042.html)
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/JBIDE-5042-6229.html (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/JBIDE-5042-6229.html 2010-06-07 17:01:26 UTC (rev 22604)
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head id="head-1">
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+<style type="text/css">
+table {
+ background-color: black;
+ table-layout: fixed;
+}
+td {
+ background-color: white;
+}
+td div {
+ width: 100px;
+ height: 100px;
+}
+</style>
+</head>
+<body>
+ <table>
+ <tr>
+ <td><div><input id="draggableButton" type="button" value="DraggableBn" style=" width : 85px;"><span id="draggableTextContainer">Draggable Text</span></div></td><td><div id="cell_01">dddddd</div></td><td><div>dddddd</div></td><td><div>dddddd</div></td>
+ </tr>
+ <tr>
+ <td><div>dddddd</div></td><td><div>dddddd</div></td><td><div>dddddd</div></td><td><div>dddddd</div></td>
+ </tr>
+ <tr>
+ <td><div>dddddd</div></td><td><div>dddddd</div></td><td><div id="dropable ">Dropable</div></td><td><div>dddddd</div></td>
+ </tr>
+ </table>
+</body>
+</html>
\ No newline at end of file
Deleted: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/JBIDE-5042.html
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042/JBIDE-5042.html 2010-06-07 08:44:31 UTC (rev 22595)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5042_6229/JBIDE-5042.html 2010-06-07 17:01:26 UTC (rev 22604)
@@ -1,33 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head id="head-1">
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Insert title here</title>
-<style type="text/css">
-table {
- background-color: black;
- table-layout: fixed;
-}
-td {
- background-color: white;
-}
-td div {
- width: 100px;
- height: 100px;
-}
-</style>
-</head>
-<body>
- <table>
- <tr>
- <td><div><input id="draggable" type="button" value="Draggable" style=" width : 85px;">dddddd</div></td><td><div id="cell_01">dddddd</div></td><td><div>dddddd</div></td><td><div>dddddd</div></td>
- </tr>
- <tr>
- <td><div>dddddd</div></td><td><div>dddddd</div></td><td><div>dddddd</div></td><td><div>dddddd</div></td>
- </tr>
- <tr>
- <td><div>dddddd</div></td><td><div>dddddd</div></td><td><div id="dropable ">Dropable</div></td><td><div>dddddd</div></td>
- </tr>
- </table>
-</body>
-</html>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -15,7 +15,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.ChangeMessageBundleTest_JBIDE5818;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.ContextMenuDoubleInsertionTest_JBIDE3888;
-import org.jboss.tools.jsf.vpe.jsf.test.jbide.DnD_JBIDE5042Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.DnD_JBIDE5042_JBIDE6229_Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.EditFontFamilyTest_JBIDE5872;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.ExceptionInVPEComments_JBIDE5143;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.FacetProcessingTest;
@@ -125,7 +125,7 @@
TestSuite suite = new TestSuite("Tests for Vpe Jsf components"); //$NON-NLS-1$
// $JUnit-BEGIN$
- suite.addTestSuite(DnD_JBIDE5042Test.class);
+ suite.addTestSuite(DnD_JBIDE5042_JBIDE6229_Test.class);
suite.addTestSuite(UnclosedELExpressionTest.class);
suite.addTestSuite(TestContextPathResolution.class);
suite.addTestSuite(JBIDE5920Test.class);
Deleted: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042Test.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042Test.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jsf.vpe.jsf.test.jbide;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.vpe.dnd.VpeDnD;
-import org.jboss.tools.vpe.editor.VpeController;
-import org.jboss.tools.vpe.editor.VpeEditorPart;
-import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
-import org.jboss.tools.vpe.editor.mozilla.MozillaEventAdapter;
-import org.jboss.tools.vpe.ui.test.TestUtil;
-import org.jboss.tools.vpe.ui.test.VpeTest;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.api.Invocation;
-import org.jmock.lib.action.CustomAction;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMEventTarget;
-import org.mozilla.interfaces.nsIDOMMouseEvent;
-import org.mozilla.interfaces.nsIDOMNSUIEvent;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDragService;
-import org.mozilla.interfaces.nsIDragSession;
-import org.mozilla.interfaces.nsIScriptableRegion;
-import org.mozilla.interfaces.nsISupportsArray;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Tests Drag&Drop functionality of the VPE.
- *
- * @see JIRA Issue JBIDE-5042 ( https://jira.jboss.org/jira/browse/JBIDE-5042 ):
- * "Enhance DnD support in VPE"
- *
- * @author yradtsevich
- */
-public class DnD_JBIDE5042Test extends VpeTest {
- private static final String DROP_CONTAINER_ID = "cell_01";
- private static final String DRAG_ICON_ID = "dragIcon";
- private static final String DRAGGABLE_ID = "draggable"; //$NON-NLS-1$
- private static final String TEST_PAGE_NAME = "JBIDE/5042/JBIDE-5042.html"; //$NON-NLS-1$
- private static final Point DRAG_POINT = new Point(0, 0);
- /**Cells in the table are 100x100px. Thus this point means 'top of the second cell'*/
- private static final Point DROP_POINT = new Point(150, 10);
- private Mockery context = new Mockery();
-
- public DnD_JBIDE5042Test(String name) {
- super(name);
- }
-
- /**
- * Try to open two pages in VPE and refresh them n times.
- */
- public void testDnDWithMocks() throws Throwable {
- setException(null);
-
- JSPMultiPageEditor editor = openPageInVpe(TEST_PAGE_NAME);
- final MozillaEditor visualEditor = ((VpeEditorPart) editor.getVisualEditor())
- .getVisualEditor();
- VpeController controller = TestUtil.getVpeController(editor);
- TestUtil.waitForJobs();
-
- final nsIDragService dragService = mock(nsIDragService.class);
- final nsIDragSession dragSession = mock(nsIDragSession.class);
- checking(new Expectations() {{
- allowing(dragService).getCurrentSession(); will(returnValue(dragSession));
- allowing(dragSession).getSourceDocument(); will(returnValue(visualEditor.getDomDocument()));
- allowing(dragSession).setCanDrop(with(any(Boolean.TYPE)));
- }});
- replaceDragService(controller.getVpeDnD(), dragService);
-
- Element draggable = findSourceElementById(controller, DRAGGABLE_ID);
- setSelectedNode(controller, draggable);
- TestUtil.waitForJobs();
-
- final nsIDOMElement dragIcon = controller.getXulRunnerEditor()
- .getDOMDocument().getElementById(DRAG_ICON_ID);
-
- final nsIDOMMouseEvent mouseDownEvent = createMockMouseEvent(
- DRAG_POINT, "mousedown", dragIcon, "mouseDown");
- final nsIDOMMouseEvent dragOverMouseEvent = createMockMouseEvent(
- DROP_POINT, "dragover", null, "dragover");
- final nsIDOMMouseEvent dragDropMouseEvent = createMockMouseEvent(
- DROP_POINT, "dragdrop", null, "dragdrop");
-
- final MozillaEventAdapter eventListener = visualEditor.getMozillaEventAdapter();
- checking(new Expectations() {{
- allowing(dragService).invokeDragSession(
- with(any(nsIDOMNode.class)), with(any(nsISupportsArray.class)),
- with(any(nsIScriptableRegion.class)), with(any(Long.TYPE)));
- will(new CustomAction("invokeDragSession") {
- public Object invoke(Invocation invocation) throws Throwable {
- eventListener.handleEvent(dragOverMouseEvent);
- TestUtil.waitForJobs();
- eventListener.handleEvent(dragDropMouseEvent);
- TestUtil.waitForJobs();
- return null;
- }
- });
- }});
-
- eventListener.handleEvent(mouseDownEvent);
- TestUtil.waitForJobs();
-
- draggable = findSourceElementById(controller, DRAGGABLE_ID);
- assertEquals(DROP_CONTAINER_ID, ((Element)draggable.getParentNode()).getAttribute("id"));
-
- if (getException() != null) {
- throw getException();
- }
- }
-
- private nsIDOMMouseEvent createMockMouseEvent(final Point mousePos,
- final String type, final nsIDOMElement targetElement, String name) {
- final nsIDOMMouseEvent mouseEvent = mock(nsIDOMMouseEvent.class, name + "_nsIDOMMouseEvent");
- final nsIDOMEventTarget mouseEventTarget = mock(nsIDOMEventTarget.class, name + "_nsIDOMEventTarget");
- final nsIDOMNSUIEvent mouseNsUIEvent = mock(nsIDOMNSUIEvent.class, name + "_nsIDOMNSUIEvent");
-
- checking(new Expectations() {{
- allowing(mouseEvent).getType(); will(returnValue(type));
- allowing(mouseEvent).getButton(); will(returnValue(VpeController.LEFT_BUTTON));
- allowing(mouseEvent).getTarget(); will(returnValue(mouseEventTarget));
- allowing(mouseEvent).queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID); will(returnValue(mouseEvent));
- allowing(mouseEventTarget).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID); will(returnValue(targetElement));
- allowing(mouseEvent).queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID); will(returnValue(mouseNsUIEvent));
- allowing(mouseEvent).getClientX(); will(returnValue(mousePos.x));
- allowing(mouseEvent).getClientY(); will(returnValue(mousePos.y));
- allowing(mouseNsUIEvent).getPageX(); will(returnValue(mousePos.x));
- allowing(mouseNsUIEvent).getPageY(); will(returnValue(mousePos.y));
- allowing(mouseEvent).stopPropagation();
- allowing(mouseEvent).preventDefault();
- }});
-
- return mouseEvent;
- }
-
- private void replaceDragService(VpeDnD vpeDnD, nsIDragService dragService) throws Throwable {
- Field dragServiceField = vpeDnD.getClass().getDeclaredField("dragService");
- dragServiceField.setAccessible(true);
- dragServiceField.set(vpeDnD, dragService);
- }
-
- private JSPMultiPageEditor openPageInVpe(final String pageName) throws CoreException,
- PartInitException, IOException {
- IFile elementPageFile = (IFile) TestUtil.getComponentPath(
- pageName, JsfAllTests.IMPORT_PROJECT_NAME);
- IEditorInput input = new FileEditorInput(elementPageFile);
-
- JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().openEditor(input,
- EDITOR_ID, true);
-
- return editor;
- }
-
- private void setSelectedNode(VpeController controller, Node node) {
- IndexedRegion sourceNodeBounds = ((IndexedRegion)node);
-
- controller.getPageContext().getSourceBuilder().getStructuredTextViewer()
- .setSelectedRange(sourceNodeBounds.getStartOffset(),
- sourceNodeBounds.getEndOffset() - sourceNodeBounds.getStartOffset());
- }
-
- /** @see org.jmock.Mockery#mock(java.lang.Class, java.lang.String) */
- public <T> T mock(Class<T> typeToMock, String name) {
- return context.mock(typeToMock, name);
- }
-
- /** @see org.jmock.Mockery#mock(java.lang.Class) */
- public <T> T mock(Class<T> typeToMock) {
- return context.mock(typeToMock);
- }
-
- /** @see org.jmock.Mockery#checking(Expectations) */
- public void checking(Expectations expectations) {
- context.checking(expectations);
- }
-}
Copied: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042_JBIDE6229_Test.java (from rev 22450, trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042Test.java)
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042_JBIDE6229_Test.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/DnD_JBIDE5042_JBIDE6229_Test.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.dnd.VpeDnD;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEventAdapter;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.api.Invocation;
+import org.jmock.lib.action.CustomAction;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMEventTarget;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+import org.mozilla.interfaces.nsIDOMNSUIEvent;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDragService;
+import org.mozilla.interfaces.nsIDragSession;
+import org.mozilla.interfaces.nsIScriptableRegion;
+import org.mozilla.interfaces.nsISupportsArray;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Tests Drag&Drop functionality of the VPE.
+ *
+ * @see JIRA Issue JBIDE-5042 ( https://jira.jboss.org/jira/browse/JBIDE-5042 ):
+ * "Enhance DnD support in VPE"
+ *
+ * @author yradtsevich
+ */
+@SuppressWarnings("nls")
+public class DnD_JBIDE5042_JBIDE6229_Test extends VpeTest {
+ private static final String DROP_CONTAINER_ID = "cell_01";
+ private static final String DRAG_ICON_ID = "dragIcon";
+ private static final String DRAGGABLE_BUTTON_ID = "draggableButton";
+ private static final String DRAGGABLE_TEXT_CONTAINER_ID = "draggableTextContainer";
+ private static final String TEST_PAGE_NAME = "JBIDE/5042_6229/JBIDE-5042-6229.html";
+ private static final String DND_TEXT = "Text";
+ private static final Point DRAG_POINT = new Point(0, 0);
+ /**Cells in the table are 100x100px. Thus this point means 'top of the second cell'*/
+ private static final Point DROP_POINT = new Point(150, 10);
+ private Mockery context = new Mockery();
+
+ public DnD_JBIDE5042_JBIDE6229_Test(String name) {
+ super(name);
+ }
+
+ /**
+ * Try to open two pages in VPE and refresh them n times.
+ */
+ public void testElementDnDWithMocks() throws Throwable {
+ setException(null);
+
+ JSPMultiPageEditor editor = openPageInVpe(TEST_PAGE_NAME);
+ final MozillaEditor visualEditor = ((VpeEditorPart) editor.getVisualEditor())
+ .getVisualEditor();
+ VpeController controller = TestUtil.getVpeController(editor);
+ TestUtil.waitForJobs();
+
+ Element draggable = findSourceElementById(controller, DRAGGABLE_BUTTON_ID);
+ IndexedRegion region = (IndexedRegion) draggable;
+ setSelectedRange(controller, region.getStartOffset(),
+ region.getEndOffset() - region.getStartOffset());
+ TestUtil.waitForJobs();
+
+ executeSelectionDragAndDropToSecondCell(visualEditor, controller);
+
+ draggable = findSourceElementById(controller, DRAGGABLE_BUTTON_ID);
+ assertEquals(DROP_CONTAINER_ID, ((Element)draggable.getParentNode()).getAttribute("id"));
+
+ if (getException() != null) {
+ throw getException();
+ }
+ }
+
+ public void testTextDnDWithMocks() throws Throwable {
+ setException(null);
+
+ JSPMultiPageEditor editor = openPageInVpe(TEST_PAGE_NAME);
+ final MozillaEditor visualEditor = ((VpeEditorPart) editor.getVisualEditor())
+ .getVisualEditor();
+ VpeController controller = TestUtil.getVpeController(editor);
+ TestUtil.waitForJobs();
+
+ Element draggableTextContainer = findSourceElementById(controller, DRAGGABLE_TEXT_CONTAINER_ID);
+ Text draggableTextNode = (Text) draggableTextContainer.getChildNodes().item(0);
+ IndexedRegion draggableTextRegion = (IndexedRegion)draggableTextNode;
+ setSelectedRange(controller,
+ draggableTextRegion.getEndOffset() - DND_TEXT.length(), DND_TEXT.length());
+ TestUtil.waitForJobs();
+
+ executeSelectionDragAndDropToSecondCell(visualEditor, controller);
+
+ Element dropContainer = findSourceElementById(controller, DROP_CONTAINER_ID);
+ NodeList dropContainerChildren = dropContainer.getChildNodes();
+ assertTrue(dropContainerChildren.getLength() == 1);
+ assertTrue(dropContainerChildren.item(0) instanceof Text);
+
+ String dropContainerContent = ((Text)dropContainerChildren.item(0)).getNodeValue();
+
+ assertEquals(DND_TEXT + "dddddd", dropContainerContent);
+
+ if (getException() != null) {
+ throw getException();
+ }
+ }
+
+ private void executeSelectionDragAndDropToSecondCell(
+ final MozillaEditor visualEditor, VpeController controller)
+ throws Throwable {
+ final nsIDragService dragService = mock(nsIDragService.class);
+ final nsIDragSession dragSession = mock(nsIDragSession.class);
+ checking(new Expectations() {{
+ allowing(dragService).getCurrentSession(); will(returnValue(dragSession));
+ allowing(dragSession).getSourceDocument(); will(returnValue(visualEditor.getDomDocument()));
+ allowing(dragSession).setCanDrop(with(any(Boolean.TYPE)));
+ }});
+ replaceDragService(controller.getVpeDnD(), dragService);
+
+ final nsIDOMElement dragIcon = controller.getXulRunnerEditor()
+ .getDOMDocument().getElementById(DRAG_ICON_ID);
+
+ final nsIDOMMouseEvent mouseDownEvent = createMockMouseEvent(
+ DRAG_POINT, "mousedown", dragIcon, "mouseDown");
+ final nsIDOMMouseEvent dragOverMouseEvent = createMockMouseEvent(
+ DROP_POINT, "dragover", null, "dragover");
+ final nsIDOMMouseEvent dragDropMouseEvent = createMockMouseEvent(
+ DROP_POINT, "dragdrop", null, "dragdrop");
+
+ final MozillaEventAdapter eventListener = visualEditor.getMozillaEventAdapter();
+ checking(new Expectations() {{
+ allowing(dragService).invokeDragSession(
+ with(any(nsIDOMNode.class)), with(any(nsISupportsArray.class)),
+ with(any(nsIScriptableRegion.class)), with(any(Long.TYPE)));
+ will(new CustomAction("invokeDragSession") {
+ public Object invoke(Invocation invocation) throws Throwable {
+ eventListener.handleEvent(dragOverMouseEvent);
+ TestUtil.waitForJobs();
+ eventListener.handleEvent(dragDropMouseEvent);
+ TestUtil.waitForJobs();
+ return null;
+ }
+ });
+ }});
+
+ eventListener.handleEvent(mouseDownEvent);
+ TestUtil.waitForJobs();
+ TestUtil.delay(100);
+ TestUtil.waitForJobs();
+ }
+
+ private nsIDOMMouseEvent createMockMouseEvent(final Point mousePos,
+ final String type, final nsIDOMElement targetElement, String name) {
+ final nsIDOMMouseEvent mouseEvent = mock(nsIDOMMouseEvent.class, name + "_nsIDOMMouseEvent");
+ final nsIDOMEventTarget mouseEventTarget = mock(nsIDOMEventTarget.class, name + "_nsIDOMEventTarget");
+ final nsIDOMNSUIEvent mouseNsUIEvent = mock(nsIDOMNSUIEvent.class, name + "_nsIDOMNSUIEvent");
+
+ checking(new Expectations() {{
+ allowing(mouseEvent).getType(); will(returnValue(type));
+ allowing(mouseEvent).getButton(); will(returnValue(VpeController.LEFT_BUTTON));
+ allowing(mouseEvent).getTarget(); will(returnValue(mouseEventTarget));
+ allowing(mouseEvent).queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID); will(returnValue(mouseEvent));
+ allowing(mouseEventTarget).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID); will(returnValue(targetElement));
+ allowing(mouseEvent).queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID); will(returnValue(mouseNsUIEvent));
+ allowing(mouseEvent).getClientX(); will(returnValue(mousePos.x));
+ allowing(mouseEvent).getClientY(); will(returnValue(mousePos.y));
+ allowing(mouseNsUIEvent).getPageX(); will(returnValue(mousePos.x));
+ allowing(mouseNsUIEvent).getPageY(); will(returnValue(mousePos.y));
+ allowing(mouseEvent).stopPropagation();
+ allowing(mouseEvent).preventDefault();
+ }});
+
+ return mouseEvent;
+ }
+
+ private void replaceDragService(VpeDnD vpeDnD, nsIDragService dragService) throws Throwable {
+ Field dragServiceField = vpeDnD.getClass().getDeclaredField("dragService");
+ dragServiceField.setAccessible(true);
+ dragServiceField.set(vpeDnD, dragService);
+ }
+
+ private JSPMultiPageEditor openPageInVpe(final String pageName) throws CoreException,
+ PartInitException, IOException {
+ IFile elementPageFile = (IFile) TestUtil.getComponentPath(
+ pageName, JsfAllTests.IMPORT_PROJECT_NAME);
+ IEditorInput input = new FileEditorInput(elementPageFile);
+
+ JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().openEditor(input,
+ EDITOR_ID, true);
+
+ return editor;
+ }
+
+ private void setSelectedRange(VpeController controller, int offset, int length) {
+ controller.getPageContext().getSourceBuilder().getStructuredTextViewer()
+ .setSelectedRange(offset, length);
+ }
+
+ /** @see org.jmock.Mockery#mock(java.lang.Class, java.lang.String) */
+ public <T> T mock(Class<T> typeToMock, String name) {
+ return context.mock(typeToMock, name);
+ }
+
+ /** @see org.jmock.Mockery#mock(java.lang.Class) */
+ public <T> T mock(Class<T> typeToMock) {
+ return context.mock(typeToMock);
+ }
+
+ /** @see org.jmock.Mockery#checking(Expectations) */
+ public void checking(Expectations expectations) {
+ context.checking(expectations);
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/AbstractDraggableFragment.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/AbstractDraggableFragment.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/AbstractDraggableFragment.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.dnd;
+
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
+import org.mozilla.interfaces.nsIDOMCSSStyleDeclaration;
+import org.mozilla.interfaces.nsIDOMElement;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public abstract class AbstractDraggableFragment implements IDraggableFragment {
+ private static final String DRAGGING_OPACITY = "0.5"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.dnd.IDraggableFragment#createRepresentation()
+ */
+ public final nsIDOMElement createRepresentation() {
+ nsIDOMElement representation = cloneFragmentAsElement();
+
+ DndUtil.setTemporaryDndElement(representation, true);
+
+ nsIDOMCSSStyleDeclaration representationStyle
+ = VpeStyleUtil.getStyle(representation);
+ representationStyle.setProperty(HTML.STYLE_PARAMETER_POSITION,
+ HTML.STYLE_VALUE_ABSOLUTE, HTML.STYLE_PRIORITY_IMPORTANT);
+ representationStyle.setProperty(HTML.STYLE_PARAMETER_OPACITY,
+ DRAGGING_OPACITY, HTML.STYLE_PRIORITY_IMPORTANT);
+ VpeStyleUtil.setElementVisible(representation, false);
+
+ return representation;
+ }
+
+ public abstract nsIDOMElement cloneFragmentAsElement();
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableElement.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableElement.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableElement.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.dnd;
+
+import static org.jboss.tools.vpe.xulrunner.util.XPCOM.queryInterface;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.jboss.tools.vpe.xulrunner.util.XulRunnerVpeUtils;
+import org.mozilla.interfaces.nsIDOMElement;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public class DraggableElement extends AbstractDraggableFragment {
+ private final nsIDOMElement element;
+
+ public DraggableElement(nsIDOMElement element) {
+ this.element = element;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.dnd.IDraggableFragment#createRepresentation()
+ */
+ public nsIDOMElement cloneFragmentAsElement() {
+ nsIDOMElement representation
+ = queryInterface(element.cloneNode(true), nsIDOMElement.class);
+ element.getParentNode().appendChild(representation);
+
+ return representation;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.dnd.IDraggableFragment#getPosition()
+ */
+ public Point getPosition() {
+ Rectangle bounds = XulRunnerVpeUtils.getElementBounds(element);
+ return new Point(bounds.x, bounds.y);
+ }
+
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -12,6 +12,7 @@
import static org.jboss.tools.vpe.xulrunner.util.XPCOM.queryInterface;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -28,12 +29,9 @@
* @author Yahor Radtsevich (yradtsevich)
*/
public class DraggablePattern {
- private static final String DRAGGING_OPACITY = "0.5"; //$NON-NLS-1$
private static final int ICON_HEIGHT = 20;
private static final String DRAG_ICON_ID = "dragIcon"; //$NON-NLS-1$
private static final String DRAG_ICON_FILE = "dragIcon.gif"; //$NON-NLS-1$
- private static final String ABSOLUTE_POSITION = "absolute"; //$NON-NLS-1$
- private static final String IMPORTANT_PRIORITY = "important"; //$NON-NLS-1$
/** @see #getTransparentDiv() */
private static final String TRANSPARENT_DIV_ID = "transparentDragDiv"; //$NON-NLS-1$
@@ -53,8 +51,8 @@
private int offsetX;
private int offsetY;
private boolean sessionStarted;
- private nsIDOMElement nodeCopy;
- private nsIDOMElement node;
+ private nsIDOMElement draggableFragmentRepresentation;
+ private IDraggableFragment draggableFragment;
private final MozillaEditor mozillaEditor;
public DraggablePattern(MozillaEditor mozillaEditor) {
@@ -62,17 +60,17 @@
this.mozillaEditor = mozillaEditor;
}
- public void showDragIcon(nsIDOMElement element) {
- this.node = element;
- Rectangle bounds = XulRunnerVpeUtils.getElementBounds(element);
+ public void showDragIcon(IDraggableFragment draggableFragment) {
+ this.draggableFragment = draggableFragment;
+ Point position = draggableFragment.getPosition();
nsIDOMElement dragIcon = getDragIcon();
VpeStyleUtil.setElementVisible(dragIcon, true);
- VpeStyleUtil.moveElementTo(dragIcon, bounds.x, bounds.y - ICON_HEIGHT);
+ VpeStyleUtil.moveElementTo(dragIcon, position.x, position.y - ICON_HEIGHT);
}
public void hideDragIcon() {
- this.node = null;
+ this.draggableFragment = null;
VpeStyleUtil.setElementVisible(getDragIcon(), false);
}
@@ -124,40 +122,24 @@
}
}
- public nsIDOMNode getNode() {
- return node;
- }
-
public void startSession(int mouseStartX, int mouseStartY) {
if (sessionStarted) {
new IllegalStateException(
"Session is already started."); //$NON-NLS-1$
}
- if (node == null) {
+ if (draggableFragment == null) {
new IllegalStateException(
"No node to drag."); //$NON-NLS-1$
}
- Rectangle nodeBounds = XulRunnerVpeUtils.getElementBounds(node);
- offsetX = nodeBounds.x - mouseStartX;
- offsetY = nodeBounds.y - mouseStartY;
+ Point fragmentPosition = draggableFragment.getPosition();
+ offsetX = fragmentPosition.x - mouseStartX;
+ offsetY = fragmentPosition.y - mouseStartY;
- nodeCopy = queryInterface(node.cloneNode(true), nsIDOMElement.class);
- if (nodeCopy.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- nsIDOMElement elementCopy = queryInterface(nodeCopy, nsIDOMElement.class);
- DndUtil.setTemporaryDndElement(elementCopy, true);
- }
+ draggableFragmentRepresentation = draggableFragment.createRepresentation();
- nsIDOMCSSStyleDeclaration nodeCopyStyle
- = VpeStyleUtil.getStyle(nodeCopy);
-
- nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_POSITION,
- ABSOLUTE_POSITION, IMPORTANT_PRIORITY);
- nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_OPACITY,
- DRAGGING_OPACITY, IMPORTANT_PRIORITY);
-
- setVisible(false);
- node.getParentNode().appendChild(nodeCopy);
+ //TODO: remove the following line
+ //setVisible(false);
moveTo(mouseStartX, mouseStartY);
setVisible(true);
sessionStarted = true;
@@ -166,25 +148,25 @@
public void closeSession() {
if (sessionStarted) {
setVisible(false);
- nsIDOMNode parent = nodeCopy.getParentNode();
+ nsIDOMNode parent = draggableFragmentRepresentation.getParentNode();
if (parent != null) {
- parent.removeChild(nodeCopy);
+ parent.removeChild(draggableFragmentRepresentation);
}
hideDragIcon();
- nodeCopy = null;
+ draggableFragmentRepresentation = null;
sessionStarted = false;
}
}
public void setVisible(boolean visible) {
- VpeStyleUtil.setElementVisible(nodeCopy, visible);
+ VpeStyleUtil.setElementVisible(draggableFragmentRepresentation, visible);
VpeStyleUtil.setElementVisible(getTransparentDiv(), visible);
VpeStyleUtil.setElementVisible(getDragIcon(), visible);
}
public void moveTo(int mouseX, int mouseY) {
- VpeStyleUtil.moveElementTo(nodeCopy, offsetX + mouseX, offsetY + mouseY);
+ VpeStyleUtil.moveElementTo(draggableFragmentRepresentation, offsetX + mouseX, offsetY + mouseY);
VpeStyleUtil.moveElementTo(getTransparentDiv(),
offsetX + mouseX - TRANSPARENT_DIV_SIZE / 2,
offsetY + mouseY - TRANSPARENT_DIV_SIZE / 2);
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableTextSelection.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableTextSelection.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggableTextSelection.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.dnd;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.jboss.tools.vpe.editor.util.VisualDomUtil;
+import org.jboss.tools.vpe.xulrunner.util.XulRunnerVpeUtils;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMText;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public class DraggableTextSelection extends AbstractDraggableFragment {
+ private final nsIDOMText selectionContainer;
+ private final int startOffset;
+ private final int endOffset;
+
+ /**
+ * NOTE: selectionContainer must contain really selected text. It will
+ * not work if real selection range do not math offsets.
+ */
+ public DraggableTextSelection(nsIDOMText selectionContainer,
+ int startOffset, int endOffset) {
+ this.selectionContainer = selectionContainer;
+ this.startOffset = startOffset;
+ this.endOffset = endOffset;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.dnd.AbstractDraggableFragment#cloneFragmentAsElement()
+ */
+ @Override
+ public nsIDOMElement cloneFragmentAsElement() {
+ nsIDOMDocument document = selectionContainer.getOwnerDocument();
+
+ nsIDOMElement cloneContainer = VisualDomUtil.createBorderlessContainer(
+ document);
+ nsIDOMNode selectionContainerParent = selectionContainer.getParentNode();
+ selectionContainerParent.appendChild(cloneContainer);
+ String cloneText = selectionContainer.getData().substring(startOffset, endOffset);
+ nsIDOMText clone = document.createTextNode(cloneText);
+ cloneContainer.appendChild(clone);
+
+ return cloneContainer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.dnd.IDraggableFragment#getPosition()
+ */
+ public Point getPosition() {
+ Rectangle bounds = XulRunnerVpeUtils.getTextSelectionBounds(selectionContainer);
+ return new Point(bounds.x, bounds.y);
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/IDraggableFragment.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/IDraggableFragment.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/IDraggableFragment.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.dnd;
+
+import org.eclipse.swt.graphics.Point;
+import org.mozilla.interfaces.nsIDOMElement;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public interface IDraggableFragment {
+ public Point getPosition();
+ public nsIDOMElement createRepresentation();
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -16,6 +16,7 @@
import java.util.EnumSet;
import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
@@ -40,6 +41,7 @@
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaDndListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaSelectionListener;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.editor.util.VpeDndUtil;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -51,8 +53,11 @@
import org.mozilla.interfaces.nsIDOMMouseEvent;
import org.mozilla.interfaces.nsIDOMNSUIEvent;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMRange;
+import org.mozilla.interfaces.nsIDOMText;
import org.mozilla.interfaces.nsIDragService;
import org.mozilla.interfaces.nsIFile;
+import org.mozilla.interfaces.nsISelection;
import org.mozilla.interfaces.nsIServiceManager;
import org.mozilla.interfaces.nsISupports;
import org.mozilla.interfaces.nsISupportsArray;
@@ -71,7 +76,7 @@
*/
// NOTE: the code has been cleaned after SVN revision 21574, many methods
// have been removed. To find the old code refer to older revisions.
-public class VpeDnD implements MozillaDndListener {
+public class VpeDnD implements MozillaDndListener, MozillaSelectionListener {
private static final String TAG_TAGLIB = "taglib"; //$NON-NLS-1$
/*
@@ -95,6 +100,11 @@
private VpeController vpeController;
+ /* TODO: yradtsevich: sourceInnerDragInfo is a state variable
+ * that not always reflects actual state of the object
+ * (e.g. during external Drag&Drop and text Drag&Drop).
+ * It has to be removed from the class and corresponding
+ * methods has to be refactored. */
private VpeSourceInnerDragInfo sourceInnerDragInfo = null;
private DraggablePattern draggablePattern;
private DropableArea dropableArea;
@@ -108,7 +118,7 @@
nsIDOMElement selectedElement = vpeController.getXulRunnerEditor()
.getLastSelectedElement();
// start drag sessionvpe-element
- if (isDraggable(selectedElement)) {
+ if (isTextSelected(getVisualSelection()) || isDraggable(selectedElement)) {
Point pageCoords = getPageCoords(domEvent);
draggablePattern.startSession(pageCoords.x, pageCoords.y);
startDragSession(selectedElement);
@@ -129,7 +139,11 @@
final DropResolver dropResolver;
if (isInnerDragSession()) {
- dropResolver = getDropResolverForInternalDrop();
+ if (isTextSelected(getVisualSelection())) {
+ dropResolver = getDropResolverForNode(vpeController.getDomMapping().getNearSourceNode(getVisualSelection().getFocusNode()));
+ } else {
+ dropResolver = getDropResolverForInternalDrop();
+ }
Point mousePosition = getPageCoords(event);
draggablePattern.moveTo(mousePosition.x, mousePosition.y);
@@ -187,15 +201,59 @@
}
public void selectionChanged() {
- nsIDOMElement selectedElement = vpeController.getXulRunnerEditor()
- .getLastSelectedElement();
- if (isDraggable(selectedElement)) {
- draggablePattern.showDragIcon(selectedElement);
+ refreshDraggablePattern();
+ }
+
+ private void refreshDraggablePattern() {
+ nsISelection selection = getVisualSelection();
+ if (isTextSelected(selection)) {
+ nsIDOMRange range = selection.getRangeAt(0);
+ nsIDOMText textContainer = queryInterface(
+ range.getStartContainer(), nsIDOMText.class);
+
+ draggablePattern.showDragIcon(new DraggableTextSelection(
+ textContainer, range.getStartOffset(), range.getEndOffset()));
} else {
- draggablePattern.hideDragIcon();
+ nsIDOMElement selectedElement = vpeController.getXulRunnerEditor()
+ .getLastSelectedElement();
+
+ if (isDraggable(selectedElement)) {
+ draggablePattern.showDragIcon(new DraggableElement(selectedElement));
+ } else {
+ draggablePattern.hideDragIcon();
+ }
}
}
+
+ private nsISelection getVisualSelection() {
+ return vpeController.getXulRunnerEditor().getWebBrowser()
+ .getContentDOMWindow().getSelection();
+ }
+ private boolean isTextSelected(nsISelection selection) {
+ if (selection.getRangeCount() == 0) {
+ // nothing selected
+ return false;
+ }
+
+ nsIDOMRange range = selection.getRangeAt(0);
+ nsIDOMNode container = range.getStartContainer();
+ if (!container.equals(range.getEndContainer())) {
+ // more than one node selected
+ return false;
+ }
+ if (container.getNodeType() != nsIDOMNode.TEXT_NODE) {
+ // not text node is selected
+ return false;
+ }
+ if (range.getStartOffset() == range.getEndOffset()) {
+ // no text selected
+ return false;
+ }
+
+ return true;
+ }
+
public boolean isDragIconClicked(nsIDOMMouseEvent mouseEvent) {
return draggablePattern.isDragIconClicked(mouseEvent);
}
@@ -363,7 +421,7 @@
nsISupportsString transferData = (nsISupportsString) getComponentManager()
.createInstanceByContractID(XPCOM.NS_SUPPORTSSTRING_CONTRACTID, null,
nsISupportsString.NS_ISUPPORTSSTRING_IID);
- String data=VPE_ELEMENT;
+ String data=VPE_ELEMENT;
transferData.setData(data);
iTransferable.setTransferData(VpeController.MODEL_FLAVOR, transferData, data.length());
iTransferable.setTransferData("text/plain", transferData, data.length()); //$NON-NLS-1$
@@ -389,17 +447,20 @@
}
- private void externalDropAny(final String flavor, final String data,
- final int offset) {
- StructuredTextEditor sourceEditor = vpeController.getSourceEditor();
- if (flavor == null || flavor.length() == 0
- || !(sourceEditor instanceof IDNDTextEditor)) {
- return;
+ private void dropAny(final String flavor, final String data) {
+ VpeSourceDropInfo dropInfo = getDropInfo();
+ Point range = getSourceSelectionRange(dropInfo.getContainer(), dropInfo.getOffset());
+
+ if (dropInfo.getContainer() != null && data != null) {
+ StructuredTextEditor sourceEditor = vpeController.getSourceEditor();
+ if (flavor == null || flavor.length() == 0
+ || !(sourceEditor instanceof IDNDTextEditor)) {
+ return;
+ }
+
+ sourceEditor.setHighlightRange(range.x, 0, true);
+ ((IDNDTextEditor) sourceEditor).runDropCommand(flavor, data);
}
-
- sourceEditor.setHighlightRange(offset, 0, true);
- ((IDNDTextEditor) sourceEditor).runDropCommand(flavor, data);
-
}
private boolean isInnerDragSession() {
@@ -465,8 +526,21 @@
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out.print("<<<<<< innerDrop"); //$NON-NLS-1$
}
- if (sourceInnerDragInfo != null) {
- VpeSourceDropInfo sourceDropInfo = getDropInfo(event);
+
+ /* TODO: yradtsevich: the code needs to be refactored.
+ * See TODO comment for sourceInnerDragInfo */
+ if (isTextSelected(getVisualSelection())) {
+ // it is inner Drag&Drop of text
+ StyledText textWidget = vpeController.getSourceEditor()
+ .getTextViewer().getTextWidget();
+ String text = textWidget.getSelectionText();
+
+ Point selectionRange = textWidget.getSelectionRange();
+ textWidget.replaceTextRange(selectionRange.x, selectionRange.y, ""); //$NON-NLS-1$
+
+ dropAny(DndUtil.kUnicodeMime, text);
+ } else if (sourceInnerDragInfo != null) {
+ VpeSourceDropInfo sourceDropInfo = getDropInfo();
if (sourceDropInfo.getContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out
@@ -512,9 +586,7 @@
private void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
vpeController.onHideTooltip();
- VpeSourceDropInfo dropInfo = getDropInfo(mouseEvent);
- Point range = getSourceSelectionRange(
- dropInfo.getContainer(), dropInfo.getOffset());
+
final DragTransferData dragTransferData = DndUtil.getDragTransferData();
final nsISupports aValue = dragTransferData.getValue();
@@ -543,20 +615,7 @@
}
}
- if (dropInfo.getContainer() != null && data != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" drop! container: " + dropInfo.getContainer().getNodeName()); //$NON-NLS-1$
- }
-
- externalDropAny(aFlavor, data, range.x);
-
- // TypedEvent tEvent = new TypedEvent(mouseEvent);
- // tEvent.data = data;
- // dropContext.setFlavor(aFlavor);
- // dropContext.setMimeData(data);
- // DnDUtil.fireDnDEvent(dropContext, textEditor, tEvent);
- }
+ dropAny(aFlavor, data);
}
@SuppressWarnings("restriction")
@@ -607,9 +666,8 @@
private nsIComponentManager getComponentManager() {
if(componentManager==null) {
-
componentManager = Mozilla.getInstance()
- .getComponentManager();
+ .getComponentManager();
}
return componentManager;
}
@@ -647,7 +705,7 @@
}
}
- private VpeSourceDropInfo getDropInfo(nsIDOMEvent event) {
+ private VpeSourceDropInfo getDropInfo() {
Node dropContainer = null;
int dropOffset = 0;
boolean canDrop = false;
@@ -685,6 +743,14 @@
return new VpeSourceDropInfo(dropContainer, dropOffset, canDrop);
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.editor.mozilla.listener.MozillaSelectionListener#notifySelectionChanged(org.mozilla.interfaces.nsIDOMDocument, org.mozilla.interfaces.nsISelection, short)
+ */
+ public void notifySelectionChanged(nsIDOMDocument domDocument,
+ nsISelection selection, short reason) {
+ refreshDraggablePattern();
+ }
private interface DropResolver {
public boolean canDrop(Node node);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -460,6 +460,7 @@
mozillaEventAdapter.addKeyListener(this);
mozillaEventAdapter.addMouseListener(this);
mozillaEventAdapter.addSelectionListener(this);
+ mozillaEventAdapter.addSelectionListener(vpeDnD);
mozillaEventAdapter.addAfterPaintListener(this);
mozillaEventAdapter.addScrollListener(this);
}
@@ -479,6 +480,7 @@
mozillaEventAdapter.removeKeyListener(this);
mozillaEventAdapter.removeMouseListener(this);
mozillaEventAdapter.removeSelectionListener(this);
+ mozillaEventAdapter.removeSelectionListener(vpeDnD);
mozillaEventAdapter.removeAfterPaintListener(this);
mozillaEventAdapter.removeScrollListener(this);
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -234,10 +234,10 @@
selectionLength = NodesManagingUtil.getNodeLength(targetSourceNode);
}
-
+
+ SelectionUtil.clearSelection(selectionController);
SelectionUtil.setSourceSelection(getPageContext(), targetSourceNode,
selectionOffset, selectionLength);
-
// paint selection rectangle
getPageContext().getVisualBuilder().setSelectionRectangle(
targetVisualNode);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XPCOM.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -16,14 +16,22 @@
import java.util.List;
import java.util.Map;
+import org.mozilla.interfaces.nsIComponentManager;
+import org.mozilla.interfaces.nsIComponentRegistrar;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIServiceManager;
+import org.mozilla.interfaces.nsISimpleEnumerator;
import org.mozilla.interfaces.nsISupports;
+import org.mozilla.interfaces.nsISupportsCString;
+import org.mozilla.xpcom.Mozilla;
import org.mozilla.xpcom.XPCOMException;
/**
* @author Sergey Vasilyev (svasilyev(a)exadel.com): initial creation.
- * @author Yahor Radtsevich (yradtsevich): method {@code queryInterface} and
- * related stuff (JBIDE-6393).
+ * @author Yahor Radtsevich (yradtsevich): methods {@link #queryInterface},
+ * {@link #printAllContractIDs(Class)},
+ * {@link #printSupportedInterfaces(nsISupports, boolean)}
+ * and related stuff (JBIDE-6393).
*/
public final class XPCOM {
private XPCOM() {}
@@ -79,7 +87,7 @@
String interfaceId = getInterfaceId(type);
return (T) object.queryInterface(interfaceId);
}
-
+
/**
* Returns XPCOM ID for the given {@code type}
* <P>
@@ -163,7 +171,7 @@
*
* @deprecated This method tries to query every known XPCOM interface
* from given object and it performs very slow (seconds).
- * For debug/test purposes only. Do not use it in the production code.
+ * For debug purposes only. Do not use it in the production code.
*/
public static void printSupportedInterfaces(nsISupports object, boolean printMethods) {
for (Class<? extends nsISupports> type : getSupportedInterfaces(object)) {
@@ -175,7 +183,57 @@
}
}
}
+
+ /**
+ * Prints all XPCOM interface ID for the given type
+ * to the {@code System.out}.
+ *
+ * @deprecated For debug purposes only.
+ */
+ public static void printAllContractIDs(Class<? extends nsISupports> type) {
+ nsIComponentManager componentManager = Mozilla.getInstance().getComponentManager();
+ nsIServiceManager serviceManager = Mozilla.getInstance().getServiceManager();
+
+ nsISimpleEnumerator contractIDsEnumerator
+ = queryInterface(componentManager, nsIComponentRegistrar.class)
+ .enumerateContractIDs();
+ List<String> contractIDs = new ArrayList<String>();
+ while(contractIDsEnumerator.hasMoreElements()) {
+ contractIDs.add( queryInterface(contractIDsEnumerator.getNext(),
+ nsISupportsCString.class).getData() );
+ }
+ java.util.Collections.sort(contractIDs);
+ for (String contractID : contractIDs) {
+ boolean hasComponent = false;
+ boolean hasService = false;
+
+ try {
+ nsISupports component = componentManager.createInstanceByContractID(
+ contractID, null, nsISupports.NS_ISUPPORTS_IID);
+ queryInterface(component, type);
+ hasService = true;
+ } catch (Throwable e) {
+ // it's OK
+ }
+
+ try {
+ nsISupports service =
+ serviceManager.getServiceByContractID(contractID, nsISupports.NS_ISUPPORTS_IID);//createInstanceByContractID(
+ //contractID, null, nsISupports.NS_ISUPPORTS_IID);
+ queryInterface(service, type);
+ hasService = true;
+ } catch (Throwable e) {
+ // it's OK
+ }
+
+ if (hasComponent || hasService) {
+ System.out.print(String.format("%s (hasComponent = %s, hasService = %s)",
+ contractID, hasComponent, hasService));
+ }
+ }
+ }
+
/**
* Returns all XPCOM interfaces which extend nsISupports.
*
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2010-06-07 15:08:21 UTC (rev 22603)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2010-06-07 17:01:26 UTC (rev 22604)
@@ -118,8 +118,8 @@
* Returns the bounds of the selected text in given
* {@code selectionContainer}.
*/
- public static Rectangle getTextSelectionBounds(nsIDOMText slectionContainer) {
- nsIAccessibleText accessibleTextAncestor = getAccessibleTextAncestor(slectionContainer);
+ public static Rectangle getTextSelectionBounds(nsIDOMText selectionContainer) {
+ nsIAccessibleText accessibleTextAncestor = getAccessibleTextAncestor(selectionContainer);
if (accessibleTextAncestor == null) {
// cannot get selection bounds
return null;
@@ -140,11 +140,16 @@
accessibleTextAncestor.getRangeExtents(startOffset[0], endOffset[0],
x, y, width, height, nsIAccessibleCoordinateType.COORDTYPE_PARENT_RELATIVE);
- Rectangle ancestorBounds = getElementBounds(
- queryInterface(accessibleTextAncestor, nsIAccessNode.class)
- .getDOMNode());
+ nsIDOMNode ancestorParent = queryInterface(accessibleTextAncestor, nsIAccessNode.class)
+ .getDOMNode().getParentNode();
+ Rectangle ancestorParentBounds;
+ if (ancestorParent != null) {
+ ancestorParentBounds = getElementBounds(ancestorParent);
+ } else {
+ ancestorParentBounds = new Rectangle(0, 0, 0, 0);
+ }
- return new Rectangle(ancestorBounds.x + x[0], ancestorBounds.y + y[0],
+ return new Rectangle(ancestorParentBounds.x + x[0], ancestorParentBounds.y + y[0],
width[0], height[0]);
}
14 years, 7 months
JBoss Tools SVN: r22603 - branches/3.2.helios/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2010-06-07 11:08:21 -0400 (Mon, 07 Jun 2010)
New Revision: 22603
Modified:
branches/3.2.helios/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/RefactoringTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6420
Modified: branches/3.2.helios/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/RefactoringTest.java
===================================================================
--- branches/3.2.helios/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/RefactoringTest.java 2010-06-07 14:34:31 UTC (rev 22602)
+++ branches/3.2.helios/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/RefactoringTest.java 2010-06-07 15:08:21 UTC (rev 22603)
@@ -329,7 +329,6 @@
}
//====================================================================================
- @SuppressWarnings("unchecked")
static class TestWorkingCopy implements ILaunchConfigurationWorkingCopy{
private TestLaunchConfig parent;
@@ -535,6 +534,11 @@
return null;
}
+ @Override
+ public void setAttribute(String attributeName, Set value) {
+ attributes.put(attributeName, value);
+ }
+
}
@SuppressWarnings("unchecked")
14 years, 7 months