Author: dgolovin
Date: 2008-08-29 20:06:07 -0400 (Fri, 29 Aug 2008)
New Revision: 9969
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.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/NodesManagingUtil.java
Log:
PMD violations fixed.
InputStreams close() added where it was possible.
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -70,13 +70,15 @@
if(eclipse!=null) {
Dictionary eclipseDic = eclipse.getHeaders();
eclipseVersion = (String)eclipseDic.get("Bundle-Version");
+ FileInputStream fis = null;
try {
String path = FileLocator.resolve(eclipse.getEntry("/")).getPath();
if(path!=null) {
File aboutMappings = new File(path, "about.mappings");
if(aboutMappings.exists()) {
Properties properties = new Properties();
- properties.load(new FileInputStream(aboutMappings));
+ fis = new FileInputStream(aboutMappings);
+ properties.load(fis);
String buildId = properties.getProperty("0");
if(buildId!=null && buildId.length()>0) {
eclipseBuildId = buildId;
@@ -85,6 +87,14 @@
}
} catch (IOException e) {
getPluginLog().logError("Error in getting environment info: " +
e.getMessage());
+ } finally {
+ if(fis!=null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
StringBuffer result = new StringBuffer(studioName).append("
").append(studioVersion).
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -62,9 +62,10 @@
public static ReadBytes readBytes(File f) {
if(!f.isFile()) return null;
+ BufferedInputStream br = null;
try {
FileInputStream fr = new FileInputStream(f);
- BufferedInputStream br = new BufferedInputStream(fr);
+ br = new BufferedInputStream(fr);
int l = (int)f.length();
byte[] bs = new byte[l];
l = br.read(bs, 0, l);
@@ -73,6 +74,14 @@
return new ReadBytes(bs, l);
} catch (IOException e) {
return null;
+ } finally {
+ if(br!=null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ }
}
}
@@ -98,9 +107,10 @@
public static boolean isTextFile(File f, int length) {
if(!f.isFile()) return false;
+ BufferedReader br = null;
try {
FileReader fr = new FileReader(f);
- BufferedReader br = new BufferedReader(fr);
+ br = new BufferedReader(fr);
int l = (int)f.length();
if(l > length) l = length;
char[] cs = new char[l];
@@ -110,6 +120,14 @@
return isText(new String(cs));
} catch (IOException e) {
return false;
+ } finally {
+ if(br!=null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -38,12 +38,13 @@
XMLInputSource result = null;
String systemId = null;
String publicId = null;
+ InputStream is = null;
try {
DtdResolver resolver = new DtdResolver();
systemId =
rid.getBaseSystemId()==null?rid.getLiteralSystemId():rid.getExpandedSystemId();
publicId = rid.getPublicId();
- InputStream is = resolver.getInputStream(rid.getPublicId(), systemId);
+ is = resolver.getInputStream(rid.getPublicId(), systemId);
if(is!=null) {
result = new XMLInputSource(rid.getPublicId(), systemId,
rid.getBaseSystemId(), is, null);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -163,10 +163,7 @@
* @return
*/
public boolean isCloseTag() {
- if((label!=null)&&(label.startsWith("/"))) {
- return true;
- }
- return false;
+ return label != null && label.startsWith("/");
}
/**
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -93,7 +93,18 @@
}
return null;
}
- Document doc = convertToSchema(is, attributes, tldResource.isJsfResource());
+ Document doc = null;
+ try {
+ doc = convertToSchema(is, attributes, tldResource.isJsfResource());
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
String tldContent = tldResource.getTldContent();
if(doc!=null && tldContent!=null) {
Element tldContentElement = doc.createElement(SchemaNodeFactory.TLD_CONTENT_NODE);
@@ -108,11 +119,21 @@
* @see org.jboss.tools.common.kb.KbSchemaConvertor#convertToSchema(java.io.File)
*/
public Document convertToSchema(File tldFile) {
+ BufferedInputStream bis = null;
try {
- return convertToSchema(new BufferedInputStream(new FileInputStream(tldFile)), new
Properties(), false);
+ bis = new BufferedInputStream(new FileInputStream(tldFile));
+ return convertToSchema(bis, new Properties(), false);
} catch (FileNotFoundException e) {
KbPlugin.getPluginLog().logError(e);
return null;
+ } finally {
+ if(bis!=null) {
+ try {
+ bis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -16,40 +16,6 @@
public OpenWithExternalBrowserHandler() {}
- /*
- public boolean isEnabled(XModelObject object) {
- if(object == null || object.getFileType() != object.FILE) return false;
- String s = getEditorName(object);
- boolean b = (s != null);
- if(!b) s = "?";
- ((XActionImpl)action).setDisplayName(s);
- return b;
- }
-
- public void executeHandler(XModelObject object, Properties p) throws XModelException
{
- if(!isEnabled(object)) return;
- String f = getFileName(object);
- String ext = OpenWithHelper.getExtension(f);
- XModelObject editor = OpenWithHelper.getEditorObject(object.getModel(), ext);
- if(editor == null) throw new RuntimeException("External editor for file
extension '" + ext + "' is not set.");
- start(action.getDisplayName(), f, editor);
- }
-
- protected String getFileName(XModelObject object) {
- return OpenWithHelper.getFileName(object);
- }
- */
-
-// private String getEditorName(XModelObject object) {
-// XModelObject o = object.getModel().getByPath(OpenWithHelper.EDITORS);
-// String[] es =
XModelObjectUtil.asStringArray(o.getAttributeValue("extensions"));
-// for (int i = 0; i < es.length; i++) {
-// if(!es[i].toLowerCase().startsWith("html:")) continue;
-// return es[i].substring("html:".length());
-// }
-// return null;
-// }
-
public static void start(String actionname, String url, XModelObject editor) throws
XModelException {
if(OpenWithHelper.validatePath(actionname, editor)) new OWEProcess(editor,
url).start();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -74,7 +74,7 @@
public static void start(String actionname, String filename, XModelObject editor)
throws XModelException {
int i = filename.indexOf('#');
String fn = (i < 0) ? filename : filename.substring(0, i);
- if(!new File(fn).isFile()) throw new RuntimeException("Cannot find file
" + fn + ".");
+ if(!new File(fn).isFile()) throw new IllegalArgumentException("Cannot find
file " + fn + ".");
if(OpenWithHelper.validatePath(actionname, editor)) new OWEProcess(editor,
filename).start();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -90,29 +90,40 @@
void load(String name, URL url) {
if(url == null) return;
// long t = System.currentTimeMillis();
- InputStream stream = null;
+ InputStream stream1 = null;
+ InputStream stream2 = null;
try {
- stream = url.openStream();
- stream = new BufferedInputStream(stream, 16384);
+ stream1 = url.openStream();
+ stream2 = new BufferedInputStream(stream1, 16384);
+
+
+ Element g = parse(stream2);
+ if(g == null) {
+ ModelPlugin.getPluginLog().logInfo("Corrupted meta resource " + name);
+ } else {
+ load0(g, name, url.toString());
+ }
+
} catch (IOException e) {
ModelPlugin.getPluginLog().logError("MetaLoader: Cannot read resource " +
url.toString());
return;
+ } finally {
+ if(stream2!=null) {
+ try {
+ stream2.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
- Element g = parse(stream);
- //XMLUtil.getElement(stream);
- if(g == null) {
- ModelPlugin.getPluginLog().logInfo("Corrupted meta resource " + name);
- } else {
- load0(g, name, url.toString());
- }
-
// long dt = - t + (t = System.currentTimeMillis());
// System.out.println("Loaded " + url + " in " + dt + "
ms");
if(validateMetaXML) {
+ InputStream stream3 = null;
try {
- stream = url.openStream();
- InputSource is = new InputSource(stream);
+ stream3 = url.openStream();
+ InputSource is = new InputSource(stream3);
String[] errors = XMLUtil.getXMLErrors(is, true);
if(errors != null && errors.length > 0) {
ModelPlugin.getPluginLog().logInfo("Errors in " + name);
@@ -122,6 +133,14 @@
}
} catch (IOException e) {
ModelPlugin.getPluginLog().logError(e);
+ }finally {
+ if(stream3!=null) {
+ try {
+ stream3.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
// dt = - t + (t = System.currentTimeMillis());
// System.out.println("Validated " + url + " in " + dt + "
ms");
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.meta.impl;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
import org.w3c.dom.*;
@@ -102,9 +103,9 @@
// meta data loading
- static Element loadDocument(String filename) {
+ static Element loadDocument(String filename) throws FileNotFoundException {
Element e = XMLUtil.getElement(filename);
- if(e == null) throw new RuntimeException("Can't load meta model from
" + filename);
+ if(e == null) throw new FileNotFoundException("Can't load meta model
from " + filename);
return e;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -273,8 +273,9 @@
protected void replace() {
StringBuffer sb = new StringBuffer();
+ BufferedReader br = null;
try {
- BufferedReader br = new BufferedReader(new FileReader(new File(filename)));
+ br = new BufferedReader(new FileReader(new File(filename)));
char[] b = new char[256];
int i = 0;
while((i = br.read(b, 0, 256)) > 0) {
@@ -282,7 +283,15 @@
}
} catch (IOException e) {
ModelPlugin.getPluginLog().logError(e);
- }
+ } finally {
+ try {
+ if(br!=null) {
+ br.close();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
+ }
int i = 0;
while(i < sb.length()) {
if(sb.charAt(i) == '&') sb.replace(i + 1, i + 5, "");
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -190,9 +190,10 @@
return "";
}
int length = 0;
+ BufferedInputStream bs = null;
try {
InputStream is = jar.getInputStream(jar.getEntry(path));
- BufferedInputStream bs = new BufferedInputStream(is);
+ bs = new BufferedInputStream(is);
while ((length = bs.available()) > 0) {
if (length > size)
length = size;
@@ -207,6 +208,13 @@
return "";
} finally {
unlockJar();
+ if(bs!=null) {
+ try {
+ bs.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ }
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -55,8 +55,9 @@
File f = new File(filename);
if(!f.isFile()) return new byte[0];
byte[] b = null;
+ FileInputStream fr = null;
try {
- FileInputStream fr = new FileInputStream(f);
+ fr = new FileInputStream(f);
int length = fr.available();
b = new byte[length];
int i = 0;
@@ -65,6 +66,14 @@
}
} catch (IOException e) {
b = new byte[0];
+ } finally {
+ if(fr != null) {
+ try {
+ fr.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
return b;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -438,7 +438,7 @@
public void setExtraRoot(XModelObject r) {
String pathpart = r.getPathPart();
- if(!pathpart.startsWith("root:")) throw new RuntimeException("Not
extra root: " + pathpart);
+ if(!pathpart.startsWith("root:")) throw new
IllegalArgumentException("Not extra root: " + pathpart);
extraroots.put(pathpart, r);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -10,19 +10,29 @@
******************************************************************************/
package org.jboss.tools.common.model.impl;
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.resources.*;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.views.properties.IPropertySource;
-
-import org.jboss.tools.common.meta.*;
-import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.XMapping;
+import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.adapter.IModelObjectAdapter;
import org.jboss.tools.common.model.adapter.ModelObjectAdapterExtensionPoint;
-import org.jboss.tools.common.model.icons.impl.*;
+import org.jboss.tools.common.model.icons.impl.XModelObjectIcon;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class XModelObjectImpl implements XModelObject, Serializable, Cloneable {
@@ -54,9 +64,9 @@
public void changeEntity(String name) {
if(entity.getName().equals(name)) return;
XModelEntity newEntity = entity.getMetaModel().getEntity(name);
- if(newEntity == null) throw new RuntimeException("Entity " + name + "
does not exist.");
+ if(newEntity == null) throw new IllegalArgumentException("Entity " + name
+ " does not exist.");
if(entity.getImplementingClass() != newEntity.getImplementingClass()) {
- throw new RuntimeException("Cannot convert entity " + entity.getName() +
" to " + name + " because they have different implementations.");
+ throw new IllegalArgumentException("Cannot convert entity " +
entity.getName() + " to " + name + " because they have different
implementations.");
}
Properties p = new Properties();
XAttribute[] as = entity.getAttributes();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.common.model.impl.trees;
-import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.MethodNotImplementedException;
+import org.jboss.tools.common.model.XFilteredTree;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
public abstract class DefaultSiftedTree implements XFilteredTree {
@@ -38,17 +41,17 @@
}
public boolean isSelectable(XModelObject object) {
- throw new RuntimeException("Not implemented");
+ throw new MethodNotImplementedException("Not implemented");
}
public String getValue(XModelObject object) {
- throw new RuntimeException("Not implemented");
+ throw new MethodNotImplementedException("Not implemented");
}
public void setConstraint(Object object) {}
public XModelObject find(String value) {
- throw new RuntimeException("Not implemented");
+ throw new MethodNotImplementedException("Not implemented");
}
public XModelObject getParent(XModelObject object) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -6,7 +6,11 @@
*/
package org.jboss.tools.common.model.options;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
import org.jboss.tools.common.model.XModelException;
@@ -47,7 +51,7 @@
}
public void setValue(String value) throws XModelException {
- if(switchPreference==null) throw new NullPointerException("switchPreference cannot
be null, call setSwitchPreferenceFirst.");
+ if(switchPreference==null) throw new IllegalStateException("switchPreference
cannot be null, call setSwitchPreferenceFirst.");
Preference preference = (Preference)preferencesMap.get(switchPreference.getValue());
if(preference==null) throw new IllegalStateException("Preference in't added
for switch value '" + switchPreference.getValue() + "'");
preference.setValue(value);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -10,13 +10,19 @@
******************************************************************************/
package org.jboss.tools.common.model.options.impl;
-import java.util.*;
-import org.w3c.dom.*;
-import org.jboss.tools.common.meta.*;
+import java.util.Properties;
+
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.XChild;
+import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.XModelConstants;
-import org.jboss.tools.common.model.options.*;
+import org.jboss.tools.common.model.options.SharableConstants;
+import org.jboss.tools.common.model.options.SharableElement;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public class SharableLoaderImpl implements SharableConstants {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -19,6 +19,7 @@
* @version 1.0
*/
+import java.io.IOException;
import java.util.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -88,6 +89,14 @@
}
} catch (java.io.IOException e) {
ModelPlugin.getPluginLog().logError(e);
+ } finally {
+ if(br!=null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
return envVars;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -166,13 +166,22 @@
if (path!=null) {
File propertiesFile = path.toFile();
if (propertiesFile.exists() && propertiesFile.canRead()) {
+ InputStream is = null;
try {
- InputStream is = new FileInputStream(propertiesFile);
+ is = new FileInputStream(propertiesFile);
properties = new PropertyResourceBundle(is);
} catch (FileNotFoundException e) {
ModelUIPlugin.getPluginLog().logError(e);
} catch (IOException e) {
ModelUIPlugin.getPluginLog().logError(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -112,7 +112,7 @@
try {
result[0] = element.createExecutableExtension(name);
}
- catch (Exception e) {
+ catch (CoreException e) {
handleCreateExecutableException(result, e);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -67,32 +67,23 @@
}
public void redrawRange(int start, int length, boolean clearBackground) {
- try {
+ //FIX for JBIDE-1479 added by Max Areshkau
+ if (start > getCharCount())
+ start = getCharCount();
+ if (start + length > getCharCount())
+ length = getCharCount() - start;
+
+ //FIX for JBIDE-2192
+ if (length > 0) {
super.redrawRange(start, length, clearBackground);
- } catch (Exception x) {
- // ignore
- //FIX for JBIDE-1479 added by Max Areshkau
- if (start > getCharCount())
- start = getCharCount();
- if (start + length > getCharCount())
- length = getCharCount() - start;
-
- //FIX for JBIDE-2192
- if (length > 0) {
- super.redrawRange(start, length, clearBackground);
- }
}
}
public int getLineAtOffset(int offset) {
- try {
- return super.getLineAtOffset(offset);
- } catch (Exception e) {
- if (offset > getCharCount())
- offset = getCharCount();
- if (offset < 0)
- offset = 0;
- return super.getLineAtOffset(offset);
- }
+ if (offset > getCharCount())
+ offset = getCharCount();
+ if (offset < 0)
+ offset = 0;
+ return super.getLineAtOffset(offset);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.jboss.tools.common.text.xml.xpl;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ResourceBundle;
@@ -24,7 +25,6 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
-
import org.jboss.tools.common.text.xml.IOccurrencePreferenceProvider;
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
import org.jboss.tools.jst.jsp.preferences.xpl.Messages;
@@ -56,20 +56,16 @@
*/
public void setEditor(ITextEditor editor) {
super.setEditor(editor);
- try {
- fOccurrencePreferenceProvider = null;
- StructuredTextEditor sse = getStructuredTextEditor(getTextEditor());
- if (sse != null && sse instanceof IOccurrencePreferenceProvider) {
- fOccurrencePreferenceProvider = (IOccurrencePreferenceProvider)sse;
- if (fOccurrencePreferenceProvider != null) {
- fEditorId =
fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getEditorId();
- fKey = PreferenceKeyGenerator.generateKey(
- OccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
- fEditorId);
- }
+ fOccurrencePreferenceProvider = null;
+ StructuredTextEditor sse = getStructuredTextEditor(getTextEditor());
+ if (sse != null && sse instanceof IOccurrencePreferenceProvider) {
+ fOccurrencePreferenceProvider = (IOccurrencePreferenceProvider)sse;
+ if (fOccurrencePreferenceProvider != null) {
+ fEditorId =
fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getEditorId();
+ fKey = PreferenceKeyGenerator.generateKey(
+ OccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
+ fEditorId);
}
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
update();
}
@@ -125,13 +121,9 @@
public void run() {
boolean markOccurences = false;
- try {
- // determine if action should be enabled or not
- markOccurences = fPreferenceStore.getBoolean(fKey);
- fPreferenceStore.setValue(fKey, !markOccurences);
- } catch (Exception x) {
- //ignore
- }
+ // determine if action should be enabled or not
+ markOccurences = fPreferenceStore.getBoolean(fKey);
+ fPreferenceStore.setValue(fKey, !markOccurences);
}
/**
@@ -140,19 +132,14 @@
*/
public void update() {
IPreferenceStore newStore = null;
-
- try {
- super.update();
- newStore = (fOccurrencePreferenceProvider == null ? null :
fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getPreferenceStore());
- if (newStore != fPreferenceStore) {
- if (fPreferenceStore != null)
- fPreferenceStore.removePropertyChangeListener(this);
- fPreferenceStore = newStore;
- if (fPreferenceStore != null)
- fPreferenceStore.addPropertyChangeListener(this);
- }
- } catch (Exception x) {
- //ignore
+ super.update();
+ newStore = (fOccurrencePreferenceProvider == null ? null :
fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getPreferenceStore());
+ if (newStore != fPreferenceStore) {
+ if (fPreferenceStore != null)
+ fPreferenceStore.removePropertyChangeListener(this);
+ fPreferenceStore = newStore;
+ if (fPreferenceStore != null)
+ fPreferenceStore.addPropertyChangeListener(this);
}
boolean markOccurences = false;
@@ -183,7 +170,7 @@
URL base = null;
try {
base =
FileLocator.resolve(XmlEditorPlugin.getDefault().getBundle().getEntry("/"));
- } catch (Exception e) {
+ } catch (IOException e) {
XmlEditorPlugin.getPluginLog().logError(e);
return null;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -56,17 +56,17 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
import org.jboss.tools.common.text.xml.ui.xpl.ISelectionListenerWithSM;
import org.jboss.tools.common.text.xml.ui.xpl.SelectionListenerWithSMManager;
import org.jboss.tools.common.text.xml.ui.xpl.UIMessages;
import org.jboss.tools.jst.jsp.preferences.xpl.PreferenceKeyGenerator;
import org.jboss.tools.jst.jsp.preferences.xpl.XMLOccurrencePreferenceConstants;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* @author Jeremy
@@ -353,7 +353,6 @@
* @see
com.ibm.sse.editor.ui.text.IStructuredTextOccurenceStructureProvider#install(org.eclipse.ui.texteditor.ITextEditor,
org.eclipse.jface.text.source.projection.ProjectionViewer)
*/
public void install(StructuredTextEditor editor, ProjectionViewer viewer) {
- // TODO Auto-generated method stub
this.fEditor = editor;
this.fViewer = viewer;
@@ -368,7 +367,6 @@
* @see
com.ibm.sse.editor.ui.text.IStructuredTextOccurenceStructureProvider#uninstall()
*/
public void uninstall() {
- // TODO Auto-generated method stub
// cancel possible running computation
fMarkOccurrenceAnnotations= false;
uninstallOccurrencesFinder();
@@ -380,43 +378,37 @@
* @see
com.ibm.sse.editor.ui.text.IStructuredTextOccurenceStructureProvider#initialize()
*/
public void initialize() {
- // Initialize preferences
- try {
- fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener);
+ fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener);
- fMarkOccurrenceAnnotations =
fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
- fEditorID));
+ fMarkOccurrenceAnnotations =
fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
+ fEditorID));
- fMarkNodeOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_NODE_OCCURRENCES,
- fEditorID));
+ fMarkNodeOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_NODE_OCCURRENCES,
+ fEditorID));
-
- fMarkAttributeOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_OCCURRENCES,
- fEditorID));
+
+ fMarkAttributeOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_OCCURRENCES,
+ fEditorID));
- fMarkAttributeValueOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_VALUE_OCCURRENCES,
- fEditorID));
+ fMarkAttributeValueOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_VALUE_OCCURRENCES,
+ fEditorID));
- fMarkTextOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_TEXT_OCCURRENCES,
- fEditorID));
+ fMarkTextOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_TEXT_OCCURRENCES,
+ fEditorID));
- fStickyOccurrenceAnnotations =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_STICKY_OCCURRENCES,
- fEditorID));
-
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
- }
+ fStickyOccurrenceAnnotations =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_STICKY_OCCURRENCES,
+ fEditorID));
}
ProjectionViewer getSourceViewer() {
@@ -512,18 +504,15 @@
Document dom = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() :
null;
List matches = findMatches(dom, model, selection);
-// System.out.println("Matches size = " + (matches == null || matches.size()
== 0 ? 0 : matches.size()));
if (matches == null || matches.size() == 0) {
if (!fStickyOccurrenceAnnotations)
removeOccurrenceAnnotations();
return;
}
-// Position[] positions= new Position[matches.size()];
List positionsList = new ArrayList();
int i= 0;
for (Iterator each= matches.iterator(); each.hasNext();) {
-// ASTNode currentNode= (ASTNode)each.next();
Object current = each.next();
if (current instanceof IDOMElement) {
IDOMElement currentNode = (IDOMElement)current;
@@ -539,24 +528,17 @@
positionsList.add(new Position(start, end - start));
}
-// positions[i++]= new Position(currentNode.getStartOffset(),
currentNode.getEndOffset() - currentNode.getStartOffset());
} else if (current instanceof ITextRegion) {
ITextRegion currentRegion = (ITextRegion)current;
positionsList.add(new Position(currentRegion.getStart(),
currentRegion.getLength()));
-// positions[i++]= new Position(currentRegion.getStart(), currentRegion.getLength());
} else if (current instanceof Position) {
Position currentPosition = (Position)current;
positionsList.add(new Position(currentPosition.getOffset(),
currentPosition.getLength()));
-// positions[i++]= new Position(currentPosition.getOffset(),
currentPosition.getLength());
}
}
if (positionsList.size() == 0) return;
-// removeOccurrenceAnnotations();
fOccurrencesFinderJob= new OccurrencesFinderJob(document,
(Position[])positionsList.toArray(new Position[positionsList.size()]), selection);
- //fOccurrencesFinderJob.setPriority(Job.DECORATE);
- //fOccurrencesFinderJob.setSystem(true);
- //fOccurrencesFinderJob.schedule();
fOccurrencesFinderJob.run(new NullProgressMonitor());
}
@@ -584,7 +566,7 @@
IDOMText xmlText = (IDOMText)region;
return findTextMatches(dom, xmlText.getData().trim());
}
- } catch (Exception x) {
+ } catch (DOMException x) {
XmlEditorPlugin.getPluginLog().logError(x);
}
return new ArrayList();
@@ -596,12 +578,9 @@
if (fMarkNodeOccurrences) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if(children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTagOccurencies(matches, xmlNode, tagName);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -629,12 +608,9 @@
if (fMarkAttributeOccurrences) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if(children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTagAttrNameOccurencies(matches, xmlNode, attrName);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -666,12 +642,9 @@
if (fMarkAttributeValueOccurrences) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if(children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTagAttrValueOccurencies(matches, xmlNode, attrValue);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -704,12 +677,9 @@
if (fMarkTextOccurrences && !isEmptyString (data)) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if (children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTextOccurencies(matches, xmlNode, data);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -717,8 +687,7 @@
}
private boolean isEmptyString(String str) {
- if (str == null || str.trim().length() == 0) return true;
- return false;
+ return str == null || str.trim().length() == 0;
}
private void addTextOccurencies(List matches, IDOMNode xmlNode, String data) {
@@ -728,7 +697,6 @@
IDOMText xmlText = (IDOMText)xmlNode;
String xmlData = xmlText.getData();
if (xmlData != null && xmlData.indexOf(data) != -1) {
-// matches.add(xmlText);
matches.add(
new Position(
xmlText.getStartOffset() + xmlData.indexOf(data), data.length()));
@@ -742,17 +710,7 @@
}
private boolean getEventNewBooleanValue(PropertyChangeEvent event) {
- boolean newValue = false;
- if (event.getNewValue() instanceof Boolean)
- newValue = ((Boolean) event.getNewValue()).booleanValue();
- else if (event.getNewValue() instanceof String) {
- String s= (String) event.getNewValue();
- if (IPreferenceStore.TRUE.equals(s))
- newValue= true;
- else if (IPreferenceStore.FALSE.equals(s))
- newValue= false;
- }
- return newValue;
+ return Boolean.getBoolean(event.getNewValue().toString());
}
/*
@@ -760,32 +718,25 @@
*/
public void handlePreferenceStoreChanged(PropertyChangeEvent event) {
- try {
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer == null)
- return;
-
+ ISourceViewer sourceViewer= getSourceViewer();
+ if (getSourceViewer() != null) {
String property= event.getProperty();
if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
boolean markOccurrences = getEventNewBooleanValue(event);
if (markOccurrences != fMarkOccurrenceAnnotations) {
fMarkOccurrenceAnnotations= markOccurrences;
-
- if (!fMarkOccurrenceAnnotations)
+
+ if (!fMarkOccurrenceAnnotations) {
uninstallOccurrencesFinder();
- else
+ } else {
installOccurrencesFinder();
+ }
}
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_OCCURRENCE_PROVIDER,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
if (event.getNewValue() instanceof String) {
String occurrenceProvider= (String)event.getNewValue();
if (occurrenceProvider != fOccurrenceProvider) {
@@ -796,52 +747,27 @@
}
}
}
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_NODE_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkNodeOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkAttributeOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_VALUE_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkAttributeValueOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_TEXT_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkAttributeValueOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
-
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_STICKY_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fStickyOccurrenceAnnotations= getEventNewBooleanValue(event);
-
- return;
}
-
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError("", x);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -36,12 +36,9 @@
IProject[] ps = ModelPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < ps.length; i++) {
IModelNature n = (IModelNature)EclipseResourceUtil.getModelNature(ps[i]);
- if(n == null) continue;
- try {
+ if (n != null) {
XModelObject o = FileSystemsHelper.getWebInf(n.getModel());
- clear(o);
- } catch (Exception e) {
- ModelPlugin.getPluginLog().logError(e);
+ clear(o);
}
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -117,9 +117,7 @@
VResult[] results = action.check(object);
notifyApplied(rule, object, results);
} catch (Exception e) {
- if(VerificationPlugin.isDebugEnabled()) {
VerificationPlugin.getPluginLog().logError("Exception in action
"+action+" ignored: "+e, e);
- }
}
checked = true;
if (checkChildren) break;
@@ -152,9 +150,7 @@
}
private void logListener(VTaskListener listener, Throwable e) {
- if(VerificationPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logInfo("Exception in listener
"+listener+" ignored: "+e, e);
- }
+ VerificationPlugin.getPluginLog().logInfo("Exception in listener
"+listener+" ignored: "+e, e);
}
private void notifyApplied(VRule rule, VObject object, VResult[] results) {
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -28,8 +28,7 @@
IConfigurationElement[] elements = es[i].getConfigurationElements();
for (int j = 0; j < elements.length; j++) {
String path = elements[j].getAttribute("path");
- if(path == null) continue;
- try {
+ if(path != null) {
URL url = bundle.getResource(path);
if(url != null) {
resources.add(url);
@@ -38,10 +37,6 @@
VerificationPlugin.getPluginLog().logInfo("Warning: meta resource " +
path + " not found.");
}
}
- } catch (Exception e) {
- if(ModelPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logError("Warning: meta resource " +
path + " not found.");
- }
}
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -8,7 +8,11 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.*;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
+
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -6,8 +6,8 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.verification.vrules.*;
-import org.jboss.tools.common.model.impl.*;
+import org.jboss.tools.common.model.impl.XModelObjectImpl;
+import org.jboss.tools.common.verification.vrules.VResult;
/**
*
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -6,11 +6,14 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.verification.vrules.*;
-import org.jboss.tools.common.model.impl.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.jboss.tools.common.model.impl.RegularObjectImpl;
+import org.jboss.tools.common.verification.vrules.VMessageFormat;
+import org.jboss.tools.common.verification.vrules.VResultTemplate;
+import org.jboss.tools.common.verification.vrules.VRule;
+
/**
*
* @author valera
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -6,13 +6,26 @@
package org.jboss.tools.common.verification.vrules.model;
-import java.util.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
-import org.jboss.tools.common.verification.vrules.*;
+import org.jboss.tools.common.verification.vrules.VAction;
+import org.jboss.tools.common.verification.vrules.VEntity;
+import org.jboss.tools.common.verification.vrules.VModel;
+import org.jboss.tools.common.verification.vrules.VObject;
+import org.jboss.tools.common.verification.vrules.VResult;
+import org.jboss.tools.common.verification.vrules.VResultTemplate;
+import org.jboss.tools.common.verification.vrules.VRule;
+import org.jboss.tools.common.verification.vrules.VRuleSet;
import org.jboss.tools.common.verification.vrules.impl.VResultFactoryImpl;
import org.jboss.tools.common.verification.vrules.impl.VRuleImpl;
import org.jboss.tools.common.verification.vrules.layer.VModelFactory;
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -8,10 +8,14 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.*;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.verification.vrules.VEntity;
import org.jboss.tools.common.verification.vrules.VModel;
@@ -102,7 +106,7 @@
}
bundles.put(baseName, NULL);
if(VerificationPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logInfo("Resource not found: " +
baseName + " by
org.jboss.tools.common.verification.vrules.model.VRuleSetModel:getBundle()", new
Exception(baseName));
+ VerificationPlugin.getPluginLog().logInfo("Resource not found: " +
baseName + " by
org.jboss.tools.common.verification.vrules.model.VRuleSetModel:getBundle()");
}
return null;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -5,18 +5,22 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.model.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.engines.impl.EnginesLoader;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.model.util.*;
-import org.jboss.tools.common.model.engines.impl.EnginesLoader;
+import org.jboss.tools.common.model.util.XMLUtil;
import org.jboss.tools.common.verification.vrules.plugin.VerificationPlugin;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import org.eclipse.core.runtime.FileLocator;
import org.w3c.dom.Element;
/**
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -6,8 +6,8 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.model.*;
-import org.jboss.tools.common.model.impl.trees.*;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.impl.trees.DefaultSiftedTree;
/**
*
@@ -29,7 +29,7 @@
VManagerModel man = (VManagerModel)prjs[0];
if (!man.developer && first) {
// bad luck :)
- throw new RuntimeException("Members only");
+ throw new IllegalStateException("Members only");
}
first = false;
return man;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -245,7 +245,7 @@
if(!includeMappings) {
org.dom4j.Document doc;
XMLHelper xmlHelper = new XMLHelper();
- InputStream stream;
+ InputStream stream = null;
String resourceName = "<unknown>"; //$NON-NLS-1$
try {
if(configXMLFile!=null) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -703,16 +703,25 @@
public void load(){
Properties properties = new Properties();
+ FileInputStream fis = null;
try{
File file = new File(getStoreFilePath().toOSString());
if(file.exists()){
- FileInputStream fis = new FileInputStream(file);
+ fis = new FileInputStream(file);
properties.load(fis);
propertiesInit(properties, this);
loadSuccessfull = true;
}
}catch(IOException ex){
VisualEditorPlugin.getDefault().logError("Can't load layout of
mapping.", ex); //$NON-NLS-1$
+ } finally {
+ if(fis!=null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -79,21 +79,31 @@
*
*/
public Class loadClassFromBinaryFile(String fileName) throws IOException {
- FileInputStream in = null;
- File f = new File(fileName);
- byte[] bytes;
- int fSize = 0;
- in = new FileInputStream(f);
- fSize = (int)f.length();
- bytes = new byte[fSize];
- int length = 0;
- while (length < fSize)
- {
- length += in.read(bytes,length,in.available());
- }
- Class clazz = defineClass(null,bytes,0,length,(CodeSource)null);
- in.close();
- return clazz;
+ FileInputStream in = null;
+ try {
+ File f = new File(fileName);
+ byte[] bytes;
+ int fSize = 0;
+ in = new FileInputStream(f);
+ fSize = (int)f.length();
+ bytes = new byte[fSize];
+ int length = 0;
+ while (length < fSize)
+ {
+ length += in.read(bytes,length,in.available());
+ }
+ Class clazz = defineClass(null,bytes,0,length,(CodeSource)null);
+ in.close();
+ return clazz;
+ } finally {
+ if(in!=null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -25,6 +25,7 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.RichFacesTemplatesActivator;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
@@ -106,7 +107,7 @@
div.appendChild(text);
return vpeCreationData;
}
-
+ BufferedReader br = null;
try {
IFile iFile = VpeCreatorUtil.getFile(srcValue, pageContext);
if (iFile==null || !iFile.isAccessible()) {
@@ -118,7 +119,7 @@
return vpeCreationData;
}
File file = new File(iFile.getLocation().toOSString());
- BufferedReader br = new BufferedReader(new InputStreamReader(
+ br = new BufferedReader(new InputStreamReader(
new FileInputStream(file)));
while ((buf = br.readLine()) != null)
finalStr += buf + "\n"; //$NON-NLS-1$
@@ -130,6 +131,14 @@
.createTextNode(RESOURCE_READING_ERROR_MESSAGE);
div.appendChild(text);
return vpeCreationData;
+ } finally {
+ try {
+ if(br!=null) {
+ br.close();
+ }
+ } catch (IOException e) {
+ RichFacesTemplatesActivator.getPluginLog().logError(e);
+ }
}
if ((highlightValue == null) || (!searchInSupportedTypes(highlightValue))){
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml 2008-08-30
00:06:07 UTC (rev 9969)
@@ -1,5 +1,4 @@
<?xml version="1.0"?>
-<?xml version="1.0"?>
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.jsp.outline.cssdialog;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
@@ -599,7 +600,7 @@
.getDisplay(), SWT.CURSOR_WAIT);
Point previewPoint = new Point(0, 0);
Point labelPoint = canvas.getSize();
- InputStream stream;
+ InputStream stream=null;
try {
getShell().setCursor(waitCursor);
stream = new FileInputStream(file.getLocation()
@@ -653,10 +654,17 @@
image.dispose();
gc.dispose();
}
- } catch (Exception ev) {
+ } catch (IOException ev) {
} finally {
- getShell().setCursor(parentCursor);
+ getShell().setCursor(parentCursor);
+ if(stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e1) {
+ // ignore
+ }
+ }
}
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -138,13 +138,21 @@
if(p == null) continue;
File f = p.toFile();
Properties properties = new Properties();
+ FileInputStream is = null;
try {
- FileInputStream is = new FileInputStream(f);
+ is = new FileInputStream(f);
properties.load(is);
- is.close();
} catch (IOException e) {
//ignore
//TODO keep error for validation
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
Set<?> s = properties.keySet();
for (Object o : s) keys.add((String)o);
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 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -97,539 +97,551 @@
public class VpeVisualDomBuilder extends VpeDomBuilder {
- public static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id";
//$NON-NLS-1$
- public static final String VPE_USER_TOGGLE_LOOKUP_PARENT =
"vpe-user-toggle-lookup-parent"; //$NON-NLS-1$
+ public static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id";
//$NON-NLS-1$
+ public static final String VPE_USER_TOGGLE_LOOKUP_PARENT =
"vpe-user-toggle-lookup-parent"; //$NON-NLS-1$
- /** REGEX_EL */
- private static final Pattern REGEX_EL = Pattern.compile(
- "[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL);
//$NON-NLS-1$
-
- private static final String PSEUDO_ELEMENT = "br"; //$NON-NLS-1$
- private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element";
//$NON-NLS-1$
- private static final String INIT_ELEMENT_ATTR = "vpe:init-element";
//$NON-NLS-1$
- private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS";
//$NON-NLS-1$
- private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element";
//$NON-NLS-1$
- private static final int DRAG_AREA_WIDTH = 10;
- private static final int DRAG_AREA_HEIGHT = 10;
- private static final String ATTR_DRAG_AVAILABLE_CLASS =
"__drag__available_style"; //$NON-NLS-1$
- private static String DOTTED_BORDER = "border: 1px dotted #FF6600; padding:
5px;"; //$NON-NLS-1$
+ /** REGEX_EL */
+ private static final Pattern REGEX_EL = Pattern.compile(
+ "[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL); //$NON-NLS-1$
- private MozillaEditor visualEditor;
- private XulRunnerEditor xulRunnerEditor;
- private nsIDOMDocument visualDocument;
- // JBIDE-2170 Sergey Dzmitrovich
- // private nsIDOMElement visualContentArea;
- private VpePageContext pageContext;
- private VpeDnD dnd;
- // JBIDE-2170 Sergey Dzmitrovich
- // private nsIDOMNode headNode;
- private List includeStack;
- // TODO Max Areshkau JBIDE-1457
- // boolean rebuildFlag = false;
+ private static final String PSEUDO_ELEMENT = "br"; //$NON-NLS-1$
+ private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element";
//$NON-NLS-1$
+ private static final String INIT_ELEMENT_ATTR = "vpe:init-element";
//$NON-NLS-1$
+ private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS";
//$NON-NLS-1$
+ private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element";
//$NON-NLS-1$
+ private static final int DRAG_AREA_WIDTH = 10;
+ private static final int DRAG_AREA_HEIGHT = 10;
+ private static final String ATTR_DRAG_AVAILABLE_CLASS =
"__drag__available_style"; //$NON-NLS-1$
+ private static String DOTTED_BORDER = "border: 1px dotted #FF6600; padding:
5px;"; //$NON-NLS-1$
- /** faceletFile */
- private boolean faceletFile = false;
+ private MozillaEditor visualEditor;
+ private XulRunnerEditor xulRunnerEditor;
+ private nsIDOMDocument visualDocument;
+ // JBIDE-2170 Sergey Dzmitrovich
+ // private nsIDOMElement visualContentArea;
+ private VpePageContext pageContext;
+ private VpeDnD dnd;
+ // JBIDE-2170 Sergey Dzmitrovich
+ // private nsIDOMNode headNode;
+ private List includeStack;
+ // TODO Max Areshkau JBIDE-1457
+ // boolean rebuildFlag = false;
- private static final String ATTR_VPE = "vpe"; //$NON-NLS-1$
- private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink";
//$NON-NLS-1$
+ /** faceletFile */
+ private boolean faceletFile = false;
- private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet";
//$NON-NLS-1$
+ private static final String ATTR_VPE = "vpe"; //$NON-NLS-1$
+ private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink";
//$NON-NLS-1$
- private static final String YES_STRING = "yes"; //$NON-NLS-1$
- private static final String ZERO_STRING = "0"; //$NON-NLS-1$
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet";
//$NON-NLS-1$
- private static final String ATRIBUTE_BORDER = "border"; //$NON-NLS-1$
- private static final String ATRIBUTE_CELLSPACING = "cellspacing";
//$NON-NLS-1$
- private static final String ATRIBUTE_CELLPADDING = "cellpadding";
//$NON-NLS-1$
+ private static final String YES_STRING = "yes"; //$NON-NLS-1$
+ private static final String ZERO_STRING = "0"; //$NON-NLS-1$
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final String DOTTED_BORDER_STYLE = "border : 1px dotted
#808080"; //$NON-NLS-1$
- private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted
#808080"; //$NON-NLS-1$
- 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"; //$NON-NLS-1$
- 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"; //$NON-NLS-1$
+ private static final String ATRIBUTE_BORDER = "border"; //$NON-NLS-1$
+ private static final String ATRIBUTE_CELLSPACING = "cellspacing";
//$NON-NLS-1$
+ private static final String ATRIBUTE_CELLPADDING = "cellpadding";
//$NON-NLS-1$
- 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 DOTTED_BORDER_STYLE = "border : 1px dotted
#808080"; //$NON-NLS-1$
+ private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted
#808080"; //$NON-NLS-1$
+ 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"; //$NON-NLS-1$
+ 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"; //$NON-NLS-1$
- 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;
+ 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 Map<IFile, Document> includeDocuments = new HashMap<IFile,
Document>();
+ 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;
+
+ private Map<IFile, Document> includeDocuments = new HashMap<IFile,
Document>();
private boolean showInvisibleTags;
- 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);
+ public VpeVisualDomBuilder(VpeDomMapping domMapping,
+ INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
+ MozillaEditor visualEditor, VpePageContext pageContext) {
- if (isFacelet()) {
- faceletFile = true;
- } else {
- faceletFile = false;
- }
-
- this.showInvisibleTags = Constants.YES_STRING
+ 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;
+ }
+
+ this.showInvisibleTags = Constants.YES_STRING
.equals(VpePreference.SHOW_INVISIBLE_TAGS.getValue());
- }
+ }
- public void buildDom(Document sourceDocument) {
- VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
- IDocument document = sourceBuilder.getStructuredTextViewer()
- .getDocument();
- if (document == null)
- return;
- 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();
- if (isFacelet()) {
- Element root = FaceletUtil.getRootFaceletElement(sourceDocument);
- if (root != null) {
- addNode(root, null, getContentArea());
- }
- } else {
- addChildren(null, sourceDocument, getContentArea());
- }
- /*
- * Fixes
http://jira.jboss.com/jira/browse/JBIDE-2126.
- * To provide appropriate context menu functionality
- * visual content area should be mapped in any case.
- */
- registerNodes(new VpeNodeMapping(sourceDocument, getContentArea()));
- }
+ public void buildDom(Document sourceDocument) {
+ VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
+ IDocument document = sourceBuilder.getStructuredTextViewer()
+ .getDocument();
+ if (document == null)
+ return;
+ 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()));
+ }
+ }
- public void rebuildDom(Document sourceDocument) {
- // clearIncludeDocuments();
- cleanHead();
- domMapping.clear(getContentArea());
- super.dispose();
+ pageContext.refreshConnector();
+ pageContext.installIncludeElements();
+ if (isFacelet()) {
+ Element root = FaceletUtil.getRootFaceletElement(sourceDocument);
+ if (root != null) {
+ addNode(root, null, getContentArea());
+ }
+ } else {
+ addChildren(null, sourceDocument, getContentArea());
+ }
+ /*
+ * Fixes
http://jira.jboss.com/jira/browse/JBIDE-2126. To provide
+ * appropriate context menu functionality visual content area should be
+ * mapped in any case.
+ */
+ registerNodes(new VpeNodeMapping(sourceDocument, getContentArea()));
+ }
- pageContext.clearAll();
- refreshExternalLinks();
- pageContext.getBundle().refreshRegisteredBundles();
+ public void rebuildDom(Document sourceDocument) {
+ // clearIncludeDocuments();
+ cleanHead();
+ domMapping.clear(getContentArea());
+ super.dispose();
- nsIDOMNodeList children = getContentArea().getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- getContentArea().removeChild(children.item(i));
- }
+ pageContext.clearAll();
+ refreshExternalLinks();
+ pageContext.getBundle().refreshRegisteredBundles();
- if (sourceDocument != null) {
- buildDom(sourceDocument);
- }
+ nsIDOMNodeList children = getContentArea().getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ getContentArea().removeChild(children.item(i));
+ }
- }
+ if (sourceDocument != null) {
+ buildDom(sourceDocument);
+ }
- // temporary, will be change to prefference's variable
- // private boolean borderVisible = 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;
- }
+ }
- return false;
- }
+ // temporary, will be change to prefference's variable
+ // private boolean borderVisible = true;
- 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 boolean addNode(Node sourceNode, nsIDOMNode visualNextNode,
+ nsIDOMNode visualContainer) {
- 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);
+ nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
- p.appendChild(visualNode);
+ // 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;
+ }
- } else {
- border = visualDocument.createElement(HTML.TAG_TABLE);
- border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
- border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
+ return false;
+ }
- 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);
+ 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);
- 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);
+ 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);
- 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);
+ p.appendChild(visualNode);
- 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;
- }
-
- /**
- * Generates visual node
- * @param sourceNode
- * @param visualOldContainer
- * @return
- */
- protected nsIDOMNode createNode(Node sourceNode,
- nsIDOMNode visualOldContainer) {
-
- boolean registerFlag = isCurrentMainDocument();
-
- //reads and dispatch events
- //JBIDE-675, checks if editor was disposed or not
- if(getPageContext().getSourceBuilder()==null ||includeDocuments==null) {
-
- throw new VpeDisposeException();
- }
- getPageContext().processDisplayEvents();
-
- //check source node can be changed and link can be a null in this case
- //we shouldn't process this node
- if(sourceNode==null||(
- sourceNode.getNodeType()!=Node.TEXT_NODE
- &&sourceNode.getNodeType()!=Node.ELEMENT_NODE
- &&sourceNode.getNodeType()!=Node.COMMENT_NODE)) {
- return null;
- }
-
- Set<Node> ifDependencySet = new HashSet<Node>();
- pageContext.setCurrentVisualNode(visualOldContainer);
- VpeTemplate template = templateManager.getTemplate(pageContext,
- sourceNode, ifDependencySet);
+ } else {
+ border = visualDocument.createElement(HTML.TAG_TABLE);
+ border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
+ border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
- VpeCreationData creationData = null;
- Node sourceNodeClone = null;
- // FIX FOR JBIDE-1568, added by Max Areshkau
- try {
+ 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);
- if (ElService.getInstance().isCloneableNode(getPageContext(),
sourceNode)) {
- sourceNodeClone = (sourceNode).cloneNode(true);
+ 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);
- template.beforeTemplateCreated(getPageContext(), sourceNodeClone,
getVisualDocument());
- creationData = template.create(getPageContext(), sourceNodeClone,
getVisualDocument());
- } else {
- creationData = template.create(getPageContext(), sourceNode,
getVisualDocument());
- }
+ 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);
- } catch (XPCOMException ex) {
- VpePlugin.getPluginLog().logError(ex);
- VpeTemplate defTemplate = templateManager.getDefTemplate();
- creationData = defTemplate.create(getPageContext(), sourceNode,
- getVisualDocument());
- }
-
- getPageContext().setCurrentVisualNode(null);
+ 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;
+ }
- nsIDOMNode visualNewNode =creationData.getNode();
+ /**
+ * Generates visual node
+ *
+ * @param sourceNode
+ * @param visualOldContainer
+ * @return
+ */
+ protected nsIDOMNode createNode(Node sourceNode,
+ nsIDOMNode visualOldContainer) {
- nsIDOMElement border = null;
+ boolean registerFlag = isCurrentMainDocument();
- if(visualNewNode!=null &&
visualNewNode.getNodeType()==nsIDOMNode.ELEMENT_NODE) {
-
- nsIDOMElement visualNewElement = (nsIDOMElement) creationData
- .getNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- if ((visualNewElement != null) && template.hasImaginaryBorder()) {
+ // reads and dispatch events
+ // JBIDE-675, checks if editor was disposed or not
+ if (getPageContext().getSourceBuilder() == null
+ || includeDocuments == null) {
- visualNewElement.setAttribute(HTML.ATTR_STYLE, visualNewElement
- .getAttribute(HTML.ATTR_STYLE)
- + VpeStyleUtil.SEMICOLON_STRING + DOTTED_BORDER);
+ throw new VpeDisposeException();
+ }
+ getPageContext().processDisplayEvents();
- }
- if (visualNewElement != null) {
- correctVisualAttribute(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);
- }
- }
+ // check source node can be changed and link can be a null in this case
+ // we shouldn't process this node
+ if (sourceNode == null
+ || (sourceNode.getNodeType() != Node.TEXT_NODE
+ && sourceNode.getNodeType() != Node.ELEMENT_NODE && sourceNode
+ .getNodeType() != Node.COMMENT_NODE)) {
+ return null;
+ }
- if(sourceNode instanceof Element && visualNewNode!= null
&&visualNewNode.getNodeType()==nsIDOMNode.ELEMENT_NODE) {
-
- setTooltip((Element) sourceNode,
(nsIDOMElement)visualNewNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID));
- }
- if (registerFlag) {
-
- final VpeElementData data = creationData.getElementData();
+ Set<Node> ifDependencySet = new HashSet<Node>();
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ VpeTemplate template = templateManager.getTemplate(pageContext,
+ sourceNode, ifDependencySet);
- if ((sourceNodeClone != null) && (data != null) &&
(data.getNodesData() != null) && (data.getNodesData().size() > 0)) {
+ VpeCreationData creationData = null;
+ Node sourceNodeClone = null;
+ // FIX FOR JBIDE-1568, added by Max Areshkau
+ try {
- if (template instanceof IEditableTemplate) {
- final IEditableTemplate editableTemplate = (IEditableTemplate)
template;
-
- for (org.jboss.tools.vpe.editor.mapping.NodeData nodeData :
data.getNodesData()) {
- Attr attr = editableTemplate.getOutputAttributeNode((Element)
sourceNode);
- if(attr!=null){
- nodeData.setSourceNode(attr);
- }
- }
- }
-
- }
- VpeElementMapping elementMapping = new VpeElementMapping(
- sourceNode, visualNewNode, border,
- template, ifDependencySet, creationData.getData(),
- data);
- registerNodes(elementMapping);
- }
- if (template.isChildren()) {
- List<?> childrenInfoList = creationData.getChildrenInfoList();
- if (childrenInfoList == null) {
- addChildren(template, sourceNode,
- visualNewNode != null ? visualNewNode
- : visualOldContainer);
- } else {
- addChildren(template, sourceNode, visualOldContainer,
- childrenInfoList);
- }
- }
- getPageContext().setCurrentVisualNode(visualOldContainer);
- template.validate(getPageContext(), sourceNode,
- visualDocument, creationData);
- getPageContext().setCurrentVisualNode(null);
-
- // if showInvisibleTags mode
- if (isShowInvisibleTags() && (visualNewNode != null)
+ if (ElService.getInstance().isCloneableNode(getPageContext(),
+ sourceNode)) {
+ sourceNodeClone = (sourceNode).cloneNode(true);
+
+ template.beforeTemplateCreated(getPageContext(),
+ sourceNodeClone, getVisualDocument());
+ creationData = template.create(getPageContext(),
+ sourceNodeClone, getVisualDocument());
+ } else {
+ creationData = template.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ }
+
+ } catch (XPCOMException ex) {
+ VpePlugin.getPluginLog().logError(ex);
+ VpeTemplate defTemplate = templateManager.getDefTemplate();
+ creationData = defTemplate.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ }
+
+ getPageContext().setCurrentVisualNode(null);
+
+ nsIDOMNode visualNewNode = creationData.getNode();
+
+ nsIDOMElement border = null;
+
+ if (visualNewNode != null
+ && visualNewNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+
+ nsIDOMElement visualNewElement = (nsIDOMElement) creationData
+ .getNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ if ((visualNewElement != null) && template.hasImaginaryBorder()) {
+
+ visualNewElement.setAttribute(HTML.ATTR_STYLE, visualNewElement
+ .getAttribute(HTML.ATTR_STYLE)
+ + VpeStyleUtil.SEMICOLON_STRING + DOTTED_BORDER);
+
+ }
+ if (visualNewElement != null) {
+ correctVisualAttribute(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 (sourceNode instanceof Element && visualNewNode != null
+ && visualNewNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+
+ setTooltip((Element) sourceNode, (nsIDOMElement) visualNewNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID));
+ }
+ if (registerFlag) {
+
+ final VpeElementData data = creationData.getElementData();
+
+ if ((sourceNodeClone != null) && (data != null)
+ && (data.getNodesData() != null)
+ && (data.getNodesData().size() > 0)) {
+
+ if (template instanceof IEditableTemplate) {
+ final IEditableTemplate editableTemplate = (IEditableTemplate) template;
+
+ for (org.jboss.tools.vpe.editor.mapping.NodeData nodeData : data
+ .getNodesData()) {
+ Attr attr = editableTemplate
+ .getOutputAttributeNode((Element) sourceNode);
+ if (attr != null) {
+ nodeData.setSourceNode(attr);
+ }
+ }
+ }
+
+ }
+ VpeElementMapping elementMapping = new VpeElementMapping(
+ sourceNode, visualNewNode, border, template,
+ ifDependencySet, creationData.getData(), data);
+ registerNodes(elementMapping);
+ }
+ if (template.isChildren()) {
+ List<?> childrenInfoList = creationData.getChildrenInfoList();
+ if (childrenInfoList == null) {
+ addChildren(template, sourceNode,
+ visualNewNode != null ? visualNewNode
+ : visualOldContainer);
+ } else {
+ addChildren(template, sourceNode, visualOldContainer,
+ childrenInfoList);
+ }
+ }
+ getPageContext().setCurrentVisualNode(visualOldContainer);
+ template.validate(getPageContext(), sourceNode, visualDocument,
+ creationData);
+ getPageContext().setCurrentVisualNode(null);
+
+ // if showInvisibleTags mode
+ if (isShowInvisibleTags() && (visualNewNode != null)
&& (sourceNode.getNodeType() == Node.ELEMENT_NODE)) {
- // add invisible children to node
+ // add invisible children to node
visualNewNode = addInvisibleChildren(sourceNode, visualNewNode);
}
-
- if (border != null)
- return border;
- else
- return visualNewNode;
- }
- private void correctVisualAttribute(nsIDOMElement element) {
+ if (border != null)
+ return border;
+ else
+ return visualNewNode;
+ }
- String styleValue = element.getAttribute(HTML.TAG_STYLE);
- String backgroundValue = element
- .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
+ private void correctVisualAttribute(nsIDOMElement element) {
- 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);
- }
- }
+ String styleValue = element.getAttribute(HTML.TAG_STYLE);
+ String backgroundValue = element
+ .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
- protected void addChildren(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
-
- /*
- * Fixes
http://jira.jboss.com/jira/browse/JBIDE-1944
- * author: Denis Maliarevich
- * This method is called when template has no childrenInfoList.
- * In this case h:dataTable and h:panelGrid should display pseudo text
- */
- if (containerTemplate instanceof VpeHtmlTemplate) {
- int type = ((VpeHtmlTemplate) containerTemplate).getType();
- if ((VpeHtmlTemplate.TYPE_DATATABLE == type)
- || (VpeHtmlTemplate.TYPE_PANELGRID == type)) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
- return;
- }
- }
-
- NodeList sourceNodes = sourceContainer.getChildNodes();
- int len = sourceNodes.getLength();
- int childrenCount = 0;
- for (int i = 0; i < len; i++) {
- Node sourceNode = sourceNodes.item(i);
- if ((!isInvisibleNode(sourceNode))
+ 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 void addChildren(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
+
+ /*
+ * Fixes
http://jira.jboss.com/jira/browse/JBIDE-1944 author: Denis
+ * Maliarevich This method is called when template has no
+ * childrenInfoList. In this case h:dataTable and h:panelGrid should
+ * display pseudo text
+ */
+ if (containerTemplate instanceof VpeHtmlTemplate) {
+ int type = ((VpeHtmlTemplate) containerTemplate).getType();
+ if ((VpeHtmlTemplate.TYPE_DATATABLE == type)
+ || (VpeHtmlTemplate.TYPE_PANELGRID == type)) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
+ return;
+ }
+ }
+
+ NodeList sourceNodes = sourceContainer.getChildNodes();
+ int len = sourceNodes.getLength();
+ int childrenCount = 0;
+ for (int i = 0; i < len; i++) {
+ Node sourceNode = sourceNodes.item(i);
+ if ((!isInvisibleNode(sourceNode))
&& (addNode(sourceNode, null, visualContainer))) {
- if (Node.ELEMENT_NODE == sourceNode.getNodeType()) {
- }
- childrenCount++;
- }
- }
+ if (Node.ELEMENT_NODE == sourceNode.getNodeType()) {
+ }
+ childrenCount++;
+ }
+ }
- if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
- }
- }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
+ }
+ }
- 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++) {
- Node child = (Node) sourceChildren.get(j);
- if ((!isInvisibleNode(child))
+ 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++) {
+ Node child = (Node) sourceChildren.get(j);
+ if ((!isInvisibleNode(child))
&& addNode((Node) sourceChildren.get(j), null,
visualParent)) {
childrenCount++;
}
- }
- }
- if (childrenCount == 0 && childrenInfoList.size() == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualParent);
- }
- }
- }
-
- /**
+ }
+ }
+ if (childrenCount == 0 && childrenInfoList.size() == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualParent);
+ }
+ }
+ }
+
+ /**
*
* @param containerTemplate
* @param sourceContainer
@@ -648,15 +660,14 @@
// add all invisible tags to wrapper
NodeList sourceNodes = sourceContainer.getChildNodes();
-
for (int i = 0; i < sourceNodes.getLength(); i++) {
Node child = sourceNodes.item(i);
-
+
if (isInvisibleNode(child)) {
addNode(child, null, wrapper);
- count++ ;
+ count++;
}
}
}
@@ -664,7 +675,7 @@
return count > 0 ? wrapper : visualContainer;
}
-
+
/**
*
* @param node
@@ -683,1731 +694,1742 @@
}
- // /////////////////////////////////////////////////////////////////////////
- public nsIDOMNode addStyleNodeToHead(String styleText) {
- nsIDOMNode newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ // /////////////////////////////////////////////////////////////////////////
+ public nsIDOMNode addStyleNodeToHead(String styleText) {
+ nsIDOMNode newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
- if (styleText != null) {
- nsIDOMText newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
- getHeadNode().appendChild(newStyle);
- return newStyle;
- }
+ if (styleText != null) {
+ nsIDOMText newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ }
+ getHeadNode().appendChild(newStyle);
+ return newStyle;
+ }
- public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode,
- String styleText) {
- nsIDOMElement newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode,
+ String styleText) {
+ nsIDOMElement newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
- if (styleText != null) {
- nsIDOMNode newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
+ if (styleText != null) {
+ nsIDOMNode newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ }
- getHeadNode().replaceChild(newStyle, oldStyleNode);
- return newStyle;
- }
+ getHeadNode().replaceChild(newStyle, oldStyleNode);
+ return newStyle;
+ }
- public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
- getHeadNode().removeChild(oldStyleNode);
- }
+ public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
+ getHeadNode().removeChild(oldStyleNode);
+ }
- 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);
//$NON-NLS-1$
- }
- }
- }
+ 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);
//$NON-NLS-1$
+ }
+ }
+ }
- void removeExternalLinks() {
- nsIDOMNodeList childs = getHeadNode().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(VpeTemplateManager.ATTR_LINK_EXT))) {
- getHeadNode().removeChild(node);
- }
- }
- }
- }
- }
+ void removeExternalLinks() {
+ nsIDOMNodeList childs = getHeadNode().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(VpeTemplateManager.ATTR_LINK_EXT))) {
+ getHeadNode().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;
- }
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode)
+ .getAttribute(INIT_ELEMENT_ATTR))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- static boolean isPseudoElement(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
+ static boolean isPseudoElement(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
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(PSEUDO_ELEMENT_ATTR))) {
- return true;
- }
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(PSEUDO_ELEMENT_ATTR))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- private void setPseudoContent(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
- if (containerTemplate != null) {
- containerTemplate.setPseudoContent(pageContext, sourceContainer,
- visualContainer, visualDocument);
- } else {
- try {
- VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
- pageContext, sourceContainer, visualContainer,
- visualDocument);
- } catch (VpeExpressionException ex) {
- VpeExpressionException exception = new VpeExpressionException("Error for source
node"+sourceContainer.toString(),ex); //$NON-NLS-1$
- VpePlugin.reportProblem(exception);
+ private void setPseudoContent(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
+ if (containerTemplate != null) {
+ containerTemplate.setPseudoContent(pageContext, sourceContainer,
+ visualContainer, visualDocument);
+ } else {
+ try {
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
+ pageContext, sourceContainer, visualContainer,
+ visualDocument);
+ } catch (VpeExpressionException ex) {
+ VpeExpressionException exception = new VpeExpressionException(
+ "Error for source node" + sourceContainer.toString(), ex); //$NON-NLS-1$
+ VpePlugin.reportProblem(exception);
+ }
}
- }
- // if (isEmptyElement(visualContainer)) {
- // addPseudoElementImpl(visualContainer);
- // }
- }
+ // 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: "
//$NON-NLS-1$
- + visualParent.getNodeName());
- }
- nsIDOMElement visualPseudoElement = visualDocument
- .createElement(PSEUDO_ELEMENT);
- visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, YES_STRING);
- visualParent.appendChild(visualPseudoElement);
- }
- }
+ private void addPseudoElementImpl(nsIDOMNode visualParent) {
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent
+ .getNodeName())) {
+ if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
+ System.out.println("-------------------- addPseudoElement: " //$NON-NLS-1$
+ + visualParent.getNodeName());
+ }
+ nsIDOMElement visualPseudoElement = visualDocument
+ .createElement(PSEUDO_ELEMENT);
+ visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, YES_STRING);
+ 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;
- }
+ if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- public boolean isEmptyDocument() {
- nsIDOMNodeList visualNodes = getContentArea().getChildNodes();
- long len = visualNodes.getLength();
- if ((len == 0)
- || (len == 1 && (isEmptyText(visualNodes.item(0)) ||
isPseudoElement(visualNodes
- .item(0))))) {
- return true;
- }
+ public boolean isEmptyDocument() {
+ nsIDOMNodeList visualNodes = getContentArea().getChildNodes();
+ long len = visualNodes.getLength();
+ if ((len == 0)
+ || (len == 1 && (isEmptyText(visualNodes.item(0)) ||
isPseudoElement(visualNodes
+ .item(0))))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- private boolean isEmptyText(nsIDOMNode visualNode) {
- if (visualNode == null
- || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
- return false;
- }
+ private boolean isEmptyText(nsIDOMNode visualNode) {
+ if (visualNode == null
+ || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
+ return false;
+ }
- if (visualNode.getNodeValue().trim().length() == 0) {
- return true;
- }
+ if (visualNode.getNodeValue().trim().length() == 0) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- // ==========================================================
+ // ==========================================================
- public void updateNode(Node sourceNode) {
- if (sourceNode == null)
- return;
+ 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));
- }
- }
+ 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;
- }
+ /* Changing of an <option> tag can affect the parent select */
+ Node sourceSelect = getParentSelect(sourceNode);
+ if (sourceSelect != null) {
+ return sourceSelect;
+ }
- return sourceNode;
- }
+ return sourceNode;
+ }
-// 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 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());
+ private void updateElement(Node sourceNode) {
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
+ if (nodeMapping instanceof VpeElementMapping) {
- /*
- * special processing of "style" element
- *
- * for unification of updating nodes - or redevelop updating
- * mechanism (for example : transfer this function to template )
- * or redevelop template of "style" element
- */
- if (HTML.TAG_STYLE.equalsIgnoreCase(sourceNode.getNodeName())) {
- // refresh style node
- VpeStyleUtil.refreshStyleElement(this, elementMapping);
- return;
- }
- if (updateNode != null && updateNode != sourceNode) {
- updateNode(updateNode);
- return;
- }
- }
- }
-
-
- nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
-
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
- 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 {
- // Max Areshkau Why we need update parent node when we update text
- // node?
- // lookd like we haven't need do it.
- if (sourceNode.getNodeType() == Node.TEXT_NODE) {
- updateNode(sourceNode.getParentNode());
- }
- }
- }
+ elementMapping = (VpeElementMapping) nodeMapping;
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ Node updateNode = elementMapping.getTemplate()
+ .getNodeForUptate(pageContext,
+ elementMapping.getSourceNode(),
+ elementMapping.getVisualNode(),
+ elementMapping.getData());
- public void removeNode(Node sourceNode) {
- //remove from cash should be called first
- domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
- }
+ /*
+ * special processing of "style" element
+ *
+ * for unification of updating nodes - or redevelop updating
+ * mechanism (for example : transfer this function to template )
+ * or redevelop template of "style" element
+ */
+ if (HTML.TAG_STYLE.equalsIgnoreCase(sourceNode.getNodeName())) {
+ // refresh style node
+ VpeStyleUtil.refreshStyleElement(this, elementMapping);
+ return;
+ }
+ if (updateNode != null && updateNode != sourceNode) {
+ updateNode(updateNode);
+ return;
+ }
+ }
+ }
- 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;
- }
+ nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
+ getSourceNodes().remove(sourceNode);
- 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;
- }
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
+ }
+ 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 {
+ // Max Areshkau Why we need update parent node when we update text
+ // node?
+ // lookd like we haven't need do it.
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ updateNode(sourceNode.getParentNode());
+ }
+ }
+ }
- // 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;
- // }
- public boolean 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) ||
HTML.TAG_STYLE.equalsIgnoreCase(sourceParentName)) {
- updateNode(sourceText.getParentNode());
- return true;
- }
- }
- 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 instanceof VpeElementMapping) {
- VpeTemplate template = ((VpeElementMapping) nodeMapping)
- .getTemplate();
- if (template != null) {
- if (!template.containsText()) {
- return false;
- }
- }
- }
- updateNode(sourceText);
- return true;
- }
+ public void removeNode(Node sourceNode) {
+ // remove from cash should be called first
+ domMapping.remove(sourceNode);
+ getSourceNodes().remove(sourceNode);
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
+ }
+ }
- // }
- // updateNode(sourceText);
- return false;
- }
+ 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;
+ }
- 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);
- // Fixes JBIDE-1744 author dmaliarevich
- // unified h:dataTable border lookup
- // after attribute change and
- // after visual editor refresh
- } else if (HTML.TAG_TABLE
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- }
- // End of fix
- }
- // setXmlnsAttribute(elementMapping, name, value);
- template.setAttribute(pageContext, sourceElement,
- visualDocument, visualElement, elementMapping
- .getData(), name, value);
- resetTooltip(sourceElement, visualElement);
- }
- }
- }
- }
+ // 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;
+ // }
+ public boolean 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)
+ || HTML.TAG_STYLE.equalsIgnoreCase(sourceParentName)) {
+ updateNode(sourceText.getParentNode());
+ return true;
+ }
+ }
+ 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 instanceof VpeElementMapping) {
+ VpeTemplate template = ((VpeElementMapping) nodeMapping)
+ .getTemplate();
+ if (template != null) {
+ if (!template.containsText()) {
+ return false;
+ }
+ }
+ }
+ updateNode(sourceText);
+ return true;
+ }
- public void stopToggle(Node sourceNode) {
- if (!(sourceNode instanceof Element))
- return;
+ // }
+ // updateNode(sourceText);
+ return false;
+ }
- 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);
- }
- }
- }
+ 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);
+ // Fixes JBIDE-1744 author dmaliarevich
+ // unified h:dataTable border lookup
+ // after attribute change and
+ // after visual editor refresh
+ } else if (HTML.TAG_TABLE
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ }
+ // End of fix
+ }
+ // setXmlnsAttribute(elementMapping, name, value);
+ template.setAttribute(pageContext, sourceElement,
+ visualDocument, visualElement, elementMapping
+ .getData(), name, value);
+ resetTooltip(sourceElement, visualElement);
+ }
+ }
+ }
+ }
- 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;
- }
+ public void stopToggle(Node sourceNode) {
+ if (!(sourceNode instanceof Element))
+ return;
- nsIDOMAttr toggleIdAttr = visualElement
- .getAttributeNode(VPE_USER_TOGGLE_ID);
- if (toggleIdAttr == null) {
- return false;
- }
- String toggleId = toggleIdAttr.getNodeValue();
+ Element sourceElement = (Element) sourceNode;
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- if (toggleId == null) {
- return false;
- }
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).stopToggling(sourceElement);
+ }
+ }
+ }
- boolean toggleLookup = false;
- nsIDOMAttr toggleLookupAttr = visualElement
- .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
- if (toggleLookupAttr != null) {
- toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
- }
+ 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;
+ }
- nsIDOMElement selectedElem = getLastSelectedElement();
- // Fixes JBIDE-1823 author dmaliarevich
- if (null == selectedElem) {
- return false;
- }
- VpeElementMapping elementMapping = null;
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(selectedElem);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- if (elementMapping == null) {
- // may be toggle with facet
- while (!selectedElem.getNodeName().equals(HTML.TAG_TABLE)) {
- selectedElem = (nsIDOMElement) selectedElem.getParentNode()
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- }
- // Fixes JBIDE-1823 author dmaliarevich
- nodeMapping = domMapping.getNodeMapping(selectedElem);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- }
- Node sourceNode = (Node) domMapping.getSourceNode(selectedElem);
- if (sourceNode == null) {
- return false;
- }
+ nsIDOMAttr toggleIdAttr = visualElement
+ .getAttributeNode(VPE_USER_TOGGLE_ID);
+ if (toggleIdAttr == null) {
+ return false;
+ }
+ String toggleId = toggleIdAttr.getNodeValue();
- Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
- : sourceNode.getParentNode());
+ if (toggleId == null) {
+ return false;
+ }
- // Fixes JBIDE-1823 author dmaliarevich
- // Template is looked according to <code>selectedElem</code>
- // so <code>toggleLookupAttr</code> should be retrieved
- // from this element
- toggleLookupAttr = selectedElem
- .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
- if (toggleLookupAttr != null) {
- toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
- }
- // end of fix
-
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
+ boolean toggleLookup = false;
+ nsIDOMAttr toggleLookupAttr = visualElement
+ .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ }
- while (toggleLookup && sourceElement != null
- && !(template instanceof VpeToggableTemplate)) {
- sourceElement = (Element) sourceElement.getParentNode();
- if (sourceElement == null) {
- break;
- }
- // Fixes JBIDE-1823 author dmaliarevich
- nodeMapping = domMapping.getNodeMapping(sourceElement);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- if (elementMapping == null) {
- continue;
- }
- template = elementMapping.getTemplate();
- }
+ nsIDOMElement selectedElem = getLastSelectedElement();
+ // Fixes JBIDE-1823 author dmaliarevich
+ if (null == selectedElem) {
+ return false;
+ }
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(selectedElem);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ if (elementMapping == null) {
+ // may be toggle with facet
+ while (!selectedElem.getNodeName().equals(HTML.TAG_TABLE)) {
+ selectedElem = (nsIDOMElement) selectedElem.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+ // Fixes JBIDE-1823 author dmaliarevich
+ nodeMapping = domMapping.getNodeMapping(selectedElem);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ }
+ Node sourceNode = (Node) domMapping.getSourceNode(selectedElem);
+ if (sourceNode == null) {
+ return false;
+ }
- if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate) template).toggle(this, sourceElement,
- toggleId);
- updateElement(sourceElement);
- return true;
- }
- }
- return false;
- }
+ Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
+ : sourceNode.getParentNode());
- 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());
- // }
- }
- }
- }
+ // Fixes JBIDE-1823 author dmaliarevich
+ // Template is looked according to <code>selectedElem</code>
+ // so <code>toggleLookupAttr</code> should be retrieved
+ // from this element
+ toggleLookupAttr = selectedElem
+ .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ }
+ // end of fix
- public void refreshBundleValues(Element sourceElement) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
- template.refreshBundleValues(pageContext, sourceElement,
- elementMapping.getData());
- }
- }
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- boolean isContentArea(nsIDOMNode visualNode) {
- return getContentArea().equals(visualNode);
- }
+ while (toggleLookup && sourceElement != null
+ && !(template instanceof VpeToggableTemplate)) {
+ sourceElement = (Element) sourceElement.getParentNode();
+ if (sourceElement == null) {
+ break;
+ }
+ // Fixes JBIDE-1823 author dmaliarevich
+ nodeMapping = domMapping.getNodeMapping(sourceElement);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ if (elementMapping == null) {
+ continue;
+ }
+ template = elementMapping.getTemplate();
+ }
- nsIDOMElement getContentArea() {
- return visualEditor.getContentArea();
- }
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).toggle(this, sourceElement,
+ toggleId);
+ updateElement(sourceElement);
+ return true;
+ }
+ }
+ return false;
+ }
- public void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement) {
- setSelectionRectangle(visualElement, true);
- }
+ 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());
+ // }
+ }
+ }
+ }
- void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement, boolean
scroll) {
- int resizerConstrains = getResizerConstrains(visualElement);
- visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
- scroll);
- }
+ 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 nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMElement newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
+ boolean isContentArea(nsIDOMNode visualNode) {
+ return getContentArea().equals(visualNode);
+ }
- //TODO Dzmitry Sakovich
- // Fix priority CSS classes JBIDE-1713
- nsIDOMNode firstNode = getHeadNode().getFirstChild();
- getHeadNode().insertBefore(newNode, firstNode);
- return newNode;
- }
+ nsIDOMElement getContentArea() {
+ return visualEditor.getContentArea();
+ }
- public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
- String href_val, String ext_val) {
- nsIDOMNode newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
- getHeadNode().replaceChild(newNode, oldNode);
- return newNode;
- }
+ public void setSelectionRectangle(/* nsIDOMElement */nsIDOMNode visualElement) {
+ setSelectionRectangle(visualElement, true);
+ }
- 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;
- }
+ void setSelectionRectangle(/* nsIDOMElement */nsIDOMNode visualElement,
+ boolean scroll) {
+ int resizerConstrains = getResizerConstrains(visualElement);
+ visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
+ scroll);
+ }
- public void removeLinkNodeFromHead(nsIDOMNode node) {
- getHeadNode().removeChild(node);
- }
+ public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
+ nsIDOMElement newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
- 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);
+ // TODO Dzmitry Sakovich
+ // Fix priority CSS classes JBIDE-1713
+ nsIDOMNode firstNode = getHeadNode().getFirstChild();
+ getHeadNode().insertBefore(newNode, firstNode);
+ return newNode;
+ }
- /* 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);
- }
+ public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
+ String href_val, String ext_val) {
+ nsIDOMNode newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
+ getHeadNode().replaceChild(newNode, oldNode);
+ return newNode;
+ }
- String styleForParse = styleText.toString();
- styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
- styleForParse, href_val);
+ 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;
+ }
- 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);
- }
- }
+ public void removeLinkNodeFromHead(nsIDOMNode node) {
+ getHeadNode().removeChild(node);
+ }
- 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 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);
- return linkNode;
- }
+ /* Copy links attributes into our <style> */
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ BufferedReader in = null;
+ try {
+ StringBuffer styleText = new StringBuffer(EMPTY_STRING);
+ URL url = new URL((new Path(href_val)).toOSString());
+ String fileName = url.getFile();
+ in = new BufferedReader(new FileReader(
+ (fileName)));
+ String str = EMPTY_STRING;
+ while ((str = in.readLine()) != null) {
+ styleText.append(str);
+ }
- 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));
- }
+ String styleForParse = styleText.toString();
+ styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
+ styleForParse, href_val);
- private nsIDOMNode getLinkNode(String href_val, String ext_val) {
- nsIDOMNodeList children = getHeadNode().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;
- }
+ 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);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+ }
- private void cleanHead() {
- nsIDOMNodeList children = getHeadNode().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 (isLinkReplacer(node)) {
- /*Added by Max Areshkau(Fix for JBIDE-1941)
- * Ext. attribute used for adding external styles
- * to editor. If was added external attribute, this
- * property is true.
- */
- if (!YES_STRING.equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
- // int linkAddress =
- // MozillaSupports.queryInterface(node,
- // nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
- // nsIStyleSheetLinkingElement linkingElement = new
- // nsIStyleSheetLinkingElement(linkAddress);
- // linkingElement.removeStyleSheet();
- node = getHeadNode().removeChild(node);
- }
- } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && (!YES_STRING
- .equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(ATTR_VPE)))) {
- node = getHeadNode().removeChild(node);
- }
- }
- }
- }
+ 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 class PseudoInfo {
- private nsIDOMNode pseudoNode;
- private boolean isElements;
+ return linkNode;
+ }
- private PseudoInfo() {
- this(null, false);
- }
+ 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 PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
- this.pseudoNode = pseudoNode;
- this.isElements = isElements;
- }
- }
+ private nsIDOMNode getLinkNode(String href_val, String ext_val) {
+ nsIDOMNodeList children = getHeadNode().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;
+ }
- void showDragCaret(nsIDOMNode node, int offset) {
- xulRunnerEditor.showDragCaret(node, offset);
- }
+ private void cleanHead() {
+ nsIDOMNodeList children = getHeadNode().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 (isLinkReplacer(node)) {
+ /*
+ * Added by Max Areshkau(Fix for JBIDE-1941) Ext. attribute
+ * used for adding external styles to editor. If was added
+ * external attribute, this property is true.
+ */
+ if (!YES_STRING.equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
+ // int linkAddress =
+ // MozillaSupports.queryInterface(node,
+ // nsIStyleSheetLinkingElement.
+ // NS_ISTYLESHEETLINKINGELEMENT_IID);
+ // nsIStyleSheetLinkingElement linkingElement = new
+ // nsIStyleSheetLinkingElement(linkAddress);
+ // linkingElement.removeStyleSheet();
+ node = getHeadNode().removeChild(node);
+ }
+ } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && (!YES_STRING
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE)))) {
+ node = getHeadNode().removeChild(node);
+ }
+ }
+ }
+ }
- void hideDragCaret() {
+ private class PseudoInfo {
+ private nsIDOMNode pseudoNode;
+ private boolean isElements;
- xulRunnerEditor.hideDragCaret();
- }
+ private PseudoInfo() {
+ this(null, false);
+ }
- private int getResizerConstrains(nsIDOMNode visualNode) {
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
- if (nodeMapping != null
- &&( nodeMapping instanceof VpeElementMapping)
- &&( nodeMapping.getSourceNode() instanceof Element)
- &&(nodeMapping.getVisualNode().getNodeType()==nsIDOMNode.ELEMENT_NODE))
{
- return ((VpeElementMapping) nodeMapping).getTemplate()
- .getTagDescription(pageContext,
- (Element) nodeMapping.getSourceNode(),
- visualDocument,
- (nsIDOMElement)
nodeMapping.getVisualNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- ((VpeElementMapping) nodeMapping).getData())
- .getResizeConstrains();
- }
- return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
- }
+ private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
+ this.pseudoNode = pseudoNode;
+ this.isElements = isElements;
+ }
+ }
- 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);
- }
- }
+ void showDragCaret(nsIDOMNode node, int offset) {
+ xulRunnerEditor.showDragCaret(node, offset);
+ }
- 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);
+ void hideDragCaret() {
- return attrValue != null && attrValue.length() > 0;
- }
+ xulRunnerEditor.hideDragCaret();
+ }
- return false;
- }
+ private int getResizerConstrains(nsIDOMNode visualNode) {
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
+ if (nodeMapping != null
+ && (nodeMapping instanceof VpeElementMapping)
+ && (nodeMapping.getSourceNode() instanceof Element)
+ && (nodeMapping.getVisualNode().getNodeType() == nsIDOMNode.ELEMENT_NODE)) {
+ return ((VpeElementMapping) nodeMapping).getTemplate()
+ .getTagDescription(
+ pageContext,
+ (Element) nodeMapping.getSourceNode(),
+ visualDocument,
+ (nsIDOMElement) nodeMapping.getVisualNode()
+ .queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID),
+ ((VpeElementMapping) nodeMapping).getData())
+ .getResizeConstrains();
+ }
+ return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ }
- boolean canInnerDrag(nsIDOMElement visualDragElement) {
- VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
- if (node instanceof VpeElementMapping) {
- VpeElementMapping elementMapping = (VpeElementMapping) node;
- if (elementMapping != null && elementMapping.getSourceNode() instanceof
Element) {
- return elementMapping.getTemplate().canInnerDrag(pageContext,
- (Element)elementMapping.getSourceNode(),
- visualDocument, visualDragElement,
- elementMapping.getData());
- }
- }
- return false;
- }
+ 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);
+ }
+ }
- VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode,
- VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
- nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
- long visualDropOffset = visualDropInfo.getDropOffset();
- Node sourceDropContainer = null;
- int sourceDropOffset = 0;
+ 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);
- 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(getContentArea());
- 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);
- }
- }
+ return attrValue != null && attrValue.length() > 0;
+ }
- 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 instanceof VpeElementMapping) {
- 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);
- }
- }
+ return false;
+ }
- 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 instanceof VpeElementMapping) {
- ((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));
- }
-// }
+ boolean canInnerDrag(nsIDOMElement visualDragElement) {
+ VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
+ if (node instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping) node;
+ if (elementMapping != null
+ && elementMapping.getSourceNode() instanceof Element) {
+ 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;
- void innerDrop(VpeSourceInnerDragInfo dragInfo,
- VpeSourceInnerDropInfo dropInfo) {
- dropper.drop(pageContext, dragInfo, dropInfo);
- }
+ 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(getContentArea());
+ 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);
+ }
+ }
- 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;
- }
+ 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 instanceof VpeElementMapping) {
+ 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);
+ }
+ }
- nsIDOMElement getDragElement(nsIDOMElement visualElement) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(visualElement);
- if (elementMapping != null
- && canInnerDrag(elementMapping.getVisualElement())) {
- return elementMapping.getVisualElement();
- }
- return null;
- }
+ 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 instanceof VpeElementMapping) {
+ ((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));
+ }
+ // }
- 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;
- }
+ void innerDrop(VpeSourceInnerDragInfo dragInfo,
+ VpeSourceInnerDropInfo dropInfo) {
+ dropper.drop(pageContext, dragInfo, dropInfo);
+ }
- VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
- int sourceDropOffset) {
- nsIDOMNode visualDropContainer = null;
- long visualDropOffset = 0;
+ 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;
+ }
- 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();
+ nsIDOMElement getDragElement(nsIDOMElement visualElement) {
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ if (elementMapping != null
+ && canInnerDrag(elementMapping.getVisualElement())) {
+ return elementMapping.getVisualElement();
+ }
+ return null;
+ }
- 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;
- }
- if (visualDropContainer == null) {
- return null;
- }
- return new VpeVisualInnerDropInfo(visualDropContainer,
- visualDropOffset, 0, 0);
- }
+ public boolean isTextEditable(nsIDOMNode visualNode) {
- protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null
- && !((IDOMElement) sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
- return;
- String titleValue = getTooltip(sourceElement);
+ 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;
+ }
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&");
- titleValue = titleValue.replaceAll("<", "<");
- titleValue = titleValue.replaceAll(">", ">");
- }
+ VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
+ int sourceDropOffset) {
+ nsIDOMNode visualDropContainer = null;
+ long visualDropOffset = 0;
- if (titleValue != null) {
- // visualElement.setAttribute("title", titleValue);
- setTooltip(visualElement, titleValue);
- }
- }
- }
+ 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();
- protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute(HTML.ATTR_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);
- }
- }
- }
+ 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;
+ }
+ if (visualDropContainer == null) {
+ return null;
+ }
+ return new VpeVisualInnerDropInfo(visualDropContainer,
+ visualDropOffset, 0, 0);
+ }
- 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);
+ protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
+ if (visualElement != null && sourceElement != null
+ && !((IDOMElement) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
+ String titleValue = getTooltip(sourceElement);
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&");
//$NON-NLS-1$//$NON-NLS-2$
- titleValue = titleValue.replaceAll("<", "<");
//$NON-NLS-1$//$NON-NLS-2$
- titleValue = titleValue.replaceAll(">", ">");
//$NON-NLS-1$//$NON-NLS-2$
- }
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
- if (titleValue != null) {
- resetTooltip(visualElement, titleValue);
- }
- }
- }
+ if (titleValue != null) {
+ // visualElement.setAttribute("title", titleValue);
+ setTooltip(visualElement, titleValue);
+ }
+ }
+ }
- private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute(HTML.ATTR_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);
- }
- }
- }
- }
+ protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
+ visualElement.setAttribute(HTML.ATTR_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 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(); //$NON-NLS-1$
- }
- int valueLength = attrs.item(i).getNodeValue().length();
- if (valueLength > 30) {
- StringBuffer temp = new StringBuffer();
- temp.append(attrs.item(i).getNodeValue().substring(0, 15)
- + " ... " //$NON-NLS-1$
- + attrs.item(i).getNodeValue().substring(
- valueLength - 15, valueLength));
- buffer.append("\n" + attrs.item(i).getNodeName() + ": " +
temp); //$NON-NLS-1$ //$NON-NLS-2$
- } else
- buffer.append("\n" + attrs.item(i).getNodeName() + ": "
//$NON-NLS-1$ //$NON-NLS-2$
- + attrs.item(i).getNodeValue());
+ 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("&", "&");
//$NON-NLS-1$//$NON-NLS-2$
+ titleValue = titleValue.replaceAll("<", "<");
//$NON-NLS-1$//$NON-NLS-2$
+ titleValue = titleValue.replaceAll(">", ">");
//$NON-NLS-1$//$NON-NLS-2$
+ }
- return buffer.toString();
- }
+ if (titleValue != null) {
+ resetTooltip(visualElement, titleValue);
+ }
+ }
+ }
- Rectangle getNodeBounds(nsIDOMNode visualNode) {
+ private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
+ visualElement.setAttribute(HTML.ATTR_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);
+ }
+ }
+ }
+ }
- return XulRunnerVpeUtils.getElementBounds(visualNode);
- }
+ 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(); //$NON-NLS-1$
+ }
+ int valueLength = attrs.item(i).getNodeValue().length();
+ if (valueLength > 30) {
+ StringBuffer temp = new StringBuffer();
+ temp.append(attrs.item(i).getNodeValue().substring(0, 15)
+ + " ... " //$NON-NLS-1$
+ + attrs.item(i).getNodeValue().substring(
+ valueLength - 15, valueLength));
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp);
//$NON-NLS-1$ //$NON-NLS-2$
+ } else
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": "
//$NON-NLS-1$ //$NON-NLS-2$
+ + attrs.item(i).getNodeValue());
- 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;
- }
+ return buffer.toString();
+ }
- void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
- VpeVisualInnerDropInfo oldVisualDropInfo) {
- nsIDOMNode newVisualDropContainer = newVisualDropInfo
- .getDropContainer();
- nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
- .getDropContainer();
+ Rectangle getNodeBounds(nsIDOMNode visualNode) {
- if (newVisualDropContainer.equals(oldVisualDropContainer)) {
- newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
- return;
- }
+ return XulRunnerVpeUtils.getElementBounds(visualNode);
+ }
- 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;
- }
- }
+ 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);
+ }
- public nsIDOMRange createDOMRange() {
- return xulRunnerEditor.createDOMRange();
- }
+ 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;
+ }
- public nsIDOMRange createDOMRange(nsIDOMNode selectedNode) {
- nsIDOMRange range = createDOMRange();
- range.selectNode(selectedNode);
- return range;
- }
+ void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
+ VpeVisualInnerDropInfo oldVisualDropInfo) {
+ nsIDOMNode newVisualDropContainer = newVisualDropInfo
+ .getDropContainer();
+ nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
+ .getDropContainer();
- public static boolean isIncludeElement(nsIDOMElement visualElement) {
- return YES_STRING.equalsIgnoreCase(visualElement
- .getAttribute(INCLUDE_ELEMENT_ATTR));
- }
+ if (newVisualDropContainer.equals(oldVisualDropContainer)) {
+ newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
+ return;
+ }
- public static void markIncludeElement(nsIDOMElement visualElement) {
- visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
- }
+ 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;
+ }
+ }
- protected void setReadOnlyElement(nsIDOMElement node) {
- String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify",
//$NON-NLS-1$
- "read-only"); //$NON-NLS-1$
- node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
+ public nsIDOMRange createDOMRange() {
+ return xulRunnerEditor.createDOMRange();
+ }
- void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
+ public nsIDOMRange createDOMRange(nsIDOMNode selectedNode) {
+ nsIDOMRange range = createDOMRange();
+ range.selectNode(selectedNode);
+ return range;
+ }
- nsIDOMElement selectedElement = xulRunnerEditor
- .getLastSelectedElement();
- if (selectedElement != null && canInnerDrag(selectedElement)) {
- String styleClasses = selectedElement.getAttribute(HTML.ATTR_CLASS);
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
- .getMousePoint(mouseEvent))) {
- // change cursor
- if (styleClasses == null
- || !(styleClasses.contains(ATTR_DRAG_AVAILABLE_CLASS))) {
- // change cursor style to move
- styleClasses = ATTR_DRAG_AVAILABLE_CLASS + " " //$NON-NLS-1$
- + styleClasses;
- }
- } else {
- // change cursor style to normal
- if (styleClasses != null) {
+ public static boolean isIncludeElement(nsIDOMElement visualElement) {
+ return YES_STRING.equalsIgnoreCase(visualElement
+ .getAttribute(INCLUDE_ELEMENT_ATTR));
+ }
- styleClasses = styleClasses.replaceAll(
- ATTR_DRAG_AVAILABLE_CLASS, ""); //$NON-NLS-1$
- }
- }
- selectedElement.setAttribute(HTML.ATTR_CLASS, styleClasses);
- }
- }
+ public static void markIncludeElement(nsIDOMElement visualElement) {
+ visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
+ }
- 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);
- }
+ protected void setReadOnlyElement(nsIDOMElement node) {
+ String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify",
//$NON-NLS-1$
+ "read-only"); //$NON-NLS-1$
+ node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
- nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
+ void setMoveCursor(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)) {
+ String styleClasses = selectedElement.getAttribute(HTML.ATTR_CLASS);
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ // change cursor
+ if (styleClasses == null
+ || !(styleClasses.contains(ATTR_DRAG_AVAILABLE_CLASS))) {
+ // change cursor style to move
+ styleClasses = ATTR_DRAG_AVAILABLE_CLASS + " " //$NON-NLS-1$
+ + styleClasses;
+ }
+ } else {
+ // change cursor style to normal
+ if (styleClasses != null) {
- VpeSourceInnerDragInfo getSourceInnerDragInfo(
- VpeVisualInnerDragInfo visualDragInfo) {
- nsIDOMNode visualNode = visualDragInfo.getNode();
- int offset = visualDragInfo.getOffset();
- int length = visualDragInfo.getLength();
+ styleClasses = styleClasses.replaceAll(
+ ATTR_DRAG_AVAILABLE_CLASS, ""); //$NON-NLS-1$
+ }
+ }
+ selectedElement.setAttribute(HTML.ATTR_CLASS, styleClasses);
+ }
+ }
- VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
- Node sourceNode = nodeMapping.getSourceNode();
+ 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);
+ }
- 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;
- }
- }
- return new VpeSourceInnerDragInfo(sourceNode, offset, length);
- }
+ nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
- public nsIDOMText getOutputTextNode(Attr attr) {
- Element sourceElement = ((Attr) attr).getOwnerElement();
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(sourceElement);
- if (elementMapping != null) {
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ return selectedElement;
+ }
+ }
+ return null;
+ }
- return elementMapping.getTemplate().getOutputTextNode(pageContext,
- sourceElement, elementMapping.getData());
- }
- return null;
- }
+ VpeSourceInnerDragInfo getSourceInnerDragInfo(
+ VpeVisualInnerDragInfo visualDragInfo) {
+ nsIDOMNode visualNode = visualDragInfo.getNode();
+ int offset = visualDragInfo.getOffset();
+ int length = visualDragInfo.getLength();
- nsIDOMElement getLastSelectedElement() {
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
+ Node sourceNode = nodeMapping.getSourceNode();
- return xulRunnerEditor.getLastSelectedElement();
- }
+ 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;
+ }
+ }
+ return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ }
- public void pushIncludeStack(VpeIncludeInfo includeInfo) {
- includeStack.add(includeInfo);
- }
+ public nsIDOMText getOutputTextNode(Attr attr) {
+ Element sourceElement = ((Attr) attr).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
+ if (elementMapping != null) {
- public VpeIncludeInfo popIncludeStack() {
- VpeIncludeInfo includeInfo = null;
- if (includeStack.size() > 0) {
- includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
- .size() - 1);
- }
- return includeInfo;
- }
+ return elementMapping.getTemplate().getOutputTextNode(pageContext,
+ sourceElement, elementMapping.getData());
+ }
+ return null;
+ }
- 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;
- }
+ nsIDOMElement getLastSelectedElement() {
- protected boolean isCurrentMainDocument() {
- return includeStack.size() <= 1;
- }
+ return xulRunnerEditor.getLastSelectedElement();
+ }
- public int getCurrentMainIncludeOffset() {
- if (includeStack.size() <= 1)
- return -1;
- VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
- return ((IndexedRegion) info.getElement()).getStartOffset();
- }
+ public void pushIncludeStack(VpeIncludeInfo includeInfo) {
+ includeStack.add(includeInfo);
+ }
- public VpeIncludeInfo getCurrentIncludeInfo() {
- if (includeStack.size() <= 0)
- return null;
- return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
- }
+ public VpeIncludeInfo popIncludeStack() {
+ VpeIncludeInfo includeInfo = null;
+ if (includeStack.size() > 0) {
+ includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
+ .size() - 1);
+ }
+ return includeInfo;
+ }
- public VpeIncludeInfo getRootIncludeInfo() {
- if (includeStack.size() <= 1)
- return null;
- return (VpeIncludeInfo) includeStack.get(1);
- }
+ 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 void dispose() {
- clearIncludeDocuments();
- includeDocuments = null;
- cleanHead();
- domMapping.clear(getContentArea());
- pageContext.dispose();
- super.dispose();
- }
+ protected boolean isCurrentMainDocument() {
+ return includeStack.size() <= 1;
+ }
- private void clearIncludeDocuments() {
- Collection<Document> documents = includeDocuments.values();
- for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
- Document document = (Document) iterator.next();
- VpeCreatorUtil.releaseDocumentFromRead(document);
- }
- includeDocuments.clear();
- }
+ public int getCurrentMainIncludeOffset() {
+ if (includeStack.size() <= 1)
+ return -1;
+ VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
+ return ((IndexedRegion) info.getElement()).getStartOffset();
+ }
- // 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;
- // }
+ public VpeIncludeInfo getCurrentIncludeInfo() {
+ if (includeStack.size() <= 0)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
+ }
- // 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);
- // }
- // }
+ public VpeIncludeInfo getRootIncludeInfo() {
+ if (includeStack.size() <= 1)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(1);
+ }
- // 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);
- // }
- // }
+ public void dispose() {
+ clearIncludeDocuments();
+ includeDocuments = null;
+ cleanHead();
+ domMapping.clear(getContentArea());
+ pageContext.dispose();
+ super.dispose();
+ }
- /**
- * @return the dnd
- */
- public VpeDnD getDnd() {
+ private void clearIncludeDocuments() {
+ Collection<Document> documents = includeDocuments.values();
+ for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
+ Document document = (Document) iterator.next();
+ VpeCreatorUtil.releaseDocumentFromRead(document);
+ }
+ includeDocuments.clear();
+ }
- return dnd;
- }
+ // 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;
+ // }
- /**
- * @param dnd
- * the dnd to set
- */
- public void setDnd(VpeDnD dnd) {
+ // 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);
+ // }
+ // }
- this.dnd = dnd;
- }
+ // 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);
+ // }
+ // }
- /**
- * @return the pageContext
- */
- protected VpePageContext getPageContext() {
- return pageContext;
- }
+ /**
+ * @return the dnd
+ */
+ public VpeDnD getDnd() {
- /**
- * @param pageContext
- * the pageContext to set
- */
- protected void setPageContext(VpePageContext pageContext) {
- this.pageContext = pageContext;
- }
+ return dnd;
+ }
- /**
- * @return the visualDocument
- */
- protected nsIDOMDocument getVisualDocument() {
- return visualDocument;
- }
+ /**
+ * @param dnd
+ * the dnd to set
+ */
+ public void setDnd(VpeDnD dnd) {
- /**
- * @param visualDocument
- * the visualDocument to set
- */
- protected void setVisualDocument(nsIDOMDocument visualDocument) {
- this.visualDocument = visualDocument;
- }
+ this.dnd = dnd;
+ }
- /**
- * Check this file is facelet
- *
- * @return this if file is facelet, otherwize false
- */
- private boolean isFacelet() {
- boolean isFacelet = false;
+ /**
+ * @return the pageContext
+ */
+ protected VpePageContext getPageContext() {
+ return pageContext;
+ }
- IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
- if (iEditorInput instanceof IFileEditorInput) {
- IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
+ /**
+ * @param pageContext
+ * the pageContext to set
+ */
+ protected void setPageContext(VpePageContext pageContext) {
+ this.pageContext = pageContext;
+ }
- IFile iFile = iFileEditorInput.getFile();
+ /**
+ * @return the visualDocument
+ */
+ protected nsIDOMDocument getVisualDocument() {
+ return visualDocument;
+ }
- 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"); //$NON-NLS-1$
- if (param != null) {
- String value = param.getAttributeValue("param-value");
//$NON-NLS-1$
+ /**
+ * @param visualDocument
+ * the visualDocument to set
+ */
+ protected void setVisualDocument(nsIDOMDocument visualDocument) {
+ this.visualDocument = visualDocument;
+ }
- if (value.length() != 0 && iFile.getName().endsWith(value)) {
- isFacelet = true;
- }
- }
- }
- }
+ /**
+ * Check this file is facelet
+ *
+ * @return this if file is facelet, otherwize false
+ */
+ private boolean isFacelet() {
+ boolean isFacelet = false;
- return isFacelet;
- }
+ IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
+ if (iEditorInput instanceof IFileEditorInput) {
+ IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
- /**
- * Create a visual element for text node
- *
- * @param sourceNode
- * @param registerFlag
- * @return a visual element for text node
- */
+ IFile iFile = iFileEditorInput.getFile();
-// protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
-// String sourceText = sourceNode.getNodeValue();
-// if(sourceText!=null){
-// final IFile file =
getPageContext().getVisualBuilder().getCurrentIncludeInfo().getFile();
-//
-// sourceText = ElService.getInstance().replaceEl(file, sourceText);
-// }
-// /*
-// * Max Areshkau this code causes very slow work of visual editor
-// * when we editing in big files txt nodes.For example exmployee.xhtml
-// * from JBIDE1105
-// *
-// * Denis Maliarevich:
-// * To fix JBIDE-2003 and JBIDE-2042
-// * this code should be uncommented.
-// */
-// if (sourceText.trim().length() <= 0) {
-// if (registerFlag) {
-// registerNodes(new VpeNodeMapping(sourceNode, null));
-// }
-// return null;
-// }
-//
-// 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);
-//
-// nsIDOMNode visualNewTextNode = visualDocument
-// .createTextNode(visualText);
-// nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
-// element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
-// element.appendChild(visualNewTextNode);
-// if (registerFlag) {
-// registerNodes(new VpeNodeMapping(sourceNode, element));
-// }
-//
-// return element;
-// }
+ 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"); //$NON-NLS-1$
+ if (param != null) {
+ String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
- /**
- * @return the xulRunnerEditor
- */
- public XulRunnerEditor getXulRunnerEditor() {
- return xulRunnerEditor;
- }
+ if (value.length() != 0 && iFile.getName().endsWith(value)) {
+ isFacelet = true;
+ }
+ }
+ }
+ }
- /**
- * @param xulRunnerEditor
- * the xulRunnerEditor to set
- */
- public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
- this.xulRunnerEditor = xulRunnerEditor;
- }
+ return isFacelet;
+ }
- public Map<IFile, Document> getIncludeDocuments() {
- return includeDocuments;
- }
-
- public nsIDOMNode getHeadNode() {
- return visualEditor.getHeadNode();
- }
+ /**
+ * 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!=null){
+ // final IFile file =
+ // getPageContext().getVisualBuilder().getCurrentIncludeInfo().getFile();
+ //
+ // sourceText = ElService.getInstance().replaceEl(file, sourceText);
+ // }
+ // /*
+ // * Max Areshkau this code causes very slow work of visual editor
+ // * when we editing in big files txt nodes.For example exmployee.xhtml
+ // * from JBIDE1105
+ // *
+ // * Denis Maliarevich:
+ // * To fix JBIDE-2003 and JBIDE-2042
+ // * this code should be uncommented.
+ // */
+ // if (sourceText.trim().length() <= 0) {
+ // if (registerFlag) {
+ // registerNodes(new VpeNodeMapping(sourceNode, null));
+ // }
+ // return null;
+ // }
+ //
+ // 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);
+ //
+ // nsIDOMNode visualNewTextNode = visualDocument
+ // .createTextNode(visualText);
+ // nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
+ // element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
+ // element.appendChild(visualNewTextNode);
+ // if (registerFlag) {
+ // registerNodes(new VpeNodeMapping(sourceNode, element));
+ // }
+ //
+ // return element;
+ // }
+ /**
+ * @return the xulRunnerEditor
+ */
+ public XulRunnerEditor getXulRunnerEditor() {
+ return xulRunnerEditor;
+ }
+
+ /**
+ * @param xulRunnerEditor
+ * the xulRunnerEditor to set
+ */
+ public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
+ this.xulRunnerEditor = xulRunnerEditor;
+ }
+
+ public Map<IFile, Document> getIncludeDocuments() {
+ return includeDocuments;
+ }
+
+ public nsIDOMNode getHeadNode() {
+ return visualEditor.getHeadNode();
+ }
+
public boolean isShowInvisibleTags() {
return showInvisibleTags;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-08-29
19:11:40 UTC (rev 9968)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-08-30
00:06:07 UTC (rev 9969)
@@ -106,12 +106,8 @@
* @return
*/
public static boolean isNodeContainsPosition(Node node, int position) {
-
- if ((NodesManagingUtil.getStartOffsetNode(node) <= position)
- && (NodesManagingUtil.getEndOffsetNode(node) >= position))
- return true;
-
- return false;
+ return NodesManagingUtil.getStartOffsetNode(node) <= position
+ && NodesManagingUtil.getEndOffsetNode(node) >= position;
}
/**