JBoss Tools SVN: r4654 - trunk/documentation/GettingStartedGuide/docs/userguide/en/modules.
by jbosstools-commits@lists.jboss.org
Author: ykryvinchanka
Date: 2007-11-02 06:03:26 -0400 (Fri, 02 Nov 2007)
New Revision: 4654
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/DevelopAsimpleJSPWebApplication.xml
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/testNG.xml
Log:
http://jira.jboss.com/jira/browse/RHDS-150 GSG. Highlighting.
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/DevelopAsimpleJSPWebApplication.xml
===================================================================
--- trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/DevelopAsimpleJSPWebApplication.xml 2007-11-02 08:18:00 UTC (rev 4653)
+++ trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/DevelopAsimpleJSPWebApplication.xml 2007-11-02 10:03:26 UTC (rev 4654)
@@ -150,7 +150,7 @@
</mediaobject>
</figure>
<itemizedlist>
- <listitem><para>Click, for example, <emphasis>WAR</emphasis> option to create war archive</para></listitem>
+ <listitem><para>Click, for example, <emphasis><property>WAR</property></emphasis> option to create war archive</para></listitem>
</itemizedlist>
<para>In the dialog New WAR you can see automatically selected default values</para>
<figure>
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml
===================================================================
--- trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml 2007-11-02 08:18:00 UTC (rev 4653)
+++ trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml 2007-11-02 10:03:26 UTC (rev 4654)
@@ -320,15 +320,15 @@
<para><emphasis role="bold">Do I need to have JBoss server installed to run Red Hat Developer Studio?</emphasis></para>
<para>No. Red Hat Developer Studio already comes bundled with JBoss server. We bundle it together so that you don't need to download any additional software and can test your application in a Web browser right away.</para>
- <para>If you want to use a different JBoss server installation, after Red Hat Developer Studio is installed open Servers View (select <emphasis>Window > Show View > Others > Server > Servers</emphasis>), then right click on this <emphasis>view > New > Server</emphasis> and follow the wizards steps to point to another Jboss server installation.</para>
+ <para>If you want to use a different JBoss server installation, after Red Hat Developer Studio is installed open Servers View (select <emphasis><property>Window > Show View > Others > Server > Servers</property></emphasis>), then right click on this <emphasis><property>view > New > Server</property></emphasis> and follow the wizards steps to point to another Jboss server installation.</para>
<para>Red Hat Developer Studio works with any servlet container, not just JBoss. For more information on deployment, please see the Deploying Your Application section.</para>
</section>
<section id="Importing_Projects">
<title>Importing Projects</title>
<para><emphasis role="bold">I have an existing Struts or JSF project. Can I open the project in RHDS?</emphasis></para>
- <para>Yes. From main menu select <emphasis>File > Import > Other > JSF Project (or Struts Project)</emphasis> and follow wizards steps.</para>
+ <para>Yes. From main menu select <emphasis><property>File > Import > Other > JSF Project (or Struts Project)</property></emphasis> and follow wizards steps.</para>
<para><emphasis role="bold">Can I import a .war file?</emphasis></para>
- <para>Yes. Select <emphasis>File > Import > Web > WAR file</emphasis>, then follow importing steps.</para>
+ <para>Yes. Select <emphasis><property>File > Import > Web > WAR file</property></emphasis>, then follow importing steps.</para>
</section>
<section id="Troubleshooting">
<title>Troubleshooting, Problems, Configuration, Error Messages</title>
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/testNG.xml
===================================================================
--- trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/testNG.xml 2007-11-02 08:18:00 UTC (rev 4653)
+++ trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/testNG.xml 2007-11-02 10:03:26 UTC (rev 4654)
@@ -12,7 +12,7 @@
<section>
<title>What is TestNG?</title>
<para><property>TestNG</property> ("Testing, the Next Generation") is a Java unit testing framework that aims to overcome many limitations of JUnit.
- <property>TestNG</property> introduces some new functionalities that make it more powerful and easier to use, such as:</para>
+ TestNG introduces some new functionalities that make it more powerful and easier to use, such as:</para>
<itemizedlist>
<listitem><para>JDK 5 Annotations (JDK 1.4 is also supported with JavaDoc annotations).</para></listitem>
<listitem><para>Flexible test configuration.</para></listitem>
@@ -80,7 +80,7 @@
</figure>
<itemizedlist>
- <listitem><para>Select <property>EAR</property> next to <emphasis><property>Deploy as:</property></emphasis> field.</para></listitem>
+ <listitem><para>Select <emphasis><property>EAR</property></emphasis> next to <emphasis><property>Deploy as:</property></emphasis> field.</para></listitem>
</itemizedlist>
<figure>
@@ -194,7 +194,7 @@
</mediaobject>
</figure>
- <para>After clicking on <property>ActionLocal Tests</property> link you will see the Results for ActionLocal Tests.</para>
+ <para>After clicking on <emphasis><property>ActionLocal Tests</property></emphasis> link you will see the Results for ActionLocal Tests.</para>
<figure>
<title>Test Information</title>
17 years, 2 months
JBoss Tools SVN: r4653 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-11-02 04:18:00 -0400 (Fri, 02 Nov 2007)
New Revision: 4653
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-1251 a4j:status template has been fixed
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2007-11-02 04:47:24 UTC (rev 4652)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2007-11-02 08:18:00 UTC (rev 4653)
@@ -220,6 +220,9 @@
<vpe:tag name="a4j:status" case-sensitive="yes">
<vpe:template children="yes" modify="yes">
+ <span class="{@styleClass};{@stopStyleClass}" style="{@style};{@stopStyle}" title="{tagstring()}">
+ <vpe:value expr=" {jsfvalue(@stopText)}"/>
+ </span>
</vpe:template>
</vpe:tag>
17 years, 2 months
JBoss Tools SVN: r4652 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-11-02 00:47:24 -0400 (Fri, 02 Nov 2007)
New Revision: 4652
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1245
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-11-02 04:39:06 UTC (rev 4651)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-11-02 04:47:24 UTC (rev 4652)
@@ -124,65 +124,66 @@
public void handleEvent(nsIDOMEvent domEvent) {
try{
- if(getEditorDomEventListener()==null){
-
- return;
- } else if(MOUSEMOVEEVENTTYPE.equals(domEvent.getType())) {
-
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseMove(mouseEvent);
- } else if(MOUSEDOWNEVENTTYPE.equals(domEvent.getType())) {
+ if(getEditorDomEventListener()==null){
+
+ return;
+ } else if(MOUSEMOVEEVENTTYPE.equals(domEvent.getType())) {
+
+ nsIDOMMouseEvent mouseEvent;
+ mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ getEditorDomEventListener().mouseMove(mouseEvent);
+ } else if(MOUSEDOWNEVENTTYPE.equals(domEvent.getType())) {
+
+ nsIDOMMouseEvent mouseEvent;
+ mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ getEditorDomEventListener().mouseDown(mouseEvent);
+
+ } else if(MOUSEUPEVENTTYPE.equals(domEvent.getType())) {
+
+ nsIDOMMouseEvent mouseEvent;
+ mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ getEditorDomEventListener().mouseUp(mouseEvent);
+ } else if(CLICKEVENTTYPE.equals(domEvent.getType())) {
+
+ nsIDOMMouseEvent mouseEvent;
+ mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ getEditorDomEventListener().mouseClick(mouseEvent);
+ } else if(DBLCLICK.equals(domEvent.getType())) {
+
+ nsIDOMMouseEvent mouseEvent;
+ mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ getEditorDomEventListener().mouseDblClick(mouseEvent);
+ } else if(KEYPRESS.equals(domEvent.getType())) {
+
+ nsIDOMKeyEvent keyEvent = (nsIDOMKeyEvent) domEvent.queryInterface(nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID);
+ getEditorDomEventListener().keyPress(keyEvent);
+ } else if(CONTEXTMENUEVENTTYPE.equals(domEvent.getType())) {
+
+ //first param are null 0, because this not used in event handler
+ getEditorDomEventListener().onShowContextMenu(0, domEvent, (nsIDOMNode) domEvent.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID));
+ } else if(DRAGGESTUREEVENT.equals(domEvent.getType())) {
+
+ if(getEditorDomEventListener()!=null) {
+
+ getEditorDomEventListener().dragGesture(domEvent);
+ }
+ } else if(DRAGDROPEVENT.equals(domEvent.getType())) {
+ // calls when drop event occure
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseDown(mouseEvent);
-
- } else if(MOUSEUPEVENTTYPE.equals(domEvent.getType())) {
-
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseUp(mouseEvent);
- } else if(CLICKEVENTTYPE.equals(domEvent.getType())) {
-
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseClick(mouseEvent);
- } else if(DBLCLICK.equals(domEvent.getType())) {
-
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseDblClick(mouseEvent);
- } else if(KEYPRESS.equals(domEvent.getType())) {
-
- nsIDOMKeyEvent keyEvent = (nsIDOMKeyEvent) domEvent.queryInterface(nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID);
- getEditorDomEventListener().keyPress(keyEvent);
- } else if(CONTEXTMENUEVENTTYPE.equals(domEvent.getType())) {
-
- //first param are null 0, because this not used in event handler
- getEditorDomEventListener().onShowContextMenu(0, domEvent, (nsIDOMNode) domEvent.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID));
- } else if(DRAGGESTUREEVENT.equals(domEvent.getType())) {
-
+ getEditorDomEventListener().dragDrop(domEvent);
+ domEvent.stopPropagation();
+ domEvent.preventDefault();
+ } else if(DRAGENTEREVENT.equals(domEvent.getType())) {
+ //just ignore this event
+ } else if(DRAGEXITEVENT.equals(domEvent.getType())) {
+ //just ignore this event
+ } else if(DRAGOVEREVENT.equals(domEvent.getType())) {
+
+ getEditorDomEventListener().dragOver(domEvent);
+ }
if(getEditorDomEventListener()!=null) {
-
- getEditorDomEventListener().dragGesture(domEvent);
+ getEditorDomEventListener().onRefresh();
}
- } else if(DRAGDROPEVENT.equals(domEvent.getType())) {
- // calls when drop event occure
-
- getEditorDomEventListener().dragDrop(domEvent);
- domEvent.stopPropagation();
- domEvent.preventDefault();
- } else if(DRAGENTEREVENT.equals(domEvent.getType())) {
- //just ignore this event
- } else if(DRAGEXITEVENT.equals(domEvent.getType())) {
- //just ignore this event
- } else if(DRAGOVEREVENT.equals(domEvent.getType())) {
-
- getEditorDomEventListener().dragOver(domEvent);
- }
-
- getEditorDomEventListener().onRefresh();
}catch(Throwable th) {
17 years, 2 months
JBoss Tools SVN: r4651 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-11-02 00:39:06 -0400 (Fri, 02 Nov 2007)
New Revision: 4651
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1244
NPE fixed
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java 2007-11-02 00:00:29 UTC (rev 4650)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/TLDRegisterHelper.java 2007-11-02 04:39:06 UTC (rev 4651)
@@ -13,6 +13,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.jboss.tools.common.kb.KbTldResource;
import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
@@ -51,12 +52,16 @@
JspEditorPlugin.getPluginLog().logError(e);
return;
}
- IEditorInput input = JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
- String tldContent = DropUtils.getTldContent(input, data.getUri());
- if(tldContent!=null) {
- resource.setTldContent(tldContent);
- wtpKbConnector.registerResource(resource, true);
- }
+
+ IEditorPart editorPart = JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editorPart!=null) {
+ IEditorInput input = editorPart.getEditorInput();
+ String tldContent = DropUtils.getTldContent(input, data.getUri());
+ if(tldContent!=null) {
+ resource.setTldContent(tldContent);
+ wtpKbConnector.registerResource(resource, true);
+ }
+ }
}
} else {
wtpKbConnector.registerResource(resource);
17 years, 2 months
JBoss Tools SVN: r4650 - in trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui: widget/field and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-11-01 20:00:29 -0400 (Thu, 01 Nov 2007)
New Revision: 4650
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1220
layout updated to have radio buttons in one line
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-11-01 21:32:09 UTC (rev 4649)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-11-02 00:00:29 UTC (rev 4650)
@@ -100,8 +100,8 @@
.createRadioEditor(
ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DEPLOY_AS,
- Arrays.asList(new String[] { SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_WAR, SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EAR }),
- Arrays.asList(new Object[] { SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_WAR, SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EAR }),
+ Arrays.asList(new String[] { ISeamFacetDataModelProperties.DEPLOY_AS_WAR.toUpperCase(), ISeamFacetDataModelProperties.DEPLOY_AS_EAR.toUpperCase() }),
+ Arrays.asList(new Object[] { ISeamFacetDataModelProperties.DEPLOY_AS_WAR, ISeamFacetDataModelProperties.DEPLOY_AS_EAR }),
getDeployAsDefaultValue());
String lastCreatedCPName = ""; //$NON-NLS-1$
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java 2007-11-01 21:32:09 UTC (rev 4649)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java 2007-11-02 00:00:29 UTC (rev 4650)
@@ -33,8 +33,8 @@
public RadioField(Composite parent, List<String> labels, List<Object> values, Object defaultValue) {
topComposite = new Composite(parent, SWT.NONE);
- topComposite.setLayout(new GridLayout(1, false));
- topComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ topComposite.setLayout(new GridLayout(values.size(), false));
+// topComposite.setLayoutData(new GridData(SWT.BEGINNING));
radios = new Button[values.size()];
if(defaultValue==null && values.size()>0) {
@@ -44,14 +44,14 @@
radios[i] = new Button(topComposite, SWT.RADIO);
radios[i].setText(labels.get(i));
radios[i].addSelectionListener(this);
- radios[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ radios[i].setLayoutData(new GridData(GridData.BEGINNING));
Object value = values.get(i);
radios[i].setData(value);
if(value != null && value.equals(defaultValue)) {
radios[i].setSelection(true);
this.value = value;
}
- }
+ }
}
/* (non-Javadoc)
17 years, 2 months
JBoss Tools SVN: r4649 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-01 17:32:09 -0400 (Thu, 01 Nov 2007)
New Revision: 4649
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/AdaptorFactoryProviderForServiceXML.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/ServicexmlModelHandler.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/util/PackageTypeSearcher.java
Log:
JBIDE-737 Problems occur when CSS file is created.
fixed factoryprovider for service xml so it only matches on relevant ones
+ comment about at least one place where the code completion is broken.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/AdaptorFactoryProviderForServiceXML.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/AdaptorFactoryProviderForServiceXML.java 2007-11-01 19:57:36 UTC (rev 4648)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/AdaptorFactoryProviderForServiceXML.java 2007-11-01 21:32:09 UTC (rev 4649)
@@ -24,6 +24,7 @@
import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
import org.eclipse.wst.xml.ui.internal.registry.AdapterFactoryProviderForXML;
+
/**
*
* @author Rob Stryker <rob.stryker(a)redhat.com>
@@ -33,8 +34,11 @@
AdapterFactoryProviderForXML {
public boolean isFor(IDocumentTypeHandler contentTypeDescription) {
- //return (contentTypeDescription instanceof ServicexmlModelHandler);
- return true;
+ if(contentTypeDescription.getId().equals(ServicexmlModelHandler.MODELHANDLER_ID)) {
+ return true;
+ } else {
+ return false;
+ }
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/ServicexmlModelHandler.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/ServicexmlModelHandler.java 2007-11-01 19:57:36 UTC (rev 4648)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/mbeans/editors/ServicexmlModelHandler.java 2007-11-01 21:32:09 UTC (rev 4649)
@@ -37,7 +37,7 @@
public class ServicexmlModelHandler extends AbstractModelHandler implements IModelHandler{
final static String CONTENTTYPE_ID = "org.jboss.ide.eclipse.as.ui.mbeans.servicexml"; //$NON-NLS-1$
- final private static String MODELHANDLER_ID = "org.jboss.ide.eclipse.as.ui.servicexmlModelHandler"; //$NON-NLS-1$
+ final static String MODELHANDLER_ID = "org.jboss.ide.eclipse.as.ui.servicexmlModelHandler"; //$NON-NLS-1$
public ServicexmlModelHandler() {
super();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/util/PackageTypeSearcher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/util/PackageTypeSearcher.java 2007-11-01 19:57:36 UTC (rev 4648)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui.mbeans/src/org/jboss/ide/eclipse/as/ui/util/PackageTypeSearcher.java 2007-11-01 21:32:09 UTC (rev 4649)
@@ -127,6 +127,11 @@
results.add(match.getElement());
}
+ @Override
+ public void beginReporting() {
+ // TODO Auto-generated method stub
+ super.beginReporting();
+ }
public void endReporting() {
}
@@ -151,7 +156,7 @@
{SearchEngine.getDefaultSearchParticipant()}, scope, requestor, new NullProgressMonitor());
ArrayList results = requestor.getResults();
- if (results.size() != 1)
+ if (results.size() != 1) // TODO: there can be multiple packagefragments for the same name in a workspace
return null;
return (IPackageFragment) results.get(0);
17 years, 2 months
JBoss Tools SVN: r4648 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2007-11-01 15:57:36 -0400 (Thu, 01 Nov 2007)
New Revision: 4648
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1187 Properties from superclass of a library class not recognized by autocomplete, validator or F3
The Content Assistant recognizes the parameterized types now
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2007-11-01 19:50:18 UTC (rev 4647)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2007-11-01 19:57:36 UTC (rev 4648)
@@ -91,7 +91,7 @@
* Result is {'1','2'}
*/
public List<String> getCompletions(ISeamProject project, IFile file, String documentContent, CharSequence prefix,
- int position, boolean returnEqualedVariablesOnly, Set<ISeamContextVariable> usedVariables, Map<String, IMethod> unpairedGettersOrSetters) throws BadLocationException, StringIndexOutOfBoundsException {
+ int position, boolean returnEqualedVariablesOnly, Set<ISeamContextVariable> usedVariables, Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters) throws BadLocationException, StringIndexOutOfBoundsException {
List<String> res= new ArrayList<String>();
SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(documentContent, position + prefix.length());
@@ -157,9 +157,9 @@
// First segment is found - proceed with next tokens
int startTokenIndex = (resolvedExpressionPart == null ? 0 : resolvedExpressionPart.size());
- Set<IMember> members = new HashSet<IMember>();
+ List<TypeInfoCollector.MemberInfo> members = new ArrayList<TypeInfoCollector.MemberInfo>();
for (ISeamContextVariable var : resolvedVariables) {
- IMember member = SeamExpressionResolver.getMemberByVariable(var, returnEqualedVariablesOnly);
+ TypeInfoCollector.MemberInfo member = SeamExpressionResolver.getMemberInfoByVariable(var, returnEqualedVariablesOnly);
if (member != null && !members.contains(member))
members.add(member);
}
@@ -173,27 +173,23 @@
if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN)
// proceed with next token
continue;
-
+
if (token.getType() == ELOperandToken.EL_NAME_TOKEN) {
// Find properties for the token
String name = token.getText();
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr : EclipseJavaUtil.findType(mbr.getJavaProject(), EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> properties = SeamExpressionResolver.getProperties(type);
- for (IMember property : properties) {
- StringBuffer propertyName = new StringBuffer(property.getElementName());
- if (property instanceof IMethod) { // Setter or getter
- propertyName.delete(0, 3);
- propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
- }
- if (name.equals(propertyName.toString())) {
- newMembers.add(property);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos = SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> properties = infos.getProperties();
+ for (TypeInfoCollector.MemberInfo property : properties) {
+ StringBuffer propertyName = new StringBuffer(property.getName());
+ if (property instanceof TypeInfoCollector.MethodInfo) { // Setter or getter
+ propertyName.delete(0, (propertyName.charAt(0) == 'i' ? 2 : 3));
+ propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
+ if (name.equals(propertyName.toString())) {
+ newMembers.add(property);
+ }
}
}
members = newMembers;
@@ -204,18 +200,14 @@
if (name.indexOf('(') != -1) {
name = name.substring(0, name.indexOf('('));
}
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr : EclipseJavaUtil.findType(mbr.getJavaProject(), EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> methods = SeamExpressionResolver.getMethods(type);
- for (IMember method : methods) {
- if (name.equals(method.getElementName())) {
- newMembers.add(method);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos = SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> methods = infos.getMethods();
+ for (TypeInfoCollector.MemberInfo method : methods) {
+ if (name.equals(method.getName())) {
+ newMembers.add(method);
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
}
}
members = newMembers;
@@ -224,32 +216,19 @@
Set<String> proposals = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN) {
// return all the methods + properties
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr : EclipseJavaUtil.findType(mbr.getJavaProject(), EclipseJavaUtil.getMemberTypeAsString(mbr)));
- proposals.addAll(SeamExpressionResolver.getMethodPresentations(type));
- proposals.addAll(SeamExpressionResolver.getPropertyPresentations(type, unpairedGettersOrSetters));
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
- }
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos = SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ proposals.addAll(infos.getMethodPresentations());
+ proposals.addAll(infos.getPropertyPresentations(unpairedGettersOrSetters));
}
} else if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
// return filtered methods + properties
Set<String> proposalsToFilter = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- for (IMember mbr : members) {
- try {
- IType type = null;
- if(mbr instanceof IType) {
- type = (IType)mbr;
- } else {
- type = EclipseJavaUtil.findType(mbr.getJavaProject(), EclipseJavaUtil.getMemberTypeAsString(mbr));
- }
- proposalsToFilter.addAll(SeamExpressionResolver.getMethodPresentations(type));
- proposalsToFilter.addAll(SeamExpressionResolver.getPropertyPresentations(type, unpairedGettersOrSetters));
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
- }
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos = SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ proposalsToFilter.addAll(infos.getMethodPresentations());
+ proposalsToFilter.addAll(infos.getPropertyPresentations(unpairedGettersOrSetters));
}
for (String proposal : proposalsToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
@@ -259,7 +238,7 @@
if (proposal.equals(filter)) {
proposals.add(proposal);
if(unpairedGettersOrSetters!=null) {
- IMethod unpirMethod = unpairedGettersOrSetters.get(filter);
+ TypeInfoCollector.MethodInfo unpirMethod = unpairedGettersOrSetters.get(filter);
unpairedGettersOrSetters.clear();
if(unpirMethod!=null) {
unpairedGettersOrSetters.put(filter, unpirMethod);
@@ -492,10 +471,9 @@
* @param prefix the prefix to search for
* @param position Offset of the prefix
*/
- public List<IJavaElement> getJavaElementsForExpression(ISeamProject project, IFile file, String expression) throws BadLocationException, StringIndexOutOfBoundsException {
+ public List<IJavaElement> getJavaElementsForExpression(ISeamProject project, IFile file, String expression) throws BadLocationException, StringIndexOutOfBoundsException {
List<IJavaElement> res= new ArrayList<IJavaElement>();
-
SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(expression, expression.length());
List<ELOperandToken> tokens = tokenizer.getTokens();
@@ -526,13 +504,12 @@
if (areEqualExpressions(resolvedExpressionPart, tokens)) {
// First segment is the last one
for (ISeamContextVariable var : resolvedVariables) {
-/* String varName = var.getName();
- if(expression.length()<varName.length()) {
- res.add(varName.substring(prefixString.length()));
- } else if(returnEqualedVariablesOnly) {
- res.add(varName);
- }
-*/
+// String varName = var.getName();
+// if(expression.length()<varName.length()) {
+// res.add(varName.substring(prefixString.length()));
+// } else if(returnEqualedVariablesOnly) {
+// res.add(varName);
+// }
IMember member = SeamExpressionResolver.getMemberByVariable(var, true);
if (member instanceof IJavaElement){
res.add((IJavaElement)member);
@@ -543,9 +520,9 @@
// First segment is found - proceed with next tokens
int startTokenIndex = (resolvedExpressionPart == null ? 0 : resolvedExpressionPart.size());
- Set<IMember> members = new HashSet<IMember>();
+ List<TypeInfoCollector.MemberInfo> members = new ArrayList<TypeInfoCollector.MemberInfo>();
for (ISeamContextVariable var : resolvedVariables) {
- IMember member = SeamExpressionResolver.getMemberByVariable(var, true);
+ TypeInfoCollector.MemberInfo member = SeamExpressionResolver.getMemberInfoByVariable(var, true);
if (member != null && !members.contains(member))
members.add(member);
}
@@ -563,23 +540,19 @@
if (token.getType() == ELOperandToken.EL_NAME_TOKEN) {
// Find properties for the token
String name = token.getText();
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr : EclipseJavaUtil.findType(mbr.getJavaProject(), EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> properties = SeamExpressionResolver.getProperties(type);
- for (IMember property : properties) {
- StringBuffer propertyName = new StringBuffer(property.getElementName());
- if (property instanceof IMethod) { // Setter or getter
- propertyName.delete(0, 3);
- propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
- }
- if (name.equals(propertyName.toString())) {
- newMembers.add(property);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos = SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> properties = infos.getProperties();
+ for (TypeInfoCollector.MemberInfo property : properties) {
+ StringBuffer propertyName = new StringBuffer(property.getName());
+ if (property instanceof TypeInfoCollector.MethodInfo) { // Setter or getter
+ propertyName.delete(0, 3);
+ propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
+ if (name.equals(propertyName.toString())) {
+ newMembers.add(property);
+ }
}
}
members = newMembers;
@@ -590,18 +563,15 @@
if (name.indexOf('(') != -1) {
name = name.substring(0, name.indexOf('('));
}
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr : EclipseJavaUtil.findType(mbr.getJavaProject(), EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> methods = SeamExpressionResolver.getMethods(type);
- for (IMember method : methods) {
- if (name.equals(method.getElementName())) {
- newMembers.add(method);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos = SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> methods = infos.getMethods();
+ for (TypeInfoCollector.MemberInfo method : methods) {
+ if (method instanceof TypeInfoCollector.MethodInfo
+ && name.equals(method.getName())) {
+ newMembers.add(method);
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
}
}
members = newMembers;
@@ -611,36 +581,25 @@
if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
// return filtered methods + properties
- Set<IJavaElement> javaElementsToFilter = new HashSet<IJavaElement>();
- for (IMember mbr : members) {
- try {
- IType type = null;
- if(mbr instanceof IType) {
- type = (IType)mbr;
- } else {
- type = EclipseJavaUtil.findType(mbr.getJavaProject(), EclipseJavaUtil.getMemberTypeAsString(mbr));
- }
- javaElementsToFilter.addAll(SeamExpressionResolver.getMethods(type));
- javaElementsToFilter.addAll(SeamExpressionResolver.getProperties(type));
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
- }
+ Set<TypeInfoCollector.MemberInfo> javaElementInfosToFilter = new HashSet<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos = SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ javaElementInfosToFilter.addAll(infos.getMethods());
+ javaElementInfosToFilter.addAll(infos.getProperties());
}
- for (IJavaElement javaElement : javaElementsToFilter) {
+
+ for (TypeInfoCollector.MemberInfo info : javaElementInfosToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
String filter = token.getText();
- String elementName = javaElement.getElementName();
// This is used for validation.
- if (javaElement.getElementName().equals(filter)) {
- javaElements.add(javaElement);
+ if (info.getName().equals(filter)) {
+ javaElements.add(info.getJavaElement());
} else {
- if (javaElement instanceof IMethod) {
- boolean getter = (elementName.startsWith("get") && !"get".equals(elementName)) || //$NON-NLS-1$ //$NON-NLS-2$
- (elementName.startsWith("is") && !"is".equals(elementName)); //$NON-NLS-1$ //$NON-NLS-2$
- boolean setter = elementName.startsWith("set") && !"set".equals(elementName); //$NON-NLS-1$ //$NON-NLS-2$
- if(getter || setter) {
- StringBuffer name = new StringBuffer(elementName);
- if(elementName.startsWith("i")) { //$NON-NLS-1$
+ if (info instanceof TypeInfoCollector.MethodInfo) {
+ TypeInfoCollector.MethodInfo methodInfo = (TypeInfoCollector.MethodInfo)info;
+ if(methodInfo.isGetter() || methodInfo.isSetter()) {
+ StringBuffer name = new StringBuffer(methodInfo.getName());
+ if(methodInfo.getName().startsWith("i")) { //$NON-NLS-1$
name.delete(0, 2);
} else {
name.delete(0, 3);
@@ -648,7 +607,7 @@
name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
String propertyName = name.toString();
if (propertyName.equals(filter)) {
- javaElements.add(javaElement);
+ javaElements.add(methodInfo.getJavaElement());
}
}
}
@@ -661,4 +620,5 @@
return res;
}
+
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-11-01 19:50:18 UTC (rev 4647)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-11-01 19:57:36 UTC (rev 4648)
@@ -11,21 +11,12 @@
package org.jboss.tools.seam.internal.core.el;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.TreeSet;
-import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamContextShortVariable;
@@ -36,7 +27,6 @@
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlFactory;
import org.jboss.tools.seam.core.ScopeType;
-import org.jboss.tools.seam.core.SeamCorePlugin;
/**
* Utility class used to resolve Seam project variables and to get the methods/properties and their presentation strings from type
@@ -158,255 +148,63 @@
}
return member;
}
-
- /**
- * Returns the methods for the type specified
- *
- * @param type
- * @return
- */
- public static Set<IMember> getMethods(IType type) {
- Set<IMember> methods = new HashSet<IMember>();
- if (type != null) {
- try {
- IMethod[] mthds = getAllMethods(type);
- for (int i = 0; mthds != null && i < mthds.length; i++) {
- if (Modifier.isPublic(mthds[i].getFlags()) &&
- !mthds[i].isConstructor() &&
- (!mthds[i].getElementName().startsWith("get") && !mthds[i].getElementName().startsWith("set")) || //$NON-NLS-1$ //$NON-NLS-2$
- "get".equals(mthds[i].getElementName()) || "set".equals(mthds[i].getElementName())) { //$NON-NLS-1$ //$NON-NLS-2$
- methods.add(mthds[i]);
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
- }
- return methods;
- }
/**
- * Returns the method presentation strings for the type specified
+ * Returns the IMember for the variable specified
*
- * @param type
+ * @param variable
* @return
*/
- public static Set<String> getMethodPresentations(IType type) {
- Set<String> methods = new HashSet<String>();
- if (type != null) {
- try {
-// IMethod[] mthds = type.getMethods();
- IMethod[] mthds = getAllMethods(type);
- for (int i = 0; mthds != null && i < mthds.length; i++) {
- IMethod m = mthds[i];
- if (Modifier.isPublic(m.getFlags()) &&
- !m.isConstructor() &&
- (!m.getElementName().startsWith("get") && !m.getElementName().startsWith("set")) || //$NON-NLS-1$ //$NON-NLS-2$
- "get".equals(m.getElementName()) || "set".equals(m.getElementName())) { //$NON-NLS-1$ //$NON-NLS-2$
-
- StringBuffer name = new StringBuffer(m.getElementName());
-
- // Add method as 'foo'
- methods.add(name.toString());
-
- // Add method as 'foo(param1,param2)'
- name.append('(');
- String[] mParams = null;
- mParams = m.getParameterNames();
- for (int j = 0; mParams != null && j < mParams.length; j++) {
- if (j > 0) name.append(", "); //$NON-NLS-1$
- name.append(mParams[j]);
- }
- name.append(')');
-
- methods.add(name.toString());
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
+ public static TypeInfoCollector.MemberInfo getMemberInfoByVariable(ISeamContextVariable variable, boolean onlyEqualNames) {
+ TypeInfoCollector.MemberInfo member = null;
+ if(variable instanceof ISeamContextShortVariable) {
+ return getMemberInfoByVariable(((ISeamContextShortVariable)variable).getOriginal(), onlyEqualNames);
}
- return methods;
- }
-
- /**
- * @param type
- * @return methods of type and methods of all super classes
- */
- private static IMethod[] getAllMethods(IType type) {
- ArrayList<IMethod> result = new ArrayList<IMethod>();
- try {
- IMethod[] mthds = type.getMethods();
- for(int i=0; i<mthds.length; i++) {
- result.add(mthds[i]);
+ if (variable instanceof ISeamComponent) {
+ ISeamComponent component = (ISeamComponent)variable;
+ ISeamJavaComponentDeclaration decl = component.getJavaDeclaration();
+ if (decl != null) {
+ member = TypeInfoCollector.createMemberInfo(decl.getSourceMember());
}
- IType superType = getSuperclass(type);
- while(superType!=null) {
- mthds = superType.getMethods();
- for(int i=0; i<mthds.length; i++) {
- result.add(mthds[i]);
- }
- superType = getSuperclass(superType);
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getPluginLog().logError(e);
}
- return result.toArray(new IMethod[result.size()]);
- }
-
- /**
- * @param type
- * @return fields of type and fields of all super classes
- */
- private static IField[] getAllFields(IType type) {
- ArrayList<IField> result = new ArrayList<IField>();
- try {
- IField[] fields = type.getFields();
- for(int i=0; i<fields.length; i++) {
- result.add(fields[i]);
- }
- IType superType = getSuperclass(type);
- while(superType!=null) {
- fields = superType.getFields();
- for(int i=0; i<fields.length; i++) {
- result.add(fields[i]);
- }
- superType = getSuperclass(superType);
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getPluginLog().logError(e);
+ if (member == null && variable instanceof IBijectedAttribute) {
+ member = TypeInfoCollector.createMemberInfo(((ISeamJavaSourceReference)variable).getSourceMember());
}
- return result.toArray(new IField[result.size()]);
- }
-
-
-
- private static IType getSuperclass(IType type) throws JavaModelException {
- String superclassName = type.getSuperclassName();
- if(superclassName!=null) {
- String fullySuperclassName = EclipseJavaUtil.resolveType(type, superclassName);
- if(fullySuperclassName!=null&&!fullySuperclassName.equals("java.lang.Object")) { //$NON-NLS-1$
- IType superType = type.getJavaProject().findType(fullySuperclassName);
- return superType;
- }
+ if (member == null && variable instanceof ISeamJavaSourceReference) {
+ member = TypeInfoCollector.createMemberInfo(((ISeamJavaSourceReference)variable).getSourceMember());
}
- return null;
- }
-
- /**
- * Returns the properties for the type specified
- *
- * @param type
- * @return
- */
- public static Set<IMember> getProperties(IType type) {
- Set<IMember> properties = new HashSet<IMember>();
- if (type != null) {
- try {
- IMethod[] mthds = getAllMethods(type);
- for (int i = 0; mthds != null && i < mthds.length; i++) {
- if (Modifier.isPublic(mthds[i].getFlags()) &&
- (mthds[i].getElementName().startsWith("get") && !"get".equals(mthds[i].getElementName())) || //$NON-NLS-1$ //$NON-NLS-2$
- (mthds[i].getElementName().startsWith("set") && !"set".equals(mthds[i].getElementName()))) { //$NON-NLS-1$ //$NON-NLS-2$
- properties.add(mthds[i]);
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
+ if (member == null && variable instanceof ISeamXmlFactory) {
+ ISeamXmlFactory factory = (ISeamXmlFactory)variable;
+ String value = factory.getValue();
+ if (value != null && value.length() > 0) {
+ if (value.startsWith("#{") || value.startsWith("${")) //$NON-NLS-1$ //$NON-NLS-2$
+ value = value.substring(2);
+ if (value.endsWith("}")) //$NON-NLS-1$
+ value = value.substring(0, value.length() - 1);
}
-
- try {
- IField[] fields = getAllFields(type);
- for (int i = 0; fields != null && i < fields.length; i++) {
- IField f = fields[i];
- if (Modifier.isPublic(f.getFlags())) {
- properties.add(f);
+ if (value != null && value.length() > 0) {
+ // TODO: Need to make sure that it's correct way to get the project and
+ // the scope from the factory
+ ISeamProject project = ((ISeamElement)factory).getSeamProject();
+// ISeamProject project = getSeamProject(factory.getResource());
+ if (project != null) {
+ List<ISeamContextVariable> resolvedValues = resolveVariables(project, null /* factory.getScope()*/, value, onlyEqualNames);
+ for (ISeamContextVariable var : resolvedValues) {
+ if (var.getName().equals(value)) {
+ member = getMemberInfoByVariable(var, onlyEqualNames);
+ break;
+ }
}
}
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
}
}
- return properties;
+ return member;
}
- /**
- * Returns the property presentation strings for the type specified
- *
- * @param type
- * @return
- */
- public static Set<String> getPropertyPresentations(IType type) {
- return getPropertyPresentations(type, null);
+ public static TypeInfoCollector collectTypeInfo(IType type) {
+ TypeInfoCollector typeInfo = new TypeInfoCollector(type);
+ typeInfo.collectInfo();
+ return typeInfo;
}
- /**
- * Returns the property presentation strings for the type specified
- *
- * @param type
- * @param unpairedGettersOrSetters - map of unpaired getters or setters of type's properties. 'key' is property name.
- * @return
- */
- public static Set<String> getPropertyPresentations(IType type, Map<String, IMethod> unpairedGettersOrSetters) {
- Set<String> properties = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- if (type != null) {
- try {
-// IMethod[] props = type.getMethods();
- IMethod[] props = getAllMethods(type);
- HashMap<String, IMethod> getters = new HashMap<String, IMethod>();
- HashMap<String, IMethod> setters = new HashMap<String, IMethod>();
- for (int i = 0; props != null && i < props.length; i++) {
- IMethod m = props[i];
- if (Modifier.isPublic(m.getFlags())) {
- String methodName = m.getElementName();
- boolean getter = (methodName.startsWith("get") && !"get".equals(methodName)) || //$NON-NLS-1$ //$NON-NLS-2$
- (methodName.startsWith("is") && !"is".equals(methodName)); //$NON-NLS-1$ //$NON-NLS-2$
- boolean setter = methodName.startsWith("set") && !"set".equals(methodName); //$NON-NLS-1$ //$NON-NLS-2$
- if(getter || setter) {
- StringBuffer name = new StringBuffer(methodName);
- if(methodName.startsWith("i")) { //$NON-NLS-1$
- name.delete(0, 2);
- } else {
- name.delete(0, 3);
- }
- name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
- String propertyName = name.toString();
- if(!properties.contains(propertyName)) {
- properties.add(propertyName);
- }
- if(unpairedGettersOrSetters!=null) {
- IMethod previousGetter = getters.get(propertyName);
- IMethod previousSetter = setters.get(propertyName);
- if((previousGetter!=null && setter)||(previousSetter!=null && getter)) {
- // We have both Getter and Setter
- unpairedGettersOrSetters.remove(propertyName);
- } else if(setter) {
- setters.put(propertyName, m);
- unpairedGettersOrSetters.put(propertyName, m);
- } else if(getter) {
- getters.put(propertyName, m);
- unpairedGettersOrSetters.put(propertyName, m);
- }
- }
- }
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
-
- try {
- IField[] fields = type.getFields();
- for (int i = 0; fields != null && i < fields.length; i++) {
- IField f = fields[i];
- if (Modifier.isPublic(f.getFlags())) {
- properties.add(f.getElementName());
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
- }
- return properties;
- }
}
\ No newline at end of file
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java 2007-11-01 19:57:36 UTC (rev 4648)
@@ -0,0 +1,669 @@
+package org.jboss.tools.seam.internal.core.el;
+
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jdt.core.ICompletionRequestor;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+public class TypeInfoCollector {
+ IType fType;
+ List<MethodInfo> fMethods;
+ List<FieldInfo> fFields;
+
+ public abstract static class MemberInfo {
+ private String fDeclaringTypeQualifiedName;
+ private String fName;
+ private int fModifiers;
+ private IType fSourceType;
+
+ protected MemberInfo (
+ IType sourceType,
+ String declaringTypeQualifiedName, String name, int modifiers) {
+ setSourceType(sourceType);
+ setDeclaringTypeQualifiedName(declaringTypeQualifiedName);
+ setName(name);
+ setModifiers(modifiers);
+ }
+
+ public void setSourceType(IType sourceType) {
+ fSourceType = sourceType;
+ }
+
+ public IType getSourceType() {
+ return fSourceType;
+ }
+
+ protected void setName (String name) {
+ this.fName = name;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ protected void setDeclaringTypeQualifiedName (String declaringTypeQualifiedName) {
+ this.fDeclaringTypeQualifiedName = declaringTypeQualifiedName;
+ }
+
+ public String getDeclaringTypeQualifiedName() {
+ return fDeclaringTypeQualifiedName;
+ }
+
+ protected void setModifiers (int modifiers) {
+ this.fModifiers = modifiers;
+ }
+
+ public int getModifiers() {
+ return fModifiers;
+ }
+
+ public boolean isPublic() {
+ return Modifier.isPublic(fModifiers) && !isJavaLangObject();
+ }
+
+ public boolean isJavaLangObject() {
+ return "java.lang.Object".equals(getDeclaringTypeQualifiedName());
+ }
+
+ abstract public IType getMemberType();
+
+ abstract public IJavaElement getJavaElement();
+
+ }
+
+ public static class TypeInfo extends MemberInfo {
+ IType fType;
+
+ public TypeInfo(IType type) throws JavaModelException {
+ super(type.getDeclaringType(), (type.getDeclaringType() == null ? null : type.getDeclaringType().getFullyQualifiedName()), type.getFullyQualifiedName(), type.getFlags());
+ this.fType = type;
+ }
+
+ public IType getType() {
+ return fType;
+ }
+
+ @Override
+ public IType getMemberType() {
+ return getType();
+ }
+
+ @Override
+ public IJavaElement getJavaElement() {
+ return getType();
+ }
+ }
+
+ public static class FieldInfo extends MemberInfo {
+
+ private String fTypeQualifiedName;
+
+ public FieldInfo(IType sourceType, String declaringTypeQualifiedName, String name, int modifiers, String typeQualifiedName) {
+ super(sourceType, declaringTypeQualifiedName, name, modifiers);
+ setTypeQualifiedName(typeQualifiedName);
+ }
+
+ public FieldInfo(IField field) throws JavaModelException {
+ this (field.getDeclaringType(), (field.getDeclaringType() == null ? null : field.getDeclaringType().getFullyQualifiedName()),
+ field.getElementName(),
+ field.getFlags(),
+ EclipseJavaUtil.getMemberTypeAsString(field));
+ }
+
+ protected void setTypeQualifiedName(String typeQualifiedName) {
+ fTypeQualifiedName = typeQualifiedName;
+ }
+
+ public String getTypeQualifiedName() {
+ return fTypeQualifiedName;
+ }
+
+ public IType getType() {
+ try {
+ return getSourceType().getJavaProject().findType(getTypeQualifiedName());
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+
+ public IJavaElement getJavaElement () {
+ try {
+ IType declType = getSourceType().getJavaProject().findType(getDeclaringTypeQualifiedName());
+
+ return (declType == null ? null : declType.getField(getName()));
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+
+ public IType getMemberType() {
+ return getType();
+ }
+
+ }
+
+ public static class MethodInfo extends MemberInfo {
+ String[] fParameterTypeQualifiedNames;
+ String[] fParameterNames;
+ String fReturnTypeQualifiedName;
+
+ public MethodInfo(IType sourceType, String declaringTypeQualifiedName, String name,
+ int modifiers, String[] parameterTypeQualifiedNames,
+ String[] parameterNames,
+ String returnTypeQualifiedName) {
+ super(sourceType, declaringTypeQualifiedName, name, modifiers);
+ setParameterTypeQualifiedNames(parameterTypeQualifiedNames);
+ setParameterNames(parameterNames);
+ setReturnTypeQualifiedName(returnTypeQualifiedName);
+ }
+
+ public MethodInfo(IMethod method) throws JavaModelException {
+ this (method.getDeclaringType(), (method.getDeclaringType() == null ? null : method.getDeclaringType().getFullyQualifiedName()),
+ method.getElementName(),
+ method.getFlags(),
+ resolveSignatures(method.getDeclaringType(), method.getParameterTypes()),
+ method.getParameterNames(),
+ EclipseJavaUtil.getMemberTypeAsString(method));
+ }
+
+ protected void setParameterTypeQualifiedNames(String[] parameterTypeQualifiedNames) {
+ fParameterTypeQualifiedNames = (parameterTypeQualifiedNames == null ?
+ new String[0] : parameterTypeQualifiedNames);
+ }
+
+ public String[] getParameterTypeQualifiedNames() {
+ return fParameterTypeQualifiedNames;
+ }
+
+ protected void setParameterNames(String[] parameterNames) {
+ fParameterNames = (parameterNames == null ?
+ new String[0] : parameterNames);
+ }
+
+ public String[] getParameterNames() {
+ return fParameterNames;
+ }
+
+ protected void setReturnTypeQualifiedName(String returnTypeQualifiedName) {
+ fReturnTypeQualifiedName = returnTypeQualifiedName;
+ }
+
+ public String getReturnTypeQualifiedName() {
+ return fReturnTypeQualifiedName;
+ }
+
+ public int getNumberOfParameters() {
+ return (getParameterNames() == null ? 0 : getParameterNames().length);
+ }
+
+ public IType getReturnType() {
+ try {
+ return getSourceType().getJavaProject().findType(getReturnTypeQualifiedName());
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+
+ public boolean isConstructor () {
+ return getDeclaringTypeQualifiedName().equals(getName());
+ }
+
+ public boolean isGetter() {
+ return (getName().startsWith("get") && !getName().equals("get")) || getName().startsWith("is");
+ }
+
+ public boolean isSetter() {
+ return (getName().startsWith("set") && !getName().equals("set"));
+ }
+
+ @Override
+ public IType getMemberType() {
+ return getReturnType();
+ }
+
+ @Override
+ public IJavaElement getJavaElement () {
+ try {
+ IType declType = getSourceType().getJavaProject().findType(getDeclaringTypeQualifiedName());
+
+ IMethod[] allMethods = declType.getMethods();
+
+ // filter methods by name
+ List<IMethod> methods = new ArrayList<IMethod>();
+ for (int i = 0; allMethods != null && i < allMethods.length; i++) {
+ if (allMethods[i].getElementName().equals(getName())) {
+ methods.add(allMethods[i]);
+ }
+ }
+ if (methods.isEmpty())
+ return null;
+ if (methods.size() == 1)
+ return methods.get(0);
+
+ // filter methods by number of parameters
+ List<IMethod> filteredMethods = new ArrayList<IMethod>();
+ for (IMethod method : methods) {
+ if (method.getNumberOfParameters() == getNumberOfParameters())
+ filteredMethods.add(method);
+ }
+ if (filteredMethods.isEmpty())
+ return null;
+ if (filteredMethods.size() == 1)
+ return filteredMethods.get(0);
+
+ methods = filteredMethods;
+
+ // filter methods by parameter types
+ for(IMethod method : methods) {
+ String[] methodParameterTypes =
+ resolveSignatures(method.getDeclaringType(),
+ method.getParameterTypes());
+ String[] parameterTypes = getParameterTypeQualifiedNames();
+
+ boolean equal = true;
+ for (int i = 0; parameterTypes != null && i < parameterTypes.length; i++) {
+ // simple types must be equal, but complex types may not
+ if (!parameterTypes[i].equals(methodParameterTypes[i])) {
+ // sure - it's Complex Type
+ if (! (parameterTypes[i].indexOf('.') != -1)
+ && (methodParameterTypes[i].indexOf('.') == -1)) {
+ equal = false;
+ break;
+ }
+ }
+ }
+ if (equal)
+ return method;
+ }
+ return null;
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+ }
+
+ ICompletionRequestor fRequestor = new ICompletionRequestor() {
+
+ public void acceptAnonymousType(
+ char[] superTypePackageName,
+ char[] superTypeName,
+ char[][] parameterPackageNames,
+ char[][] parameterTypeNames,
+ char[][] parameterNames, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptClass(char[] packageName,
+ char[] className, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptError(IProblem error) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptField(
+ char[] declaringTypePackageName,
+ char[] declaringTypeName, char[] name,
+ char[] typePackageName, char[] typeName,
+ char[] completionName, int modifiers,
+ int completionStart, int completionEnd,
+ int relevance) {
+
+ FieldInfo info = new FieldInfo(TypeInfoCollector.this.fType,
+ getQualifiedClassNameFromChars(declaringTypePackageName, declaringTypeName),
+ String.valueOf(name), modifiers,
+ getQualifiedClassNameFromChars(typePackageName, typeName));
+ fFields.add(info);
+ }
+
+ public void acceptInterface(char[] packageName,
+ char[] interfaceName, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptKeyword(char[] keywordName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptLabel(char[] labelName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptLocalVariable(char[] name,
+ char[] typePackageName, char[] typeName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptMethod(
+ char[] declaringTypePackageName,
+ char[] declaringTypeName, char[] selector,
+ char[][] parameterPackageNames,
+ char[][] parameterTypeNames,
+ char[][] parameterNames,
+ char[] returnTypePackageName,
+ char[] returnTypeName, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+
+ MethodInfo info = new MethodInfo(TypeInfoCollector.this.fType,
+ getQualifiedClassNameFromChars(declaringTypePackageName, declaringTypeName),
+ String.valueOf(selector), modifiers,
+ getQualifiedClassNameFromCharArray(parameterPackageNames, parameterTypeNames),
+ convertToStringArray(parameterNames),
+ getQualifiedClassNameFromChars(returnTypePackageName, returnTypeName));
+ fMethods.add(info);
+ }
+
+ public void acceptMethodDeclaration(
+ char[] declaringTypePackageName,
+ char[] declaringTypeName, char[] selector,
+ char[][] parameterPackageNames,
+ char[][] parameterTypeNames,
+ char[][] parameterNames,
+ char[] returnTypePackageName,
+ char[] returnTypeName, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptModifier(char[] modifierName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptPackage(char[] packageName,
+ char[] completionName, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptType(char[] packageName,
+ char[] typeName, char[] completionName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptVariableName(char[] typePackageName,
+ char[] typeName, char[] name,
+ char[] completionName, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+
+ public TypeInfoCollector(IType type) {
+ this.fType = type;
+ }
+
+ public void collectInfo() {
+ if (fMethods == null) {
+ fMethods = new ArrayList<MethodInfo>();
+ } else {
+ fMethods.clear();
+ }
+
+ if (fFields == null) {
+ fFields = new ArrayList<FieldInfo>();
+ } else {
+ fFields.clear();
+ }
+
+ if (fType == null)
+ return;
+ try {
+ fType.codeComplete("".toCharArray(), -1, 0, new char[0][0], new char[0][0], new int[0], false, fRequestor);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+
+ public MemberInfo[] getAllMethodInfos() {
+ List<MemberInfo> methods = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor())
+ methods.add(info);
+ }
+ return methods.toArray(new MemberInfo[0]);
+ }
+
+ /**
+ * Returns the methods for the type specified
+ *
+ * @return
+ */
+ public List<MemberInfo> getMethods() {
+ List<MemberInfo> methods = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor()
+ && !info.isGetter() && !info.isSetter())
+ methods.add(info);
+ }
+ return methods;
+ }
+
+ /**
+ * Returns the method presentation strings for the type specified
+ *
+ * @param type
+ * @return
+ */
+ public Set<String> getMethodPresentations() {
+ Set<String> methods = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+// IMethod[] mthds = type.getMethods();
+ List<MemberInfo> mthds = getMethods();
+ for (MemberInfo info : mthds) {
+ if (!(info instanceof MethodInfo))
+ continue;
+
+ MethodInfo method = (MethodInfo)info;
+
+ StringBuffer name = new StringBuffer(method.getName());
+
+ // Add method as 'foo'
+ methods.add(name.toString());
+
+ // Add method as 'foo(param1,param2)'
+ name.append('(');
+ String[] mParams = method.getParameterNames();
+ for (int j = 0; mParams != null && j < mParams.length; j++) {
+ if (j > 0) name.append(", "); //$NON-NLS-1$
+ name.append(mParams[j]);
+ }
+ name.append(')');
+
+ methods.add(name.toString());
+ }
+ return methods;
+ }
+
+ /**
+ * Returns the properties for the type specified
+ *
+ * @return
+ */
+ public List<MemberInfo> getProperties() {
+ List<MemberInfo> properties = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor()
+ && (info.isGetter() || info.isSetter()))
+ properties.add(info);
+ }
+ for (FieldInfo info : fFields) {
+ if (info.isPublic())
+ properties.add(info);
+ }
+
+
+ return properties;
+ }
+
+
+ /**
+ * Returns the property presentation strings for the type specified
+ *
+ * @return
+ */
+ public Set<String> getPropertyPresentations() {
+ return getPropertyPresentations(null);
+ }
+
+ /**
+ * Returns the property presentation strings for the type specified
+ *
+ * @param unpairedGettersOrSetters - map of unpaired getters or setters of type's properties. 'key' is property name.
+ * @return
+ */
+ public Set<String> getPropertyPresentations(Map<String, MethodInfo> unpairedGettersOrSetters) {
+ Set<String> properties = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ List<MemberInfo> props = getProperties();
+ HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
+ HashMap<String, MethodInfo> setters = new HashMap<String, MethodInfo>();
+ for (MemberInfo info : props) {
+ if (info instanceof MethodInfo) {
+ MethodInfo m = (MethodInfo)info;
+
+ if (m.isGetter() || m.isSetter()) {
+ StringBuffer name = new StringBuffer(m.getName());
+ if(m.getName().startsWith("i")) { //$NON-NLS-1$
+ name.delete(0, 2);
+ } else {
+ name.delete(0, 3);
+ }
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ String propertyName = name.toString();
+ if(!properties.contains(propertyName)) {
+ properties.add(propertyName);
+ }
+ if(unpairedGettersOrSetters!=null) {
+ MethodInfo previousGetter = getters.get(propertyName);
+ MethodInfo previousSetter = setters.get(propertyName);
+ if((previousGetter!=null && m.isSetter())||(previousSetter!=null && m.isGetter())) {
+ // We have both Getter and Setter
+ unpairedGettersOrSetters.remove(propertyName);
+ } else if(m.isSetter()) {
+ setters.put(propertyName, m);
+ unpairedGettersOrSetters.put(propertyName, m);
+ } else if(m.isGetter()) {
+ getters.put(propertyName, m);
+ unpairedGettersOrSetters.put(propertyName, m);
+ }
+ }
+ }
+ } else {
+ properties.add(info.getName());
+ }
+ }
+ return properties;
+ }
+
+ public static MemberInfo createMemberInfo(IMember member) {
+
+ try {
+ if (member instanceof IType)
+ return new TypeInfo((IType)member);
+ else if (member instanceof IField)
+ return new FieldInfo((IField)member);
+ else if (member instanceof IMethod)
+ return new MethodInfo((IMethod)member);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+
+ return null;
+ }
+
+ static String[] resolveSignatures (IType type, String[] signatures) {
+ if (signatures == null || signatures.length == 0)
+ return new String[0];
+
+ String[] resolvedSignatures = new String[signatures.length];
+ for (int i = 0; i < signatures.length; i++) {
+ resolvedSignatures[i] = EclipseJavaUtil.resolveTypeAsString(type, signatures[i]);
+ }
+ return resolvedSignatures;
+ }
+
+ static String[] convertToStringArray(char[][] names) {
+ if (names == null || names.length == 0)
+ return new String[0];
+ String[] sNames = new String[names.length];
+ for (int i = 0; i < sNames.length; i++) {
+ sNames[i] = String.valueOf(names[i]);
+ }
+ return sNames;
+ }
+
+ static String[] getQualifiedClassNameFromCharArray (char[][] packageNames, char[][] classNames) {
+ if (packageNames == null || packageNames.length == 0)
+ return new String[0];
+ String[] qualifiedNames = new String[packageNames.length];
+ for (int i = 0; i < qualifiedNames.length; i++) {
+ qualifiedNames[i] = getQualifiedClassNameFromChars(packageNames[i], classNames[i]);
+ }
+ return qualifiedNames;
+ }
+
+ public static String getQualifiedClassNameFromChars (char[] packageName, char[] className) {
+ StringBuffer qualifiedName = new StringBuffer();
+ if (packageName != null && packageName.length > 0)
+ qualifiedName.append(packageName).append('.');
+ qualifiedName.append(className);
+ return qualifiedName.toString();
+ }
+
+ public static String getQualifiedClassName (String packageName, String className) {
+ StringBuffer qualifiedName = new StringBuffer();
+ if (packageName != null && packageName.length() > 0)
+ qualifiedName.append(packageName).append('.');
+ qualifiedName.append(className);
+ return qualifiedName.toString();
+ }
+
+}
Property changes on: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2007-11-01 19:50:18 UTC (rev 4647)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2007-11-01 19:57:36 UTC (rev 4648)
@@ -54,6 +54,7 @@
import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
import org.jboss.tools.seam.internal.core.el.SeamELOperandTokenizer;
import org.jboss.tools.seam.internal.core.el.SeamELTokenizer;
+import org.jboss.tools.seam.internal.core.el.TypeInfoCollector;
/**
* EL Validator
@@ -277,7 +278,7 @@
}
Set<ISeamContextVariable> usedVariables = new HashSet<ISeamContextVariable>();
- Map<String, IMethod> unpairedGettersOrSetters = new HashMap<String, IMethod>();
+ Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters = new HashMap<String, TypeInfoCollector.MethodInfo>();
List<String> suggestions = engine.getCompletions(project, file, operand, prefix, position, true, usedVariables, unpairedGettersOrSetters);
@@ -293,8 +294,8 @@
// Check pair for getter/setter
if(unpairedGettersOrSetters.size()>0) {
- IMethod unpairedMethod = unpairedGettersOrSetters.values().iterator().next();
- String methodName = unpairedMethod.getElementName();
+ TypeInfoCollector.MethodInfo unpairedMethod = unpairedGettersOrSetters.values().iterator().next();
+ String methodName = unpairedMethod.getName();
String propertyName = unpairedGettersOrSetters.keySet().iterator().next();
String missingMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_SETTER;
String existedMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_GETTER;
17 years, 2 months
JBoss Tools SVN: r4647 - in trunk/vpe/plugins: org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2007-11-01 15:50:18 -0400 (Thu, 01 Nov 2007)
New Revision: 4647
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.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/util/VpeDndUtil.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1143
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 2007-11-01 19:49:18 UTC (rev 4646)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-11-01 19:50:18 UTC (rev 4647)
@@ -65,16 +65,14 @@
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.VpeDebugUtil;
-import org.jboss.tools.vpe.editor.util.VpeDndUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
+import org.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMHTMLInputElement;
import org.mozilla.interfaces.nsIDOMMouseEvent;
-import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMRange;
@@ -88,1956 +86,1965 @@
import org.w3c.dom.NodeList;
public class VpeVisualDomBuilder extends VpeDomBuilder {
- /** REGEX_EL */
- private static final Pattern REGEX_EL = Pattern.compile("[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL);
-
- private static final String PSEUDO_ELEMENT = "br";
- private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element";
- private static final String INIT_ELEMENT_ATTR = "vpe:init-element";
- private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS";
- private static final String COMMENT_STYLE = "font-style:italic; color:green";
- private static final String COMMENT_PREFIX = "";
- private static final String COMMENT_SUFFIX = "";
- private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element";
- private static final int DRAG_AREA_WIDTH = 10;
- private static final int DRAG_AREA_HEIGHT = 10;
- private static final String ATTR_XMLNS = "xmlns";
+ /** REGEX_EL */
+ private static final Pattern REGEX_EL = Pattern.compile(
+ "[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL);
- private MozillaEditor visualEditor;
- private XulRunnerEditor xulRunnerEditor;
- private nsIDOMDocument visualDocument;
- private nsIDOMElement visualContentArea;
- private VpePageContext pageContext;
- private VpeDnD dnd;
- private nsIDOMNode headNode;
- private List includeStack;
- boolean rebuildFlag = false;
-
- /** faceletFile */
- private boolean faceletFile = false;
+ private static final String PSEUDO_ELEMENT = "br";
+ private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element";
+ private static final String INIT_ELEMENT_ATTR = "vpe:init-element";
+ private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS";
+ private static final String COMMENT_STYLE = "font-style:italic; color:green";
+ private static final String COMMENT_PREFIX = "";
+ private static final String COMMENT_SUFFIX = "";
+ private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element";
+ private static final int DRAG_AREA_WIDTH = 10;
+ private static final int DRAG_AREA_HEIGHT = 10;
+ private static final String ATTR_XMLNS = "xmlns";
- private static final String ATTR_VPE = "vpe";
- private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink";
+ private MozillaEditor visualEditor;
+ private XulRunnerEditor xulRunnerEditor;
+ private nsIDOMDocument visualDocument;
+ private nsIDOMElement visualContentArea;
+ private VpePageContext pageContext;
+ private VpeDnD dnd;
+ private nsIDOMNode headNode;
+ private List includeStack;
+ boolean rebuildFlag = false;
- private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet";
+ /** faceletFile */
+ private boolean faceletFile = false;
- private static final String YES_STRING = "yes";
- private static final String NO_STRING = "no";
- private static final String ZERO_STRING = "0";
- private static final String EMPTY_STRING = "";
+ private static final String ATTR_VPE = "vpe";
+ private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink";
- private static final String ATRIBUTE_BORDER = "border";
- private static final String ATRIBUTE_CELLSPACING = "cellspacing";
- private static final String ATRIBUTE_CELLPADDING = "cellpadding";
+ private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet";
- private static final String DOTTED_BORDER_STYLE = "border : 1px dotted #808080";
- private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted #808080";
- private static final String DOTTED_BORDER_STYLE_FOR_TD = "border-left : 1px dotted #808080; border-right : 1px dotted #808080; border-top : 1px dotted #808080; border-bottom : 0px; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only";
- private static final String DOTTED_BORDER_STYLE_FOR_SPAN = "border : 1px solid #0051DD; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only";
+ private static final String YES_STRING = "yes";
+ private static final String NO_STRING = "no";
+ private static final String ZERO_STRING = "0";
+ private static final String EMPTY_STRING = "";
- static private HashSet<String> unborderedSourceNodes = new HashSet<String>();
- static {
- unborderedSourceNodes.add(HTML.TAG_HTML);
- unborderedSourceNodes.add(HTML.TAG_HEAD);
- unborderedSourceNodes.add(HTML.TAG_BODY);
+ private static final String ATRIBUTE_BORDER = "border";
+ private static final String ATRIBUTE_CELLSPACING = "cellspacing";
+ private static final String ATRIBUTE_CELLPADDING = "cellpadding";
+
+ private static final String DOTTED_BORDER_STYLE = "border : 1px dotted #808080";
+ private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted #808080";
+ private static final String DOTTED_BORDER_STYLE_FOR_TD = "border-left : 1px dotted #808080; border-right : 1px dotted #808080; border-top : 1px dotted #808080; border-bottom : 0px; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only";
+ private static final String DOTTED_BORDER_STYLE_FOR_SPAN = "border : 1px solid #0051DD; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only";
+
+ static private HashSet<String> unborderedSourceNodes = new HashSet<String>();
+ static {
+ unborderedSourceNodes.add(HTML.TAG_HTML);
+ unborderedSourceNodes.add(HTML.TAG_HEAD);
+ unborderedSourceNodes.add(HTML.TAG_BODY);
+ }
+
+ static private HashSet<String> unborderedVisualNodes = new HashSet<String>();
+ static {
+ unborderedVisualNodes.add(HTML.TAG_TBODY);
+ unborderedVisualNodes.add(HTML.TAG_THEAD);
+ unborderedVisualNodes.add(HTML.TAG_TR);
+ unborderedVisualNodes.add(HTML.TAG_TD);
+ unborderedVisualNodes.add(HTML.TAG_COL);
+ unborderedVisualNodes.add(HTML.TAG_COLS);
+ unborderedVisualNodes.add(HTML.TAG_COLGROUP);
+ unborderedVisualNodes.add(HTML.TAG_LI);
+ unborderedVisualNodes.add(HTML.TAG_BR);
+ }
+ private VpeDnd dropper;
+
+ public VpeVisualDomBuilder(VpeDomMapping domMapping,
+ INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
+ MozillaEditor visualEditor, VpePageContext pageContext) {
+ super(domMapping, sorceAdapter, templateManager);
+ this.visualEditor = visualEditor;
+ xulRunnerEditor = visualEditor.getXulRunnerEditor();
+ this.visualDocument = visualEditor.getDomDocument();
+ this.visualContentArea = visualEditor.getContentArea();
+ this.dnd = new VpeDnD();
+ this.pageContext = pageContext;
+ this.headNode = visualEditor.getHeadNode();
+ dropper = new VpeDnd();
+ dropper.setDndData(false, true);
+
+ if (isFacelet()) {
+ faceletFile = true;
+ } else {
+ faceletFile = false;
}
- static private HashSet<String> unborderedVisualNodes = new HashSet<String>();
- static {
- unborderedVisualNodes.add(HTML.TAG_TBODY);
- unborderedVisualNodes.add(HTML.TAG_THEAD);
- unborderedVisualNodes.add(HTML.TAG_TR);
- unborderedVisualNodes.add(HTML.TAG_TD);
- unborderedVisualNodes.add(HTML.TAG_COL);
- unborderedVisualNodes.add(HTML.TAG_COLS);
- unborderedVisualNodes.add(HTML.TAG_COLGROUP);
- unborderedVisualNodes.add(HTML.TAG_LI);
- unborderedVisualNodes.add(HTML.TAG_BR);
+ }
+
+ public void buildDom(Document sourceDocument) {
+ includeStack = new ArrayList();
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) input).getFile();
+ if (file != null) {
+ includeStack.add(new VpeIncludeInfo(null, file, pageContext
+ .getSourceBuilder().getSourceDocument()));
+ }
}
- private VpeDnd dropper;
+ pageContext.refreshConnector();
+ pageContext.installIncludeElements();
+ addChildren(null, sourceDocument, visualContentArea);
+ registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
+ }
- public VpeVisualDomBuilder(VpeDomMapping domMapping,
- INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
- MozillaEditor visualEditor, VpePageContext pageContext) {
- super(domMapping, sorceAdapter, templateManager);
- this.visualEditor = visualEditor;
- xulRunnerEditor = visualEditor.getXulRunnerEditor();
- this.visualDocument = visualEditor.getDomDocument();
- this.visualContentArea = visualEditor.getContentArea();
- this.dnd = new VpeDnD();
- this.pageContext = pageContext;
- this.headNode = visualEditor.getHeadNode();
- dropper = new VpeDnd();
- dropper.setDndData(false, true);
-
- if ( isFacelet() ) {
- faceletFile = true;
- } else {
- faceletFile = false;
- }
+ public void rebuildDom(Document sourceDocument) {
+ cleanHead();
+ domMapping.clear(visualContentArea);
+ pageContext.clearAll();
+ refreshExternalLinks();
+ pageContext.getBundle().refreshRegisteredBundles();
+ nsIDOMNodeList children = visualContentArea.getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ visualContentArea.removeChild(children.item(i));
}
- public void buildDom(Document sourceDocument) {
- includeStack = new ArrayList();
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- if (input instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput) input).getFile();
- if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file, pageContext
- .getSourceBuilder().getSourceDocument()));
- }
- }
- pageContext.refreshConnector();
- pageContext.installIncludeElements();
- addChildren(null, sourceDocument, visualContentArea);
- registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
+ if (sourceDocument != null) {
+ buildDom(sourceDocument);
}
- public void rebuildDom(Document sourceDocument) {
- cleanHead();
- domMapping.clear(visualContentArea);
- pageContext.clearAll();
- refreshExternalLinks();
- pageContext.getBundle().refreshRegisteredBundles();
+ rebuildFlag = true;
+ }
- nsIDOMNodeList children = visualContentArea.getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- visualContentArea.removeChild(children.item(i));
- }
+ // temporary, will be change to prefference's variable
+ // private boolean borderVisible = true;
- if (sourceDocument != null) {
- buildDom(sourceDocument);
- }
-
- rebuildFlag = true;
+ private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode,
+ nsIDOMNode visualContainer) {
+ nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
+ // Fix for JBIDE-1097
+ try {
+ if (visualNewNode != null) {
+ nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode
+ .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
+ iDOMInputElement.setReadOnly(true);
+ }
+ } catch (XPCOMException ex) {
+ // just ignore this exception
}
+ if (visualNewNode != null) {
+ if (visualNextNode == null) {
+ visualContainer.appendChild(visualNewNode);
+ } else {
+ visualContainer.insertBefore(visualNewNode, visualNextNode);
+ }
+ return true;
+ }
- // temporary, will be change to prefference's variable
- // private boolean borderVisible = true;
+ return false;
+ }
- private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode,
- nsIDOMNode visualContainer) {
- nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
- //Fix for JBIDE-1097
- try {
- if(visualNewNode!=null) {
- nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode.queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
- iDOMInputElement.setReadOnly(true);
- }
- } catch(XPCOMException ex) {
- //just ignore this exception
- }
- if (visualNewNode != null) {
- if (visualNextNode == null) {
- visualContainer.appendChild(visualNewNode);
- } else {
- visualContainer.insertBefore(visualNewNode, visualNextNode);
- }
- return true;
- }
-
- return false;
+ private nsIDOMElement createBorder(Node sourceNode,
+ nsIDOMElement visualNode, boolean block) {
+ nsIDOMElement border = null;
+ if (visualNode == null)
+ return null;
+ if (unborderedSourceNodes.contains(sourceNode.getNodeName()
+ .toLowerCase()))
+ return null;
+ if (unborderedVisualNodes.contains(visualNode.getNodeName()
+ .toLowerCase()))
+ return null;
+ if (HTML.TAG_IMG.equalsIgnoreCase(visualNode.getNodeName())) {
+ String width = visualNode.getAttribute(ATRIBUTE_BORDER);
+ if (width == null || ZERO_STRING.equalsIgnoreCase(width)
+ || EMPTY_STRING.equalsIgnoreCase(width)) {
+ String style = visualNode
+ .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style,
+ ATRIBUTE_BORDER, DOTTED_BORDER_STYLE_FOR_IMG);
+ visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
+ return null;
}
+ if (block) {
+ if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
+ border = visualDocument.createElement(HTML.TAG_TABLE);
+ border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
+ border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
- private nsIDOMElement createBorder(Node sourceNode,
- nsIDOMElement visualNode, boolean block) {
- nsIDOMElement border = null;
- if (visualNode == null)
- return null;
- if (unborderedSourceNodes.contains(sourceNode.getNodeName()
- .toLowerCase()))
- return null;
- if (unborderedVisualNodes.contains(visualNode.getNodeName()
- .toLowerCase()))
- return null;
- if (HTML.TAG_IMG.equalsIgnoreCase(visualNode.getNodeName())) {
- String width = visualNode.getAttribute(ATRIBUTE_BORDER);
- if (width == null || ZERO_STRING.equalsIgnoreCase(width)
- || EMPTY_STRING.equalsIgnoreCase(width)) {
- String style = visualNode
- .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style,
- ATRIBUTE_BORDER, DOTTED_BORDER_STYLE_FOR_IMG);
- visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
- return null;
- }
- if (block) {
- if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
- border = visualDocument.createElement(HTML.TAG_TABLE);
- border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
- border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
+ nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr1);
+ nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
+ td1.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE_FOR_TD);
+ nsIDOMText text = visualDocument.createTextNode(sourceNode
+ .getNodeName());
+ td1.appendChild(text);
+ tr1.appendChild(td1);
+ nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr2);
+ nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
+ tr2.appendChild(td2);
+ nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ td2.appendChild(p);
- nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr1);
- nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
- td1.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE_FOR_TD);
- nsIDOMText text = visualDocument.createTextNode(sourceNode
- .getNodeName());
- td1.appendChild(text);
- tr1.appendChild(td1);
- nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr2);
- nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
- tr2.appendChild(td2);
- nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
- p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- td2.appendChild(p);
+ p.appendChild(visualNode);
- p.appendChild(visualNode);
+ } else {
+ border = visualDocument.createElement(HTML.TAG_TABLE);
+ border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
+ border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
- } else {
- border = visualDocument.createElement(HTML.TAG_TABLE);
- border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
- border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
+ nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr2);
+ nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
+ tr2.appendChild(td2);
+ nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ td2.appendChild(p);
- nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr2);
- nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
- tr2.appendChild(td2);
- nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
- p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- td2.appendChild(p);
+ p.appendChild(visualNode);
+ }
+ } else {
+ border = visualDocument.createElement(HTML.TAG_SPAN);
+ border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
+ nsIDOMElement name = visualDocument
+ .createElement(HTML.TAG_SPAN);
+ name.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE_FOR_SPAN);
+ nsIDOMText text = visualDocument.createTextNode(sourceNode
+ .getNodeName());
+ name.appendChild(text);
+ border.appendChild(name);
+ }
+ border.appendChild(visualNode);
+ }
+ if (VpeStyleUtil.getAbsolute((Element) sourceNode) && border != null) {
+ int top = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_TOP);
+ int left = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_LEFT);
- p.appendChild(visualNode);
- }
- } else {
- border = visualDocument.createElement(HTML.TAG_SPAN);
- border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
- nsIDOMElement name = visualDocument
- .createElement(HTML.TAG_SPAN);
- name.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE_FOR_SPAN);
- nsIDOMText text = visualDocument.createTextNode(sourceNode
- .getNodeName());
- name.appendChild(text);
- border.appendChild(name);
- }
- border.appendChild(visualNode);
- }
- if (VpeStyleUtil.getAbsolute((Element) sourceNode) && border != null) {
- int top = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
- VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
- + VpeStyleUtil.PARAMETER_TOP);
- int left = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
- VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
- + VpeStyleUtil.PARAMETER_LEFT);
+ String style = visualNode
+ .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_POSITION,
+ VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
+ visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- String style = visualNode
- .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_POSITION,
- VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
- visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
-
- style = border.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setAbsolute(style);
- if (top != -1)
- style = VpeStyleUtil.setSizeInStyle(style,
- VpeStyleUtil.PARAMETER_TOP, top);
- if (left != -1)
- style = VpeStyleUtil.setSizeInStyle(style,
- VpeStyleUtil.PARAMETER_LEFT, left);
- border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
- return border;
+ style = border.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setAbsolute(style);
+ if (top != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_TOP, top);
+ if (left != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_LEFT, left);
+ border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
}
+ return border;
+ }
- protected nsIDOMNode createNode(Node sourceNode,
- nsIDOMNode visualOldContainer) {
- boolean registerFlag = isCurrentMainDocument();
- switch (sourceNode.getNodeType()) {
- case Node.ELEMENT_NODE:
- Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
- Set<Node> ifDependencySet = new HashSet<Node>();
- pageContext.setCurrentVisualNode(visualOldContainer);
- VpeTemplate template = templateManager.getTemplate(pageContext,
- (Element) sourceNode, ifDependencySet);
+ protected nsIDOMNode createNode(Node sourceNode,
+ nsIDOMNode visualOldContainer) {
+ boolean registerFlag = isCurrentMainDocument();
+ switch (sourceNode.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
+ Set<Node> ifDependencySet = new HashSet<Node>();
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ VpeTemplate template = templateManager.getTemplate(pageContext,
+ (Element) sourceNode, ifDependencySet);
- VpeCreationData creationData = template.create(pageContext,
- sourceNode, visualDocument);
- pageContext.setCurrentVisualNode(null);
- nsIDOMElement visualNewElement = (nsIDOMElement) creationData
- .getNode();
+ VpeCreationData creationData = template.create(pageContext,
+ sourceNode, visualDocument);
+ pageContext.setCurrentVisualNode(null);
+ nsIDOMElement visualNewElement = (nsIDOMElement) creationData
+ .getNode();
- if (visualNewElement != null)
- correctVisualAttribute(visualNewElement);
+ if (visualNewElement != null)
+ correctVisualAttribute(visualNewElement);
- nsIDOMElement border = null;
- setTooltip((Element) sourceNode, visualNewElement);
- if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS
- .getValue())
- && visualNewElement != null) {
- boolean block = true;
- if (template.getTagDescription(null, null, null,
- visualNewElement, null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
- block = false;
- }
- border = createBorder(sourceNode, visualNewElement, block);
- }
- if (!isCurrentMainDocument() && visualNewElement != null) {
- setReadOnlyElement(visualNewElement);
- }
- if (registerFlag) {
- VpeElementMapping elementMapping = new VpeElementMapping(
- (Element) sourceNode, visualNewElement, border,
- template, ifDependencySet, creationData.getData());
- elementMapping.setXmlnsMap(xmlnsMap);
- registerNodes(elementMapping);
- }
- if (template.isChildren()) {
- List<?> childrenInfoList = creationData.getChildrenInfoList();
- if (childrenInfoList == null) {
- addChildren(template, sourceNode,
- visualNewElement != null ? visualNewElement
- : visualOldContainer);
- } else {
- addChildren(template, sourceNode, visualOldContainer,
- childrenInfoList);
- }
- }
- pageContext.setCurrentVisualNode(visualOldContainer);
- template.validate(pageContext, (Element) sourceNode,
- visualDocument, creationData);
- pageContext.setCurrentVisualNode(null);
- if (border != null)
- return border;
- else
- return visualNewElement;
- case Node.TEXT_NODE:
- return createTextNode(sourceNode, registerFlag);
- case Node.COMMENT_NODE:
- if (!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
- return null;
- }
- nsIDOMElement visualNewComment = createComment(sourceNode);
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
- }
- return visualNewComment;
+ nsIDOMElement border = null;
+ setTooltip((Element) sourceNode, visualNewElement);
+ if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS
+ .getValue())
+ && visualNewElement != null) {
+ boolean block = true;
+ if (template.getTagDescription(null, null, null,
+ visualNewElement, null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
+ block = false;
}
+ border = createBorder(sourceNode, visualNewElement, block);
+ }
+ if (!isCurrentMainDocument() && visualNewElement != null) {
+ setReadOnlyElement(visualNewElement);
+ }
+ if (registerFlag) {
+ VpeElementMapping elementMapping = new VpeElementMapping(
+ (Element) sourceNode, visualNewElement, border,
+ template, ifDependencySet, creationData.getData());
+ elementMapping.setXmlnsMap(xmlnsMap);
+ registerNodes(elementMapping);
+ }
+ if (template.isChildren()) {
+ List<?> childrenInfoList = creationData.getChildrenInfoList();
+ if (childrenInfoList == null) {
+ addChildren(template, sourceNode,
+ visualNewElement != null ? visualNewElement
+ : visualOldContainer);
+ } else {
+ addChildren(template, sourceNode, visualOldContainer,
+ childrenInfoList);
+ }
+ }
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ template.validate(pageContext, (Element) sourceNode,
+ visualDocument, creationData);
+ pageContext.setCurrentVisualNode(null);
+ if (border != null)
+ return border;
+ else
+ return visualNewElement;
+ case Node.TEXT_NODE:
+ return createTextNode(sourceNode, registerFlag);
+ case Node.COMMENT_NODE:
+ if (!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
return null;
+ }
+ nsIDOMElement visualNewComment = createComment(sourceNode);
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
+ }
+ return visualNewComment;
}
+ return null;
+ }
- private void correctVisualAttribute(nsIDOMElement element) {
+ private void correctVisualAttribute(nsIDOMElement element) {
- String styleValue = element.getAttribute(HTML.TAG_STYLE);
- String backgroundValue = element
- .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
+ String styleValue = element.getAttribute(HTML.TAG_STYLE);
+ String backgroundValue = element
+ .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
- if (styleValue != null) {
- styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
- pageContext.getEditPart().getEditorInput());
- element.setAttribute(HTML.TAG_STYLE, styleValue);
- }
- if (backgroundValue != null) {
- backgroundValue = VpeStyleUtil
- .addFullPathIntoBackgroundValue(backgroundValue,
- pageContext.getEditPart().getEditorInput());
- element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
- backgroundValue);
- }
+ if (styleValue != null) {
+ styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(HTML.TAG_STYLE, styleValue);
}
+ if (backgroundValue != null) {
+ backgroundValue = VpeStyleUtil
+ .addFullPathIntoBackgroundValue(backgroundValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
+ backgroundValue);
+ }
+ }
- protected nsIDOMElement createComment(Node sourceNode) {
- nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
- String value = COMMENT_PREFIX + sourceNode.getNodeValue()
- + COMMENT_SUFFIX;
- nsIDOMText text = visualDocument.createTextNode(value);
- div.appendChild(text);
- return div;
+ protected nsIDOMElement createComment(Node sourceNode) {
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
+ String value = COMMENT_PREFIX + sourceNode.getNodeValue()
+ + COMMENT_SUFFIX;
+ nsIDOMText text = visualDocument.createTextNode(value);
+ div.appendChild(text);
+ return div;
+ }
+
+ protected void addChildren(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
+ NodeList sourceNodes = sourceContainer.getChildNodes();
+ int len = sourceNodes.getLength();
+ int childrenCount = 0;
+ for (int i = 0; i < len; i++) {
+ Node sourceNode = sourceNodes.item(i);
+ if (addNode(sourceNode, null, visualContainer)) {
+ childrenCount++;
+ }
}
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
+ }
+ }
- protected void addChildren(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
- NodeList sourceNodes = sourceContainer.getChildNodes();
- int len = sourceNodes.getLength();
- int childrenCount = 0;
- for (int i = 0; i < len; i++) {
- Node sourceNode = sourceNodes.item(i);
- if (addNode(sourceNode, null, visualContainer)) {
- childrenCount++;
- }
+ protected void addChildren(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualOldContainer,
+ List<?> childrenInfoList) {
+ for (int i = 0; i < childrenInfoList.size(); i++) {
+ VpeChildrenInfo info = (VpeChildrenInfo) childrenInfoList.get(i);
+ nsIDOMNode visualParent = info.getVisualParent();
+ if (visualParent == null)
+ visualParent = visualOldContainer;
+ List<?> sourceChildren = info.getSourceChildren();
+ int childrenCount = 0;
+ if (sourceChildren != null) {
+ for (int j = 0; j < sourceChildren.size(); j++) {
+ if (addNode((Node) sourceChildren.get(j), null,
+ visualParent)) {
+ childrenCount++;
+ }
}
- if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
- }
+ }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualParent);
+ }
}
+ }
- protected void addChildren(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualOldContainer,
- List<?> childrenInfoList) {
- for (int i = 0; i < childrenInfoList.size(); i++) {
- VpeChildrenInfo info = (VpeChildrenInfo) childrenInfoList.get(i);
- nsIDOMNode visualParent = info.getVisualParent();
- if (visualParent == null)
- visualParent = visualOldContainer;
- List<?> sourceChildren = info.getSourceChildren();
- int childrenCount = 0;
- if (sourceChildren != null) {
- for (int j = 0; j < sourceChildren.size(); j++) {
- if (addNode((Node) sourceChildren.get(j), null,
- visualParent)) {
- childrenCount++;
- }
- }
- }
- if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualParent);
- }
- }
+ // /////////////////////////////////////////////////////////////////////////
+ public nsIDOMNode addStyleNodeToHead(String styleText) {
+ nsIDOMNode newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+
+ if (styleText != null) {
+ nsIDOMText newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
}
+ headNode.appendChild(newStyle);
+ return newStyle;
+ }
- // /////////////////////////////////////////////////////////////////////////
- public nsIDOMNode addStyleNodeToHead(String styleText) {
- nsIDOMNode newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode,
+ String styleText) {
+ nsIDOMElement newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
- if (styleText != null) {
- nsIDOMText newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
- headNode.appendChild(newStyle);
- return newStyle;
+ if (styleText != null) {
+ nsIDOMNode newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
}
- public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode,
- String styleText) {
- nsIDOMElement newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ headNode.replaceChild(newStyle, oldStyleNode);
+ return newStyle;
+ }
- if (styleText != null) {
- nsIDOMNode newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
+ public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
+ headNode.removeChild(oldStyleNode);
+ }
- headNode.replaceChild(newStyle, oldStyleNode);
- return newStyle;
+ void addExternalLinks() {
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
}
-
- public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
- headNode.removeChild(oldStyleNode);
+ ResourceReference[] l = null;
+ if (file != null) {
+ l = CSSReferenceList.getInstance().getAllResources(file);
}
-
- void addExternalLinks() {
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
- }
- ResourceReference[] l = null;
- if (file != null) {
- l = CSSReferenceList.getInstance().getAllResources(file);
- }
- if (l != null) {
- for (int i = 0; i < l.length; i++) {
- ResourceReference item = l[i];
- addLinkNodeToHead("file:///" + item.getLocation(), YES_STRING);
- }
- }
+ if (l != null) {
+ for (int i = 0; i < l.length; i++) {
+ ResourceReference item = l[i];
+ addLinkNodeToHead("file:///" + item.getLocation(), YES_STRING);
+ }
}
+ }
- void removeExternalLinks() {
- nsIDOMNodeList childs = headNode.getChildNodes();
- long length = childs.getLength();
- for (long i = length - 1; i >= 0; i--) {
- nsIDOMNode node = childs.item(i);
- if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- boolean isLink = false;
- boolean isStyle = false;
- if ((isLink = HTML.TAG_LINK
- .equalsIgnoreCase(node.getNodeName()))
- || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node
- .getNodeName()))) {
- nsIDOMElement element = (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE
- .equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
- && YES_STRING.equalsIgnoreCase(element
- .getAttribute("ext"))) {
- headNode.removeChild(node);
- }
- }
- }
+ void removeExternalLinks() {
+ nsIDOMNodeList childs = headNode.getChildNodes();
+ long length = childs.getLength();
+ for (long i = length - 1; i >= 0; i--) {
+ nsIDOMNode node = childs.item(i);
+ if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ boolean isLink = false;
+ boolean isStyle = false;
+ if ((isLink = HTML.TAG_LINK
+ .equalsIgnoreCase(node.getNodeName()))
+ || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node
+ .getNodeName()))) {
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
+ && YES_STRING.equalsIgnoreCase(element
+ .getAttribute("ext"))) {
+ headNode.removeChild(node);
+ }
}
+ }
}
+ }
- void refreshExternalLinks() {
- removeExternalLinks();
- addExternalLinks();
- }
+ void refreshExternalLinks() {
+ removeExternalLinks();
+ addExternalLinks();
+ }
- // ==========================================================
- void resetPseudoElement(nsIDOMNode visualNode) {
- if (visualNode != null) {
- nsIDOMNode visualParent = visualNode.getParentNode();
- if (visualParent != null) {
- PseudoInfo info = getPseudoInfo(visualParent);
- if (info.pseudoNode == null && !info.isElements) {
- addPseudoElementImpl(visualParent);
- } else if (info.pseudoNode != null && info.isElements) {
- visualParent.removeChild(info.pseudoNode);
- }
- }
+ // ==========================================================
+ void resetPseudoElement(nsIDOMNode visualNode) {
+ if (visualNode != null) {
+ nsIDOMNode visualParent = visualNode.getParentNode();
+ if (visualParent != null) {
+ PseudoInfo info = getPseudoInfo(visualParent);
+ if (info.pseudoNode == null && !info.isElements) {
+ addPseudoElementImpl(visualParent);
+ } else if (info.pseudoNode != null && info.isElements) {
+ visualParent.removeChild(info.pseudoNode);
}
+ }
}
+ }
- private PseudoInfo getPseudoInfo(nsIDOMNode visualParent) {
- nsIDOMNode pseudoNode = null;
- boolean isElements = false;
+ private PseudoInfo getPseudoInfo(nsIDOMNode visualParent) {
+ nsIDOMNode pseudoNode = null;
+ boolean isElements = false;
- if (visualParent == null)
- return new PseudoInfo();
- nsIDOMNodeList visualNodes = visualParent.getChildNodes();
- if (visualNodes == null)
- return new PseudoInfo();
+ if (visualParent == null)
+ return new PseudoInfo();
+ nsIDOMNodeList visualNodes = visualParent.getChildNodes();
+ if (visualNodes == null)
+ return new PseudoInfo();
- long length = visualNodes.getLength();
- for (long i = 0; i < length; i++) {
- nsIDOMNode visualNode = visualNodes.item(i);
- if (pseudoNode == null && isPseudoElement(visualNode)) {
- pseudoNode = visualNode;
- } else if (!isEmptyText(visualNode)) {
- isElements = true;
- }
- if (pseudoNode != null && isElements) {
- break;
- }
- }
- return new PseudoInfo(pseudoNode, isElements);
+ long length = visualNodes.getLength();
+ for (long i = 0; i < length; i++) {
+ nsIDOMNode visualNode = visualNodes.item(i);
+ if (pseudoNode == null && isPseudoElement(visualNode)) {
+ pseudoNode = visualNode;
+ } else if (!isEmptyText(visualNode)) {
+ isElements = true;
+ }
+ if (pseudoNode != null && isElements) {
+ break;
+ }
}
+ return new PseudoInfo(pseudoNode, isElements);
+ }
- static boolean isInitElement(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
+ static boolean isInitElement(nsIDOMNode visualNode) {
+ if (visualNode == null) {
+ return false;
+ }
- if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
- return false;
- }
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
- if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode)
- .getAttribute(INIT_ELEMENT_ATTR))) {
- return true;
- }
-
- return false;
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode)
+ .getAttribute(INIT_ELEMENT_ATTR))) {
+ return true;
}
- static boolean isPseudoElement(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
+ return false;
+ }
- if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
- return false;
- }
+ static boolean isPseudoElement(nsIDOMNode visualNode) {
+ if (visualNode == null) {
+ return false;
+ }
- if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(PSEUDO_ELEMENT_ATTR))) {
- return true;
- }
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
- return false;
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(PSEUDO_ELEMENT_ATTR))) {
+ return true;
}
- private void setPseudoContent(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
- if (containerTemplate != null) {
- containerTemplate.setPseudoContent(pageContext, sourceContainer,
- visualContainer, visualDocument);
- } else {
- VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
- pageContext, sourceContainer, visualContainer,
- visualDocument);
- }
+ return false;
+ }
- // if (isEmptyElement(visualContainer)) {
- // addPseudoElementImpl(visualContainer);
- // }
+ private void setPseudoContent(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
+ if (containerTemplate != null) {
+ containerTemplate.setPseudoContent(pageContext, sourceContainer,
+ visualContainer, visualDocument);
+ } else {
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
+ pageContext, sourceContainer, visualContainer,
+ visualDocument);
}
- private void addPseudoElementImpl(nsIDOMNode visualParent) {
- if (!templateManager.isWithoutPseudoElementContainer(visualParent
- .getNodeName())) {
- if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
- System.out.println("-------------------- addPseudoElement: "
- + visualParent.getNodeName());
- }
- nsIDOMElement visualPseudoElement = visualDocument
- .createElement(PSEUDO_ELEMENT);
- visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, "yes");
- visualParent.appendChild(visualPseudoElement);
- }
+ // if (isEmptyElement(visualContainer)) {
+ // addPseudoElementImpl(visualContainer);
+ // }
+ }
+
+ private void addPseudoElementImpl(nsIDOMNode visualParent) {
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent
+ .getNodeName())) {
+ if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
+ System.out.println("-------------------- addPseudoElement: "
+ + visualParent.getNodeName());
+ }
+ nsIDOMElement visualPseudoElement = visualDocument
+ .createElement(PSEUDO_ELEMENT);
+ visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, "yes");
+ visualParent.appendChild(visualPseudoElement);
}
+ }
- public boolean isEmptyElement(nsIDOMNode visualParent) {
- nsIDOMNodeList visualNodes = visualParent.getChildNodes();
- long len = visualNodes.getLength();
+ public boolean isEmptyElement(nsIDOMNode visualParent) {
+ nsIDOMNodeList visualNodes = visualParent.getChildNodes();
+ long len = visualNodes.getLength();
- if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
- return true;
- }
-
- return false;
+ if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
+ return true;
}
- public boolean isEmptyDocument() {
- nsIDOMNodeList visualNodes = visualContentArea.getChildNodes();
- long len = visualNodes.getLength();
- if ((len == 0)
- || (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
- .item(0))))) {
- return true;
- }
+ return false;
+ }
- return false;
+ public boolean isEmptyDocument() {
+ nsIDOMNodeList visualNodes = visualContentArea.getChildNodes();
+ long len = visualNodes.getLength();
+ if ((len == 0)
+ || (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
+ .item(0))))) {
+ return true;
}
- private boolean isEmptyText(nsIDOMNode visualNode) {
- if (visualNode == null
- || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
- return false;
- }
+ return false;
+ }
- if (visualNode.getNodeValue().trim().length() == 0) {
- return true;
- }
+ private boolean isEmptyText(nsIDOMNode visualNode) {
+ if (visualNode == null
+ || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
+ return false;
+ }
- return false;
+ if (visualNode.getNodeValue().trim().length() == 0) {
+ return true;
}
- // ==========================================================
+ return false;
+ }
- public void updateNode(Node sourceNode) {
- if (sourceNode == null)
- return;
+ // ==========================================================
- switch (sourceNode.getNodeType()) {
- case Node.DOCUMENT_NODE:
- rebuildDom((Document) sourceNode);
- break;
- case Node.COMMENT_NODE:
- updateComment(sourceNode);
- break;
- default:
- updateElement(getNodeForUpdate(sourceNode));
- }
+ public void updateNode(Node sourceNode) {
+ if (sourceNode == null)
+ return;
+
+ switch (sourceNode.getNodeType()) {
+ case Node.DOCUMENT_NODE:
+ rebuildDom((Document) sourceNode);
+ break;
+ case Node.COMMENT_NODE:
+ updateComment(sourceNode);
+ break;
+ default:
+ updateElement(getNodeForUpdate(sourceNode));
}
+ }
- // TODO Ssergey Vasilyev make a common code for figuring out
- // if it is need to update parent node or not
- private Node getNodeForUpdate(Node sourceNode) {
- /* Changing of <tr> or <td> tags can affect whole the table */
- Node sourceTable = getParentTable(sourceNode, 2);
- if (sourceTable != null) {
- return sourceTable;
- }
+ // TODO Ssergey Vasilyev make a common code for figuring out
+ // if it is need to update parent node or not
+ private Node getNodeForUpdate(Node sourceNode) {
+ /* Changing of <tr> or <td> tags can affect whole the table */
+ Node sourceTable = getParentTable(sourceNode, 2);
+ if (sourceTable != null) {
+ return sourceTable;
+ }
- /* Changing of an <option> tag can affect the parent select */
- Node sourceSelect = getParentSelect(sourceNode);
- if (sourceSelect != null) {
- return sourceSelect;
- }
-
- return sourceNode;
+ /* Changing of an <option> tag can affect the parent select */
+ Node sourceSelect = getParentSelect(sourceNode);
+ if (sourceSelect != null) {
+ return sourceSelect;
}
- private void updateComment(Node sourceNode) {
- VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
- if (mapping != null
- && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
- nsIDOMNodeList visualNodes = mapping.getVisualNode()
- .getChildNodes();
+ return sourceNode;
+ }
- if (visualNodes.getLength() > 0) {
- visualNodes.item(0).setNodeValue(sourceNode.getNodeValue());
- }
- }
+ private void updateComment(Node sourceNode) {
+ VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
+ if (mapping != null
+ && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
+ nsIDOMNodeList visualNodes = mapping.getVisualNode()
+ .getChildNodes();
+
+ if (visualNodes.getLength() > 0) {
+ visualNodes.item(0).setNodeValue(sourceNode.getNodeValue());
+ }
}
+ }
- private void updateElement(Node sourceNode) {
- VpeElementMapping elementMapping = null;
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- if (elementMapping != null && elementMapping.getTemplate() != null) {
- Node updateNode = elementMapping.getTemplate()
- .getNodeForUptate(pageContext,
- elementMapping.getSourceNode(),
- elementMapping.getVisualNode(),
- elementMapping.getData());
- if (updateNode != null && updateNode != sourceNode) {
- updateNode(updateNode);
- return;
- }
- }
+ private void updateElement(Node sourceNode) {
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ Node updateNode = elementMapping.getTemplate()
+ .getNodeForUptate(pageContext,
+ elementMapping.getSourceNode(),
+ elementMapping.getVisualNode(),
+ elementMapping.getData());
+ if (updateNode != null && updateNode != sourceNode) {
+ updateNode(updateNode);
+ return;
}
- nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
- if (visualOldNode != null) {
- if (elementMapping != null) {
- nsIDOMElement border = elementMapping.getBorder();
- if (border != null) {
- visualOldNode = border;
- }
- }
- nsIDOMNode visualContainer = visualOldNode.getParentNode();
- nsIDOMNode visualNextNode = visualOldNode.getNextSibling();
- if (visualContainer != null) {
- visualContainer.removeChild(visualOldNode);
- addNode(sourceNode, visualNextNode, visualContainer);
- }
- } else {
- if (sourceNode.getNodeType() == Node.TEXT_NODE) {
- updateNode(sourceNode.getParentNode());
- }
+ }
+ }
+ nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
+ if (visualOldNode != null) {
+ if (elementMapping != null) {
+ nsIDOMElement border = elementMapping.getBorder();
+ if (border != null) {
+ visualOldNode = border;
}
+ }
+ nsIDOMNode visualContainer = visualOldNode.getParentNode();
+ nsIDOMNode visualNextNode = visualOldNode.getNextSibling();
+ if (visualContainer != null) {
+ visualContainer.removeChild(visualOldNode);
+ addNode(sourceNode, visualNextNode, visualContainer);
+ }
+ } else {
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ updateNode(sourceNode.getParentNode());
+ }
}
+ }
- public void removeNode(Node sourceNode) {
- domMapping.remove(sourceNode);
+ public void removeNode(Node sourceNode) {
+ domMapping.remove(sourceNode);
+ }
+
+ private Node getParentTable(Node sourceNode, int depth) {
+ Node parentNode = sourceNode.getParentNode();
+ for (int i = 0; parentNode != null && i < depth; parentNode = parentNode
+ .getParentNode(), i++) {
+ if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
+ return parentNode;
+ }
}
+ return null;
+ }
- private Node getParentTable(Node sourceNode, int depth) {
- Node parentNode = sourceNode.getParentNode();
- for (int i = 0; parentNode != null && i < depth; parentNode = parentNode
- .getParentNode(), i++) {
- if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
- }
- return null;
+ private Node getParentSelect(Node sourceNode) {
+ if (HTML.TAG_OPTION.equalsIgnoreCase(sourceNode.getNodeName())) {
+ Node parentNode = sourceNode.getParentNode();
+ if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
+ return parentNode;
+ }
}
+ return null;
+ }
- private Node getParentSelect(Node sourceNode) {
- if (HTML.TAG_OPTION.equalsIgnoreCase(sourceNode.getNodeName())) {
- Node parentNode = sourceNode.getParentNode();
- if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
+ public void setText(Node sourceText) {
+ Node sourceParent = sourceText.getParentNode();
+ if (sourceParent != null && sourceParent.getLocalName() != null) {
+ String sourceParentName = sourceParent.getLocalName();
+ if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
+ || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
+ updateNode(sourceText.getParentNode());
+ return;
+ }
+ }
+ nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
+ if (visualText != null) {
+ String visualValue = TextUtil.visualText(sourceText.getNodeValue());
+ visualText.setNodeValue(visualValue);
+ } else {
+ VpeNodeMapping nodeMapping = domMapping
+ .getNodeMapping(sourceParent);
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ VpeTemplate template = ((VpeElementMapping) nodeMapping)
+ .getTemplate();
+ if (template != null) {
+ if (!template.containsText()) {
+ return;
+ }
}
- return null;
+ }
+ updateNode(sourceText);
}
+ }
- public void setText(Node sourceText) {
- Node sourceParent = sourceText.getParentNode();
- if (sourceParent != null && sourceParent.getLocalName() != null) {
- String sourceParentName = sourceParent.getLocalName();
- if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
- || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
- updateNode(sourceText.getParentNode());
- return;
- }
- }
- nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
- if (visualText != null) {
- String visualValue = TextUtil.visualText(sourceText.getNodeValue());
- visualText.setNodeValue(visualValue);
+ public void setAttribute(Element sourceElement, String name, String value) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (elementMapping.getBorder() != null) {
+ updateElement(sourceElement);
+ } else if (template.isRecreateAtAttrChange(pageContext,
+ sourceElement, visualDocument,
+ (nsIDOMElement) elementMapping.getVisualNode(),
+ elementMapping.getData(), name, value)) {
+ updateElement(sourceElement);
} else {
- VpeNodeMapping nodeMapping = domMapping
- .getNodeMapping(sourceParent);
- if (nodeMapping != null
- && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- VpeTemplate template = ((VpeElementMapping) nodeMapping)
- .getTemplate();
- if (template != null) {
- if (!template.containsText()) {
- return;
- }
- }
+ nsIDOMElement visualElement = (nsIDOMElement) elementMapping
+ .getVisualNode();
+ if (visualElement != null) {
+ String visualElementName = visualElement.getNodeName();
+ if (HTML.TAG_SELECT.equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ return;
+ } else if (HTML.TAG_OPTION
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement.getParentNode());
+ return;
+ } else if (HTML.TAG_INPUT
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
}
- updateNode(sourceText);
+ }
+ setXmlnsAttribute(elementMapping, name, value);
+ template.setAttribute(pageContext, sourceElement,
+ visualDocument, visualElement, elementMapping
+ .getData(), name, value);
+ resetTooltip(sourceElement, visualElement);
}
+ }
}
+ }
- public void setAttribute(Element sourceElement, String name, String value) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- if (elementMapping.isIfDependencyFromAttribute(name)) {
- updateElement(sourceElement);
- } else {
- VpeTemplate template = elementMapping.getTemplate();
- if (elementMapping.getBorder() != null) {
- updateElement(sourceElement);
- } else if (template.isRecreateAtAttrChange(pageContext,
- sourceElement, visualDocument,
- (nsIDOMElement) elementMapping.getVisualNode(),
- elementMapping.getData(), name, value)) {
- updateElement(sourceElement);
- } else {
- nsIDOMElement visualElement = (nsIDOMElement) elementMapping
- .getVisualNode();
- if (visualElement != null) {
- String visualElementName = visualElement.getNodeName();
- if (HTML.TAG_SELECT.equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- return;
- } else if (HTML.TAG_OPTION
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement.getParentNode());
- return;
- } else if (HTML.TAG_INPUT
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- }
- }
- setXmlnsAttribute(elementMapping, name, value);
- template.setAttribute(pageContext, sourceElement,
- visualDocument, visualElement, elementMapping
- .getData(), name, value);
- resetTooltip(sourceElement, visualElement);
- }
- }
- }
- }
+ public void stopToggle(Node sourceNode) {
+ if (!(sourceNode instanceof Element))
+ return;
- public void stopToggle(Node sourceNode) {
- if (!(sourceNode instanceof Element))
- return;
+ Element sourceElement = (Element) sourceNode;
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- Element sourceElement = (Element) sourceNode;
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
-
- if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate) template).stopToggling(sourceElement);
- }
- }
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).stopToggling(sourceElement);
+ }
}
+ }
- public boolean doToggle(nsIDOMNode visualNode) {
- if (visualNode == null)
- return false;
- nsIDOMElement visualElement = null;
- try {
+ public boolean doToggle(nsIDOMNode visualNode) {
+ if (visualNode == null)
+ return false;
+ nsIDOMElement visualElement = null;
+ try {
- visualElement = (nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- } catch (XPCOMException exception) {
- visualElement = (nsIDOMElement) visualNode.getParentNode()
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- }
- if (visualElement == null)
- return false;
+ visualElement = (nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ } catch (XPCOMException exception) {
+ visualElement = (nsIDOMElement) visualNode.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+ if (visualElement == null)
+ return false;
- nsIDOMAttr toggleIdAttr = visualElement
- .getAttributeNode("vpe-user-toggle-id");
- if (toggleIdAttr == null)
- return false;
- String toggleId = toggleIdAttr.getNodeValue();
+ nsIDOMAttr toggleIdAttr = visualElement
+ .getAttributeNode("vpe-user-toggle-id");
+ if (toggleIdAttr == null)
+ return false;
+ String toggleId = toggleIdAttr.getNodeValue();
- if (toggleId == null)
- return false;
+ if (toggleId == null)
+ return false;
- boolean toggleLookup = false;
- nsIDOMAttr toggleLookupAttr = visualElement
- .getAttributeNode("vpe-user-toggle-lookup-parent");
- if (toggleLookupAttr != null) {
- toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
- }
+ boolean toggleLookup = false;
+ nsIDOMAttr toggleLookupAttr = visualElement
+ .getAttributeNode("vpe-user-toggle-lookup-parent");
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ }
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(getLastSelectedElement());
- Node sourceNode = (Node) domMapping
- .getSourceNode(getLastSelectedElement());
- if (sourceNode == null)
- return false;
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(getLastSelectedElement());
+ Node sourceNode = (Node) domMapping
+ .getSourceNode(getLastSelectedElement());
+ if (sourceNode == null)
+ return false;
- Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
- : sourceNode.getParentNode());
+ Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
+ : sourceNode.getParentNode());
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- while (toggleLookup && sourceElement != null
- && !(template instanceof VpeToggableTemplate)) {
- sourceElement = (Element) sourceElement.getParentNode();
- if (sourceElement == null)
- break;
- elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping == null)
- continue;
- template = elementMapping.getTemplate();
- }
+ while (toggleLookup && sourceElement != null
+ && !(template instanceof VpeToggableTemplate)) {
+ sourceElement = (Element) sourceElement.getParentNode();
+ if (sourceElement == null)
+ break;
+ elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping == null)
+ continue;
+ template = elementMapping.getTemplate();
+ }
- if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate) template).toggle(this, sourceElement,
- toggleId);
- updateElement(sourceElement);
- return true;
- }
- }
- return false;
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).toggle(this, sourceElement,
+ toggleId);
+ updateElement(sourceElement);
+ return true;
+ }
}
+ return false;
+ }
- public void removeAttribute(Element sourceElement, String name) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- if (elementMapping.isIfDependencyFromAttribute(name)) {
- updateElement(sourceElement);
- } else {
- VpeTemplate template = elementMapping.getTemplate();
- if (template.isRecreateAtAttrChange(pageContext, sourceElement,
- visualDocument, (nsIDOMElement) elementMapping
- .getVisualNode(), elementMapping.getData(),
- name, null)) {
- updateElement(sourceElement);
- } else {
- removeXmlnsAttribute(elementMapping, name);
- template.removeAttribute(pageContext, sourceElement,
- visualDocument, (nsIDOMElement) elementMapping
- .getVisualNode(), elementMapping.getData(),
- name);
- resetTooltip(sourceElement, (nsIDOMElement) elementMapping
- .getVisualNode());
- }
- }
+ public void removeAttribute(Element sourceElement, String name) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (template.isRecreateAtAttrChange(pageContext, sourceElement,
+ visualDocument, (nsIDOMElement) elementMapping
+ .getVisualNode(), elementMapping.getData(),
+ name, null)) {
+ updateElement(sourceElement);
+ } else {
+ removeXmlnsAttribute(elementMapping, name);
+ template.removeAttribute(pageContext, sourceElement,
+ visualDocument, (nsIDOMElement) elementMapping
+ .getVisualNode(), elementMapping.getData(),
+ name);
+ resetTooltip(sourceElement, (nsIDOMElement) elementMapping
+ .getVisualNode());
}
+ }
}
+ }
- public void refreshBundleValues(Element sourceElement) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
- template.refreshBundleValues(pageContext, sourceElement,
- elementMapping.getData());
- }
+ public void refreshBundleValues(Element sourceElement) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+ template.refreshBundleValues(pageContext, sourceElement,
+ elementMapping.getData());
}
+ }
- boolean isContentArea(nsIDOMNode visualNode) {
- return visualContentArea.equals(visualNode);
- }
+ boolean isContentArea(nsIDOMNode visualNode) {
+ return visualContentArea.equals(visualNode);
+ }
- nsIDOMElement getContentArea() {
- return visualContentArea;
- }
+ nsIDOMElement getContentArea() {
+ return visualContentArea;
+ }
- void setSelectionRectangle(nsIDOMElement visualElement) {
- setSelectionRectangle(visualElement, true);
- }
+ void setSelectionRectangle(nsIDOMElement visualElement) {
+ setSelectionRectangle(visualElement, true);
+ }
- void setSelectionRectangle(nsIDOMElement visualElement, boolean scroll) {
- int resizerConstrains = getResizerConstrains(visualElement);
- visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
- scroll);
- }
+ void setSelectionRectangle(nsIDOMElement visualElement, boolean scroll) {
+ int resizerConstrains = getResizerConstrains(visualElement);
+ visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
+ scroll);
+ }
- public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMElement newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
- headNode.appendChild(newNode);
- return newNode;
- }
+ public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
+ nsIDOMElement newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
+ headNode.appendChild(newNode);
+ return newNode;
+ }
- public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
- String href_val, String ext_val) {
- nsIDOMNode newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
- headNode.replaceChild(newNode, oldNode);
- return newNode;
- }
+ public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
+ String href_val, String ext_val) {
+ nsIDOMNode newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
+ headNode.replaceChild(newNode, oldNode);
+ return newNode;
+ }
- public nsIDOMNode replaceLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMNode newNode = null;
- nsIDOMNode oldNode = getLinkNode(href_val, ext_val);
- if (oldNode == null) {
- newNode = addLinkNodeToHead(href_val, ext_val);
- }
- return newNode;
+ public nsIDOMNode replaceLinkNodeToHead(String href_val, String ext_val) {
+ nsIDOMNode newNode = null;
+ nsIDOMNode oldNode = getLinkNode(href_val, ext_val);
+ if (oldNode == null) {
+ newNode = addLinkNodeToHead(href_val, ext_val);
}
+ return newNode;
+ }
- public void removeLinkNodeFromHead(nsIDOMNode node) {
- headNode.removeChild(node);
- }
+ public void removeLinkNodeFromHead(nsIDOMNode node) {
+ headNode.removeChild(node);
+ }
- private nsIDOMElement createLinkNode(String href_val, String rel_val,
- String ext_val) {
- nsIDOMElement linkNode = null;
- if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
- && href_val.startsWith("file:")) {
- /*
- * Because of the Mozilla caches the linked css files we replace tag
- * <link rel="styleseet" href="file://..."> with tag <style
- * vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style> It is
- * LinkReplacer
- */
- linkNode = visualDocument.createElement(HTML.TAG_STYLE);
- linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
+ private nsIDOMElement createLinkNode(String href_val, String rel_val,
+ String ext_val) {
+ nsIDOMElement linkNode = null;
+ if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
+ && href_val.startsWith("file:")) {
+ /*
+ * Because of the Mozilla caches the linked css files we replace tag
+ * <link rel="styleseet" href="file://..."> with tag <style
+ * vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style> It is
+ * LinkReplacer
+ */
+ linkNode = visualDocument.createElement(HTML.TAG_STYLE);
+ linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
- /* Copy links attributes into our <style> */
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- try {
- StringBuffer styleText = new StringBuffer(EMPTY_STRING);
- URL url = new URL((new Path(href_val)).toOSString());
- String fileName=url.getFile();
- BufferedReader in = new BufferedReader(new FileReader(
- (fileName)));
- String str = EMPTY_STRING;
- while ((str = in.readLine()) != null) {
- styleText.append(str);
- }
-
- String styleForParse = styleText.toString();
- styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
- styleForParse, href_val);
-
- in.close();
- nsIDOMText textNode = visualDocument
- .createTextNode(styleForParse);
- linkNode.appendChild(textNode);
- return linkNode;
- } catch (FileNotFoundException fnfe) {
- /* File which was pointed by user is not exists. Do nothing. */
- } catch (IOException ioe) {
- VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
- }
+ /* Copy links attributes into our <style> */
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ try {
+ StringBuffer styleText = new StringBuffer(EMPTY_STRING);
+ URL url = new URL((new Path(href_val)).toOSString());
+ String fileName = url.getFile();
+ BufferedReader in = new BufferedReader(new FileReader(
+ (fileName)));
+ String str = EMPTY_STRING;
+ while ((str = in.readLine()) != null) {
+ styleText.append(str);
}
- linkNode = visualDocument.createElement(HTML.TAG_LINK);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ String styleForParse = styleText.toString();
+ styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
+ styleForParse, href_val);
+ in.close();
+ nsIDOMText textNode = visualDocument
+ .createTextNode(styleForParse);
+ linkNode.appendChild(textNode);
return linkNode;
+ } catch (FileNotFoundException fnfe) {
+ /* File which was pointed by user is not exists. Do nothing. */
+ } catch (IOException ioe) {
+ VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
+ }
}
- private boolean isLinkReplacer(nsIDOMNode node) {
- return HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && ATTR_VPE_INLINE_LINK_VALUE
- .equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(ATTR_VPE));
- }
+ linkNode = visualDocument.createElement(HTML.TAG_LINK);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- private nsIDOMNode getLinkNode(String href_val, String ext_val) {
- nsIDOMNodeList children = headNode.getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode node = children.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if (HTML.TAG_LINK.equalsIgnoreCase(node.getNodeName())
- || isLinkReplacer(node)) {
- nsIDOMElement element = (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if (ext_val.equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
- && href_val
- .equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
- return node;
- }
- }
- }
+ return linkNode;
+ }
+
+ private boolean isLinkReplacer(nsIDOMNode node) {
+ return HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE));
+ }
+
+ private nsIDOMNode getLinkNode(String href_val, String ext_val) {
+ nsIDOMNodeList children = headNode.getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ if (HTML.TAG_LINK.equalsIgnoreCase(node.getNodeName())
+ || isLinkReplacer(node)) {
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if (ext_val.equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
+ && href_val
+ .equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
+ return node;
+ }
}
- return null;
+ }
}
+ return null;
+ }
- private void cleanHead() {
- nsIDOMNodeList children = headNode.getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode node = children.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- String name = node.getNodeName();
- if (HTML.TAG_LINK.equalsIgnoreCase(name)
- || isLinkReplacer(node)) {
- if (NO_STRING.equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute("ext"))) {
- // int linkAddress =
- // MozillaSupports.queryInterface(node,
- // nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
- // nsIStyleSheetLinkingElement linkingElement = new
- // nsIStyleSheetLinkingElement(linkAddress);
- // linkingElement.removeStyleSheet();
- node = headNode.removeChild(node);
- }
- } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && (!YES_STRING
- .equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(ATTR_VPE)))) {
- node = headNode.removeChild(node);
- }
- }
+ private void cleanHead() {
+ nsIDOMNodeList children = headNode.getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ String name = node.getNodeName();
+ if (HTML.TAG_LINK.equalsIgnoreCase(name)
+ || isLinkReplacer(node)) {
+ if (NO_STRING.equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute("ext"))) {
+ // int linkAddress =
+ // MozillaSupports.queryInterface(node,
+ // nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
+ // nsIStyleSheetLinkingElement linkingElement = new
+ // nsIStyleSheetLinkingElement(linkAddress);
+ // linkingElement.removeStyleSheet();
+ node = headNode.removeChild(node);
+ }
+ } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && (!YES_STRING
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE)))) {
+ node = headNode.removeChild(node);
}
+ }
}
+ }
- private class PseudoInfo {
- private nsIDOMNode pseudoNode;
- private boolean isElements;
+ private class PseudoInfo {
+ private nsIDOMNode pseudoNode;
+ private boolean isElements;
- private PseudoInfo() {
- this(null, false);
- }
-
- private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
- this.pseudoNode = pseudoNode;
- this.isElements = isElements;
- }
+ private PseudoInfo() {
+ this(null, false);
}
- void showDragCaret(nsIDOMNode node, int offset) {
- xulRunnerEditor.showDragCaret(node, offset);
+ private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
+ this.pseudoNode = pseudoNode;
+ this.isElements = isElements;
}
+ }
- void hideDragCaret() {
+ void showDragCaret(nsIDOMNode node, int offset) {
+ xulRunnerEditor.showDragCaret(node, offset);
+ }
- xulRunnerEditor.hideDragCaret();
- }
+ void hideDragCaret() {
- private int getResizerConstrains(nsIDOMNode visualNode) {
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
- if (nodeMapping != null
- && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- return ((VpeElementMapping) nodeMapping).getTemplate()
- .getTagDescription(pageContext,
- (Element) nodeMapping.getSourceNode(),
- visualDocument,
- (nsIDOMElement) nodeMapping.getVisualNode(),
- ((VpeElementMapping) nodeMapping).getData())
- .getResizeConstrains();
- }
- return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ xulRunnerEditor.hideDragCaret();
+ }
+
+ private int getResizerConstrains(nsIDOMNode visualNode) {
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ return ((VpeElementMapping) nodeMapping).getTemplate()
+ .getTagDescription(pageContext,
+ (Element) nodeMapping.getSourceNode(),
+ visualDocument,
+ (nsIDOMElement) nodeMapping.getVisualNode(),
+ ((VpeElementMapping) nodeMapping).getData())
+ .getResizeConstrains();
}
+ return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ }
- public void resize(nsIDOMElement element, int resizerConstrains, int top,
- int left, int width, int height) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(element);
- if (elementMapping != null) {
- elementMapping.getTemplate().resize(pageContext,
- (Element) elementMapping.getSourceNode(), visualDocument,
- element, elementMapping.getData(), resizerConstrains, top,
- left, width, height);
- }
+ public void resize(nsIDOMElement element, int resizerConstrains, int top,
+ int left, int width, int height) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(element);
+ if (elementMapping != null) {
+ elementMapping.getTemplate().resize(pageContext,
+ (Element) elementMapping.getSourceNode(), visualDocument,
+ element, elementMapping.getData(), resizerConstrains, top,
+ left, width, height);
}
+ }
- static boolean isAnonElement(nsIDOMNode visualNode) {
- if (visualNode != null
- && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- String attrValue = ((nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(MOZ_ANONCLASS_ATTR);
+ static boolean isAnonElement(nsIDOMNode visualNode) {
+ if (visualNode != null
+ && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ String attrValue = ((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(MOZ_ANONCLASS_ATTR);
- return attrValue != null && attrValue.length() > 0;
- }
-
- return false;
+ return attrValue != null && attrValue.length() > 0;
}
- boolean canInnerDrag(nsIDOMElement visualDragElement) {
- VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
- if (node instanceof VpeElementMapping) {
- VpeElementMapping elementMapping = (VpeElementMapping) node;
- if (elementMapping != null) {
- return elementMapping.getTemplate().canInnerDrag(pageContext,
- (Element) elementMapping.getSourceNode(),
- visualDocument, visualDragElement,
- elementMapping.getData());
- }
- }
- return false;
+ return false;
+ }
+
+ boolean canInnerDrag(nsIDOMElement visualDragElement) {
+ VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
+ if (node instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping) node;
+ if (elementMapping != null) {
+ return elementMapping.getTemplate().canInnerDrag(pageContext,
+ (Element) elementMapping.getSourceNode(),
+ visualDocument, visualDragElement,
+ elementMapping.getData());
+ }
}
+ return false;
+ }
- VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode,
- VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
- nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
- long visualDropOffset = visualDropInfo.getDropOffset();
- Node sourceDropContainer = null;
- int sourceDropOffset = 0;
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode,
+ VpeVisualInnerDropInfo 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 (isPseudoElement(visualOffsetNode)
- || isAnonElement(visualOffsetNode)) {
- visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = true;
- }
- } else {
- visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = visualChildCount != 0;
- }
- if (visualOffsetNode != null) {
- Node sourceOffsetNode = domMapping
- .getSourceNode(visualOffsetNode);
- if (sourceOffsetNode != null) {
- sourceDropContainer = sourceOffsetNode.getParentNode();
- sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
- if (afterFlag) {
- sourceDropOffset++;
- }
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = domMapping
- .getNearSourceNode(visualDropContainer);
- if (sourceDropContainer != null) {
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = domMapping
- .getNearSourceNode(visualContentArea);
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- break;
- case nsIDOMNode.TEXT_NODE:
- VpeNodeMapping nodeMapping = domMapping
- .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 (isTextEditable(visualDropContainer)) {
- String[] atributeNames = ((VpeElementMapping) nodeMapping)
- .getTemplate().getOutputAtributeNames();
- 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;
+ 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 (isPseudoElement(visualOffsetNode)
+ || isAnonElement(visualOffsetNode)) {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = true;
}
+ } else {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = visualChildCount != 0;
+ }
+ if (visualOffsetNode != null) {
+ Node sourceOffsetNode = domMapping
+ .getSourceNode(visualOffsetNode);
+ if (sourceOffsetNode != null) {
+ sourceDropContainer = sourceOffsetNode.getParentNode();
+ sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
+ if (afterFlag) {
+ sourceDropOffset++;
+ }
+ }
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping
+ .getNearSourceNode(visualDropContainer);
if (sourceDropContainer != null) {
- return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer,
- sourceDropOffset, checkParentTemplates);
- } else {
- return new VpeSourceInnerDropInfo(null, 0, false);
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
}
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping
+ .getNearSourceNode(visualContentArea);
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
+ }
+ break;
+ case nsIDOMNode.TEXT_NODE:
+ VpeNodeMapping nodeMapping = domMapping
+ .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 (isTextEditable(visualDropContainer)) {
+ String[] atributeNames = ((VpeElementMapping) nodeMapping)
+ .getTemplate().getOutputAtributeNames();
+ 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 getSourceInnerDropInfo(sourceDragNode, sourceDropContainer,
+ sourceDropOffset, checkParentTemplates);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, false);
+ }
+ }
- VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode,
- Node container, int offset, boolean checkParentsTemplates) {
- // Thread.dumpStack();
- boolean canDrop = false;
- switch (container.getNodeType()) {
- case Node.ELEMENT_NODE:
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
- if (nodeMapping != null
- && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
- .canInnerDrop(pageContext, container, dragNode);
- }
- if (!canDrop) {
- if (!checkParentsTemplates)
- return new VpeSourceInnerDropInfo(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 getSourceInnerDropInfo(dragNode, container, offset,
- // false);
- return new VpeSourceInnerDropInfo(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 VpeSourceInnerDropInfo(container, offset, canDrop);
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode,
+ Node container, int offset, boolean checkParentsTemplates) {
+ // Thread.dumpStack();
+ boolean canDrop = false;
+ switch (container.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
+ .canInnerDrop(pageContext, container, dragNode);
+ }
+ if (!canDrop) {
+ if (!checkParentsTemplates)
+ return new VpeSourceInnerDropInfo(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 getSourceInnerDropInfo(dragNode, container, offset,
+ // false);
+ return new VpeSourceInnerDropInfo(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 VpeSourceInnerDropInfo(container, offset, canDrop);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, canDrop);
+ }
+ }
+
+ public void innerDrop(Node dragNode, Node container, int offset) {
+ VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
+ if (mapping != null) {
+ nsIDOMNode visualDropContainer = mapping.getVisualNode();
+ switch (mapping.getType()) {
+ case VpeNodeMapping.TEXT_MAPPING:
+ break;
+ case VpeNodeMapping.ELEMENT_MAPPING:
+ nsIDOMNode visualParent = visualDropContainer.getParentNode();
+ VpeNodeMapping oldMapping = mapping;
+ mapping = domMapping.getNearNodeMapping(visualParent);
+ if (mapping != null
+ && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ ((VpeElementMapping) mapping).getTemplate()
+ .innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container,
+ offset, true));
} else {
- return new VpeSourceInnerDropInfo(null, 0, canDrop);
+ ((VpeElementMapping) oldMapping).getTemplate()
+ .innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container,
+ offset, true));
}
+ }
+
}
+ }
- public void innerDrop(Node dragNode, Node container, int offset) {
- VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
- if (mapping != null) {
- nsIDOMNode visualDropContainer = mapping.getVisualNode();
- switch (mapping.getType()) {
- case VpeNodeMapping.TEXT_MAPPING:
- break;
- case VpeNodeMapping.ELEMENT_MAPPING:
- nsIDOMNode visualParent = visualDropContainer.getParentNode();
- VpeNodeMapping oldMapping = mapping;
- mapping = domMapping.getNearNodeMapping(visualParent);
- if (mapping != null
- && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- ((VpeElementMapping) mapping).getTemplate()
- .innerDrop(
- pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container,
- offset, true));
- } else {
- ((VpeElementMapping) oldMapping).getTemplate()
- .innerDrop(
- pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container,
- offset, true));
- }
- }
+ void innerDrop(VpeSourceInnerDragInfo dragInfo,
+ VpeSourceInnerDropInfo dropInfo) {
+ dropper.drop(pageContext, dragInfo, dropInfo);
+ }
- }
+ nsIDOMElement getNearDragElement(Element visualElement) {
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ while (elementMapping != null) {
+ if (canInnerDrag(elementMapping.getVisualElement())) {
+ return elementMapping.getVisualElement();
+ }
+ elementMapping = domMapping.getNearElementMapping(elementMapping
+ .getVisualNode().getParentNode());
}
+ return null;
+ }
- void innerDrop(VpeSourceInnerDragInfo dragInfo,
- VpeSourceInnerDropInfo dropInfo) {
- dropper.drop(pageContext, dragInfo, dropInfo);
+ nsIDOMElement getDragElement(nsIDOMElement visualElement) {
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ if (elementMapping != null
+ && canInnerDrag(elementMapping.getVisualElement())) {
+ return elementMapping.getVisualElement();
}
+ return null;
+ }
- nsIDOMElement getNearDragElement(Element visualElement) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(visualElement);
- while (elementMapping != null) {
- if (canInnerDrag(elementMapping.getVisualElement())) {
- return elementMapping.getVisualElement();
+ public boolean isTextEditable(nsIDOMNode visualNode) {
+ if (visualNode != null) {
+ nsIDOMNode parent = visualNode.getParentNode();
+ if (parent != null
+ && parent.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ nsIDOMElement element = (nsIDOMElement) parent
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMAttr style = element.getAttributeNode("style");
+ if (style != null) {
+ String styleValue = style.getNodeValue();
+ String[] items = styleValue.split(";");
+ for (int i = 0; i < items.length; i++) {
+ String[] item = items[i].split(":");
+ if ("-moz-user-modify".equals(item[0].trim())
+ && "read-only".equals(item[1].trim())) {
+ return false;
}
- elementMapping = domMapping.getNearElementMapping(elementMapping
- .getVisualNode().getParentNode());
+ }
}
- return null;
- }
-
- nsIDOMElement getDragElement(nsIDOMElement visualElement) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(visualElement);
- if (elementMapping != null
- && canInnerDrag(elementMapping.getVisualElement())) {
- return elementMapping.getVisualElement();
+ nsIDOMAttr classAttr = element.getAttributeNode("class");
+ if (classAttr != null) {
+ String classValue = classAttr.getNodeValue().trim();
+ if ("__any__tag__caption".equals(classValue)) {
+ return false;
+ }
}
- return null;
+ }
}
+ return true;
+ }
- public boolean isTextEditable(nsIDOMNode visualNode) {
- if (visualNode != null) {
- nsIDOMNode parent = visualNode.getParentNode();
- if (parent != null
- && parent.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- nsIDOMElement element = (nsIDOMElement) parent
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMAttr style = element.getAttributeNode("style");
- if (style != null) {
- String styleValue = style.getNodeValue();
- String[] items = styleValue.split(";");
- for (int i = 0; i < items.length; i++) {
- String[] item = items[i].split(":");
- if ("-moz-user-modify".equals(item[0].trim())
- && "read-only".equals(item[1].trim())) {
- return false;
- }
- }
- }
- nsIDOMAttr classAttr = element.getAttributeNode("class");
- if (classAttr != null) {
- String classValue = classAttr.getNodeValue().trim();
- if ("__any__tag__caption".equals(classValue)) {
- return false;
- }
- }
- }
- }
- return true;
- }
+ VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
+ int sourceDropOffset) {
+ nsIDOMNode visualDropContainer = null;
+ long visualDropOffset = 0;
- VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
- int sourceDropOffset) {
- nsIDOMNode visualDropContainer = null;
- long visualDropOffset = 0;
+ switch (sourceDropContainer.getNodeType()) {
+ case Node.TEXT_NODE:
+ visualDropContainer = domMapping.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 = domMapping.getVisualNode(sourceChild);
+ if (visualChild != null) {
+ visualDropContainer = visualChild.getParentNode();
- switch (sourceDropContainer.getNodeType()) {
- case Node.TEXT_NODE:
- visualDropContainer = domMapping.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 = domMapping.getVisualNode(sourceChild);
- if (visualChild != null) {
- visualDropContainer = visualChild.getParentNode();
-
- visualDropOffset = VisualDomUtil.getOffset(visualChild);
- }
- }
- if (visualDropContainer == null) {
- visualDropContainer = domMapping
- .getNearVisualNode(sourceDropContainer);
- nsIDOMNode visualChild = 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 = domMapping
- .getNearElementMapping(sourceElement);
- nsIDOMNode textNode = elementMapping.getTemplate()
- .getOutputTextNode(pageContext, sourceElement,
- elementMapping.getData());
- if (textNode != null) {
- visualDropContainer = textNode;
- visualDropOffset = TextUtil.visualInnerPosition(
- sourceDropContainer.getNodeValue(), sourceDropOffset);
- }
- break;
+ visualDropOffset = VisualDomUtil.getOffset(visualChild);
}
- if (visualDropContainer == null) {
- return null;
+ }
+ if (visualDropContainer == null) {
+ visualDropContainer = domMapping
+ .getNearVisualNode(sourceDropContainer);
+ nsIDOMNode visualChild = getLastAppreciableVisualChild(visualDropContainer);
+ if (visualChild != null) {
+ visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
+ } else {
+ visualDropOffset = 0;
}
- return new VpeVisualInnerDropInfo(visualDropContainer,
- visualDropOffset, 0, 0);
+ }
+ break;
+ case Node.ATTRIBUTE_NODE:
+ Element sourceElement = ((Attr) sourceDropContainer)
+ .getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
+ nsIDOMNode textNode = elementMapping.getTemplate()
+ .getOutputTextNode(pageContext, sourceElement,
+ elementMapping.getData());
+ if (textNode != null) {
+ visualDropContainer = textNode;
+ visualDropOffset = TextUtil.visualInnerPosition(
+ sourceDropContainer.getNodeValue(), sourceDropOffset);
+ }
+ break;
}
+ if (visualDropContainer == null) {
+ return null;
+ }
+ return new VpeVisualInnerDropInfo(visualDropContainer,
+ visualDropOffset, 0, 0);
+ }
- protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null
- && !((ElementImpl) sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
- return;
- String titleValue = getTooltip(sourceElement);
+ protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
+ if (visualElement != null && sourceElement != null
+ && !((ElementImpl) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
+ String titleValue = getTooltip(sourceElement);
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&");
- titleValue = titleValue.replaceAll("<", "<");
- titleValue = titleValue.replaceAll(">", ">");
- }
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
- if (titleValue != null) {
- // visualElement.setAttribute("title", titleValue);
- setTooltip(visualElement, titleValue);
- }
- }
+ if (titleValue != null) {
+ // visualElement.setAttribute("title", titleValue);
+ setTooltip(visualElement, titleValue);
+ }
}
+ }
- protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute("title", titleValue);
- nsIDOMNodeList children = visualElement.getChildNodes();
- long len = children.getLength();
- for (long i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- setTooltip(((nsIDOMElement) child
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)),
- titleValue);
- }
- }
+ protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
+ visualElement.setAttribute("title", titleValue);
+ nsIDOMNodeList children = visualElement.getChildNodes();
+ long len = children.getLength();
+ for (long i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ setTooltip(((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)),
+ titleValue);
+ }
}
+ }
- private void resetTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null
- && !((ElementImpl) sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
- return;
- String titleValue = getTooltip(sourceElement);
+ private void resetTooltip(Element sourceElement, nsIDOMElement visualElement) {
+ if (visualElement != null && sourceElement != null
+ && !((ElementImpl) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
+ String titleValue = getTooltip(sourceElement);
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&");
- titleValue = titleValue.replaceAll("<", "<");
- titleValue = titleValue.replaceAll(">", ">");
- }
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
- if (titleValue != null) {
- resetTooltip(visualElement, titleValue);
- }
- }
+ if (titleValue != null) {
+ resetTooltip(visualElement, titleValue);
+ }
}
+ }
- private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute("title", titleValue);
- nsIDOMNodeList children = visualElement.getChildNodes();
- long len = children.getLength();
- for (long i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- if (domMapping.getNodeMapping(child) == null) {
- resetTooltip((nsIDOMElement) child
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- titleValue);
- }
- }
+ private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
+ visualElement.setAttribute("title", titleValue);
+ nsIDOMNodeList children = visualElement.getChildNodes();
+ long len = children.getLength();
+ for (long i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ if (domMapping.getNodeMapping(child) == null) {
+ resetTooltip((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
+ titleValue);
}
+ }
}
+ }
- private String getTooltip(Element sourceElement) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(sourceElement.getNodeName());
- NamedNodeMap attrs = sourceElement.getAttributes();
- int len = attrs.getLength();
- for (int i = 0; i < len; i++) {
- if (i == 7) {
- return buffer.append("\n\t... ").toString();
- }
- int valueLength = attrs.item(i).getNodeValue().length();
- if (valueLength > 30) {
- StringBuffer temp = new StringBuffer();
- temp.append(attrs.item(i).getNodeValue().substring(0, 15)
- + " ... "
- + attrs.item(i).getNodeValue().substring(
- valueLength - 15, valueLength));
- buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp);
- } else
- buffer.append("\n" + attrs.item(i).getNodeName() + ": "
- + attrs.item(i).getNodeValue());
+ private String getTooltip(Element sourceElement) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(sourceElement.getNodeName());
+ NamedNodeMap attrs = sourceElement.getAttributes();
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++) {
+ if (i == 7) {
+ return buffer.append("\n\t... ").toString();
+ }
+ int valueLength = attrs.item(i).getNodeValue().length();
+ if (valueLength > 30) {
+ StringBuffer temp = new StringBuffer();
+ temp.append(attrs.item(i).getNodeValue().substring(0, 15)
+ + " ... "
+ + attrs.item(i).getNodeValue().substring(
+ valueLength - 15, valueLength));
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp);
+ } else
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": "
+ + attrs.item(i).getNodeValue());
- }
-
- return buffer.toString();
}
- Rectangle getNodeBounds(nsIDOMNode visualNode) {
+ return buffer.toString();
+ }
- return VpeDndUtil.getBounds(visualNode);
- }
+ Rectangle getNodeBounds(nsIDOMNode visualNode) {
- static 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);
+ return XulRunnerVpeUtils.getElementBounds(visualNode);
+ }
+
+ static 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);
+ }
- static nsIDOMNode getLastAppreciableVisualChild(nsIDOMNode visualParent) {
- nsIDOMNode visualLastChild = null;
- nsIDOMNodeList visualChildren = visualParent.getChildNodes();
- long len = visualChildren.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode visualChild = visualChildren.item(i);
- if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
- visualLastChild = visualChild;
- break;
- }
- }
- return visualLastChild;
+ static nsIDOMNode getLastAppreciableVisualChild(nsIDOMNode visualParent) {
+ nsIDOMNode visualLastChild = null;
+ nsIDOMNodeList visualChildren = visualParent.getChildNodes();
+ long len = visualChildren.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode visualChild = visualChildren.item(i);
+ if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
+ visualLastChild = visualChild;
+ break;
+ }
}
+ return visualLastChild;
+ }
- void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
- VpeVisualInnerDropInfo oldVisualDropInfo) {
- nsIDOMNode newVisualDropContainer = newVisualDropInfo
- .getDropContainer();
- nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
- .getDropContainer();
+ void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
+ VpeVisualInnerDropInfo oldVisualDropInfo) {
+ nsIDOMNode newVisualDropContainer = newVisualDropInfo
+ .getDropContainer();
+ nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
+ .getDropContainer();
- if (newVisualDropContainer.equals(oldVisualDropContainer)) {
- newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
- return;
- }
+ 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 = getNodeBounds(child);
- if (canInsertAfter(oldVisualDropInfo.getMouseX(),
- oldVisualDropInfo.getMouseY(), rect)) {
- offset++;
- }
- newVisualDropInfo.setDropOffset(offset);
- }
- child = parent;
+ 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 = getNodeBounds(child);
+ if (canInsertAfter(oldVisualDropInfo.getMouseX(),
+ oldVisualDropInfo.getMouseY(), rect)) {
+ offset++;
}
+ newVisualDropInfo.setDropOffset(offset);
+ }
+ child = parent;
}
+ }
- public nsIDOMRange createDOMRange() {
- return xulRunnerEditor.createDOMRange();
- }
+ public nsIDOMRange createDOMRange() {
+ return xulRunnerEditor.createDOMRange();
+ }
- public nsIDOMRange createDOMRange(nsIDOMNode selectedNode) {
- nsIDOMRange range = createDOMRange();
- range.selectNode(selectedNode);
- return range;
- }
+ public nsIDOMRange createDOMRange(nsIDOMNode selectedNode) {
+ nsIDOMRange range = createDOMRange();
+ range.selectNode(selectedNode);
+ return range;
+ }
- public static boolean isIncludeElement(nsIDOMElement visualElement) {
- return YES_STRING.equalsIgnoreCase(visualElement
- .getAttribute(INCLUDE_ELEMENT_ATTR));
- }
+ public static boolean isIncludeElement(nsIDOMElement visualElement) {
+ return YES_STRING.equalsIgnoreCase(visualElement
+ .getAttribute(INCLUDE_ELEMENT_ATTR));
+ }
- public static void markIncludeElement(nsIDOMElement visualElement) {
- visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
- }
+ public static void markIncludeElement(nsIDOMElement visualElement) {
+ visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
+ }
- protected void setReadOnlyElement(nsIDOMElement node) {
- String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify",
- "read-only");
- node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
+ protected void setReadOnlyElement(nsIDOMElement node) {
+ String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify",
+ "read-only");
+ node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
- void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
+ void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
- nsIDOMElement selectedElement = xulRunnerEditor
- .getLastSelectedElement();
- if (selectedElement != null && canInnerDrag(selectedElement)) {
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
- .getMousePoint(mouseEvent))) {
- // change cursor
- Cursor cursor1 = new Cursor(xulRunnerEditor.getDisplay(),
- SWT.CURSOR_SIZEALL);
- xulRunnerEditor.setCursor(cursor1);
- }
- }
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ // change cursor
+ Cursor cursor1 = new Cursor(xulRunnerEditor.getDisplay(),
+ SWT.CURSOR_SIZEALL);
+ xulRunnerEditor.setCursor(cursor1);
+ }
}
+ }
- private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
- // TODO add drag and drop support
- return dragArea.contains(mousePoint)
- && mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH)
- && mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
- }
+ private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
+ // TODO add drag and drop support
+ return dragArea.contains(mousePoint)
+ && mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH)
+ && mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
+ }
- nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
+ nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
- nsIDOMElement selectedElement = xulRunnerEditor
- .getLastSelectedElement();
- if (selectedElement != null && canInnerDrag(selectedElement)) {
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
- .getMousePoint(mouseEvent))) {
- return selectedElement;
- }
- }
- return null;
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ return selectedElement;
+ }
}
+ return null;
+ }
- VpeSourceInnerDragInfo getSourceInnerDragInfo(
- VpeVisualInnerDragInfo visualDragInfo) {
- nsIDOMNode visualNode = visualDragInfo.getNode();
- int offset = visualDragInfo.getOffset();
- int length = visualDragInfo.getLength();
+ VpeSourceInnerDragInfo getSourceInnerDragInfo(
+ VpeVisualInnerDragInfo visualDragInfo) {
+ nsIDOMNode visualNode = visualDragInfo.getNode();
+ int offset = visualDragInfo.getOffset();
+ int length = visualDragInfo.getLength();
- VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
- Node sourceNode = nodeMapping.getSourceNode();
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
+ Node sourceNode = nodeMapping.getSourceNode();
- if (sourceNode != null) {
- switch (sourceNode.getNodeType()) {
- case Node.TEXT_NODE:
- int end = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset + length);
- offset = TextUtil.sourceInnerPosition(
- visualNode.getNodeValue(), offset);
- length = end - offset;
- break;
- case Node.ELEMENT_NODE:
- if (visualNode.getNodeType() == Node.TEXT_NODE) {
- // it's attribute
- sourceNode = null;
- if (isTextEditable(visualNode)) {
- String[] atributeNames = ((VpeElementMapping) nodeMapping)
- .getTemplate().getOutputAtributeNames();
- if (atributeNames != null && atributeNames.length > 0) {
- Element sourceElement = (Element) nodeMapping
- .getSourceNode();
- sourceNode = sourceElement
- .getAttributeNode(atributeNames[0]);
- end = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset + length);
- offset = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset);
- length = end - offset;
- }
- }
- }
- break;
+ if (sourceNode != null) {
+ switch (sourceNode.getNodeType()) {
+ case Node.TEXT_NODE:
+ int end = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(
+ visualNode.getNodeValue(), offset);
+ length = end - offset;
+ break;
+ case Node.ELEMENT_NODE:
+ if (visualNode.getNodeType() == Node.TEXT_NODE) {
+ // it's attribute
+ sourceNode = null;
+ if (isTextEditable(visualNode)) {
+ String[] atributeNames = ((VpeElementMapping) nodeMapping)
+ .getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element) nodeMapping
+ .getSourceNode();
+ sourceNode = sourceElement
+ .getAttributeNode(atributeNames[0]);
+ end = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset);
+ length = end - offset;
}
+ }
}
- return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ break;
+ }
}
+ return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ }
- public nsIDOMText getOutputTextNode(Attr attr) {
- Element sourceElement = ((Attr) attr).getOwnerElement();
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(sourceElement);
- if (elementMapping != null) {
- return elementMapping.getTemplate().getOutputTextNode(pageContext,
- sourceElement, elementMapping.getData());
- }
- return null;
+ public nsIDOMText getOutputTextNode(Attr attr) {
+ Element sourceElement = ((Attr) attr).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
+ if (elementMapping != null) {
+ return elementMapping.getTemplate().getOutputTextNode(pageContext,
+ sourceElement, elementMapping.getData());
}
+ return null;
+ }
- nsIDOMElement getLastSelectedElement() {
+ nsIDOMElement getLastSelectedElement() {
- return xulRunnerEditor.getLastSelectedElement();
- }
+ return xulRunnerEditor.getLastSelectedElement();
+ }
- public void pushIncludeStack(VpeIncludeInfo includeInfo) {
- includeStack.add(includeInfo);
- }
+ public void pushIncludeStack(VpeIncludeInfo includeInfo) {
+ includeStack.add(includeInfo);
+ }
- public VpeIncludeInfo popIncludeStack() {
- VpeIncludeInfo includeInfo = null;
- if (includeStack.size() > 0) {
- includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
- .size() - 1);
- }
- return includeInfo;
+ public VpeIncludeInfo popIncludeStack() {
+ VpeIncludeInfo includeInfo = null;
+ if (includeStack.size() > 0) {
+ includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
+ .size() - 1);
}
+ return includeInfo;
+ }
- public boolean isFileInIncludeStack(IFile file) {
- if (file == null)
- return false;
- for (int i = 0; i < includeStack.size(); i++) {
- if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
- return true;
- }
- }
- return false;
+ public boolean isFileInIncludeStack(IFile file) {
+ if (file == null)
+ return false;
+ for (int i = 0; i < includeStack.size(); i++) {
+ if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
+ return true;
+ }
}
+ return false;
+ }
- protected boolean isCurrentMainDocument() {
- return includeStack.size() <= 1;
- }
+ protected boolean isCurrentMainDocument() {
+ return includeStack.size() <= 1;
+ }
- public int getCurrentMainIncludeOffset() {
- if (includeStack.size() <= 1)
- return -1;
- VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
- return ((IndexedRegion) info.getElement()).getStartOffset();
- }
+ public int getCurrentMainIncludeOffset() {
+ if (includeStack.size() <= 1)
+ return -1;
+ VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
+ return ((IndexedRegion) info.getElement()).getStartOffset();
+ }
- public VpeIncludeInfo getCurrentIncludeInfo() {
- if (includeStack.size() <= 0)
- return null;
- return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
- }
+ public VpeIncludeInfo getCurrentIncludeInfo() {
+ if (includeStack.size() <= 0)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
+ }
- public VpeIncludeInfo getRootIncludeInfo() {
- if (includeStack.size() <= 1)
- return null;
- return (VpeIncludeInfo) includeStack.get(1);
- }
+ public VpeIncludeInfo getRootIncludeInfo() {
+ if (includeStack.size() <= 1)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(1);
+ }
- void dispose() {
- cleanHead();
- domMapping.clear(visualContentArea);
- pageContext.dispose();
- }
+ void dispose() {
+ cleanHead();
+ domMapping.clear(visualContentArea);
+ pageContext.dispose();
+ }
- protected Map createXmlns(Element sourceNode) {
- NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
- if (attrs != null) {
- Map xmlnsMap = new HashMap();
- for (int i = 0; i < attrs.getLength(); i++) {
- addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
- true);
- }
- if (xmlnsMap.size() > 0) {
- return xmlnsMap;
- }
- }
- return null;
+ protected Map createXmlns(Element sourceNode) {
+ NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
+ if (attrs != null) {
+ Map xmlnsMap = new HashMap();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
+ true);
+ }
+ if (xmlnsMap.size() > 0) {
+ return xmlnsMap;
+ }
}
+ return null;
+ }
- private void setXmlnsAttribute(VpeElementMapping elementMapping,
- String name, String value) {
- Element sourceElement = (Element) elementMapping.getSourceNode();
- if (sourceElement != null) {
- Map xmlnsMap = elementMapping.getXmlnsMap();
- if (xmlnsMap == null)
- xmlnsMap = new HashMap();
- addTaglib(sourceElement, xmlnsMap, name, true);
- elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
- }
+ private void setXmlnsAttribute(VpeElementMapping elementMapping,
+ String name, String value) {
+ Element sourceElement = (Element) elementMapping.getSourceNode();
+ if (sourceElement != null) {
+ Map xmlnsMap = elementMapping.getXmlnsMap();
+ if (xmlnsMap == null)
+ xmlnsMap = new HashMap();
+ addTaglib(sourceElement, xmlnsMap, name, true);
+ elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
}
+ }
- private void removeXmlnsAttribute(VpeElementMapping elementMapping,
- String name) {
- Element sourceElement = (Element) elementMapping.getSourceNode();
- if (sourceElement != null) {
- Map xmlnsMap = elementMapping.getXmlnsMap();
- if (xmlnsMap != null) {
- Object id = xmlnsMap.remove(name);
- if (id != null) {
- pageContext.setTaglib(((Integer) id).intValue(), null,
- null, true);
- elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap
- : null);
- }
- }
+ private void removeXmlnsAttribute(VpeElementMapping elementMapping,
+ String name) {
+ Element sourceElement = (Element) elementMapping.getSourceNode();
+ if (sourceElement != null) {
+ Map xmlnsMap = elementMapping.getXmlnsMap();
+ if (xmlnsMap != null) {
+ Object id = xmlnsMap.remove(name);
+ if (id != null) {
+ pageContext.setTaglib(((Integer) id).intValue(), null,
+ null, true);
+ elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap
+ : null);
}
+ }
}
+ }
- private void addTaglib(Element sourceElement, Map xmlnsMap,
- String attrName, boolean ns) {
- Attr attr = sourceElement.getAttributeNode(attrName);
- if (ATTR_XMLNS.equals(attr.getPrefix())) {
- xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
- pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
- .getLocalName(), ns);
- }
+ private void addTaglib(Element sourceElement, Map xmlnsMap,
+ String attrName, boolean ns) {
+ Attr attr = sourceElement.getAttributeNode(attrName);
+ if (ATTR_XMLNS.equals(attr.getPrefix())) {
+ xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
+ pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
+ .getLocalName(), ns);
}
+ }
- /**
- * @return the dnd
- */
- public VpeDnD getDnd() {
+ /**
+ * @return the dnd
+ */
+ public VpeDnD getDnd() {
- return dnd;
- }
+ return dnd;
+ }
- /**
- * @param dnd
- * the dnd to set
- */
- public void setDnd(VpeDnD dnd) {
+ /**
+ * @param dnd
+ * the dnd to set
+ */
+ public void setDnd(VpeDnD dnd) {
- this.dnd = dnd;
- }
+ this.dnd = dnd;
+ }
- /**
- * @return the pageContext
- */
- protected VpePageContext getPageContext() {
- return pageContext;
- }
+ /**
+ * @return the pageContext
+ */
+ protected VpePageContext getPageContext() {
+ return pageContext;
+ }
- /**
- * @param pageContext
- * the pageContext to set
- */
- protected void setPageContext(VpePageContext pageContext) {
- this.pageContext = pageContext;
- }
+ /**
+ * @param pageContext
+ * the pageContext to set
+ */
+ protected void setPageContext(VpePageContext pageContext) {
+ this.pageContext = pageContext;
+ }
- /**
- * @return the visualDocument
- */
- protected nsIDOMDocument getVisualDocument() {
- return visualDocument;
- }
+ /**
+ * @return the visualDocument
+ */
+ protected nsIDOMDocument getVisualDocument() {
+ return visualDocument;
+ }
- /**
- * @param visualDocument
- * the visualDocument to set
- */
- protected void setVisualDocument(nsIDOMDocument visualDocument) {
- this.visualDocument = visualDocument;
- }
-
- /**
- * Check this file is facelet
- * @return this if file is facelet, otherwize false
- */
- private boolean isFacelet() {
- boolean isFacelet = false;
-
- IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
- if ( iEditorInput instanceof IFileEditorInput ) {
- IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
-
- IFile iFile = iFileEditorInput.getFile();
-
- IProject project = iFile.getProject();
- IModelNature nature = EclipseResourceUtil.getModelNature(project);
- if (nature != null) {
- XModel model = nature.getModel();
- XModelObject webXML = WebAppHelper.getWebApp(model);
- XModelObject param = WebAppHelper.findWebAppContextParam(webXML, "javax.faces.DEFAULT_SUFFIX");
- if ( param != null ) {
- String value = param.getAttributeValue("param-value");
-
- if ( value.length() != 0 && iFile.getName().endsWith(value)) {
- isFacelet = true;
- }
- }
- }
+ /**
+ * @param visualDocument
+ * the visualDocument to set
+ */
+ protected void setVisualDocument(nsIDOMDocument visualDocument) {
+ this.visualDocument = visualDocument;
+ }
+
+ /**
+ * Check this file is facelet
+ *
+ * @return this if file is facelet, otherwize false
+ */
+ private boolean isFacelet() {
+ boolean isFacelet = false;
+
+ IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
+ if (iEditorInput instanceof IFileEditorInput) {
+ IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
+
+ IFile iFile = iFileEditorInput.getFile();
+
+ IProject project = iFile.getProject();
+ IModelNature nature = EclipseResourceUtil.getModelNature(project);
+ if (nature != null) {
+ XModel model = nature.getModel();
+ XModelObject webXML = WebAppHelper.getWebApp(model);
+ XModelObject param = WebAppHelper.findWebAppContextParam(
+ webXML, "javax.faces.DEFAULT_SUFFIX");
+ if (param != null) {
+ String value = param.getAttributeValue("param-value");
+
+ if (value.length() != 0 && iFile.getName().endsWith(value)) {
+ isFacelet = true;
+ }
}
-
- return isFacelet;
+ }
}
- /**
- * Create a visual element for text node
- * @param sourceNode
- * @param registerFlag
- * @return a visual element for text node
- */
-
- protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag ) {
- String sourceText = sourceNode.getNodeValue();
- if (sourceText.trim().length() <= 0) {
- registerNodes(new VpeNodeMapping(sourceNode, null));
- return null;
- }
+ return isFacelet;
+ }
- if (faceletFile) {
- Matcher matcher_EL = REGEX_EL.matcher(sourceText);
- if (matcher_EL.find()) {
- BundleMap bundle = pageContext.getBundle();
- int offset = pageContext.getVisualBuilder().getCurrentMainIncludeOffset();
- if (offset == -1) offset = ((IndexedRegion)sourceNode).getStartOffset();
- String jsfValue = bundle.getBundleValue(sourceText, offset);
- sourceText = jsfValue;
- }
- }
- String visualText = TextUtil.visualText(sourceText);
+ /**
+ * Create a visual element for text node
+ *
+ * @param sourceNode
+ * @param registerFlag
+ * @return a visual element for text node
+ */
- nsIDOMNode visualNewTextNode = visualDocument.createTextNode(visualText);
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, visualNewTextNode));
- }
+ protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
+ String sourceText = sourceNode.getNodeValue();
+ if (sourceText.trim().length() <= 0) {
+ registerNodes(new VpeNodeMapping(sourceNode, null));
+ return null;
+ }
- return visualNewTextNode;
+ if (faceletFile) {
+ Matcher matcher_EL = REGEX_EL.matcher(sourceText);
+ if (matcher_EL.find()) {
+ BundleMap bundle = pageContext.getBundle();
+ int offset = pageContext.getVisualBuilder()
+ .getCurrentMainIncludeOffset();
+ if (offset == -1)
+ offset = ((IndexedRegion) sourceNode).getStartOffset();
+ String jsfValue = bundle.getBundleValue(sourceText, offset);
+ sourceText = jsfValue;
+ }
}
+ String visualText = TextUtil.visualText(sourceText);
- /**
- * @return the xulRunnerEditor
- */
- public XulRunnerEditor getXulRunnerEditor() {
- return xulRunnerEditor;
+ nsIDOMNode visualNewTextNode = visualDocument
+ .createTextNode(visualText);
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, visualNewTextNode));
}
- /**
- * @param xulRunnerEditor the xulRunnerEditor to set
- */
- public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
- this.xulRunnerEditor = xulRunnerEditor;
- }
+ return visualNewTextNode;
+ }
+
+ /**
+ * @return the xulRunnerEditor
+ */
+ public XulRunnerEditor getXulRunnerEditor() {
+ return xulRunnerEditor;
+ }
+
+ /**
+ * @param xulRunnerEditor
+ * the xulRunnerEditor to set
+ */
+ public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
+ this.xulRunnerEditor = xulRunnerEditor;
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDndUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDndUtil.java 2007-11-01 19:49:18 UTC (rev 4646)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeDndUtil.java 2007-11-01 19:50:18 UTC (rev 4647)
@@ -7,79 +7,38 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.util;
import java.util.Properties;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.graphics.Rectangle;
import org.jboss.tools.common.model.ui.dnd.DnDUtil;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.vpe.VpePlugin;
-import org.mozilla.interfaces.nsIDOMNSHTMLElement;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.xpcom.XPCOMException;
public class VpeDndUtil {
- public static boolean isDropEnabled(IModelObjectEditorInput input){
- return DnDUtil.isPasteEnabled(input.getXModelObject());
- }
-
- public static void drop(IModelObjectEditorInput input, ISourceViewer viewer, ISelectionProvider provider){
- Properties properties = new Properties();
- properties.setProperty("isDrop", "true");
- properties.setProperty("actionSourceGUIComponentID", "editor");
- properties.setProperty("accepsAsString", "true");
- properties.put("selectionProvider", provider);
- properties.put("viewer", viewer);
-
- try{
- DnDUtil.paste(input.getXModelObject(), properties);
- PaletteInsertHelper.insertIntoEditor(viewer, properties);
- }catch(Exception ex){
- VpePlugin.getPluginLog().logError(ex);
- }
- }
-
- /**
- *
- * @param visualNode
- * @return returns absolute position and size of visual node
- */
- public static Rectangle getBounds(nsIDOMNode visualNode) {
- try {
-
- nsIDOMNSHTMLElement domNSHTMLElement = (nsIDOMNSHTMLElement) visualNode.queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
- int offsetLeft=domNSHTMLElement.getOffsetLeft();
- int offsetTop =domNSHTMLElement.getOffsetTop();
- int offsetWidth=domNSHTMLElement.getOffsetWidth();
- int offsetHeight=domNSHTMLElement.getOffsetHeight();
- while(true) {
-
- try{
-
- if(domNSHTMLElement.getOffsetParent()==null) {
- break;
- }
-
- domNSHTMLElement=(nsIDOMNSHTMLElement) domNSHTMLElement.getOffsetParent().queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
- offsetLeft+=domNSHTMLElement.getOffsetLeft();
- offsetTop+=domNSHTMLElement.getOffsetTop();
- } catch(XPCOMException ex){
- break;
- }
- }
+ public static boolean isDropEnabled(IModelObjectEditorInput input) {
+ return DnDUtil.isPasteEnabled(input.getXModelObject());
+ }
- return new Rectangle(offsetLeft, offsetTop,offsetWidth,offsetHeight);
-
- } catch(XPCOMException xpcomException) {
-
- //TODO Max Areshkau
- //If node not not implement nsIDOMNSHTMLElement, may be check best take a parent node
- return new Rectangle(0, 0, 0,0);
- }
+ public static void drop(IModelObjectEditorInput input,
+ ISourceViewer viewer, ISelectionProvider provider) {
+ Properties properties = new Properties();
+ properties.setProperty("isDrop", "true");
+ properties.setProperty("actionSourceGUIComponentID", "editor");
+ properties.setProperty("accepsAsString", "true");
+ properties.put("selectionProvider", provider);
+ properties.put("viewer", viewer);
+
+ try {
+ DnDUtil.paste(input.getXModelObject(), properties);
+ PaletteInsertHelper.insertIntoEditor(viewer, properties);
+ } catch (Exception ex) {
+ VpePlugin.getPluginLog().logError(ex);
}
+ }
+
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java 2007-11-01 19:49:18 UTC (rev 4646)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerVpeUtils.java 2007-11-01 19:50:18 UTC (rev 4647)
@@ -12,44 +12,35 @@
package org.jboss.tools.vpe.xulrunner.editor;
import org.eclipse.swt.graphics.Rectangle;
+import org.mozilla.interfaces.nsIBoxObject;
+import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNSHTMLElement;
+import org.mozilla.interfaces.nsIDOMNSDocument;
+import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.xpcom.XPCOMException;
/**
- * @author A. Yukhovich
+ * @author dsakovich(a)exadel.com
*/
public class XulRunnerVpeUtils {
- /**
- * @param domElement
- * @return
- */
- static public Rectangle getElementBounds(nsIDOMElement domElement) {
- try {
- nsIDOMNSHTMLElement domNSHTMLElement = (nsIDOMNSHTMLElement) domElement.queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
- int offsetLeft = domNSHTMLElement.getOffsetLeft();
- int offsetTop = domNSHTMLElement.getOffsetTop();
- int width = domNSHTMLElement.getOffsetWidth();
- int height = domNSHTMLElement.getOffsetHeight();
-
- while (true) {
- try {
- if (domNSHTMLElement.getOffsetParent() == null) {
- break;
- }
+ /**
+ * @param domElement
+ * @return Rectangle
+ */
+ static public Rectangle getElementBounds(nsIDOMNode domNode) {
+ try {
+ nsIDOMElement domElement = (nsIDOMElement) domNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMDocument document = domElement.getOwnerDocument();
+ nsIDOMNSDocument nsDocument = (nsIDOMNSDocument) document
+ .queryInterface(nsIDOMNSDocument.NS_IDOMNSDOCUMENT_IID);
+ nsIBoxObject boxObject = nsDocument.getBoxObjectFor(domElement);
+ return new Rectangle(boxObject.getX(), boxObject.getY(), boxObject
+ .getWidth(), boxObject.getHeight());
- domNSHTMLElement = (nsIDOMNSHTMLElement) domNSHTMLElement.getOffsetParent().queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
- offsetLeft += domNSHTMLElement.getOffsetLeft();
- offsetTop += domNSHTMLElement.getOffsetTop();
- } catch (XPCOMException ex) {
- break;
- }
- }
- return new Rectangle(offsetLeft, offsetTop, width, height);
-
- } catch (XPCOMException xpcomException) {
- return new Rectangle(0, 0, 0, 0);
- }
+ } catch (XPCOMException xpcomException) {
+ return new Rectangle(0, 0, 0, 0);
}
+ }
}
17 years, 2 months
JBoss Tools SVN: r4646 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-01 15:49:18 -0400 (Thu, 01 Nov 2007)
New Revision: 4646
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
Log:
fixed layout in File Filter dialog
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2007-11-01 18:43:01 UTC (rev 4645)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2007-11-01 19:49:18 UTC (rev 4646)
@@ -45,6 +45,7 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -577,7 +578,7 @@
return null;
}
- protected class FilesetDialog extends Dialog {
+ protected class FilesetDialog extends TitleAreaDialog {
protected Fileset fileset;
private String name, dir, includes, excludes;
private Button browse;
@@ -588,6 +589,7 @@
super(parentShell);
this.fileset = new Fileset();
this.fileset.setFolder(defaultLocation);
+
}
protected FilesetDialog(Shell parentShell, Fileset fileset) {
super(parentShell);
@@ -608,6 +610,9 @@
}
protected Control createDialogArea(Composite parent) {
+ setTitle("File filter");
+ setMessage("Creates a new file filter");
+
Composite sup = (Composite) super.createDialogArea(parent);
main = new Composite(sup, SWT.NONE);
main.setLayout(new GridLayout(3, false));
@@ -686,7 +691,19 @@
excludesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Group previewWrapper = new Group(main, SWT.NONE);
- previewWrapper.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 3, 3));
+
+ previewWrapper.setLayout(new GridLayout());
+ GridLayout gridLayout = new GridLayout();
+ //gridLayout.numColumns = 3;
+ //gridLayout.verticalSpacing = 9;
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.grabExcessHorizontalSpace = true;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalSpan = 3;
+ data.minimumHeight = 200;
+
+ previewWrapper.setLayoutData(data);
previewWrapper.setText(Messages.FilesetsNewPreview);
previewWrapper.setLayout(new FillLayout());
17 years, 2 months
JBoss Tools SVN: r4645 - trunk/documentation/GettingStartedGuide/docs/userguide/en/images/WriteYourFirst.
by jbosstools-commits@lists.jboss.org
Author: ykryvinchanka
Date: 2007-11-01 14:43:01 -0400 (Thu, 01 Nov 2007)
New Revision: 4645
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/WriteYourFirst/SeamNewProj01.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/WriteYourFirst/newseamproj22.png
Log:
http://jira.jboss.com/jira/browse/RHDS-166 GSG. Screens updated
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/WriteYourFirst/SeamNewProj01.png
===================================================================
(Binary files differ)
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/WriteYourFirst/newseamproj22.png
===================================================================
(Binary files differ)
17 years, 2 months