JBoss Tools SVN: r21583 - in trunk/jst/tests/org.jboss.tools.jst.jsp.test: src/org/jboss/tools/jst/jsp/test/ca and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-04-21 10:10:23 -0400 (Wed, 21 Apr 2010)
New Revision: 21583
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForCompositeComponentTest/WebContent/resources/sample/tag2.xhtml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForCompositeComponentTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5941
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForCompositeComponentTest/WebContent/resources/sample/tag2.xhtml
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForCompositeComponentTest/WebContent/resources/sample/tag2.xhtml 2010-04-21 14:02:36 UTC (rev 21582)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/CAForCompositeComponentTest/WebContent/resources/sample/tag2.xhtml 2010-04-21 14:10:23 UTC (rev 21583)
@@ -4,5 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="a2"/>
+ <composite:attribute name="b3"/>
</composite:interface>
+ #{cc.attrs.}
</html>
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForCompositeComponentTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForCompositeComponentTest.java 2010-04-21 14:02:36 UTC (rev 21582)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/CAForCompositeComponentTest.java 2010-04-21 14:10:23 UTC (rev 21583)
@@ -7,6 +7,7 @@
boolean makeCopy = true;
private static final String PROJECT_NAME = "CAForCompositeComponentTest";
private static final String PAGE_NAME = "/WebContent/pages/greeting.xhtml";
+ private static final String TAG_NAME = "/WebContent/resources/sample/tag2.xhtml";
public void setUp() throws Exception {
provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test", null, PROJECT_NAME, makeCopy);
@@ -31,4 +32,16 @@
};
checkProposals(PAGE_NAME, "<sample:tag />", 12, proposals, false);
}
+
+ /**
+ * JBIDE-5941
+ */
+ public void testCAForCCAttrs(){
+ String[] proposals = {
+ "cc.attrs.a2", "cc.attrs.b3", "cc.attrs.onclick"
+ };
+
+ checkProposals(TAG_NAME, "#{cc.attrs.}", 11, proposals, false);
+
+ }
}
14 years, 8 months
JBoss Tools SVN: r21582 - in branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui: wizards/project and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-04-21 10:02:36 -0400 (Wed, 21 Apr 2010)
New Revision: 21582
Modified:
branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java
branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5974
Modified: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java
===================================================================
--- branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java 2010-04-21 13:56:06 UTC (rev 21581)
+++ branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java 2010-04-21 14:02:36 UTC (rev 21582)
@@ -44,6 +44,7 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.eclipse.wst.server.core.IRuntime;
@@ -394,9 +395,19 @@
FacetDataModelMap map = (FacetDataModelMap) dataModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
IDataModel configDM = (IDataModel) map.get("jst.web"); //$NON-NLS-1$
+ boolean hasJSTWebFacet = false;
if(exists) {
IFacetedProject fp0 = ProjectFacetsManager.create(getProject());
exists = fp0 != null;
+ if(exists) {
+ Set<IProjectFacetVersion> vs = fp0.getProjectFacets();
+ if(vs != null) for (IProjectFacetVersion v: vs) {
+ String id = v.getProjectFacet().getId();
+ if("jst.web".equals(id)) { //$NON-NLS-1$
+ hasJSTWebFacet = true;
+ }
+ }
+ }
}
if(sv != null && (sv.indexOf("2.3") >= 0 || sv.indexOf("2.5") >= 0)) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -448,7 +459,7 @@
ProjectUtilities.addNatureToProject(getProject(), emfNature);
}
}
- if(!exists) {
+ if(!exists || !hasJSTWebFacet) {
return wcco;
} else {
return null;
Modified: branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java
===================================================================
--- branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java 2010-04-21 13:56:06 UTC (rev 21581)
+++ branches/jbosstools-3.1.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java 2010-04-21 14:02:36 UTC (rev 21582)
@@ -13,6 +13,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -22,6 +24,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.jboss.tools.common.model.ui.attribute.XAttributeSupport;
import org.jboss.tools.common.model.ui.attribute.adapter.IModelPropertyEditorAdapter;
import org.jboss.tools.common.model.ui.attribute.editor.IPropertyEditor;
@@ -36,6 +39,11 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
import org.jboss.tools.common.meta.action.XEntityData;
import org.jboss.tools.common.meta.action.impl.XEntityDataImpl;
@@ -364,6 +372,50 @@
}
}
+ if(project != null && project.exists()) {
+ //Check existing faceted project
+ IProjectFacet f = ProjectFacetsManager.getProjectFacet("jst.web"); //$NON-NLS-1$
+ if(f != null) {
+ IFacetedProject fp = null;
+ try {
+ fp = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if(fp != null) {
+ //Check that 'jst.web' facet is compatible with facets of existing faceted projects
+ boolean hasJSTWebFacet = false;
+ Set<IProjectFacetVersion> vs = fp.getProjectFacets();
+ if(vs != null) for (IProjectFacetVersion v: vs) {
+ String id = v.getProjectFacet().getId();
+ if("jst.web".equals(id)) { //$NON-NLS-1$
+ hasJSTWebFacet = true;
+ }
+ }
+ if(!hasJSTWebFacet) {
+ Set<IProjectFacetVersion> fvs = f.getVersions();
+ boolean ok = false;
+ for (IProjectFacetVersion v: fvs) {
+ IFacetedProject.Action action = new Action(IFacetedProject.Action.Type.INSTALL, v, null);
+ Set<IFacetedProject.Action> actions = new HashSet<Action>();
+ actions.add(action);
+ IStatus status = ProjectFacetsManager.check(vs, actions);
+ if(status != null && status.isOK()) {
+ ok = true;
+ break;
+ }
+ }
+ if (!ok) {
+ String message = "This project cannot be converted to Web Dynamic project required for JSF capabilities."; //$NON-NLS-1$
+ setErrorMessage(message);
+ return false;
+ }
+ }
+ }
+
+ }
+ }
+
if(context.isInitialized()) return true;
boolean hasNature = false;
boolean hasJavaNature = false;
14 years, 8 months
JBoss Tools SVN: r21581 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-04-21 09:56:06 -0400 (Wed, 21 Apr 2010)
New Revision: 21581
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5974
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java 2010-04-21 13:55:32 UTC (rev 21580)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java 2010-04-21 13:56:06 UTC (rev 21581)
@@ -13,6 +13,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -22,6 +24,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.jboss.tools.common.model.ui.attribute.XAttributeSupport;
import org.jboss.tools.common.model.ui.attribute.adapter.IModelPropertyEditorAdapter;
import org.jboss.tools.common.model.ui.attribute.editor.IPropertyEditor;
@@ -36,6 +39,11 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
import org.jboss.tools.common.meta.action.XEntityData;
import org.jboss.tools.common.meta.action.impl.XEntityDataImpl;
@@ -364,6 +372,50 @@
}
}
+ if(project != null && project.exists()) {
+ //Check existing faceted project
+ IProjectFacet f = ProjectFacetsManager.getProjectFacet("jst.web"); //$NON-NLS-1$
+ if(f != null) {
+ IFacetedProject fp = null;
+ try {
+ fp = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if(fp != null) {
+ //Check that 'jst.web' facet is compatible with facets of existing faceted projects
+ boolean hasJSTWebFacet = false;
+ Set<IProjectFacetVersion> vs = fp.getProjectFacets();
+ if(vs != null) for (IProjectFacetVersion v: vs) {
+ String id = v.getProjectFacet().getId();
+ if("jst.web".equals(id)) { //$NON-NLS-1$
+ hasJSTWebFacet = true;
+ }
+ }
+ if(!hasJSTWebFacet) {
+ Set<IProjectFacetVersion> fvs = f.getVersions();
+ boolean ok = false;
+ for (IProjectFacetVersion v: fvs) {
+ IFacetedProject.Action action = new Action(IFacetedProject.Action.Type.INSTALL, v, null);
+ Set<IFacetedProject.Action> actions = new HashSet<Action>();
+ actions.add(action);
+ IStatus status = ProjectFacetsManager.check(vs, actions);
+ if(status != null && status.isOK()) {
+ ok = true;
+ break;
+ }
+ }
+ if (!ok) {
+ String message = "This project cannot be converted to Web Dynamic project required for JSF capabilities."; //$NON-NLS-1$
+ setErrorMessage(message);
+ return false;
+ }
+ }
+ }
+
+ }
+ }
+
if(context.isInitialized()) return true;
boolean hasNature = false;
boolean hasJavaNature = false;
14 years, 8 months
JBoss Tools SVN: r21580 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-04-21 09:55:32 -0400 (Wed, 21 Apr 2010)
New Revision: 21580
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5974
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java 2010-04-21 12:19:20 UTC (rev 21579)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java 2010-04-21 13:55:32 UTC (rev 21580)
@@ -44,6 +44,7 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationPropertiesNew;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.eclipse.wst.server.core.IRuntime;
@@ -394,9 +395,19 @@
FacetDataModelMap map = (FacetDataModelMap) dataModel.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
IDataModel configDM = (IDataModel) map.get("jst.web"); //$NON-NLS-1$
+ boolean hasJSTWebFacet = false;
if(exists) {
IFacetedProject fp0 = ProjectFacetsManager.create(getProject());
exists = fp0 != null;
+ if(exists) {
+ Set<IProjectFacetVersion> vs = fp0.getProjectFacets();
+ if(vs != null) for (IProjectFacetVersion v: vs) {
+ String id = v.getProjectFacet().getId();
+ if("jst.web".equals(id)) { //$NON-NLS-1$
+ hasJSTWebFacet = true;
+ }
+ }
+ }
}
if(sv != null && (sv.indexOf("2.3") >= 0 || sv.indexOf("2.5") >= 0)) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -448,7 +459,7 @@
ProjectUtilities.addNatureToProject(getProject(), emfNature);
}
}
- if(!exists) {
+ if(!exists || !hasJSTWebFacet) {
return wcco;
} else {
return null;
14 years, 8 months
JBoss Tools SVN: r21579 - trunk/bpel/plugins/org.eclipse.bpel.model.
by jbosstools-commits@lists.jboss.org
Author: bbrodt
Date: 2010-04-21 08:19:20 -0400 (Wed, 21 Apr 2010)
New Revision: 21579
Modified:
trunk/bpel/plugins/org.eclipse.bpel.model/build.properties
Log:
checked in unintentional change
Modified: trunk/bpel/plugins/org.eclipse.bpel.model/build.properties
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.model/build.properties 2010-04-21 11:50:54 UTC (rev 21578)
+++ trunk/bpel/plugins/org.eclipse.bpel.model/build.properties 2010-04-21 12:19:20 UTC (rev 21579)
@@ -10,7 +10,8 @@
# JBoss by Red Hat - subsequent contributions and maintenance
###############################################################################
bin.includes = META-INF/,\
- plugin.*
+ plugin.*,\
+ .
src.includes = .classpath,\
.cvsignore,\
.project,\
@@ -18,3 +19,4 @@
src/,\
META-INF/,\
plugin.*
+source.. = src/
14 years, 8 months
JBoss Tools SVN: r21578 - in trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext: config and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: lzoubek(a)redhat.com
Date: 2010-04-21 07:50:54 -0400 (Wed, 21 Apr 2010)
New Revision: 21578
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/SwitchPerspective.java
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJRE.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java
Log:
SWTbot extensions : improving custom annotations
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -7,9 +7,11 @@
import org.apache.log4j.Logger;
import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;
import org.junit.runner.Runner;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.Suite;
+import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
/**
@@ -17,14 +19,32 @@
*
* @author lzoubek(a)redhat.com
*/
-public class RequirementAwareSuite extends Suite {
+public class RequirementAwareSuite extends Suite {
+ class ReqAwareClassRunner extends BlockJUnit4ClassRunner {
+ private final List<RequirementBase> requirements;
+ public ReqAwareClassRunner(Class<?> klass, List<RequirementBase> requirements) throws InitializationError {
+ super(klass);
+ this.requirements = requirements;
+ }
+ @Override
+ protected Object createTest() throws Exception {
+ log.info("Fullfilling requirements before test "+getTestClass().getJavaClass());
+ for (RequirementBase r : requirements) {
+ r.fulfill();
+ }
+ return super.createTest();
+ }
+
+ }
+
private static final Logger log = Logger.getLogger(RequirementAwareSuite.class);
private class RequirementAwareRunnerBuilder extends RunnerBuilder {
@Override
- public Runner runnerForClass(Class<?> klass) throws Throwable {
- if (TestConfigurator.canRunClass(klass)) {
+ public Runner runnerForClass(Class<?> klass) throws Throwable {
+ List<RequirementBase> reqs = TestConfigurator.getClassRequirements(klass);
+ if (reqs!=null) {
log.info("Returning runner for test class "+klass.getCanonicalName());
- return new BlockJUnit4ClassRunner(klass);
+ return new ReqAwareClassRunner(klass,reqs);
}
log.info("Skipping test class "+klass.getCanonicalName());
return null;
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTOpenExt.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -158,6 +158,7 @@
shell.activate();
bot.table().select(perspective.getName());
bot.button("OK").click();
+ log.info("Perspective switched to '"+perspective.getName()+"'");
}
/**
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -10,23 +10,15 @@
******************************************************************************/
package org.jboss.tools.ui.bot.ext;
-import java.util.List;
import java.util.Properties;
-import java.util.Vector;
-
import org.apache.log4j.Logger;
import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.jboss.tools.ui.bot.ext.config.ConfiguredState;
-import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;
-import org.jboss.tools.ui.bot.ext.gen.IView;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.view.ConsoleView;
import org.jboss.tools.ui.bot.ext.view.PackageExplorer;
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
import org.jboss.tools.ui.bot.ext.view.ServersView;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
/**
* Base class for SWTBot Tests using SWTBotExt
* @author jpeterka
@@ -50,8 +42,6 @@
// config & state
public static final ConfiguredState configuredState = new ConfiguredState();
- public static final List<RequirementBase> beforeRequirements = new Vector<RequirementBase>();
- public static final List<RequirementBase> afterRequirements = new Vector<RequirementBase>();
public static Properties properties;
/**
@@ -70,32 +60,5 @@
public static int TIME_5S = Timing.time5S();
public static int TIME_10S = Timing.time10S();
public static int TIME_20S = Timing.time20S();
-
- /**
- * fullfills given requirements
- * @param requirements
- */
- @BeforeClass
- public static void beforeTest() throws Exception {
- // try to close Welcome view
- open.viewClose(new IView(){
- public List<String> getGroupPath() {
- return new Vector<String>();
- }
- public String getName() {
- return IDELabel.View.WELCOME;
- }});
- log.info("Fullfilling requirements before test");
- for (RequirementBase r : beforeRequirements) {
- r.fullfill();
- }
- }
- @AfterClass
- public static void afterTest() throws Exception {
- log.info("Fullfilling requirements before test");
- for (RequirementBase r : afterRequirements) {
- r.fullfill();
- }
- }
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -10,7 +10,7 @@
public class Annotations {
/**
* annotation which defines requirement of whole test Class
- * by default all sub-annotations are optional and are
+ * by default all sub-annotations are optional and are disabled
* @author lzoubek
*
*/
@@ -22,6 +22,11 @@
*/
Server server() default @Server( required = false );
Seam seam() default @Seam( required = false );
+ /**
+ * name of perspective to run within
+ * @return
+ */
+ String perspective() default "";
}
/**
* Server requirement, by default matches all server types and versions
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -4,14 +4,16 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
-
import org.jboss.tools.ui.bot.ext.Activator;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.*;
import org.jboss.tools.ui.bot.ext.config.requirement.AddSeam;
import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;
import org.jboss.tools.ui.bot.ext.config.requirement.StartServer;
+import org.jboss.tools.ui.bot.ext.config.requirement.SwitchPerspective;
public class TestConfigurator {
@@ -112,30 +114,38 @@
return new AddSeam();
}
/**
- * returns true, if given class (Test) can run, this is done by exploring class'es
+ * returns list of requirements if given class (Test) can run, all this is done by exploring class'es
* annotations (see {@link SWTBotTestRequires}
+ * if class cannot run returns null
*/
- public static boolean canRunClass(Class<?> klass) {
+ public static List<RequirementBase> getClassRequirements(Class<?> klass) {
+
SWTBotTestRequires requies = klass.getAnnotation(SWTBotTestRequires.class);
// all not annotated classes can run
if (requies==null) {
- return true;
+ return null;
}
+ // internal list
+ List<RequirementBase> reqs = new ArrayList<RequirementBase>();
+
if (requies.server().required()) {
RequirementBase req = getServerRequirement(requies.server());
if (req==null) {
- return false;
+ return null;
}
- SWTTestExt.beforeRequirements.add(req);
+ reqs.add(req);
}
if (requies.seam().required()) {
RequirementBase req = getSeamRequirement(requies.seam());
if (req==null) {
- return false;
+ return null;
}
- SWTTestExt.beforeRequirements.add(req);
+ reqs.add(req);
}
- return true;
+ if (!"".equals(requies.perspective())) {
+ reqs.add(new SwitchPerspective(requies.perspective()));
+ }
+ return reqs;
}
/**
* implements comparison of 2 params by given operator (in this order)
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJRE.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJRE.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJRE.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -19,7 +19,7 @@
this.version = version;
}
@Override
- public boolean checkFullfilled() {
+ public boolean checkFulfilled() {
return SWTTestExt.configuredState.getJreList().contains(getAddedAsName());
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -6,7 +6,7 @@
public class AddSeam extends RequirementBase {
@Override
- public boolean checkFullfilled() {
+ public boolean checkFulfilled() {
return SWTTestExt.configuredState.getSeam().isConfiured;
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -88,7 +88,7 @@
fail("Unable to add server runtime, unparsable or not supported property value: "+TestConfigurator.getProperty(TestConfigurator.Keys.SERVER));
}
@Override
- public boolean checkFullfilled() {
+ public boolean checkFulfilled() {
return SWTTestExt.configuredState.getServer().isConfigured;
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -29,19 +29,20 @@
* fulfills this requirement. First fulfills the dependent ones, then this.
* @throws RequirementNotFulfilledException
*/
- public void fullfill() throws RequirementNotFulfilledException {
+ public void fulfill() throws RequirementNotFulfilledException {
log.info("Fulfilling requirement '"+this.getClass().getName()+"'");
try {
for (RequirementBase dep : getDependsOn()) {
- dep.fullfill();
+ dep.fulfill();
}
- if (!checkFullfilled()) {
+ if (!checkFulfilled()) {
handle();
- if (!checkFullfilled()) {
- throw new Exception("Requirement implementation error, checkFullfilled failed after calling handle();");
+ if (!checkFulfilled()) {
+ throw new Exception("Requirement implementation error, checkFulfilled() failed after calling handle();");
}
}
} catch (Exception ex) {
+ log.info("Unable to fulfill requirement '"+this.getClass().getName()+"'");
throw new RequirementNotFulfilledException("Unable to fulfill requirement "+this.getClass().getCanonicalName(),ex);
}
log.info("Requirement '"+this.getClass().getName()+"' fulfilled");
@@ -51,10 +52,19 @@
* must return true if the Requirement is already fulfilled
* @return
*/
- public abstract boolean checkFullfilled();
+ public abstract boolean checkFulfilled();
/**
- * handles (should do everything to fulfill requirement), {@link RequirementBase#checkFullfilled()}
+ * handles (should do everything to fulfill requirement), {@link RequirementBase#checkFulfilled()}
* should return true after calling this method
*/
public abstract void handle();
+
+ @Override
+ public int hashCode() {
+ return getClass().hashCode();
+ }
+ @Override
+ public boolean equals(Object obj) {
+ return this.getClass().equals(obj.getClass());
+ }
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java 2010-04-21 10:55:28 UTC (rev 21577)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -14,7 +14,7 @@
}
@Override
- public boolean checkFullfilled() {
+ public boolean checkFulfilled() {
return SWTTestExt.configuredState.getServer().isRunning;
}
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/SwitchPerspective.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/SwitchPerspective.java (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/SwitchPerspective.java 2010-04-21 11:50:54 UTC (rev 21578)
@@ -0,0 +1,33 @@
+package org.jboss.tools.ui.bot.ext.config.requirement;
+
+import java.util.List;
+import java.util.Vector;
+
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.gen.IPerspective;
+
+public class SwitchPerspective extends RequirementBase {
+
+ private final String name;
+ public SwitchPerspective(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean checkFulfilled() {
+ return SWTTestExt.bot.activePerspective().getLabel().equals(name);
+ }
+
+ @Override
+ public void handle() {
+ SWTTestExt.open.perspective(new IPerspective() {
+ public List<String> getGroupPath() {
+ return new Vector<String>();
+ }
+ public String getName() {
+ return name;
+ }});
+
+ }
+
+}
Property changes on: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/SwitchPerspective.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 8 months
JBoss Tools SVN: r21577 - in trunk: drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-04-21 06:55:28 -0400 (Wed, 21 Apr 2010)
New Revision: 21577
Added:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRules.java
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java
Log:
Added Drools Rule Test
Modified: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -16,9 +16,11 @@
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsRuntime;
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsProject;
+import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsRules;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@@ -34,15 +36,19 @@
*/
@RunWith(Suite.class)
@SuiteClasses({ManageDroolsRuntime.class,
- ManageDroolsProject.class})
+ ManageDroolsProject.class,
+ ManageDroolsRules.class})
public class DroolsAllBotTests extends SWTTestExt {
public static final String DROOLS_PROJECT_NAME = "droolsTest";
public static final String DROOLS_RUNTIME_NAME = "Drools Test Runtime";
public static String DROOLS_RUNTIME_LOCATION = null;
public static String CREATE_DROOLS_RUNTIME_LOCATION = null;
public static String SRC_MAIN_JAVA_TREE_NODE = "src/main/java";
+ public static String SRC_MAIN_RULES_TREE_NODE = "src/main/rules";
public static String COM_SAMPLE_TREE_NODE = "com.sample";
public static String DROOLS_TEST_JAVA_TREE_NODE = "DroolsTest.java";
+ public static final String TEST_DROOLS_RULE_NAME = "TestRule.drl";
+ public static final String SAMPLE_DROOLS_RULE_NAME = "Sample.drl";
private static String testDroolsRuntimeName = null;
public static String getTestDroolsRuntimeName() {
return testDroolsRuntimeName;
@@ -74,7 +80,7 @@
} catch (WidgetNotFoundException wnfe){
// Do nothing ignore this error
}
-
+ eclipse.openPerspective(PerspectiveType.JAVA);
}
@AfterClass
Modified: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -15,14 +15,18 @@
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.helper.FileRenameHelper;
import org.jboss.tools.ui.bot.ext.types.EntityType;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+import org.jboss.tools.ui.bot.test.WidgetVariables;
import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
import org.junit.Test;
+import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
/**
* Test managing of Drools Project
@@ -33,10 +37,14 @@
/**
* Test manage Drools project
*/
+ private static final String RENAMED_DROOLS_PROJECT = DroolsAllBotTests.DROOLS_PROJECT_NAME + "-renamed";
@Test
public void testManageDroolsProject() {
createDroolsProject (DroolsAllBotTests.DROOLS_PROJECT_NAME);
runNewDroolsProject (DroolsAllBotTests.DROOLS_PROJECT_NAME);
+ renameDroolsProject (DroolsAllBotTests.DROOLS_PROJECT_NAME, ManageDroolsProject.RENAMED_DROOLS_PROJECT);
+ deleteDroolsProject (ManageDroolsProject.RENAMED_DROOLS_PROJECT);
+ createDroolsProject (DroolsAllBotTests.DROOLS_PROJECT_NAME);
}
/**
* Creates new Drools project
@@ -108,5 +116,41 @@
"Expected console text is: " + "Hello World\nGoodbye cruel world\n",
"Hello World\nGoodbye cruel world\n".equals(consoleText));
}
+ /**
+ * Renames Drools project and check result
+ * @param droolsProjectName
+ * @param renamedProjectName
+ */
+ private void renameDroolsProject(String droolsProjectName, String renamedProjectName){
+ packageExplorer.show();
+
+ bot.sleep(TIME_1S);
+
+ SWTBot webProjects = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).bot();
+ SWTBotTree tree = webProjects.tree();
+
+ tree.setFocus();
+ String checkResult = FileRenameHelper.checkProjectRenamingWithinPackageExplorer(bot,
+ DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ ManageDroolsProject.RENAMED_DROOLS_PROJECT,
+ IDELabel.Shell.RENAME_JAVA_PROJECT);
+ assertNull(checkResult,checkResult);
+ }
+ /**
+ * Deletes Drools project and check result
+ * @param droolsProjectName
+ */
+ private void deleteDroolsProject(String droolsProjectName){
+
+ packageExplorer.deleteProject(droolsProjectName, true);
+ boolean notFound = false;
+ try{
+ packageExplorer.selectProject(droolsProjectName);
+ }catch (WidgetNotFoundException wnf){
+ notFound = true;
+ }
+ assertTrue("Drools project: " + droolsProjectName +
+ " was not deleted properly",notFound);
+ }
}
Added: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRules.java
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRules.java (rev 0)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRules.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -0,0 +1,117 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.drools.ui.bot.test.smoke;
+
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.EntityType;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
+import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
+import org.junit.Test;
+/**
+ * Test managing of Drools Rules
+ * @author Vladimir Pakan
+ *
+ */
+public class ManageDroolsRules extends SWTTestExt{
+ /**
+ * Test manage Drools Rules
+ */
+ @Test
+ public void testManageDroolsProject() {
+ createDroolsRule (DroolsAllBotTests.TEST_DROOLS_RULE_NAME);
+ debugDroolsRule (DroolsAllBotTests.SAMPLE_DROOLS_RULE_NAME);
+ }
+ /**
+ * Creates Drools Rule and checks result
+ * @param droolsRuletName
+ */
+ private void createDroolsRule(String droolsRuleName){
+
+ packageExplorer.show();
+ SWTBotTreeItem tiDroolsRules = packageExplorer.selectTreeItem(DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE,
+ new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME});
+
+ tiDroolsRules.select();
+ eclipse.createNew(EntityType.DROOLS_RULE);
+
+ bot.textWithLabel(IDELabel.NewDroolsRuleDialog.FILE_NAME).setText(droolsRuleName);
+ bot.textWithLabel(IDELabel.NewDroolsRuleDialog.RULE_PACKAGE_NAME).setText(DroolsAllBotTests.COM_SAMPLE_TREE_NODE);
+ bot.button(IDELabel.Button.FINISH).click();
+ bot.sleep(Timing.time1S());
+ tiDroolsRules.expand();
+ // Test if new Drools Rule is within package tree view
+ boolean isRuleCreated = true;
+ try{
+ tiDroolsRules.getNode(droolsRuleName);
+ } catch (WidgetNotFoundException wnfe){
+ isRuleCreated = false;
+ }
+ assertTrue("New Drools Rule was not created properly. It's not present within Package Explorer",isRuleCreated);
+ // Test if new Drools Rule is opened in editor
+ isRuleCreated = true;
+ try{
+ bot.editorByTitle(droolsRuleName);
+ } catch (WidgetNotFoundException wnfe){
+ isRuleCreated = false;
+ }
+ assertTrue("New Drools Rule was not created properly. File " + droolsRuleName + " is not opened in editor",isRuleCreated);
+ }
+ /**
+ * Debug Drools Rule and checks result
+ * @param droolsRuletName
+ */
+ private void debugDroolsRule(String droolsRuleName){
+ packageExplorer.show();
+ SWTBotTreeItem tiDroolsRule = packageExplorer.selectTreeItem(DroolsAllBotTests.SAMPLE_DROOLS_RULE_NAME,
+ new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE});
+ SWTBot packageExplorerBot = bot.viewByTitle(ViewType.PACKAGE_EXPLORER.getViewLabel()).bot();
+ SWTBotTree tree = packageExplorerBot.tree();
+ // Select and Open Rule File
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree , tiDroolsRule);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.OPEN, true)).click();
+ SWTBotEclipseEditor ruleEditor = bot.editorByTitle(droolsRuleName).toTextEditor();
+ ruleEditor.selectRange(8, 0, 0);
+ bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.TOGGLE_BREAKPOINT).click();
+ SWTBotTreeItem tiDroolsTest = packageExplorer.selectTreeItem(DroolsAllBotTests.DROOLS_TEST_JAVA_TREE_NODE,
+ new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_JAVA_TREE_NODE,
+ DroolsAllBotTests.COM_SAMPLE_TREE_NODE});
+ console.clearConsole();
+ eclipse.debugTreeItemAsDroolsApplication(tiDroolsTest);
+ eclipse.closeConfirmPerspectiveSwitchShellIfOpened(true);
+ String consoleText = console.getConsoleText(3*1000L,3*1000L,true);
+ assertTrue("Drools Rule was not debuged properly.\nConsole content should have been empty but is:\n" + consoleText,
+ consoleText.length() == 0);
+ SWTBotView debugView = bot.viewByTitle(ViewType.DEBUG.getViewLabel());
+ debugView.toolbarButton(IDELabel.DebugView.BUTTON_STEP_OVER_TOOLTIP).click();
+ consoleText = console.getConsoleText(3*1000L,60*1000L,true);
+ assertTrue("Drools Rule was not debuged properly.\nConsole content should be:\n'Hello World\n' but is:\n" + consoleText,
+ consoleText.equals("Hello World\n"));
+ debugView.toolbarButton(IDELabel.DebugView.BUTTON_RESUME_TOOLTIP).click();
+ consoleText = console.getConsoleText(3*1000L,60*1000L,true);
+ assertTrue("Drools Rule was not debuged properly.\nConsole content should be:Hello World\nGoodbye cruel world\n" + consoleText,
+ consoleText.equals("Hello World\nGoodbye cruel world\n"));
+ }
+
+}
+
Property changes on: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRules.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -11,10 +11,6 @@
package org.jboss.tools.drools.ui.bot.test.smoke;
-import static org.jboss.tools.ui.bot.ext.SWTTestExt.bot;
-import static org.jboss.tools.ui.bot.ext.SWTTestExt.console;
-import static org.jboss.tools.ui.bot.ext.SWTTestExt.eclipse;
-
import java.io.File;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -156,6 +156,9 @@
case JPA:
perspectiveLabel = IDELabel.SelectPerspectiveDialog.JPA;
break;
+ case DEBUG:
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.DEBUG;
+ break;
default:
fail("Unknown perspective to open");
}
@@ -664,6 +667,24 @@
closeWarningWindowIfOpened(bot, pressContinueButton);
}
+ /**
+ * if Confirm Perspective Switch Shell is opened close it and depend on
+ * switchPerspective parameter change current perspective
+ *
+ * @param switchPerspective
+ */
+ public void closeConfirmPerspectiveSwitchShellIfOpened(
+ boolean switchPerspective) {
+ try {
+ bot.shell(IDELabel.Shell.CONFIRM_PERSPECTIVE_SWITCH).activate();
+ bot.button(
+ switchPerspective ? IDELabel.Button.YES
+ : IDELabel.Button.NO).click();
+ } catch (WidgetNotFoundException wnfe) {
+ // do nothing
+ }
+ }
+
/**
* Returns true if table column specified by column parameter contains item
*
@@ -941,5 +962,16 @@
return stringBuilder.toString();
}
-
+ /**
+ * Choose Debug As Drools Application menu for specified Tree Item
+ *
+ * @param treeItem
+ */
+ public void debugTreeItemAsDroolsApplication(SWTBotTreeItem treeItem) {
+ treeItem.select();
+ treeItem.click();
+ SWTEclipseExt.getMenuFromSubmenu(
+ bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.DEBUG_AS),
+ IDELabel.Menu.DEBUG_AS_DROOLS_APPLICATION).click();
+ }
}
\ No newline at end of file
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.ui.bot.ext;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Properties;
import java.util.Vector;
@@ -19,9 +17,7 @@
import org.apache.log4j.Logger;
import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.jboss.tools.ui.bot.ext.config.ConfiguredState;
-import org.jboss.tools.ui.bot.ext.config.requirement.AddServer;
import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;
-import org.jboss.tools.ui.bot.ext.config.requirement.StartServer;
import org.jboss.tools.ui.bot.ext.gen.IView;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.view.ConsoleView;
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -17,6 +17,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -26,17 +27,22 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
import org.jboss.tools.ui.bot.ext.parts.SWTBotBrowserExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.JobLists;
import org.jboss.tools.ui.bot.ext.types.JobState;
import org.osgi.framework.Bundle;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
/**
* Base class for all classes using SWTBot
@@ -48,7 +54,20 @@
private Logger log = Logger.getLogger(SWTUtilExt.class);
protected SWTWorkbenchBot bot;
+
+ private static class AlwaysMatchMatcher<T extends Widget> extends BaseMatcher<T> {
+ public boolean matches(Object item) {
+ // Always returns true
+ return true;
+ }
+
+ public void describeTo(Description description) {
+ description.appendText("AlwaysMatchMatcher");
+ }
+
+ }
+
public SWTUtilExt(SWTWorkbenchBot bot) {
this.bot = bot;
}
@@ -586,4 +605,50 @@
}
}
}
+ /**
+ * Display all active widgets
+ * @param bot
+ */
+ public static void displayAllBotWidgets (SWTBot bot){
+ List<?> widgets = bot.widgets(new SWTUtilExt.AlwaysMatchMatcher<Widget>());
+ for (Object object : widgets){
+ System.out.println(object +
+ " Text: " + SWTUtilExt.invokeMethod(object, "getText") +
+ " Tooltip: " + SWTUtilExt.invokeMethod(object, "getToolTipText"));
+ }
+ }
+ /**
+ * Display all Toolbar Buttons of view
+ * @param view
+ */
+ public static void displayAllToolbarButtons (SWTBotView view){
+ List<SWTBotToolbarButton> buttons = view.getToolbarButtons();
+ for (SWTBotToolbarButton button : buttons){
+ System.out.println("Button Tooltip: " + button.getToolTipText() +
+ " Text: " + button.getText());
+ }
+ }
+ /**
+ * Invoke method on object and returns result as String
+ * @param object
+ * @param method
+ * @return
+ */
+ public static String invokeMethod (Object object, String method){
+
+ String result = "<null>";
+
+ try {
+ result = SWTUtils.invokeMethod(object, "getText").toString();
+ } catch (NoSuchMethodException e) {
+ result = "<null>";
+ } catch (IllegalAccessException e) {
+ result = "<null>";
+ } catch (InvocationTargetException e) {
+ result = "<null>";
+ }
+
+ return result;
+ }
+
}
\ No newline at end of file
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -19,8 +19,8 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.types.JobName;
import org.jboss.tools.ui.bot.ext.types.ViewType;
/**
@@ -119,4 +119,51 @@
String[] treePathItems){
return checkFileRenamingWithinWebProjects(bot, oldFileName, newFileName, treePathItems, "");
}
+ /**
+ * Check Project Renaming within Package Explorer
+ * @param bot
+ * @param oldProjectName
+ * @param newProjectName
+ * @return
+ */
+ public static String checkProjectRenamingWithinPackageExplorer(SWTWorkbenchBot bot ,
+ String oldProjectName,
+ String newProjectName,
+ String renameShellTitle){
+
+ bot.sleep(sleepTime);
+ SWTBotTree tree = eclipse.showView(ViewType.PACKAGE_EXPLORER).tree();
+
+ tree.setFocus();
+ tree.getTreeItem(oldProjectName).select();
+ bot.sleep(Timing.time1S());
+ // Rename project
+ bot.menu(IDELabel.Menu.FILE).
+ menu("Rename...")
+ .click();
+ bot.sleep(Timing.time1S());
+ bot.shell(renameShellTitle).activate();
+ bot.textWithLabel(IDELabel.RenameResourceDialog.NEW_NAME)
+ .setText(newProjectName);
+ bot.button(IDELabel.Button.OK).click();
+ new SWTUtilExt(bot).waitForAll(Timing.time10S());
+ // Check Results
+ // Project with Old Name doesn't exists within Package explorer
+ try{
+ tree.getTreeItem(oldProjectName);
+ return "Project " + oldProjectName + " was not renamed to " + newProjectName + ".";
+ }catch (WidgetNotFoundException wnfe) {
+ // do nothing
+ }
+ // Project with New Name exists within Package Explorer
+ try{
+ tree.getTreeItem(newProjectName);
+ }catch (WidgetNotFoundException wnfe) {
+ return "Renamed Project " + newProjectName + " was not found.";
+ }
+
+ return null;
+
+ }
+
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -21,7 +21,7 @@
*/
public enum EntityType {
HIBERNATE_MAPPING_FILE, JAVA_PROJECT, JAVA_CLASS, HIBERNATE_REVERSE_FILE, HIBERNATE_CONSOLE,
- HIBERNATE_CONFIGURATION_FILE, STRUTS_PROJECT, JPA_PROJECT, DROOLS_PROJECT;
+ HIBERNATE_CONFIGURATION_FILE, STRUTS_PROJECT, JPA_PROJECT, DROOLS_PROJECT, DROOLS_RULE;
public List<String> getGroupsLabels() {
List<String> groupLabel = new LinkedList<String>();
@@ -36,6 +36,7 @@
case STRUTS_PROJECT: groupLabel.add(IDELabel.EntityGroup.JBOSS_TOOLS_WEB); groupLabel.add(IDELabel.EntityGroup.STRUTS);break;
case JPA_PROJECT: groupLabel.add(IDELabel.EntityGroup.JPA);break;
case DROOLS_PROJECT: groupLabel.add(IDELabel.EntityGroup.DROOLS);break;
+ case DROOLS_RULE: groupLabel.add(IDELabel.EntityGroup.DROOLS);break;
default: fail("Unknown Entity Type");
}
@@ -43,7 +44,7 @@
}
/**
- * Return entity label acc
+ * Return entity label
* @return
*/
public String getEntityLabel() {
@@ -59,6 +60,7 @@
case STRUTS_PROJECT: entityLabel = IDELabel.EntityLabel.STRUTS_PROJECT; break;
case JPA_PROJECT: entityLabel = IDELabel.EntityLabel.JPA_PROJECT; break;
case DROOLS_PROJECT: entityLabel = IDELabel.EntityLabel.DROOLS_PROJECT; break;
+ case DROOLS_RULE: entityLabel = IDELabel.EntityLabel.DROOLS_RULE; break;
default: fail("Unknown Entity Type");
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -62,6 +62,9 @@
public static final String RUN_ON_SERVER = "Run on Server";
public static final String ADD_AND_REMOVE="Add and Remove...";
public static final String RUN_AS_JAVA_APPLICATION="Java Application";
+ public static final String TOGGLE_BREAKPOINT="Toggle Breakpoint";
+ public static final String DEBUG_AS = "Debug As";
+ public static final String DEBUG_AS_DROOLS_APPLICATION = "Drools Application";
}
public class Button {
@@ -110,6 +113,9 @@
public static final String WARNING = "Warning";
public static final String DROOLS_RUNTIME = "Drools Runtime";
public static final String NEW_DROOLS_PROJECT = "";
+ public static final String RENAME_COMPILATION_UNIT = "Rename Compilation Unit";
+ public static final String RENAME_JAVA_PROJECT = "Rename Java Project";
+ public static final String CONFIRM_PERSPECTIVE_SWITCH = "Confirm Perspective Switch";
public static final String NEW_SEAM_RUNTIME = "New Seam Runtime";
}
@@ -134,6 +140,7 @@
public static final String STRUTS_PROJECT = "Struts Project";
public static final String JPA_PROJECT = "JPA Project";
public static final String DROOLS_PROJECT = "Drools Project";
+ public static final String DROOLS_RULE = "Rule Resource";
}
public class JavaProjectWizard {
@@ -159,6 +166,7 @@
public static final String SERVERS = "Servers";
public static final String WEB_PROJECTS = "Web Projects";
public static final String PROBLEMS = "Problems";
+ public static final String DEBUG = "Debug";
}
public class ViewGroup {
@@ -167,6 +175,7 @@
public static final String DATA_MANAGEMENT = "Data Management";
public static final String SERVER = "Server";
public static final String JBOSS_TOOLS_WEB = "JBoss Tools Web";
+ public static final String DEBUG = "Debug";
}
public class SelectPerspectiveDialog {
@@ -176,6 +185,7 @@
public static final String WEB_DEVELOPMENT = "Web Development";
public static final String DB_DEVELOPMENT = "Database Development";
public static final String JPA = "JPA";
+ public static final String DEBUG = "Debug";
}
/**
* Hibernate Console Wizard (ConsoleConfigurationCreationWizard) Labels (
@@ -344,6 +354,13 @@
}
+ public static final class NewDroolsRuleDialog {
+
+ public static final String FILE_NAME = "File name:";
+ public static final String RULE_PACKAGE_NAME = "Rule package name:";
+
+ }
+
public static class ProblemsTree {
public static final String WARNINGS = "Warnings";
@@ -356,4 +373,11 @@
public static final String BUTTON_CLEAR_CONSOLE_TOOLTIP = "Clear Console";
}
+
+ public static class DebugView {
+
+ public static final String BUTTON_STEP_OVER_TOOLTIP = "Step Over (F6)";
+ public static final String BUTTON_RESUME_TOOLTIP = "Resume (F8)";
+
+ }
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -16,6 +16,6 @@
*
*/
public enum PerspectiveType {
- SEAM, JAVA, WEB_DEVELOPMENT, HIBERNATE, DB_DEVELOPMENT, JPA;
+ SEAM, JAVA, WEB_DEVELOPMENT, HIBERNATE, DB_DEVELOPMENT, JPA, DEBUG;
}
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -18,7 +18,7 @@
*
*/
public enum ViewType {
- PACKAGE_EXPLORER, PROJECT_EXPLORER, WELCOME, DATA_SOURCE_EXPLORER,SERVERS,WEB_PROJECTS,PROBLEMS;
+ PACKAGE_EXPLORER, PROJECT_EXPLORER, WELCOME, DATA_SOURCE_EXPLORER,SERVERS,WEB_PROJECTS,PROBLEMS,DEBUG;
public String getGroupLabel() {
@@ -30,6 +30,7 @@
case SERVERS: viewLabel = IDELabel.ViewGroup.SERVER; break;
case WEB_PROJECTS: viewLabel = IDELabel.ViewGroup.JBOSS_TOOLS_WEB; break;
case PROBLEMS: viewLabel = IDELabel.ViewGroup.GENERAL; break;
+ case DEBUG: viewLabel = IDELabel.ViewGroup.DEBUG; break;
default: fail("Unknown View Type");
}
return viewLabel;
@@ -44,6 +45,7 @@
case SERVERS: viewLabel = IDELabel.View.SERVERS; break;
case WEB_PROJECTS: viewLabel = IDELabel.View.WEB_PROJECTS; break;
case PROBLEMS: viewLabel = IDELabel.View.PROBLEMS; break;
+ case DEBUG: viewLabel = IDELabel.View.DEBUG; break;
default: fail("Unknown View Type");
}
return viewLabel;
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java 2010-04-21 10:52:22 UTC (rev 21576)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ConsoleView.java 2010-04-21 10:55:28 UTC (rev 21577)
@@ -84,8 +84,9 @@
String prevConsoleText = getConsoleText();
String consoleText = prevConsoleText;
log.info("Waiting for console text with TimeOut: " + timeOut);
- while ((estimatedTime <= timeOut)
+ while ((estimatedTime < timeOut)
&& (!quitWhenNoChange
+ || estimatedTime == 0
|| prevConsoleText == null
|| prevConsoleText.length() == 0
|| !prevConsoleText.equals(consoleText))){
14 years, 8 months
JBoss Tools SVN: r21576 - trunk/jst/tests/org.jboss.tools.ui.bot.ext.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-04-21 06:52:22 -0400 (Wed, 21 Apr 2010)
New Revision: 21576
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties
Log:
Added resource dir to src property to remove warning
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties 2010-04-21 09:31:44 UTC (rev 21575)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties 2010-04-21 10:52:22 UTC (rev 21576)
@@ -1,4 +1,4 @@
-source.. = src/
+source.. = src/,resources/
output.. = bin/
bin.includes = META-INF/,\
.
14 years, 8 months
JBoss Tools SVN: r21575 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2010-04-21 05:31:44 -0400 (Wed, 21 Apr 2010)
New Revision: 21575
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5042
Enhance DnD support in VPE
- Code cleanup has been done.
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-04-21 09:10:45 UTC (rev 21574)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-04-21 09:31:44 UTC (rev 21575)
@@ -15,12 +15,12 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
import org.jboss.tools.common.model.ui.editors.dnd.DropUtils;
import org.jboss.tools.common.model.ui.editors.dnd.context.IDNDTextEditor;
@@ -67,13 +67,12 @@
* @author Max Areshkau
* @author Yahor Radtsevich (yradtsevich)
*/
-// TODO: cleanup the code
+// 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 {
private static final String TAG_TAGLIB = "taglib"; //$NON-NLS-1$
- private static int HUGE_DISTANCE = 999999;
-
- /*
+ /*
* Default transfer data
*/
private static final String VPE_ELEMENT = ""; //$NON-NLS-1$
@@ -189,7 +188,7 @@
.isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
XModelObject object = PreferenceModelUtilities.getPreferenceModel()
.getModelBuffer().source();
- if (object.getFileType() == XModelObject.FILE
+ if (object.getFileType() == XFileObject.FILE
&& !TLDUtil.isTaglib(object)) {
final IFile f = (IFile) EclipseResourceUtil.getResource(object);
return getSimpleDropResolver(f != null);
@@ -767,67 +766,6 @@
} else {
return new VpeVisualInnerDragInfo(element);
}
-
- // fix of JBIDE-4998
-// nsISelection selection = visualSelectionController.getSelection(
-// nsISelectionController.SELECTION_NORMAL);
-// nsIDOMNode focusNode = selection.getFocusNode();
-// nsIDOMNode anchorNode = selection.getAnchorNode();
-// //when we select input this function return null
-// //but we select elemnt
-// if(focusNode==null && anchorNode==null) {
-// nsIDOMNode visualNode =(nsIDOMNode) event.getTarget()
-// .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
-// //fix of JBIDE-1097
-// if(HTML.TAG_SPAN.equalsIgnoreCase(visualNode.getNodeName())) {
-// if(visualBuilder.getXulRunnerEditor().getLastSelectedElement() != null
-// && !visualBuilder.getNodeBounds(
-// visualBuilder.getXulRunnerEditor()
-// .getLastSelectedElement())
-// .contains(VisualDomUtil.getMousePoint(event))) {
-// return null;
-// }
-// }
-// int offset = (int) VisualDomUtil.getOffset(visualNode);
-// selection.removeAllRanges();
-// selection.collapse(visualNode.getParentNode(), offset);
-// try {
-// selection.extend(visualNode.getParentNode(), offset + 1);
-// } catch(XPCOMException ex) {
-// //just ignore exception
-// // throws when we trying drag element which already resizing
-// return null;
-// }
-// focusNode = selection.getFocusNode();
-// anchorNode = selection.getAnchorNode();
-// }
-// if (focusNode != null && focusNode.equals(anchorNode)) {
-// int focusOffset = selection.getFocusOffset();
-// int anchorOffset = selection.getAnchorOffset();
-// int offset = Math.min(focusOffset, anchorOffset);
-// int length = Math.max(focusOffset, anchorOffset) - offset;
-//
-// int focusNodeType = focusNode.getNodeType();
-// if (focusNodeType == nsIDOMNode.ELEMENT_NODE) {
-// if (length == 1) {
-// nsIDOMNodeList children = focusNode.getChildNodes();
-// nsIDOMNode selectedNode = children.item(
-// Math.min(focusOffset, anchorOffset));
-// if (visualBuilder.getNodeBounds(selectedNode).contains(VisualDomUtil.getMousePoint(event))) {
-// int selectedNodeType = selectedNode.getNodeType();
-// if (selectedNodeType == nsIDOMNode.ELEMENT_NODE) {
-// return new VpeVisualInnerDragInfo((nsIDOMElement)selectedNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID));
-// } else if (selectedNodeType == nsIDOMNode.TEXT_NODE) {
-// return new VpeVisualInnerDragInfo(selectedNode, 0, selectedNode.getNodeValue().length());
-// }
-// }
-// }
-// } else if (focusNodeType == nsIDOMNode.TEXT_NODE) {
-// return new VpeVisualInnerDragInfo(focusNode, offset, length);
-// }
-// }
-//
-// return null;
}
private VpeSourceDropInfo getDropInfo(nsIDOMEvent event) {
@@ -867,552 +805,9 @@
}
return new VpeSourceDropInfo(dropContainer, dropOffset, canDrop);
-
-// nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
-// event.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
-// int mouseX = nsuiEvent.getPageX();
-// int mouseY = nsuiEvent.getPageY();
-// nsIDOMNode dropContainer = null;
-// int dropOffset = 0;
-//
-// nsIDOMDocument document = vpeController.getVisualBuilder()
-// .getOriginalTargetNode(event).getOwnerDocument();
-//
-// nsIDOMNode originalNode = DndUtil.getElementFromPoint(document, mouseX, mouseY);
-//// if (originalNode != null) {
-//// if (dropableArea == null) {
-//// dropableArea = new DropableArea(document);
-//// dropableArea.setDropSpots(EnumSet.allOf(DropSpot.class));
-//// }
-//// dropableArea.setNode(originalNode);
-//// dropableArea.setHighlightedSpot(mouseX, mouseY);
-//// dropableArea.setVisible(true);
-//// dropableArea.redraw();
-//// }
-//
-// if (originalNode == null || originalNode.getParentNode() == null ||
-// originalNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
-// return new VpeVisualDropInfo(null, 0);
-// }
-// if (originalNode.getNodeType() == Node.TEXT_NODE) {
-// dropContainer = nsuiEvent.getRangeParent();
-// nsIDOMNode containerForPseudoContent = VpePseudoContentCreator
-// .getContainerForPseudoContent(dropContainer);
-// if (containerForPseudoContent != null) {
-// dropContainer = containerForPseudoContent;
-// dropOffset = 0;
-// } else {
-// dropOffset = nsuiEvent.getRangeOffset();
-// }
-// } else {
-// int closestXDistance = HUGE_DISTANCE;
-// int closestYDistance = HUGE_DISTANCE;
-// boolean inNodeFlag = false;
-// nsIDOMNode closestNode = null;
-//
-// nsIDOMNodeList childen = originalNode.getChildNodes();
-// long count = childen.getLength();
-// for (long i = 0; i < count; i++) {
-// nsIDOMNode child = childen.item(i);
-// if (VpeVisualDomBuilder.isPseudoElement(child)
-// || VpeVisualDomBuilder.isAnonElement(child)) {
-// continue;
-// }
-// Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
-// int fromTop = mouseY - rect.y;
-// int fromBottom = mouseY - rect.y - rect.height;
-//
-// int yDistance;
-// if (fromTop > 0 && fromBottom < 0) {
-// yDistance = 0;
-// } else {
-// yDistance = Math.min(Math.abs(fromTop), Math.abs(fromBottom));
-// }
-//
-// if (yDistance <= closestYDistance && rect.width > 0 && rect.height > 0) {
-// if (yDistance < closestYDistance) {
-// closestXDistance = HUGE_DISTANCE;
-// }
-// int fromLeft = mouseX - rect.x;
-// int fromRight = mouseX - rect.x - rect.width;
-//
-// int xDistance;
-// if (fromLeft > 0 && fromRight < 0) {
-// xDistance = 0;
-// } else {
-// xDistance = Math.min(Math.abs(fromLeft), Math.abs(fromRight));
-// }
-// if (xDistance == 0 && yDistance == 0) {
-// closestNode = child;
-// inNodeFlag = true;
-// break;
-// }
-//
-// if (xDistance < closestXDistance || (xDistance == closestXDistance && rect.x <= mouseX)) {
-// closestXDistance = xDistance;
-// closestYDistance = yDistance;
-// closestNode = child;
-// }
-// }
-// }
-//
-// if (closestNode == null) {
-// closestNode = originalNode;
-// inNodeFlag = true;
-// }
-// if (inNodeFlag) {
-// if (closestNode.getNodeType() == Node.TEXT_NODE) {
-// dropContainer = nsuiEvent.getRangeParent();
-// dropOffset = nsuiEvent.getRangeOffset();
-// } else {
-// if (HTML.TAG_COLGROUP.equalsIgnoreCase(closestNode.getNodeName())) {
-// nsIDOMNode nearChild = getNearChild(closestNode, mouseX, mouseY);
-// if (nearChild != null && nearChild.getNodeType() == Node.ELEMENT_NODE) {
-// dropContainer = nearChild;
-// } else {
-// dropContainer = closestNode;
-// }
-// } else {
-// dropContainer = closestNode;
-// }
-// dropOffset = 0;
-// }
-// } else {
-// dropContainer = closestNode.getParentNode();
-// dropOffset = (int)VisualDomUtil.getOffset(closestNode);
-// Rectangle rect = XulRunnerVpeUtils.getElementBounds(closestNode);
-// if (canInsertAfter(mouseX, mouseY, rect)) {
-// dropOffset++;
-// }
-// }
-// }
}
private interface DropResolver {
public boolean canDrop(Node node);
}
-
-// TODO: delete the following methods, as they are never used
-// this method is never used
-// private boolean canInsertAfter(int x, int y, Rectangle rect) {
-// if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
-// return true;
-// }
-// return y >= rect.x && x > (rect.x + rect.width / 2);
-// }
-
-// this method is never used
-// private MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
-// InnerDragBuffer.object = null;
-// vpeController.onHideTooltip();
-//
-// if (vpeController.getDropWindow().isActive()) {
-// if (!mouseEvent.getAltKey()) {
-// vpeController.getDropWindow().close();
-// } else {
-// return new MozillaDropInfo(false, null, 0);
-// }
-// }
-// if (mouseEvent.getAltKey()) {
-// nsIDOMNode visualNode = (nsIDOMNode) mouseEvent.getTarget()
-// .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
-// Node sourceNode = vpeController.getDomMapping().getNearSourceNode(visualNode);
-// if (sourceNode != null) {
-// if (ModelTransfer.MODEL.equals(flavor)) {
-// // XModelObject object =
-// // PreferenceModelUtilities.getPreferenceModel().
-// // getModelBuffer().source();
-// // InnerDragBuffer.object = object;
-// } else {
-// vpeController.getDropWindow().setFlavor(flavor);
-// }
-// vpeController.getDropWindow().setActive(true);
-// vpeController.getDropWindow().setEventPosition(mouseEvent.getScreenX(), mouseEvent
-// .getScreenY());
-// vpeController.getDropWindow().setInitialTargetNode(sourceNode);
-// vpeController.getDropWindow().open();
-// mouseEvent.stopPropagation();
-// mouseEvent.preventDefault();
-// return new MozillaDropInfo(false, null, 0);
-// }
-// }
-// boolean canDrop = false;
-// nsIDOMNode caretParent = null;
-// long caretOffset = 0;
-//
-// if (VpeController.MODEL_FLAVOR.equals(flavor)) {
-// XModelObject object = PreferenceModelUtilities.getPreferenceModel()
-// .getModelBuffer().source();
-// if (object.getFileType() == XModelObject.FILE
-// && !TLDUtil.isTaglib(object)) {
-// IFile f = (IFile) EclipseResourceUtil.getResource(object);
-// canDrop = f != null;
-// VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
-// caretParent = visualDropInfo.getDropContainer();
-// caretOffset = visualDropInfo.getDropOffset();
-// } else {
-// String tagname = vpeController.getTagName(object);
-// if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
-// Node sourceDragNode = ((Document) vpeController.getModel().getAdapter(
-// Document.class)).createElement(tagname);
-// VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
-// if (visualDropInfo.getDropContainer() != null) {
-// VpeSourceDropInfo sourceDropInfo
-// = getSourceDropInfo(
-// sourceDragNode, visualDropInfo, true);
-// canDrop = sourceDropInfo.canDrop();
-// if (canDrop) {
-// VpeVisualDropInfo newVisualDropInfo
-// = getDropInfo(
-// sourceDropInfo.getContainer(),
-// sourceDropInfo.getOffset());
-// if (newVisualDropInfo != null) {
-// correctVisualDropPosition(mouseEvent,
-// newVisualDropInfo, visualDropInfo);
-// caretParent = newVisualDropInfo.getDropContainer();
-// caretOffset = newVisualDropInfo.getDropOffset();
-// }
-// }
-// }
-// visualDropInfo.release();
-// }
-// } else if (XulRunnerEditor.TRANS_FLAVOR_kFileMime.equals(flavor)
-// || XulRunnerEditor.TRANS_FLAVOR_kURLMime.equals(flavor)) {
-// VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
-// caretParent = visualDropInfo.getDropContainer();
-// caretOffset = visualDropInfo.getDropOffset();
-// canDrop = true;
-//
-// }
-// if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
-// System.out.println(" canDrop: " + canDrop //$NON-NLS-1$
-// + (canDrop ?
-// " container: " //$NON-NLS-1$
-// + caretParent.getNodeName()
-// + " offset: " //$NON-NLS-1$
-// + caretOffset
-// : "")); //$NON-NLS-1$
-// }
-// return new MozillaDropInfo(canDrop, caretParent, caretOffset);
-//
-// }
-
-// this method is never used
-// private VpeSourceDropInfo getSourceDropInfo(Node dragNode,
-// Node container, int offset, boolean checkParentsTemplates) {
-// // Thread.dumpStack();
-// boolean canDrop = false;
-// switch (container.getNodeType()) {
-// case Node.ELEMENT_NODE:
-// VpeNodeMapping nodeMapping = vpeController.getDomMapping()
-// .getNodeMapping(container);
-// if (nodeMapping != null && nodeMapping instanceof VpeElementMapping) {
-// canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
-// .canInnerDrop(vpeController.getPageContext(), container, dragNode);
-// }
-// if (!canDrop) {
-// if (!checkParentsTemplates)
-// return new VpeSourceDropInfo(container, offset,
-// canDrop);
-// // offset = ((NodeImpl)container).getIndex();
-// // container = container.getParentNode();
-// // TODO Max Areshkau unclear logic , if we can drop on element
-// // why we trying to drop
-// // this on parent
-// // return getSourceDropInfo(dragNode, container, offset,
-// // false);
-// return new VpeSourceDropInfo(container, offset, canDrop);
-// }
-// break;
-// case Node.TEXT_NODE:
-// case Node.DOCUMENT_NODE:
-// canDrop = true;
-// break;
-// case Node.ATTRIBUTE_NODE:
-// canDrop = true;
-// break;
-// }
-// if (canDrop) {
-// return new VpeSourceDropInfo(container, offset, canDrop);
-// } else {
-// return new VpeSourceDropInfo(null, 0, canDrop);
-// }
-// }
-
-// this method is never used
-// private VpeSourceDropInfo getSourceDropInfo(Node sourceDragNode,
-// VpeVisualDropInfo visualDropInfo, boolean checkParentTemplates) {
-// nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
-// long visualDropOffset = visualDropInfo.getDropOffset();
-// Node sourceDropContainer = null;
-// int sourceDropOffset = 0;
-//
-// switch (visualDropContainer.getNodeType()) {
-// case nsIDOMNode.ELEMENT_NODE:
-// nsIDOMNode visualOffsetNode = null;
-// boolean afterFlag = false;
-// long visualChildCount = VisualDomUtil
-// .getChildCount(visualDropContainer);
-// if (visualDropOffset < visualChildCount) {
-// visualOffsetNode = VisualDomUtil.getChildNode(
-// visualDropContainer, visualDropOffset);
-// if (VpeVisualDomBuilder.isPseudoElement(visualOffsetNode)
-// || VpeVisualDomBuilder.isAnonElement(visualOffsetNode)) {
-// visualOffsetNode = VpeVisualDomBuilder
-// .getLastAppreciableVisualChild(visualDropContainer);
-// afterFlag = true;
-// }
-// } else {
-// visualOffsetNode = VpeVisualDomBuilder.getLastAppreciableVisualChild(visualDropContainer);
-// afterFlag = visualChildCount != 0;
-// }
-// if (visualOffsetNode != null) {
-// Node sourceOffsetNode = vpeController.getDomMapping()
-// .getSourceNode(visualOffsetNode);
-// if (sourceOffsetNode != null) {
-// sourceDropContainer = sourceOffsetNode.getParentNode();
-// sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
-// if (afterFlag) {
-// sourceDropOffset++;
-// }
-// }
-// }
-// if (sourceDropContainer == null) {
-// sourceDropContainer = vpeController.getDomMapping()
-// .getNearSourceNode(visualDropContainer);
-// if (sourceDropContainer != null) {
-// sourceDropOffset = sourceDropContainer.getChildNodes()
-// .getLength();
-// }
-// }
-// if (sourceDropContainer == null) {
-// sourceDropContainer = vpeController.getDomMapping()
-// .getNearSourceNode(
-// vpeController.getVisualBuilder().getContentArea());
-// sourceDropOffset = sourceDropContainer.getChildNodes()
-// .getLength();
-// }
-// break;
-// case nsIDOMNode.TEXT_NODE:
-// VpeNodeMapping nodeMapping = vpeController.getDomMapping()
-// .getNearNodeMapping(visualDropContainer);
-// // switch (nodeMapping.getType()) {
-// // case VpeNodeMapping.TEXT_MAPPING:
-// sourceDropContainer = nodeMapping.getSourceNode();
-// sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer
-// .getNodeValue(), visualDropOffset);
-// // break;
-// // case VpeNodeMapping.ELEMENT_MAPPING:
-// // it's attribute
-// if (VpeVisualDomBuilder.isTextEditable(visualDropContainer)) {
-// String[] atributeNames = ((VpeElementMapping) nodeMapping)
-// .getTemplate().getOutputAttributeNames();
-// if (atributeNames != null && atributeNames.length > 0) {
-// Element sourceElement = (Element) nodeMapping
-// .getSourceNode();
-// sourceDropContainer = sourceElement
-// .getAttributeNode(atributeNames[0]);
-// sourceDropOffset = TextUtil.sourceInnerPosition(
-// sourceDropContainer.getNodeValue(),
-// visualDropOffset);
-// }
-// }
-// }
-// if (sourceDropContainer != null) {
-// return getSourceDropInfo(sourceDragNode, sourceDropContainer,
-// sourceDropOffset, checkParentTemplates);
-// } else {
-// return new VpeSourceDropInfo(null, 0, false);
-// }
-// }
-
-// this method is never used
-// private void correctVisualDropPosition(nsIDOMMouseEvent mouseEvent,
-// VpeVisualDropInfo newVisualDropInfo,
-// VpeVisualDropInfo oldVisualDropInfo) {
-// nsIDOMNode newVisualDropContainer = newVisualDropInfo
-// .getDropContainer();
-// nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
-// .getDropContainer();
-//
-// if (newVisualDropContainer.equals(oldVisualDropContainer)) {
-// newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
-// return;
-// }
-//
-// nsIDOMNode child = oldVisualDropContainer;
-// while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
-// nsIDOMNode parent = child.getParentNode();
-// if (newVisualDropContainer.equals(parent)) {
-// long offset = VisualDomUtil.getOffset(child);
-// Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
-//
-// nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
-// mouseEvent.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
-// int mouseX = nsuiEvent.getPageX();
-// int mouseY = nsuiEvent.getPageY();
-//
-// if (canInsertAfter(mouseX, mouseY, rect)) {
-// offset++;
-// }
-// newVisualDropInfo.setDropOffset(offset);
-// }
-// child = parent;
-// }
-// }
-
-// this method is never used
-// private VpeVisualDropInfo getDropInfo(Node sourceDropContainer,
-// int sourceDropOffset) {
-// nsIDOMNode visualDropContainer = null;
-// long visualDropOffset = 0;
-//
-// switch (sourceDropContainer.getNodeType()) {
-// case Node.TEXT_NODE:
-// visualDropContainer = vpeController.getDomMapping().getVisualNode(sourceDropContainer);
-// visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
-// .getNodeValue(), sourceDropOffset);
-// break;
-// case Node.ELEMENT_NODE:
-// case Node.DOCUMENT_NODE:
-// NodeList sourceChildren = sourceDropContainer.getChildNodes();
-// if (sourceDropOffset < sourceChildren.getLength()) {
-// Node sourceChild = sourceChildren.item(sourceDropOffset);
-// nsIDOMNode visualChild = vpeController.getDomMapping().getVisualNode(sourceChild);
-// if (visualChild != null) {
-// visualDropContainer = visualChild.getParentNode();
-//
-// visualDropOffset = VisualDomUtil.getOffset(visualChild);
-// }
-// }
-// if (visualDropContainer == null) {
-// visualDropContainer = vpeController.getDomMapping()
-// .getNearVisualNode(sourceDropContainer);
-// nsIDOMNode visualChild = VpeVisualDomBuilder.getLastAppreciableVisualChild(visualDropContainer);
-// if (visualChild != null) {
-// visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
-// } else {
-// visualDropOffset = 0;
-// }
-// }
-// break;
-// case Node.ATTRIBUTE_NODE:
-// Element sourceElement = ((Attr) sourceDropContainer)
-// .getOwnerElement();
-// VpeElementMapping elementMapping = vpeController.getDomMapping()
-// .getNearElementMapping(sourceElement);
-// nsIDOMNode textNode = elementMapping.getTemplate()
-// .getOutputTextNode(vpeController.getPageContext(), sourceElement,
-// elementMapping.getData());
-// if (textNode != null) {
-// visualDropContainer = textNode;
-// visualDropOffset = TextUtil.visualInnerPosition(
-// sourceDropContainer.getNodeValue(), sourceDropOffset);
-// }
-// break;
-// }
-// if (visualDropContainer == null) {
-// return null;
-// }
-// return new VpeVisualDropInfo(visualDropContainer, visualDropOffset);
-// }
-
-// this method is never used
-// private nsIDOMNode getNearChild(nsIDOMNode container, int x, int y) {
-// int closestXDistance = HUGE_DISTANCE;
-// int closestYDistance = HUGE_DISTANCE;
-// nsIDOMNode closestNode = null;
-//
-// nsIDOMNodeList childen = container.getChildNodes();
-// long count = childen.getLength();
-// for (long i = 0; i < count; i++) {
-// nsIDOMNode child = childen.item(i);
-// if (VpeVisualDomBuilder.isPseudoElement(child) || VpeVisualDomBuilder.isAnonElement(child)) {
-// continue;
-// }
-// Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
-// int fromTop = y - rect.y;
-// int fromBottom = y - rect.y - rect.height;
-//
-// int yDistance;
-// if (fromTop > 0 && fromBottom < 0) {
-// yDistance = 0;
-// } else {
-// yDistance = Math.min(Math.abs(fromTop), Math.abs(fromBottom));
-// }
-//
-// if (yDistance <= closestYDistance && rect.width > 0 && rect.height > 0) {
-// if (yDistance < closestYDistance) {
-// closestXDistance = HUGE_DISTANCE;
-// }
-// int fromLeft = x - rect.x;
-// int fromRight = x - rect.x - rect.width;
-//
-// int xDistance;
-// if (fromLeft > 0 && fromRight < 0) {
-// xDistance = 0;
-// } else {
-// xDistance = Math.min(Math.abs(fromLeft), Math.abs(fromRight));
-// }
-// if (xDistance == 0 && yDistance == 0) {
-// closestNode = child;
-// break;
-// }
-// if (xDistance < closestXDistance || (xDistance == closestXDistance && rect.x <= x)) {
-// closestXDistance = xDistance;
-// closestYDistance = yDistance;
-// closestNode = child;
-// }
-// }
-// }
-// return closestNode;
-// }
-
-// this method is never used
-// public VpeSourceDropInfo canExternalDropMacro(XModelObject object, Node parentNode, int offset) {
-// String tagname = vpeController.getTagName(object);
-// Node sourceDragNode = ((Document) vpeController.getModel().getAdapter(Document.class))
-// .createElement(tagname);
-// return vpeController.getVisualBuilder().getSourceDropInfo(sourceDragNode, parentNode,
-// offset, false);
-// }
-
-// this method is never used
-// public void _dragOver(nsIDOMEvent event) {
-// if (!vpeController.getSwitcher()
-// .startActiveEditor(VpeController.ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
-// return;
-// }
-// try {
-// if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
-// System.out.println("<<<<<<<<<<<<<<<<<<<< dragOver"); //$NON-NLS-1$
-// }
-// // browser.computeDropPosition(event);
-// boolean canDrop = !vpeController.getXulRunnerEditor().isMozillaDragFlavor();
-// if (canDrop) {
-// Clipboard clipboard = new Clipboard(Display.getCurrent());
-// canDrop = clipboard.getContents(ModelTransfer.getInstance()) != null;
-// }
-// if (canDrop) {
-// canDrop = VpeDndUtil.isDropEnabled((IModelObjectEditorInput)
-// vpeController.getSourceEditor().getEditorInput());
-// }
-// if (canDrop) {
-// VpeVisualCaretInfo caretInfo = vpeController.getSelectionBuilder()
-// .getVisualCaretInfo(event);
-// canDrop = caretInfo.exist();
-// if (canDrop) {
-// caretInfo.showCaret();
-// } else {
-// caretInfo.hideCaret();
-// }
-// }
-// if (!canDrop) {
-// event.stopPropagation();
-// event.preventDefault();
-// }
-// } finally {
-// vpeController.getSwitcher().stopActiveEditor();
-// }
-// }
}
14 years, 8 months
JBoss Tools SVN: r21574 - in trunk/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/dnd and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2010-04-21 05:10:45 -0400 (Wed, 21 Apr 2010)
New Revision: 21574
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnDHelper.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualCaretInfo.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5042
Enhance DnD support in VPE
- Highlighting of drop container has been added.
- Drop algorithm has been rewritten.
- Code has been refactored.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2010-04-21 09:10:45 UTC (rev 21574)
@@ -26,7 +26,6 @@
org.jboss.tools.vpe.editor.selection,
org.jboss.tools.vpe.editor.template,
org.jboss.tools.vpe.editor.template.custom,
- org.jboss.tools.vpe.editor.template.dnd,
org.jboss.tools.vpe.editor.template.expression,
org.jboss.tools.vpe.editor.template.resize,
org.jboss.tools.vpe.editor.template.textformating,
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -27,6 +27,7 @@
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNSDocument;
+import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDragService;
import org.mozilla.interfaces.nsIDragSession;
import org.mozilla.interfaces.nsIServiceManager;
@@ -234,10 +235,13 @@
}
}
- public static nsIDOMElement getElementFromPoint(nsIDOMNSDocument document,
- int x, int y) {
- nsIDOMElement element = document.elementFromPoint(x, y);
+ public static nsIDOMElement getElementFromPoint(nsIDOMDocument document,
+ int clientX, int clientY) {
+ nsIDOMNSDocument nsDocument = (nsIDOMNSDocument) document
+ .queryInterface(nsIDOMNSDocument.NS_IDOMNSDOCUMENT_IID);
+ nsIDOMElement element = nsDocument.elementFromPoint(clientX, clientY);
+
Stack<nsIDOMElement> hiddenElements = new Stack<nsIDOMElement>();
Stack<String> hiddenElementsStyles = new Stack<String>();
while (element != null && isTemporaryDndElement(element)) {
@@ -245,7 +249,7 @@
hiddenElementsStyles.push(element.getAttribute(HTML.ATTR_STYLE));
element.setAttribute(HTML.ATTR_STYLE, "display:none !important;");
- element = document.elementFromPoint(x, y);
+ element = nsDocument.elementFromPoint(clientX, clientY);
}
while (!hiddenElements.empty()) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -31,11 +31,11 @@
public class DropableArea {
private boolean visible;
private EnumSet<DropTarget> dropTargets;
- private final nsIDOMDocument document;
+ private nsIDOMDocument document;
private nsIDOMNode node;
private nsIDOMElement domArea;
private static final String AREA_COLOR = "rgba(166, 202, 240, 0.5)"; //$NON-NLS-1$
- private DropTarget hightlightedDropTarget;
+ private DropTarget highlightedDropTarget;
/**
*
@@ -51,6 +51,9 @@
public void setNode(nsIDOMNode node) {
this.node = node;
}
+ public nsIDOMNode getNode() {
+ return node;
+ }
/**
* @param dropTargets cannot be null
@@ -63,37 +66,37 @@
this.visible = visible;
}
- public void setHighlightedSpot(int mouseX, int mouseY) {
- this.hightlightedDropTarget = getHighlightedDropTarget(mouseX, mouseY);
- }
-
- public DropTarget getHighlightedDropTarget(int mouseX, int mouseY) {
+ public void setHighlightedDropTarget(int mouseX, int mouseY) {
if (node == null) {
- return null;
+ highlightedDropTarget = null;
}
Rectangle bounds = XulRunnerVpeUtils.getElementBounds(node);
if (dropTargets.contains(DropTarget.BEFORE)
&& bounds.x <= mouseX
&& mouseX < bounds.x + bounds.width / 5) {
- return DropTarget.BEFORE;
+ highlightedDropTarget = DropTarget.BEFORE;
} else if (dropTargets.contains(DropTarget.AFTER)
&& bounds.x + bounds.width * 4 / 5 <= mouseX
&& mouseX < bounds.x + bounds.width) {
- return DropTarget.AFTER;
+ highlightedDropTarget = DropTarget.AFTER;
} else if (dropTargets.contains(DropTarget.BEGIN)
&& bounds.y <= mouseY
&& mouseY < bounds.y + bounds.height / 5) {
- return DropTarget.BEGIN;
+ highlightedDropTarget = DropTarget.BEGIN;
} else if (dropTargets.contains(DropTarget.END)
&& bounds.y + bounds.height * 4 / 5 <= mouseY
&& mouseY < bounds.y + bounds.height) {
- return DropTarget.END;
+ highlightedDropTarget = DropTarget.END;
} else {
- return null;
+ highlightedDropTarget = null;
}
}
-
+
+ public DropTarget getHighlightedDropTarget() {
+ return highlightedDropTarget;
+ }
+
public void redraw() {
if (!visible || node == null) {
if (domArea != null) {
@@ -156,15 +159,24 @@
contentArea.removeChild(oldDomArea);
}
}
-
+
+ public void dispose() {
+ setVisible(false);
+ redraw();
+
+ document = null;
+ node = null;
+ domArea = null;
+ }
+
private String getColor(DropTarget dropTarget) {
- if (dropTarget == hightlightedDropTarget) {
+ if (dropTarget == highlightedDropTarget) {
return "red";
} else {
return "black";
}
}
-
+
private nsIDOMElement createRect(Rectangle coords, String color) {
nsIDOMElement rect = createElement(HTML.TAG_DIV);
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-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -11,62 +11,45 @@
******************************************************************************/
package org.jboss.tools.vpe.dnd;
+import java.util.EnumSet;
+
import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xml.core.internal.document.NodeImpl;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
-import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
-import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
-import org.jboss.tools.common.model.ui.editors.dnd.DropData;
import org.jboss.tools.common.model.ui.editors.dnd.DropUtils;
-import org.jboss.tools.common.model.ui.editors.dnd.IDropCommand;
+import org.jboss.tools.common.model.ui.editors.dnd.context.IDNDTextEditor;
import org.jboss.tools.common.model.ui.editors.dnd.context.InnerDragBuffer;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
-import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPTagProposalFactory;
-import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
import org.jboss.tools.jst.web.tld.model.TLDUtil;
import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.dnd.DndUtil.DragTransferData;
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.editor.VpeSourceDropInfo;
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
-import org.jboss.tools.vpe.editor.VpeVisualCaretInfo;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
-import org.jboss.tools.vpe.editor.VpeVisualDropInfo;
import org.jboss.tools.vpe.editor.VpeVisualInnerDragInfo;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaDndListener;
-import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
-import org.jboss.tools.vpe.editor.template.VpePseudoContentCreator;
-import org.jboss.tools.vpe.editor.util.HTML;
-import org.jboss.tools.vpe.editor.util.TextUtil;
-import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.editor.util.VpeDndUtil;
import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
-import org.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
import org.mozilla.interfaces.nsIComponentManager;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMEvent;
-import org.mozilla.interfaces.nsIDOMEventTarget;
import org.mozilla.interfaces.nsIDOMMouseEvent;
-import org.mozilla.interfaces.nsIDOMNSDocument;
import org.mozilla.interfaces.nsIDOMNSUIEvent;
import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDragService;
import org.mozilla.interfaces.nsIFile;
-import org.mozilla.interfaces.nsISelectionController;
import org.mozilla.interfaces.nsIServiceManager;
import org.mozilla.interfaces.nsISupports;
import org.mozilla.interfaces.nsISupportsArray;
@@ -74,20 +57,20 @@
import org.mozilla.interfaces.nsISupportsString;
import org.mozilla.interfaces.nsITransferable;
import org.mozilla.xpcom.Mozilla;
-import org.mozilla.xpcom.XPCOMException;
-import org.w3c.dom.Attr;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
+ * Class responsible for Drag&Drop functionality
+ *
* @author Max Areshkau
* @author Yahor Radtsevich (yradtsevich)
- *
- * Class responsible for Drag&Drop functionality
*/
+// TODO: cleanup the code
public class VpeDnD implements MozillaDndListener {
+ private static final String TAG_TAGLIB = "taglib"; //$NON-NLS-1$
+
private static int HUGE_DISTANCE = 999999;
/*
@@ -110,8 +93,10 @@
private nsIDragService dragService;
private VpeController vpeController;
- private VpeVisualInnerDragInfo innerDragInfo = null;
+
+ private VpeSourceInnerDragInfo sourceInnerDragInfo = null;
private DraggablePattern draggablePattern;
+ private DropableArea dropableArea;
public VpeDnD(VpeController vpeController, MozillaEditor mozillaEditor) {
this.vpeController = vpeController;
@@ -123,9 +108,10 @@
.getLastSelectedElement();
// start drag sessionvpe-element
if (isDraggable(selectedElement)) {
- Point mousePosition = getMousePosition(domEvent);
- draggablePattern.startSession(mousePosition.x, mousePosition.y);
+ Point pageCoords = getPageCoords(domEvent);
+ draggablePattern.startSession(pageCoords.x, pageCoords.y);
startDragSession(selectedElement);
+
draggablePattern.closeSession();
domEvent.stopPropagation();
domEvent.preventDefault();
@@ -139,16 +125,24 @@
public void dragOver(nsIDOMEvent event) {
final nsIDOMMouseEvent mouseEvent =
(nsIDOMMouseEvent) event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+
+ final XulRunnerEditor editor = vpeController.getXulRunnerEditor();
+ new ScrollingSupport(editor).scroll(mouseEvent);
+
+ final DropResolver dropResolver;
if (isInnerDragSession()) {
- Point mousePosition = getMousePosition(event);
+ dropResolver = getDropResolverForInternalDrop();
+
+ Point mousePosition = getPageCoords(event);
draggablePattern.moveTo(mousePosition.x, mousePosition.y);
+ } else {
+ dropResolver = getDropResolverForExternalDrop();
}
- final XulRunnerEditor editor = vpeController.getXulRunnerEditor();
- new ScrollingSupport(editor).scroll(mouseEvent);
+ highlightDropTargets(dropResolver, mouseEvent);
refreshCanDrop(event);
vpeController.onRefresh();
}
-
+
/**
* Drop Event handler
* @param domEvent
@@ -163,9 +157,19 @@
//in this case it's is external drag
externalDrop((nsIDOMMouseEvent)domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID), VpeController.MODEL_FLAVOR, ""); //$NON-NLS-1$
}
+ disposeDropableArea();
vpeController.onRefresh();
}
-
+
+ public void dragExit(nsIDOMEvent domEvent) {
+// disposeDropableArea();
+ nsIDOMNode visualNode = (nsIDOMNode) domEvent.getTarget()
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+ if (visualNode.getNodeType()==nsIDOMNode.DOCUMENT_NODE) {
+ disposeDropableArea();
+ }
+ }
+
public void selectionChanged() {
nsIDOMElement selectedElement = vpeController.getXulRunnerEditor()
.getLastSelectedElement();
@@ -180,6 +184,135 @@
return draggablePattern.isDragIconClicked(mouseEvent);
}
+ private DropResolver getDropResolverForExternalDrop() {
+ if (getDragService().getCurrentSession()
+ .isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
+ XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+ .getModelBuffer().source();
+ if (object.getFileType() == XModelObject.FILE
+ && !TLDUtil.isTaglib(object)) {
+ final IFile f = (IFile) EclipseResourceUtil.getResource(object);
+ return getSimpleDropResolver(f != null);
+ } else {
+ String tagname = vpeController.getTagName(object);
+ if (tagname.indexOf(TAG_TAGLIB) >= 0) {
+ tagname = TAG_TAGLIB;
+ }
+ Node dropContainer = ((Document) vpeController.getModel()
+ .getAdapter(Document.class)).createElement(tagname);
+
+ return getDropResolverForNode(dropContainer);
+ }
+ } else {
+ return getSimpleDropResolver(true);
+ }
+ }
+
+ private DropResolver getDropResolverForInternalDrop() {
+ return getDropResolverForNode(sourceInnerDragInfo.getNode());
+ }
+
+ private DropResolver getSimpleDropResolver(final boolean canDrop) {
+ return new DropResolver() {
+ public boolean canDrop(Node node) {
+ return canDrop;
+ }
+ };
+ }
+
+ private DropResolver getDropResolverForNode(final Node draggedNode) {
+ return new DropResolver() {
+ public boolean canDrop(Node container) {
+ VpeNodeMapping nodeMapping = vpeController.getDomMapping()
+ .getNodeMapping(container);
+
+ boolean canDrop = false;
+ if (nodeMapping != null && nodeMapping instanceof VpeElementMapping) {
+ canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
+ .canInnerDrop(vpeController.getPageContext(),
+ container, draggedNode);
+ }
+
+ return canDrop;
+ }
+ };
+ }
+
+ private void highlightDropTargets(DropResolver dropResolver, nsIDOMMouseEvent event) {
+ nsIDOMDocument document = vpeController.getVisualBuilder()
+ .getOriginalTargetNode(event).getOwnerDocument();
+
+ Point clientCoords = getClientCoords(event);
+
+ nsIDOMNode originalVisualNode = DndUtil.getElementFromPoint(document,
+ clientCoords.x, clientCoords.y);
+ if (originalVisualNode == null) {
+ return;
+ }
+
+ if (dropableArea == null) {
+ dropableArea = new DropableArea(document);
+ }
+ Node originalSourceNode = vpeController.getDomMapping()
+ .getNearSourceNode(originalVisualNode);
+ if (originalSourceNode.getNodeType() == Node.TEXT_NODE) {
+ originalSourceNode = originalSourceNode.getParentNode();
+ }
+
+ final Node highlightedNode;
+ final EnumSet<DropTarget> dropTargets;
+ if (dropResolver.canDrop(originalSourceNode)) {
+ highlightedNode = originalSourceNode;
+
+ Node originalSourceNodeParent = originalSourceNode.getParentNode();
+ if (originalSourceNodeParent != null
+ && dropResolver.canDrop(originalSourceNodeParent)) {
+ dropTargets = EnumSet.of(DropTarget.BEFORE, DropTarget.AFTER,
+ DropTarget.BEGIN, DropTarget.END);
+ } else {
+ dropTargets = EnumSet.of(DropTarget.BEGIN, DropTarget.END);
+ }
+ } else {
+ Node sourceNode;
+ Node sourceNodeParent = originalSourceNode;
+ boolean nodeFound = false;
+ do {
+ sourceNode = sourceNodeParent;
+ sourceNodeParent = sourceNode.getParentNode();
+ nodeFound = dropResolver.canDrop(sourceNodeParent);
+ } while (sourceNodeParent != null && !nodeFound);
+
+ if (nodeFound) {
+ highlightedNode = sourceNode;
+ dropTargets = EnumSet.of(DropTarget.BEFORE, DropTarget.AFTER);
+ } else {
+ highlightedNode = null;
+ dropTargets = EnumSet.noneOf(DropTarget.class);
+ }
+ }
+
+ dropableArea.setDropTargets(dropTargets);
+ dropableArea.setNode(
+ vpeController.getDomMapping().getNearVisualNode(highlightedNode));
+ Point mouseCoords = getPageCoords(event);
+ dropableArea.setHighlightedDropTarget(mouseCoords.x, mouseCoords.y);
+ dropableArea.setVisible(true);
+ dropableArea.redraw();
+ }
+
+ private Point getClientCoords(nsIDOMEvent event) {
+ final nsIDOMMouseEvent mouseEvent =
+ (nsIDOMMouseEvent) event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ return new Point(mouseEvent.getClientX(), mouseEvent.getClientY());
+ }
+
+ private void disposeDropableArea() {
+ if (dropableArea != null) {
+ dropableArea.dispose();
+ dropableArea = null;
+ }
+ }
+
/**
* Starts drag session
* @param dragetElement
@@ -224,76 +357,83 @@
}
private void refreshCanDrop(nsIDOMEvent event) {
- boolean canDrop = true;
nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- //in this condition early was check for xulelement
- if (getDragService().getCurrentSession().isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
- MozillaDropInfo info;
-
- if(isInnerDragSession()){
- info = canInnerDrop(mouseEvent);
- } else {
- info = canExternalDrop(mouseEvent, VpeController.MODEL_FLAVOR, ""); //$NON-NLS-1$
- }
- if (info != null) {
- canDrop = info.canDrop();
- }
- }
- //sets possability to drop current element here
- //Added by estherbin fix jbide-1046
- VpeSelectionController selectionController = vpeController.getVisualSelectionController();
- final VpeVisualCaretInfo visualCaretInfo = vpeController.getSelectionBuilder().getVisualCaretInfo(event);
-
- final nsIDOMEventTarget target = event.getTarget();
- final nsIDOMNode targetDomNode = (nsIDOMNode) target.queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
-// final nsIDOMNode selectedVisualNode = controller.getXulRunnerEditor().getLastSelectedNode();
- try {
- if ((targetDomNode.getFirstChild() != null) && (targetDomNode.getFirstChild().getNodeType() == nsIDOMNode.TEXT_NODE)) {
- selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).collapse(targetDomNode.getFirstChild(),
- visualCaretInfo.getRageOffset());
- } else if ((targetDomNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
- selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).collapse(targetDomNode, 0);
- }
- } catch (XPCOMException xpcome) {
- event.stopPropagation();
- event.preventDefault();
- }
-
- //sets possability to drop current element here
- getDragService().getCurrentSession().setCanDrop(canDrop);
+ getDragService().getCurrentSession().setCanDrop(dropableArea != null
+ && dropableArea.getHighlightedDropTarget() != null);
mouseEvent.preventDefault();
mouseEvent.stopPropagation();
+
+// boolean canDrop = true;
+// //in this condition early was check for xulelement
+// if (getDragService().getCurrentSession().isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
+// MozillaDropInfo info;
+//
+// if(isInnerDragSession()){
+// info = canInnerDrop(mouseEvent);
+// } else {
+// info = canExternalDrop(mouseEvent, VpeController.MODEL_FLAVOR, ""); //$NON-NLS-1$
+// }
+// if (info != null) {
+// canDrop = info.canDrop();
+// }
+// }
+// //sets possability to drop current element here
+// //Added by estherbin fix jbide-1046
+// VpeSelectionController selectionController = vpeController.getVisualSelectionController();
+// final VpeVisualCaretInfo visualCaretInfo = vpeController.getSelectionBuilder().getVisualCaretInfo(event);
+//
+// final nsIDOMEventTarget target = event.getTarget();
+// final nsIDOMNode targetDomNode = (nsIDOMNode) target.queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+//// final nsIDOMNode selectedVisualNode = controller.getXulRunnerEditor().getLastSelectedNode();
+// try {
+// if ((targetDomNode.getFirstChild() != null) && (targetDomNode.getFirstChild().getNodeType() == nsIDOMNode.TEXT_NODE)) {
+// selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).collapse(targetDomNode.getFirstChild(),
+// visualCaretInfo.getRageOffset());
+// } else if ((targetDomNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
+// selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).collapse(targetDomNode, 0);
+// }
+// } catch (XPCOMException xpcome) {
+// event.stopPropagation();
+// event.preventDefault();
+// }
}
- private void externalDropAny(final String flavor, final String data, final Point range,
- Node container) {
- if (flavor == null || flavor.length() == 0)
+ private void externalDropAny(final String flavor, final String data,
+ final Point range) {
+ StructuredTextEditor sourceEditor = vpeController.getSourceEditor();
+ if (flavor == null || flavor.length() == 0
+ || !(sourceEditor instanceof IDNDTextEditor)) {
return;
- IDropCommand dropCommand = DropCommandFactory.getInstance()
- .getDropCommand(flavor, JSPTagProposalFactory.getInstance());
-
- boolean promptAttributes = JspEditorPlugin.getDefault()
- .getPreferenceStore().getBoolean(
- IVpePreferencesPage.ASK_TAG_ATTRIBUTES_ON_TAG_INSERT);
- dropCommand.getDefaultModel().setPromptForTagAttributesRequired(
- promptAttributes);
- DropData dropData = new DropData(flavor, data,
- vpeController.getSourceEditor().getEditorInput(),
- (ISourceViewer) vpeController.getSourceEditor().getAdapter(ISourceViewer.class),
- vpeController.new VpeSelectionProvider(range.x, range.y),
- container);
-
- /*
- * https://jira.jboss.org/jira/browse/JBIDE-4982 Setting the value
- * provider to create tag insert dialog.
- */
- if (vpeController.getSourceEditor() instanceof JSPTextEditor) {
- dropData.setValueProvider(((JSPTextEditor) vpeController.getSourceEditor())
- .createAttributeDescriptorValueProvider());
}
-
- dropCommand.execute(dropData);
+
+ //vpeController.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(range.x);
+ sourceEditor.setHighlightRange(range.x, range.y, true);
+ ((IDNDTextEditor) sourceEditor).runDropCommand(flavor, data);
+// IDropCommand dropCommand = DropCommandFactory.getInstance()
+// .getDropCommand(flavor, JSPTagProposalFactory.getInstance());
+//
+// boolean promptAttributes = JspEditorPlugin.getDefault()
+// .getPreferenceStore().getBoolean(
+// IVpePreferencesPage.ASK_TAG_ATTRIBUTES_ON_TAG_INSERT);
+// dropCommand.getDefaultModel().setPromptForTagAttributesRequired(
+// promptAttributes);
+// DropData dropData = new DropData(flavor, data,
+// vpeController.getSourceEditor().getEditorInput(),
+// (ISourceViewer) vpeController.getSourceEditor().getAdapter(ISourceViewer.class),
+// vpeController.new VpeSelectionProvider(range.x, range.y),
+// container);
+//
+// /*
+// * https://jira.jboss.org/jira/browse/JBIDE-4982 Setting the value
+// * provider to create tag insert dialog.
+// */
+// if (vpeController.getSourceEditor() instanceof JSPTextEditor) {
+// dropData.setValueProvider(((JSPTextEditor) vpeController.getSourceEditor())
+// .createAttributeDescriptorValueProvider());
+// }
+//
+// dropCommand.execute(dropData);
}
private boolean isInnerDragSession() {
@@ -306,9 +446,8 @@
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out.print("<<<<<< canInnerDrag"); //$NON-NLS-1$
}
- if (innerDragInfo != null) {
- innerDragInfo.release();
- innerDragInfo = null;
+ if (sourceInnerDragInfo != null) {
+ sourceInnerDragInfo = null;
}
boolean canDrag = false;
VpeVisualInnerDragInfo dragInfo = getInnerDragInfo(element);
@@ -325,15 +464,15 @@
break;
}
case nsIDOMNode.TEXT_NODE: {
- canDrag = vpeController.getVisualBuilder().isTextEditable(dragNode);
+ vpeController.getVisualBuilder();
+ canDrag = VpeVisualDomBuilder.isTextEditable(dragNode);
break;
}
}
if (canDrag) {
- VpeSourceInnerDragInfo sourceInnerDragInfo = vpeController.getVisualBuilder()
+ sourceInnerDragInfo = vpeController.getVisualBuilder()
.getSourceInnerDragInfo(dragInfo);
if (sourceInnerDragInfo.getNode() != null) {
- innerDragInfo = dragInfo;
InnerDragBuffer.object = sourceInnerDragInfo.getNode();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
@@ -341,6 +480,7 @@
}
});
} else {
+ sourceInnerDragInfo = null;
canDrag = false;
}
}
@@ -354,115 +494,104 @@
return canDrag;
}
- private MozillaDropInfo canInnerDrop(nsIDOMMouseEvent event) {
- vpeController.onHideTooltip();
+// this method is never used
+// private MozillaDropInfo canInnerDrop(nsIDOMMouseEvent event) {
+// vpeController.onHideTooltip();
+//
+// if (vpeController.getDropWindow().isActive()) {
+// if (!event.getAltKey()) {
+// vpeController.getDropWindow().close();
+// } else {
+// return null;
+// }
+// }
+// if (event.getAltKey()) {
+// nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
+// Node sourceNode = vpeController.getDomMapping().getNearSourceNode(visualNode);
+// if (sourceNode != null) {
+// vpeController.getDropWindow().setActive(true);
+// vpeController.getDropWindow().setEventPosition(event.getScreenX(), event
+// .getScreenY());
+// vpeController.getDropWindow().setInitialTargetNode(sourceNode);
+// vpeController.getDropWindow().open();
+// event.stopPropagation();
+// event.preventDefault();
+// return null;
+// }
+// }
+// if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+// System.out.print("<<<<<< canInnerDrop"); //$NON-NLS-1$
+// }
+// boolean canDrop = false;
+//
+// nsIDOMNode caretParent = null;
+// long caretOffset = 0;
+// if (sourceInnerDragInfo != null) {
+// VpeVisualDropInfo visualDropInfo = getDropInfo(event);
+// if (visualDropInfo.getDropContainer() != null) {
+// if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+// System.out.print(" container: " //$NON-NLS-1$
+// + visualDropInfo.getDropContainer().getNodeName()
+// + "(" //$NON-NLS-1$
+// + visualDropInfo.getDropContainer()
+// + ") parent: " //$NON-NLS-1$
+// + visualDropInfo.getDropContainer().getParentNode()
+// .getNodeName()
+// + "(" //$NON-NLS-1$
+// + visualDropInfo.getDropContainer().getParentNode()
+// + ") offset: " //$NON-NLS-1$
+// + visualDropInfo.getDropOffset());
+// }
+// VpeSourceDropInfo sourceDropInfo
+// = getSourceDropInfo(sourceInnerDragInfo.getNode(),
+// visualDropInfo, true);
+// canDrop = sourceDropInfo.canDrop();
+// if (canDrop) {
+// VpeVisualDropInfo newVisualDropInfo
+// = getDropInfo(sourceDropInfo.getContainer(),
+// sourceDropInfo.getOffset());
+// if (newVisualDropInfo != null) {
+// correctVisualDropPosition(event,
+// newVisualDropInfo, visualDropInfo);
+// caretParent = newVisualDropInfo.getDropContainer();
+// caretOffset = newVisualDropInfo.getDropOffset();
+// }
+// }
+// }
+// visualDropInfo.release();
+// }
+// if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+// System.out.println(" canDrop: " + canDrop); //$NON-NLS-1$
+// }
+// return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+// }
- if (vpeController.getDropWindow().isActive()) {
- if (!event.getAltKey()) {
- vpeController.getDropWindow().close();
- } else {
- return null;
- }
- }
- if (event.getAltKey()) {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
- Node sourceNode = vpeController.getDomMapping().getNearSourceNode(visualNode);
- if (sourceNode != null) {
- vpeController.getDropWindow().setActive(true);
- vpeController.getDropWindow().setEventPosition(event.getScreenX(), event
- .getScreenY());
- vpeController.getDropWindow().setInitialTargetNode(sourceNode);
- vpeController.getDropWindow().open();
- event.stopPropagation();
- event.preventDefault();
- return null;
- }
- }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print("<<<<<< canInnerDrop"); //$NON-NLS-1$
- }
- boolean canDrop = false;
-
- nsIDOMNode caretParent = null;
- long caretOffset = 0;
- if (innerDragInfo != null) {
- VpeVisualDropInfo visualDropInfo = getDropInfo(event);
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print(" container: " //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getNodeName()
- + "(" //$NON-NLS-1$
- + visualDropInfo.getDropContainer()
- + ") parent: " //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getParentNode()
- .getNodeName()
- + "(" //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getParentNode()
- + ") offset: " //$NON-NLS-1$
- + visualDropInfo.getDropOffset());
- }
- VpeSourceInnerDragInfo sourceInnerDragInfo = vpeController.getVisualBuilder()
- .getSourceInnerDragInfo(innerDragInfo);
- VpeSourceDropInfo sourceDropInfo
- = getSourceDropInfo(sourceInnerDragInfo.getNode(),
- visualDropInfo, true);
- canDrop = sourceDropInfo.canDrop();
- if (canDrop) {
- VpeVisualDropInfo newVisualDropInfo
- = getDropInfo(sourceDropInfo.getContainer(),
- sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- correctVisualDropPosition(event,
- newVisualDropInfo, visualDropInfo);
- caretParent = newVisualDropInfo.getDropContainer();
- caretOffset = newVisualDropInfo.getDropOffset();
- }
- }
- }
- visualDropInfo.release();
- }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrop: " + canDrop); //$NON-NLS-1$
- }
- return new MozillaDropInfo(canDrop, caretParent, caretOffset);
- }
-
private void innerDrop(nsIDOMMouseEvent event) {
vpeController.onHideTooltip();
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out.print("<<<<<< innerDrop"); //$NON-NLS-1$
}
- if (innerDragInfo != null) {
- VpeVisualDropInfo visualDropInfo = getDropInfo(event);
- if (visualDropInfo.getDropContainer() != null) {
+ if (sourceInnerDragInfo != null) {
+ VpeSourceDropInfo sourceDropInfo = getDropInfo(event);
+ if (sourceDropInfo.getContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out
- .print(" container: " + visualDropInfo.getDropContainer().getNodeName() + //$NON-NLS-1$
- "(" + visualDropInfo.getDropContainer() //$NON-NLS-1$
+ .print(" container: " + sourceDropInfo.getContainer().getNodeName() + //$NON-NLS-1$
+ "(" + sourceDropInfo.getContainer() //$NON-NLS-1$
+ ")" + //$NON-NLS-1$
" offset: " //$NON-NLS-1$
- + visualDropInfo.getDropOffset());
+ + sourceDropInfo.getOffset());
}
-
- VpeSourceInnerDragInfo sourceInnerDragInfo = vpeController.getVisualBuilder()
- .getSourceInnerDragInfo(innerDragInfo);
- VpeSourceDropInfo sourceDropInfo
- = getSourceDropInfo(sourceInnerDragInfo.getNode(),
- visualDropInfo, true);
+
if (sourceDropInfo.canDrop()) {
- VpeVisualDropInfo newVisualDropInfo
- = getDropInfo(sourceDropInfo.getContainer(),
- sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- correctVisualDropPosition(event,
- newVisualDropInfo, visualDropInfo);
- vpeController.getVisualBuilder().innerDrop(sourceInnerDragInfo,
- sourceDropInfo);
- if (innerDragInfo != null) {
- innerDragInfo.release();
- innerDragInfo = null;
- }
+ VpeDnDHelper dropper = new VpeDnDHelper();
+ dropper.setDndData(false, true);
+ dropper.drop(vpeController.getPageContext(),
+ sourceInnerDragInfo, sourceDropInfo);
+
+ if (sourceInnerDragInfo != null) {
+ sourceInnerDragInfo = null;
}
}
}
@@ -471,185 +600,13 @@
System.out.println();
}
}
-
- private void correctVisualDropPosition(nsIDOMMouseEvent mouseEvent,
- VpeVisualDropInfo newVisualDropInfo,
- VpeVisualDropInfo oldVisualDropInfo) {
- nsIDOMNode newVisualDropContainer = newVisualDropInfo
- .getDropContainer();
- nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
- .getDropContainer();
- if (newVisualDropContainer.equals(oldVisualDropContainer)) {
- newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
- return;
- }
-
- nsIDOMNode child = oldVisualDropContainer;
- while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
- nsIDOMNode parent = child.getParentNode();
- if (newVisualDropContainer.equals(parent)) {
- long offset = VisualDomUtil.getOffset(child);
- Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
-
- nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
- mouseEvent.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
- int mouseX = nsuiEvent.getPageX();
- int mouseY = nsuiEvent.getPageY();
-
- if (canInsertAfter(mouseX, mouseY, rect)) {
- offset++;
- }
- newVisualDropInfo.setDropOffset(offset);
- }
- child = parent;
- }
- }
-
- private VpeSourceDropInfo getSourceDropInfo(Node sourceDragNode,
- VpeVisualDropInfo visualDropInfo, boolean checkParentTemplates) {
- nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
- long visualDropOffset = visualDropInfo.getDropOffset();
- Node sourceDropContainer = null;
- int sourceDropOffset = 0;
-
- switch (visualDropContainer.getNodeType()) {
- case nsIDOMNode.ELEMENT_NODE:
- nsIDOMNode visualOffsetNode = null;
- boolean afterFlag = false;
- long visualChildCount = VisualDomUtil
- .getChildCount(visualDropContainer);
- if (visualDropOffset < visualChildCount) {
- visualOffsetNode = VisualDomUtil.getChildNode(
- visualDropContainer, visualDropOffset);
- if (VpeVisualDomBuilder.isPseudoElement(visualOffsetNode)
- || VpeVisualDomBuilder.isAnonElement(visualOffsetNode)) {
- visualOffsetNode = VpeVisualDomBuilder
- .getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = true;
- }
- } else {
- visualOffsetNode = VpeVisualDomBuilder.getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = visualChildCount != 0;
- }
- if (visualOffsetNode != null) {
- Node sourceOffsetNode = vpeController.getDomMapping()
- .getSourceNode(visualOffsetNode);
- if (sourceOffsetNode != null) {
- sourceDropContainer = sourceOffsetNode.getParentNode();
- sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
- if (afterFlag) {
- sourceDropOffset++;
- }
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = vpeController.getDomMapping()
- .getNearSourceNode(visualDropContainer);
- if (sourceDropContainer != null) {
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = vpeController.getDomMapping()
- .getNearSourceNode(
- vpeController.getVisualBuilder().getContentArea());
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- break;
- case nsIDOMNode.TEXT_NODE:
- VpeNodeMapping nodeMapping = vpeController.getDomMapping()
- .getNearNodeMapping(visualDropContainer);
- // switch (nodeMapping.getType()) {
- // case VpeNodeMapping.TEXT_MAPPING:
- sourceDropContainer = nodeMapping.getSourceNode();
- sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer
- .getNodeValue(), visualDropOffset);
- // break;
- // case VpeNodeMapping.ELEMENT_MAPPING:
- // it's attribute
- if (VpeVisualDomBuilder.isTextEditable(visualDropContainer)) {
- String[] atributeNames = ((VpeElementMapping) nodeMapping)
- .getTemplate().getOutputAttributeNames();
- if (atributeNames != null && atributeNames.length > 0) {
- Element sourceElement = (Element) nodeMapping
- .getSourceNode();
- sourceDropContainer = sourceElement
- .getAttributeNode(atributeNames[0]);
- sourceDropOffset = TextUtil.sourceInnerPosition(
- sourceDropContainer.getNodeValue(),
- visualDropOffset);
- }
- }
- nodeMapping.getVisualNode();
- // }
- // break;
- }
- if (sourceDropContainer != null) {
- return getSourceDropInfo(sourceDragNode, sourceDropContainer,
- sourceDropOffset, checkParentTemplates);
- } else {
- return new VpeSourceDropInfo(null, 0, false);
- }
- }
-
- private VpeSourceDropInfo getSourceDropInfo(Node dragNode,
- Node container, int offset, boolean checkParentsTemplates) {
- // Thread.dumpStack();
- boolean canDrop = false;
- switch (container.getNodeType()) {
- case Node.ELEMENT_NODE:
- VpeNodeMapping nodeMapping = vpeController.getDomMapping()
- .getNodeMapping(container);
- if (nodeMapping != null && nodeMapping instanceof VpeElementMapping) {
- canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
- .canInnerDrop(vpeController.getPageContext(), container, dragNode);
- }
- if (!canDrop) {
- if (!checkParentsTemplates)
- return new VpeSourceDropInfo(container, offset,
- canDrop);
- // offset = ((NodeImpl)container).getIndex();
- // container = container.getParentNode();
- // TODO Max Areshkau unclear logic , if we can drop on element
- // why we trying to drop
- // this on parent
- // return getSourceDropInfo(dragNode, container, offset,
- // false);
- return new VpeSourceDropInfo(container, offset, canDrop);
- }
- break;
- case Node.TEXT_NODE:
- case Node.DOCUMENT_NODE:
- canDrop = true;
- break;
- case Node.ATTRIBUTE_NODE:
- canDrop = true;
- break;
- }
- if (canDrop) {
- return new VpeSourceDropInfo(container, offset, canDrop);
- } else {
- return new VpeSourceDropInfo(null, 0, canDrop);
- }
- }
-
- private boolean canInsertAfter(int x, int y, Rectangle rect) {
- if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
- return true;
- }
- return y >= rect.x && x > (rect.x + rect.width / 2);
- }
-
private void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
vpeController.onHideTooltip();
- VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
- Point range = vpeController.getSelectionBuilder().getSourceSelectionRangeAtVisualNode(
- visualDropInfo.getDropContainer(), (int) visualDropInfo
- .getDropOffset());
+ VpeSourceDropInfo dropInfo = getDropInfo(mouseEvent);
+ Point range = getSourceSelectionRange(
+ dropInfo.getContainer(), dropInfo.getOffset());
// if (MODEL_FLAVOR.equals(flavor)) {
// XModelObject object = PreferenceModelUtilities.getPreferenceModel()
@@ -708,12 +665,13 @@
// }
// }
- if (visualDropInfo.getDropContainer() != null && data != null) {
+ if (dropInfo.getContainer() != null && data != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out
- .println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ .println(" drop! container: " + dropInfo.getContainer().getNodeName()); //$NON-NLS-1$
}
- externalDropAny(aFlavor, data, range, null);
+
+ externalDropAny(aFlavor, data, range);
// TypedEvent tEvent = new TypedEvent(mouseEvent);
// tEvent.data = data;
@@ -722,106 +680,44 @@
// DnDUtil.fireDnDEvent(dropContext, textEditor, tEvent);
}
}
-
- private MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
- InnerDragBuffer.object = null;
- vpeController.onHideTooltip();
-
- if (vpeController.getDropWindow().isActive()) {
- if (!mouseEvent.getAltKey()) {
- vpeController.getDropWindow().close();
- } else {
- return new MozillaDropInfo(false, null, 0);
- }
- }
- if (mouseEvent.getAltKey()) {
- nsIDOMEvent event = (nsIDOMEvent) mouseEvent
- .queryInterface(nsIDOMEvent.NS_IDOMEVENT_IID);
- nsIDOMNode visualNode = (nsIDOMNode) event.getTarget()
- .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
- Node sourceNode = vpeController.getDomMapping().getNearSourceNode(visualNode);
- if (sourceNode != null) {
- if (ModelTransfer.MODEL.equals(flavor)) {
- // XModelObject object =
- // PreferenceModelUtilities.getPreferenceModel().
- // getModelBuffer().source();
- // InnerDragBuffer.object = object;
- } else {
- vpeController.getDropWindow().setFlavor(flavor);
+
+ private Point getSourceSelectionRange(Node sourceInitNode, int sourceInitOffset) {
+ int offset=0;
+ int position=0;
+ switch (sourceInitNode.getNodeType()) {
+ case Node.TEXT_NODE:
+ offset = Math.min(sourceInitOffset, sourceInitNode.getNodeValue().length());
+ position = vpeController.getSourceBuilder()
+ .getPosition(sourceInitNode, offset, false);
+ break;
+ case Node.ELEMENT_NODE:
+ case Node.DOCUMENT_NODE:
+ NodeList children = sourceInitNode.getChildNodes();
+ int count = children.getLength();
+ if (sourceInitOffset < count) {
+ // insert before the child with index sourceInitOffset
+ Node sourceNode = children.item(sourceInitOffset);
+ position = ((IndexedRegion)sourceNode).getStartOffset();
+ } else if (count > 0) {
+ // insert after the last child
+ Node sourceNode = children.item(count - 1);
+ position = ((IndexedRegion)sourceNode).getEndOffset();
+ } else { // if (count == 0)
+ // insert as a child
+ position = ((IndexedRegion)sourceInitNode).getStartOffset();
+ if (sourceInitNode instanceof ElementImpl) {
+ ElementImpl element = (ElementImpl)sourceInitNode;
+ if (element.isContainer()) {
+ position = element.getStartEndOffset();
+ }
}
- vpeController.getDropWindow().setActive(true);
- vpeController.getDropWindow().setEventPosition(mouseEvent.getScreenX(), mouseEvent
- .getScreenY());
- vpeController.getDropWindow().setInitialTargetNode(sourceNode);
- vpeController.getDropWindow().open();
- mouseEvent.stopPropagation();
- mouseEvent.preventDefault();
- return new MozillaDropInfo(false, null, 0);
}
+ break;
}
- boolean canDrop = false;
- nsIDOMNode caretParent = null;
- long caretOffset = 0;
-
- if (VpeController.MODEL_FLAVOR.equals(flavor)) {
- XModelObject object = PreferenceModelUtilities.getPreferenceModel()
- .getModelBuffer().source();
- if (object.getFileType() == XModelObject.FILE
- && !TLDUtil.isTaglib(object)) {
- IFile f = (IFile) EclipseResourceUtil.getResource(object);
- canDrop = f != null;
- VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
- caretParent = visualDropInfo.getDropContainer();
- caretOffset = visualDropInfo.getDropOffset();
- } else {
- String tagname = vpeController.getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document) vpeController.getModel().getAdapter(
- Document.class)).createElement(tagname);
- VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
- if (visualDropInfo.getDropContainer() != null) {
- VpeSourceDropInfo sourceDropInfo
- = getSourceDropInfo(
- sourceDragNode, visualDropInfo, true);
- canDrop = sourceDropInfo.canDrop();
- if (canDrop) {
- VpeVisualDropInfo newVisualDropInfo
- = getDropInfo(
- sourceDropInfo.getContainer(),
- sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- correctVisualDropPosition(mouseEvent,
- newVisualDropInfo, visualDropInfo);
- caretParent = newVisualDropInfo.getDropContainer();
- caretOffset = newVisualDropInfo.getDropOffset();
- }
- }
- }
- visualDropInfo.release();
- }
- } else if (XulRunnerEditor.TRANS_FLAVOR_kFileMime.equals(flavor)
- || XulRunnerEditor.TRANS_FLAVOR_kURLMime.equals(flavor)) {
- VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
- caretParent = visualDropInfo.getDropContainer();
- caretOffset = visualDropInfo.getDropOffset();
- canDrop = true;
-
- }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrop: " + canDrop //$NON-NLS-1$
- + (canDrop ?
- " container: " //$NON-NLS-1$
- + caretParent.getNodeName()
- + " offset: " //$NON-NLS-1$
- + caretOffset
- : "")); //$NON-NLS-1$
- }
- return new MozillaDropInfo(canDrop, caretParent, caretOffset);
-
+ return new Point(position, 0);
}
-
- private Point getMousePosition(nsIDOMEvent domEvent) {
+ private Point getPageCoords(nsIDOMEvent domEvent) {
nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
domEvent.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
return new Point(nsuiEvent.getPageX(), nsuiEvent.getPageY());
@@ -934,236 +830,545 @@
// return null;
}
- private VpeVisualDropInfo getDropInfo(nsIDOMEvent event) {
- nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
- event.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
- nsIDOMNode dropContainer = null;
+ private VpeSourceDropInfo getDropInfo(nsIDOMEvent event) {
+ Node dropContainer = null;
int dropOffset = 0;
- int mouseX = nsuiEvent.getPageX();
- int mouseY = nsuiEvent.getPageY();
-
- nsIDOMDocument document = vpeController.getVisualBuilder()
- .getOriginalTargetNode(event).getOwnerDocument();
-
- nsIDOMNSDocument nsDocument = (nsIDOMNSDocument) document
- .queryInterface(nsIDOMNSDocument.NS_IDOMNSDOCUMENT_IID);
- nsIDOMNode originalNode = DndUtil.getElementFromPoint(nsDocument, mouseX, mouseY);
-// if (originalNode != null) {
-// if (dropableArea == null) {
-// dropableArea = new DropableArea(document);
-// dropableArea.setDropSpots(EnumSet.allOf(DropSpot.class));
-// }
-// dropableArea.setNode(originalNode);
-// dropableArea.setHighlightedSpot(mouseX, mouseY);
-// dropableArea.setVisible(true);
-// dropableArea.redraw();
-// }
-
- if (originalNode == null || originalNode.getParentNode() == null ||
- originalNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
- return new VpeVisualDropInfo(null, 0);
- }
- if (originalNode.getNodeType() == Node.TEXT_NODE) {
- dropContainer = nsuiEvent.getRangeParent();
- nsIDOMNode containerForPseudoContent = VpePseudoContentCreator
- .getContainerForPseudoContent(dropContainer);
- if (containerForPseudoContent != null) {
- dropContainer = containerForPseudoContent;
- dropOffset = 0;
- } else {
- dropOffset = nsuiEvent.getRangeOffset();
- }
- } else {
- int closestXDistance = HUGE_DISTANCE;
- int closestYDistance = HUGE_DISTANCE;
- boolean inNodeFlag = false;
- nsIDOMNode closestNode = null;
-
- nsIDOMNodeList childen = originalNode.getChildNodes();
- long count = childen.getLength();
- for (long i = 0; i < count; i++) {
- nsIDOMNode child = childen.item(i);
- if (VpeVisualDomBuilder.isPseudoElement(child)
- || VpeVisualDomBuilder.isAnonElement(child)) {
- continue;
- }
- Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
- int fromTop = mouseY - rect.y;
- int fromBottom = mouseY - rect.y - rect.height;
-
- int yDistance;
- if (fromTop > 0 && fromBottom < 0) {
- yDistance = 0;
- } else {
- yDistance = Math.min(Math.abs(fromTop), Math.abs(fromBottom));
- }
-
- if (yDistance <= closestYDistance && rect.width > 0 && rect.height > 0) {
- if (yDistance < closestYDistance) {
- closestXDistance = HUGE_DISTANCE;
- }
- int fromLeft = mouseX - rect.x;
- int fromRight = mouseX - rect.x - rect.width;
-
- int xDistance;
- if (fromLeft > 0 && fromRight < 0) {
- xDistance = 0;
- } else {
- xDistance = Math.min(Math.abs(fromLeft), Math.abs(fromRight));
- }
- if (xDistance == 0 && yDistance == 0) {
- closestNode = child;
- inNodeFlag = true;
+ boolean canDrop = false;
+ if (dropableArea != null && dropableArea.getNode() != null
+ && dropableArea.getHighlightedDropTarget() != null) {
+ canDrop = true;
+ DropTarget dropTarget = dropableArea.getHighlightedDropTarget();
+ Node targetNode = vpeController.getDomMapping()
+ .getNearSourceNode(dropableArea.getNode());
+
+ if (dropTarget == DropTarget.BEFORE || dropTarget == DropTarget.AFTER) {
+ dropContainer = targetNode.getParentNode();
+ int offset = 0;
+ for (int i = 0; i < dropContainer.getChildNodes().getLength(); i++) {
+ if (targetNode.equals(dropContainer.getChildNodes().item(i))) {
break;
}
-
- if (xDistance < closestXDistance || (xDistance == closestXDistance && rect.x <= mouseX)) {
- closestXDistance = xDistance;
- closestYDistance = yDistance;
- closestNode = child;
- }
+ offset++;
}
- }
-
- if (closestNode == null) {
- closestNode = originalNode;
- inNodeFlag = true;
- }
- if (inNodeFlag) {
- if (closestNode.getNodeType() == Node.TEXT_NODE) {
- dropContainer = nsuiEvent.getRangeParent();
- dropOffset = nsuiEvent.getRangeOffset();
- } else {
- if (HTML.TAG_COLGROUP.equalsIgnoreCase(closestNode.getNodeName())) {
- nsIDOMNode nearChild = getNearChild(closestNode, mouseX, mouseY);
- if (nearChild != null && nearChild.getNodeType() == Node.ELEMENT_NODE) {
- dropContainer = nearChild;
- } else {
- dropContainer = closestNode;
- }
- } else {
- dropContainer = closestNode;
- }
+
+ if (dropTarget == DropTarget.BEFORE) {
+ dropOffset = offset;
+ } else if (dropTarget == DropTarget.AFTER) {
+ dropOffset = offset + 1;
+ }
+ } else if(dropTarget == DropTarget.BEGIN || dropTarget == DropTarget.END) {
+ dropContainer = targetNode;
+ if (dropTarget == DropTarget.BEGIN) {
dropOffset = 0;
+ } else if (dropTarget == DropTarget.END) {
+ dropOffset = dropContainer.getChildNodes().getLength();
}
- } else {
- dropContainer = closestNode.getParentNode();
- dropOffset = (int)VisualDomUtil.getOffset(closestNode);
- Rectangle rect = XulRunnerVpeUtils.getElementBounds(closestNode);
- if (canInsertAfter(mouseX, mouseY, rect)) {
- dropOffset++;
- }
}
}
- VpeVisualDropInfo info = new VpeVisualDropInfo(dropContainer, dropOffset);
- return info;
+
+ return new VpeSourceDropInfo(dropContainer, dropOffset, canDrop);
+
+// nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
+// event.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
+// int mouseX = nsuiEvent.getPageX();
+// int mouseY = nsuiEvent.getPageY();
+// nsIDOMNode dropContainer = null;
+// int dropOffset = 0;
+//
+// nsIDOMDocument document = vpeController.getVisualBuilder()
+// .getOriginalTargetNode(event).getOwnerDocument();
+//
+// nsIDOMNode originalNode = DndUtil.getElementFromPoint(document, mouseX, mouseY);
+//// if (originalNode != null) {
+//// if (dropableArea == null) {
+//// dropableArea = new DropableArea(document);
+//// dropableArea.setDropSpots(EnumSet.allOf(DropSpot.class));
+//// }
+//// dropableArea.setNode(originalNode);
+//// dropableArea.setHighlightedSpot(mouseX, mouseY);
+//// dropableArea.setVisible(true);
+//// dropableArea.redraw();
+//// }
+//
+// if (originalNode == null || originalNode.getParentNode() == null ||
+// originalNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
+// return new VpeVisualDropInfo(null, 0);
+// }
+// if (originalNode.getNodeType() == Node.TEXT_NODE) {
+// dropContainer = nsuiEvent.getRangeParent();
+// nsIDOMNode containerForPseudoContent = VpePseudoContentCreator
+// .getContainerForPseudoContent(dropContainer);
+// if (containerForPseudoContent != null) {
+// dropContainer = containerForPseudoContent;
+// dropOffset = 0;
+// } else {
+// dropOffset = nsuiEvent.getRangeOffset();
+// }
+// } else {
+// int closestXDistance = HUGE_DISTANCE;
+// int closestYDistance = HUGE_DISTANCE;
+// boolean inNodeFlag = false;
+// nsIDOMNode closestNode = null;
+//
+// nsIDOMNodeList childen = originalNode.getChildNodes();
+// long count = childen.getLength();
+// for (long i = 0; i < count; i++) {
+// nsIDOMNode child = childen.item(i);
+// if (VpeVisualDomBuilder.isPseudoElement(child)
+// || VpeVisualDomBuilder.isAnonElement(child)) {
+// continue;
+// }
+// Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
+// int fromTop = mouseY - rect.y;
+// int fromBottom = mouseY - rect.y - rect.height;
+//
+// int yDistance;
+// if (fromTop > 0 && fromBottom < 0) {
+// yDistance = 0;
+// } else {
+// yDistance = Math.min(Math.abs(fromTop), Math.abs(fromBottom));
+// }
+//
+// if (yDistance <= closestYDistance && rect.width > 0 && rect.height > 0) {
+// if (yDistance < closestYDistance) {
+// closestXDistance = HUGE_DISTANCE;
+// }
+// int fromLeft = mouseX - rect.x;
+// int fromRight = mouseX - rect.x - rect.width;
+//
+// int xDistance;
+// if (fromLeft > 0 && fromRight < 0) {
+// xDistance = 0;
+// } else {
+// xDistance = Math.min(Math.abs(fromLeft), Math.abs(fromRight));
+// }
+// if (xDistance == 0 && yDistance == 0) {
+// closestNode = child;
+// inNodeFlag = true;
+// break;
+// }
+//
+// if (xDistance < closestXDistance || (xDistance == closestXDistance && rect.x <= mouseX)) {
+// closestXDistance = xDistance;
+// closestYDistance = yDistance;
+// closestNode = child;
+// }
+// }
+// }
+//
+// if (closestNode == null) {
+// closestNode = originalNode;
+// inNodeFlag = true;
+// }
+// if (inNodeFlag) {
+// if (closestNode.getNodeType() == Node.TEXT_NODE) {
+// dropContainer = nsuiEvent.getRangeParent();
+// dropOffset = nsuiEvent.getRangeOffset();
+// } else {
+// if (HTML.TAG_COLGROUP.equalsIgnoreCase(closestNode.getNodeName())) {
+// nsIDOMNode nearChild = getNearChild(closestNode, mouseX, mouseY);
+// if (nearChild != null && nearChild.getNodeType() == Node.ELEMENT_NODE) {
+// dropContainer = nearChild;
+// } else {
+// dropContainer = closestNode;
+// }
+// } else {
+// dropContainer = closestNode;
+// }
+// dropOffset = 0;
+// }
+// } else {
+// dropContainer = closestNode.getParentNode();
+// dropOffset = (int)VisualDomUtil.getOffset(closestNode);
+// Rectangle rect = XulRunnerVpeUtils.getElementBounds(closestNode);
+// if (canInsertAfter(mouseX, mouseY, rect)) {
+// dropOffset++;
+// }
+// }
+// }
}
-
- private VpeVisualDropInfo getDropInfo(Node sourceDropContainer,
- int sourceDropOffset) {
- nsIDOMNode visualDropContainer = null;
- long visualDropOffset = 0;
- switch (sourceDropContainer.getNodeType()) {
- case Node.TEXT_NODE:
- visualDropContainer = vpeController.getDomMapping().getVisualNode(sourceDropContainer);
- visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
- .getNodeValue(), sourceDropOffset);
- break;
- case Node.ELEMENT_NODE:
- case Node.DOCUMENT_NODE:
- NodeList sourceChildren = sourceDropContainer.getChildNodes();
- if (sourceDropOffset < sourceChildren.getLength()) {
- Node sourceChild = sourceChildren.item(sourceDropOffset);
- nsIDOMNode visualChild = vpeController.getDomMapping().getVisualNode(sourceChild);
- if (visualChild != null) {
- visualDropContainer = visualChild.getParentNode();
-
- visualDropOffset = VisualDomUtil.getOffset(visualChild);
- }
- }
- if (visualDropContainer == null) {
- visualDropContainer = vpeController.getDomMapping()
- .getNearVisualNode(sourceDropContainer);
- nsIDOMNode visualChild = VpeVisualDomBuilder.getLastAppreciableVisualChild(visualDropContainer);
- if (visualChild != null) {
- visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
- } else {
- visualDropOffset = 0;
- }
- }
- break;
- case Node.ATTRIBUTE_NODE:
- Element sourceElement = ((Attr) sourceDropContainer)
- .getOwnerElement();
- VpeElementMapping elementMapping = vpeController.getDomMapping()
- .getNearElementMapping(sourceElement);
- nsIDOMNode textNode = elementMapping.getTemplate()
- .getOutputTextNode(vpeController.getPageContext(), sourceElement,
- elementMapping.getData());
- if (textNode != null) {
- visualDropContainer = textNode;
- visualDropOffset = TextUtil.visualInnerPosition(
- sourceDropContainer.getNodeValue(), sourceDropOffset);
- }
- break;
- }
- if (visualDropContainer == null) {
- return null;
- }
- return new VpeVisualDropInfo(visualDropContainer, visualDropOffset);
+ private interface DropResolver {
+ public boolean canDrop(Node node);
}
- private nsIDOMNode getNearChild(nsIDOMNode container, int x, int y) {
- int closestXDistance = HUGE_DISTANCE;
- int closestYDistance = HUGE_DISTANCE;
- nsIDOMNode closestNode = null;
+// TODO: delete the following methods, as they are never used
+// this method is never used
+// private boolean canInsertAfter(int x, int y, Rectangle rect) {
+// if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
+// return true;
+// }
+// return y >= rect.x && x > (rect.x + rect.width / 2);
+// }
+
+// this method is never used
+// private MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
+// InnerDragBuffer.object = null;
+// vpeController.onHideTooltip();
+//
+// if (vpeController.getDropWindow().isActive()) {
+// if (!mouseEvent.getAltKey()) {
+// vpeController.getDropWindow().close();
+// } else {
+// return new MozillaDropInfo(false, null, 0);
+// }
+// }
+// if (mouseEvent.getAltKey()) {
+// nsIDOMNode visualNode = (nsIDOMNode) mouseEvent.getTarget()
+// .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+// Node sourceNode = vpeController.getDomMapping().getNearSourceNode(visualNode);
+// if (sourceNode != null) {
+// if (ModelTransfer.MODEL.equals(flavor)) {
+// // XModelObject object =
+// // PreferenceModelUtilities.getPreferenceModel().
+// // getModelBuffer().source();
+// // InnerDragBuffer.object = object;
+// } else {
+// vpeController.getDropWindow().setFlavor(flavor);
+// }
+// vpeController.getDropWindow().setActive(true);
+// vpeController.getDropWindow().setEventPosition(mouseEvent.getScreenX(), mouseEvent
+// .getScreenY());
+// vpeController.getDropWindow().setInitialTargetNode(sourceNode);
+// vpeController.getDropWindow().open();
+// mouseEvent.stopPropagation();
+// mouseEvent.preventDefault();
+// return new MozillaDropInfo(false, null, 0);
+// }
+// }
+// boolean canDrop = false;
+// nsIDOMNode caretParent = null;
+// long caretOffset = 0;
+//
+// if (VpeController.MODEL_FLAVOR.equals(flavor)) {
+// XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+// .getModelBuffer().source();
+// if (object.getFileType() == XModelObject.FILE
+// && !TLDUtil.isTaglib(object)) {
+// IFile f = (IFile) EclipseResourceUtil.getResource(object);
+// canDrop = f != null;
+// VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
+// caretParent = visualDropInfo.getDropContainer();
+// caretOffset = visualDropInfo.getDropOffset();
+// } else {
+// String tagname = vpeController.getTagName(object);
+// if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
+// Node sourceDragNode = ((Document) vpeController.getModel().getAdapter(
+// Document.class)).createElement(tagname);
+// VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
+// if (visualDropInfo.getDropContainer() != null) {
+// VpeSourceDropInfo sourceDropInfo
+// = getSourceDropInfo(
+// sourceDragNode, visualDropInfo, true);
+// canDrop = sourceDropInfo.canDrop();
+// if (canDrop) {
+// VpeVisualDropInfo newVisualDropInfo
+// = getDropInfo(
+// sourceDropInfo.getContainer(),
+// sourceDropInfo.getOffset());
+// if (newVisualDropInfo != null) {
+// correctVisualDropPosition(mouseEvent,
+// newVisualDropInfo, visualDropInfo);
+// caretParent = newVisualDropInfo.getDropContainer();
+// caretOffset = newVisualDropInfo.getDropOffset();
+// }
+// }
+// }
+// visualDropInfo.release();
+// }
+// } else if (XulRunnerEditor.TRANS_FLAVOR_kFileMime.equals(flavor)
+// || XulRunnerEditor.TRANS_FLAVOR_kURLMime.equals(flavor)) {
+// VpeVisualDropInfo visualDropInfo = getDropInfo(mouseEvent);
+// caretParent = visualDropInfo.getDropContainer();
+// caretOffset = visualDropInfo.getDropOffset();
+// canDrop = true;
+//
+// }
+// if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+// System.out.println(" canDrop: " + canDrop //$NON-NLS-1$
+// + (canDrop ?
+// " container: " //$NON-NLS-1$
+// + caretParent.getNodeName()
+// + " offset: " //$NON-NLS-1$
+// + caretOffset
+// : "")); //$NON-NLS-1$
+// }
+// return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+//
+// }
- nsIDOMNodeList childen = container.getChildNodes();
- long count = childen.getLength();
- for (long i = 0; i < count; i++) {
- nsIDOMNode child = childen.item(i);
- if (VpeVisualDomBuilder.isPseudoElement(child) || VpeVisualDomBuilder.isAnonElement(child)) {
- continue;
- }
- Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
- int fromTop = y - rect.y;
- int fromBottom = y - rect.y - rect.height;
+// this method is never used
+// private VpeSourceDropInfo getSourceDropInfo(Node dragNode,
+// Node container, int offset, boolean checkParentsTemplates) {
+// // Thread.dumpStack();
+// boolean canDrop = false;
+// switch (container.getNodeType()) {
+// case Node.ELEMENT_NODE:
+// VpeNodeMapping nodeMapping = vpeController.getDomMapping()
+// .getNodeMapping(container);
+// if (nodeMapping != null && nodeMapping instanceof VpeElementMapping) {
+// canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
+// .canInnerDrop(vpeController.getPageContext(), container, dragNode);
+// }
+// if (!canDrop) {
+// if (!checkParentsTemplates)
+// return new VpeSourceDropInfo(container, offset,
+// canDrop);
+// // offset = ((NodeImpl)container).getIndex();
+// // container = container.getParentNode();
+// // TODO Max Areshkau unclear logic , if we can drop on element
+// // why we trying to drop
+// // this on parent
+// // return getSourceDropInfo(dragNode, container, offset,
+// // false);
+// return new VpeSourceDropInfo(container, offset, canDrop);
+// }
+// break;
+// case Node.TEXT_NODE:
+// case Node.DOCUMENT_NODE:
+// canDrop = true;
+// break;
+// case Node.ATTRIBUTE_NODE:
+// canDrop = true;
+// break;
+// }
+// if (canDrop) {
+// return new VpeSourceDropInfo(container, offset, canDrop);
+// } else {
+// return new VpeSourceDropInfo(null, 0, canDrop);
+// }
+// }
- int yDistance;
- if (fromTop > 0 && fromBottom < 0) {
- yDistance = 0;
- } else {
- yDistance = Math.min(Math.abs(fromTop), Math.abs(fromBottom));
- }
-
- if (yDistance <= closestYDistance && rect.width > 0 && rect.height > 0) {
- if (yDistance < closestYDistance) {
- closestXDistance = HUGE_DISTANCE;
- }
- int fromLeft = x - rect.x;
- int fromRight = x - rect.x - rect.width;
+// this method is never used
+// private VpeSourceDropInfo getSourceDropInfo(Node sourceDragNode,
+// VpeVisualDropInfo visualDropInfo, boolean checkParentTemplates) {
+// nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
+// long visualDropOffset = visualDropInfo.getDropOffset();
+// Node sourceDropContainer = null;
+// int sourceDropOffset = 0;
+//
+// switch (visualDropContainer.getNodeType()) {
+// case nsIDOMNode.ELEMENT_NODE:
+// nsIDOMNode visualOffsetNode = null;
+// boolean afterFlag = false;
+// long visualChildCount = VisualDomUtil
+// .getChildCount(visualDropContainer);
+// if (visualDropOffset < visualChildCount) {
+// visualOffsetNode = VisualDomUtil.getChildNode(
+// visualDropContainer, visualDropOffset);
+// if (VpeVisualDomBuilder.isPseudoElement(visualOffsetNode)
+// || VpeVisualDomBuilder.isAnonElement(visualOffsetNode)) {
+// visualOffsetNode = VpeVisualDomBuilder
+// .getLastAppreciableVisualChild(visualDropContainer);
+// afterFlag = true;
+// }
+// } else {
+// visualOffsetNode = VpeVisualDomBuilder.getLastAppreciableVisualChild(visualDropContainer);
+// afterFlag = visualChildCount != 0;
+// }
+// if (visualOffsetNode != null) {
+// Node sourceOffsetNode = vpeController.getDomMapping()
+// .getSourceNode(visualOffsetNode);
+// if (sourceOffsetNode != null) {
+// sourceDropContainer = sourceOffsetNode.getParentNode();
+// sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
+// if (afterFlag) {
+// sourceDropOffset++;
+// }
+// }
+// }
+// if (sourceDropContainer == null) {
+// sourceDropContainer = vpeController.getDomMapping()
+// .getNearSourceNode(visualDropContainer);
+// if (sourceDropContainer != null) {
+// sourceDropOffset = sourceDropContainer.getChildNodes()
+// .getLength();
+// }
+// }
+// if (sourceDropContainer == null) {
+// sourceDropContainer = vpeController.getDomMapping()
+// .getNearSourceNode(
+// vpeController.getVisualBuilder().getContentArea());
+// sourceDropOffset = sourceDropContainer.getChildNodes()
+// .getLength();
+// }
+// break;
+// case nsIDOMNode.TEXT_NODE:
+// VpeNodeMapping nodeMapping = vpeController.getDomMapping()
+// .getNearNodeMapping(visualDropContainer);
+// // switch (nodeMapping.getType()) {
+// // case VpeNodeMapping.TEXT_MAPPING:
+// sourceDropContainer = nodeMapping.getSourceNode();
+// sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer
+// .getNodeValue(), visualDropOffset);
+// // break;
+// // case VpeNodeMapping.ELEMENT_MAPPING:
+// // it's attribute
+// if (VpeVisualDomBuilder.isTextEditable(visualDropContainer)) {
+// String[] atributeNames = ((VpeElementMapping) nodeMapping)
+// .getTemplate().getOutputAttributeNames();
+// if (atributeNames != null && atributeNames.length > 0) {
+// Element sourceElement = (Element) nodeMapping
+// .getSourceNode();
+// sourceDropContainer = sourceElement
+// .getAttributeNode(atributeNames[0]);
+// sourceDropOffset = TextUtil.sourceInnerPosition(
+// sourceDropContainer.getNodeValue(),
+// visualDropOffset);
+// }
+// }
+// }
+// if (sourceDropContainer != null) {
+// return getSourceDropInfo(sourceDragNode, sourceDropContainer,
+// sourceDropOffset, checkParentTemplates);
+// } else {
+// return new VpeSourceDropInfo(null, 0, false);
+// }
+// }
- int xDistance;
- if (fromLeft > 0 && fromRight < 0) {
- xDistance = 0;
- } else {
- xDistance = Math.min(Math.abs(fromLeft), Math.abs(fromRight));
- }
- if (xDistance == 0 && yDistance == 0) {
- closestNode = child;
- break;
- }
- if (xDistance < closestXDistance || (xDistance == closestXDistance && rect.x <= x)) {
- closestXDistance = xDistance;
- closestYDistance = yDistance;
- closestNode = child;
- }
- }
- }
- return closestNode;
- }
// this method is never used
+// private void correctVisualDropPosition(nsIDOMMouseEvent mouseEvent,
+// VpeVisualDropInfo newVisualDropInfo,
+// VpeVisualDropInfo oldVisualDropInfo) {
+// nsIDOMNode newVisualDropContainer = newVisualDropInfo
+// .getDropContainer();
+// nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
+// .getDropContainer();
+//
+// if (newVisualDropContainer.equals(oldVisualDropContainer)) {
+// newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
+// return;
+// }
+//
+// nsIDOMNode child = oldVisualDropContainer;
+// while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
+// nsIDOMNode parent = child.getParentNode();
+// if (newVisualDropContainer.equals(parent)) {
+// long offset = VisualDomUtil.getOffset(child);
+// Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
+//
+// nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
+// mouseEvent.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
+// int mouseX = nsuiEvent.getPageX();
+// int mouseY = nsuiEvent.getPageY();
+//
+// if (canInsertAfter(mouseX, mouseY, rect)) {
+// offset++;
+// }
+// newVisualDropInfo.setDropOffset(offset);
+// }
+// child = parent;
+// }
+// }
+
+// this method is never used
+// private VpeVisualDropInfo getDropInfo(Node sourceDropContainer,
+// int sourceDropOffset) {
+// nsIDOMNode visualDropContainer = null;
+// long visualDropOffset = 0;
+//
+// switch (sourceDropContainer.getNodeType()) {
+// case Node.TEXT_NODE:
+// visualDropContainer = vpeController.getDomMapping().getVisualNode(sourceDropContainer);
+// visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
+// .getNodeValue(), sourceDropOffset);
+// break;
+// case Node.ELEMENT_NODE:
+// case Node.DOCUMENT_NODE:
+// NodeList sourceChildren = sourceDropContainer.getChildNodes();
+// if (sourceDropOffset < sourceChildren.getLength()) {
+// Node sourceChild = sourceChildren.item(sourceDropOffset);
+// nsIDOMNode visualChild = vpeController.getDomMapping().getVisualNode(sourceChild);
+// if (visualChild != null) {
+// visualDropContainer = visualChild.getParentNode();
+//
+// visualDropOffset = VisualDomUtil.getOffset(visualChild);
+// }
+// }
+// if (visualDropContainer == null) {
+// visualDropContainer = vpeController.getDomMapping()
+// .getNearVisualNode(sourceDropContainer);
+// nsIDOMNode visualChild = VpeVisualDomBuilder.getLastAppreciableVisualChild(visualDropContainer);
+// if (visualChild != null) {
+// visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
+// } else {
+// visualDropOffset = 0;
+// }
+// }
+// break;
+// case Node.ATTRIBUTE_NODE:
+// Element sourceElement = ((Attr) sourceDropContainer)
+// .getOwnerElement();
+// VpeElementMapping elementMapping = vpeController.getDomMapping()
+// .getNearElementMapping(sourceElement);
+// nsIDOMNode textNode = elementMapping.getTemplate()
+// .getOutputTextNode(vpeController.getPageContext(), sourceElement,
+// elementMapping.getData());
+// if (textNode != null) {
+// visualDropContainer = textNode;
+// visualDropOffset = TextUtil.visualInnerPosition(
+// sourceDropContainer.getNodeValue(), sourceDropOffset);
+// }
+// break;
+// }
+// if (visualDropContainer == null) {
+// return null;
+// }
+// return new VpeVisualDropInfo(visualDropContainer, visualDropOffset);
+// }
+
+// this method is never used
+// private nsIDOMNode getNearChild(nsIDOMNode container, int x, int y) {
+// int closestXDistance = HUGE_DISTANCE;
+// int closestYDistance = HUGE_DISTANCE;
+// nsIDOMNode closestNode = null;
+//
+// nsIDOMNodeList childen = container.getChildNodes();
+// long count = childen.getLength();
+// for (long i = 0; i < count; i++) {
+// nsIDOMNode child = childen.item(i);
+// if (VpeVisualDomBuilder.isPseudoElement(child) || VpeVisualDomBuilder.isAnonElement(child)) {
+// continue;
+// }
+// Rectangle rect = XulRunnerVpeUtils.getElementBounds(child);
+// int fromTop = y - rect.y;
+// int fromBottom = y - rect.y - rect.height;
+//
+// int yDistance;
+// if (fromTop > 0 && fromBottom < 0) {
+// yDistance = 0;
+// } else {
+// yDistance = Math.min(Math.abs(fromTop), Math.abs(fromBottom));
+// }
+//
+// if (yDistance <= closestYDistance && rect.width > 0 && rect.height > 0) {
+// if (yDistance < closestYDistance) {
+// closestXDistance = HUGE_DISTANCE;
+// }
+// int fromLeft = x - rect.x;
+// int fromRight = x - rect.x - rect.width;
+//
+// int xDistance;
+// if (fromLeft > 0 && fromRight < 0) {
+// xDistance = 0;
+// } else {
+// xDistance = Math.min(Math.abs(fromLeft), Math.abs(fromRight));
+// }
+// if (xDistance == 0 && yDistance == 0) {
+// closestNode = child;
+// break;
+// }
+// if (xDistance < closestXDistance || (xDistance == closestXDistance && rect.x <= x)) {
+// closestXDistance = xDistance;
+// closestYDistance = yDistance;
+// closestNode = child;
+// }
+// }
+// }
+// return closestNode;
+// }
+
+// this method is never used
// public VpeSourceDropInfo canExternalDropMacro(XModelObject object, Node parentNode, int offset) {
// String tagname = vpeController.getTagName(object);
// Node sourceDragNode = ((Document) vpeController.getModel().getAdapter(Document.class))
Copied: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnDHelper.java (from rev 21518, trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java)
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnDHelper.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnDHelper.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.dnd;
+
+import java.util.HashSet;
+
+import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
+import org.jboss.tools.vpe.editor.VpeSourceDropInfo;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+
+public class VpeDnDHelper {
+ static final String TAG_DRAG = VpeTemplateManager.VPE_PREFIX + "drag"; //$NON-NLS-1$
+ static final String TAG_DROP = VpeTemplateManager.VPE_PREFIX + "drop"; //$NON-NLS-1$
+ static final String TAG_CONTAINER_CHILD = VpeTemplateManager.VPE_PREFIX + "container-child"; //$NON-NLS-1$
+
+ static final String ATTRIBUTE_START_ENABLE = "start-enable"; //$NON-NLS-1$
+ static final String ATTRIBUTE_CONTAINER = "container"; //$NON-NLS-1$
+ static final String ATTRIBUTE_TAG_NAME = "tag-name"; //$NON-NLS-1$
+
+ static final String STRING_YES = "yes"; //$NON-NLS-1$
+
+ private boolean dragEnabled = false;
+ private boolean isContainer = false;
+ private HashSet<String> enabledTags = null;
+
+ public void setDndData(boolean dragEnabled, boolean isContainer){
+ this.dragEnabled = dragEnabled;
+ this.isContainer = isContainer;
+ enabledTags = null;
+ }
+
+ public void setDndData(Element node){
+ enabledTags = null;
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ int len = children.getLength();
+ boolean dragFlag = false;
+ boolean dropFlag = false;
+ for (int i = 0; i < len; i++) {
+ Node innerNode = children.item(i);
+ if (innerNode.getNodeType() == Node.ELEMENT_NODE) {
+ String name = innerNode.getNodeName();
+ if (name.startsWith(VpeTemplateManager.VPE_PREFIX)) {
+ if (!dragFlag && TAG_DRAG.equals(name)) {
+ if(STRING_YES.equalsIgnoreCase(((Element)innerNode).getAttribute(ATTRIBUTE_START_ENABLE))) dragEnabled = true;
+ else dragEnabled = false;
+ dragFlag = true;
+ }
+ if (!dropFlag && TAG_DROP.equals(name)){
+ if(STRING_YES.equalsIgnoreCase(((Element)innerNode).getAttribute(ATTRIBUTE_CONTAINER))) isContainer = true;
+ else isContainer = false;
+
+ dropFlag = true;
+ NodeList childNodes = innerNode.getChildNodes();
+ if (childNodes != null) {
+ int childNodesLength = childNodes.getLength();
+ if (childNodesLength > 0) {
+ enabledTags = new HashSet<String>();
+ }
+ for (int j = 0; j < childNodesLength; j++) {
+ Node child = childNodes.item(j);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ String tagName = child.getNodeName();
+ if (tagName.startsWith(VpeTemplateManager.VPE_PREFIX)) {
+ if (TAG_CONTAINER_CHILD.equals(tagName)) {
+ enabledTags.add(((Element)child).getAttribute(ATTRIBUTE_TAG_NAME).toLowerCase());
+ }
+ }
+ }
+ }
+ }
+ }
+ if(dragFlag && dropFlag)break;
+ }
+ }
+ }
+ }
+ }
+
+ public boolean isDragEnabled(){
+ return dragEnabled;
+ }
+
+ public boolean isDropEnabled(VpePageContext pageContext, Node container, Node node){
+ if(!pageContext.isAbsolutePosition() && isAncestor(container, node)) return false;
+ if(isContainer){
+ if(enabledTags != null && enabledTags.size() > 0){
+ String name = node.getNodeType() == Node.ELEMENT_NODE ? node.getLocalName().toLowerCase() : node.getNodeName();
+ if(enabledTags.contains(name)) return true;
+ else return false;
+ }else return true;
+ }
+ return false;
+ }
+
+ private boolean isAncestor(Node container, Node node){
+ Node curent = container;
+ while(curent != null){
+ if(curent.equals(node))return true;
+ curent = curent.getParentNode();
+ }
+ return false;
+ }
+
+ private void removeTextFromTextNode(Node node, int start, int end){
+ Node parent = node.getParentNode();
+ boolean split1=true, split2=true;
+ String text = node.getNodeValue();
+ if(start == 0)split1 = false;
+ if(end == (text.length()+1))split2 = false;
+ if(split1 && split2){
+ String text1 = text.substring(0,start);
+ String text2 = text.substring(end, text.length());
+
+ node.setNodeValue(text1+text2);
+ }else if(split1){
+ String text1 = text.substring(0,start);
+
+ node.setNodeValue(text1);
+ }else if(split2){
+ String text1 = text.substring(end, text.length());
+
+ node.setNodeValue(text1);
+ }else{
+ parent.removeChild(node);
+ }
+ }
+
+ private void insertTextIntoTextNode(Node node, String text, int offset) {
+ String oldText = node.getNodeValue();
+ if(oldText == null) return;
+ String newText = oldText.substring(0, offset)+text+oldText.substring(offset, oldText.length());
+ node.setNodeValue(newText);
+ }
+
+ private void replaceTextInTextNode(Node node, int offset, int selStart, int selEnd) {
+ if (offset >= selStart && offset <= selEnd) {
+ return;
+ }
+ String oldText = node.getNodeValue();
+ if (oldText == null) {
+ return;
+ }
+ String selText = oldText.substring(selStart, selEnd);
+ String newText = null;
+ if (offset < selStart) {
+ newText = oldText.substring(0, offset) + selText + oldText.substring(offset, selStart) + oldText.substring(selEnd);
+ } else {
+ newText = oldText.substring(0, selStart) + oldText.substring(selEnd, offset) + selText + oldText.substring(offset);
+ }
+ node.setNodeValue(newText);
+ }
+
+ private void insertAnyTextIntoAnyText(Node container, int offset, Node node, int start, int end) {
+ String nodeText = node.getNodeValue();
+ String draggedText = nodeText.substring(start, end);
+
+ if (node == container) {
+ replaceTextInTextNode(container, offset, start, end);
+ } else {
+ removeTextFromTextNode(node, start, end);
+ insertTextIntoTextNode(container, draggedText, offset);
+ }
+ }
+
+ public void drop(VpePageContext pageContext, VpeSourceInnerDragInfo dragInfo, VpeSourceDropInfo dropInfo){
+ Node container = dropInfo.getContainer();
+ int offset = dropInfo.getOffset();
+ Node node = dragInfo.getNode();
+
+ switch (node.getNodeType()) {
+ case Node.TEXT_NODE:
+ case Node.ATTRIBUTE_NODE:
+ String nodeText = node.getNodeValue();
+ int beginPosition = Math.min(dragInfo.getOffset(), nodeText.length());
+ int endPosition = Math.min(dragInfo.getOffset() + dragInfo.getLength(), nodeText.length());
+
+ switch (container.getNodeType()) {
+ case Node.TEXT_NODE:
+ case Node.ATTRIBUTE_NODE:
+ insertAnyTextIntoAnyText(container, offset, node, beginPosition, endPosition);
+ break;
+
+ case Node.ELEMENT_NODE:
+ case Node.DOCUMENT_NODE:
+ NodeList children = container.getChildNodes();
+ int count = children.getLength();
+ Node child = null;
+ boolean insertBefore = true;
+ if (offset < count) {
+ if (offset > 0) {
+ child = children.item(offset - 1);
+ insertBefore = false;
+ if (child.getNodeType() != Node.TEXT_NODE) {
+ child = children.item(offset);
+ insertBefore = true;
+ }
+ } else {
+ child = children.item(offset);
+ }
+ } else if (count > 0) {
+ child = children.item(count - 1);
+ insertBefore = false;
+ }
+ if (child != null && child.getNodeType() == Node.TEXT_NODE) {
+ if (insertBefore) {
+ insertAnyTextIntoAnyText(child, 0, node, beginPosition, endPosition);
+ } else {
+ insertAnyTextIntoAnyText(child, child.getNodeValue().length(), node, beginPosition, endPosition);
+ }
+ } else {
+ removeTextFromTextNode(node, beginPosition, endPosition);
+ Document document = container.getNodeType()== Node.DOCUMENT_NODE ? (Document) container : container.getOwnerDocument();
+ Node textNode = document.createTextNode(nodeText.substring(beginPosition, endPosition));
+ if (offset < count) {
+ container.insertBefore(textNode, child);
+ } else {
+ container.appendChild(textNode);
+ }
+ }
+ break;
+ }
+ break;
+
+ case Node.ELEMENT_NODE:
+ if (!isAncestor(container, node)) {
+ Node parent = node.getParentNode();
+
+ switch (container.getNodeType()) {
+ case Node.TEXT_NODE:
+ Text text = (Text)container;
+ String str1 = text.getNodeValue().substring(0,offset);
+ String str2 = text.getNodeValue().substring(offset,text.getNodeValue().length());
+ //text.setNodeValue(str1);
+ //Text newText = text.splitText(offset);
+ Text newText = text.getOwnerDocument().createTextNode(str2);
+ text.getParentNode().insertBefore(newText, text.getNextSibling());
+ parent.removeChild(node);
+ text.getParentNode().insertBefore(node, newText);
+ text.getParentNode().removeChild(text);
+ Text oldText = text.getOwnerDocument().createTextNode(str1);
+ node.getParentNode().insertBefore(oldText, node);
+ break;
+
+ case Node.ELEMENT_NODE:
+ case Node.DOCUMENT_NODE:
+ NodeList children = container.getChildNodes();
+ int count = children.getLength();
+ Node child = null;
+ if (offset < count) {
+ child = children.item(offset);
+ } else if (count > 0) {
+ child = children.item(count - 1);
+ }
+ if (node != child) {
+ parent.removeChild(node);
+ if (offset < count) {
+ container.insertBefore(node, child);
+ } else {
+ container.appendChild(node);
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -908,7 +908,7 @@
return position;
}
- public Point getSourceSelectionRangeAtVisualNode(nsIDOMNode visualInitNode, int visualInitOffset) {
+ private Point getSourceSelectionRangeAtVisualNode(nsIDOMNode visualInitNode, int visualInitOffset) {
if (visualInitNode.getNodeType() == Node.TEXT_NODE) {
Node sourceNode = domMapping.getSourceNode(visualInitNode);
if (sourceNode == null) {
@@ -930,37 +930,6 @@
}
}
- Point getSourceSelectionRange(Node sourceInitNode, int sourceInitOffset) {
- int offset=0;
- int position=0;
- switch (sourceInitNode.getNodeType()) {
- case Node.TEXT_NODE:
- offset = Math.min(sourceInitOffset, sourceInitNode.getNodeValue().length());
- position = sourceBuilder.getPosition(sourceInitNode, offset, false);
- break;
- case Node.ELEMENT_NODE:
- case Node.DOCUMENT_NODE:
- NodeList children = sourceInitNode.getChildNodes();
- int count = children.getLength();
- if (sourceInitOffset < count) {
- Node sourceNode = children.item(sourceInitOffset);
- position = ((IndexedRegion)sourceNode).getStartOffset();
- } else if (count > 0) {
- Node sourceNode = children.item(count - 1);
- position = ((IndexedRegion)sourceNode).getEndOffset();
- } else {
- position = ((IndexedRegion)sourceInitNode).getStartOffset();
- if (sourceInitNode instanceof ElementImpl) {
- ElementImpl element = (ElementImpl)sourceInitNode;
- if (element.isContainer()) {
- position = element.getStartEndOffset();
- }
- }
- }
- break;
- }
- return new Point(position, offset);
- }
void setVisualElementSelection(nsIDOMMouseEvent mouseEvent) {
nsISelection selection = visualSelectionController.getSelection(nsISelectionController.SELECTION_NORMAL);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -353,7 +353,7 @@
return empty;
}
- int getPosition(Node sourceNode, int offset, boolean innerFlag) {
+ public int getPosition(Node sourceNode, int offset, boolean innerFlag) {
int start = 0;
if (sourceNode != null) {
start = ((IndexedRegion) sourceNode).getStartOffset() + offset;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualCaretInfo.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualCaretInfo.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualCaretInfo.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -48,8 +48,4 @@
public int getSourcePosition() {
return selectionBuilder.getSourcePosition(rangeParent, rangeOffset);
}
-
- Point getSourceSelectionRange() {
- return selectionBuilder.getSourceSelectionRangeAtVisualNode(rangeParent, rangeOffset);
- }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -44,6 +44,7 @@
import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.dnd.VpeDnDHelper;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
@@ -60,7 +61,6 @@
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
-import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
import org.jboss.tools.vpe.editor.util.ElService;
import org.jboss.tools.vpe.editor.util.FaceletUtil;
@@ -164,7 +164,6 @@
unborderedVisualNodes.add(HTML.TAG_LI);
unborderedVisualNodes.add(HTML.TAG_BR);
}
- private VpeDnd dropper;
private Map<IStorage, Document> includeDocuments = new HashMap<IStorage, Document>();
private boolean showInvisibleTags;
@@ -181,8 +180,6 @@
// this.visualContentArea = visualEditor.getContentArea();
this.pageContext = pageContext;
// this.headNode = visualEditor.getHeadNode();
- dropper = new VpeDnd();
- dropper.setDndData(false, true);
// if (isFacelet()) {
// faceletFile = true;
@@ -1647,11 +1644,6 @@
}
}
- public void innerDrop(VpeSourceInnerDragInfo dragInfo,
- VpeSourceDropInfo dropInfo) {
- dropper.drop(pageContext, dragInfo, dropInfo);
- }
-
nsIDOMElement getNearDragElement(Element visualElement) {
VpeElementMapping elementMapping = domMapping
.getNearElementMapping(visualElement);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -92,11 +92,6 @@
contentArea.addEventListener(MozillaEventAdapter.MOUSEUPEVENTTYPE, this, false);
contentArea.addEventListener(MozillaEventAdapter.MOUSEMOVEEVENTTYPE, this, false);
contentArea.addEventListener(MozillaEventAdapter.CONTEXTMENUEVENTTYPE, this, false);
- contentArea.addEventListener(MozillaEventAdapter.DRAGDROPEVENT, this, false);
- contentArea.addEventListener(MozillaEventAdapter.DRAGENTEREVENT, this, false);
- contentArea.addEventListener(MozillaEventAdapter.DRAGEXITEVENT,this, false);
- contentArea.addEventListener(MozillaEventAdapter.DRAGGESTUREEVENT, this, false);
- contentArea.addEventListener(MozillaEventAdapter.DRAGOVEREVENT, this, false);
contentArea.addEventListener(MozillaEventAdapter.DBLCLICK, this, false);
}
if (window != null) {
@@ -108,6 +103,12 @@
selectionPrivate.addSelectionListener(this);
}
if (document != null) {
+ document.addEventListener(MozillaEventAdapter.DRAGDROPEVENT, this, false);
+ document.addEventListener(MozillaEventAdapter.DRAGENTEREVENT, this, false);
+ document.addEventListener(MozillaEventAdapter.DRAGEXITEVENT,this, false);
+ document.addEventListener(MozillaEventAdapter.DRAGGESTUREEVENT, this, false);
+ document.addEventListener(MozillaEventAdapter.DRAGOVEREVENT, this, false);
+
document.addEventListener(MozillaEventAdapter.KEYPRESS, this, false);
//as a fix of https://jira.jboss.org/jira/browse/JBIDE-4022
//scroll event listener was added for selection border redrawing
@@ -127,15 +128,16 @@
contentArea.removeEventListener(MozillaEventAdapter.MOUSEUPEVENTTYPE, this, false);
contentArea.removeEventListener(MozillaEventAdapter.MOUSEMOVEEVENTTYPE, this, false);
contentArea.removeEventListener(MozillaEventAdapter.CONTEXTMENUEVENTTYPE, this, false);
- contentArea.removeEventListener(MozillaEventAdapter.DRAGDROPEVENT, this, false);
- contentArea.removeEventListener(MozillaEventAdapter.DRAGENTEREVENT, this, false);
- contentArea.removeEventListener(MozillaEventAdapter.DRAGEXITEVENT, this, false);
- contentArea.removeEventListener(MozillaEventAdapter.DRAGGESTUREEVENT, this, false);
- contentArea.removeEventListener(MozillaEventAdapter.DRAGOVEREVENT, this, false);
contentArea.removeEventListener(MozillaEventAdapter.DBLCLICK, this, false);
contentArea = null;
}
if (document != null) {
+ document.removeEventListener(MozillaEventAdapter.DRAGDROPEVENT, this, false);
+ document.removeEventListener(MozillaEventAdapter.DRAGENTEREVENT, this, false);
+ document.removeEventListener(MozillaEventAdapter.DRAGEXITEVENT, this, false);
+ document.removeEventListener(MozillaEventAdapter.DRAGGESTUREEVENT, this, false);
+ document.removeEventListener(MozillaEventAdapter.DRAGOVEREVENT, this, false);
+
document.removeEventListener(MozillaEventAdapter.KEYPRESS, this, false);
document.removeEventListener(MozillaEventAdapter.SCROLL, this, false);
document = null;
@@ -282,7 +284,10 @@
} else if(DRAGENTEREVENT.equals(eventType)) {
//just ignore this event
} else if(DRAGEXITEVENT.equals(eventType)) {
- //just ignore this event
+ for (MozillaDndListener listener : listeners.getListeners(
+ MozillaDndListener.class)) {
+ listener.dragExit(domEvent);
+ }
} else if(DRAGOVEREVENT.equals(eventType)) {
for (MozillaDndListener listener : listeners.getListeners(
MozillaDndListener.class)) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -38,4 +38,6 @@
// void dragExit(nsIDOMEvent event);
// void drop(nsIDOMEvent event);
// void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data);
+
+ void dragExit(nsIDOMEvent domEvent);
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2010-04-21 08:46:06 UTC (rev 21573)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2010-04-21 09:10:45 UTC (rev 21574)
@@ -23,6 +23,7 @@
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.jst.jsp.editor.ITextFormatter;
import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.dnd.VpeDnDHelper;
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
import org.jboss.tools.vpe.editor.VpeSourceDropInfo;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -31,7 +32,6 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
-import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
import org.jboss.tools.vpe.editor.template.resize.VpeResizer;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
@@ -76,7 +76,7 @@
// TODO Max Areshkau add DnD support
/** The dragger. */
- private VpeDnd dragger;
+ private VpeDnDHelper dragger;
/** The text formating data. */
private TextFormatingData textFormatingData;
@@ -321,7 +321,7 @@
private void initDndHandler(Element templateSection) {
if (getDragger() == null) {
- setDragger(new VpeDnd());
+ setDragger(new VpeDnDHelper());
getDragger().setDndData(templateSection);
}
}
@@ -1279,7 +1279,7 @@
*
* @return the dragger
*/
- public VpeDnd getDragger() {
+ public VpeDnDHelper getDragger() {
return dragger;
}
@@ -1289,7 +1289,7 @@
*
* @param dragger the dragger to set
*/
- public void setDragger(VpeDnd dragger) {
+ public void setDragger(VpeDnDHelper dragger) {
this.dragger = dragger;
}
14 years, 8 months