JBoss Tools SVN: r2770 - in branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view: META-INF and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-07-31 11:16:51 -0400 (Tue, 31 Jul 2007)
New Revision: 2770
Added:
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.classpath
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.project
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/META-INF/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/META-INF/MANIFEST.MF
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/build.properties
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/icons/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/icons/sample.gif
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/plugin.xml
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/browser/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/browser/view/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/browser/view/views/
branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/browser/view/views/XulRunnerBrowserView.java
Log:
View for debugging of Browser
Added: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.classpath
===================================================================
--- branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.classpath (rev 0)
+++ branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.classpath 2007-07-31 15:16:51 UTC (rev 2770)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.project
===================================================================
--- branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.project (rev 0)
+++ branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/.project 2007-07-31 15:16:51 UTC (rev 2770)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.vpe.xulrunner.browser.view</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/META-INF/MANIFEST.MF (rev 0)
+++ branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/META-INF/MANIFEST.MF 2007-07-31 15:16:51 UTC (rev 2770)
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: View Plug-in
+Bundle-SymbolicName: org.jboss.tools.vpe.xulrunner.browser.view; singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Vendor: Red Hat, Inc.
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.jboss.tools.vpe.xulrunner.browser
Added: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/build.properties
===================================================================
--- branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/build.properties (rev 0)
+++ branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/build.properties 2007-07-31 15:16:51 UTC (rev 2770)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/
Added: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/icons/sample.gif
===================================================================
(Binary files differ)
Property changes on: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/icons/sample.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/plugin.xml
===================================================================
--- branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/plugin.xml (rev 0)
+++ branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/plugin.xml 2007-07-31 15:16:51 UTC (rev 2770)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ name="XULRunner"
+ id="org.jboss.tools.vpe.xulrunner">
+ </category>
+ <view
+ name="XULRunner Browser"
+ icon="icons/sample.gif"
+ category="org.jboss.tools.vpe.xulrunner"
+ class="org.jboss.tools.vpe.xulrunner.browser.view.views.XulRunnerBrowserView"
+ id="org.jboss.tools.vpe.xulrunner.browser.view.views.XulRunnerBrowserView">
+ </view>
+ </extension>
+</plugin>
Added: branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/browser/view/views/XulRunnerBrowserView.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/browser/view/views/XulRunnerBrowserView.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/xul_spike/org.jboss.tools.vpe.xulrunner.browser.view/src/org/jboss/tools/vpe/xulrunner/browser/view/views/XulRunnerBrowserView.java 2007-07-31 15:16:51 UTC (rev 2770)
@@ -0,0 +1,243 @@
+package org.jboss.tools.vpe.xulrunner.browser.view.views;
+
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+import org.jboss.tools.vpe.xulrunner.XulRunnerException;
+import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser;
+
+
+/**
+* This sample class demonstrates how to plug-in a new
+* workbench view. The view shows data obtained from the
+* model. The sample creates a dummy model on the fly,
+* but a real implementation would connect to the model
+* available either in this or another plug-in (e.g. the workspace).
+* The view is connected to the model using a content provider.
+* <p>
+* The view uses a label provider to define how model
+* objects should be presented in the view. Each
+* view can present the same model objects using
+* different labels and icons, if needed. Alternatively,
+* a single label provider can be shared between views
+* in order to ensure that objects of the same type are
+* presented in the same way everywhere.
+* <p>
+*/
+
+public class XulRunnerBrowserView extends ViewPart {
+ private XulRunnerBrowser browser;
+ private Combo comboLocation;
+ private Action action1;
+ private Action action2;
+
+ private final String INIT_URL = "about:blank";
+ /*
+ * The content provider class is responsible for
+ * providing objects to the view. It can wrap
+ * existing objects in adapters or simply return
+ * objects as-is. These objects may be sensitive
+ * to the current input of the view, or ignore
+ * it and always show the same content
+ * (like Task List, for example).
+ */
+ class ViewContentProvider implements IStructuredContentProvider {
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public Object[] getElements(Object parent) {
+ return new String[] { "One", "Two", "Three" };
+ }
+ }
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object obj, int index) {
+ return getText(obj);
+ }
+ public Image getColumnImage(Object obj, int index) {
+ return getImage(obj);
+ }
+ public Image getImage(Object obj) {
+ return PlatformUI.getWorkbench().
+ getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
+ }
+ }
+
+ /**
+ * The constructor.
+ */
+ public XulRunnerBrowserView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 2;
+ layout.verticalSpacing = 0;
+ parent.setLayout(layout);
+ createToolBar(parent);
+ try {
+ browser = new XulRunnerBrowser (parent);
+ browser.setURL(INIT_URL);
+ browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ makeActions();
+ contributeToActionBars();
+ } catch (XulRunnerException xre) {
+ // TODO Sergey Vasilyev add to common loger
+ xre.printStackTrace();
+ }
+ }
+
+ private void createToolBar(Composite parent) {
+ GridLayout layout;
+ Composite compToolBar = new Composite(parent, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 2;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 2;
+ layout.verticalSpacing = 0;
+ layout.numColumns = 3;
+ compToolBar.setLayout(layout);
+ compToolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL|GridData.GRAB_HORIZONTAL));
+ ToolBar toolBar = new ToolBar(compToolBar, SWT.HORIZONTAL | SWT.FLAT);
+ ToolItem toolItem = new ToolItem(toolBar,SWT.PUSH);
+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_BACK));
+ toolItem.setToolTipText("Back to the previous page");
+ toolItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.goBack();
+ }
+ });
+ toolItem = new ToolItem(toolBar,SWT.PUSH);
+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_FORWARD));
+ toolItem.setToolTipText("Forward to the next page");
+ toolItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.goForward();
+ }
+ });
+
+ toolItem = new ToolItem(toolBar, SWT.SEPARATOR);
+ toolItem = new ToolItem(toolBar,SWT.PUSH);
+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_UNDO));
+ toolItem.setToolTipText("Refresh the current page");
+ toolItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.reload();
+ }
+ });
+ toolItem = new ToolItem(toolBar,SWT.PUSH);
+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
+ toolItem.setToolTipText("Stop loading the current page");
+ toolItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.stop();
+ }
+ });
+
+ Composite compLocationBar = new Composite(compToolBar, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 2;
+ layout.verticalSpacing = 0;
+ layout.numColumns = 2;
+ compLocationBar.setLayout(layout);
+ compLocationBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ comboLocation = new Combo(compLocationBar, SWT.DROP_DOWN);
+ comboLocation.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ toolBar = new ToolBar(compLocationBar, SWT.HORIZONTAL|SWT.FLAT);
+ toolItem = new ToolItem(toolBar, SWT.PUSH);
+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_NEW_WIZARD));
+ toolItem.setToolTipText("Go to the URL");
+ toolItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.stop();
+ String url = comboLocation.getText();
+ browser.setURL(url);
+ }
+ });
+ toolBar = new ToolBar(compToolBar, SWT.HORIZONTAL|SWT.FLAT);
+ toolItem = new ToolItem(toolBar, SWT.PUSH);
+ toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_NEW_WIZARD));
+ toolItem.setToolTipText("Go to Red Hat");
+ toolItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ browser.stop();
+ browser.setURL("http://www.redhat.com/");
+ }
+ });
+ }
+
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ }
+
+ private void makeActions() {
+ action1 = new Action() {
+ public void run() {
+ showMessage("Action 1 executed");
+ }
+ };
+ action1.setText("Action 1");
+ action1.setToolTipText("Action 1 tooltip");
+ action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ action2 = new Action() {
+ public void run() {
+ showMessage("Action 2 executed");
+ }
+ };
+ action2.setText("Action 2");
+ action2.setToolTipText("Action 2 tooltip");
+ action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ }
+
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ browser.getShell(),
+ "XulRunner Browser View",
+ message);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ browser.setFocus();
+ }
+}
\ No newline at end of file
17 years, 5 months
JBoss Tools SVN: r2767 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2007-07-31 11:13:55 -0400 (Tue, 31 Jul 2007)
New Revision: 2767
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ComponentShapeEditPart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java
Log:
http://jira.jboss.com/jira/browse/EXIN-365
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ComponentShapeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ComponentShapeEditPart.java 2007-07-31 15:12:53 UTC (rev 2766)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ComponentShapeEditPart.java 2007-07-31 15:13:55 UTC (rev 2767)
@@ -59,17 +59,8 @@
public void activate() {
super.activate();
if(this.getClass().equals(ComponentShapeEditPart.class) && !((ExpandeableShape)getModel()).isReferenceVisible()){
+ ((ComponentShape)getModel()).refHide = true;
((ComponentShape)getModel()).refreshChildsHiden(((OrmDiagram)getViewer().getContents().getModel()));
- /*int i = figure.getPreferredSize().width;
- ((ComponentFigure)figure).setChildsHiden(true);
-
- figure.setSize(i,-1);
-
- referenceList.add((OrmShape)getCastedModel().getParent());
- refreshReference((ExpandeableShape)getCastedModel(), ((ExpandeableShape)getCastedModel()).isReferenceVisible());
-
-
- ((OrmShape)getParent().getModel()).refreshReference();*/
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java 2007-07-31 15:12:53 UTC (rev 2766)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java 2007-07-31 15:13:55 UTC (rev 2767)
@@ -58,8 +58,6 @@
if(this.getClass().equals(ExpandeableShapeEditPart.class) && !((ExpandeableShape)getModel()).isReferenceVisible()){
((ExpandeableShape)getModel()).refHide = true;
((ExpandeableShape)getModel()).refreshReferences(getViewer().getContents().getModel());
- //refreshReferences((Shape)getCastedModel(), ((ExpandeableShape)getCastedModel()).isReferenceVisible());
- //((TitleLabel)getFigure()).setHidden(true);
}
}
17 years, 5 months
JBoss Tools SVN: r2766 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser: META-INF and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-07-31 11:12:53 -0400 (Tue, 31 Jul 2007)
New Revision: 2766
Added:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.classpath
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.project
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/META-INF/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/META-INF/MANIFEST.MF
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/build.properties
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
Log:
Browser founded on XulRunner
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.classpath
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.classpath (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.classpath 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.project
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.project (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/.project 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.vpe.xulrunner.browser</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/META-INF/MANIFEST.MF (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/META-INF/MANIFEST.MF 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Browser (XULRunner) Plug-in
+Bundle-SymbolicName: org.jboss.tools.vpe.xulrunner.browser;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.vpe.xulrunner.BrowserPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.vpe.xulrunner;bundle-version="1.8.1.3",
+ org.mozilla.xpcom
+Eclipse-LazyStart: true
+Export-Package: org.jboss.tools.vpe.xulrunner;uses:="org.eclipse.jface.resource,org.eclipse.ui.plugin,org.osgi.framework",
+ org.jboss.tools.vpe.xulrunner.browser;uses:="org.mozilla.interfaces,org.eclipse.swt.widgets,org.mozilla.xpcom"
+Bundle-ClassPath: .
+Bundle-Vendor: Red Hat, Inc.
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/build.properties
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/build.properties (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/build.properties 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/BrowserPlugin.java 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,61 @@
+package org.jboss.tools.vpe.xulrunner;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class BrowserPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.vpe.xulrunner.browser";
+
+ // The shared instance
+ private static BrowserPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public BrowserPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static BrowserPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/XulRunnerException.java 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,22 @@
+package org.jboss.tools.vpe.xulrunner;
+
+public class XulRunnerException extends Exception {
+ private static final long serialVersionUID = -7973228286977485907L;
+
+ public XulRunnerException() {
+ super();
+ }
+
+ public XulRunnerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public XulRunnerException(String message) {
+ super(message);
+ }
+
+ public XulRunnerException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/AppFileLocProvider.java 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,49 @@
+package org.jboss.tools.vpe.xulrunner.browser;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.vpe.xulrunner.BrowserPlugin;
+import org.mozilla.xpcom.IAppFileLocProvider;
+
+public class AppFileLocProvider implements IAppFileLocProvider {
+ private File xulRunnerPath;
+ private File userDataPath;
+
+ private final String PLUGINS_DIRECTORY = "plugins";
+ private final String HISTORY_FILE = "history.dat";
+ private final String COMPREG_FILE = "compreg.dat";
+ private final String XPTI_FILE = "xpti.dat";
+
+ public AppFileLocProvider(File xulRunnerPath) {
+ this.xulRunnerPath = xulRunnerPath;
+ this.userDataPath = Platform.getLocation().append(".metadata/.plugins")
+ .append(BrowserPlugin.PLUGIN_ID)
+ .append("xulrunner").toFile();
+ }
+
+ public File getFile(String prop, boolean[] persistent) {
+ persistent[0] = false;
+
+ if ("ProfD".equals(prop)) {
+ return userDataPath;
+ } else if ("UHist".equals(prop)) {
+ return new File(userDataPath, HISTORY_FILE);
+ } else if ("ComRegF".equals(prop)) {
+ return new File(userDataPath, COMPREG_FILE);
+ } else if ("XptiRegF".equals(prop)) {
+ return new File(userDataPath, XPTI_FILE);
+ }
+
+ return null;
+ }
+
+ public File[] getFiles(String prop) {
+ if("APluginsDL".equals(prop)) {
+ return new File[] {new File(xulRunnerPath, PLUGINS_DIRECTORY)};
+ }
+
+ return null;
+ }
+
+}
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/WindowCreator.java 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,32 @@
+package org.jboss.tools.vpe.xulrunner.browser;
+
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.interfaces.nsIURI;
+import org.mozilla.interfaces.nsIWebBrowserChrome;
+import org.mozilla.interfaces.nsIWindowCreator;
+import org.mozilla.interfaces.nsIWindowCreator2;
+import org.mozilla.xpcom.Mozilla;
+
+public class WindowCreator implements nsIWindowCreator, nsIWindowCreator2 {
+
+ public nsIWebBrowserChrome createChromeWindow(nsIWebBrowserChrome arg0,
+ long arg1) {
+ // TODO Sergey Vasilyev implement
+ System.out.println("WindowCreator:createChromeWindow(" + arg0 +", " + arg1 + ")");
+ return arg0;
+ }
+
+ public nsISupports queryInterface(String arg0) {
+ // TODO Auto-generated method stub
+ return Mozilla.queryInterface(this, arg0);
+ }
+
+ public nsIWebBrowserChrome createChromeWindow2(nsIWebBrowserChrome arg0,
+ long arg1, long arg2, nsIURI arg3, boolean[] arg4) {
+ // TODO Sergey Vasilyev implement
+ System.out.println("WindowCreator:createChromeWindow2(" + arg0 +", "
+ + arg1 + ", "+ arg2 + ", "+ (arg3 == null ? "null" : arg3.getSpec()) +")");
+ return arg0;
+ }
+
+}
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe.xulrunner.browser/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2007-07-31 15:12:53 UTC (rev 2766)
@@ -0,0 +1,279 @@
+package org.jboss.tools.vpe.xulrunner.browser;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.jboss.tools.vpe.xulrunner.XulRunnerException;
+import org.mozilla.interfaces.nsIBaseWindow;
+import org.mozilla.interfaces.nsIComponentManager;
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.interfaces.nsIWebBrowser;
+import org.mozilla.interfaces.nsIWebBrowserChrome;
+import org.mozilla.interfaces.nsIWebBrowserFocus;
+import org.mozilla.interfaces.nsIWebNavigation;
+import org.mozilla.xpcom.Mozilla;
+import org.osgi.framework.Bundle;
+
+public class XulRunnerBrowser extends Composite implements nsIWebBrowserChrome {
+ private static String xulRunnerBundle = "org.jboss.tools.vpe.xulrunner"; //$NON-NLS-1$
+
+ // TEMPORARY CODE (@see org.eclipse.swt.browser.Mozilla)
+ static final String XULRUNNER_INITIALIZED = "org.eclipse.swt.browser.XULRunnerInitialized"; //$NON-NLS-1$
+ static final String XULRUNNER_PATH = "org.eclipse.swt.browser.XULRunnerPath"; //$NON-NLS-1$
+
+ private Mozilla mozilla = null;
+ private nsIWebBrowser webBrowser = null;
+ private long chrome_flags = nsIWebBrowserChrome.CHROME_ALL;
+
+ private boolean busyResizeFlag = false;
+
+ public XulRunnerBrowser(Composite parent) throws XulRunnerException {
+ super(parent, SWT.NONE);
+
+ mozilla = Mozilla.getInstance();
+
+ String xulRunnerPath = getXulRunnerPath();
+
+ Boolean isXulRunnerInitialized = "true".equals(System.getProperty(XULRUNNER_INITIALIZED));
+ if (!isXulRunnerInitialized) {
+ File file = new File(xulRunnerPath);
+ mozilla.initialize(file);
+ mozilla.initEmbedding(file, file, new AppFileLocProvider(file));
+ System.setProperty(XULRUNNER_INITIALIZED, "true");
+ }
+
+ nsIComponentManager componentManager = mozilla.getComponentManager();
+ webBrowser = (nsIWebBrowser) componentManager.createInstance("F1EAC761-87E9-11d3-AF80-00A024FFC08C", null, nsIWebBrowser.NS_IWEBBROWSER_IID); //$NON-NLS-1$
+ webBrowser.setContainerWindow(this);
+ nsIBaseWindow baseWindow = (nsIBaseWindow) webBrowser.queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID);
+
+ Rectangle rect = getClientArea();
+ if (rect.isEmpty()) {
+ rect.height = 1;
+ rect.width = 1;
+ }
+ baseWindow.initWindow(handle, 0, 0, 0, rect.height, rect.width);
+ baseWindow.create();
+ baseWindow.setVisibility(true);
+
+ Listener listener = new Listener(){
+ public void handleEvent (Event event) {
+ switch(event.type) {
+ case SWT.Dispose:
+ onDispose();
+ break;
+ case SWT.Activate:
+ case SWT.FocusIn:
+ onFocusGained();
+ break;
+ case SWT.Deactivate:
+ if (XulRunnerBrowser.this == event.display.getFocusControl()) {
+ onFocusLost();
+ }
+ break;
+ case SWT.Resize:
+ case SWT.Show:
+ /*
+ * Feature on GTK Mozilla. Mozilla does not show up when
+ * its container (a GTK fixed handle) is made visible
+ * after having been hidden. The workaround is to reset
+ * its size after the container has been made visible.
+ */
+ if (!busyResizeFlag) {
+ busyResizeFlag = true;
+ event.display.asyncExec(new Runnable() {
+ public void run() {
+ if (XulRunnerBrowser.this.isDisposed()) return;
+ onResize();
+ busyResizeFlag = false;
+ }
+ });
+ }
+ break;
+ case SWT.KeyDown:
+ onKeyDown();
+ break;
+ }
+ }
+ };
+
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.Resize, listener);
+ addListener(SWT.FocusIn, listener);
+ addListener(SWT.KeyDown, listener);
+ addListener(SWT.Activate, listener);
+ addListener(SWT.Deactivate, listener);
+ addListener(SWT.Show, listener);
+ }
+
+ private void onDispose() {
+ nsIBaseWindow baseWindow = (nsIBaseWindow) webBrowser.queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID);
+ baseWindow.destroy();
+ }
+
+ private void onFocusGained() {
+ nsIWebBrowserFocus webBrowserFocus = (nsIWebBrowserFocus) webBrowser.queryInterface(nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID);
+ webBrowserFocus.activate();
+ }
+
+ private void onFocusLost() {
+ nsIWebBrowserFocus webBrowserFocus = (nsIWebBrowserFocus) webBrowser.queryInterface(nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID);
+ webBrowserFocus.deactivate();
+ }
+
+ private void onResize() {
+ nsIBaseWindow baseWindow = (nsIBaseWindow) webBrowser.queryInterface(nsIBaseWindow.NS_IBASEWINDOW_IID);
+
+ Rectangle rect = getClientArea();
+ if (rect.isEmpty()) {
+ rect.height = 1;
+ rect.width = 1;
+ }
+
+ baseWindow.setPositionAndSize(rect.x, rect.y, rect.width, rect.height, true);
+ }
+
+ private void onKeyDown() {
+ System.out.println("XulRunnerBrowser.onKeyDown()");
+ }
+
+ public static String getXulRunnerBundle() {
+ return xulRunnerBundle;
+ }
+
+ public static void setXulRunnerBundle(String xulRunnerBundle) {
+ XulRunnerBrowser.xulRunnerBundle = xulRunnerBundle;
+ }
+
+ private String getXulRunnerPath() throws XulRunnerException {
+ String xulRunnerPath = System.getProperty(XULRUNNER_PATH);
+ if (xulRunnerPath == null) {
+
+ Bundle fragment = Platform.getBundle(getXulRunnerBundle());
+ if (fragment == null) {
+ throw new XulRunnerException("Bundle " + getXulRunnerBundle() + " is not found.");
+ }
+
+ URL url = fragment.getEntry("/xulrunner");
+ if (url == null) {
+ throw new XulRunnerException("Bundle " + getXulRunnerBundle() + " doesn't contain /xulrunner");
+ }
+
+
+ try {
+ URL url1 = FileLocator.resolve(url);
+ File file = new File(FileLocator.toFileURL(url1).getFile());
+ xulRunnerPath = file.getAbsolutePath();
+ System.setProperty(XULRUNNER_PATH, xulRunnerPath);
+ } catch (IOException ioe) {
+ throw new XulRunnerException(ioe);
+ }
+ }
+
+ return xulRunnerPath;
+ }
+
+ public void setURL(String url) {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.loadURI(url, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
+ }
+
+ public String getURL() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ return webNavigation.getCurrentURI().getSpec();
+ }
+
+ public void stop() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.stop(nsIWebNavigation.STOP_ALL);
+ }
+
+ public void reload() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.reload(nsIWebNavigation.LOAD_FLAGS_NONE);
+ }
+
+ public void goBack() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.goBack();
+ }
+
+ public void goForward() {
+ nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
+ webNavigation.goForward();
+ }
+
+ /*
+ * nsISupports
+ *
+ * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ */
+ public nsISupports queryInterface(String arg0) {
+ return Mozilla.queryInterface(this, arg0);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.mozilla.interfaces.nsIWebBrowserChrome#destroyBrowserWindow()
+ */
+ public void destroyBrowserWindow() {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ public void exitModalEventLoop(long arg0) {
+ throw new RuntimeException("Not implemented");
+ }
+
+ public long getChromeFlags() {
+ return chrome_flags;
+ }
+
+ public nsIWebBrowser getWebBrowser() {
+ return webBrowser;
+ }
+
+ public boolean isWindowModal() {
+ // TODO Sergey Vasilyev implement
+ return false;
+ }
+
+ public void setChromeFlags(long arg0) {
+ chrome_flags = arg0;
+ }
+
+ public void setStatus(long arg0, String arg1) {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ public void setWebBrowser(nsIWebBrowser arg0) {
+ webBrowser = arg0;
+ }
+
+ public void showAsModal() {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ public void sizeBrowserTo(int arg0, int arg1) {
+ // TODO Sergey Vasilyev implement
+ throw new RuntimeException("Not implemented");
+ }
+
+ protected void finalize() throws Throwable {
+ if (mozilla != null) {
+ mozilla.termEmbedding();
+ }
+
+ super.finalize();
+ }
+}
17 years, 5 months
JBoss Tools SVN: r2760 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: mozilla and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-07-31 10:05:33 -0400 (Tue, 31 Jul 2007)
New Revision: 2760
Added:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
Log:
the merge with HEAD revision
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-07-31 14:05:33 UTC (rev 2760)
@@ -0,0 +1,1793 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.eclipse.wst.xml.core.internal.document.NodeImpl;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
+import org.jboss.tools.vpe.VpeDebug;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.css.CSSReferenceList;
+import org.jboss.tools.vpe.editor.css.ResourceReference;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeDefaultPseudoContentCreator;
+import org.jboss.tools.vpe.editor.template.VpeTagDescription;
+import org.jboss.tools.vpe.editor.template.VpeTemplate;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
+import org.jboss.tools.vpe.editor.util.MozillaSupports;
+import org.jboss.tools.vpe.editor.util.TextUtil;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
+import org.jboss.tools.vpe.mozilla.browser.MozillaBrowser;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.VpeDnD;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMMouseEvent;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMNode;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMRange;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * class VpePreviewDomBuilder for create DOM-tree for Mozilla preview
+ * @author A. Yukhovich
+ */
+public class VpePreviewDomBuilder extends VpeVisualDomBuilder {
+ private static final String PSEUDO_ELEMENT = "br";
+ private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element";
+ private static final String INIT_ELEMENT_ATTR = "vpe:init-element";
+ private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS";
+ private static final String COMMENT_STYLE = "font-style:italic; color:green";
+ private static final String COMMENT_PREFIX = "";
+ private static final String COMMENT_SUFFIX = "";
+ private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element";
+ private static final int DRAG_AREA_WIDTH = 10;
+ private static final int DRAG_AREA_HEIGHT = 10;
+ private static final String ATTR_XMLNS = "xmlns";
+
+ private MozillaEditor visualEditor;
+ private MozillaBrowser browser;
+ private Document visualDocument;
+ private Element visualContentArea;
+ private VpePageContext pageContext;
+ private VpeDnD dnd;
+ private Node headNode;
+ private List includeStack;
+ boolean rebuildFlag = false;
+
+ private static final String EMPTY_STRING = "";
+
+ private static final String TAG_BODY = "body";
+ private static final String TAG_HEAD = "head";
+ private static final String TAG_HTML = "html";
+ private static final String TAG_LINK = "link";
+ private static final String TAG_STYLE = "style";
+ private static final String TAG_TABLE = "table";
+ private static final String TAG_TBODY = "tbody";
+ private static final String TAG_THEAD = "thead";
+ private static final String TAG_TR = "tr";
+ private static final String TAG_TD = "td";
+ private static final String TAG_COL = "col";
+ private static final String TAG_COLS = "cols";
+ private static final String TAG_COLGROUP = "colgroup";
+ private static final String TAG_BR = "br";
+ private static final String TAG_LI = "li";
+ private static final String TAG_IMG = "img";
+ private static final String TAG_DIV = "div";
+ private static final String TAG_SPAN = "span";
+ private static final String TAG_P = "p";
+
+ 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";
+
+ /**
+ *
+ * @param domMapping
+ * @param sorceAdapter
+ * @param templateManager
+ * @param visualEditor
+ * @param pageContext
+ */
+ public VpePreviewDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter, VpeTemplateManager templateManager, MozillaEditor visualEditor, VpePageContext pageContext) {
+ super(domMapping, sorceAdapter, templateManager, visualEditor, pageContext);
+ this.visualEditor = visualEditor;
+ browser = (MozillaBrowser)visualEditor.getControl();
+ this.visualDocument = visualEditor.getDomDocument();
+ this.visualContentArea = visualEditor.getContentArea();
+ this.dnd = visualEditor.getLocalDnD();
+ this.pageContext = pageContext;
+ this.headNode = visualEditor.getHeadNode();
+ }
+
+ /**
+ *
+ */
+ public void buildDom(Document sourceDocument) {
+ includeStack = new ArrayList();
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput)input).getFile();
+ if (file != null) {
+ includeStack.add(new VpeIncludeInfo(null, file, pageContext.getSourceBuilder().getSourceDocument()));
+ }
+ }
+ pageContext.refreshConnector();
+ pageContext.installIncludeElements();
+ addChildren(null, sourceDocument, visualContentArea);
+ registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
+ }
+
+ /**
+ *
+ */
+ public void rebuildDom(Document sourceDocument) {
+ cleanHead();
+ domMapping.clear(visualContentArea);
+ pageContext.clearAll();
+ refreshExternalLinks();
+ pageContext.getBundle().refreshRegisteredBundles();
+
+ NodeList children = visualContentArea.getChildNodes();
+ int len = children.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node child = children.item(i);
+ Node visualRemovedNode = visualContentArea.removeChild(child);
+ MozillaSupports.release(child, visualRemovedNode);
+ }
+ MozillaSupports.release(children);
+
+ if (sourceDocument != null) {
+ buildDom(sourceDocument);
+ }
+
+ rebuildFlag = true;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @param visualNextNode
+ * @param visualContainer
+ * @return
+ */
+ private boolean addNode(Node sourceNode, Node visualNextNode, Node visualContainer) {
+ Node visualNewNode = createNode(sourceNode, visualContainer);
+ if (visualNewNode != null) {
+ Node visualAddedNode = visualNextNode == null ?
+ visualContainer.appendChild(visualNewNode) :
+ visualContainer.insertBefore(visualNewNode, visualNextNode);
+ MozillaSupports.release(visualAddedNode);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @param visualOldContainer
+ * @return
+ */
+ private Node createNode(Node sourceNode, Node visualOldContainer) {
+ boolean registerFlag = isCurrentMainDocument();
+ switch (sourceNode.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Map xmlnsMap = createXmlns((Element)sourceNode);
+ Set ifDependencySet = new HashSet();
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ VpeTemplate template = templateManager.getTemplate(pageContext, (Element)sourceNode, ifDependencySet);
+ VpeCreationData creationData;
+
+ if ( template.isHaveVisualPreview() ) {
+ creationData = template.create(pageContext, sourceNode, visualDocument);
+ } else {
+ Element tempHTMLElement = visualDocument.createElement(TAG_DIV);
+ creationData = new VpeCreationData(tempHTMLElement);
+ }
+
+ pageContext.setCurrentVisualNode(null);
+ Element visualNewElement;
+ visualNewElement = (Element)creationData.getNode();
+ setTooltip((Element)sourceNode, visualNewElement);
+
+ if (!isCurrentMainDocument() && visualNewElement != null) {
+ setReadOnlyElement(visualNewElement);
+ }
+
+ if (template.isChildren()) {
+ List childrenInfoList = creationData.getChildrenInfoList();
+ if (childrenInfoList == null) {
+ addChildren(template, sourceNode, visualNewElement != null ? visualNewElement : visualOldContainer);
+ } else {
+ addChildren(template, sourceNode, visualOldContainer, childrenInfoList);
+ }
+ }
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ template.validate(pageContext, (Element)sourceNode, visualDocument, creationData);
+ pageContext.setCurrentVisualNode(null);
+ return visualNewElement;
+ case Node.TEXT_NODE:
+ String sourceText = sourceNode.getNodeValue();
+ if (sourceText.trim().length() <= 0) {
+ registerNodes(new VpeNodeMapping(sourceNode, null));
+ return null;
+ }
+ String visualText = TextUtil.visualText(sourceText);
+ Node 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())) {
+ return null;
+ }
+ Element visualNewComment = createComment(sourceNode);
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
+ }
+ return visualNewComment;
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private Element createComment(Node sourceNode) {
+ Element div = visualDocument.createElement(TAG_DIV);
+ div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
+ String value = COMMENT_PREFIX + sourceNode.getNodeValue() + COMMENT_SUFFIX;
+ Node text = visualDocument.createTextNode(value);
+ div.appendChild(text);
+ return div;
+ }
+
+ /**
+ *
+ * @param containerTemplate
+ * @param sourceContainer
+ * @param visualContainer
+ */
+ private void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualContainer) {
+ NodeList sourceNodes = sourceContainer.getChildNodes();
+ int len = sourceNodes.getLength();
+ int childrenCount = 0;
+ for (int i = 0; i < len; i++) {
+ Node sourceNode = sourceNodes.item(i);
+ if (addNode(sourceNode, null, visualContainer)) {
+ childrenCount++;
+ }
+ }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer, visualContainer);
+ }
+ }
+
+ /**
+ *
+ * @param containerTemplate
+ * @param sourceContainer
+ * @param visualOldContainer
+ * @param childrenInfoList
+ */
+ private void addChildren(VpeTemplate containerTemplate, Node sourceContainer, Node visualOldContainer, List childrenInfoList) {
+ for (int i = 0; i < childrenInfoList.size(); i++) {
+ VpeChildrenInfo info = (VpeChildrenInfo)childrenInfoList.get(i);
+ Node visualParent = info.getVisualParent();
+ if (visualParent == null) visualParent = visualOldContainer;
+ List sourceChildren = info.getSourceChildren();
+ int childrenCount = 0;
+ if (sourceChildren != null) {
+ for (int j = 0; j < sourceChildren.size(); j++) {
+ if (addNode((Node)sourceChildren.get(j), null, visualParent)) {
+ childrenCount++;
+ }
+ }
+ }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer, visualParent);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public Node addStyleNodeToHead(String styleText){
+ Node newStyle = visualDocument.createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+
+ if(styleText != null){
+ Node newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ MozillaSupports.release(newText);
+ }
+ headNode.appendChild(newStyle);
+ return newStyle;
+ }
+
+ /**
+ *
+ */
+ public Node replaceStyleNodeToHead(Node oldStyleNode, String styleText){
+ Node newStyle = visualDocument.createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+
+ if(styleText != null){
+ Node newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ MozillaSupports.release(newText);
+ }
+
+ headNode.replaceChild(newStyle, oldStyleNode);
+ MozillaSupports.release(oldStyleNode);
+ return newStyle;
+ }
+
+ /**
+ *
+ */
+ public void removeStyleNodeFromHead(Node oldStyleNode){
+ headNode.removeChild(oldStyleNode);
+ MozillaSupports.release(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);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ void removeExternalLinks() {
+ NodeList childs = headNode.getChildNodes();
+ int length = childs.getLength();
+ for (int i = length - 1; i >= 0; i--) {
+ Node node = childs.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ boolean isLink = false;
+ boolean isStyle = false;
+ if((isLink = TAG_LINK.equalsIgnoreCase(node.getNodeName()))
+ || (isStyle = TAG_STYLE.equalsIgnoreCase(node.getNodeName()))) {
+ Element element = (Element)node;
+ if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE.equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
+ && YES_STRING.equalsIgnoreCase(element.getAttribute("ext"))) {
+ headNode.removeChild(node);
+ }
+ }
+ }
+ MozillaSupports.release(node);
+ }
+ MozillaSupports.release(childs);
+ }
+
+ /**
+ *
+ */
+ void refreshExternalLinks() {
+ removeExternalLinks();
+ addExternalLinks();
+ }
+
+ /**
+ *
+ */
+ void resetPseudoElement(Node visualNode) {
+ if (visualNode != null) {
+ Node visualParent = visualNode.getParentNode();
+ if (visualParent != null) {
+ PseudoInfo info = getPseudoInfo(visualParent);
+ if (info.pseudoNode == null && !info.isElements) {
+ addPseudoElementImpl(visualParent);
+ } else if (info.pseudoNode != null && info.isElements) {
+ visualParent.removeChild(info.pseudoNode);
+ MozillaSupports.release(info.pseudoNode);
+ }
+ MozillaSupports.release(visualParent);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param visualParent
+ * @return
+ */
+ private PseudoInfo getPseudoInfo(Node visualParent) {
+ Node pseudoNode = null;
+ boolean isElements = false;
+
+ if (visualParent == null) return new PseudoInfo();
+ NodeList visualNodes = visualParent.getChildNodes();
+ if (visualNodes == null) return new PseudoInfo();
+
+ int length = visualNodes.getLength();
+ for (int i = 0; i < length; i++) {
+ Node visualNode = visualNodes.item(i);
+ if (pseudoNode == null && isPseudoElement(visualNode)) {
+ pseudoNode = visualNode;
+ } else if (!isEmptyText(visualNode)) {
+ isElements = true;
+ }
+ if (visualNode != pseudoNode) {
+ MozillaSupports.release(visualNode);
+ }
+ if (pseudoNode != null && isElements) {
+ break;
+ }
+ }
+ MozillaSupports.release(visualNodes);
+ return new PseudoInfo(pseudoNode, isElements);
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ static boolean isInitElement(Node visualNode) {
+ if (visualNode == null) return false;
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) return false;
+ if (YES_STRING.equalsIgnoreCase(((Element)visualNode).getAttribute(INIT_ELEMENT_ATTR))) return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ static boolean isPseudoElement(Node visualNode) {
+ if (visualNode == null) return false;
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) return false;
+ if (YES_STRING.equalsIgnoreCase(((Element)visualNode).getAttribute(PSEUDO_ELEMENT_ATTR))) return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param containerTemplate
+ * @param sourceContainer
+ * @param visualContainer
+ */
+ private void setPseudoContent(VpeTemplate containerTemplate, Node sourceContainer, Node visualContainer) {
+ if (containerTemplate != null) {
+ containerTemplate.setPseudoContent(pageContext, sourceContainer, visualContainer, visualDocument);
+ } else {
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(pageContext, sourceContainer, visualContainer, visualDocument);
+ }
+ }
+
+ /**
+ *
+ * @param visualParent
+ */
+ private void addPseudoElementImpl(Node visualParent) {
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent.getNodeName())) {
+ if (VpeDebug.visualAddPseudoElement) {
+ System.out.println("-------------------- addPseudoElement: " + visualParent.getNodeName());
+ }
+ Element visualPseudoElement = visualDocument.createElement(PSEUDO_ELEMENT);
+ visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, "yes");
+ visualParent.appendChild(visualPseudoElement);
+ MozillaSupports.release(visualPseudoElement);
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean isEmptyElement(Node visualParent) {
+ boolean empty = false;
+ NodeList visualNodes = visualParent.getChildNodes();
+ int len = visualNodes.getLength();
+ if (len == 0) {
+ empty = true;
+ } else if (len == 1) {
+ Node visualNode = visualNodes.item(0);
+ if (isEmptyText(visualNode)) {
+ empty = true;
+ }
+ MozillaSupports.release(visualNode);
+ }
+ MozillaSupports.release(visualNodes);
+ return empty;
+ }
+
+ /**
+ *
+ */
+ public boolean isEmptyDocument() {
+ boolean empty = false;
+ NodeList visualNodes = visualContentArea.getChildNodes();
+ int len = visualNodes.getLength();
+ if (len == 0) {
+ empty = true;
+ } else if (len == 1) {
+ Node visualNode = visualNodes.item(0);
+ if (isEmptyText(visualNode) || isPseudoElement(visualNode)) {
+ empty = true;
+ }
+ MozillaSupports.release(visualNode);
+ }
+ MozillaSupports.release(visualNodes);
+ return empty;
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ private boolean isEmptyText(Node visualNode) {
+ if (visualNode == null) return false;
+ if (visualNode.getNodeType() != Node.TEXT_NODE) return false;
+ if (visualNode.getNodeValue().trim().length() == 0) return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ */
+ private void updateComment(Node sourceNode) {
+ VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
+ if (mapping != null && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
+ Node visualCommentFrame = mapping.getVisualNode();
+ NodeList visualNodes = visualCommentFrame.getChildNodes();
+ int len = visualNodes.getLength();
+ if (len > 0) {
+ Node visualText = visualNodes.item(0);
+ visualText.setNodeValue(sourceNode.getNodeValue());
+ MozillaSupports.release(visualText);
+ }
+ MozillaSupports.release(visualNodes);
+ }
+ }
+
+ /**
+ *
+ * @param sourceNode
+ */
+ private void updateElement(Node sourceNode) {
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping)nodeMapping;
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ Node updateNode = elementMapping.getTemplate().getNodeForUptate(pageContext, elementMapping.getSourceNode(), elementMapping.getVisualNode(), elementMapping.getData());
+ if (updateNode != null && updateNode != sourceNode) {
+ updateNode(updateNode);
+ return;
+ }
+ }
+ }
+ Node visualOldNode = domMapping.remove(sourceNode);
+ if (visualOldNode != null) {
+ if(elementMapping != null){
+ Element border = elementMapping.getBorder();
+ if(border != null){
+ MozillaSupports.release(visualOldNode);
+ visualOldNode = border;
+ }
+ }
+ Node visualContainer = visualOldNode.getParentNode();
+ Node visualNextNode = visualOldNode.getNextSibling();
+ if (visualContainer != null) {
+ visualContainer.removeChild(visualOldNode);
+ addNode(sourceNode, visualNextNode, visualContainer);
+ }
+ MozillaSupports.release(visualOldNode, visualNextNode, visualContainer);
+ } else {
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ updateNode(sourceNode.getParentNode());
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void removeNode(Node sourceNode) {
+ Node visualNode = domMapping.remove(sourceNode);
+ if (visualNode != null) {
+ MozillaSupports.release(visualNode);
+ }
+ }
+
+ /**
+ *
+ */
+ public void setText(Node sourceText) {
+ Node sourceParent = sourceText.getParentNode();
+ if (sourceParent != null && sourceParent.getLocalName() != null) {
+ String sourceParentName = sourceParent.getLocalName();
+ if ("textarea".equalsIgnoreCase(sourceParentName) || "option".equalsIgnoreCase(sourceParentName)) {
+ updateNode(sourceText.getParentNode());
+ return;
+ }
+ }
+ Node visualText = domMapping.getVisualNode(sourceText);
+ if (visualText != null) {
+ String visualValue = TextUtil.visualText(sourceText.getNodeValue());
+ visualText.setNodeValue(visualValue);
+ } else {
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceParent);
+ if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ VpeTemplate template = ((VpeElementMapping)nodeMapping).getTemplate();
+ if (template != null) {
+ if (!template.containsText()) {
+ return;
+ }
+ }
+ }
+ updateNode(sourceText);
+ }
+ }
+
+ /**
+ *
+ */
+ public void setAttribute(Element sourceElement, String name, String value) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (elementMapping.getBorder() != null) {
+ updateElement(sourceElement);
+ } else if (template.isRecreateAtAttrChange(pageContext, sourceElement, visualDocument, (Element)elementMapping.getVisualNode(), elementMapping.getData(), name, value)) {
+ updateElement(sourceElement);
+ } else {
+ Element visualElement = (Element)elementMapping.getVisualNode();
+ if (visualElement != null) {
+ String visualElementName = visualElement.getNodeName().toLowerCase();
+ if ("select".equals(visualElementName)) {
+ updateElement(sourceElement);
+ return;
+ } else if ("option".equals(visualElementName)) {
+ updateElement(sourceElement.getParentNode());
+ return;
+ }
+ }
+ setXmlnsAttribute(elementMapping, name, value);
+ template.setAttribute(pageContext, sourceElement, visualDocument, visualElement, elementMapping.getData(), name, value);
+ resetTooltip(sourceElement, visualElement);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void stopToggle(Node sourceNode) {
+ if (!(sourceNode instanceof Element))
+ return;
+
+ Element sourceElement = (Element)sourceNode;
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate)template).stopToggling(sourceElement);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean doToggle(Node visualNode) {
+ if (visualNode == null) return false;
+
+ Element visualElement = (Element) (visualNode instanceof Element ?
+ visualNode : visualNode.getParentNode());
+
+ if (visualElement == null) return false;
+
+ Attr toggleIdAttr = visualElement.getAttributeNode("vpe-user-toggle-id");
+ if (toggleIdAttr == null) return false;
+ String toggleId = toggleIdAttr.getNodeValue();
+ MozillaSupports.release(toggleIdAttr);
+
+ if (toggleId == null) return false;
+
+ boolean toggleLookup = false;
+ Attr toggleLookupAttr = visualElement.getAttributeNode("vpe-user-toggle-lookup-parent");
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ MozillaSupports.release(toggleIdAttr);
+ }
+
+
+ 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;
+ template = elementMapping.getTemplate();
+ }
+
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate)template).toggle(this, sourceElement, toggleId);
+ updateElement(sourceElement);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public void removeAttribute(Element sourceElement, String name) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (template.isRecreateAtAttrChange(pageContext, sourceElement, visualDocument, (Element)elementMapping.getVisualNode(), elementMapping.getData(), name, null)) {
+ updateElement(sourceElement);
+ } else {
+ removeXmlnsAttribute(elementMapping, name);
+ template.removeAttribute(pageContext, sourceElement, visualDocument, (Element)elementMapping.getVisualNode(), elementMapping.getData(), name);
+ resetTooltip(sourceElement, (Element)elementMapping.getVisualNode());
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void refreshBundleValues(Element sourceElement) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+ template.refreshBundleValues(pageContext, sourceElement, elementMapping.getData());
+ }
+ }
+
+ /**
+ *
+ */
+ boolean isContentArea(Node visualNode) {
+ return visualContentArea.equals(visualNode);
+ }
+
+ /**
+ *
+ */
+ Element getContentArea() {
+ return visualContentArea;
+ }
+
+ /**
+ *
+ */
+ void setSelectionRectangle(Element visualElement) {
+ setSelectionRectangle(visualElement, true);
+ }
+
+ /**
+ *
+ */
+ void setSelectionRectangle(Element visualElement, boolean scroll) {
+ int resizerConstrains = getResizerConstrains(visualElement);
+ visualEditor.setSelectionRectangle(visualElement, resizerConstrains, scroll);
+ }
+
+ /**
+ *
+ */
+ public Node addLinkNodeToHead(String href_val, String ext_val) {
+ Element newNode = createLinkNode(href_val, ATTR_REL_STYLESHEET_VALUE, ext_val);
+ headNode.appendChild(newNode);
+ return newNode;
+ }
+
+ /**
+ *
+ */
+ public Node replaceLinkNodeToHead(Node oldNode, String href_val, String ext_val) {
+ Node newNode = createLinkNode(href_val, ATTR_REL_STYLESHEET_VALUE, ext_val);
+ headNode.replaceChild(newNode, oldNode);
+ MozillaSupports.release(oldNode);
+ return newNode;
+ }
+
+ /**
+ *
+ */
+ public Node replaceLinkNodeToHead(String href_val, String ext_val) {
+ Node newNode = null;
+ Node oldNode = getLinkNode(href_val, ext_val);
+ if (oldNode == null) {
+ newNode = addLinkNodeToHead(href_val, ext_val);
+ }
+ return newNode;
+ }
+
+ /**
+ *
+ */
+ public void removeLinkNodeFromHead(Node node){
+ headNode.removeChild(node);
+ MozillaSupports.release(node);
+ }
+
+ /**
+ *
+ * @param href_val
+ * @param rel_val
+ * @param ext_val
+ * @return
+ */
+ private Element createLinkNode(String href_val, String rel_val, String ext_val) {
+ Element linkNode = null;
+ if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
+ && href_val.startsWith("file:")) {
+ /* Because of the Mozilla caches the linked css files we replace
+ * tag <link rel="styleseet" href="file://..."> with tag
+ * <style vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style>
+ * It is LinkReplacer
+ */
+ linkNode = visualDocument.createElement(TAG_STYLE);
+ linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
+
+ /* Copy links attributes into our <style> */
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ try {
+ StringBuffer styleText = new StringBuffer(EMPTY_STRING);
+ BufferedReader in = new BufferedReader(new FileReader((new Path(href_val)).setDevice("").toOSString()));
+ String str = EMPTY_STRING;
+ while ((str = in.readLine()) != null) {
+ styleText.append(str);
+ }
+ in.close();
+ Node textNode = visualDocument.createTextNode(styleText.toString());
+ linkNode.appendChild(textNode);
+ return linkNode;
+ } catch (FileNotFoundException fnfe) {
+ MozillaSupports.release(linkNode);
+ /* File which was pointed by user is not exists. Do nothing. */
+ } catch (IOException ioe) {
+ MozillaSupports.release(linkNode);
+ VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
+ }
+ }
+
+ linkNode = visualDocument.createElement(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);
+
+ return linkNode;
+ }
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ private boolean isLinkReplacer(Node node) {
+ return TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && ATTR_VPE_INLINE_LINK_VALUE.equalsIgnoreCase(((Element)node).getAttribute(ATTR_VPE));
+ }
+
+ /**
+ *
+ * @param href_val
+ * @param ext_val
+ * @return
+ */
+ private Node getLinkNode(String href_val, String ext_val) {
+ NodeList children = headNode.getChildNodes();
+ int len = children.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ if (TAG_LINK.equalsIgnoreCase(node.getNodeName())
+ || isLinkReplacer(node) ) {
+ Element element = (Element)node;
+ if (ext_val.equalsIgnoreCase(element.getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
+ && href_val.equalsIgnoreCase(element.getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
+ MozillaSupports.release(children);
+ return node;
+ }
+ }
+ }
+ MozillaSupports.release(node);
+ }
+ MozillaSupports.release(children);
+ return null;
+ }
+
+ /**
+ *
+ */
+ private void cleanHead() {
+ NodeList children = headNode.getChildNodes();
+ int len = children.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ String name = node.getNodeName();
+ if (TAG_LINK.equalsIgnoreCase(name) || isLinkReplacer(node) ) {
+ if (NO_STRING.equalsIgnoreCase(((Element)node).getAttribute("ext"))) {
+ node = headNode.removeChild(node);
+ }
+ } else if (TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && (!YES_STRING.equalsIgnoreCase(((Element)node).getAttribute(ATTR_VPE)))) {
+ node = headNode.removeChild(node);
+ }
+ }
+ MozillaSupports.release(node);
+ }
+ MozillaSupports.release(children);
+ }
+
+ /**
+ *
+ * @author A. Yukhovich
+ */
+ private class PseudoInfo {
+ private Node pseudoNode;
+ private boolean isElements;
+
+ private PseudoInfo() {
+ this(null, false);
+ }
+
+ private PseudoInfo(Node pseudoNode, boolean isElements) {
+ this.pseudoNode = pseudoNode;
+ this.isElements = isElements;
+ }
+ }
+
+ /**
+ *
+ */
+ void showDragCaret(Node node, int offset) {
+ browser.showDragCaret((nsIDOMNode)node, offset);
+ }
+
+ /**
+ *
+ */
+ void hideDragCaret() {
+ browser.hideDragCaret();
+ }
+
+ /**
+ *
+ * @param visualNode
+ * @return
+ */
+ private int getResizerConstrains(Node visualNode) {
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
+ if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ return ((VpeElementMapping)nodeMapping).getTemplate().getTagDescription(pageContext, (Element)nodeMapping.getSourceNode(), visualDocument, (Element)nodeMapping.getVisualNode(), ((VpeElementMapping)nodeMapping).getData()).getResizeConstrains();
+ }
+ return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ }
+
+ /**
+ *
+ */
+ public void resize(Element element, int resizerConstrains, int top, int left, int width, int height) {
+ VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(element);
+ if (elementMapping != null) {
+ elementMapping.getTemplate().resize(pageContext, (Element)elementMapping.getSourceNode(), visualDocument, element, elementMapping.getData(), resizerConstrains, top, left, width, height);
+ }
+ }
+
+ static boolean isAnonElement(Node visualNode) {
+ if (visualNode != null && visualNode.getNodeType() == Node.ELEMENT_NODE) {
+ String attrValue = ((Element)visualNode).getAttribute(MOZ_ANONCLASS_ATTR);
+ return attrValue != null && attrValue.length() > 0;
+ }
+ return false;
+ }
+
+ boolean canInnerDrag(Element visualDragElement) {
+ VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
+ if(node instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping)node;
+ if (elementMapping != null) {
+ return elementMapping.getTemplate().canInnerDrag(pageContext, (Element)elementMapping.getSourceNode(), visualDocument, visualDragElement, elementMapping.getData());
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode, VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
+ Node visualDropContainer = visualDropInfo.getDropContainer();
+ int visualDropOffset = visualDropInfo.getDropOffset();
+ Node sourceDropContainer = null;
+ int sourceDropOffset = 0;
+
+ switch (visualDropContainer.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Node visualOffsetNode = null;
+ boolean afterFlag = false;
+ int visualChildCount = MozillaSupports.getChildCount(visualDropContainer);
+ if (visualDropOffset < visualChildCount) {
+ visualOffsetNode = MozillaSupports.getChildNode(visualDropContainer, visualDropOffset);
+ if (isPseudoElement(visualOffsetNode) || isAnonElement(visualOffsetNode)) {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = true;
+ }
+ } else {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = visualChildCount != 0;
+ }
+ if (visualOffsetNode != null) {
+ Node sourceOffsetNode = domMapping.getSourceNode(visualOffsetNode);
+ if (sourceOffsetNode != null) {
+ sourceDropContainer = sourceOffsetNode.getParentNode();
+ sourceDropOffset = ((NodeImpl)sourceOffsetNode).getIndex();
+ if (afterFlag) {
+ sourceDropOffset++;
+ }
+ }
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping.getNearSourceNode(visualDropContainer);
+ if (sourceDropContainer != null) {
+ sourceDropOffset = sourceDropContainer.getChildNodes().getLength();
+ }
+ }
+ if (sourceDropContainer == null){
+ sourceDropContainer = domMapping.getNearSourceNode(visualContentArea);
+ sourceDropOffset = sourceDropContainer.getChildNodes().getLength();
+ }
+ break;
+ case Node.TEXT_NODE:
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualDropContainer);
+ switch (nodeMapping.getType()) {
+ case VpeNodeMapping.TEXT_MAPPING:
+ sourceDropContainer = nodeMapping.getSourceNode();
+ sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer.getNodeValue(), visualDropOffset);
+ break;
+ case VpeNodeMapping.ELEMENT_MAPPING:
+ // it's attribute
+ if (isTextEditable(visualDropContainer)) {
+ String[] atributeNames = ((VpeElementMapping)nodeMapping).getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element)nodeMapping.getSourceNode();
+ sourceDropContainer = sourceElement.getAttributeNode(atributeNames[0]);
+ sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer.getNodeValue(), visualDropOffset);
+ }
+ }
+ nodeMapping.getVisualNode();
+ }
+ break;
+ }
+ if (sourceDropContainer != null) {
+ return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer, sourceDropOffset, checkParentTemplates);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, false);
+ }
+ }
+
+ /**
+ *
+ */
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode, Node container, int offset, boolean checkParentsTemplates) {
+ //Thread.dumpStack();
+ boolean canDrop = false;
+ switch (container.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
+ if (nodeMapping != null && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ canDrop = ((VpeElementMapping)nodeMapping).getTemplate().canInnerDrop(pageContext, container, dragNode);
+ }
+ if (!canDrop) {
+ if(!checkParentsTemplates) return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ offset = ((NodeImpl)container).getIndex();
+ container = container.getParentNode();
+ return getSourceInnerDropInfo(dragNode, container, offset, false);
+ }
+ break;
+ case Node.TEXT_NODE:
+ case Node.DOCUMENT_NODE:
+ canDrop = true;
+ break;
+ case Node.ATTRIBUTE_NODE:
+ canDrop = true;
+ break;
+ }
+ if (canDrop) {
+ return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, canDrop);
+ }
+ }
+
+ /**
+ *
+ */
+ public void innerDrop(Node dragNode, Node container, int offset) {
+ VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
+ if (mapping != null) {
+ Node visualDropContainer = mapping.getVisualNode();
+ switch (mapping.getType()) {
+ case VpeNodeMapping.TEXT_MAPPING:
+ break;
+ case VpeNodeMapping.ELEMENT_MAPPING:
+ Node visualParent = visualDropContainer.getParentNode();
+ VpeNodeMapping oldMapping = mapping;
+ mapping = domMapping.getNearNodeMapping(visualParent);
+ MozillaSupports.release(visualParent);
+ if (mapping != null && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ ((VpeElementMapping)mapping).getTemplate().innerDrop(pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container, offset, true));
+ } else {
+ ((VpeElementMapping)oldMapping).getTemplate().innerDrop(pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container, offset, true));
+ }
+ }
+
+ }
+ }
+
+ /**
+ *
+ */
+ Element getNearDragElement(Element visualElement) {
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(visualElement);
+ while (elementMapping != null) {
+ if (canInnerDrag((Element)elementMapping.getVisualNode())) {
+ return (Element)elementMapping.getVisualNode();
+ }
+ elementMapping = domMapping.getNearElementMapping(elementMapping.getVisualNode().getParentNode());
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ Element getDragElement(Element visualElement) {
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(visualElement);
+ if (elementMapping != null && canInnerDrag((Element)elementMapping.getVisualNode())) {
+ return (Element)elementMapping.getVisualNode();
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public boolean isTextEditable(Node visualNode) {
+ if (visualNode != null) {
+ Node parent = visualNode.getParentNode();
+ if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element)parent;
+ Attr style = element.getAttributeNode("style");
+ if (style != null) {
+ String styleValue = style.getNodeValue();
+ MozillaSupports.release(style);
+ 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())) {
+ MozillaSupports.release(parent);
+ return false;
+ }
+ }
+ }
+ Attr classAttr = element.getAttributeNode("class");
+ if (classAttr != null) {
+ String classValue = classAttr.getNodeValue().trim();
+ MozillaSupports.release(classAttr);
+ if ("__any__tag__caption".equals(classValue)) {
+ MozillaSupports.release(parent);
+ return false;
+ }
+ }
+ }
+ MozillaSupports.release(parent);
+ }
+ return true;
+ }
+ /**
+ *
+ */
+ VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer, int sourceDropOffset) {
+ Node visualDropContainer = null;
+ int visualDropOffset = 0;
+
+ switch (sourceDropContainer.getNodeType()) {
+ case Node.TEXT_NODE:
+ visualDropContainer = domMapping.getVisualNode(sourceDropContainer);
+ visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer.getNodeValue(), sourceDropOffset);
+ break;
+ case Node.ELEMENT_NODE:
+ case Node.DOCUMENT_NODE:
+ NodeList sourceChildren = sourceDropContainer.getChildNodes();
+ if (sourceDropOffset < sourceChildren.getLength()) {
+ Node sourceChild = sourceChildren.item(sourceDropOffset);
+ Node visualChild = domMapping.getVisualNode(sourceChild);
+ if (visualChild != null) {
+ visualDropContainer = visualChild.getParentNode();
+ visualDropOffset = MozillaSupports.getOffset(visualChild);
+ }
+ }
+ if (visualDropContainer == null) {
+ visualDropContainer = domMapping.getNearVisualNode(sourceDropContainer);
+ Node visualChild = getLastAppreciableVisualChild(visualDropContainer);
+ if (visualChild != null) {
+ visualDropOffset = MozillaSupports.getOffset(visualChild) + 1;
+ } else {
+ visualDropOffset = 0;
+ }
+ }
+ break;
+ case Node.ATTRIBUTE_NODE:
+ Element sourceElement = ((Attr)sourceDropContainer).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(sourceElement);
+ Node textNode = elementMapping.getTemplate().getOutputTextNode(pageContext, sourceElement, elementMapping.getData());
+ if (textNode != null) {
+ visualDropContainer = textNode;
+ visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer.getNodeValue(), sourceDropOffset);
+ }
+ break;
+ }
+ if (visualDropContainer == null) {
+ return null;
+ }
+ return new VpeVisualInnerDropInfo(visualDropContainer, visualDropOffset, 0, 0);
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param visualElement
+ */
+ private void setTooltip(Element sourceElement, Element visualElement) {
+ if (visualElement != null && sourceElement != null && !((ElementImpl)sourceElement).isJSPTag()) {
+ if ("HTML".equalsIgnoreCase(sourceElement.getNodeName())) return;
+ String titleValue = getTooltip(sourceElement);
+
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
+
+ if (titleValue != null) {
+ setTooltip(visualElement, titleValue);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param visualElement
+ * @param titleValue
+ */
+ private void setTooltip(Element visualElement, String titleValue) {
+ visualElement.setAttribute("title", titleValue);
+ NodeList children = visualElement.getChildNodes();
+ int len = children.getLength();
+ for (int i = 0; i < len; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ setTooltip((Element)child, titleValue);
+ }
+ MozillaSupports.release(child);
+ }
+ MozillaSupports.release(children);
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param visualElement
+ */
+ private void resetTooltip(Element sourceElement, Element visualElement) {
+ if (visualElement != null && sourceElement != null && !((ElementImpl)sourceElement).isJSPTag()) {
+ if ("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);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param visualElement
+ * @param titleValue
+ */
+ private void resetTooltip(Element visualElement, String titleValue) {
+ visualElement.setAttribute("title", titleValue);
+ NodeList children = visualElement.getChildNodes();
+ int len = children.getLength();
+ for (int i = 0; i < len; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ if (domMapping.getNodeMapping(child) == null) {
+ resetTooltip((Element)child, titleValue);
+ }
+ }
+ MozillaSupports.release(child);
+ }
+ MozillaSupports.release(children);
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @return
+ */
+ private String getTooltip(Element sourceElement) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(sourceElement.getNodeName());
+ NamedNodeMap attrs = sourceElement.getAttributes();
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++){
+ if (i == 7)
+ {
+ return buffer.append("\n\t... ").toString();
+ }
+ int valueLength = attrs.item(i).getNodeValue().length();
+ if (valueLength > 30) {
+ StringBuffer temp = new StringBuffer();
+ temp.append(attrs.item(i).getNodeValue().substring(0,15) + " ... "
+ + attrs.item(i).getNodeValue().substring(valueLength - 15,valueLength));
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp);
+ }
+ else
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + attrs.item(i).getNodeValue());
+
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ *
+ */
+ Rectangle getNodeBounds(Node visualNode) {
+ return dnd.getBounds((nsIDOMNode)visualNode);
+ }
+
+ /**
+ *
+ * @param x
+ * @param y
+ * @param rect
+ * @return
+ */
+ 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);
+ }
+
+ /**
+ *
+ * @param visualParent
+ * @return
+ */
+ static Node getLastAppreciableVisualChild(Node visualParent) {
+ Node visualLastChild = null;
+ NodeList visualChildren = visualParent.getChildNodes();
+ int len = visualChildren.getLength();
+ for (int i = len - 1; i >= 0; i--) {
+ Node visualChild = visualChildren.item(i);
+ if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
+ visualLastChild = visualChild;
+ break;
+ }
+ MozillaSupports.release(visualChild);
+ }
+ MozillaSupports.release(visualChildren);
+ return visualLastChild;
+ }
+
+ /**
+ *
+ */
+ void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo, VpeVisualInnerDropInfo oldVisualDropInfo) {
+ Node newVisualDropContainer = newVisualDropInfo.getDropContainer();
+ Node oldVisualDropContainer = oldVisualDropInfo.getDropContainer();
+
+ if (newVisualDropContainer.equals(oldVisualDropContainer)) {
+ newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
+ return;
+ }
+
+ Node child = oldVisualDropContainer;
+ while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
+ Node parent = child.getParentNode();
+ if (newVisualDropContainer.equals(parent)) {
+ int offset = MozillaSupports.getOffset(child);
+ Rectangle rect = getNodeBounds(child);
+ if (canInsertAfter(oldVisualDropInfo.getMouseX(), oldVisualDropInfo.getMouseY(), rect)) {
+ offset++;
+ }
+ newVisualDropInfo.setDropOffset(offset);
+ }
+ child = parent;
+ }
+ }
+
+ /**
+ *
+ */
+ public nsIDOMRange createDOMRange() {
+ return browser.createDOMRange();
+ }
+
+ /**
+ *
+ */
+ public nsIDOMRange createDOMRange(Node selectedNode) {
+ nsIDOMRange range = createDOMRange();
+ range.selectNode((nsIDOMNode)selectedNode);
+ return range;
+ }
+
+ /**
+ *
+ * @param visualElement
+ * @return
+ */
+ public static boolean isIncludeElement(Element visualElement) {
+ return YES_STRING.equalsIgnoreCase(visualElement.getAttribute(INCLUDE_ELEMENT_ATTR));
+ }
+
+ /**
+ *
+ * @param visualElement
+ */
+ public static void markIncludeElement(Element visualElement) {
+ visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
+ }
+
+ /**
+ *
+ * @param node
+ */
+ private void setReadOnlyElement(Element node) {
+ String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify", "read-only");
+ node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
+
+ /**
+ *
+ */
+ void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
+ Element selectedElement = browser.getSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), mouseEvent.getMousePoint())) {
+ dnd.setMoveCursor();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param dragArea
+ * @param mousePoint
+ * @return
+ */
+ private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
+ return dragArea.contains(mousePoint) &&
+ mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH) &&
+ mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
+ }
+
+ /**
+ *
+ */
+ Element getDragElement(nsIDOMMouseEvent mouseEvent) {
+ Element selectedElement = browser.getSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), mouseEvent.getMousePoint())) {
+ return selectedElement;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ VpeSourceInnerDragInfo getSourceInnerDragInfo(VpeVisualInnerDragInfo visualDragInfo) {
+ Node 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);
+ length = end - offset;
+ break;
+ case Node.ELEMENT_NODE:
+ if (visualNode.getNodeType() == Node.TEXT_NODE) {
+ // it's attribute
+ sourceNode = null;
+ if (isTextEditable(visualNode)) {
+ String[] atributeNames = ((VpeElementMapping)nodeMapping).getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element)nodeMapping.getSourceNode();
+ sourceNode = sourceElement.getAttributeNode(atributeNames[0]);
+ end = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(visualNode.getNodeValue(), offset);
+ length = end - offset;
+ }
+ }
+ }
+ break;
+ }
+ }
+ return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ }
+
+ /**
+ *
+ */
+ public void SetCursor(String aCursorName, int aLock) {
+ dnd.SetCursor(aCursorName, aLock);
+ }
+
+ /**
+ *
+ */
+ public Node getOutputTextNode(Attr attr) {
+ Element sourceElement = ((Attr)attr).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping.getNearElementMapping(sourceElement);
+ if (elementMapping != null) {
+ return elementMapping.getTemplate().getOutputTextNode(pageContext, sourceElement, elementMapping.getData());
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ Element getLastSelectedElement() {
+ return browser.getSelectedElement();
+ }
+
+ /**
+ *
+ */
+ public void pushIncludeStack(VpeIncludeInfo includeInfo) {
+ includeStack.add(includeInfo);
+ }
+
+ /**
+ *
+ */
+ public VpeIncludeInfo popIncludeStack() {
+ VpeIncludeInfo includeInfo = null;
+ if (includeStack.size() > 0) {
+ includeInfo = (VpeIncludeInfo)includeStack.remove(includeStack.size() - 1);
+ }
+ return includeInfo;
+ }
+
+ /**
+ *
+ */
+ public boolean isFileInIncludeStack(IFile file) {
+ if (file == null) return false;
+ for (int i = 0; i < includeStack.size(); i++) {
+ if (file.equals(((VpeIncludeInfo)includeStack.get(i)).getFile())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private boolean isCurrentMainDocument() {
+ return includeStack.size() <= 1;
+ }
+
+ /**
+ *
+ *
+ */
+ public int getCurrentMainIncludeOffset() {
+ if (includeStack.size() <= 1) return -1;
+ VpeIncludeInfo info = (VpeIncludeInfo)includeStack.get(1);
+ return ((IndexedRegion)info.getElement()).getStartOffset();
+ }
+
+ /**
+ *
+ */
+ public VpeIncludeInfo getCurrentIncludeInfo() {
+ if (includeStack.size() <= 0) return null;
+ return (VpeIncludeInfo)includeStack.get(includeStack.size() - 1);
+ }
+
+ /**
+ *
+ */
+ public VpeIncludeInfo getRootIncludeInfo() {
+ if (includeStack.size() <= 1) return null;
+ return (VpeIncludeInfo)includeStack.get(1);
+ }
+
+ /**
+ *
+ */
+ void dispose() {
+ cleanHead();
+ domMapping.clear(visualContentArea);
+ pageContext.dispose();
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private Map createXmlns(Element sourceNode) {
+ NamedNodeMap attrs = ((Element)sourceNode).getAttributes();
+ if (attrs != null) {
+ Map xmlnsMap = new HashMap();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(), true);
+ }
+ if (xmlnsMap.size() > 0) {
+ return xmlnsMap;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param elementMapping
+ * @param name
+ * @param value
+ */
+ private void setXmlnsAttribute(VpeElementMapping elementMapping, String name, String value) {
+ Element sourceElement = (Element)elementMapping.getSourceNode();
+ if (sourceElement != null) {
+ Map xmlnsMap = elementMapping.getXmlnsMap();
+ if (xmlnsMap == null) xmlnsMap = new HashMap();
+ addTaglib(sourceElement, xmlnsMap, name, true);
+ elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
+ }
+ }
+
+ /**
+ *
+ * @param elementMapping
+ * @param name
+ */
+ 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);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param xmlnsMap
+ * @param attrName
+ * @param 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);
+ }
+ }
+}
Added: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java (rev 0)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-07-31 14:05:33 UTC (rev 2760)
@@ -0,0 +1,466 @@
+/*******************************************************************************
+ * 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.mozilla;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
+import org.jboss.tools.vpe.editor.VpePreviewDomBuilder;
+import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
+import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
+import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.MozillaSupports;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.mozilla.browser.MozillaBrowser;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.VpeDnD;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMElement;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMEventTarget;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsISelectionController;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsISupports;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * a class implementation of mozilla previre
+ * @author A. Yukhovich
+ */
+public class MozillaPreview extends MozillaEditor {
+ private static final String INIT_URL = "chrome://vpe/content/init.html"; //$NON-NLS-1$
+ private static final String CONTENT_AREA_ID = "__content__area__"; //$NON-NLS-1$
+
+ static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
+ private MozillaBrowser editor;
+ private Document domDocument;
+ private nsIDOMEventTarget documentEventTarget;
+ private Element contentArea;
+ private Node headNode;
+ private nsIDOMEventTarget contentAreaEventTarget;
+ private MozillaDomEventListener contentAreaEventListener;
+ private MozillaBaseEventListener baseEventListener;
+ private EditorLoadWindowListener editorLoadWindowListener;
+ private EditorDomEventListener editorDomEventListener;
+ private VpeController controller;
+ private Link link = null;
+ private VpeTemplateManager templateManager;
+ private VpePageContext pageContext;
+ private BundleMap bundle;
+ private StructuredTextEditor sourceEditor;
+ private VpeEditorPart editPart;
+ private VpeDomMapping domMapping;
+ private IDOMDocument sourceDocument;
+
+ public MozillaPreview(VpeEditorPart editPart, StructuredTextEditor sourceEditor) {
+ templateManager = VpeTemplateManager.getInstance();
+
+ this.sourceEditor = sourceEditor;
+ this.editPart = editPart;
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ }
+
+ public void doSaveAs() {
+ }
+
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.setInput(input);
+ }
+
+ public void setInput(IEditorInput input) {
+ boolean isVisualRefreshRequired = (getEditorInput() != null && getEditorInput() != input && controller != null);
+ super.setInput(input);
+ if(isVisualRefreshRequired) controller.visualRefresh();
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl(final Composite parent) {
+ try {
+ editor = new MozillaBrowser(parent, SWT.NONE) {
+ public void onLoadWindow() {
+ super.onLoadWindow();
+ MozillaPreview.this.onLoadWindow();
+ }
+
+ public void onElementResize(nsIDOMElement element, int resizerConstrains, int top, int left, int width, int height) {
+ }
+
+ public void onShowTooltip(int x, int y, String text) {
+ if (editorDomEventListener != null) {
+ editorDomEventListener.onShowTooltip(x, y, text);
+ }
+ }
+ public void onHideTooltip() {
+ if (editorDomEventListener != null) {
+ editorDomEventListener.onHideTooltip();
+ }
+ }
+ };
+ editor.setUrl(INIT_URL);
+ editor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ } catch (Exception e) {
+ Label title = new Label(parent, SWT.WRAP);
+ title.setText(VpeUIMessages.MOZILLA_LOADING_ERROR);
+ title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ link = new Link(parent, SWT.WRAP);
+ link.setText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK_TEXT);
+ link.setToolTipText(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK);
+ link.setForeground(link.getDisplay().getSystemColor(SWT.COLOR_BLUE));
+ link.addMouseListener(new MouseListener() {
+ public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
+ BusyIndicator.showWhile(link.getDisplay(), new Runnable() {
+ public void run() {
+ URL theURL=null;;
+ try {
+ theURL = new URL(VpeUIMessages.MOZILLA_LOADING_ERROR_LINK);
+ } catch (MalformedURLException e) {
+ VpePlugin.reportProblem(e);
+ }
+ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
+ try {
+ support.getExternalBrowser().openURL(theURL);
+ } catch (PartInitException e) {
+ VpePlugin.reportProblem(e);
+ }
+ }
+ });
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ public void mouseUp(MouseEvent e) {
+ }
+ });
+ link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Label fill = new Label(parent, SWT.WRAP);
+ fill.setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+ }
+
+ private ToolItem createToolItem(ToolBar parent, int type, String image, String toolTipText) {
+ ToolItem item = new ToolItem(parent, type);
+ item.setImage(ImageDescriptor.createFromFile(MozillaPreview.class, image).createImage());
+ item.setToolTipText(toolTipText);
+ return item;
+ }
+
+ public void setFocus() {
+ if(editor!=null) {
+ editor.setFocus();
+ } else {
+ //link.setFocus();
+ }
+ }
+
+ public void dispose() {
+ removeDomEventListeners();
+// removeClipboardDragDropHooks();
+ super.dispose();
+
+ if (contentArea != null) {
+ MozillaSupports.release(contentArea);
+ contentArea = null;
+ }
+ if (domDocument != null) {
+ MozillaSupports.release(domDocument);
+ domDocument = null;
+ }
+ if (editor != null) {
+ editor.dispose();
+ editor = null;
+ }
+ }
+
+ public void setEditorLoadWindowListener(EditorLoadWindowListener listener) {
+ editorLoadWindowListener = listener;
+ }
+
+ public void setEditorDomEventListener(EditorDomEventListener listener) {
+ editorDomEventListener = listener;
+ if (contentAreaEventListener != null) {
+ contentAreaEventListener.setEditorDomEventListener(listener);
+ }
+ if (editor != null) {
+ editor.setContextMenuListener(listener);
+ }
+ }
+
+ public Document getDomDocument() {
+ if (domDocument == null) {
+ domDocument = editor.getDOMDocument();
+ }
+ return domDocument;
+ }
+
+ public Element getContentArea() {
+ return contentArea;
+ }
+
+ public Node getHeadNode() {
+ return headNode;
+ }
+
+ public Menu getMenu() {
+ return editor.getMenu();
+ }
+
+ public Control getControl() {
+ return editor;
+ }
+
+ public VpeDnD getLocalDnD() {
+ if (contentAreaEventListener != null) {
+ return contentAreaEventListener.getLocalDnD();
+ }
+ return null;
+ }
+
+ private Element findContentArea() {
+ Node root = editor.getDOMDocumentElement();
+ Node area = findContentArea(root);
+ if (area == null) {
+ return null;
+ }
+ headNode = findHeadNode(root);
+ MozillaSupports.release(root);
+ return (Element)area;
+ }
+
+ private Node findHeadNode(Node root){
+ Node headNode = findChildNode(root, "HEAD"); //$NON-NLS-1$
+ return headNode;
+ }
+
+ private Node findChildNode(Node parent, String name) {
+ NodeList list = parent.getChildNodes();
+ Node node;
+ for (int i=0;i<list.getLength();i++) {
+ node = list.item(i);
+ if (node.getNodeName().equalsIgnoreCase(name)) {
+ MozillaSupports.release(list);
+ return node;
+ }
+ else {
+ MozillaSupports.release(node);
+ }
+ }
+ MozillaSupports.release(list);
+ return null;
+ }
+
+ private Node findContentArea(Node node) {
+ Node area = null;
+ if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ NodeList children = node.getChildNodes();
+ if (children != null) {
+ int length = children.getLength();
+ for (int i = 0; i < length; i++) {
+ Node child = children.item(i);
+ if (isContentArea(child)) {
+ area = child;
+ break;
+ }
+ area = findContentArea(child);
+ MozillaSupports.release(child);
+ if (area != null) {
+ break;
+ }
+ }
+ MozillaSupports.release(children);
+ }
+ }
+ return area;
+ }
+
+ private boolean isContentArea(Node node) {
+ boolean ret = false;
+ if ("BODY".equalsIgnoreCase(node.getNodeName())) { //$NON-NLS-1$
+ NamedNodeMap map = node.getAttributes();
+ if (map != null) {
+ int length = map.getLength();
+ for (int i = 0; i < length; i++) {
+ Node attr = map.item(i);
+ ret = attr.getNodeType() == Node.ATTRIBUTE_NODE &&
+ "ID".equalsIgnoreCase(attr.getNodeName()) && //$NON-NLS-1$
+ CONTENT_AREA_ID.equalsIgnoreCase(attr.getNodeValue());
+ MozillaSupports.release(attr);
+ if (ret) {
+ break;
+ }
+ }
+ MozillaSupports.release(map);
+ }
+ }
+ return ret;
+ }
+
+ /**
+ *
+ */
+ private void onLoadWindow() {
+ contentArea = findContentArea();
+ addDomEventListeners();
+ addSelectionListener();
+ if (editorLoadWindowListener != null) {
+ editorLoadWindowListener.load();
+ }
+ }
+
+ private void addDomEventListeners() {
+ if (contentArea != null) {
+ try {
+ contentAreaEventListener = (MozillaDomEventListener)Class.forName("org.jboss.tools.vpe.editor.mozilla.MozillaDomEventListener").newInstance(); //$NON-NLS-1$
+ } catch (Exception e) {
+ }
+
+ if (contentAreaEventListener != null) {
+ contentAreaEventListener.setMozillaBrowser(editor);
+ int aEventTarget = nsISupports.queryInterface(MozillaSupports.getAddress(contentArea), nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+ contentAreaEventTarget = new nsIDOMEventTarget(aEventTarget);
+ contentAreaEventListener.getLocalDnD().Init(editor.getDOMDocument(),editor.getPresShell(), contentAreaEventListener.getDropListener());
+ //contentAreaEventTarget.addEventListener("DOMSubtreeModified", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeInserted", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeRemoved", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeRemovedFromDocument", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMNodeInsertedIntoDocument", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMAttrModified", contentAreaEventListener.getDomEventListener());
+ //contentAreaEventTarget.addEventListener("DOMCharacterDataModified", contentAreaEventListener.getDomEventListener());
+ contentAreaEventTarget.addEventListener("click", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.addEventListener("mousedown", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.addEventListener("mouseup", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.addEventListener("mousemove", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+
+ Document document = getDomDocument();
+ aEventTarget = nsISupports.queryInterface(MozillaSupports.getAddress(document), nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+ documentEventTarget = new nsIDOMEventTarget(aEventTarget);
+ documentEventTarget.addEventListener("keypress", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ } else {
+ baseEventListener = new MozillaBaseEventListener();
+ baseEventListener.getLocalDnD().Init(editor.getDOMDocument(),editor.getPresShell(), baseEventListener.getDropListener());
+ }
+ }
+ }
+
+ private void removeDomEventListeners() {
+ if (contentAreaEventTarget != null && contentAreaEventListener != null) {
+ contentAreaEventTarget.removeEventListener("click", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.removeEventListener("mousedown", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.removeEventListener("mouseup", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ contentAreaEventTarget.removeEventListener("mousemove", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ }
+ if (domDocument != null && documentEventTarget != null) {
+ documentEventTarget.removeEventListener("keypress", contentAreaEventListener.getDomEventListener()); //$NON-NLS-1$
+ }
+ }
+
+ private void addSelectionListener() {
+ if (contentAreaEventListener != null) {
+ nsISelectionController selectionController = editor.getSelectionController();
+ selectionController.addSelectionListener(contentAreaEventListener.getSelectionListener());
+ selectionController.Release();
+ }
+ }
+
+ private void removeSelectionListener() {
+ nsISelectionController selectionController = editor.getSelectionController();
+ selectionController.removeSelectionListener(contentAreaEventListener.getSelectionListener());
+ selectionController.Release();
+ }
+
+ public void setSelectionRectangle(Element element, int resizerConstrains, boolean scroll) {
+ if (contentAreaEventListener != null) {
+ editor.setSelectionRectangle((nsIDOMElement)element, resizerConstrains, scroll);
+ }
+ }
+
+ public void showResizer() {
+ if (contentAreaEventListener != null) {
+ editor.showResizer();
+ }
+ }
+
+ public void hideResizer() {
+ if (contentAreaEventListener != null) {
+ editor.hideResizer();
+ }
+ }
+
+ /**
+ *
+ */
+ public void rebuildDom() {
+ pageContext.getVisualBuilder().rebuildDom(sourceDocument);
+ }
+
+ /**
+ */
+ public void buildDom() {
+ bundle = new BundleMap();
+ bundle.init(sourceEditor);
+
+ pageContext = new VpePageContext(templateManager, bundle, editPart);
+
+ domMapping = new VpeDomMapping(pageContext);
+ VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null, templateManager, sourceEditor, pageContext);
+ VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null, templateManager, this, pageContext);
+ pageContext.setSourceDomBuilder(sourceBuilder);
+ pageContext.setVisualDomBuilder(visualBuilder);
+
+ IDOMModel sourceModel = (IDOMModel)sourceEditor.getModel();
+ sourceDocument = sourceModel.getDocument();
+
+ visualBuilder.buildDom(sourceDocument);
+ }
+}
\ No newline at end of file
17 years, 5 months
JBoss Tools SVN: r2759 - in branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/bundle and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-07-31 10:04:13 -0400 (Tue, 31 Jul 2007)
New Revision: 2759
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/VpeDomBuilder.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml
Log:
merge with HEAD revision
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-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -10,9 +10,9 @@
******************************************************************************/
package org.jboss.tools.vpe.editor;
+import java.util.Iterator;
import java.util.List;
import java.util.Properties;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -22,6 +22,9 @@
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.bindings.Binding;
+import org.eclipse.jface.bindings.keys.KeySequence;
+import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.ISelection;
@@ -45,12 +48,16 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.internal.keys.WorkbenchKeyboard;
+import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent;
import org.eclipse.wst.sse.core.internal.provisional.IModelLifecycleListener;
@@ -74,7 +81,6 @@
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
-import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
import org.jboss.tools.common.model.ui.editors.dnd.DropData;
@@ -125,6 +131,7 @@
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.mozilla.browser.MozillaBrowser;
import org.jboss.tools.vpe.mozilla.browser.util.DOMTreeDumper;
+import org.jboss.tools.vpe.mozilla.internal.swt.xpl.XPCOM;
import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMEvent;
import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMKeyEvent;
import org.jboss.tools.vpe.mozilla.internal.swt.xpl.nsIDOMMouseEvent;
@@ -146,6 +153,9 @@
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;
MozillaBrowser browser;
@@ -785,7 +795,7 @@
selectionBuilder.setClickContentAreaSelection();
}
}
- switcher.stopActiveEditor();
+ switcher.stopActiveEditor();
}
public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
@@ -845,12 +855,17 @@
if (VpeDebug.printVisualKeyEvent) {
System.out.println("<<< keyPress type: " + keyEvent.getType() + " Ctrl: " + keyEvent.isCtrlKey() + " Shift: " + keyEvent.isShiftKey() + " CharCode: " + keyEvent.getCharCode() + " KeyCode: " + keyEvent.getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
+
if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ switcher.stopActiveEditor();
return;
}
+
visualEditor.hideResizer();
+ //TODO with this behaviour isn't works 'CTRL+M'
switcher.stopActiveEditor();
+
try {
if (visualKeyHandler.keyPressHandler(keyEvent)) {
switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
@@ -858,11 +873,70 @@
sourceSelectionChanged(true);
visualSelectionController.setCaretEnabled(true);
switcher.stopActiveEditor();
+ } else {
+ //adding calls of core event handlers, for example 'CTR+H' or 'CTRL+M' event handler dialog
+ Event keyboardEvent = new Event ();
+ //widget where event occur
+ keyboardEvent.widget=browser;
+ int rc=0;
+ boolean[] aAltKey = new boolean[1];
+ boolean[] aCtrlKey = new boolean[1];
+ boolean[] aShiftKey = new boolean[1];
+ boolean[] aMetaKey = new boolean[1];
+
+ rc = keyEvent.GetAltKey (aAltKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+ rc = keyEvent.GetCtrlKey (aCtrlKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+ rc = keyEvent.GetShiftKey (aShiftKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+ rc = keyEvent.GetMetaKey (aMetaKey);
+ if (rc != XPCOM.NS_OK) MozillaBrowser.error (rc);
+
+ keyboardEvent.stateMask = (aAltKey[0] ? SWT.ALT : 0) | (aCtrlKey[0] ? SWT.CTRL : 0) | (aShiftKey[0] ? SWT.SHIFT : 0) | (aMetaKey[0] ? SWT.MOD1 : 0);
+ keyboardEvent.x=0;
+ keyboardEvent.y=0;
+ keyboardEvent.type=SWT.KeyDown;
+
+ if(keyEvent.getKeyCode()==0) {
+
+ keyboardEvent.keyCode=keyEvent.getCharCode();
+ } else{
+
+ keyboardEvent.keyCode=keyEvent.getKeyCode();
+ }
+ //for maximaze/minimaze command(CTRL+M), we shouldn't call event listeners
+ List possibleKeyStrokes = WorkbenchKeyboard.generatePossibleKeyStrokes(keyboardEvent);
+ IWorkbench iWorkbench = VpePlugin.getDefault().getWorkbench();
+ if(iWorkbench.hasService(IBindingService.class)){
+ IBindingService iBindingService = (IBindingService) iWorkbench.getService(IBindingService.class);
+
+ KeySequence sequenceBeforeKeyStroke = KeySequence.getInstance();
+ for (Iterator iterator = possibleKeyStrokes.iterator(); iterator
+ .hasNext();){
+ KeySequence sequenceAfterKeyStroke = KeySequence.getInstance(
+ sequenceBeforeKeyStroke, (KeyStroke) iterator.next());
+ if(iBindingService.isPerfectMatch(sequenceAfterKeyStroke)){
+ final Binding binding = iBindingService.getPerfectMatch(sequenceAfterKeyStroke);
+
+ if((binding!=null)
+ && (binding.getParameterizedCommand()!=null)
+ && (binding.getParameterizedCommand().getCommand()!=null)
+ && (binding.getParameterizedCommand().getCommand().getId()!=null)
+ &&binding.getParameterizedCommand().getCommand().getId().equals(VpeController.MAXIMAZE_PART_ID)){
+ keyboardEvent.type = SWT.NONE;
+ }
+ }
+ }
+ }
+ browser.notifyListeners(keyboardEvent.type, keyboardEvent);
+
}
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
visualRefresh();
}
+
}
public void elementResized(Element element, int resizerConstrains, int top, int left, int width, int height) {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -38,7 +38,11 @@
return templateManager;
}
- public void registerNodes(VpeNodeMapping nodeMapping) {
+ public void registerNodes(VpeNodeMapping nodeMapping) {
+ if (sorceAdapter == null) {
+ return;
+ }
+
domMapping.mapNodes(nodeMapping);
Node sourceNode = nodeMapping.getSourceNode();
if (((INodeNotifier) sourceNode).getExistingAdapter(sorceAdapter) == null) {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -28,7 +28,6 @@
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
@@ -49,10 +48,10 @@
import org.eclipse.ui.texteditor.ITextEditorExtension;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
-
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.mozilla.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.mozilla.MozillaPreview;
import org.jboss.tools.vpe.editor.xpl.SashForm;
public class VpeEditorPart extends EditorPart implements ITextEditor, ITextEditorExtension, IReusableEditor, IVisualEditor {
@@ -66,8 +65,15 @@
private EditorPart multiPageEditor;
private static final QualifiedName SPLITTER_POSITION_KEY1 = new QualifiedName("", "splitter_position1");
private static final QualifiedName SPLITTER_POSITION_KEY2 = new QualifiedName("", "splitter_position2");
+ private static final QualifiedName SPLITTER_POSITION_KEY3 = new QualifiedName("", "splitter_position3");
private int controlCount = 0;
+ /** default web-browser */
+ private MozillaPreview previewWebBrowser = null;
+
+ /** preview content */
+ private Composite previewContent = null;
+
public StructuredTextEditor getSourceEditor(){
return sourceEditor;
}
@@ -150,10 +156,10 @@
if(sourceEditor!=null)sourceEditor.removeRulerContextMenuListener(listener);
}
public void setStatusField(IStatusField field, String category) {
- if(visualMode == VISUAL_MODE){
- if(field != null){
- field.setImage(null);
- field.setText(null);
+ if(visualMode == VISUAL_MODE) {
+ if(field != null) {
+ field.setImage(null);
+ field.setText(null);
}
}else
if(sourceEditor!=null)sourceEditor.setStatusField(field, category);
@@ -215,7 +221,7 @@
}
protected int[] loadSplitterPosition() {
- int[] sizes = new int[2];
+ int[] sizes = new int[3];
try {
IEditorInput input = getEditorInput();
if(!(input instanceof IFileEditorInput)) return null;
@@ -228,6 +234,10 @@
if (s != null) {
sizes[1] = Integer.parseInt(s);
}else return null;
+ s = file.getPersistentProperty(SPLITTER_POSITION_KEY3);
+ if (s != null) {
+ sizes[2] = Integer.parseInt(s);
+ }else return null;
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
return null;
@@ -244,6 +254,8 @@
file.setPersistentProperty(SPLITTER_POSITION_KEY1, s);
s = String.valueOf(weights[1]);
file.setPersistentProperty(SPLITTER_POSITION_KEY2, s);
+ s = String.valueOf(weights[2]);
+ file.setPersistentProperty(SPLITTER_POSITION_KEY3, s);
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
}
@@ -256,15 +268,41 @@
case VISUALSOURCE_MODE:
if(sourceContent!= null)sourceContent.setVisible(true);
if(visualContent!= null)visualContent.setVisible(true);
+ if(previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
+
case VISUAL_MODE:
if(sourceContent!= null)sourceContent.setVisible(false);
if(visualContent!= null)visualContent.setVisible(true);
+ if(previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
+
case SOURCE_MODE:
if(sourceContent!= null)sourceContent.setVisible(true);
if(visualContent!= null)visualContent.setVisible(false);
+ if(previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
+
+ case PREVIEW_MODE:
+ if(sourceContent!= null) {
+ sourceContent.setVisible(false);
+ }
+
+ if(visualContent!= null) {
+ visualContent.setVisible(false);
+ }
+
+ if(previewContent != null) {
+ previewWebBrowser.rebuildDom();
+ previewContent.setVisible(true);
+ }
+ break;
}
container.layout();
if(visualMode == SOURCE_MODE && type != SOURCE_MODE) {
@@ -290,6 +328,12 @@
sourceContent.setLayout(new FillLayout());
visualContent = new Composite(container, SWT.NONE);
visualContent.setLayout(new FillLayout());
+
+
+ // Create a preview content
+ previewContent = new Composite(container, SWT.NONE);
+ previewContent.setLayout(new FillLayout());
+
if(sourceEditor == null)sourceEditor = new StructuredTextEditor() {
public void safelySanityCheckState(IEditorInput input) {
super.safelySanityCheckState(input);
@@ -318,6 +362,13 @@
VpePlugin.reportProblem(e);
}
+ previewWebBrowser = new MozillaPreview(this, sourceEditor);
+ try {
+ previewWebBrowser.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+
try {
sourceEditor.addPropertyListener(
new IPropertyListener() {
@@ -347,6 +398,18 @@
});
visualEditor.createPartControl(visualContent);
}
+
+
+ if(previewWebBrowser!=null) {
+ previewWebBrowser.setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ previewWebBrowser.setEditorLoadWindowListener(null);
+ previewWebBrowser.buildDom();
+ }
+ });
+ previewWebBrowser.createPartControl(previewContent);
+ }
+
activeEditor = sourceEditor;
sourceContent.addListener(SWT.Activate, new Listener() {
@@ -371,6 +434,19 @@
}
});
+
+ previewContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (previewWebBrowser!=null && activeEditor != previewWebBrowser) {
+ activeEditor = previewWebBrowser;
+ setFocus();
+ }
+ }
+ }
+ });
+
+
IWorkbenchWindow window = getSite().getWorkbenchWindow();
window.getPartService().addPartListener(activationListener);
window.getShell().addShellListener(activationListener);
@@ -414,6 +490,11 @@
visualEditor.dispose();
visualEditor = null;
}
+
+ if (previewContent != null) {
+ previewContent.dispose();
+ previewContent = null;
+ }
}
public Object getAdapter(Class adapter) {
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -11,6 +11,7 @@
package org.jboss.tools.vpe.editor.bundle;
import java.io.File;
+import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
@@ -19,6 +20,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;
@@ -31,17 +33,16 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
-
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
import org.jboss.tools.common.model.util.ELParser;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+import org.jboss.tools.vpe.VpePlugin;
public class BundleMap {
// private static final String BEGIN_BUNDLE = "#{";
@@ -201,8 +202,8 @@
try {
file = new File(javaSources[i]).getCanonicalFile();
urls[i] = file.toURL();
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
+ } catch (IOException ioe) {
+ VpePlugin.reportProblem(ioe);
return null;
}
}
@@ -211,9 +212,10 @@
return bundle;
}
- } catch(Exception e) {
- VpePlugin.getPluginLog().logError(e);
+ } catch (MissingResourceException ex) {
+ // Ignore this exception
}
+
return null;
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -39,6 +39,9 @@
protected boolean caseSensitive;
protected boolean children;
protected boolean modify;
+
+ protected boolean haveVisualPreview;
+
private VpeResizer resizer;
private VpeDnd dragger;
private TextFormatingData textFormatingData;
@@ -145,6 +148,16 @@
this.caseSensitive = caseSensitive;
children = "yes".equals(templateElement.getAttribute(VpeTemplateManager.ATTR_TEMPLATE_CHILDREN));
modify = "yes".equals(templateElement.getAttribute(VpeTemplateManager.ATTR_TEMPLATE_MODIFY));
+
+ String strHaveVisualPreview = templateElement.getAttribute(VpeTemplateManager.ATTR_TEMPLATE_HAVE_VISUAL_PREVIEW);
+
+ if (strHaveVisualPreview != null && strHaveVisualPreview.length() != 0 ) {
+ haveVisualPreview = "yes".equals(strHaveVisualPreview);
+ } else {
+ haveVisualPreview = true;
+ }
+
+
init(templateElement);
}
@@ -892,4 +905,8 @@
public boolean containsText() {
return true;
}
+
+ public boolean isHaveVisualPreview() {
+ return haveVisualPreview;
+ }
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import org.jboss.tools.jst.jsp.editor.ITextFormatter;
@@ -25,241 +25,407 @@
/**
* Initiates template after its creating
- * @param templateElement <code>Element</code> with a name "vpe:template" from the template file
- * @param caseSensitive The case sensitive of an element of a source file
+ *
+ * @param templateElement
+ * <code>Element</code> with a name "vpe:template" from the
+ * template file
+ * @param caseSensitive
+ * The case sensitive of an element of a source file
*/
void init(Element templateElement, boolean caseSensitive);
/**
- * 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.
+ * 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.
*/
- VpeCreationData create(VpePageContext pageContext, Node sourceNode, Document visualDocument);
-
+ VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument);
+
/**
- * Is invoked after construction of all child nodes of the current visual node.
- * @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.
- * @param data Object <code>VpeCreationData</code>, built by a method <code>create</code>
+ * Is invoked after construction of all child nodes of the current visual
+ * node.
+ *
+ * @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.
+ * @param data
+ * Object <code>VpeCreationData</code>, built by a method
+ * <code>create</code>
*/
- void validate(VpePageContext pageContext, Node sourceNode, Document visualDocument, VpeCreationData data);
-
+ void validate(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument, VpeCreationData data);
+
/**
* Processes keyboard input (without the pressed key Ctrl)
- * @param pageContext Contains the information on edited page.
- * @param sourceDocument The document of the source tree.
- * @param sourceNode The current node of the source tree.
- * @param visualNode The current node of the visual tree.
- * @param data The arbitrary data, built by a method <code>create</code>
- * @param charCode Code of the pressed key
- * @param selection The current selection
- * @param formatter Interface for formatting the source text
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceDocument
+ * The document of the source tree.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @param charCode
+ * Code of the pressed key
+ * @param selection
+ * The current selection
+ * @param formatter
+ * Interface for formatting the source text
* @return <code>true</code> if the key is processed
*/
- boolean nonctrlKeyPressHandler(VpePageContext pageContext, Document sourceDocument, Node sourceNode, Node visualNode, Object data, int charCode, VpeSourceSelection selection, ITextFormatter formatter);
-
+ boolean nonctrlKeyPressHandler(VpePageContext pageContext,
+ Document sourceDocument, Node sourceNode, Node visualNode,
+ Object data, int charCode, VpeSourceSelection selection,
+ ITextFormatter formatter);
+
/**
- * Sets value of attribute of the current visual element.
- * Is invoked at change of attribute of an source element.
- * @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.
+ * Sets value of attribute of the current visual element. Is invoked at
+ * change of attribute of an source element.
+ *
+ * @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.
*/
- void setAttribute(VpePageContext pageContext, Element sourceElement, Document visualDocument, Node visualNode, Object data, String name, String value);
-
+ void setAttribute(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Node visualNode, Object data, String name,
+ String value);
+
/**
* Informs on remove of attribute of the current source element.
- * @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 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.
*/
- void removeAttribute(VpePageContext pageContext, Element sourceElement, Document visualDocument, Node visualNode, Object data, String name);
-
+ void removeAttribute(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Node visualNode, Object data, String name);
+
/**
* Is invoked before removal of the visiblis node from the tree
- * @param pageContext Contains the information on edited page.
- * @param sourceNode The current node of the source tree.
- * @param visualNode The current node of the visual tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
*/
- void beforeRemove(VpePageContext pageContext, Node sourceNode, Node visualNode, Object data);
-
+ void beforeRemove(VpePageContext pageContext, Node sourceNode,
+ Node visualNode, Object data);
+
/**
- * At a modification of the node of an source tree, the method update
- * for this node is invoked. Template can indicate other node for update
- * @param pageContext Contains the information on edited page.
- * @param sourceNode The current node of the source tree.
- * @param visualNode The current node of the visual tree.
- * @param data The arbitrary data, built by a method <code>create</code>
- * @return For this node of an source tree the method update is invoked.
- * If null, that is invoked update for current source node
+ * At a modification of the node of an source tree, the method update for
+ * this node is invoked. Template can indicate other node for update
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @return For this node of an source tree the method update is invoked. If
+ * null, that is invoked update for current source node
*/
- Node getNodeForUptate(VpePageContext pageContext, Node sourceNode, Node visualNode, Object data);
-
+ Node getNodeForUptate(VpePageContext pageContext, Node sourceNode,
+ Node visualNode, Object data);
+
/**
* Is invoked at resize of an element visual tree
- * @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 visualElement The current element of the visual tree.
- * @param data The arbitrary data, built by a method <code>create</code>
- * @param resizerConstrains Code of resizer:<br>
- * top-left: 1<br>
- * top: 2<br>
- * top-right: 4<br>
- * left: 8<br>
- * right: 16<br>
- * bottomleft: 32<br>
- * bottom: 64<br>
- * bottom-right: 128<br>
- * @param top Element top
- * @param left Element left
- * @param width Element width
- * @param height Element height
+ *
+ * @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 visualElement
+ * The current element of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @param resizerConstrains
+ * Code of resizer:<br>
+ * top-left: 1<br>
+ * top: 2<br>
+ * top-right: 4<br>
+ * left: 8<br>
+ * right: 16<br>
+ * bottomleft: 32<br>
+ * bottom: 64<br>
+ * bottom-right: 128<br>
+ * @param top
+ * Element top
+ * @param left
+ * Element left
+ * @param width
+ * Element width
+ * @param height
+ * Element height
*/
- void resize(VpePageContext pageContext, Element sourceElement, Document visualDocument, Element visualElement, Object data, int resizerConstrains, int top, int left, int width, int height);
-
+ void resize(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Element visualElement, Object data,
+ int resizerConstrains, int top, int left, int width, int height);
+
/**
- * Checks a capability of drag of visual element
- * @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 visualElement The current element of the visual tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ * Checks a capability of drag of visual element
+ *
+ * @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 visualElement
+ * The current element of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
* @return <code>true</code> The element can be dragged
*/
- boolean canInnerDrag(VpePageContext pageContext, Element sourceElement, Document visualDocument, Element visualElement, Object data);
-
+ boolean canInnerDrag(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Element visualElement, Object data);
+
/**
* Checks a capability to drop an element in the container
- * @param pageContext Contains the information on edited page.
- * @param container Element-Container
- * @param sourceDragNode Node for drop
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param container
+ * Element-Container
+ * @param sourceDragNode
+ * Node for drop
* @return <code>true</code> The node can be dropped
*/
- boolean canInnerDrop(VpePageContext pageContext, Node container, Node sourceDragNode);
-
+ boolean canInnerDrop(VpePageContext pageContext, Node container,
+ Node sourceDragNode);
+
/**
* Is invoked at drop of an element visual tree
- * @param pageContext Contains the information on edited page.
- * @param dragInfo The information on the dragged element
- * @param dropInfo The information on the drop container
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param dragInfo
+ * The information on the dragged element
+ * @param dropInfo
+ * The information on the drop container
*/
- void innerDrop(VpePageContext pageContext, VpeSourceInnerDragInfo dragInfo, VpeSourceInnerDropInfo dropInfo);
-
+ void innerDrop(VpePageContext pageContext, VpeSourceInnerDragInfo dragInfo,
+ VpeSourceInnerDropInfo dropInfo);
+
/**
* Returns <code>VpeTagDescription</code>
- * @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 visualElement The current element of the visual tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ *
+ * @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 visualElement
+ * The current element of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
* @return <code>VpeTagDescription</code>
*/
- VpeTagDescription getTagDescription(VpePageContext pageContext, Element sourceElement, Document visualDocument, Element visualElement, Object data);
-
+ VpeTagDescription getTagDescription(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument,
+ Element visualElement, Object data);
+
/**
- * 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.
+ * 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.
*/
- boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement, Document visualDocument, Node visualNde, Object data, String name, String value);
-
+ boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Node visualNde,
+ Object data, String name, String value);
+
/**
* @return <code>true</code> if the element can have children
*/
boolean isChildren();
-
+
/**
* @return <code>true</code> if the element is case sensitive
*/
boolean isCaseSensitive();
-
+
/**
+ * Return <code>true</code> if the element has visual representation on tab
+ * 'Preview', otherwise <code>false</code>.<br/>
+ * This value is initialized by attribute <b>haveVisualPreview</b> of tag
+ * <b><vpe:template></b>. If the attribute is not presented default
+ * value is <code>true</code>.<br/>
+ * <br/>
+ * Example:<br/>
+ * JSF tag <code><h:form></code>:<br/>
+ * <code>
+ * <vpe:tag name="h:form" case-sensitive="yes"><br/>
+ * <vpe:template children="yes" modify="yes" haveVisualPreview="no"><br/>
+ * <div style="border:1px dotted #FF6600;padding: 5px;" title="{tagstring()}"/><br/>
+ * <vpe:dnd><br/>
+ * <vpe:drag start-enable="yes"/><br/>
+ * <vpe:drop container="yes"/><br/>
+ * </vpe:dnd><br/>
+ * </vpe:template><br/>
+ * </vpe:tag><br/>
+ * </code><br/>
+ * In visual editor part (see tab 'Visual') the tag have a red border for
+ * visualization reason, but it is not visual element and it shouldn't have
+ * visual representation on tab 'Preview'.<br/>
+ * <br/>
+ * @return <code>true</code> if the element is have visual preview
+ */
+ boolean isHaveVisualPreview();
+
+ /**
* Returns the data for formatting an element of source tree
+ *
* @return <code>TextFormatingData</code>
*/
TextFormatingData getTextFormatingData();
-
+
/**
- * Returns a list of attributes of an element of the source tree,
- * the values which one are mapped in the visiblis editor
+ * Returns a list of attributes of an element of the source tree, the values
+ * which one are mapped in the visiblis editor
+ *
* @return attrubute name array
*/
- String [] getOutputAtributeNames();
+ String[] getOutputAtributeNames();
/**
* Is invoked at a change of bundle values
- * @param pageContext Contains the information on edited page.
- * @param sourceElement The current element of the source tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
*/
- void refreshBundleValues(VpePageContext pageContext, Element sourceElement, Object data);
+ void refreshBundleValues(VpePageContext pageContext, Element sourceElement,
+ Object data);
/**
- * Opens proprties editor for bundle value
- * Is invoked at double mouse click on visual element
- * @param pageContext Contains the information on edited page.
- * @param sourceElement The current element of the source tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ * Opens proprties editor for bundle value Is invoked at double mouse click
+ * on visual element
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
*/
- void openBundleEditors(VpePageContext pageContext, Element sourceElement, Object data);
+ void openBundleEditors(VpePageContext pageContext, Element sourceElement,
+ Object data);
/**
* Opens editor of source file for include-element
- * @param pageContext Contains the information on edited page.
- * @param sourceElement The current element of the source tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
*/
- void openIncludeEditor(VpePageContext pageContext, Element sourceElement, Object data);
+ void openIncludeEditor(VpePageContext pageContext, Element sourceElement,
+ Object data);
/**
* @deprecated
- * @param pageContext Contains the information on edited page.
- * @param sourceElement The current element of the source tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
*/
- void setSourceAttributeValue(VpePageContext pageContext, Element sourceElement, Object data);
-
+ void setSourceAttributeValue(VpePageContext pageContext,
+ Element sourceElement, Object data);
+
/**
- * If the value of attribute of an element of an source tree
- * is mapped by the way of text node of a visual treer,
- * this method returns the text node, otherwise - null
- * @param pageContext Contains the information on edited page.
- * @param sourceElement The current element of the source tree.
- * @param data The arbitrary data, built by a method <code>create</code>
+ * If the value of attribute of an element of an source tree is mapped by
+ * the way of text node of a visual treer, this method returns the text
+ * node, otherwise - null
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
* @return Text node or null
*/
- Node getOutputTextNode(VpePageContext pageContext, Element sourceElement, Object data);
+ Node getOutputTextNode(VpePageContext pageContext, Element sourceElement,
+ Object data);
/**
* @deprecated
- * @param pageContext Contains the information on edited page.
- * @param sourceElement The current element of the source tree.
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
* @param offset
* @param length
* @param data
*/
- void setSourceAttributeSelection(VpePageContext pageContext, Element sourceElement, int offset, int length, Object data);
+ void setSourceAttributeSelection(VpePageContext pageContext,
+ Element sourceElement, int offset, int length, Object data);
/**
* @deprecated
@@ -279,15 +445,20 @@
VpeAnyData getAnyData();
/**
- * The unfilled element of an source tree can be mapped
- * in the visiblis editor with the default contents
- * This method fills default contents
- * @param pageContext Contains the information on edited page.
- * @param sourceContainer The current element of the source tree.
- * @param visualContainer The current element of the visual tree.
- * @param visualDocument The document of the visual tree.
+ * The unfilled element of an source tree can be mapped in the visiblis
+ * editor with the default contents This method fills default contents
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceContainer
+ * The current element of the source tree.
+ * @param visualContainer
+ * The current element of the visual tree.
+ * @param visualDocument
+ * The document of the visual tree.
*/
- void setPseudoContent(VpePageContext pageContext, Node sourceContainer, Node visualContainer, Document visualDocument);
-
+ void setPseudoContent(VpePageContext pageContext, Node sourceContainer,
+ Node visualContainer, Document visualDocument);
+
boolean containsText();
}
\ No newline at end of file
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -112,6 +112,9 @@
static final String ATTR_TEMPLATE_CLASS = "class";
static final String ATTR_TEMPLATE_CHILDREN = "children";
static final String ATTR_TEMPLATE_MODIFY = "modify";
+
+ /** ATTR_TEMPLATE_HAVE_VISUAL_PREVIEW */
+ static final String ATTR_TEMPLATE_HAVE_VISUAL_PREVIEW = "haveVisualPreview";
static final String ATTR_COPY_ATTRS = "attrs";
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2007-07-31 14:04:13 UTC (rev 2759)
@@ -13,6 +13,7 @@
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.compare.Splitter;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -163,7 +164,7 @@
Rectangle rect = null;
try {
rect = composite.getBounds();
- } catch (Exception e) {
+ } catch (SWTException e) {
VpePlugin.getPluginLog().logError(e);
}
Modified: branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml
===================================================================
--- branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml 2007-07-31 14:03:46 UTC (rev 2758)
+++ branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml 2007-07-31 14:04:13 UTC (rev 2759)
@@ -1060,7 +1060,7 @@
</vpe:tag>
<vpe:tag name="f:view" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
+ <vpe:template children="yes" modify="yes" haveVisualPreview="no">
<div style="border:1px dotted #FF6600;padding: 5px;" title="{tagstring()}"/>
<vpe:dnd>
<vpe:drag start-enable="yes"/>
@@ -1078,7 +1078,7 @@
</vpe:tag>
<vpe:tag name="f:subview" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
+ <vpe:template children="yes" modify="yes" haveVisualPreview="no">
<div style="border:1px dotted #FF6600;padding: 5px;" title="{tagstring()}"/>
<vpe:dnd>
<vpe:drag start-enable="yes"/>
@@ -1096,7 +1096,7 @@
</vpe:tag>
<vpe:tag name="h:form" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
+ <vpe:template children="yes" modify="yes" haveVisualPreview="no">
<div style="border:1px dotted #FF6600;padding: 5px;" title="{tagstring()}"/>
<vpe:dnd>
<vpe:drag start-enable="yes"/>
17 years, 5 months