JBoss Tools SVN: r3812 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-09-26 09:34:20 -0400 (Wed, 26 Sep 2007)
New Revision: 3812
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
Log:
JBIDE-944
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2007-09-26 13:24:19 UTC (rev 3811)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2007-09-26 13:34:20 UTC (rev 3812)
@@ -81,7 +81,9 @@
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.model.XModelBuffer;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelTransferBuffer;
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
@@ -647,21 +649,31 @@
}
public void runDropCommand(final String flavor, final String data) {
+ XModelBuffer b = XModelTransferBuffer.getInstance().getBuffer();
+ final XModelObject o = b.source();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (parentEditor.getVisualEditor().getController() != null) {
- DropData dropData = new DropData(flavor,
+ if(!XModelTransferBuffer.getInstance().isEnabled()) {
+ XModelTransferBuffer.getInstance().enable();
+ XModelTransferBuffer.getInstance().getBuffer().addSource(o);
+ }
+ try {
+ DropData dropData = new DropData(flavor,
data,
parentEditor.getVisualEditor().getController()
.getPageContext(),
getEditorInput(), getSourceViewer(),
getSelectionProvider());
- dropData.setAttributeName(dropContext.getAttributeName());
- IDropCommand dropCommand = DropCommandFactory.getInstance().getDropCommand(flavor, JSPTagProposalFactory.getInstance());
+ dropData.setAttributeName(dropContext.getAttributeName());
+ IDropCommand dropCommand = DropCommandFactory.getInstance().getDropCommand(flavor, JSPTagProposalFactory.getInstance());
- boolean promptAttributes = "yes".equals(VpePreference.ALWAYS_REQUEST_FOR_ATTRIBUTE.getValue());
- dropCommand.getDefaultModel().setPromptForTagAttributesRequired(promptAttributes);
- dropCommand.execute(dropData);
+ boolean promptAttributes = "yes".equals(VpePreference.ALWAYS_REQUEST_FOR_ATTRIBUTE.getValue());
+ dropCommand.getDefaultModel().setPromptForTagAttributesRequired(promptAttributes);
+ dropCommand.execute(dropData);
+ } finally {
+ XModelTransferBuffer.getInstance().disable();
+ }
}
}
});
17 years, 3 months
JBoss Tools SVN: r3811 - in trunk/seam/plugins: org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-09-26 09:24:19 -0400 (Wed, 26 Sep 2007)
New Revision: 3811
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
Log:
use template path the same way as seam-gen does.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-09-26 12:52:41 UTC (rev 3810)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-09-26 13:24:19 UTC (rev 3811)
@@ -116,4 +116,9 @@
public String getViewTemplatesDir() {
return getSeamGenDir()+"/view";
}
+
+ public String getTemplatesDir() {
+ return getSeamGenDir();
+ }
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2007-09-26 12:52:41 UTC (rev 3810)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2007-09-26 13:24:19 UTC (rev 3811)
@@ -67,6 +67,7 @@
ILaunchConfigurationWorkingCopy wc =
launchConfigurationType.newInstance(project, project.getName() + "-generate-entities");
+
//Main
wc.setAttribute(
HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
@@ -88,9 +89,8 @@
wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
}
- wc.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, false);
- wc.setAttribute("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.Util");
+
SeamRuntime seamRt = getRuntime(project);
if(seamRt==null) {
seamRt = getRuntime(project);
@@ -98,10 +98,11 @@
if(seamRt == null) {
throw new CoreException(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, "Can't find seam runtime for project " + project.getName()));
}
- String viewTemplate = seamRt.getViewTemplatesDir();
- String srcTemplate = seamRt.getSrcTemplatesDir();
- wc.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, viewTemplate);
-
+ String seamTemplatesRoot = seamRt.getTemplatesDir();
+
+ wc.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, seamTemplatesRoot);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, true);
+
wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5, true);
wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS, true);
@@ -142,9 +143,14 @@
wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate9.extension_id", "org.hibernate.tools.hbmtemplate");
Map<String, String> hbmtemplateAttributes = new HashMap<String, String>();
+
+// <hbmtemplate filepattern="{class-name}List.xhtml"
+// template="view/list.xhtml.ftl"
+// destdir="${project.home}/view"
+// foreach="entity"/>
+
hbmtemplateAttributes.put("file_pattern", "{class-name}List.xhtml");
- hbmtemplateAttributes.put("template_path", viewTemplate);
- hbmtemplateAttributes.put("template_name", "list.xhtml.ftl");
+ hbmtemplateAttributes.put("template_name", "view/list.xhtml.ftl");
hbmtemplateAttributes.put("outputdir", seamProjectsSet.getViewsFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -157,8 +163,7 @@
hbmtemplateAttributes = new HashMap<String, String>();
hbmtemplateAttributes.put("file_pattern", "{class-name}.xhtml");
- hbmtemplateAttributes.put("template_path", viewTemplate);
- hbmtemplateAttributes.put("template_name", "view.xhtml.ftl");
+ hbmtemplateAttributes.put("template_name", "view/view.xhtml.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -171,8 +176,7 @@
hbmtemplateAttributes = new HashMap<String, String>();
hbmtemplateAttributes.put("file_pattern", "{class-name}.page.xml");
- hbmtemplateAttributes.put("template_path", viewTemplate);
- hbmtemplateAttributes.put("template_name", "view.page.xml.ftl");
+ hbmtemplateAttributes.put("template_name", "view/view.page.xml.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -185,8 +189,7 @@
hbmtemplateAttributes = new HashMap<String, String>();
hbmtemplateAttributes.put("file_pattern", "{class-name}Edit.xhtml");
- hbmtemplateAttributes.put("template_path", viewTemplate);
- hbmtemplateAttributes.put("template_name", "edit.xhtml.ftl");
+ hbmtemplateAttributes.put("template_name", "view/edit.xhtml.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -200,8 +203,7 @@
hbmtemplateAttributes = new HashMap<String, String>();
hbmtemplateAttributes.put("file_pattern", "{class-name}Edit.page.xml");
- hbmtemplateAttributes.put("template_path", viewTemplate);
- hbmtemplateAttributes.put("template_name", "edit.page.xml.ftl");
+ hbmtemplateAttributes.put("template_name", "view/edit.page.xml.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -213,9 +215,8 @@
// foreach="entity"/>
hbmtemplateAttributes = new HashMap<String, String>();
- hbmtemplateAttributes.put("file_pattern", "{class-name}List.java");
- hbmtemplateAttributes.put("template_path", srcTemplate);
- hbmtemplateAttributes.put("template_name", "EntityList.java.ftl");
+ hbmtemplateAttributes.put("file_pattern", "{package-name}/{class-name}List.java");
+ hbmtemplateAttributes.put("template_name", "src/EntityList.java.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getBeansFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -229,8 +230,7 @@
hbmtemplateAttributes = new HashMap<String, String>();
hbmtemplateAttributes.put("file_pattern", "{class-name}List.page.xml");
- hbmtemplateAttributes.put("template_path", viewTemplate);
- hbmtemplateAttributes.put("template_name", "list.page.xml.ftl");
+ hbmtemplateAttributes.put("template_name", "view/list.page.xml.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -242,9 +242,8 @@
// foreach="entity"/>
hbmtemplateAttributes = new HashMap<String, String>();
- hbmtemplateAttributes.put("file_pattern", "{class-name}Home.java");
- hbmtemplateAttributes.put("template_path", srcTemplate);
- hbmtemplateAttributes.put("template_name", "EntityHome.java.ftl");
+ hbmtemplateAttributes.put("file_pattern", "{package-name}/{class-name}Home.java");
+ hbmtemplateAttributes.put("template_name", "src/EntityHome.java.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getBeansFolder().getFullPath().toString());
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
@@ -257,8 +256,7 @@
hbmtemplateAttributes = new HashMap<String, String>();
hbmtemplateAttributes.put("file_pattern", "menu.xhtml");
- hbmtemplateAttributes.put("template_path", viewTemplate+"/layout");
- hbmtemplateAttributes.put("template_name", "menu.xhtml.ftl");
+ hbmtemplateAttributes.put("template_name", "view/layout/menu.xhtml.ftl");
hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString()+"/layout");
hbmtemplateAttributes.put("for_each", "entity");
hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
17 years, 3 months
JBoss Tools SVN: r3810 - branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-09-26 08:52:41 -0400 (Wed, 26 Sep 2007)
New Revision: 3810
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
Log:
code adjustment
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-09-26 12:46:51 UTC (rev 3809)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-09-26 12:52:41 UTC (rev 3810)
@@ -53,6 +53,7 @@
import org.mozilla.interfaces.nsIDOMKeyEvent;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsISelection;
+import org.mozilla.xpcom.XPCOMException;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
import org.w3c.dom.Node;
@@ -1632,13 +1633,17 @@
int minlenght = Integer.MAX_VALUE;
int currentLenght = 0;
for(nsIDOMNode nsDOMNode : elements) {
+
currentLenght=Integer.MAX_VALUE;
+ try{
domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
if(nearestElement==null) {
nearestElement=domElement;
continue;
}
domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+
if(domElementRect.y<curentElementRect.y) {
currentLenght= curentElementRect.y-domElementRect.y;
@@ -1649,7 +1654,11 @@
>Math.abs(curentElementRect.x-domElementRect.x)) {
minlenght=currentLenght;
nearestElement=domElement;
+ }
}
+ }catch(XPCOMException ex){
+ //just ignore
+ //if we cann't cast to nsIDOMELemen -> it's not visual element
}
}
return nearestElement;
@@ -1671,23 +1680,32 @@
int currentLenght = 0;
for(nsIDOMNode nsDOMNode : elements) {
currentLenght=Integer.MAX_VALUE;
- domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if(nearestElement==null) {
- nearestElement=domElement;
- continue;
- }
- domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
- if(domElementRect.y>curentElementRect.y) {
- currentLenght= domElementRect.y-curentElementRect.y;
+ try{
+ domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ if(nearestElement==null) {
+
+ nearestElement=domElement;
+ continue;
+ }
+ domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+ if(domElementRect.y>curentElementRect.y) {
+
+ currentLenght= domElementRect.y-curentElementRect.y;
- if(currentLenght < minlenght) {
- minlenght = currentLenght;
- nearestElement=domElement;
- } else if(currentLenght==minlenght&&Math.abs(curentElementRect.x-XulRunnerVpeUtils.getElementBounds(nearestElement).x)
- >Math.abs(curentElementRect.x-domElementRect.x)) {
- minlenght=currentLenght;
- nearestElement=domElement;
+ if(currentLenght < minlenght) {
+
+ minlenght = currentLenght;
+ nearestElement=domElement;
+ } else if(currentLenght==minlenght&&Math.abs(curentElementRect.x-XulRunnerVpeUtils.getElementBounds(nearestElement).x)
+ >Math.abs(curentElementRect.x-domElementRect.x)) {
+ minlenght=currentLenght;
+ nearestElement=domElement;
+ }
}
+ }catch(XPCOMException exception){
+ //just ignore
+ //if we cann't cast to nsIDOMELemen -> it's not visual element
}
}
return nearestElement;
@@ -1709,24 +1727,31 @@
int currentLenght = 0;
for(nsIDOMNode nsDOMNode : elements) {
currentLenght=Integer.MAX_VALUE;
- domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if(nearestElement==null) {
- nearestElement=domElement;
- continue;
- }
- domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
- if(domElementRect.x>curentElementRect.x) {
- currentLenght= domElementRect.x-curentElementRect.x;
+ try{
+ domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ if(nearestElement==null) {
+ nearestElement=domElement;
+ continue;
+ }
+ domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+
+ if(domElementRect.x>curentElementRect.x) {
+ currentLenght= domElementRect.x-curentElementRect.x;
- if(currentLenght < minlenght) {
- minlenght = currentLenght;
- nearestElement=domElement;
- } else if(currentLenght==minlenght&&Math.abs(curentElementRect.y-XulRunnerVpeUtils.getElementBounds(nearestElement).y)
- >Math.abs(curentElementRect.y-domElementRect.y)) {
- minlenght=currentLenght;
- nearestElement=domElement;
- }
- }
+ if(currentLenght < minlenght) {
+ minlenght = currentLenght;
+ nearestElement=domElement;
+ } else if(currentLenght==minlenght&&Math.abs(curentElementRect.y-XulRunnerVpeUtils.getElementBounds(nearestElement).y)
+ >Math.abs(curentElementRect.y-domElementRect.y)) {
+ minlenght=currentLenght;
+ nearestElement=domElement;
+ }
+ }
+ }catch(XPCOMException ex) {
+ //just ignore
+ //if we cann't cast to nsIDOMELemen -> it's not visual element
+ }
}
return nearestElement;
}
@@ -1747,24 +1772,32 @@
int currentLenght = 0;
for(nsIDOMNode nsDOMNode : elements) {
currentLenght=Integer.MAX_VALUE;
- domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if(nearestElement==null) {
- nearestElement=domElement;
- continue;
+ try{
+ domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ if(nearestElement==null) {
+ nearestElement=domElement;
+ continue;
+ }
+ domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+
+ if(domElementRect.x<curentElementRect.x) {
+
+ currentLenght= curentElementRect.x-domElementRect.x;
+ if(currentLenght < minlenght) {
+ minlenght = currentLenght;
+ nearestElement=domElement;
+ } else if(currentLenght==minlenght&&Math.abs(curentElementRect.y-XulRunnerVpeUtils.getElementBounds(nearestElement).y)
+ >Math.abs(curentElementRect.y-domElementRect.y)) {
+ minlenght=currentLenght;
+ nearestElement=domElement;
+ }
+ }
+ }catch (XPCOMException ex) {
+ //just ignore exception
+ //if we cann't cast to nsIDOMELemen -> it's not visual element
}
- domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
- if(domElementRect.x<curentElementRect.x) {
- currentLenght= curentElementRect.x-domElementRect.x;
- if(currentLenght < minlenght) {
- minlenght = currentLenght;
- nearestElement=domElement;
- } else if(currentLenght==minlenght&&Math.abs(curentElementRect.y-XulRunnerVpeUtils.getElementBounds(nearestElement).y)
- >Math.abs(curentElementRect.y-domElementRect.y)) {
- minlenght=currentLenght;
- nearestElement=domElement;
- }
- }
}
return nearestElement;
}
17 years, 3 months
JBoss Tools SVN: r3809 - in trunk/hibernatetools/plugins: org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: mdryakhlenkov
Date: 2007-09-26 08:46:51 -0400 (Wed, 26 Sep 2007)
New Revision: 3809
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/autolayout/impl/Items.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.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java
Log:
Dependencies from plugins org.jboss.tools.common and org.jboss.common.gef removed.
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-09-26 12:46:51 UTC (rev 3809)
@@ -14,10 +14,8 @@
org.eclipse.ui.editors,
org.eclipse.core.resources,
org.hibernate.eclipse,
- org.jboss.tools.common,
org.eclipse.jdt.core,
- org.jboss.tools.hibernate.ui.view,
- org.jboss.tools.common.gef
+ org.jboss.tools.hibernate.ui.view
Bundle-Version: 2.0.0
Export-Package: org.jboss.tools.hibernate.ui.veditor,
org.jboss.tools.hibernate.ui.veditor.editors,
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/VisualEditorPlugin.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -12,9 +12,8 @@
import org.eclipse.ui.plugin.*;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.hibernate.ui.view.BaseUIPlugin;
import org.osgi.framework.BundleContext;
-import org.jboss.tools.common.log.BaseUIPlugin;
-import org.jboss.tools.common.log.IPluginLog;
public class VisualEditorPlugin extends BaseUIPlugin {
@@ -43,9 +42,4 @@
public static ImageDescriptor getImageDescriptor(String path) {
return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
}
-
- public static IPluginLog getPluginLog() {
- return getDefault();
- }
-
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/VisualEditor.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -27,8 +27,8 @@
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.mapping.RootClass;
-import org.jboss.tools.common.gef.edit.GEFRootEditPart;
import org.jboss.tools.hibernate.ui.veditor.editors.model.OrmDiagram;
+import org.jboss.tools.hibernate.ui.veditor.editors.parts.GEFRootEditPart;
import org.jboss.tools.hibernate.ui.veditor.editors.parts.OrmEditPartFactory;
import org.jboss.tools.hibernate.ui.view.views.ObjectEditorInput;
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/autolayout/impl/Items.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/autolayout/impl/Items.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/autolayout/impl/Items.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -39,7 +39,7 @@
public void setProcess(IDiagramInfo process) {
this.process = process;
- try { load(); } catch (Exception e) { VisualEditorPlugin.getPluginLog().logError(e); }
+ try { load(); } catch (Exception e) { VisualEditorPlugin.getDefault().logError(e); }
}
private void load() {
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 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -607,7 +607,7 @@
FileOutputStream fos = new FileOutputStream(file);
properties.store(fos, "");
} catch (IOException e) {
- VisualEditorPlugin.getPluginLog().logError("Can't save layout of mapping.", e);
+ VisualEditorPlugin.getDefault().logError("Can't save layout of mapping.", e);
}
}
@@ -624,7 +624,7 @@
file.create(source, true, null);
}
} catch (CoreException e) {
- VisualEditorPlugin.getPluginLog().logError(e);
+ VisualEditorPlugin.getDefault().logError(e);
}
}
return file;
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialOrmShape.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -50,7 +50,7 @@
}
getChildren().add(bodyOrmShape);
} catch (Exception e) {
- VisualEditorPlugin.getPluginLog().logError(e);
+ VisualEditorPlugin.getDefault().logError(e);
}
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ConnectionEditPart.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -30,7 +30,6 @@
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
-import org.jboss.tools.common.gef.edit.GEFRootEditPart;
import org.jboss.tools.hibernate.ui.veditor.editors.figures.RoundPolylineConnection;
import org.jboss.tools.hibernate.ui.veditor.editors.model.Connection;
import org.jboss.tools.hibernate.ui.veditor.editors.model.ModelElement;
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/DiagramEditPart.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -110,7 +110,7 @@
ormShape.setLocation(new Point(Integer
.parseInt(xy[0]), Integer.parseInt(xy[1])));
} catch (NumberFormatException e) {
- VisualEditorPlugin.getPluginLog().logError(e);
+ VisualEditorPlugin.getDefault().logError(e);
}
if (xy.length > 2)
if ((new Boolean(xy[2])).booleanValue())
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/GEFRootEditPart.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.parts;
+
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLayer;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+//import org.eclipse.gef.LayerConstants;
+
+public class GEFRootEditPart extends ScalableFreeformRootEditPart{
+
+ public GEFRootEditPart() {
+ super();
+ }
+
+ public void setToFront(AbstractConnectionEditPart editpart){
+ ConnectionLayer layer = (ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER);
+ IFigure fig = editpart.getFigure();
+
+ List children = layer.getChildren();
+
+ children.remove(fig);
+ children.add(fig);
+ }
+
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/META-INF/MANIFEST.MF 2007-09-26 12:46:51 UTC (rev 3809)
@@ -20,7 +20,6 @@
org.eclipse.ltk.core.refactoring,
org.eclipse.ui.editors,
org.eclipse.jface.text,
- org.jboss.tools.common,
org.hibernate.eclipse,
org.hibernate.eclipse.console,
org.eclipse.debug.core
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/plugin.xml 2007-09-26 12:46:51 UTC (rev 3809)
@@ -20,5 +20,14 @@
class="org.jboss.tools.hibernate.ui.view.views.OpenMappingActionDelegate">
</action>
</objectContribution>
+ <objectContribution id="sourceEditorAction" objectClass="org.hibernate.mapping.RootClass">
+ <menu id="org.jboss.tools.hibernate.ui.view.openSource" label="Open Source File" path="sourceEditorAction"/>
+ <action
+ id="org.jboss.tools.hibernate.ui.view.openSourceAction"
+ label="Open Source File"
+ icon="icons/runOpenSource.gif"
+ class="org.jboss.tools.hibernate.ui.view.views.OpenSourceActionDelegate">
+ </action>
+ </objectContribution>
</extension>
</plugin>
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/BaseUIPlugin.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Provides an easy way to log status of events.
+ *
+ * NOTE: It is useful to make the static method getPluginLog()
+ * which provides the interface IPluginLog for using it in your code
+ * in future
+ *
+ * @author Sergey Vasilyev
+ *
+ */
+
+public class BaseUIPlugin extends AbstractUIPlugin {
+
+ public void logError(String message, Throwable t) {
+ LogHelper.logError(this, message, t);
+ }
+
+ public void logError(String message) {
+ LogHelper.logError(this, message);
+ }
+
+ public void logError(Throwable t) {
+ LogHelper.logError(this, t);
+ }
+
+ public void logInfo(String message, Throwable t) {
+ LogHelper.logInfo(this, message, t);
+ }
+
+ public void logInfo(String message) {
+ LogHelper.logInfo(this, message);
+ }
+
+ public void logWarning(String message, Throwable t) {
+ LogHelper.logWarning(this, message, t);
+ }
+
+ public void logWarning(String message) {
+ LogHelper.logWarning(this, message);
+ }
+
+ public void logWarning(Throwable t) {
+ LogHelper.logWarning(this, t);
+ }
+
+ public void showError(String message, Throwable t) {
+ logError(message, t);
+ Shell shell = Display.getDefault().getActiveShell();
+ IStatus s = StatusFactory.getInstance(IStatus.ERROR, this.getBundle().getSymbolicName(), message, t);
+ ErrorDialog.openError(shell, "Hibernate Console", message, s);
+ }
+}
\ No newline at end of file
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/LogHelper.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.Bundle;
+
+public class LogHelper {
+ public static void logError(Plugin plugin, Throwable t) {
+ logError(plugin, null, t);
+ }
+
+ public static void logError(Plugin plugin, String message) {
+ logError(plugin, message, null);
+ }
+
+ public static void logError(Plugin plugin, String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR,
+ plugin.getBundle().getSymbolicName(), message, t);
+ logStatus(plugin, status);
+ }
+
+ public static void logError(String pluginId, Throwable t) {
+ logError(pluginId, null, t);
+ }
+
+ public static void logError(String pluginId, String message) {
+ logError(pluginId, message, null);
+ }
+
+ public static void logError(String pluginId, String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR, pluginId,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logWarning(Plugin plugin, Throwable t) {
+ logWarning(plugin, null, t);
+ }
+
+ public static void logWarning(Plugin plugin, String message) {
+ logWarning(plugin, message, null);
+ }
+
+
+ public static void logWarning(Plugin plugin, String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.WARNING,
+ plugin.getBundle().getSymbolicName(), message, t);
+ logStatus(plugin, status);
+ }
+
+ public static void logWarning(String pluginId, Throwable t) {
+ logWarning(pluginId, null, t);
+ }
+
+ public static void logWarning(String pluginId, String message) {
+ logWarning(pluginId, message, null);
+ }
+
+
+ public static void logWarning(String pluginId, String message,
+ Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.WARNING, pluginId,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logInfo(Plugin plugin, String message,
+ Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO,
+ plugin.getBundle().getSymbolicName(), message, t);
+ logStatus(plugin, status);
+ }
+
+
+ public static void logInfo(Plugin plugin, String message) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO,
+ plugin.getBundle().getSymbolicName(), message);
+ logStatus(plugin, status);
+ }
+
+ public static void logInfo(String pluginId, String message,
+ Throwable t) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO, pluginId,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logInfo(String pluginId, String message) {
+ IStatus status = StatusFactory.getInstance(IStatus.INFO, pluginId,
+ message);
+ logStatus(pluginId, status);
+ }
+
+ public static void log(int severity, String pluginId, int code,
+ String message, Throwable t) {
+ IStatus status = StatusFactory.getInstance(severity, pluginId, code,
+ message, t);
+ logStatus(pluginId, status);
+ }
+
+ public static void logStatus(Plugin plugin, IStatus status) {
+ plugin.getLog().log(status);
+ }
+
+ public static void logStatus(String pluginId, IStatus status) {
+ Bundle bundle = Platform.getBundle(pluginId);
+ logStatus(bundle, status);
+ }
+
+ public static void logStatus(Bundle bundle, IStatus status) {
+ ILog log = Platform.getLog(bundle);
+ log.log(status);
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/StatusFactory.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class StatusFactory {
+ public final static int UNDEFINED_ERROR = 0;
+ public final static String UNSPECIFIED_MESSAGE = null;
+ public final static String EMPTY_MESSAGE = "";
+ public final static String EMPTY_PLUGIN = "";
+
+ public static IStatus getInstance(int severity, String pluginId,
+ int code, String message, Throwable t) {
+ return new Status(severity, pluginId == null ? EMPTY_PLUGIN : pluginId,
+ code, checkMessage(message, t) , t);
+ }
+
+ public static IStatus getInstance(int severity, int code, String message,
+ Throwable t) {
+ return getInstance(severity, EMPTY_PLUGIN, code, message, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ String message, Throwable t) {
+ return getInstance(severity, pluginId, UNDEFINED_ERROR, message, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ String message) {
+ return getInstance(severity, pluginId, UNDEFINED_ERROR, message, null);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ Throwable t) {
+ return getInstance(severity, pluginId, UNDEFINED_ERROR, EMPTY_MESSAGE, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ int code, Throwable t) {
+ return getInstance(severity, pluginId, code, EMPTY_MESSAGE, t);
+ }
+
+ public static IStatus getInstance(int severity, String pluginId,
+ int code, String message) {
+ return getInstance(severity, pluginId, code, message, null);
+ }
+
+ private static String checkMessage(String message, Throwable t) {
+ if (message == UNSPECIFIED_MESSAGE) {
+ if (t != null && t.getMessage() != null) {
+ return t.getMessage();
+ }
+
+ return EMPTY_MESSAGE;
+ }
+
+ return message;
+ }
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/ViewPlugin.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -26,7 +26,6 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.common.log.BaseUIPlugin;
import org.osgi.framework.BundleContext;
/**
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenActionDelegate.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view.views;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.ObjectPluginAction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.EclipseLaunchConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.jboss.tools.hibernate.ui.view.ViewPlugin;
+
+public abstract class OpenActionDelegate implements IObjectActionDelegate {
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ protected IJavaProject findJavaProject(ConsoleConfiguration consoleConfiguration) {
+ IJavaProject proj = null;
+ if (consoleConfiguration != null) {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( "org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+ ILaunchConfiguration[] launchConfigurations;
+ try {
+ launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType );
+ for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there is no look up by name API
+ ILaunchConfiguration launchConfiguration = launchConfigurations[i];
+ if(launchConfiguration.getName().equals(consoleConfiguration.getName())) {
+ proj = ProjectUtils.findJavaProject(launchConfiguration.getAttribute(IConsoleConfigurationLaunchConstants.PROJECT_NAME, ""));
+ }
+ }
+ } catch (CoreException e1) {
+ ViewPlugin.getDefault().logError("Can't find java project.", e1);
+ }
+ }
+ return proj;
+ }
+// protected IJavaProject findJavaProject(ConsoleConfiguration consoleConfiguration) {
+// IJavaProject proj = null;
+// if (consoleConfiguration != null) {
+// ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+//
+// ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( "org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+// ILaunchConfiguration[] launchConfigurations = null;
+// try {
+// launchConfigurations = launchManager.getLaunchConfigurations(launchConfigurationType);
+// } catch (Exception e) {
+// }
+// for (int i = 0; i < launchConfigurations.length; i++) {
+//
+// }
+//
+// String projectName = ((EclipseConsoleConfigurationPreferences)consoleConfiguration.getPreferences()).getProjectName();
+// if (projectName != null) {
+// proj = ProjectUtils.findJavaProject(projectName);
+// }
+// }
+// return proj;
+// }
+
+}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenDiagramActionDelegate.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -32,11 +32,8 @@
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.jboss.tools.hibernate.ui.view.ViewPlugin;
-public class OpenDiagramActionDelegate implements IObjectActionDelegate {
+public class OpenDiagramActionDelegate extends OpenActionDelegate {
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
public void run(IAction action) {
HashMap hashMap = new HashMap();
ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
@@ -44,24 +41,8 @@
ObjectEditorInput input = (ObjectEditorInput)hashMap.get(rootClass);
ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration)(((TreeSelection)objectPluginAction.getSelection()).getPaths()[0]).getSegment(0);
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
-
- ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( "org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
- ILaunchConfiguration[] launchConfigurations;
- IJavaProject proj = null;
- try {
- launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType );
- for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there is no look up by name API
- ILaunchConfiguration launchConfiguration = launchConfigurations[i];
- if(launchConfiguration.getName().equals(consoleConfiguration.getName())) {
- proj = ProjectUtils.findJavaProject(launchConfiguration.getAttribute(IConsoleConfigurationLaunchConstants.PROJECT_NAME, ""));
- }
- }
- } catch (CoreException e1) {
- ViewPlugin.getDefault().logError("Can't find java project.", e1);
- }
+ IJavaProject proj = findJavaProject(consoleConfiguration);
-
if(input == null) {
input = new ObjectEditorInput(consoleConfiguration, rootClass, proj);
hashMap.put(rootClass, input);
@@ -72,7 +53,4 @@
ViewPlugin.getDefault().logError("Can't open mapping view.", e);
}
}
-
- public void selectionChanged(IAction action, ISelection selection) {
- }
}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java 2007-09-26 11:56:43 UTC (rev 3808)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenMappingActionDelegate.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -34,6 +34,7 @@
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeSelection;
@@ -47,6 +48,7 @@
import org.hibernate.MappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.hibernate.mapping.RootClass;
@@ -54,13 +56,10 @@
import org.jboss.tools.hibernate.ui.view.ViewPlugin;
import org.xml.sax.InputSource;
-public class OpenMappingActionDelegate implements IObjectActionDelegate {
+public class OpenMappingActionDelegate extends OpenActionDelegate {
private static XMLHelper helper = new XMLHelper();
private HashMap map = new HashMap();
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
public void run(IAction action) {
ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
RootClass rootClass = (RootClass)((TreeSelection)objectPluginAction.getSelection()).getFirstElement();
@@ -70,11 +69,20 @@
Document doc = getDocument(consoleConfiguration, configXMLFile);
IResource resource = getResource(consoleConfiguration, proj, doc, configXMLFile, rootClass);
- if (resource instanceof IFile){
+ if (resource == null) {
+ String fullyQualifiedName = rootClass.getClassName();
+ try {
+ resource = proj.findType(fullyQualifiedName).getResource();
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ if (resource != null && resource instanceof IFile){
try {
IDE.openEditor(ViewPlugin.getPage(), (IFile) resource);
} catch (PartInitException e) {
- ViewPlugin.getDefault().logError("Can't open mapping file.", e);
+ ViewPlugin.getDefault().logError("Can't open mapping or source file.", e);
}
}
}
@@ -136,7 +144,6 @@
java.io.File file = files[i];
if (file != null) {
resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(file.getPath()));
-// resource = proj.getProject().getFile(new Path(file.getPath()).removeFirstSegments(1));
if (classInResource(consoleConfiguration, resource, rootClass)) return resource;
}
}
@@ -176,28 +183,4 @@
}
return doc;
}
-
- private IJavaProject findJavaProject(ConsoleConfiguration consoleConfiguration) {
- IJavaProject proj = null;
- if (consoleConfiguration != null) {
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( "org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
- ILaunchConfiguration[] launchConfigurations;
- try {
- launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType );
- for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there is no look up by name API
- ILaunchConfiguration launchConfiguration = launchConfigurations[i];
- if(launchConfiguration.getName().equals(consoleConfiguration.getName())) {
- proj = ProjectUtils.findJavaProject(launchConfiguration.getAttribute(IConsoleConfigurationLaunchConstants.PROJECT_NAME, ""));
- }
- }
- } catch (CoreException e1) {
- ViewPlugin.getDefault().logError("Can't find java project.", e1);
- }
- }
- return proj;
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- }
}
\ No newline at end of file
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/OpenSourceActionDelegate.java 2007-09-26 12:46:51 UTC (rev 3809)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.view.views;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.eclipse.core.internal.resources.File;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.ObjectPluginAction;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.util.XMLHelper;
+import org.jboss.tools.hibernate.ui.view.ViewPlugin;
+import org.xml.sax.InputSource;
+
+public class OpenSourceActionDelegate extends OpenActionDelegate {
+
+ public void run(IAction action) {
+ ObjectPluginAction objectPluginAction = (ObjectPluginAction)action;
+ RootClass rootClass = (RootClass)((TreeSelection)objectPluginAction.getSelection()).getFirstElement();
+ ConsoleConfiguration consoleConfiguration = (ConsoleConfiguration)(((TreeSelection)objectPluginAction.getSelection()).getPaths()[0]).getSegment(0);
+ IJavaProject proj = findJavaProject(consoleConfiguration);
+
+ IResource resource = null;
+ String fullyQualifiedName = rootClass.getClassName();
+ try {
+ resource = proj.findType(fullyQualifiedName).getResource();
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+
+ if (resource instanceof IFile){
+ try {
+ IDE.openEditor(ViewPlugin.getPage(), (IFile) resource);
+ } catch (PartInitException e) {
+ ViewPlugin.getDefault().logError("Can't open source file.", e);
+ }
+ }
+ }
+}
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r3808 - branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-09-26 07:56:43 -0400 (Wed, 26 Sep 2007)
New Revision: 3808
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-945
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-09-26 09:45:39 UTC (rev 3807)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-09-26 11:56:43 UTC (rev 3808)
@@ -147,8 +147,6 @@
import org.w3c.dom.Text;
public class VpeController implements INodeAdapter, IModelLifecycleListener, INodeSelectionListener, ITextSelectionListener, SelectionListener, EditorDomEventListener, VpeTemplateListener, XModelTreeListener, ResourceReferenceListListener, ISelectionChangedListener, IVisualController {
- //id of command which is maximazed/minimazed editor
- private static final String MAXIMAZE_PART_ID="org.eclipse.ui.window.maximizePart";
StructuredTextEditor sourceEditor;
private MozillaEditor visualEditor;
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-09-26 09:45:39 UTC (rev 3807)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-09-26 11:56:43 UTC (rev 3808)
@@ -78,12 +78,6 @@
public static final int VK_HOME = 0x24;
public static final int VK_END = 0x23;
- //directions for looking nearest node when we are using navigation keys
- private static final int UP=0;
- private static final int DOWN=1;
- private static final int LEFT=2;
- private static final int RIGHT=3;
-
StructuredTextEditor sourceEditor;
VpeDomMapping domMapping;
VpePageContext pageContext;
@@ -176,14 +170,13 @@
if (keyCode == VK_ENTER) {
return split();
} else if (keyCode == VK_LEFT && !shiftKey) {
- //TODO Max Areshkau (Optimize Move Left)
return moveLeft();
} else if (keyCode == VK_UP && !shiftKey) {
- return moveUp(false);
+ return moveUp();
} else if (keyCode == VK_RIGHT && !shiftKey) {
return moveRight();
} else if (keyCode == VK_DOWN && !shiftKey) {
- return moveDown(false);
+ return moveDown();
} else if (keyCode == VK_HOME && !shiftKey) {
return moveHome(false);
} else if (keyCode == VK_END && !shiftKey) {
@@ -1348,153 +1341,32 @@
}
return false;
}
-
+ /**
+ * Moves to right element focus
+ * @return
+ */
private boolean moveRight() {
- VpeSourceSelectionBuilder sourceSelectionBuilder = new VpeSourceSelectionBuilder(sourceEditor);
- VpeSourceSelection selection = sourceSelectionBuilder.getSelection();
- if (selection == null || selection.getFocusNode() == null)
- return false;
-
- // We're in the visible attribute
- if (selection.getFocusAttribute() != null) {
- if (isVisualEditableForNode(selection.getFocusNode())) {
- AttrImpl attr = (AttrImpl)selection.getFocusAttribute();
-
- Point range = selection.getFocusAttributeRange();
- if (range != null) {
- int eo = range.x + range.y;
- int attrSelStart = ((ElementImpl)attr.getOwnerElement()).getStartOffset() + ((AttrImpl)attr).getValueRegion().getStart() + 1 + eo;
-
- if (eo + 1 <= ((AttrImpl)attr).getValue().length()) {
- setSourceFocus(attrSelStart + 1);
- return true;
- } else {
- return moveCursorToNextVisualNode(selection.getFocusNode());
- }
- }
- } else {
- return moveCursorToNextVisualNode(selection.getFocusNode());
- }
- } else {
- if (selection.getFocusNode().getNodeType() == Node.TEXT_NODE ||
- selection.getFocusNode().getNodeType() == Node.COMMENT_NODE) {
- int so = ((IndexedRegion)selection.getFocusNode()).getStartOffset();
- int eo = ((IndexedRegion)selection.getFocusNode()).getEndOffset();
- if (selection.getFocusOffset() >= eo-so) {
- return moveCursorToNextVisualNode(selection.getFocusNode());
- }
- int fo = selection.getFocusOffset();
- char[] chars = ((TextImpl)selection.getFocusNode()).getValueSource().toCharArray();
-
- String sourceValue=((TextImpl)selection.getFocusNode()).getValueSource();
- String nodeValue=selection.getFocusNode().getNodeValue();
-
- int visualOffser=TextUtil.visualPosition(sourceValue, fo);
-
- int sourseOffset=TextUtil.sourcePosition(sourceValue, nodeValue, visualOffser+1);
- int diff = sourseOffset-fo;
- if(isTextToSkip(chars, fo + diff-1)){
- while ((fo + diff < chars.length) && isTextToSkip(chars, fo + diff)) {
- diff++;
- }
- }
- if (fo + diff > chars.length||diff==0) {
- return moveCursorToNextVisualNode(selection.getFocusNode());
- }
- setSourceFocus(so + fo + diff);
-
- return true;
- } else if (selection.getFocusNode().getNodeType() == Node.ELEMENT_NODE) {
- // Move to second position of the visual attribute (because we're placed
- // either before first char of visual attribute or not in visual attribute
- // but still in the beginning of the element
- return moveCursorToNextVisualNode(selection.getFocusNode());
- }
- }
+ nsIDOMElement visualELement = getNearestNodeinRightDirection(getSelectedNode());
+ Node sourceNode = domMapping.getSourceNode(visualELement);
+ if(sourceNode!=null) {
+ //set selection to node
+ setSourceFocus(((IndexedRegion)sourceNode).getStartOffset());
+ return true;
+ }
return false;
}
//moves selection to left
private boolean moveLeft() {
+ nsIDOMElement visualELement = getNearestNodeinLeftDirection(getSelectedNode());
+ Node sourceNode = domMapping.getSourceNode(visualELement);
- VpeSourceSelectionBuilder sourceSelectionBuilder = new VpeSourceSelectionBuilder(sourceEditor);
- VpeSourceSelection selection = sourceSelectionBuilder.getSelection();
- if (selection == null || selection.getFocusNode() == null) {
-
- return false;
+ if(sourceNode!=null) {
+ //set selection to node
+ setSourceFocus(((IndexedRegion)sourceNode).getStartOffset());
+ return true;
}
- // We're in the visible attribute
- if (selection.getFocusAttribute() != null) {
- if (isVisualEditableForNode(selection.getFocusNode())) {
- AttrImpl attr = (AttrImpl)selection.getFocusAttribute();
-
- Point range = selection.getFocusAttributeRange();
- if (range != null) {
- int eo = range.x + range.y;
- int attrSelStart = ((ElementImpl)attr.getOwnerElement()).getStartOffset() + ((AttrImpl)attr).getValueRegion().getStart() + 1 + eo;
-
- if (eo > 0) {
- setSourceFocus(attrSelStart - 1);
- return true;
- }
-// else {
-// return moveCursorToPrevVisualNode(selection.getFocusNode());
-// }
- }
- }
-// else {
-// return moveCursorToPrevVisualNode(selection.getFocusNode());
-// }
- } else {
- if (selection.getFocusNode().getNodeType() == Node.TEXT_NODE ||
- selection.getFocusNode().getNodeType() == Node.COMMENT_NODE) {
- int so = ((IndexedRegion)selection.getFocusNode()).getStartOffset();
- int eo = ((IndexedRegion)selection.getFocusNode()).getEndOffset();
-
-// if (selection.getFocusOffset() <= 0) {
-//
-// return moveCursorToPrevVisualNode(selection.getFocusNode());
-// }
- int fo = selection.getFocusOffset();
-
-
-
- char[] chars = ((TextImpl)selection.getFocusNode()).getValueSource().toCharArray();
- String sourceValue=((TextImpl)selection.getFocusNode()).getValueSource();
- String nodeValue=selection.getFocusNode().getNodeValue();
-
- int visualOffser=TextUtil.visualPosition(sourceValue, fo);
- int sourseOffset=TextUtil.sourcePosition(sourceValue, nodeValue, visualOffser-1);
- int diff = sourseOffset-fo;
- boolean cicle=false;
-
- while ((fo + diff >= 0)&&(fo+diff<chars.length) && isTextToSkip(chars, fo + diff)) {
- diff--;
- cicle=true;
- }
-
- if(cicle==true){
- diff++;
- }
-
-// if (fo + diff < 0||diff==0) {
-//
-// return moveCursorToPrevVisualNode(selection.getFocusNode());
-// }
-
- setSourceFocus(so + fo + diff);
- return true;
- }
-// else if (selection.getFocusNode().getNodeType() == Node.ELEMENT_NODE) {
-// // Move to second position of the visual attribute (because we're placed
-// // either before first char of visual attribute or not in visual attribute
-// // but still in the beginning of the element
-//
-// return moveCursorToPrevVisualNode(selection.getFocusNode());
-// }
- }
-
return false;
}
@@ -1689,27 +1561,37 @@
return node;
}
- private boolean moveUp(boolean extend) {
+ /**
+ * Moves cursor to UP ELement
+ * @return if moving was successful return true, else return false
+ */
+ //TODO Max Areshkau when we at higest node ad automatic downcast
+ private boolean moveUp() {
- VpeDebugUtil.debugInfo("MoveUp\n");
-
- nsIDOMElement visualELement = getNearestNode(getSelectedNode(), UP);
+ nsIDOMElement visualELement = getNearestNodeinUpDirection(getSelectedNode());
Node sourceNode = domMapping.getSourceNode(visualELement);
- setSourceFocus(((IndexedRegion)sourceNode).getStartOffset());
- if(visualELement!=null) {
- VpeDebugUtil.debugInfo("["+visualELement.getNodeName()+"]");
- // pageContext.getEditPart().getController().getXulRunnerEditor().setSelectionRectangle(element, resizerConstrains, scroll)
+
+ if(sourceNode!=null) {
+ //set selection to node
+ setSourceFocus(((IndexedRegion)sourceNode).getStartOffset());
+ return true;
}
-// TODO Max Areshkau figure out
-// frameSelection.lineMove(false, extend);
- return true;
+ return false;
}
+ /**
+ * Moves cursor to down element
+ * @return if moving was successful return true, else return false
+ */
+ private boolean moveDown() {
- private boolean moveDown(boolean extend) {
- VpeDebugUtil.debugInfo("moveDown()");
-// TODO Max Areshkau figure out
-// frameSelection.lineMove(true, extend);
- return true;
+ nsIDOMElement visualELement = getNearestNodeinDownDirection(getSelectedNode());
+ Node sourceNode = domMapping.getSourceNode(visualELement);
+ if(sourceNode!=null) {
+ //set selection to node
+ setSourceFocus(((IndexedRegion)sourceNode).getStartOffset());
+ return true;
+ }
+ return false;
}
private boolean moveHome(boolean extend) {
@@ -1733,13 +1615,12 @@
// frameSelection.characterMove(false, extend);
return true;
}
+
/**
- *
* @param currentNode - node from which we will be look nearest node
- * @param direction - direction on which we will be look for node
- * @return nearest node in one of four directions(UP, DOWN, LEFT, RIGHT)
+ * @return nearest node in UP direction
*/
- private nsIDOMElement getNearestNode(nsIDOMElement currentNode, int direction) {
+ private nsIDOMElement getNearestNodeinUpDirection(nsIDOMElement currentNode) {
if(currentNode==null) {
return null;
}
@@ -1750,7 +1631,6 @@
nsIDOMElement domElement;
int minlenght = Integer.MAX_VALUE;
int currentLenght = 0;
- //TODO Max Areshkau optimize cycle
for(nsIDOMNode nsDOMNode : elements) {
currentLenght=Integer.MAX_VALUE;
domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
@@ -1759,32 +1639,137 @@
continue;
}
domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
- if(UP==direction&&domElementRect.y<curentElementRect.y) {
+ if(domElementRect.y<curentElementRect.y) {
currentLenght= curentElementRect.y-domElementRect.y;
if(currentLenght < minlenght) {
minlenght = currentLenght;
nearestElement=domElement;
- VpePlugin.getPluginLog().logInfo("current node is"+nearestElement.getNodeName());
} else if(currentLenght==minlenght&&Math.abs(curentElementRect.x-XulRunnerVpeUtils.getElementBounds(nearestElement).x)
>Math.abs(curentElementRect.x-domElementRect.x)) {
minlenght=currentLenght;
nearestElement=domElement;
- VpePlugin.getPluginLog().logInfo("current node is"+nearestElement.getNodeName());
}
}
+ }
+ return nearestElement;
+ }
+ /**
+ * @param currentNode - node from which we will be look nearest node
+ * @return nearest node in UP direction
+ */
+ private nsIDOMElement getNearestNodeinDownDirection(nsIDOMElement currentNode) {
+ if(currentNode==null) {
+ return null;
}
-
+ Collection<nsIDOMNode> elements = domMapping.getVisualMap().keySet();
+ nsIDOMElement nearestElement=null;
+ Rectangle curentElementRect = XulRunnerVpeUtils.getElementBounds(currentNode);
+ Rectangle domElementRect=null;
+ nsIDOMElement domElement;
+ int minlenght = Integer.MAX_VALUE;
+ int currentLenght = 0;
+ for(nsIDOMNode nsDOMNode : elements) {
+ currentLenght=Integer.MAX_VALUE;
+ domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if(nearestElement==null) {
+ nearestElement=domElement;
+ continue;
+ }
+ domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+ if(domElementRect.y>curentElementRect.y) {
+ currentLenght= domElementRect.y-curentElementRect.y;
+
+ if(currentLenght < minlenght) {
+ minlenght = currentLenght;
+ nearestElement=domElement;
+ } else if(currentLenght==minlenght&&Math.abs(curentElementRect.x-XulRunnerVpeUtils.getElementBounds(nearestElement).x)
+ >Math.abs(curentElementRect.x-domElementRect.x)) {
+ minlenght=currentLenght;
+ nearestElement=domElement;
+ }
+ }
+ }
return nearestElement;
}
+ /**
+ * @param currentNode - node from which we will be look nearest node
+ * @return nearest node in Right direction
+ */
+ private nsIDOMElement getNearestNodeinRightDirection(nsIDOMElement currentNode) {
+ if(currentNode==null) {
+ return null;
+ }
+ Collection<nsIDOMNode> elements = domMapping.getVisualMap().keySet();
+ nsIDOMElement nearestElement=null;
+ Rectangle curentElementRect = XulRunnerVpeUtils.getElementBounds(currentNode);
+ Rectangle domElementRect=null;
+ nsIDOMElement domElement;
+ int minlenght = Integer.MAX_VALUE;
+ int currentLenght = 0;
+ for(nsIDOMNode nsDOMNode : elements) {
+ currentLenght=Integer.MAX_VALUE;
+ domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if(nearestElement==null) {
+ nearestElement=domElement;
+ continue;
+ }
+ domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+ if(domElementRect.x>curentElementRect.x) {
+ currentLenght= domElementRect.x-curentElementRect.x;
+
+ if(currentLenght < minlenght) {
+ minlenght = currentLenght;
+ nearestElement=domElement;
+ } else if(currentLenght==minlenght&&Math.abs(curentElementRect.y-XulRunnerVpeUtils.getElementBounds(nearestElement).y)
+ >Math.abs(curentElementRect.y-domElementRect.y)) {
+ minlenght=currentLenght;
+ nearestElement=domElement;
+ }
+ }
+ }
+ return nearestElement;
+ }
+ /**
+ * @param currentNode - node from which we will be look nearest node
+ * @return nearest node in Left direction
+ */
+ private nsIDOMElement getNearestNodeinLeftDirection(nsIDOMElement currentNode) {
+ if(currentNode==null) {
+ return null;
+ }
+ Collection<nsIDOMNode> elements = domMapping.getVisualMap().keySet();
+ nsIDOMElement nearestElement=null;
+ Rectangle curentElementRect = XulRunnerVpeUtils.getElementBounds(currentNode);
+ Rectangle domElementRect=null;
+ nsIDOMElement domElement;
+ int minlenght = Integer.MAX_VALUE;
+ int currentLenght = 0;
+ for(nsIDOMNode nsDOMNode : elements) {
+ currentLenght=Integer.MAX_VALUE;
+ domElement = (nsIDOMElement) nsDOMNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if(nearestElement==null) {
+ nearestElement=domElement;
+ continue;
+ }
+ domElementRect = XulRunnerVpeUtils.getElementBounds(domElement);
+ if(domElementRect.x<curentElementRect.x) {
+ currentLenght= curentElementRect.x-domElementRect.x;
+
+ if(currentLenght < minlenght) {
+ minlenght = currentLenght;
+ nearestElement=domElement;
+ } else if(currentLenght==minlenght&&Math.abs(curentElementRect.y-XulRunnerVpeUtils.getElementBounds(nearestElement).y)
+ >Math.abs(curentElementRect.y-domElementRect.y)) {
+ minlenght=currentLenght;
+ nearestElement=domElement;
+ }
+ }
+ }
+ return nearestElement;
+ }
- private boolean moveRight(boolean extend) {
- // TODO Max Areshkau figure out
-// frameSelection.characterMove(true, extend);
- VpePlugin.getDefault().logInfo("MoveRight");
- return true;
- }
private VpeSelectionBuilder getSelectionBuilder() {
17 years, 3 months
JBoss Tools SVN: r3807 - trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-26 05:45:39 -0400 (Wed, 26 Sep 2007)
New Revision: 3807
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
Log:
fix junit test errors
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2007-09-26 09:43:08 UTC (rev 3806)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2007-09-26 09:45:39 UTC (rev 3807)
@@ -77,14 +77,6 @@
assertTrue("Cannot find components.xml in test project", componentsFile != null && componentsFile.exists());
}
- public void testCreatedProjectIsShownOnTree() {
-
- IStructuredContentProvider content
- = (IStructuredContentProvider)getSeamComponentsView().getCommonViewer().getContentProvider();
- assertTrue("Created Seam enabled project haven't been shown in tree",1==content.getElements(ResourcesPlugin.getWorkspace().getRoot()).length);
-
- }
-
public void testAddComponentInXmlFile(){
SeamCorePlugin.getSeamProject(project, true);
@@ -448,17 +440,6 @@
" found",seamPackage!=null);
}
- public void testThatDeletedProjectIsDisappearedFromTree() {
- try {
- ResourcesPlugin.getWorkspace().getRoot().findMember("TestComponentView").delete(true, new NullProgressMonitor());
- } catch (CoreException e) {
- JUnitUtils.fail(e.getMessage(),e);
- }
- IStructuredContentProvider content
- = (IStructuredContentProvider)getSeamComponentsView().getCommonViewer().getContentProvider();
- assertTrue("Created Seam enabled project haven't been deleted from tree",0==content.getElements(ResourcesPlugin.getWorkspace().getRoot()).length);
- }
-
private CommonNavigator getSeamComponentsView() {
IWorkbenchPage page = WorkbenchUtils.getWorkbenchActivePage();
CommonNavigator part = (CommonNavigator)page.findView(ISeamUiConstants.SEAM_COMPONENTS_VIEW_ID);
17 years, 3 months
JBoss Tools SVN: r3806 - in trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui: widget/editor and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-26 05:43:08 -0400 (Wed, 26 Sep 2007)
New Revision: 3806
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-769
Domain and Generic exporters added based on seam-ge generate-entities ant atrget
http://jira.jboss.com/jira/browse/JBIDE-846
src/action
src/model
added for war config
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -39,8 +39,11 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.wizard.IParameter;
@@ -317,10 +320,14 @@
return createErrormessage(
"Project '" + value + "' does'n exist.");
} else {
+ IProject selection = (IProject)project;
try {
- if (!((IProject) project).hasNature(ISeamProject.NATURE_ID)) {
+ if (!selection.hasNature(SeamProject.NATURE_ID)
+ || SeamCorePlugin.getSeamPreferences(selection)==null
+ || selection.getAdapter(IFacetedProject.class)==null
+ || !((IFacetedProject)selection.getAdapter(IFacetedProject.class)).hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.web"))) {
return createErrormessage(
- "Project '" + project.getName() + "' has no Seam nature");
+ "Selected project '" + project.getName() + "' is not a Seam Web Project");
}
} catch (CoreException e) {
SeamCorePlugin.getPluginLog().logError(e);
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -389,7 +389,7 @@
setErrorMessage("Cannot obtain Seam version number from jboss-seam.jar file.");
setPageComplete(false);
return;
- } else if(!seamVersion.matches(version.getValueAsString()+".*")) {
+ } else if(!seamVersion.matches(version.getValueAsString().replace(".","\\.")+".*")) {
setErrorMessage("Selected seam has wrong version number '" + seamVersion + "'");
setPageComplete(false);
return;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -67,7 +67,7 @@
// initialize war files mapping
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/ActionJavaBean.java",
- "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/action/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/test/ActionTest.java",
"${" + IParameter.SEAM_TEST_PROJECT_LOCATION_PATH + "}/test-src/${" + ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH + "}/${"+ IParameter.SEAM_LOCAL_INTERFACE_NAME +"}Test.java"});
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -37,17 +37,17 @@
@Override
public void propertyChange(PropertyChangeEvent event) {
- if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME)) {
- if(event.getNewValue()==null||"".equals(event.getNewValue().toString().trim())) {
+ if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME) || event.getPropertyName().equals(IParameter.SEAM_PROJECT_NAME)) {
+ String value = getEditor(IParameter.SEAM_COMPONENT_NAME).getValueAsString();
+ if(value==null||"".equals(value)) {
setDefaultValue(IParameter.SEAM_COMPONENT_NAME, "");
setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "");
setDefaultValue(IParameter.SEAM_BEAN_NAME, "");
setDefaultValue(IParameter.SEAM_METHOD_NAME, "");
setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
} else {
- String value = event.getNewValue().toString();
String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
- setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "I" + valueU);
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, isWar()?valueU :"I" + valueU);
setDefaultValue(IParameter.SEAM_BEAN_NAME, valueU+"Bean");
String valueL = value.substring(0,1).toLowerCase() + value.substring(1);
setDefaultValue(IParameter.SEAM_METHOD_NAME, valueL);
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -63,10 +63,10 @@
// initialize war files mapping
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/ConversationBean.java",
- "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/model/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_BEAN_NAME +"}.java"});
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/Conversation.java",
- "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/model/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/view/conversation.xhtml",
"${" + IParameter.SEAM_PROJECT_WEBCONTENT_PATH + "}/${" + IParameter.SEAM_PAGE_NAME +"}.xhtml"});
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizardPage1.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -58,14 +58,14 @@
@Override
public void propertyChange(PropertyChangeEvent event) {
if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME)) {
- if(event.getNewValue()==null||"".equals(event.getNewValue().toString().trim())) {
+ String value = getEditor(IParameter.SEAM_COMPONENT_NAME).getValueAsString();
+ if(value==null||"".equals(value)) {
setDefaultValue(IParameter.SEAM_COMPONENT_NAME, "");
setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "");
setDefaultValue(IParameter.SEAM_BEAN_NAME, "");
setDefaultValue(IParameter.SEAM_METHOD_NAME, "");
setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
} else {
- String value = event.getNewValue().toString();
String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "I" + valueU);
setDefaultValue(IParameter.SEAM_BEAN_NAME, valueU+"Bean");
@@ -74,6 +74,5 @@
setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL);
}
}
- super.propertyChange(event);
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -79,13 +79,13 @@
// initialize war files mapping
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/Entity.java",
- "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}.java"});
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/model/${" + ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}.java"});
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/EntityHome.java",
- "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}Home.java"});
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/model/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}Home.java"});
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/EntityList.java",
- "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}List.java"});
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/model/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}List.java"});
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/view/edit.xhtml",
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -84,7 +84,7 @@
static {
FORM_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/src/FormActionJavaBean.java",
- "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
+ "${" + IParameter.SEAM_PROJECT_LOCATION_PATH + "}/src/model/${" + ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_PATH + "}/${" + IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"});
FORM_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME + "}/seam-gen/test/FormTest.java",
"${" + IParameter.SEAM_TEST_PROJECT_LOCATION_PATH + "}/test-src/${" + ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH + "}/${"+ IParameter.SEAM_LOCAL_INTERFACE_NAME +"}Test.java"});
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizardPage1.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -36,23 +36,22 @@
@Override
public void propertyChange(PropertyChangeEvent event) {
- if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME)) {
- if(event.getNewValue()==null||"".equals(event.getNewValue().toString().trim())) {
+ if(event.getPropertyName().equals(IParameter.SEAM_COMPONENT_NAME) || event.getPropertyName().equals(IParameter.SEAM_PROJECT_NAME)) {
+ String value = getEditor(IParameter.SEAM_COMPONENT_NAME).getValueAsString();
+ if(value==null||"".equals(value)) {
setDefaultValue(IParameter.SEAM_COMPONENT_NAME, "");
setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "");
setDefaultValue(IParameter.SEAM_BEAN_NAME, "");
setDefaultValue(IParameter.SEAM_METHOD_NAME, "");
setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
} else {
- String value = event.getNewValue().toString();
String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
- setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, "I" + valueU);
+ setDefaultValue(IParameter.SEAM_LOCAL_INTERFACE_NAME, isWar()?valueU :"I" + valueU);
setDefaultValue(IParameter.SEAM_BEAN_NAME, valueU+"Bean");
String valueL = value.substring(0,1).toLowerCase() + value.substring(1);
setDefaultValue(IParameter.SEAM_METHOD_NAME, valueL);
setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL);
}
}
- super.propertyChange(event);
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizard.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -65,106 +65,204 @@
ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType("org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType");
ILaunchConfigurationWorkingCopy wc =
- launchConfigurationType.newInstance(project, project.getName() + "generate-entities");
+ launchConfigurationType.newInstance(project, project.getName() + "-generate-entities");
//Main
wc.setAttribute(
HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
params.get(IParameter.HIBERNATE_CONFIGURATION_NAME));
- J2EEProjects seamProjectUtil = J2EEProjects.create(project);
- IPath webContentPath = null;
- IFolder webContent = seamProjectUtil.getWARContentFolder();
- IProject webProject = null;
- if(webContent!=null && webContent.exists()) {
- webContentPath = webContent.getFullPath();
- webProject = seamProjectUtil.getWARProjects().get(0);
- }
+ J2EEProjects seamProjectsSet = J2EEProjects.create(project);
- if(webContentPath == null) {
- throw new CoreException(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, "WebContent folder not found in project " + project.getName()));
- }
- wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, webContentPath.toString());
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR,
+ seamProjectsSet.getBeansFolder()==null?
+ "":seamProjectsSet.getBeansFolder().getFullPath().toString());
boolean isReverseEngineer = "true".equals(params.get(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER));
wc.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, isReverseEngineer);
if(isReverseEngineer) {
- wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, "seamtest");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, seamProjectsSet.getEntityPackage());
wc.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
}
- wc.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_USE_OWN_TEMPLATES, false);
+ wc.setAttribute("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.Util");
+
SeamRuntime seamRt = getRuntime(project);
if(seamRt==null) {
- seamRt = getRuntime(webProject);
+ seamRt = getRuntime(project);
}
if(seamRt == null) {
throw new CoreException(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, "Can't find seam runtime for project " + project.getName()));
}
+ String viewTemplate = seamRt.getViewTemplatesDir();
+ String srcTemplate = seamRt.getSrcTemplatesDir();
+ wc.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, viewTemplate);
- IResource[] resources = seamProjectUtil.getEJBSourceRoots();
- IPath javaSource = null;
- if(resources!=null && resources.length>0) {
- javaSource = resources[0].getFullPath();
- }
- if(javaSource == null) {
- throw new CoreException(new Status(IStatus.ERROR, SeamCorePlugin.PLUGIN_ID, "Source folder not found in project " + project.getName()));
- }
-
- String template = "" + seamRt.getHomeDir() + "/seam-gen/view";
- wc.setAttribute(HibernateLaunchConstants.ATTR_TEMPLATE_DIR, template);
-
wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5, true);
wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS, true);
// Create exporters
// TODO Add others exporters
List<String> exporters = new ArrayList<String>();
+
+ exporters.add("hbmtemplate0");
exporters.add("hbmtemplate1");
exporters.add("hbmtemplate2");
+ exporters.add("hbmtemplate3");
+ exporters.add("hbmtemplate4");
+ exporters.add("hbmtemplate5");
+ exporters.add("hbmtemplate6");
+ exporters.add("hbmtemplate7");
+ exporters.add("hbmtemplate8");
+ exporters.add("hbmtemplate9");
wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, exporters);
-
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate0", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate0.extension_id", "org.hibernate.tools.hbm2java");
wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate1", true);
wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate1.extension_id", "org.hibernate.tools.hbmtemplate");
wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate2", true);
wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate2.extension_id", "org.hibernate.tools.hbmtemplate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate3", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate3.extension_id", "org.hibernate.tools.hbmtemplate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate4", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate4.extension_id", "org.hibernate.tools.hbmtemplate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate5", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate5.extension_id", "org.hibernate.tools.hbmtemplate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate6", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate6.extension_id", "org.hibernate.tools.hbmtemplate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate7", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate7.extension_id", "org.hibernate.tools.hbmtemplate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate8", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate8.extension_id", "org.hibernate.tools.hbmtemplate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate9", true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate9.extension_id", "org.hibernate.tools.hbmtemplate");
+
+ Map<String, String> hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}List.xhtml");
+ hbmtemplateAttributes.put("template_path", viewTemplate);
+ hbmtemplateAttributes.put("template_name", "list.xhtml.ftl");
+ hbmtemplateAttributes.put("outputdir", seamProjectsSet.getViewsFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate1.properties", hbmtemplateAttributes);
-// ExporterDefinition[] ds = ExtensionManager.findExporterDefinitions();
+// <hbmtemplate filepattern="{class-name}.xhtml"
+// template="view/view.xhtml.ftl"
+// destdir="${project.home}/view"
+// foreach="entity"/>
- // Set properties:
- // <hbmtemplate filepattern="{class-name}List.xhtml"
- // template="view/list.xhtml.ftl"
- // destdir="${project.home}/view"
- // foreach="entity"/>
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}.xhtml");
+ hbmtemplateAttributes.put("template_path", viewTemplate);
+ hbmtemplateAttributes.put("template_name", "view.xhtml.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate2.properties", hbmtemplateAttributes);
- Map<String, String> hbmtemplate1Attributes = new HashMap<String, String>();
- hbmtemplate1Attributes.put("file_pattern", "{class-name}List.xhtml");
- hbmtemplate1Attributes.put("template_path", template);
- hbmtemplate1Attributes.put("template_name", "list.xhtml.ftl");
- // TODO create "view" folder
- hbmtemplate1Attributes.put("outputdir", webContentPath.toString() + "/view");
- hbmtemplate1Attributes.put("for_each", "entity");
- wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate1.properties", hbmtemplate1Attributes);
+// <hbmtemplate filepattern="{class-name}.page.xml"
+// template="view/view.page.xml.ftl"
+// destdir="${project.home}/view"
+// foreach="entity"/>
- // Set properties:
- // <hbmtemplate filepattern="{class-name}.page.xml"
- // template="view/view.page.xml.ftl"
- // destdir="${project.home}/view"
- // foreach="entity"/>
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}.page.xml");
+ hbmtemplateAttributes.put("template_path", viewTemplate);
+ hbmtemplateAttributes.put("template_name", "view.page.xml.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate3.properties", hbmtemplateAttributes);
+
+// <hbmtemplate filepattern="{class-name}Edit.xhtml"
+// template="view/edit.xhtml.ftl"
+// destdir="${project.home}/view"
+// foreach="entity"/>
- Map<String, String> hbmtemplate2Attributes = new HashMap<String, String>();
- hbmtemplate2Attributes.put("file_pattern", "{class-name}.page.xml");
- hbmtemplate1Attributes.put("template_path", template);
- hbmtemplate1Attributes.put("template_name", "view.page.xml.ftl");
- hbmtemplate2Attributes.put("outputdir", webContentPath.toString() + "/view");
- hbmtemplate2Attributes.put("for_each", "entity");
- wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate2.properties", hbmtemplate2Attributes);
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}Edit.xhtml");
+ hbmtemplateAttributes.put("template_path", viewTemplate);
+ hbmtemplateAttributes.put("template_name", "edit.xhtml.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate4.properties", hbmtemplateAttributes);
- // TODO Set properties for others exporters
+// <hbmtemplate filepattern="{class-name}Edit.page.xml"
+// template="view/edit.page.xml.ftl"
+// destdir="${project.home}/view"
+// foreach="entity"/>
+
+
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}Edit.page.xml");
+ hbmtemplateAttributes.put("template_path", viewTemplate);
+ hbmtemplateAttributes.put("template_name", "edit.page.xml.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate5.properties", hbmtemplateAttributes);
+// <hbmtemplate filepattern="{package-name}/{class-name}List.java"
+// template="src/EntityList.java.ftl"
+// destdir="${project.home}/src"
+// foreach="entity"/>
+
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}List.java");
+ hbmtemplateAttributes.put("template_path", srcTemplate);
+ hbmtemplateAttributes.put("template_name", "EntityList.java.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getBeansFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate6.properties", hbmtemplateAttributes);
+
+// <hbmtemplate filepattern="{class-name}List.page.xml"
+// template="view/list.page.xml.ftl"
+// destdir="${project.home}/view"
+// foreach="entity"/>
+
+
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}List.page.xml");
+ hbmtemplateAttributes.put("template_path", viewTemplate);
+ hbmtemplateAttributes.put("template_name", "list.page.xml.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate7.properties", hbmtemplateAttributes);
+
+// <hbmtemplate filepattern="{package-name}/{class-name}Home.java"
+// template="src/EntityHome.java.ftl"
+// destdir="${project.home}/src"
+// foreach="entity"/>
+
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "{class-name}Home.java");
+ hbmtemplateAttributes.put("template_path", srcTemplate);
+ hbmtemplateAttributes.put("template_name", "EntityHome.java.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getBeansFolder().getFullPath().toString());
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate8.properties", hbmtemplateAttributes);
+
+// <hbmtemplate filepattern="menu.xhtml"
+// template="view/layout/menu.xhtml.ftl"
+// destdir="${project.home}/view/layout"
+// foreach="entity"/>
+
+ hbmtemplateAttributes = new HashMap<String, String>();
+ hbmtemplateAttributes.put("file_pattern", "menu.xhtml");
+ hbmtemplateAttributes.put("template_path", viewTemplate+"/layout");
+ hbmtemplateAttributes.put("template_name", "menu.xhtml.ftl");
+ hbmtemplateAttributes.put("outputdir",seamProjectsSet.getViewsFolder().getFullPath().toString()+"/layout");
+ hbmtemplateAttributes.put("for_each", "entity");
+ hbmtemplateAttributes.put("hibernatetool.util.toolclass","org.hibernate.eclipse.launch.SeamUtil");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + ".hbmtemplate9.properties", hbmtemplateAttributes);
wc.doSave();
launchManager.addLaunch(wc.launch(ILaunchManager.RUN_MODE, monitor));
} catch (CoreException e) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-09-26 09:43:01 UTC (rev 3805)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-09-26 09:43:08 UTC (rev 3806)
@@ -16,6 +16,7 @@
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
@@ -109,6 +110,7 @@
* @return
*/
public static IFieldEditor createHibernateConsoleConfigurationSelectionFieldEditor(String defaultSelection) {
+ HibernateConsolePlugin.getDefault();
ConsoleConfiguration[] configs = KnownConfigurations.getInstance().getConfigurations();
List<String> configurationNames = new ArrayList<String>();
for (int i = 0; i < configs.length; i++) {
@@ -121,7 +123,10 @@
defaultSelection = "";
}
}
- IFieldEditor editor = SwtFieldEditorFactory.INSTANCE.createComboEditor(IParameter.HIBERNATE_CONFIGURATION_NAME, SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL, configurationNames, defaultSelection);
+ IFieldEditor editor = SwtFieldEditorFactory.INSTANCE.createComboEditor(
+ IParameter.HIBERNATE_CONFIGURATION_NAME,
+ SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL,
+ configurationNames, defaultSelection);
return editor;
}
}
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r3805 - in trunk/seam/plugins/org.jboss.tools.seam.core: src/org/jboss/tools/seam/core and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-09-26 05:43:01 -0400 (Wed, 26 Sep 2007)
New Revision: 3805
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-769
Domain and Generic exporters added based on seam-ge generate-entities ant atrget
http://jira.jboss.com/jira/browse/JBIDE-846
src/action
src/model
added for war config
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2007-09-26 09:14:13 UTC (rev 3804)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2007-09-26 09:43:01 UTC (rev 3805)
@@ -38,7 +38,8 @@
org.eclipse.wst.server.core,
org.eclipse.jpt.core,
org.eclipse.jpt.ui,
- org.eclipse.core.filesystem
+ org.eclipse.core.filesystem,
+ org.eclipse.jst.j2ee.ejb
Provide-Package: org.jboss.tools.seam.core,
org.jboss.tools.seam.internal.core,
org.jboss.tools.seam.internal.core.scanner,
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java 2007-09-26 09:14:13 UTC (rev 3804)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/J2EEProjects.java 2007-09-26 09:43:01 UTC (rev 3805)
@@ -13,15 +13,24 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.core.project.facet.SeamFacetPreference;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
/**
* Helper class that collects related J2EE projects for
@@ -43,111 +52,167 @@
*/
public class J2EEProjects {
IProject ear;
- List<IProject> wars = new ArrayList<IProject>();
- List<IProject> ejbs = new ArrayList<IProject>();
+ IProject war;
+ IProject ejb;
+ IProject test;
+ IEclipsePreferences prefs;
/**
- * Returns instance of J2EEProjects
- * if parameter project is a J2EE project,
- * otherwise null is returned.
- * If parameter project is EAR, referenced projects
- * are used to fill lists 'wars' and ears'
- * If parameter project is WAR or EJB and has referencing EAR,
- * then that EAR project is considered as current project,
- * otherwise referenced EJB projects are put to 'ears' list.
* @param project
* @return
*/
public static J2EEProjects create(IProject project) {
- boolean isWar = J2EEProjectUtilities.isDynamicWebProject(project);
- boolean isEar = J2EEProjectUtilities.isEARProject(project);
- boolean isEJB = J2EEProjectUtilities.isEJBProject(project);
- if(!isEar && !isEJB && !isWar) return null;
return new J2EEProjects(project);
}
private J2EEProjects(IProject project) {
- if(J2EEProjectUtilities.isDynamicWebProject(project)) {
- wars.add(project);
- } else if(J2EEProjectUtilities.isEARProject(project)) {
- ear = project;
- } else if(J2EEProjectUtilities.isEJBProject(project)) {
- ejbs.add(project);
+
+ IScopeContext projectScope = new ProjectScope(project);
+ prefs = projectScope.getNode(SeamCorePlugin.PLUGIN_ID);
+
+ war = project;
+
+ String earName = prefs.get(
+ ISeamFacetDataModelProperties.SEAM_EAR_PROJECT,project.getName()+"-ear");
+ if(earName!=null && !"".equals(earName.trim())) {
+ ear = (IProject)project.getWorkspace().getRoot().findMember(earName);
}
- if(ear == null) {
- IProject[] ps = J2EEProjectUtilities.getReferencingEARProjects(project);
- if(ps != null && ps.length > 0) ear = ps[0];
+ String ejbName = prefs.get(
+ ISeamFacetDataModelProperties.SEAM_EJB_PROJECT,project.getName()+"-ejb");
+ if(ejbName!=null && !"".equals(ejbName.trim())) {
+ ejb = (IProject)project.getWorkspace().getRoot().findMember(ejbName);
}
- if(ear != null || wars.size() > 0) {
- IProject seed = (ear != null) ? ear : project;
- IVirtualComponent component = ComponentCore.createComponent(seed);
- IVirtualReference[] rs = component.getReferences();
- for (int i = 0; i < rs.length; i++) {
- IVirtualComponent c = rs[i].getReferencedComponent();
- if(c == null) continue;
- IProject p = c.getProject();
- if(J2EEProjectUtilities.isDynamicWebProject(p)) {
- if(!wars.contains(p)) wars.add(p);
- } else if(J2EEProjectUtilities.isEJBProject(project)) {
- if(!ejbs.contains(p)) ejbs.add(p);
- }
- }
+ String testName = prefs.get(
+ ISeamFacetDataModelProperties.SEAM_TEST_PROJECT,project.getName()+"test");
+ if(testName!=null && !"".equals(testName)) {
+ test = (IProject)project.getWorkspace().getRoot().findMember(testName);
}
}
+ public boolean isWarConfiguration() {
+ return prefs.get(
+ ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
+ ISeamFacetDataModelProperties.DEPLOY_AS_WAR)
+ .equals(ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
+ }
+
/**
+ * Returns list of WAR projects.
+ * @return
+ */
+ public IProject getWarProject() {
+ return war;
+ }
+
+ /**
* Returns EAR project or null, if WAR project is not used by EAR.
* @return
*/
- public IProject getEARProject() {
+ public IProject getEarProject() {
return ear;
}
-
+
/**
- * Returns Content folder of EAR project or null
- * if EAR is not available.
+ * Returns list of EJB projects.
* @return
- */
- public IFolder getEARContentFolder() {
- if(ear == null) return null;
- IVirtualComponent component = ComponentCore.createComponent(ear);
- IPath path = component.getRootFolder().getProjectRelativePath();
- return path == null ? null : ear.getFolder(path);
+ */
+ public IProject getEJBProject() {
+ return ejb;
}
/**
- * Returns list of WAR projects.
+ * Returns list of EJB projects.
* @return
*/
- public List<IProject> getWARProjects() {
- return wars;
+ public IProject getTestProject() {
+ return test;
}
-
+
/**
+ * Returns Content folder of EAR project or null
+ * if EAR is not available.
+ * @return
+ */
+ public IFolder getActionsFolder() {
+ IFolder actionsFolder = null;
+ if(isWarConfiguration()) {
+ IVirtualComponent com = ComponentCore.createComponent(war);
+ IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/"));
+ final IVirtualFolder srcRootFolder = com.getRootFolder().getFolder(new Path("/WEB-INF/classes"));
+ IContainer[] folder = webRootFolder.getUnderlyingFolders();
+ if(folder.length==1) {
+ actionsFolder = (IFolder)folder[0];
+ } else if(folder.length>1) {
+ IContainer parent = folder[0].getParent();
+ IResource actions = parent.findMember("actions");
+ if(actions!=null && actions instanceof IFolder) {
+ actionsFolder = (IFolder)actions;
+ } else {
+ actionsFolder = (IFolder)folder[0];
+ }
+ }
+ } else {
+ IVirtualComponent com = ComponentCore.createComponent(ejb);
+ IVirtualFolder ejbRootFolder = com.getRootFolder().getFolder(new Path("/"));
+ actionsFolder = (IFolder)ejbRootFolder.getUnderlyingFolder();
+ }
+ return actionsFolder;
+ }
+
+ /**
* Returns Content folder for first found WAR project.
* @return
*/
- public IFolder getWARContentFolder() {
- if(wars.size() == 0) return null;
- IVirtualComponent component = ComponentCore.createComponent(wars.get(0));
- IPath path = component.getRootFolder().getProjectRelativePath();
- return path == null ? null : wars.get(0).getFolder(path);
+ public IFolder getBeansFolder() {
+ IFolder actionsFolder = null;
+ if(isWarConfiguration()) {
+ IVirtualComponent com = ComponentCore.createComponent(war);
+ final IVirtualFolder srcRootFolder = com.getRootFolder().getFolder(new Path("/WEB-INF/classes"));
+ IContainer[] folder = srcRootFolder.getUnderlyingFolders();
+ if(folder.length==1) {
+ actionsFolder = (IFolder)folder[0];
+ } else if(folder.length>1) {
+ IContainer parent = folder[0].getParent();
+ IResource actions = parent.findMember("model");
+ if(actions!=null && actions instanceof IFolder) {
+ actionsFolder = (IFolder)actions;
+ } else {
+ actionsFolder = (IFolder)folder[0];
+ }
+ }
+ } else {
+ IVirtualComponent com = ComponentCore.createComponent(ejb);
+ IVirtualFolder ejbRootFolder = com.getRootFolder().getFolder(new Path("/"));
+ actionsFolder = (IFolder)ejbRootFolder.getUnderlyingFolder();
+ }
+ return actionsFolder;
}
/**
- * Returns list of EJB projects.
+ * Returns source roots for first found EJB project.
* @return
*/
- public List<IProject> getEJBProjects() {
- return ejbs;
+ public IFolder getViewsFolder() {
+ IVirtualComponent com = ComponentCore.createComponent(war);
+ IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/"));
+ return (IFolder)webRootFolder.getUnderlyingFolder();
}
-
+
/**
* Returns source roots for first found EJB project.
* @return
*/
- public IResource[] getEJBSourceRoots() {
- return ejbs.size() == 0 ? new IResource[0] : EclipseResourceUtil.getJavaSourceRoots(ejbs.get(0));
+ public IFolder getTestsFolder() {
+ IResource testRes = test.findMember("test-src");
+ IFolder testFolder = null;
+ if(testRes instanceof IFolder) {
+ testFolder = (IFolder)testRes;
+ }
+ return testFolder;
}
+ public String getEntityPackage(){
+ return prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME, "entity");
+ }
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-09-26 09:14:13 UTC (rev 3804)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-09-26 09:43:01 UTC (rev 3805)
@@ -104,4 +104,16 @@
public boolean isDefault() {
return defaultRt;
}
+
+ public String getSeamGenDir() {
+ return getHomeDir()+"/seam-gen";
+ }
+
+ public String getSrcTemplatesDir() {
+ return getSeamGenDir()+"/src";
+ }
+
+ public String getViewTemplatesDir() {
+ return getSeamGenDir()+"/view";
+ }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-09-26 09:14:13 UTC (rev 3804)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-09-26 09:43:01 UTC (rev 3805)
@@ -88,6 +88,10 @@
* @param runtime
*/
public void addRuntime(SeamRuntime runtime) {
+ if(runtimes.size()==0) {
+ runtime.setDefault(true);
+ }
+
if(getDefaultRuntime()!=null && runtime.isDefault()) {
getDefaultRuntime().setDefault(false);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-26 09:14:13 UTC (rev 3804)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-26 09:43:01 UTC (rev 3805)
@@ -30,6 +30,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
@@ -193,6 +194,10 @@
.include("seam\\.properties")
.include("messages_en\\.properties");
+ public static AntCopyUtils.FileSet JBOOS_EJB_WEB_INF_CLASSES_SET = new AntCopyUtils.FileSet()
+ .include("import\\.sql")
+ .include("seam\\.properties");
+
public static AntCopyUtils.FileSet JBOSS_EAR_META_INF_SET = new AntCopyUtils.FileSet()
.include("META-INF/jboss-app\\.xml");
@@ -207,12 +212,10 @@
final IDataModel model = (IDataModel)config;
// get WebContents folder path from DWP model
- WebArtifactEdit edit = WebArtifactEdit.getWebArtifactEditForRead(project);
IVirtualComponent com = ComponentCore.createComponent(project);
IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/"));
final IVirtualFolder srcRootFolder = com.getRootFolder().getFolder(new Path("/WEB-INF/classes"));
IContainer folder = webRootFolder.getUnderlyingFolder();
- edit.dispose();
model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
model.setProperty(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT, project.getName()+"-test");
@@ -223,7 +226,7 @@
final File webInfClassesMetaInf = new File(webInfClasses, "META-INF");
webInfClassesMetaInf.mkdirs();
final File webLibFolder = new File(webContentFolder,WEB_LIBRARIES_RELATED_PATH);
- final File srcFolder = srcRootFolder.getUnderlyingFolder().getLocation().toFile();
+ final File srcFolder = isWarConfiguration(model)?new File(srcRootFolder.getUnderlyingFolder().getLocation().toFile(),"model"):srcRootFolder.getUnderlyingFolder().getLocation().toFile();
final File webMetaInf = new File(webContentFolder, "META-INF");
final SeamRuntime selectedRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
@@ -232,6 +235,8 @@
final File seamHomeFolder = new File(seamHomePath);
final File seamLibFolder = new File(seamHomePath,SEAM_LIB_RELATED_PATH);
final File seamGenResFolder = new File(seamHomePath,"seam-gen/resources");
+ final File seamGenResMetainfFolder = new File(seamGenResFolder,"META-INF");
+
final File droolsLibFolder = new File(seamHomePath,DROOLS_LIB_SEAM_RELATED_PATH);
final File seamGenHomeFolder = new File(seamHomePath,"seam-gen");
final File seamGenViewSource = new File(seamGenHomeFolder,"view");
@@ -244,7 +249,7 @@
final File persistenceFile = new File(seamGenResFolder,"META-INF/persistence-" + (isWarConfiguration(model)?DEV_WAR_PROFILE:DEV_EAR_PROFILE) + ".xml");
final File applicationFile = new File(seamGenResFolder,"META-INF/application.xml");
-
+
final FilterSet jdbcFilterSet = SeamFacetFilterSetFactory.createJdbcFilterSet(model);
final FilterSet projectFilterSet = SeamFacetFilterSetFactory.createProjectFilterSet(model);
final FilterSet filtersFilterSet = SeamFacetFilterSetFactory.createFiltersFilterSet(model);
@@ -277,23 +282,26 @@
AntCopyUtils.copyFilesAndFolders(
seamGenResFolder,webContentFolder,new AntCopyUtils.FileSetFileFilter(webInfSet), viewFilterSetCollection, true);
- AntCopyUtils.FileSet webInfClassesSet = new AntCopyUtils.FileSet(JBOOS_WAR_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
- AntCopyUtils.copyFilesAndFolders(
- seamGenResFolder,srcFolder,new AntCopyUtils.FileSetFileFilter(webInfClassesSet), viewFilterSetCollection, true);
final FilterSetCollection hibernateDialectFilterSet = new FilterSetCollection();
hibernateDialectFilterSet.addFilterSet(jdbcFilterSet);
hibernateDialectFilterSet.addFilterSet(projectFilterSet);
hibernateDialectFilterSet.addFilterSet(SeamFacetFilterSetFactory.createHibernateDialectFilterSet(model));
- createComponentsProperties(srcFolder, isWarConfiguration(model)?"":project.getName()+"-ear", false);
+
createTestProject(model,project,selectedRuntime);
// ********************************************************************************************
// Handle WAR/EAR configurations
// ********************************************************************************************
if(isWarConfiguration(model)) {
+
+ AntCopyUtils.FileSet webInfClassesSet = new AntCopyUtils.FileSet(JBOOS_WAR_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
+ AntCopyUtils.copyFilesAndFolders(
+ seamGenResFolder,srcFolder,new AntCopyUtils.FileSetFileFilter(webInfClassesSet), viewFilterSetCollection, true);
+ createComponentsProperties(srcFolder, isWarConfiguration(model)?"":project.getName()+"-ear", false);
+
AntCopyUtils.copyFileToFolder(
hibernateConsolePref,
new File(project.getLocation().toFile(),".settings"),
@@ -310,22 +318,20 @@
// ********************************************************************************************
AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"seam.properties"), srcFolder, true);
+ IContainer source = srcRootFolder.getUnderlyingFolder();
+ WtpUtils.createSourceFolder(project, new Path(source.getFullPath().lastSegment()+"/action"),new Path(source.getFullPath().lastSegment()));
+ WtpUtils.createSourceFolder(project, new Path(source.getFullPath().lastSegment()+"/model"),new Path(source.getFullPath().lastSegment()));
-// WtpUtils.createSourceFolder(project, new Path("src/test"),new Path("src"));
-// WtpUtils.createSourceFolder(project, new Path("src/action"),new Path("src"));
-// WtpUtils.createSourceFolder(project, new Path("src/model"),new Path("src"));
-
-
// Copy sources to src
AntCopyUtils.copyFileToFile(
- new File(seamGenHomeFolder,"src/Authenticator.java"),
- new File(project.getLocation().toFile(),"src/" + model.getProperty(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString().replace('.', '/')+"/"+"Authenticator.java"),
+ new File(seamGenHomeFolder,"src/modelAuthenticator.java"),
+ new File(project.getLocation().toFile(),source.getFullPath().lastSegment()+"/model/" + model.getProperty(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString().replace('.', '/')+"/"+"Authenticator.java"),
new FilterSetCollection(filtersFilterSet), true);
AntCopyUtils.copyFileToFile(
persistenceFile,
- new File(project.getLocation().toFile(),"src/META-INF/persistence.xml"),
+ new File(srcFolder,"META-INF/persistence.xml"),
viewFilterSetCollection, true);
AntCopyUtils.copyFileToFile(
@@ -361,8 +367,8 @@
AntCopyUtils.copyFiles(seamHomeFolder,webLibFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamHomeFolder)));
AntCopyUtils.copyFiles(seamLibFolder,webLibFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(seamLibFolder)));
AntCopyUtils.copyFiles(droolsLibFolder,webLibFolder,new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_WAR_LIB_FILESET_EAR_CONFIG).dir(droolsLibFolder)));
+ AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"messages_en.properties"),srcFolder, true);
-
File ear = new File(project.getLocation().removeLastSegments(1).toFile(),model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ear");
File ejb = new File(project.getLocation().removeLastSegments(1).toFile(),model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME)+"-ejb");
ear.mkdir();
@@ -396,6 +402,14 @@
persistenceFile,
new File(ejb,"ejbModule/META-INF/persistence.xml"),
viewFilterSetCollection, true);
+
+ createComponentsProperties(new File(ejb,"ejbModule"), isWarConfiguration(model)?"":project.getName()+"-ear", false);
+
+ AntCopyUtils.FileSet ejbSrcResourcesSet = new AntCopyUtils.FileSet(JBOOS_EJB_WEB_INF_CLASSES_SET).dir(seamGenResFolder);
+ AntCopyUtils.copyFilesAndFolders(
+ seamGenResFolder,new File(ejb,"ejbModule"),new AntCopyUtils.FileSetFileFilter(ejbSrcResourcesSet), viewFilterSetCollection, true);
+
+
// ********************************************************************************************
// Copy seam project indicator
// ********************************************************************************************
@@ -430,13 +444,15 @@
hibernateDialectFilterSet, true);
File earContentsFolder = new File(ear,"EarContent");
-
- AntCopyUtils.copyFilesAndFolders(
- seamGenResFolder,
- earContentsFolder,
- new AntCopyUtils.FileSetFileFilter(new AntCopyUtils.FileSet(JBOSS_EAR_META_INF_SET).dir(seamGenResFolder)),
- viewFilterSetCollection,true);
+ FilterSet earFilterSet = new FilterSet();
+ earFilterSet.addFilter("projectName",ear.getName()+".ear");
+
+ AntCopyUtils.copyFileToFolder(
+ new File(seamGenResFolder,"META-INF/jboss-app.xml"),
+ new File(earContentsFolder,"META-INF"),
+ new FilterSetCollection(earFilterSet),true);
+
// Copy configuration files from template
AntCopyUtils.copyFilesAndFolders(
new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(),"ear"),
17 years, 3 months
JBoss Tools SVN: r3804 - in trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces: resources/calendar and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: ezheleznyakov
Date: 2007-09-26 05:14:13 -0400 (Wed, 26 Sep 2007)
New Revision: 3804
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-847
Create template for <rich:calendar/> component.
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css 2007-09-26 09:14:13 UTC (rev 3804)
@@ -0,0 +1,137 @@
+.rich-calendar-exterior {
+ border: 1px solid #c0c0c0; /*panelBorderColor*/
+}
+
+.rich-calendar-btn {
+ cursor: pointer;
+}
+
+.rich-calendar-header {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ background: #C7D7EC; /*additionalBackgroundColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 7px;
+ height: 22px;
+}
+
+.rich-cell-size {
+ width: 25px;
+ height: 22px;
+}
+
+.rich-calendar-cell {
+ background-color: #FFFFFF; /*generalBackgroundColor*/
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 0px;
+ vertical-align: middle;
+ text-align: center;
+}
+
+.rich-calendar-tool {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color: #D4CFC7; /*headerBackgroundColor*/
+ font-size: 11px; /*headerSizeFont*/
+ font-family: Arial, Verdana, sans-serif;
+ color: #000000; /*headerTextColor*/
+ font-weight: bold;
+ vertical-align: middle;
+ text-align: center;
+ width: 25px;
+ height: 22px;
+}
+
+.rich-calendar-month {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color: #D4CFC7; /*headerBackgroundColor*/
+ border-bottom-color: #C4C0B9;
+ font-size: 11px; /*headerSizeFont*/
+ font-family: Arial, Verdana, sans-serif;
+ color: #000000;
+ /*headerTextColor*/
+ font-weight: bold;
+ vertical-align: middle;
+ text-align: center;
+ color: #000000;
+ font-size: 11px
+}
+
+.rich-calendar-days {
+ background: #F1EEE9 none repeat scroll 0%;
+ border-bottom: 1px solid #C4C0B9; /*panelBorderColor*/
+ border-right: 0px solid #C4C0B9; /*panelBorderColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: Arial, Verdana, sans-serif;
+ vertical-align: middle;
+ text-align: center;
+ height: 22px;
+ vertical-align: middle;
+}
+
+.rich-calendar-week {
+ border-bottom: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ background-color: #f5f5f5; /*unknown parameter - need to add*/
+ vertical-align: middle;
+ text-align: center;
+ width: 25px;
+}
+
+.rich-calendar-holly {
+ background-color: # #FFEBDA; /*unknown parameter - need to add*/
+ color: #FF7800; /*unknown parameter - need to add*/
+}
+
+.rich-calendar-today {
+ background-color: #ff7800; /*unknown parameter - need to add*/
+ color: #ffebda; /*unknown parameter - need to add*/
+ font-weight: bold;
+}
+
+.rich-calendar-spec {
+ background-color: #e4f5e2; /*unknown parameter - need to add*/
+}
+
+.rich-calendar-select {
+ background-color: #224986; /*headerBackgroundColor*/
+ color: #FFFFFF; /*headerTextColor*/
+ font-weight: bold;
+}
+
+.rich-right-cell {
+ border-right: 0px;
+}
+
+.rich-bottom-cell {
+ border-bottom: 0px;
+}
+
+.rich-calendar-toolfooter {
+ border-top: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 0px solid #c0c0c0; /*panelBorderColor*/
+ background: #F1EEE9; /*additionalBackgroundColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 0px 7px 0px 7px;
+ height: 22px;
+}
+
+.rich-calendar-footer {
+ border-top: 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right: 0px solid #c0c0c0; /*panelBorderColor*/
+ background: #C7D7EC; /*additionalBackgroundColor*/
+ font-size: 11px; /*generalSizeFont*/
+ font-family: verdana; /*generalFamilyFont*/
+ padding: 7px;
+ height: 22px;
+}
+
+.rich-calendar-popupicon {
+ cursor: pointer;
+ vertical-align: middle;
+}
\ No newline at end of file
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.css
___________________________________________________________________
Name: svn:mime-type
+ text/css
Name: svn:eol-style
+ native
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/calendar/calendar.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2007-09-26 08:41:28 UTC (rev 3803)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2007-09-26 09:14:13 UTC (rev 3804)
@@ -17,6 +17,9 @@
*
*/
public class HtmlComponentUtil {
+
+ /** HTML TAG BR */
+ public static final String HTML_TAG_BR = "br";
/** HTML TAG COLGROUP */
public static final String HTML_TAG_COLGROUP = "colgroup";
@@ -125,6 +128,9 @@
/** HTML_ROWSPAN_ATTR * */
public static final String HTML_ROWSPAN_ATTR = "rowspan";
+
+ /** HTML_READONLY_ATTR * */
+ public static final String HTML_READONLY_ATTR = "readonly";
/** HTML_SIZE_ATTR * */
public static final String HTML_SIZE_ATTR = "size";
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2007-09-26 09:14:13 UTC (rev 3804)
@@ -0,0 +1,448 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Displays template for calendar
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesCalendarTemplate extends VpeAbstractTemplate {
+
+ static String[] HEADER_CONTENT = { "<<", "<", "", ">", ">>" };
+ private String[] weeks = new String[7];
+ private int[] monthDays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+ final static String STYLE_PATH = "calendar/calendar.css";
+ final static String BUTTON_IMG = "calendar/calendar.gif";
+ final static int COLUMN = 8;
+ final static String FILL_WIDTH = "100%";
+ final static int NUM_DAYS_IN_WEEK = 7;
+ final static String TODAY = "Today";
+ final static int CALENDAR_WIDTH = 200;
+ final static int CALENDAR_IMAGE_WIDTH = 20;
+ final static String ATTRIBUTE_POPUP = "popup";
+ final static String ATTRIBUTE_TEXT = "text";
+
+ public RichFacesCalendarTemplate() {
+ super();
+ Calendar cal = Calendar.getInstance();
+ int firstDayOfWeek = cal.getFirstDayOfWeek();
+ while (firstDayOfWeek != cal.get(Calendar.DAY_OF_WEEK)) {
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ }
+
+ SimpleDateFormat sdf = new SimpleDateFormat("EE");
+ for (int i = 0; i < NUM_DAYS_IN_WEEK; i++) {
+ weeks[i] = new String(sdf.format(cal.getTime()));
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ }
+
+ }
+
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+ Element source = (Element) sourceNode;
+ String popup = source.getAttribute(ATTRIBUTE_POPUP);
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "calendar");
+ VpeCreationData creationData;
+ if (popup != null && popup.equalsIgnoreCase("false")) {
+ Element calendar = createCalendar(visualDocument);
+ creationData = new VpeCreationData(calendar);
+ } else {
+ Element calendarWithPopup = createCalendarWithPopup(visualDocument,
+ source);
+ creationData = new VpeCreationData(calendarWithPopup);
+ }
+ return creationData;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private Element createCalendarWithPopup(Document visualDocument,
+ Element source) {
+ Element div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.HTML_ATR_WIDTH + " : " + CALENDAR_WIDTH
+ + "px;");
+ Element input = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_INPUT);
+ input.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.HTML_ATR_WIDTH + " : "
+ + (CALENDAR_WIDTH - CALENDAR_IMAGE_WIDTH) + "px;");
+ input.setAttribute(HtmlComponentUtil.HTML_TYPE_ATTR, ATTRIBUTE_TEXT);
+ input.setAttribute(HtmlComponentUtil.HTML_READONLY_ATTR, "true");
+ String value = source.getAttribute(HtmlComponentUtil.HTML_VALUE_ATTR);
+ if (value != null) {
+ input.setAttribute(HtmlComponentUtil.HTML_VALUE_ATTR, value);
+ }
+
+ Element image = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ image.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-popupicon");
+ ComponentUtil.setImg(image, BUTTON_IMG);
+
+ div.appendChild(input);
+ div.appendChild(image);
+
+ return div;
+ }
+
+ /**
+ * Checks, whether it is necessary to re-create an element at change of
+ * attribute
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @param name
+ * Atrribute name
+ * @param value
+ * Attribute value
+ * @return <code>true</code> if it is required to re-create an element at
+ * a modification of attribute, <code>false</code> otherwise.
+ */
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Element visualNode,
+ Object data, String name, String value) {
+ if (name.equalsIgnoreCase(ATTRIBUTE_POPUP)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private Element createCalendar(Document visualDocument) {
+ Element div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.HTML_ATR_WIDTH + " : " + CALENDAR_WIDTH
+ + "px;");
+ Element table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "calendar-exterior");
+
+ Element tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+ Element header = createCalendarHeader(visualDocument);
+ Element calendarBody = createCalendarBody(visualDocument);
+ tbody.appendChild(header);
+ tbody.appendChild(calendarBody);
+ table.appendChild(tbody);
+ div.appendChild(table);
+
+ return div;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private Element createCalendarHeader(Document visualDocument) {
+ Element tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ Element td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td.setAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN, "" + COLUMN);
+
+ SimpleDateFormat sdf = new SimpleDateFormat("MMMM, yyyy");
+ Calendar cal = Calendar.getInstance();
+ HEADER_CONTENT[2] = sdf.format(cal.getTime());
+
+ Element table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+
+ Element tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+
+ Element tr1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ for (int i = 0; i < HEADER_CONTENT.length; i++) {
+ Element td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ i == 2 ? "rich-calendar-month" : "rich-calendar-tool");
+
+ Text text1 = visualDocument.createTextNode(HEADER_CONTENT[i]);
+ td1.appendChild(text1);
+ tr1.appendChild(td1);
+ }
+
+ tbody.appendChild(tr1);
+ table.appendChild(tbody);
+ td.appendChild(table);
+ tr.appendChild(td);
+ return tr;
+ }
+
+ /**
+ *
+ * @param visualDocument
+ * @return Node of the visual tree.
+ */
+ private Element createCalendarBody(Document visualDocument) {
+ Element tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+
+ Element bodyTR = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ for (int i = 0; i < COLUMN; i++) {
+ Element td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-days");
+ if (i == 0) {
+ Element br = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_BR);
+ td.appendChild(br);
+ } else {
+ Text text = visualDocument.createTextNode(i == 0 ? ""
+ : weeks[i - 1]);
+ td.appendChild(text);
+ }
+ bodyTR.appendChild(td);
+ }
+
+ tbody.appendChild(bodyTR);
+
+ // // Calendar body
+ int jumped = 0;
+ int inserted = 1;
+
+ Calendar cal = Calendar.getInstance();
+ int month = cal.get(Calendar.MONTH);
+ int day = cal.get(Calendar.DAY_OF_WEEK);
+ int dayN = cal.get(Calendar.DAY_OF_MONTH);
+ int days = monthDays[month];
+ if (month == 1) {
+ int year = cal.get(Calendar.YEAR);
+ if (year % 4 == 0)
+ days = 29;
+ }
+
+ int start = day
+ - (dayN % NUM_DAYS_IN_WEEK + cal.getFirstDayOfWeek() - 1);
+ if (start < 0)
+ start += NUM_DAYS_IN_WEEK;
+ int weeks = (start + days) / NUM_DAYS_IN_WEEK;
+ if ((start + days) % NUM_DAYS_IN_WEEK != 0)
+ weeks++;
+ for (int i = weeks; i > 0; i--) {
+ Element tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ // Week in year
+ Element weekTD = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ weekTD.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-week");
+ cal.set(Calendar.DAY_OF_MONTH, inserted);
+ Text weekText = visualDocument.createTextNode(""
+ + cal.get(Calendar.WEEK_OF_YEAR));
+ weekTD.appendChild(weekText);
+ tr.appendChild(weekTD);
+ for (int j = NUM_DAYS_IN_WEEK; j > 0; j--) {
+ Element td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ if (jumped < start || inserted > days) {
+ cal.set(Calendar.DAY_OF_MONTH, inserted);
+ int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
+ td
+ .setAttribute(
+ HtmlComponentUtil.HTML_CLASS_ATTR,
+ (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) ? "rich-cell-size rich-calendar-cell rich-calendar-holly rich-right-cell"
+ : "rich-cell-size rich-calendar-cell rich-calendar-cell");
+ Element br = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_BR);
+ td.appendChild(br);
+ tr.appendChild(td);
+ jumped++;
+ } else {
+ if (inserted == dayN) {
+
+ td
+ .setAttribute(
+ HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-cell-size rich-calendar-cell rich-calendar-today ");
+ Text text = visualDocument
+ .createTextNode("" + inserted);
+ td.appendChild(text);
+ tr.appendChild(td);
+ } else {
+ cal.set(Calendar.DAY_OF_MONTH, inserted);
+ int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
+ td
+ .setAttribute(
+ HtmlComponentUtil.HTML_CLASS_ATTR,
+ (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) ? "rich-cell-size rich-calendar-cell rich-calendar-holly rich-right-cell "
+ : "rich-cell-size rich-calendar-cell");
+ Text text = visualDocument
+ .createTextNode("" + inserted);
+ td.appendChild(text);
+ tr.appendChild(td);
+ }
+ inserted++;
+ }
+ }
+ tbody.appendChild(tr);
+ }
+
+ // Footer for calendar
+
+ Element tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ Element td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td.setAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN, "" + COLUMN);
+
+ Element table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+
+ Element tr1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ Element td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-toolfooter");
+
+ SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
+ cal = Calendar.getInstance();
+
+ Text text1 = visualDocument.createTextNode(sdf.format(cal.getTime()));
+ td1.appendChild(text1);
+ tr1.appendChild(td1);
+
+ Element td2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td2.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+ td2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-toolfooter");
+ tr1.appendChild(td2);
+
+ Element td3 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td3.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, FILL_WIDTH);
+ td3.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-calendar-toolfooter");
+ td3.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR,
+ HtmlComponentUtil.HTML_ALIGN_RIGHT_VALUE);
+ Text text3 = visualDocument.createTextNode(TODAY);
+ td3.appendChild(text3);
+ tr1.appendChild(td3);
+
+ table.appendChild(tr1);
+ td.appendChild(table);
+ tr.appendChild(td);
+
+ tbody.appendChild(tr);
+
+ return tbody;
+ }
+
+ /**
+ *
+ */
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Node visualNode, Object data, String name,
+ String value) {
+ super.setAttribute(pageContext, sourceElement, visualDocument,
+ visualNode, data, name, value);
+ if (name.equalsIgnoreCase(HtmlComponentUtil.HTML_VALUE_ATTR)) {
+ String popup = sourceElement.getAttribute(ATTRIBUTE_POPUP);
+ if (popup != null && popup.equalsIgnoreCase("false"))
+ return;
+ Element element = (Element) visualNode;
+ NodeList list = element.getChildNodes();
+ Node tableNode = list.item(0);
+ Element input = (Element) tableNode;
+ input.setAttribute(HtmlComponentUtil.HTML_VALUE_ATTR, value);
+ }
+
+ }
+
+ /**
+ *
+ */
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Node visualNode,
+ Object data, String name) {
+ super.removeAttribute(pageContext, sourceElement, visualDocument,
+ visualNode, data, name);
+ if (name.equalsIgnoreCase(HtmlComponentUtil.HTML_VALUE_ATTR)) {
+ String popup = sourceElement.getAttribute(ATTRIBUTE_POPUP);
+ if (popup != null && popup.equalsIgnoreCase("false"))
+ return;
+ Element element = (Element) visualNode;
+ NodeList list = element.getChildNodes();
+ Node tableNode = list.item(0);
+ Element input = (Element) tableNode;
+ input.removeAttribute(HtmlComponentUtil.HTML_VALUE_ATTR);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-26 08:41:28 UTC (rev 3803)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-26 09:14:13 UTC (rev 3804)
@@ -452,6 +452,20 @@
</vpe:template>
</vpe:tag>
+ <vpe:tag name="rich:calendar" case-sensitive="yes">
+ <vpe:template children="no" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesCalendarTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
<vpe:tag name="rich:virtualEarth" case-sensitive="yes">
<vpe:template children="no" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesVirtualEarthTemplate">
17 years, 3 months
JBoss Tools SVN: r3803 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/template and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: ezheleznyakov
Date: 2007-09-26 04:41:28 -0400 (Wed, 26 Sep 2007)
New Revision: 3803
Added:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-897
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-26 08:34:58 UTC (rev 3802)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-09-26 08:41:28 UTC (rev 3803)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor;
import java.io.BufferedReader;
@@ -62,6 +62,7 @@
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMMouseEvent;
+import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMRange;
@@ -86,7 +87,7 @@
private static final int DRAG_AREA_WIDTH = 10;
private static final int DRAG_AREA_HEIGHT = 10;
private static final String ATTR_XMLNS = "xmlns";
-
+
private MozillaEditor visualEditor;
private XulRunnerEditor xulRunnerEditor;
private nsIDOMDocument visualDocument;
@@ -96,36 +97,35 @@
private nsIDOMNode headNode;
private List includeStack;
boolean rebuildFlag = false;
-
- private static final String ATTR_VPE = "vpe";
+
+ private static final String ATTR_VPE = "vpe";
private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink";
-
+
private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet";
-
- private static final String YES_STRING = "yes";
- private static final String NO_STRING = "no";
- private static final String ZERO_STRING = "0";
- private static final String EMPTY_STRING = "";
-
- private static final String ATRIBUTE_BORDER = "border";
- private static final String ATRIBUTE_CELLSPACING = "cellspacing";
- private static final String ATRIBUTE_CELLPADDING = "cellpadding";
-
- private static final String DOTTED_BORDER_STYLE = "border : 1px dotted #808080";
- private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted #808080";
- private static final String DOTTED_BORDER_STYLE_FOR_TD = "border-left : 1px dotted #808080; border-right : 1px dotted #808080; border-top : 1px dotted #808080; border-bottom : 0px; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only";
+
+ private static final String YES_STRING = "yes";
+ private static final String NO_STRING = "no";
+ private static final String ZERO_STRING = "0";
+ private static final String EMPTY_STRING = "";
+
+ private static final String ATRIBUTE_BORDER = "border";
+ private static final String ATRIBUTE_CELLSPACING = "cellspacing";
+ private static final String ATRIBUTE_CELLPADDING = "cellpadding";
+
+ private static final String DOTTED_BORDER_STYLE = "border : 1px dotted #808080";
+ private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted #808080";
+ private static final String DOTTED_BORDER_STYLE_FOR_TD = "border-left : 1px dotted #808080; border-right : 1px dotted #808080; border-top : 1px dotted #808080; border-bottom : 0px; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only";
private static final String DOTTED_BORDER_STYLE_FOR_SPAN = "border : 1px solid #0051DD; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only";
-
-
+
static private HashSet<String> unborderedSourceNodes = new HashSet<String>();
- static{
+ static {
unborderedSourceNodes.add(HTML.TAG_HTML);
unborderedSourceNodes.add(HTML.TAG_HEAD);
unborderedSourceNodes.add(HTML.TAG_BODY);
}
-
+
static private HashSet<String> unborderedVisualNodes = new HashSet<String>();
- static{
+ static {
unborderedVisualNodes.add(HTML.TAG_TBODY);
unborderedVisualNodes.add(HTML.TAG_THEAD);
unborderedVisualNodes.add(HTML.TAG_TR);
@@ -137,9 +137,10 @@
unborderedVisualNodes.add(HTML.TAG_BR);
}
private VpeDnd dropper;
-
- public VpeVisualDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter, VpeTemplateManager templateManager, MozillaEditor visualEditor, VpePageContext pageContext) {
+ public VpeVisualDomBuilder(VpeDomMapping domMapping,
+ INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
+ MozillaEditor visualEditor, VpePageContext pageContext) {
super(domMapping, sorceAdapter, templateManager);
this.visualEditor = visualEditor;
xulRunnerEditor = visualEditor.getXulRunnerEditor();
@@ -151,14 +152,15 @@
dropper = new VpeDnd();
dropper.setDndData(false, true);
}
-
+
public void buildDom(Document sourceDocument) {
includeStack = new ArrayList();
IEditorInput input = pageContext.getEditPart().getEditorInput();
if (input instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput)input).getFile();
+ IFile file = ((IFileEditorInput) input).getFile();
if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file, pageContext.getSourceBuilder().getSourceDocument()));
+ includeStack.add(new VpeIncludeInfo(null, file, pageContext
+ .getSourceBuilder().getSourceDocument()));
}
}
pageContext.refreshConnector();
@@ -166,9 +168,9 @@
addChildren(null, sourceDocument, visualContentArea);
registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
}
-
+
public void rebuildDom(Document sourceDocument) {
- cleanHead();
+ cleanHead();
domMapping.clear(visualContentArea);
pageContext.clearAll();
refreshExternalLinks();
@@ -183,44 +185,53 @@
if (sourceDocument != null) {
buildDom(sourceDocument);
}
-
+
rebuildFlag = true;
}
// temporary, will be change to prefference's variable
- //private boolean borderVisible = true;
-
- private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode, nsIDOMNode visualContainer) {
+ // private boolean borderVisible = true;
+
+ private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode,
+ nsIDOMNode visualContainer) {
nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
if (visualNewNode != null) {
- if (visualNextNode == null) {
+ if (visualNextNode == null) {
visualContainer.appendChild(visualNewNode);
- } else {
+ } else {
visualContainer.insertBefore(visualNewNode, visualNextNode);
}
return true;
}
-
+
return false;
}
-
- private nsIDOMElement createBorder(Node sourceNode, nsIDOMElement visualNode, boolean block){
+ 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())){
+ 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);
+ 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())){
+ 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);
@@ -228,8 +239,10 @@
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.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);
@@ -237,73 +250,104 @@
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);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
td2.appendChild(p);
p.appendChild(visualNode);
-
- }else{
+
+ } else {
border = visualDocument.createElement(HTML.TAG_TABLE);
border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
-
+
nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
border.appendChild(tr2);
nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
tr2.appendChild(td2);
nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
- p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, DOTTED_BORDER_STYLE);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
td2.appendChild(p);
p.appendChild(visualNode);
}
- }else{
+ } 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());
+ border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
+ nsIDOMElement name = visualDocument
+ .createElement(HTML.TAG_SPAN);
+ name.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE_FOR_SPAN);
+ nsIDOMText text = visualDocument.createTextNode(sourceNode
+ .getNodeName());
name.appendChild(text);
border.appendChild(name);
}
border.appendChild(visualNode);
}
- if(VpeStyleUtil.getAbsolute((Element)sourceNode) && border != null){
- int top = VpeStyleUtil.getSizeFromStyle((Element)sourceNode, VpeStyleUtil.ATTRIBUTE_STYLE+VpeStyleUtil.DOT_STRING+VpeStyleUtil.PARAMETER_TOP);
- int left = VpeStyleUtil.getSizeFromStyle((Element)sourceNode, VpeStyleUtil.ATTRIBUTE_STYLE+VpeStyleUtil.DOT_STRING+VpeStyleUtil.PARAMETER_LEFT);
-
- String style = visualNode.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.deleteFromString(style, VpeStyleUtil.PARAMETER_POSITION, VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style, VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style, VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
+ if (VpeStyleUtil.getAbsolute((Element) sourceNode) && border != null) {
+ int top = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_TOP);
+ int left = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_LEFT);
+
+ String style = visualNode
+ .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_POSITION,
+ VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
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);
+ if (top != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_TOP, top);
+ if (left != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_LEFT, left);
border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
}
return border;
}
-
- protected nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer) {
+
+ protected nsIDOMNode createNode(Node sourceNode,
+ nsIDOMNode visualOldContainer) {
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
- Map<?,?> xmlnsMap = createXmlns((Element)sourceNode);
+ Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
Set<?> ifDependencySet = new HashSet();
pageContext.setCurrentVisualNode(visualOldContainer);
- VpeTemplate template = templateManager.getTemplate(pageContext, (Element)sourceNode, ifDependencySet);
- VpeCreationData creationData = template.create(pageContext, sourceNode, visualDocument);
+ VpeTemplate template = templateManager.getTemplate(pageContext,
+ (Element) sourceNode, ifDependencySet);
+
+ VpeCreationData creationData = template.create(pageContext,
+ sourceNode, visualDocument);
pageContext.setCurrentVisualNode(null);
- nsIDOMElement visualNewElement = (nsIDOMElement) creationData.getNode();
+ nsIDOMElement visualNewElement = (nsIDOMElement) creationData
+ .getNode();
+
+ if (visualNewElement != null)
+ correctVisualAttribute(visualNewElement);
+
nsIDOMElement border = null;
- setTooltip((Element)sourceNode, visualNewElement);
- if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS.getValue()) && visualNewElement != null) {
+ setTooltip((Element) sourceNode, visualNewElement);
+ if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS
+ .getValue())
+ && visualNewElement != null) {
boolean block = true;
- if (template.getTagDescription(null, null, null,visualNewElement,null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
+ if (template.getTagDescription(null, null, null,
+ visualNewElement, null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
block = false;
}
border = createBorder(sourceNode, visualNewElement, block);
@@ -312,23 +356,31 @@
setReadOnlyElement(visualNewElement);
}
if (registerFlag) {
- VpeElementMapping elementMapping = new VpeElementMapping((Element)sourceNode, visualNewElement, border, template, ifDependencySet, creationData.getData());
+ VpeElementMapping elementMapping = new VpeElementMapping(
+ (Element) sourceNode, visualNewElement, border,
+ template, ifDependencySet, creationData.getData());
elementMapping.setXmlnsMap(xmlnsMap);
registerNodes(elementMapping);
}
if (template.isChildren()) {
List<?> childrenInfoList = creationData.getChildrenInfoList();
if (childrenInfoList == null) {
- addChildren(template, sourceNode, visualNewElement != null ? visualNewElement : visualOldContainer);
+ addChildren(template, sourceNode,
+ visualNewElement != null ? visualNewElement
+ : visualOldContainer);
} else {
- addChildren(template, sourceNode, visualOldContainer, childrenInfoList);
+ addChildren(template, sourceNode, visualOldContainer,
+ childrenInfoList);
}
}
pageContext.setCurrentVisualNode(visualOldContainer);
- template.validate(pageContext, (Element)sourceNode, visualDocument, creationData);
+ template.validate(pageContext, (Element) sourceNode,
+ visualDocument, creationData);
pageContext.setCurrentVisualNode(null);
- if(border != null) return border;
- else return visualNewElement;
+ if (border != null)
+ return border;
+ else
+ return visualNewElement;
case Node.TEXT_NODE:
String sourceText = sourceNode.getNodeValue();
if (sourceText.trim().length() <= 0) {
@@ -336,13 +388,14 @@
return null;
}
String visualText = TextUtil.visualText(sourceText);
- nsIDOMText visualNewTextNode = visualDocument.createTextNode(visualText);
+ nsIDOMText visualNewTextNode = visualDocument
+ .createTextNode(visualText);
if (registerFlag) {
registerNodes(new VpeNodeMapping(sourceNode, visualNewTextNode));
}
return visualNewTextNode;
case Node.COMMENT_NODE:
- if(!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
+ if (!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
return null;
}
nsIDOMElement visualNewComment = createComment(sourceNode);
@@ -353,17 +406,39 @@
}
return null;
}
-
+
+ private void correctVisualAttribute(nsIDOMElement element) {
+
+ String styleValue = element.getAttribute(HTML.TAG_STYLE);
+ String backgroundValue = element
+ .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
+
+ if (styleValue != null) {
+ styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(HTML.TAG_STYLE, styleValue);
+ }
+ if (backgroundValue != null) {
+ backgroundValue = VpeStyleUtil
+ .addFullPathIntoBackgroundValue(backgroundValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
+ backgroundValue);
+ }
+ }
+
protected nsIDOMElement createComment(Node sourceNode) {
nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
- String value = COMMENT_PREFIX + sourceNode.getNodeValue() + COMMENT_SUFFIX;
+ String value = COMMENT_PREFIX + sourceNode.getNodeValue()
+ + COMMENT_SUFFIX;
nsIDOMText text = visualDocument.createTextNode(value);
div.appendChild(text);
return div;
}
- protected void addChildren(VpeTemplate containerTemplate, Node sourceContainer, nsIDOMNode visualContainer) {
+ protected void addChildren(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
NodeList sourceNodes = sourceContainer.getChildNodes();
int len = sourceNodes.getLength();
int childrenCount = 0;
@@ -374,39 +449,42 @@
}
}
if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer, visualContainer);
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
}
}
- protected void addChildren(VpeTemplate containerTemplate, Node sourceContainer, nsIDOMNode visualOldContainer, List<?> childrenInfoList) {
+ 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);
+ VpeChildrenInfo info = (VpeChildrenInfo) childrenInfoList.get(i);
nsIDOMNode visualParent = info.getVisualParent();
- if (visualParent == null) visualParent = visualOldContainer;
+ if (visualParent == null)
+ visualParent = visualOldContainer;
List<?> sourceChildren = info.getSourceChildren();
int childrenCount = 0;
if (sourceChildren != null) {
for (int j = 0; j < sourceChildren.size(); j++) {
- if (addNode((Node)sourceChildren.get(j), null, visualParent)) {
+ if (addNode((Node) sourceChildren.get(j), null,
+ visualParent)) {
childrenCount++;
}
}
}
if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer, visualParent);
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualParent);
}
}
}
-
-
-
-
-///////////////////////////////////////////////////////////////////////////
- public nsIDOMNode addStyleNodeToHead(String styleText){
- nsIDOMNode newStyle = visualDocument.createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
-
- if(styleText != null){
+ // /////////////////////////////////////////////////////////////////////////
+ public nsIDOMNode addStyleNodeToHead(String styleText) {
+ nsIDOMNode newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+
+ if (styleText != null) {
nsIDOMText newText = visualDocument.createTextNode(styleText);
newStyle.appendChild(newText);
}
@@ -414,66 +492,73 @@
return newStyle;
}
- public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode, String styleText){
- nsIDOMElement newStyle = visualDocument.createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
-
- if(styleText != null){
+ 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);
}
-
+
headNode.replaceChild(newStyle, oldStyleNode);
return newStyle;
}
-
- public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode){
+
+ public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
headNode.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);
- }
- }
+ 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);
+ }
+ }
}
void removeExternalLinks() {
- nsIDOMNodeList childs = headNode.getChildNodes();
- long length = childs.getLength();
- for (long i = length - 1; i >= 0; i--) {
- nsIDOMNode node = childs.item(i);
- if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- boolean isLink = false;
- boolean isStyle = false;
- if((isLink = HTML.TAG_LINK.equalsIgnoreCase(node.getNodeName()))
- || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName()))) {
- nsIDOMElement element = (nsIDOMElement)node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE.equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
- && YES_STRING.equalsIgnoreCase(element.getAttribute("ext"))) {
- headNode.removeChild(node);
- }
- }
- }
- }
+ nsIDOMNodeList childs = headNode.getChildNodes();
+ long length = childs.getLength();
+ for (long i = length - 1; i >= 0; i--) {
+ nsIDOMNode node = childs.item(i);
+ if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ boolean isLink = false;
+ boolean isStyle = false;
+ if ((isLink = HTML.TAG_LINK
+ .equalsIgnoreCase(node.getNodeName()))
+ || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node
+ .getNodeName()))) {
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
+ && YES_STRING.equalsIgnoreCase(element
+ .getAttribute("ext"))) {
+ headNode.removeChild(node);
+ }
+ }
+ }
+ }
}
void refreshExternalLinks() {
- removeExternalLinks();
- addExternalLinks();
+ removeExternalLinks();
+ addExternalLinks();
}
-
-// ==========================================================
+
+ // ==========================================================
void resetPseudoElement(nsIDOMNode visualNode) {
if (visualNode != null) {
nsIDOMNode visualParent = visualNode.getParentNode();
@@ -481,155 +566,166 @@
PseudoInfo info = getPseudoInfo(visualParent);
if (info.pseudoNode == null && !info.isElements) {
addPseudoElementImpl(visualParent);
- } else if (info.pseudoNode != null && info.isElements) {
+ } else if (info.pseudoNode != null && info.isElements) {
visualParent.removeChild(info.pseudoNode);
}
}
}
}
-
+
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;
- }
- }
+ 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;
}
-
+
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;
}
-
+
static boolean isPseudoElement(nsIDOMNode visualNode) {
if (visualNode == null) {
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;
- }
- return false;
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(PSEUDO_ELEMENT_ATTR))) {
+ return true;
+ }
+
+ return false;
}
-
- private void setPseudoContent(VpeTemplate containerTemplate, Node sourceContainer, nsIDOMNode visualContainer) {
+
+ private void setPseudoContent(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
if (containerTemplate != null) {
- containerTemplate.setPseudoContent(pageContext, sourceContainer, visualContainer, visualDocument);
+ containerTemplate.setPseudoContent(pageContext, sourceContainer,
+ visualContainer, visualDocument);
} else {
- VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(pageContext, sourceContainer, visualContainer, visualDocument);
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
+ pageContext, sourceContainer, visualContainer,
+ visualDocument);
}
-
-// if (isEmptyElement(visualContainer)) {
-// addPseudoElementImpl(visualContainer);
-// }
+
+ // if (isEmptyElement(visualContainer)) {
+ // addPseudoElementImpl(visualContainer);
+ // }
}
-
+
private void addPseudoElementImpl(nsIDOMNode visualParent) {
- if (!templateManager.isWithoutPseudoElementContainer(visualParent.getNodeName())) {
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent
+ .getNodeName())) {
if (VpeDebug.visualAddPseudoElement) {
- System.out.println("-------------------- addPseudoElement: " + visualParent.getNodeName());
+ System.out.println("-------------------- addPseudoElement: "
+ + visualParent.getNodeName());
}
- nsIDOMElement visualPseudoElement = visualDocument.createElement(PSEUDO_ELEMENT);
+ nsIDOMElement visualPseudoElement = visualDocument
+ .createElement(PSEUDO_ELEMENT);
visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, "yes");
visualParent.appendChild(visualPseudoElement);
}
}
-
+
public boolean isEmptyElement(nsIDOMNode visualParent) {
nsIDOMNodeList visualNodes = visualParent.getChildNodes();
long len = visualNodes.getLength();
-
- if ((len == 0)
- || (len == 1 && isEmptyText(visualNodes.item(0)))) {
+
+ if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
return true;
}
return false;
}
-
+
public boolean isEmptyDocument() {
nsIDOMNodeList visualNodes = visualContentArea.getChildNodes();
long len = visualNodes.getLength();
if ((len == 0)
- || (len == 1
- && (isEmptyText(visualNodes.item(0))
- || isPseudoElement(visualNodes.item(0)))) ) {
+ || (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
+ .item(0))))) {
return true;
}
-
+
return false;
}
-
+
private boolean isEmptyText(nsIDOMNode visualNode) {
if (visualNode == null
- || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE) ) {
+ || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
return false;
}
-
+
if (visualNode.getNodeValue().trim().length() == 0) {
return true;
}
-
+
return false;
}
-// ==========================================================
-
+
+ // ==========================================================
+
public void updateNode(Node sourceNode) {
if (sourceNode == null)
return;
-
+
switch (sourceNode.getNodeType()) {
- case Node.DOCUMENT_NODE :
- rebuildDom((Document)sourceNode);
+ case Node.DOCUMENT_NODE:
+ rebuildDom((Document) sourceNode);
break;
- case Node.COMMENT_NODE :
+ case Node.COMMENT_NODE:
updateComment(sourceNode);
break;
- default :
+ default:
updateElement(getNodeForUpdate(sourceNode));
}
}
-
+
// TODO Ssergey Vasilyev make a common code for figuring out
- // if it is need to update parent node or not
+ // 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) {
@@ -638,25 +734,31 @@
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 (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;
+ elementMapping = (VpeElementMapping) nodeMapping;
if (elementMapping != null && elementMapping.getTemplate() != null) {
- Node updateNode = elementMapping.getTemplate().getNodeForUptate(pageContext, elementMapping.getSourceNode(), elementMapping.getVisualNode(), elementMapping.getData());
+ Node updateNode = elementMapping.getTemplate()
+ .getNodeForUptate(pageContext,
+ elementMapping.getSourceNode(),
+ elementMapping.getVisualNode(),
+ elementMapping.getData());
if (updateNode != null && updateNode != sourceNode) {
updateNode(updateNode);
return;
@@ -665,9 +767,9 @@
}
nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
if (visualOldNode != null) {
- if(elementMapping != null){
+ if (elementMapping != null) {
nsIDOMElement border = elementMapping.getBorder();
- if(border != null){
+ if (border != null) {
visualOldNode = border;
}
}
@@ -683,21 +785,22 @@
}
}
}
-
+
public void removeNode(Node sourceNode) {
domMapping.remove(sourceNode);
}
-
+
private Node getParentTable(Node sourceNode, int depth) {
Node parentNode = sourceNode.getParentNode();
- for (int i = 0; parentNode != null && i < depth; parentNode = parentNode.getParentNode(), i++) {
+ 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();
@@ -707,7 +810,7 @@
}
return null;
}
-
+
public void setText(Node sourceText) {
Node sourceParent = sourceText.getParentNode();
if (sourceParent != null && sourceParent.getLocalName() != null) {
@@ -723,9 +826,12 @@
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();
+ 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;
@@ -735,9 +841,10 @@
updateNode(sourceText);
}
}
-
+
public void setAttribute(Element sourceElement, String name, String value) {
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
if (elementMapping != null) {
if (elementMapping.isIfDependencyFromAttribute(name)) {
updateElement(sourceElement);
@@ -745,126 +852,160 @@
VpeTemplate template = elementMapping.getTemplate();
if (elementMapping.getBorder() != null) {
updateElement(sourceElement);
- } else if (template.isRecreateAtAttrChange(pageContext, sourceElement, visualDocument, (nsIDOMElement)elementMapping.getVisualNode(), elementMapping.getData(), name, value)) {
+ } else if (template.isRecreateAtAttrChange(pageContext,
+ sourceElement, visualDocument,
+ (nsIDOMElement) elementMapping.getVisualNode(),
+ elementMapping.getData(), name, value)) {
updateElement(sourceElement);
} else {
- nsIDOMElement visualElement = (nsIDOMElement)elementMapping.getVisualNode();
+ 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)) {
+ } else if (HTML.TAG_OPTION
+ .equalsIgnoreCase(visualElementName)) {
updateElement(sourceElement.getParentNode());
return;
- } else if (HTML.TAG_INPUT.equalsIgnoreCase(visualElementName)) {
+ } else if (HTML.TAG_INPUT
+ .equalsIgnoreCase(visualElementName)) {
updateElement(sourceElement);
- }
+ }
}
setXmlnsAttribute(elementMapping, name, value);
- template.setAttribute(pageContext, sourceElement, visualDocument, visualElement, elementMapping.getData(), name, value);
+ template.setAttribute(pageContext, sourceElement,
+ visualDocument, visualElement, elementMapping
+ .getData(), name, value);
resetTooltip(sourceElement, visualElement);
}
}
}
}
-
-
+
public void stopToggle(Node sourceNode) {
- if (!(sourceNode instanceof Element))
+ if (!(sourceNode instanceof Element))
return;
-
- Element sourceElement = (Element)sourceNode;
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+
+ 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);
+ ((VpeToggableTemplate) template).stopToggling(sourceElement);
}
}
}
+
public boolean doToggle(nsIDOMNode visualNode) {
- if (visualNode == null) return false;
+ 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);
+ 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;
+ if (visualElement == null)
+ return false;
- nsIDOMAttr toggleIdAttr = visualElement.getAttributeNode("vpe-user-toggle-id");
- if (toggleIdAttr == null) return false;
+ nsIDOMAttr toggleIdAttr = visualElement
+ .getAttributeNode("vpe-user-toggle-id");
+ if (toggleIdAttr == null)
+ return false;
String toggleId = toggleIdAttr.getNodeValue();
- if (toggleId == null) return false;
+ if (toggleId == null)
+ return false;
boolean toggleLookup = false;
- nsIDOMAttr toggleLookupAttr = visualElement.getAttributeNode("vpe-user-toggle-lookup-parent");
+ nsIDOMAttr toggleLookupAttr = visualElement
+ .getAttributeNode("vpe-user-toggle-lookup-parent");
if (toggleLookupAttr != null) {
toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
}
-
-
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(getLastSelectedElement());
- Node sourceNode = (Node)domMapping.getSourceNode(getLastSelectedElement());
- if (sourceNode == null) return false;
- Element sourceElement = (Element)(sourceNode instanceof Element ?
- sourceNode : sourceNode.getParentNode());
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(getLastSelectedElement());
+ Node sourceNode = (Node) domMapping
+ .getSourceNode(getLastSelectedElement());
+ if (sourceNode == null)
+ return false;
+ Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
+ : sourceNode.getParentNode());
+
if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
-
- while (toggleLookup && sourceElement != null && !(template instanceof VpeToggableTemplate)) {
- sourceElement = (Element)sourceElement.getParentNode();
- if (sourceElement == null) break;
- elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
- if (elementMapping == null) continue;
+ VpeTemplate template = elementMapping.getTemplate();
+
+ while (toggleLookup && sourceElement != null
+ && !(template instanceof VpeToggableTemplate)) {
+ sourceElement = (Element) sourceElement.getParentNode();
+ if (sourceElement == null)
+ break;
+ elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping == null)
+ continue;
template = elementMapping.getTemplate();
}
-
+
if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate)template).toggle(this, sourceElement, toggleId);
+ ((VpeToggableTemplate) template).toggle(this, sourceElement,
+ toggleId);
updateElement(sourceElement);
return true;
}
}
return false;
}
-
+
public void removeAttribute(Element sourceElement, String name) {
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ 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)) {
+ 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());
+ template.removeAttribute(pageContext, sourceElement,
+ visualDocument, (nsIDOMElement) elementMapping
+ .getVisualNode(), elementMapping.getData(),
+ name);
+ resetTooltip(sourceElement, (nsIDOMElement) elementMapping
+ .getVisualNode());
}
}
}
}
-
+
public void refreshBundleValues(Element sourceElement) {
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
if (elementMapping != null) {
VpeTemplate template = elementMapping.getTemplate();
- template.refreshBundleValues(pageContext, sourceElement, elementMapping.getData());
+ template.refreshBundleValues(pageContext, sourceElement,
+ elementMapping.getData());
}
}
-
+
boolean isContentArea(nsIDOMNode visualNode) {
return visualContentArea.equals(visualNode);
}
-
+
nsIDOMElement getContentArea() {
return visualContentArea;
}
@@ -875,62 +1016,71 @@
void setSelectionRectangle(nsIDOMElement visualElement, boolean scroll) {
int resizerConstrains = getResizerConstrains(visualElement);
- visualEditor.setSelectionRectangle(visualElement, resizerConstrains, scroll);
+ visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
+ scroll);
}
public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMElement newNode = createLinkNode(href_val, ATTR_REL_STYLESHEET_VALUE, ext_val);
+ nsIDOMElement newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
headNode.appendChild(newNode);
return newNode;
}
- public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode, String href_val, String ext_val) {
- nsIDOMNode newNode = createLinkNode(href_val, ATTR_REL_STYLESHEET_VALUE, ext_val);
+ public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
+ String href_val, String ext_val) {
+ nsIDOMNode newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
headNode.replaceChild(newNode, oldNode);
return newNode;
}
-
+
public nsIDOMNode replaceLinkNodeToHead(String href_val, String ext_val) {
nsIDOMNode newNode = null;
nsIDOMNode oldNode = getLinkNode(href_val, ext_val);
- if (oldNode == null) {
- newNode = addLinkNodeToHead(href_val, ext_val);
- }
+ if (oldNode == null) {
+ newNode = addLinkNodeToHead(href_val, ext_val);
+ }
return newNode;
}
-
- public void removeLinkNodeFromHead(nsIDOMNode node){
+
+ public void removeLinkNodeFromHead(nsIDOMNode node) {
headNode.removeChild(node);
}
-
- private nsIDOMElement createLinkNode(String href_val, String rel_val, String 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
+ /*
+ * Because of the Mozilla caches the linked css files we replace tag
+ * <link rel="styleseet" href="file://..."> with tag <style
+ * vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style> It is
+ * LinkReplacer
*/
linkNode = visualDocument.createElement(HTML.TAG_STYLE);
linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
-
+
/* Copy links attributes into our <style> */
linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- try {
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ try {
StringBuffer styleText = new StringBuffer(EMPTY_STRING);
- BufferedReader in = new BufferedReader(new FileReader((new Path(href_val)).setDevice("").toOSString()));
+ BufferedReader in = new BufferedReader(new FileReader(
+ (new Path(href_val)).setDevice("").toOSString()));
String str = EMPTY_STRING;
while ((str = in.readLine()) != null) {
styleText.append(str);
}
String styleForParse = styleText.toString();
- styleForParse = VpeStyleUtil.addFullPathIntoURLValue(styleForParse, href_val);
-
+ styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
+ styleForParse, href_val);
+
in.close();
- nsIDOMText textNode = visualDocument.createTextNode(styleForParse);
+ nsIDOMText textNode = visualDocument
+ .createTextNode(styleForParse);
linkNode.appendChild(textNode);
return linkNode;
} catch (FileNotFoundException fnfe) {
@@ -939,18 +1089,21 @@
VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
}
}
-
+
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);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- return linkNode;
+ return linkNode;
}
private boolean isLinkReplacer(nsIDOMNode node) {
return HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && ATTR_VPE_INLINE_LINK_VALUE.equalsIgnoreCase(((nsIDOMElement)node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).getAttribute(ATTR_VPE));
+ && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE));
}
private nsIDOMNode getLinkNode(String href_val, String ext_val) {
@@ -958,116 +1111,150 @@
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;
- }
- }
- }
+ 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;
}
-
+
private void cleanHead() {
nsIDOMNodeList children = headNode.getChildNodes();
long len = children.getLength();
for (long i = len - 1; i >= 0; i--) {
nsIDOMNode node = children.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- String name = node.getNodeName();
- if (HTML.TAG_LINK.equalsIgnoreCase(name) || isLinkReplacer(node) ) {
- if (NO_STRING.equalsIgnoreCase(((nsIDOMElement)node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).getAttribute("ext"))) {
-// int linkAddress = MozillaSupports.queryInterface(node, nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
-// nsIStyleSheetLinkingElement linkingElement = new nsIStyleSheetLinkingElement(linkAddress);
-// linkingElement.removeStyleSheet();
- node = headNode.removeChild(node);
- }
- } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && (!YES_STRING.equalsIgnoreCase(((nsIDOMElement)node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).getAttribute(ATTR_VPE)))) {
- node = headNode.removeChild(node);
- }
- }
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ String name = node.getNodeName();
+ if (HTML.TAG_LINK.equalsIgnoreCase(name)
+ || isLinkReplacer(node)) {
+ if (NO_STRING.equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute("ext"))) {
+ // int linkAddress =
+ // MozillaSupports.queryInterface(node,
+ // nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
+ // nsIStyleSheetLinkingElement linkingElement = new
+ // nsIStyleSheetLinkingElement(linkAddress);
+ // linkingElement.removeStyleSheet();
+ node = headNode.removeChild(node);
+ }
+ } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && (!YES_STRING
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE)))) {
+ node = headNode.removeChild(node);
+ }
+ }
}
}
-
+
private class PseudoInfo {
private nsIDOMNode pseudoNode;
private boolean isElements;
-
+
private PseudoInfo() {
this(null, false);
}
-
+
private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
this.pseudoNode = pseudoNode;
this.isElements = isElements;
}
}
-
void showDragCaret(nsIDOMNode node, int offset) {
xulRunnerEditor.showDragCaret(node, offset);
}
-
+
void hideDragCaret() {
-
+
xulRunnerEditor.hideDragCaret();
}
-
+
private int getResizerConstrains(nsIDOMNode visualNode) {
VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
- if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- return ((VpeElementMapping)nodeMapping).getTemplate().getTagDescription(pageContext, (Element)nodeMapping.getSourceNode(), visualDocument, (nsIDOMElement)nodeMapping.getVisualNode(), ((VpeElementMapping)nodeMapping).getData()).getResizeConstrains();
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ return ((VpeElementMapping) nodeMapping).getTemplate()
+ .getTagDescription(pageContext,
+ (Element) nodeMapping.getSourceNode(),
+ visualDocument,
+ (nsIDOMElement) nodeMapping.getVisualNode(),
+ ((VpeElementMapping) nodeMapping).getData())
+ .getResizeConstrains();
}
return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
}
- public void resize(nsIDOMElement element, int resizerConstrains, int top, int left, int width, int height) {
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(element);
+ 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);
+ elementMapping.getTemplate().resize(pageContext,
+ (Element) elementMapping.getSourceNode(), visualDocument,
+ element, elementMapping.getData(), resizerConstrains, top,
+ left, width, height);
}
}
-
+
static boolean isAnonElement(nsIDOMNode visualNode) {
- if (visualNode != null && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- String attrValue = ((nsIDOMElement)visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).getAttribute(MOZ_ANONCLASS_ATTR);
-
+ if (visualNode != null
+ && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ String attrValue = ((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(MOZ_ANONCLASS_ATTR);
+
return attrValue != null && attrValue.length() > 0;
}
-
+
return false;
}
boolean canInnerDrag(nsIDOMElement visualDragElement) {
VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
- if(node instanceof VpeElementMapping) {
- VpeElementMapping elementMapping = (VpeElementMapping)node;
+ if (node instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping) node;
if (elementMapping != null) {
- return elementMapping.getTemplate().canInnerDrag(pageContext, (Element)elementMapping.getSourceNode(), visualDocument, visualDragElement, elementMapping.getData());
+ return elementMapping.getTemplate().canInnerDrag(pageContext,
+ (Element) elementMapping.getSourceNode(),
+ visualDocument, visualDragElement,
+ elementMapping.getData());
}
}
return false;
}
- VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode, VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode,
+ VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
long visualDropOffset = visualDropInfo.getDropOffset();
Node sourceDropContainer = null;
int sourceDropOffset = 0;
-
+
switch (visualDropContainer.getNodeType()) {
case nsIDOMNode.ELEMENT_NODE:
nsIDOMNode visualOffsetNode = null;
boolean afterFlag = false;
- long visualChildCount = VisualDomUtil.getChildCount(visualDropContainer);
+ long visualChildCount = VisualDomUtil
+ .getChildCount(visualDropContainer);
if (visualDropOffset < visualChildCount) {
- visualOffsetNode = VisualDomUtil.getChildNode(visualDropContainer, visualDropOffset);
- if (isPseudoElement(visualOffsetNode) || isAnonElement(visualOffsetNode)) {
+ visualOffsetNode = VisualDomUtil.getChildNode(
+ visualDropContainer, visualDropOffset);
+ if (isPseudoElement(visualOffsetNode)
+ || isAnonElement(visualOffsetNode)) {
visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
afterFlag = true;
}
@@ -1076,41 +1263,53 @@
afterFlag = visualChildCount != 0;
}
if (visualOffsetNode != null) {
- Node sourceOffsetNode = domMapping.getSourceNode(visualOffsetNode);
+ Node sourceOffsetNode = domMapping
+ .getSourceNode(visualOffsetNode);
if (sourceOffsetNode != null) {
sourceDropContainer = sourceOffsetNode.getParentNode();
- sourceDropOffset = ((NodeImpl)sourceOffsetNode).getIndex();
+ sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
if (afterFlag) {
sourceDropOffset++;
}
}
}
if (sourceDropContainer == null) {
- sourceDropContainer = domMapping.getNearSourceNode(visualDropContainer);
+ sourceDropContainer = domMapping
+ .getNearSourceNode(visualDropContainer);
if (sourceDropContainer != null) {
- sourceDropOffset = sourceDropContainer.getChildNodes().getLength();
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
}
}
- if (sourceDropContainer == null){
- sourceDropContainer = domMapping.getNearSourceNode(visualContentArea);
- sourceDropOffset = sourceDropContainer.getChildNodes().getLength();
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping
+ .getNearSourceNode(visualContentArea);
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
}
break;
case nsIDOMNode.TEXT_NODE:
- VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualDropContainer);
+ VpeNodeMapping nodeMapping = domMapping
+ .getNearNodeMapping(visualDropContainer);
switch (nodeMapping.getType()) {
case VpeNodeMapping.TEXT_MAPPING:
sourceDropContainer = nodeMapping.getSourceNode();
- sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer.getNodeValue(), visualDropOffset);
+ sourceDropOffset = TextUtil.sourceInnerPosition(
+ sourceDropContainer.getNodeValue(), visualDropOffset);
break;
case VpeNodeMapping.ELEMENT_MAPPING:
// it's attribute
if (isTextEditable(visualDropContainer)) {
- String[] atributeNames = ((VpeElementMapping)nodeMapping).getTemplate().getOutputAtributeNames();
+ 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);
+ Element sourceElement = (Element) nodeMapping
+ .getSourceNode();
+ sourceDropContainer = sourceElement
+ .getAttributeNode(atributeNames[0]);
+ sourceDropOffset = TextUtil.sourceInnerPosition(
+ sourceDropContainer.getNodeValue(),
+ visualDropOffset);
}
}
nodeMapping.getVisualNode();
@@ -1118,28 +1317,36 @@
break;
}
if (sourceDropContainer != null) {
- return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer, sourceDropOffset, checkParentTemplates);
+ return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer,
+ sourceDropOffset, checkParentTemplates);
} else {
return new VpeSourceInnerDropInfo(null, 0, false);
}
}
-
- VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode, Node container, int offset, boolean checkParentsTemplates) {
- //Thread.dumpStack();
+
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode,
+ Node container, int offset, boolean checkParentsTemplates) {
+ // Thread.dumpStack();
boolean canDrop = false;
switch (container.getNodeType()) {
case Node.ELEMENT_NODE:
VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
- if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- canDrop = ((VpeElementMapping)nodeMapping).getTemplate().canInnerDrop(pageContext, container, dragNode);
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
+ .canInnerDrop(pageContext, container, dragNode);
}
if (!canDrop) {
- if(!checkParentsTemplates) return new VpeSourceInnerDropInfo(container, offset, canDrop);
-// offset = ((NodeImpl)container).getIndex();
-// container = container.getParentNode();
- //TODO Max Areshkau unclear logic , if we can drop on element why we trying to drop
+ 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 getSourceInnerDropInfo(dragNode, container, offset,
+ // false);
return new VpeSourceInnerDropInfo(container, offset, canDrop);
}
break;
@@ -1157,7 +1364,7 @@
return new VpeSourceInnerDropInfo(null, 0, canDrop);
}
}
-
+
public void innerDrop(Node dragNode, Node container, int offset) {
VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
if (mapping != null) {
@@ -1169,38 +1376,50 @@
nsIDOMNode visualParent = visualDropContainer.getParentNode();
VpeNodeMapping oldMapping = mapping;
mapping = domMapping.getNearNodeMapping(visualParent);
- if (mapping != null && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- ((VpeElementMapping)mapping).getTemplate().innerDrop(pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container, offset, true));
+ if (mapping != null
+ && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ ((VpeElementMapping) mapping).getTemplate()
+ .innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container,
+ offset, true));
} else {
- ((VpeElementMapping)oldMapping).getTemplate().innerDrop(pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container, offset, true));
+ ((VpeElementMapping) oldMapping).getTemplate()
+ .innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container,
+ offset, true));
}
}
-
+
}
}
- void innerDrop(VpeSourceInnerDragInfo dragInfo, VpeSourceInnerDropInfo dropInfo) {
+ void innerDrop(VpeSourceInnerDragInfo dragInfo,
+ VpeSourceInnerDropInfo dropInfo) {
dropper.drop(pageContext, dragInfo, dropInfo);
}
-
+
nsIDOMElement getNearDragElement(Element visualElement) {
- VpeElementMapping elementMapping = domMapping.getNearElementMapping(visualElement);
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
while (elementMapping != null) {
if (canInnerDrag(elementMapping.getVisualElement())) {
return elementMapping.getVisualElement();
}
- elementMapping = domMapping.getNearElementMapping(elementMapping.getVisualNode().getParentNode());
+ elementMapping = domMapping.getNearElementMapping(elementMapping
+ .getVisualNode().getParentNode());
}
return null;
}
-
+
nsIDOMElement getDragElement(nsIDOMElement visualElement) {
- VpeElementMapping elementMapping = domMapping.getNearElementMapping(visualElement);
- if (elementMapping != null && canInnerDrag(elementMapping.getVisualElement())) {
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ if (elementMapping != null
+ && canInnerDrag(elementMapping.getVisualElement())) {
return elementMapping.getVisualElement();
}
return null;
@@ -1209,15 +1428,18 @@
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);
+ 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(";");
+ 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())) {
+ if ("-moz-user-modify".equals(item[0].trim())
+ && "read-only".equals(item[1].trim())) {
return false;
}
}
@@ -1233,15 +1455,17 @@
}
return true;
}
-
- VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer, int sourceDropOffset) {
+
+ VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
+ int sourceDropOffset) {
nsIDOMNode visualDropContainer = null;
long visualDropOffset = 0;
switch (sourceDropContainer.getNodeType()) {
case Node.TEXT_NODE:
visualDropContainer = domMapping.getVisualNode(sourceDropContainer);
- visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer.getNodeValue(), sourceDropOffset);
+ visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
+ .getNodeValue(), sourceDropOffset);
break;
case Node.ELEMENT_NODE:
case Node.DOCUMENT_NODE:
@@ -1251,12 +1475,13 @@
nsIDOMNode visualChild = domMapping.getVisualNode(sourceChild);
if (visualChild != null) {
visualDropContainer = visualChild.getParentNode();
-
+
visualDropOffset = VisualDomUtil.getOffset(visualChild);
}
}
if (visualDropContainer == null) {
- visualDropContainer = domMapping.getNearVisualNode(sourceDropContainer);
+ visualDropContainer = domMapping
+ .getNearVisualNode(sourceDropContainer);
nsIDOMNode visualChild = getLastAppreciableVisualChild(visualDropContainer);
if (visualChild != null) {
visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
@@ -1266,39 +1491,47 @@
}
break;
case Node.ATTRIBUTE_NODE:
- Element sourceElement = ((Attr)sourceDropContainer).getOwnerElement();
- VpeElementMapping elementMapping = domMapping.getNearElementMapping(sourceElement);
- nsIDOMNode textNode = elementMapping.getTemplate().getOutputTextNode(pageContext, sourceElement, elementMapping.getData());
+ 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);
+ visualDropOffset = TextUtil.visualInnerPosition(
+ sourceDropContainer.getNodeValue(), sourceDropOffset);
}
break;
}
if (visualDropContainer == null) {
return null;
}
- return new VpeVisualInnerDropInfo(visualDropContainer, visualDropOffset, 0, 0);
+ return new VpeVisualInnerDropInfo(visualDropContainer,
+ visualDropOffset, 0, 0);
}
-
+
protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null && !((ElementImpl)sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName())) return;
+ if (visualElement != null && sourceElement != null
+ && !((ElementImpl) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
String titleValue = getTooltip(sourceElement);
-
+
if (titleValue != null) {
titleValue = titleValue.replaceAll("&", "&");
titleValue = titleValue.replaceAll("<", "<");
titleValue = titleValue.replaceAll(">", ">");
}
-
+
if (titleValue != null) {
-// visualElement.setAttribute("title", titleValue);
+ // visualElement.setAttribute("title", titleValue);
setTooltip(visualElement, titleValue);
}
}
}
-
+
protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
visualElement.setAttribute("title", titleValue);
nsIDOMNodeList children = visualElement.getChildNodes();
@@ -1306,28 +1539,32 @@
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);
+ setTooltip(((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)),
+ titleValue);
}
}
}
-
+
private void resetTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null && !((ElementImpl)sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName())) return;
+ if (visualElement != null && sourceElement != null
+ && !((ElementImpl) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
String titleValue = getTooltip(sourceElement);
-
+
if (titleValue != null) {
titleValue = titleValue.replaceAll("&", "&");
titleValue = titleValue.replaceAll("<", "<");
titleValue = titleValue.replaceAll(">", ">");
}
-
+
if (titleValue != null) {
resetTooltip(visualElement, titleValue);
}
}
}
-
+
private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
visualElement.setAttribute("title", titleValue);
nsIDOMNodeList children = visualElement.getChildNodes();
@@ -1336,49 +1573,52 @@
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);
+ resetTooltip((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
+ titleValue);
}
}
}
}
-
+
private String getTooltip(Element sourceElement) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(sourceElement.getNodeName());
- NamedNodeMap attrs = sourceElement.getAttributes();
- int len = attrs.getLength();
- for (int i = 0; i < len; i++){
- if (i == 7)
- {
- return buffer.append("\n\t... ").toString();
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(sourceElement.getNodeName());
+ NamedNodeMap attrs = sourceElement.getAttributes();
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++) {
+ if (i == 7) {
+ return buffer.append("\n\t... ").toString();
}
int valueLength = attrs.item(i).getNodeValue().length();
if (valueLength > 30) {
- StringBuffer temp = new StringBuffer();
- temp.append(attrs.item(i).getNodeValue().substring(0,15) + " ... "
- + attrs.item(i).getNodeValue().substring(valueLength - 15,valueLength));
+ StringBuffer temp = new StringBuffer();
+ temp.append(attrs.item(i).getNodeValue().substring(0, 15)
+ + " ... "
+ + attrs.item(i).getNodeValue().substring(
+ valueLength - 15, valueLength));
buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp);
- }
- else
- buffer.append("\n" + attrs.item(i).getNodeName() + ": " + attrs.item(i).getNodeValue());
-
- }
-
+ } else
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": "
+ + attrs.item(i).getNodeValue());
+
+ }
+
return buffer.toString();
}
-
+
Rectangle getNodeBounds(nsIDOMNode visualNode) {
-
+
return VpeDndUtil.getBounds(visualNode);
}
-
+
static boolean canInsertAfter(int x, int y, Rectangle rect) {
if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
return true;
}
return y >= rect.x && x > (rect.x + rect.width / 2);
}
-
+
static nsIDOMNode getLastAppreciableVisualChild(nsIDOMNode visualParent) {
nsIDOMNode visualLastChild = null;
nsIDOMNodeList visualChildren = visualParent.getChildNodes();
@@ -1392,23 +1632,27 @@
}
return visualLastChild;
}
-
- void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo, VpeVisualInnerDropInfo oldVisualDropInfo) {
- nsIDOMNode newVisualDropContainer = newVisualDropInfo.getDropContainer();
- nsIDOMNode oldVisualDropContainer = oldVisualDropInfo.getDropContainer();
+ void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
+ VpeVisualInnerDropInfo oldVisualDropInfo) {
+ nsIDOMNode newVisualDropContainer = newVisualDropInfo
+ .getDropContainer();
+ nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
+ .getDropContainer();
+
if (newVisualDropContainer.equals(oldVisualDropContainer)) {
newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
return;
}
-
+
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)) {
+ if (canInsertAfter(oldVisualDropInfo.getMouseX(),
+ oldVisualDropInfo.getMouseY(), rect)) {
offset++;
}
newVisualDropInfo.setDropOffset(offset);
@@ -1426,64 +1670,74 @@
range.selectNode(selectedNode);
return range;
}
-
+
public static boolean isIncludeElement(nsIDOMElement visualElement) {
- return YES_STRING.equalsIgnoreCase(visualElement.getAttribute(INCLUDE_ELEMENT_ATTR));
+ return YES_STRING.equalsIgnoreCase(visualElement
+ .getAttribute(INCLUDE_ELEMENT_ATTR));
}
-
+
public static void markIncludeElement(nsIDOMElement visualElement) {
visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
}
-
+
protected void setReadOnlyElement(nsIDOMElement node) {
String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify", "read-only");
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify",
+ "read-only");
node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
}
-
+
void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
- nsIDOMElement selectedElement = xulRunnerEditor.getLastSelectedElement();
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
if (selectedElement != null && canInnerDrag(selectedElement)) {
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil.getMousePoint(mouseEvent))) {
- //change cursor
- Cursor cursor1= new Cursor(xulRunnerEditor.getDisplay(),SWT.CURSOR_SIZEALL);
- xulRunnerEditor.setCursor(cursor1);
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ // change cursor
+ Cursor cursor1 = new Cursor(xulRunnerEditor.getDisplay(),
+ SWT.CURSOR_SIZEALL);
+ xulRunnerEditor.setCursor(cursor1);
}
}
}
-
+
private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
- //TODO add drag and drop support
- return dragArea.contains(mousePoint) &&
- mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH) &&
- mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
+ // TODO add drag and drop support
+ return dragArea.contains(mousePoint)
+ && mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH)
+ && mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
}
-
+
nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
-
- nsIDOMElement selectedElement = xulRunnerEditor.getLastSelectedElement();
+
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
if (selectedElement != null && canInnerDrag(selectedElement)) {
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil.getMousePoint(mouseEvent))) {
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
return selectedElement;
}
}
return null;
}
-
- VpeSourceInnerDragInfo getSourceInnerDragInfo(VpeVisualInnerDragInfo visualDragInfo) {
+
+ VpeSourceInnerDragInfo getSourceInnerDragInfo(
+ VpeVisualInnerDragInfo visualDragInfo) {
nsIDOMNode visualNode = visualDragInfo.getNode();
int offset = visualDragInfo.getOffset();
int length = visualDragInfo.getLength();
-
+
VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
Node sourceNode = nodeMapping.getSourceNode();
if (sourceNode != null) {
switch (sourceNode.getNodeType()) {
case Node.TEXT_NODE:
- int end = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset + length);
- offset = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset);
+ int end = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(
+ visualNode.getNodeValue(), offset);
length = end - offset;
break;
case Node.ELEMENT_NODE:
@@ -1491,12 +1745,17 @@
// it's attribute
sourceNode = null;
if (isTextEditable(visualNode)) {
- String[] atributeNames = ((VpeElementMapping)nodeMapping).getTemplate().getOutputAtributeNames();
+ 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);
+ 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;
}
}
@@ -1506,75 +1765,83 @@
}
return new VpeSourceInnerDragInfo(sourceNode, offset, length);
}
-
+
public nsIDOMText getOutputTextNode(Attr attr) {
- Element sourceElement = ((Attr)attr).getOwnerElement();
- VpeElementMapping elementMapping = domMapping.getNearElementMapping(sourceElement);
+ Element sourceElement = ((Attr) attr).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
if (elementMapping != null) {
- return elementMapping.getTemplate().getOutputTextNode(pageContext, sourceElement, elementMapping.getData());
+ return elementMapping.getTemplate().getOutputTextNode(pageContext,
+ sourceElement, elementMapping.getData());
}
return null;
}
-
+
nsIDOMElement getLastSelectedElement() {
-
- return xulRunnerEditor.getLastSelectedElement();
+
+ return xulRunnerEditor.getLastSelectedElement();
}
-
+
public void pushIncludeStack(VpeIncludeInfo includeInfo) {
includeStack.add(includeInfo);
}
-
+
public VpeIncludeInfo popIncludeStack() {
VpeIncludeInfo includeInfo = null;
if (includeStack.size() > 0) {
- includeInfo = (VpeIncludeInfo)includeStack.remove(includeStack.size() - 1);
+ includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
+ .size() - 1);
}
return includeInfo;
}
public boolean isFileInIncludeStack(IFile file) {
- if (file == null) return false;
+ if (file == null)
+ return false;
for (int i = 0; i < includeStack.size(); i++) {
- if (file.equals(((VpeIncludeInfo)includeStack.get(i)).getFile())) {
+ if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
return true;
}
}
return false;
}
-
+
protected boolean isCurrentMainDocument() {
return includeStack.size() <= 1;
}
-
+
public int getCurrentMainIncludeOffset() {
- if (includeStack.size() <= 1) return -1;
- VpeIncludeInfo info = (VpeIncludeInfo)includeStack.get(1);
- return ((IndexedRegion)info.getElement()).getStartOffset();
+ if (includeStack.size() <= 1)
+ return -1;
+ VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
+ return ((IndexedRegion) info.getElement()).getStartOffset();
}
-
+
public VpeIncludeInfo getCurrentIncludeInfo() {
- if (includeStack.size() <= 0) return null;
- return (VpeIncludeInfo)includeStack.get(includeStack.size() - 1);
+ if (includeStack.size() <= 0)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
}
-
+
public VpeIncludeInfo getRootIncludeInfo() {
- if (includeStack.size() <= 1) return null;
- return (VpeIncludeInfo)includeStack.get(1);
+ if (includeStack.size() <= 1)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(1);
}
void dispose() {
- cleanHead();
+ cleanHead();
domMapping.clear(visualContentArea);
pageContext.dispose();
}
-
+
protected Map createXmlns(Element sourceNode) {
- NamedNodeMap attrs = ((Element)sourceNode).getAttributes();
+ 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);
+ addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
+ true);
}
if (xmlnsMap.size() > 0) {
return xmlnsMap;
@@ -1583,35 +1850,42 @@
return null;
}
- private void setXmlnsAttribute(VpeElementMapping elementMapping, String name, String value) {
- Element sourceElement = (Element)elementMapping.getSourceNode();
+ 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();
+ if (xmlnsMap == null)
+ xmlnsMap = new HashMap();
addTaglib(sourceElement, xmlnsMap, name, true);
elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
}
}
- private void removeXmlnsAttribute(VpeElementMapping elementMapping, String name) {
- Element sourceElement = (Element)elementMapping.getSourceNode();
+ 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);
+ 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) {
+ 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(), new Integer(attr.hashCode()));
- pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr.getLocalName(), ns);
+ pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
+ .getLocalName(), ns);
}
}
@@ -1619,15 +1893,16 @@
* @return the dnd
*/
public VpeDnD getDnd() {
-
+
return dnd;
}
/**
- * @param dnd the dnd to set
+ * @param dnd
+ * the dnd to set
*/
public void setDnd(VpeDnD dnd) {
-
+
this.dnd = dnd;
}
@@ -1639,7 +1914,8 @@
}
/**
- * @param pageContext the pageContext to set
+ * @param pageContext
+ * the pageContext to set
*/
protected void setPageContext(VpePageContext pageContext) {
this.pageContext = pageContext;
@@ -1653,7 +1929,8 @@
}
/**
- * @param visualDocument the visualDocument to set
+ * @param visualDocument
+ * the visualDocument to set
*/
protected void setVisualDocument(nsIDOMDocument visualDocument) {
this.visualDocument = visualDocument;
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java 2007-09-26 08:41:28 UTC (rev 3803)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author ezheleznyakov(a)exadel.com
+ *
+ */
+public class HtmlBodyTemplate extends VpeAbstractTemplate {
+
+ private nsIDOMElement bodyOld;
+ private static String STYLE_FOR_DIV = "width: 100%; height: 100%";
+
+ /**
+ *
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ goToTree(visualDocument.getChildNodes().item(0));
+
+ for (int i = 0; i < sourceNode.getAttributes().getLength(); i++) {
+ String name = sourceNode.getAttributes().item(i).getNodeName();
+ String value = sourceNode.getAttributes().item(i).getNodeValue();
+ // all full path for 'url'
+ if (VpeStyleUtil.ATTRIBUTE_STYLE.equalsIgnoreCase(name))
+ value = VpeStyleUtil.addFullPathIntoURLValue(value, pageContext
+ .getEditPart().getEditorInput());
+ if (VpeStyleUtil.PARAMETR_BACKGROND.equalsIgnoreCase(name))
+ value = VpeStyleUtil.addFullPathIntoBackgroundValue(value,
+ pageContext.getEditPart().getEditorInput());
+
+ bodyOld.setAttribute(name, value);
+
+ }
+
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, STYLE_FOR_DIV);
+
+ return new VpeCreationData(div);
+ }
+
+ /**
+ *
+ * @param node
+ */
+ private void goToTree(nsIDOMNode node) {
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++)
+ if (HTML.TAG_BODY.equalsIgnoreCase(node.getChildNodes().item(i)
+ .getNodeName()))
+ bodyOld = (nsIDOMElement) node.getChildNodes().item(i)
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ else
+ goToTree(node.getChildNodes().item(i));
+ }
+
+ /**
+ * Checks, whether it is necessary to re-create an element at change of
+ * attribute
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @param name
+ * Attribute name
+ * @param value
+ * Attribute value
+ * @return <code>true</code> if it is required to re-create an element at
+ * a modification of attribute, <code>false</code> otherwise.
+ */
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
+}
\ No newline at end of file
Property changes on: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/HtmlBodyTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-26 08:34:58 UTC (rev 3802)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCopyCreator.java 2007-09-26 08:41:28 UTC (rev 3803)
@@ -143,8 +143,6 @@
String name = sourceAttr.getName();
String value = sourceAttr.getValue();
- if (name.equalsIgnoreCase(STYLE_ATTR_NAME))
- value = VpeStyleUtil.addFullPathIntoURLValue(sourceAttr.getValue(), pageContext.getEditPart().getEditorInput());
if (isAttribute(name)) {
visualElement.setAttribute(name, value);
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-26 08:34:58 UTC (rev 3802)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2007-09-26 08:41:28 UTC (rev 3803)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.util;
import java.io.File;
@@ -22,227 +22,263 @@
import org.w3c.dom.Element;
public class VpeStyleUtil {
-
- public static final String ATTRIBUTE_STYLE = "style";
+ public static final String ATTRIBUTE_STYLE = "style";
+
public static final String PARAMETER_POSITION = "position";
public static final String PARAMETER_TOP = "top";
public static final String PARAMETER_LEFT = "left";
public static final String PARAMETER_WIDTH = "width";
public static final String PARAMETER_HEIGHT = "height";
+ public static final String PARAMETR_BACKGROND = "background";
public static final String VALUE_ABSOLUTE = "absolute";
-
+
public static final String DOT_STRING = ".";
public static final String COLON_STRING = ":";
public static final String SEMICOLON_STRING = ";";
public static final String PX_STRING = "px";
public static final String SPACE_STRING = " ";
public static final String EMPTY_STRING = "";
-
+
public static String ATTR_URL = "url";
public static String OPEN_BRACKET = "(";
public static String CLOSE_BRACKET = ")";
public static String FILE_PRTOCOL = "file:///";
public static String FILE_STR = "file:";
public static String FILE_SEPARAROT = "/";
-
-
+
// sets parameter position in atribute style to absolute value
- public static void setAbsolute(Element sourceElement){
+ public static void setAbsolute(Element sourceElement) {
String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
- if(style == null){
+ if (style == null) {
style = EMPTY_STRING;
- }else{ // remove old sizes
- style = deleteFromString(style, PARAMETER_POSITION, SEMICOLON_STRING);
+ } else { // remove old sizes
+ style = deleteFromString(style, PARAMETER_POSITION,
+ SEMICOLON_STRING);
}
- if(style.length() > 0){
- if(!style.endsWith(SEMICOLON_STRING))style += SEMICOLON_STRING;
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
}
-
- style += SPACE_STRING+PARAMETER_POSITION+SPACE_STRING+COLON_STRING+SPACE_STRING+VALUE_ABSOLUTE+SEMICOLON_STRING;
-
+
+ style += SPACE_STRING + PARAMETER_POSITION + SPACE_STRING
+ + COLON_STRING + SPACE_STRING + VALUE_ABSOLUTE
+ + SEMICOLON_STRING;
+
sourceElement.setAttribute(ATTRIBUTE_STYLE, style);
}
-// sets parameter position in absolute value
- public static String setAbsolute(String styleString){
+ // sets parameter position in absolute value
+ public static String setAbsolute(String styleString) {
String style = new String(styleString);
- if(style == null){
+ if (style == null) {
style = EMPTY_STRING;
- }else{ // remove old sizes
- style = deleteFromString(style, PARAMETER_POSITION, SEMICOLON_STRING);
+ } else { // remove old sizes
+ style = deleteFromString(style, PARAMETER_POSITION,
+ SEMICOLON_STRING);
}
- if(style.length() > 0){
- if(!style.endsWith(SEMICOLON_STRING))style += SEMICOLON_STRING;
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
}
-
- style += SPACE_STRING+PARAMETER_POSITION+SPACE_STRING+COLON_STRING+SPACE_STRING+VALUE_ABSOLUTE+SEMICOLON_STRING;
-
- return style;
+
+ style += SPACE_STRING + PARAMETER_POSITION + SPACE_STRING
+ + COLON_STRING + SPACE_STRING + VALUE_ABSOLUTE
+ + SEMICOLON_STRING;
+
+ return style;
}
-// return true if parameter position was set to absolute
- public static boolean getAbsolute(Element sourceElement){
+ // return true if parameter position was set to absolute
+ public static boolean getAbsolute(Element sourceElement) {
String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
- if(style == null){
+ if (style == null) {
return false;
- }else{ // remove old sizes
- if(style.indexOf(VALUE_ABSOLUTE) >= 0)return true;
+ } else { // remove old sizes
+ if (style.indexOf(VALUE_ABSOLUTE) >= 0)
+ return true;
}
return false;
}
-// return true if parameter position was set to absolute
- public static boolean getAbsolute(String style){
- if(style == null){
+ // return true if parameter position was set to absolute
+ public static boolean getAbsolute(String style) {
+ if (style == null) {
return false;
- }else{ // remove old sizes
- if(style.indexOf(VALUE_ABSOLUTE) >= 0)return true;
+ } else { // remove old sizes
+ if (style.indexOf(VALUE_ABSOLUTE) >= 0)
+ return true;
}
return false;
}
-
- // return value of parameter described in sizeAttribute, for example "style.width"
- public static int getSizeFromStyle(Element sourceElement, String sizeAttribute){
+
+ // return value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static int getSizeFromStyle(Element sourceElement,
+ String sizeAttribute) {
int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0,dotPosition);
- String parameter = sizeAttribute.substring(dotPosition+1, sizeAttribute.length());
-
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
+
String style = sourceElement.getAttribute(attribute);
- if(style == null || EMPTY_STRING.equals(style)) return -1;
-
+ if (style == null || EMPTY_STRING.equals(style))
+ return -1;
+
int parameterPosition = style.indexOf(parameter);
- if(parameterPosition >= 0){
- int valuePosition = style.indexOf(COLON_STRING,parameterPosition);
- if(valuePosition >= 0){
- int endPosition = style.indexOf(PX_STRING,valuePosition);
- if(endPosition >= 0){
- return new Integer(style.substring(valuePosition+1, endPosition).trim()).intValue();
+ if (parameterPosition >= 0) {
+ int valuePosition = style.indexOf(COLON_STRING, parameterPosition);
+ if (valuePosition >= 0) {
+ int endPosition = style.indexOf(PX_STRING, valuePosition);
+ if (endPosition >= 0) {
+ return new Integer(style.substring(valuePosition + 1,
+ endPosition).trim()).intValue();
}
}
}
return -1;
}
- // return value of parameter described in sizeAttribute, for example "style.width"
- public static String getParameterFromStyle(Element sourceElement, String sizeAttribute){
+ // return value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static String getParameterFromStyle(Element sourceElement,
+ String sizeAttribute) {
int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0,dotPosition);
- String parameter = sizeAttribute.substring(dotPosition+1, sizeAttribute.length());
-
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
+
String style = sourceElement.getAttribute(attribute);
- if(style == null || EMPTY_STRING.equals(style)) return null;
-
+ if (style == null || EMPTY_STRING.equals(style))
+ return null;
+
int parameterPosition = style.indexOf(parameter);
- if(parameterPosition >= 0){
- int valuePosition = style.indexOf(COLON_STRING,parameterPosition);
- if(valuePosition >= 0){
- int endPosition = style.indexOf(PX_STRING,valuePosition);
- if(endPosition >= 0){
- return style.substring(valuePosition+1, endPosition).trim();
+ if (parameterPosition >= 0) {
+ int valuePosition = style.indexOf(COLON_STRING, parameterPosition);
+ if (valuePosition >= 0) {
+ int endPosition = style.indexOf(PX_STRING, valuePosition);
+ if (endPosition >= 0) {
+ return style.substring(valuePosition + 1, endPosition)
+ .trim();
}
}
}
return null;
}
-
- // sets value of parameter described in sizeAttribute, for example "style.width"
- public static void setSizeInStyle(Element sourceElement, String sizeAttribute, int size){
+
+ // sets value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static void setSizeInStyle(Element sourceElement,
+ String sizeAttribute, int size) {
int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0,dotPosition);
- String parameter = sizeAttribute.substring(dotPosition+1, sizeAttribute.length());
-
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
+
String style = sourceElement.getAttribute(attribute);
- if(style == null){
+ if (style == null) {
style = EMPTY_STRING;
- }else{ // remove old sizes
+ } else { // remove old sizes
style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
- if(style.length() > 0){
- if(!style.endsWith(SEMICOLON_STRING))style += SEMICOLON_STRING;
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
}
-
- style += SPACE_STRING+parameter+SPACE_STRING+COLON_STRING+SPACE_STRING+size+PX_STRING+SEMICOLON_STRING;
-
- sourceElement.setAttribute(attribute, style);
+
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + size + PX_STRING + SEMICOLON_STRING;
+
+ sourceElement.setAttribute(attribute, style);
}
- // sets value of parameter described in sizeAttribute, for example "style.width"
- public static void setParameterInStyle(Element sourceElement, String sizeAttribute, String value){
+ // sets value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static void setParameterInStyle(Element sourceElement,
+ String sizeAttribute, String value) {
int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0,dotPosition);
- String parameter = sizeAttribute.substring(dotPosition+1, sizeAttribute.length());
-
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
+
String style = sourceElement.getAttribute(attribute);
- if(style == null){
+ if (style == null) {
style = EMPTY_STRING;
- }else{ // remove old sizes
+ } else { // remove old sizes
style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
- if(style.length() > 0){
- if(!style.endsWith(SEMICOLON_STRING))style += SEMICOLON_STRING;
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
}
-
- style += SPACE_STRING+parameter+SPACE_STRING+COLON_STRING+SPACE_STRING+value+SEMICOLON_STRING;
-
- sourceElement.setAttribute(attribute, style);
+
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + value + SEMICOLON_STRING;
+
+ sourceElement.setAttribute(attribute, style);
}
-
- public static String setSizeInStyle(String style, String parameter, int size){
- if(style == null){
+
+ public static String setSizeInStyle(String style, String parameter, int size) {
+ if (style == null) {
style = EMPTY_STRING;
- }else{ // remove old sizes
+ } else { // remove old sizes
style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
- if(style.length() > 0){
- if(!style.endsWith(SEMICOLON_STRING))style += SEMICOLON_STRING;
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
}
-
- style += SPACE_STRING+parameter+SPACE_STRING+COLON_STRING+SPACE_STRING+size+PX_STRING+SEMICOLON_STRING;
-
- return style;
+
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + size + PX_STRING + SEMICOLON_STRING;
+
+ return style;
}
- public static String setParameterInStyle(String style, String parameter, String value){
- if(style == null){
+ public static String setParameterInStyle(String style, String parameter,
+ String value) {
+ if (style == null) {
style = EMPTY_STRING;
- }else{ // remove old sizes
+ } else { // remove old sizes
style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
- if(style.length() > 0){
- if(!style.endsWith(SEMICOLON_STRING))style += SEMICOLON_STRING;
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
}
-
- style += SPACE_STRING+parameter+SPACE_STRING+COLON_STRING+SPACE_STRING+value+SEMICOLON_STRING;
-
- return style;
+
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + value + SEMICOLON_STRING;
+
+ return style;
}
-
+
// selets parameter from atribute style
- public static void deleteFromStyle(Element sourceElement, String begin, String end){
+ public static void deleteFromStyle(Element sourceElement, String begin,
+ String end) {
String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
style = deleteFromString(style, begin, end);
sourceElement.setAttribute(ATTRIBUTE_STYLE, style);
}
-
+
// selets parameter from atribute style
- public static String deleteFromString(String data, String begin, String end){
+ public static String deleteFromString(String data, String begin, String end) {
int startPosition = data.indexOf(begin);
-
- if(startPosition < 0) return data;
-
+
+ if (startPosition < 0)
+ return data;
+
int endPosition = data.indexOf(end, startPosition);
-
+
String result = data.substring(0, startPosition).trim();
- if(endPosition > 0){
- result += data.substring(endPosition+1, data.length()).trim();
+ if (endPosition > 0) {
+ result += data.substring(endPosition + 1, data.length()).trim();
}
-
+
return result;
}
-
-
+
/**
*
* @param value
@@ -251,6 +287,34 @@
* The editor input
* @return format style string
*/
+ public static String addFullPathIntoBackgroundValue(String value,
+ IEditorInput input) {
+
+ if (value.indexOf(FILE_STR) != -1)
+ return value;
+
+ if (!new File(value).isAbsolute())
+ value = getFilePath(input, value);
+
+ value = FILE_PRTOCOL + value;
+ URL url = null;
+ try {
+ url = new URL(value);
+ } catch (MalformedURLException e) {
+ return value;
+ }
+
+ return url.toString();
+ }
+
+ /**
+ *
+ * @param value
+ * Css string
+ * @param input
+ * The editor input
+ * @return format style string
+ */
public static String addFullPathIntoURLValue(String value,
IEditorInput input) {
@@ -411,7 +475,7 @@
try {
url = new URL(pathCssAbsolute);
} catch (MalformedURLException e) {
-
+ return pathImgRelative;
}
pathCssAbsolute = url.toString();
while (j != -1) {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml 2007-09-26 08:34:58 UTC (rev 3802)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-html.xml 2007-09-26 08:41:28 UTC (rev 3803)
@@ -352,44 +352,20 @@
</vpe:template>
</vpe:tag>
- <vpe:tag name="body" case-sensitive="no">
- <vpe:if test="attrpresent('background')">
- <vpe:template children="yes" modify="yes">
- <div
- style="background-color:{@bgcolor};background-image:url({src(@background)});" />
- <vpe:dnd>
- <vpe:drop container="yes" />
- </vpe:dnd>
- <vpe:textFormating>
- <vpe:format type="BlockFormat" addParent="deny" addChildren="allow"
- handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
- <vpe:format type="BoldFormat" addParent="deny" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BoldFormatHandler" />
- <vpe:format type="ItalicFormat" addParent="deny" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.ItalicFormatHandler" />
- <vpe:format type="UnderlineFormat" addParent="deny" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.UnderlineFormatHandler" />
- </vpe:textFormating>
- </vpe:template>
- </vpe:if>
- <vpe:template children="yes" modify="yes">
- <div style="background-color:{@bgcolor};" />
+ <vpe:tag name="body" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.vpe.editor.template.HtmlBodyTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
<vpe:dnd>
- <vpe:drop container="yes" />
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no"></vpe:drop>
</vpe:dnd>
- <vpe:textFormating>
- <vpe:format type="BlockFormat" addParent="deny" addChildren="allow"
- handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BlockFormatHandler" />
- <vpe:format type="BoldFormat" addParent="deny" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.BoldFormatHandler" />
- <vpe:format type="ItalicFormat" addParent="deny" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.ItalicFormatHandler" />
- <vpe:format type="UnderlineFormat" addParent="deny" addChildren="allow" handler="org.jboss.tools.vpe.editor.toolbar.format.handler.UnderlineFormatHandler" />
- </vpe:textFormating>
</vpe:template>
</vpe:tag>
- <vpe:tag name="br" case-sensitive="no">
- <vpe:template children="no" modify="yes">
- <vpe:copy attrs="id,style,class,clear" />
- </vpe:template>
- </vpe:tag>
-
<vpe:tag name="button" case-sensitive="no">
<vpe:template children="yes" modify="no">
<vpe:copy attrs="id,style,class,value">
@@ -2293,7 +2269,7 @@
<vpe:tag name="table" case-sensitive="no">
<vpe:template children="yes" modify="yes">
<vpe:copy
- attrs="style,class,width,border,frame,rules,cellspacing,cellpadding,align,bgcolor" />
+ attrs="style,class,width,border,frame,rules,cellspacing,cellpadding,align,bgcolor,background" />
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
17 years, 3 months