JBoss Tools SVN: r7381 - in trunk: documentation/guides/Exadel-migration and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-04-07 09:56:47 -0400 (Mon, 07 Apr 2008)
New Revision: 7381
Modified:
trunk/as/docs/reference/pom.xml
trunk/documentation/guides/Exadel-migration/pom.xml
trunk/documentation/guides/GettingStartedGuide/pom.xml
trunk/documentation/jboss-tools-docs/pom.xml
trunk/hibernatetools/docs/reference/pom.xml
trunk/jbpm/docs/reference/pom.xml
trunk/jsf/docs/jsf_tools_ref_guide/pom.xml
trunk/jsf/docs/jsf_tools_tutorial/pom.xml
trunk/jsf/docs/userguide/pom.xml
trunk/seam/docs/reference/pom.xml
trunk/struts/docs/struts_tools_ref_guide/pom.xml
trunk/struts/docs/struts_tools_tutorial/pom.xml
Log:
http://jira.jboss.com/jira/browse/JBQA-1524
tag "name" is corrected to avoid ()
Modified: trunk/as/docs/reference/pom.xml
===================================================================
--- trunk/as/docs/reference/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/as/docs/reference/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>as-ref-guide-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>AS_Reference_Guide_(${translation})</name>
+ <name>AS_Reference_Guide</name>
<build>
<plugins>
Modified: trunk/documentation/guides/Exadel-migration/pom.xml
===================================================================
--- trunk/documentation/guides/Exadel-migration/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/documentation/guides/Exadel-migration/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>exadel-studio-migration-guide${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>Exadel_Studio_Migration_Guide_(${translation})</name>
+ <name>Exadel_Studio_Migration_Guide</name>
<build>
<plugins>
Modified: trunk/documentation/guides/GettingStartedGuide/pom.xml
===================================================================
--- trunk/documentation/guides/GettingStartedGuide/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/documentation/guides/GettingStartedGuide/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>getting-started-guide-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>Getting_Started_Guide_(${translation})</name>
+ <name>Getting_Started_Guide</name>
<build>
<plugins>
Modified: trunk/documentation/jboss-tools-docs/pom.xml
===================================================================
--- trunk/documentation/jboss-tools-docs/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/documentation/jboss-tools-docs/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>all-guides</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
- <name>All_Userguides_(${translation})</name>
+ <name>All_Userguides</name>
<dependencies>
Modified: trunk/hibernatetools/docs/reference/pom.xml
===================================================================
--- trunk/hibernatetools/docs/reference/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/hibernatetools/docs/reference/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>hibernatetools-ref-guide-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>Hibernatetools_Reference_Guide_(${translation})</name>
+ <name>Hibernatetools_Reference_Guide</name>
<build>
<plugins>
Modified: trunk/jbpm/docs/reference/pom.xml
===================================================================
--- trunk/jbpm/docs/reference/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/jbpm/docs/reference/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>jbpm-ref-guide${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>JBPM_Reference_Guide_(${translation})</name>
+ <name>JBPM_Reference_Guide</name>
<build>
<plugins>
Modified: trunk/jsf/docs/jsf_tools_ref_guide/pom.xml
===================================================================
--- trunk/jsf/docs/jsf_tools_ref_guide/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/jsf/docs/jsf_tools_ref_guide/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>jsf-tools-reference-guide-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>JSF_Tools_Reference_Guide_(${translation})</name>
+ <name>JSF_Tools_Reference_Guide</name>
<build>
<plugins>
Modified: trunk/jsf/docs/jsf_tools_tutorial/pom.xml
===================================================================
--- trunk/jsf/docs/jsf_tools_tutorial/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/jsf/docs/jsf_tools_tutorial/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>jsf-tools-tutorial-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>JSF_Tools_Tutorial_(${translation})</name>
+ <name>JSF_Tools_Tutorial</name>
<build>
<plugins>
Modified: trunk/jsf/docs/userguide/pom.xml
===================================================================
--- trunk/jsf/docs/userguide/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/jsf/docs/userguide/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>visua-web-tools-guide-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>Visual_Web_Tools_Reference_Guide_(${translation})</name>
+ <name>Visual_Web_Tools_Reference_Guide</name>
<build>
<plugins>
Modified: trunk/seam/docs/reference/pom.xml
===================================================================
--- trunk/seam/docs/reference/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/seam/docs/reference/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>seam-ref-guide-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>Seam_Reference_Guide_(${translation})</name>
+ <name>Seam_Reference_Guide</name>
<build>
<plugins>
Modified: trunk/struts/docs/struts_tools_ref_guide/pom.xml
===================================================================
--- trunk/struts/docs/struts_tools_ref_guide/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/struts/docs/struts_tools_ref_guide/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>struts-tools-reference-guide-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>Struts_Tools_Reference_Guide_(${translation})</name>
+ <name>Struts_Tools_Reference_Guide</name>
<build>
<plugins>
Modified: trunk/struts/docs/struts_tools_tutorial/pom.xml
===================================================================
--- trunk/struts/docs/struts_tools_tutorial/pom.xml 2008-04-07 12:33:19 UTC (rev 7380)
+++ trunk/struts/docs/struts_tools_tutorial/pom.xml 2008-04-07 13:56:47 UTC (rev 7381)
@@ -8,7 +8,7 @@
<artifactId>struts-tools-tutorial-${translation}</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
- <name>Struts_Tools_Tutorial_(${translation})</name>
+ <name>Struts_Tools_Tutorial</name>
<build>
<plugins>
17 years, 8 months
JBoss Tools SVN: r7380 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2008-04-07 08:33:19 -0400 (Mon, 07 Apr 2008)
New Revision: 7380
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1626
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-04-07 12:17:45 UTC (rev 7379)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-04-07 12:33:19 UTC (rev 7380)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor;
import java.util.Iterator;
@@ -163,2299 +163,2611 @@
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
-public class VpeController implements INodeAdapter, IModelLifecycleListener, INodeSelectionListener, ITextSelectionListener, SelectionListener, EditorDomEventListener, VpeTemplateListener, XModelTreeListener, ResourceReferenceListListener, ISelectionChangedListener, IVisualController {
-
- StructuredTextEditor sourceEditor;
- private MozillaEditor visualEditor;
-// MozillaBrowser browser;
- XulRunnerEditor xulRunnerEditor;
+public class VpeController implements INodeAdapter, IModelLifecycleListener,
+ INodeSelectionListener, ITextSelectionListener, SelectionListener,
+ EditorDomEventListener, VpeTemplateListener, XModelTreeListener,
+ ResourceReferenceListListener, ISelectionChangedListener,
+ IVisualController {
+
+ StructuredTextEditor sourceEditor;
+ private MozillaEditor visualEditor;
+ // MozillaBrowser browser;
+ XulRunnerEditor xulRunnerEditor;
+ // TODO Sergey Vasilyev figure out with nsIPressShell
+ // private nsIPresShell presShell;
+ // TODO Max Areshkau figure out with nsISelectionController
+ private VpeSelectionController visualSelectionController;
+ VpeDomMapping domMapping;
+ private VpeTemplateManager templateManager;
+ private VpeSourceDomBuilder sourceBuilder;
+ private VpeVisualDomBuilder visualBuilder;
+ private VpeSelectionBuilder selectionBuilder;
+ private VpeVisualKeyHandler visualKeyHandler;
+ private ActiveEditorSwitcher switcher = new ActiveEditorSwitcher();
+ private Attr lastRemovedAttr;
+ private String lastRemovedAttrName;
+ private boolean mouseUpSelectionReasonFlag;
+ private boolean mouseDownSelectionFlag;
+ private boolean sourceChangeFlag;
+ private VpePageContext pageContext;
+ private BundleMap bundle;
+ private VpeEditorPart editPart;
+ private static final int AROUND_MENU = 1;
+ private static final int BEFORE_MENU = 2;
+ private static final int AFTER_MENU = 3;
+
+ private CSSReferenceList cssReferenceListListener;
+ private TaglibReferenceList taglibReferenceListListener;
+ private AbsoluteFolderReferenceList absoluteFolderReferenceListListener;
+ private RelativeFolderReferenceList relativeFolderReferenceListListener;
+ private VpeIncludeList includeList = new VpeIncludeList();
+ private VpeVisualInnerDragInfo innerDragInfo = null;
+ private FormatControllerManager toolbarFormatControllerManager = null;
+ private SelectionBar selectionBar = null;
+ private XModelTreeListenerSWTSync optionsListener;
+ // Added by Max Areshkau Fix for JBIDE-1479
+ private UIJob job = null;
+ Shell tip;
+
+ public final static String MODEL_FLAVOR = ModelTransfer.MODEL; //$NON-NLS-1$
+
+ public VpeController(VpeEditorPart editPart) {
+
+ this.editPart = editPart;
+ dropWindow = new VpeDropWindow(editPart.getSite().getShell());
+ }
+
+ void init(StructuredTextEditor sourceEditor, MozillaEditor visualEditor)
+ throws Exception {
+ this.sourceEditor = sourceEditor;
+ if (sourceEditor instanceof IJSPTextEditor) {
+ ((IJSPTextEditor) sourceEditor).setVPEController(this);
+ dropWindow.setEditor((IJSPTextEditor) sourceEditor);
+ }
+ this.visualEditor = visualEditor;
+ visualEditor.setController(this);
+ templateManager = VpeTemplateManager.getInstance();
+ bundle = new BundleMap();
+ bundle.init(sourceEditor);
+ pageContext = new VpePageContext(templateManager, bundle, editPart);
+ domMapping = new VpeDomMapping(pageContext);
+ sourceBuilder = new VpeSourceDomBuilder(domMapping, this,
+ templateManager, sourceEditor, pageContext);
+ visualBuilder = new VpeVisualDomBuilder(domMapping, this,
+ templateManager, visualEditor, pageContext);
+ pageContext.setSourceDomBuilder(sourceBuilder);
+ pageContext.setVisualDomBuilder(visualBuilder);
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel == null) {
+ return;
+ }
+ sourceModel.addModelLifecycleListener(this);
+ IDOMDocument sourceDocument = sourceModel.getDocument();
+ visualBuilder.refreshExternalLinks();
+ visualBuilder.buildDom(sourceDocument);
+
+ templateManager.addTemplateListener(this);
+
+ xulRunnerEditor = visualEditor.getXulRunnerEditor();
// TODO Sergey Vasilyev figure out with nsIPressShell
-// private nsIPresShell presShell;
- // TODO Max Areshkau figure out with nsISelectionController
- private VpeSelectionController visualSelectionController;
- VpeDomMapping domMapping;
- private VpeTemplateManager templateManager;
- private VpeSourceDomBuilder sourceBuilder;
- private VpeVisualDomBuilder visualBuilder;
- private VpeSelectionBuilder selectionBuilder;
- private VpeVisualKeyHandler visualKeyHandler;
- private ActiveEditorSwitcher switcher = new ActiveEditorSwitcher();
- private Attr lastRemovedAttr;
- private String lastRemovedAttrName;
- private boolean mouseUpSelectionReasonFlag;
- private boolean mouseDownSelectionFlag;
- private boolean sourceChangeFlag;
- private VpePageContext pageContext;
- private BundleMap bundle;
- private VpeEditorPart editPart;
- private static final int AROUND_MENU = 1;
- private static final int BEFORE_MENU = 2;
- private static final int AFTER_MENU = 3;
-
- private CSSReferenceList cssReferenceListListener;
- private TaglibReferenceList taglibReferenceListListener;
- private AbsoluteFolderReferenceList absoluteFolderReferenceListListener;
- private RelativeFolderReferenceList relativeFolderReferenceListListener;
- private VpeIncludeList includeList = new VpeIncludeList();
- private VpeVisualInnerDragInfo innerDragInfo = null;
- private FormatControllerManager toolbarFormatControllerManager = null;
- private SelectionBar selectionBar = null;
- private XModelTreeListenerSWTSync optionsListener;
- //Added by Max Areshkau Fix for JBIDE-1479
- private UIJob job = null;
- Shell tip;
-
- public final static String MODEL_FLAVOR = ModelTransfer.MODEL; //$NON-NLS-1$
-
- public VpeController(VpeEditorPart editPart){
+ // presShell = browser.getPresShell();
+ visualSelectionController = new VpeSelectionController(xulRunnerEditor
+ .getSelection());
+ selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
+ visualBuilder, visualSelectionController);
+ visualKeyHandler = new VpeVisualKeyHandler(sourceEditor, domMapping,
+ pageContext) {
+ public void doSave(IProgressMonitor monitor) {
+ editPart.doSave(monitor);
+ }
+ };
- this.editPart = editPart;
- dropWindow = new VpeDropWindow(editPart.getSite().getShell());
+ // glory
+ ISelectionProvider provider = sourceEditor.getSelectionProvider();
+ // Max Areshkau JBIDE-1105 If selection event received after selection
+ // in
+ // visual part we lost focus of selection, so we should process
+ // selection event
+ // in time of selection
+ // if (provider instanceof IPostSelectionProvider)
+ // ((IPostSelectionProvider)
+ // provider).addPostSelectionChangedListener(this);
+ // else
+ provider.addSelectionChangedListener(this);
+
+ // ViewerSelectionManager selectionManager =
+ // sourceEditor.getViewerSelectionManager();
+ // selectionManager.addNodeSelectionListener(this);
+ // selectionManager.addTextSelectionListener(this);
+ StyledText textWidget = VpeSelectionHelper
+ .getSourceTextWidget(sourceEditor);
+ if (textWidget != null) {
+ textWidget.addSelectionListener(this);
}
- void init(StructuredTextEditor sourceEditor, MozillaEditor visualEditor) throws Exception {
- this.sourceEditor = sourceEditor;
- if(sourceEditor instanceof IJSPTextEditor) {
- ((IJSPTextEditor)sourceEditor).setVPEController(this);
- dropWindow.setEditor((IJSPTextEditor)sourceEditor);
- }
- this.visualEditor = visualEditor;
- visualEditor.setController(this);
- templateManager = VpeTemplateManager.getInstance();
- bundle = new BundleMap();
- bundle.init(sourceEditor);
- pageContext = new VpePageContext(templateManager, bundle, editPart);
- domMapping = new VpeDomMapping(pageContext);
- sourceBuilder = new VpeSourceDomBuilder(domMapping, this, templateManager, sourceEditor, pageContext);
- visualBuilder = new VpeVisualDomBuilder(domMapping, this, templateManager, visualEditor, pageContext);
- pageContext.setSourceDomBuilder(sourceBuilder);
- pageContext.setVisualDomBuilder(visualBuilder);
- IDOMModel sourceModel = (IDOMModel)getModel();
- if (sourceModel == null) {
- return;
- }
- sourceModel.addModelLifecycleListener(this);
- IDOMDocument sourceDocument = sourceModel.getDocument();
- visualBuilder.refreshExternalLinks();
- visualBuilder.buildDom(sourceDocument);
-
- templateManager.addTemplateListener(this);
+ visualEditor.setEditorDomEventListener(this);
+ switcher.initActiveEditor();
- xulRunnerEditor = visualEditor.getXulRunnerEditor();
- // TODO Sergey Vasilyev figure out with nsIPressShell
-// presShell = browser.getPresShell();
- visualSelectionController = new VpeSelectionController(xulRunnerEditor.getSelection());
- selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder, visualBuilder, visualSelectionController);
- visualKeyHandler = new VpeVisualKeyHandler(sourceEditor, domMapping, pageContext){
- public void doSave(IProgressMonitor monitor){
- editPart.doSave(monitor);
- }
- };
+ if (optionsListener == null) {
+ XModelObject optionsObject = ModelUtilities.getPreferenceModel()
+ .getByPath(VpePreference.EDITOR_PATH);
+ optionsListener = new XModelTreeListenerSWTSync(this);
+ optionsObject.getModel().addModelTreeListener(optionsListener);
+ }
-// glory
- ISelectionProvider provider = sourceEditor.getSelectionProvider();
- //Max Areshkau JBIDE-1105 If selection event received after selection in
- //visual part we lost focus of selection, so we should process selection event
- //in time of selection
-// if (provider instanceof IPostSelectionProvider)
-// ((IPostSelectionProvider) provider).addPostSelectionChangedListener(this);
-// else
- provider.addSelectionChangedListener(this);
+ cssReferenceListListener = CSSReferenceList.getInstance();
+ cssReferenceListListener.addChangeListener(this);
-// ViewerSelectionManager selectionManager = sourceEditor.getViewerSelectionManager();
-// selectionManager.addNodeSelectionListener(this);
-// selectionManager.addTextSelectionListener(this);
- StyledText textWidget = VpeSelectionHelper.getSourceTextWidget(sourceEditor);
- if (textWidget != null) {
- textWidget.addSelectionListener(this);
- }
+ taglibReferenceListListener = TaglibReferenceList.getInstance();
+ taglibReferenceListListener.addChangeListener(this);
- visualEditor.setEditorDomEventListener(this);
- switcher.initActiveEditor();
-
- if (optionsListener == null) {
- XModelObject optionsObject = ModelUtilities.getPreferenceModel().getByPath(VpePreference.EDITOR_PATH);
- optionsListener = new XModelTreeListenerSWTSync(this);
- optionsObject.getModel().addModelTreeListener(optionsListener);
- }
-
+ absoluteFolderReferenceListListener = AbsoluteFolderReferenceList
+ .getInstance();
+ absoluteFolderReferenceListListener.addChangeListener(this);
- cssReferenceListListener = CSSReferenceList.getInstance();
- cssReferenceListListener.addChangeListener(this);
+ relativeFolderReferenceListListener = RelativeFolderReferenceList
+ .getInstance();
+ relativeFolderReferenceListListener.addChangeListener(this);
- taglibReferenceListListener = TaglibReferenceList.getInstance();
- taglibReferenceListListener.addChangeListener(this);
+ // pageContext.fireTaglibsChanged();
+ }
- absoluteFolderReferenceListListener = AbsoluteFolderReferenceList.getInstance();
- absoluteFolderReferenceListListener.addChangeListener(this);
+ public void dispose() {
+ if (optionsListener != null) {
+ XModelObject optionsObject = ModelUtilities.getPreferenceModel()
+ .getByPath(VpePreference.EDITOR_PATH);
+ optionsObject.getModel().removeModelTreeListener(optionsListener);
+ optionsListener.dispose();
+ optionsListener = null;
+ }
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel != null) {
+ sourceModel.removeModelLifecycleListener(this);
+ }
+ switcher.destroyActiveEditor();
+ switcher = null;
- relativeFolderReferenceListListener = RelativeFolderReferenceList.getInstance();
- relativeFolderReferenceListListener.addChangeListener(this);
-
-// pageContext.fireTaglibsChanged();
+ if (templateManager != null) {
+ templateManager.removeTemplateListener(this);
+ templateManager = null;
}
+ if (visualBuilder != null) {
+ visualBuilder.dispose();
+ visualBuilder = null;
+ }
+ sourceBuilder = null;
+ if (sourceEditor != null) {
+ // glory
+ ISelectionProvider provider = sourceEditor.getSelectionProvider();
+ provider.removeSelectionChangedListener(this);
+ // ViewerSelectionManager selectionManager =
+ // sourceEditor.getViewerSelectionManager();
+ // selectionManager.removeNodeSelectionListener(this);
+ // selectionManager.removeTextSelectionListener(this);
+ StyledText textWidget = VpeSelectionHelper
+ .getSourceTextWidget(sourceEditor);
+ if (textWidget != null) {
+ textWidget.removeSelectionListener(this);
+ }
+ ((IJSPTextEditor) sourceEditor).setVPEController(null);
- public void dispose() {
- if (optionsListener != null) {
- XModelObject optionsObject = ModelUtilities.getPreferenceModel().getByPath(VpePreference.EDITOR_PATH);
- optionsObject.getModel().removeModelTreeListener(optionsListener);
- optionsListener.dispose();
- optionsListener = null;
- }
- IDOMModel sourceModel = (IDOMModel)getModel();
- if (sourceModel != null) {
- sourceModel.removeModelLifecycleListener(this);
- }
- switcher.destroyActiveEditor();
- switcher=null;
-
- if (templateManager != null) {
- templateManager.removeTemplateListener(this);
- templateManager=null;
- }
- if (visualBuilder != null) {
- visualBuilder.dispose();
- visualBuilder = null;
- }
- sourceBuilder=null;
- if (sourceEditor != null) {
-//glory
- ISelectionProvider provider = sourceEditor.getSelectionProvider();
- provider.removeSelectionChangedListener(this);
-// ViewerSelectionManager selectionManager = sourceEditor.getViewerSelectionManager();
-// selectionManager.removeNodeSelectionListener(this);
-// selectionManager.removeTextSelectionListener(this);
- StyledText textWidget = VpeSelectionHelper.getSourceTextWidget(sourceEditor);
- if (textWidget != null) {
- textWidget.removeSelectionListener(this);
- }
- ((IJSPTextEditor)sourceEditor).setVPEController(null);
-
- }
- if (dropWindow != null) {
- dropWindow.setEditor(null);
- }
- if (visualEditor != null) {
- visualEditor.setEditorDomEventListener(null);
- if (visualSelectionController != null) {
-// visualSelectionController.Release();
- visualSelectionController = null;
- }
- // TODO Sergey Vasilyev figure out with Press Shell
-// if (presShell != null) {
-// presShell.Release();
-// presShell = null;
-// }
- visualEditor = null;
- }
+ }
+ if (dropWindow != null) {
+ dropWindow.setEditor(null);
+ }
+ if (visualEditor != null) {
+ visualEditor.setEditorDomEventListener(null);
+ if (visualSelectionController != null) {
+ // visualSelectionController.Release();
+ visualSelectionController = null;
+ }
+ // TODO Sergey Vasilyev figure out with Press Shell
+ // if (presShell != null) {
+ // presShell.Release();
+ // presShell = null;
+ // }
+ visualEditor = null;
+ }
- if (cssReferenceListListener != null) {
- cssReferenceListListener.removeChangeListener(this);
- }
- if (taglibReferenceListListener != null) {
- taglibReferenceListListener.removeChangeListener(this);
- }
- if (absoluteFolderReferenceListListener != null) {
- absoluteFolderReferenceListListener.removeChangeListener(this);
- }
- if (relativeFolderReferenceListListener != null) {
- relativeFolderReferenceListListener.removeChangeListener(this);
- }
- toolbarFormatControllerManager = null;
+ if (cssReferenceListListener != null) {
+ cssReferenceListListener.removeChangeListener(this);
}
+ if (taglibReferenceListListener != null) {
+ taglibReferenceListListener.removeChangeListener(this);
+ }
+ if (absoluteFolderReferenceListListener != null) {
+ absoluteFolderReferenceListListener.removeChangeListener(this);
+ }
+ if (relativeFolderReferenceListListener != null) {
+ relativeFolderReferenceListListener.removeChangeListener(this);
+ }
+ toolbarFormatControllerManager = null;
+ }
- // INodeAdapter implementation
- public boolean isAdapterForType(Object type) {
- return type == this;
+ // INodeAdapter implementation
+ public boolean isAdapterForType(Object type) {
+ return type == this;
+ }
+
+ // FIX Fox JBIDE-1479 added by Max Areshkau
+ public void notifyChanged(final INodeNotifier notifier,
+ final int eventType, final Object feature, final Object oldValue,
+ final Object newValue, final int pos) {
+
+ // start job when we modify file in ui thread, without this code
+ // changes will be applied with 1 second delay
+ Display display = null;
+ if (PlatformUI.isWorkbenchRunning())
+ display = PlatformUI.getWorkbench().getDisplay();
+
+ if (display != null && (Thread.currentThread() == display.getThread())) {
+ notifyChangedInUiThread(notifier, eventType, feature, oldValue,
+ newValue, pos);
+ return;
}
- //FIX Fox JBIDE-1479 added by Max Areshkau
- public void notifyChanged(final INodeNotifier notifier, final int eventType,final Object feature,final Object oldValue,final Object newValue, final int pos) {
+ // start job when we modify file in non ui thread
+ if (job != null) {
+ job.cancel();
+ }
- //start job when we modify file in ui thread, without this code
- //changes will be applied with 1 second delay
- Display display = null;
- if (PlatformUI.isWorkbenchRunning())
- display= PlatformUI.getWorkbench().getDisplay();
-
- if (display != null && (Thread.currentThread() == display.getThread())) {
- notifyChangedInUiThread(notifier, eventType, feature, oldValue, newValue, pos);
- return;
- }
- //start job when we modify file in non ui thread
- if(job!=null) {
- job.cancel();
+ job = new UIJob("NotifyChangedJob") {
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ // we checks is job was canceled and if is it true we cancel job
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ } else {
+ notifyChangedInUiThread(notifier, eventType, feature,
+ oldValue, newValue, pos);
}
+ return Status.OK_STATUS;
+ }
+ };
+ job.setPriority(Job.LONG);
+ job.schedule(1000L);
+ }
- job = new UIJob("NotifyChangedJob"){
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- //we checks is job was canceled and if is it true we cancel job
- if(monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
- } else {
- notifyChangedInUiThread(notifier, eventType, feature, oldValue, newValue, pos);
- }
- return Status.OK_STATUS;
- }};
- job.setPriority(Job.LONG);
- job.schedule(1000L);
- }
-
- public void notifyChangedInUiThread(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int pos) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
+ public void notifyChangedInUiThread(INodeNotifier notifier, int eventType,
+ Object feature, Object oldValue, Object newValue, int pos) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
+ }
+ if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
+ printSourceEvent(notifier, eventType, feature, oldValue, newValue,
+ pos);
+ }
+ if (visualBuilder == null) {
+ return;
+ }
+ // visualBuilder.rebuildFlag = false;
+
+ switch (eventType) {
+ case INodeNotifier.CHANGE:
+ sourceChangeFlag = true;
+ int type = ((Node) notifier).getNodeType();
+ visualEditor.hideResizer();
+ visualBuilder.setSelectionRectangle(null);
+ if (type == Node.TEXT_NODE) {
+ boolean update = visualBuilder.setText((Node) notifier);
+ visualEditor.showResizer();
+ // Added by Max Areshkau JBIDE-1554
+ if (!update)
+ visualBuilder.updateNode((Node) notifier);
+ } else if (type == Node.COMMENT_NODE) {
+ if ("yes".equals(VpePreference.SHOW_COMMENTS.getValue())) { //$NON-NLS-1$
+ visualBuilder.setSelectionRectangle(null);
+ visualBuilder.updateNode((Node) notifier);
}
- if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
- printSourceEvent(notifier, eventType, feature, oldValue, newValue, pos);
+ } else if (feature != null
+ && ((Node) feature).getNodeType() == Node.ATTRIBUTE_NODE) {
+ if (newValue != null) {
+ String attrName = ((Attr) feature).getName();
+ if ((Attr) feature == lastRemovedAttr
+ && !attrName.equals(lastRemovedAttrName)) {
+ lastRemovedAttr = null;
+ visualBuilder.removeAttribute((Element) notifier,
+ lastRemovedAttrName);
+ }
+ visualBuilder.setAttribute((Element) notifier,
+ ((Attr) feature).getName(), (String) newValue);
+ } else {
+ lastRemovedAttr = (Attr) feature;
+ lastRemovedAttrName = ((Attr) feature).getName();
+ visualBuilder.removeAttribute((Element) notifier,
+ lastRemovedAttrName);
}
- if(visualBuilder==null) {
- return;
- }
-// visualBuilder.rebuildFlag = false;
-
- switch (eventType) {
- case INodeNotifier.CHANGE:
- sourceChangeFlag = true;
- int type = ((Node)notifier).getNodeType();
- visualEditor.hideResizer();
- visualBuilder.setSelectionRectangle(null);
- if (type == Node.TEXT_NODE) {
- boolean update = visualBuilder.setText((Node)notifier);
- visualEditor.showResizer();
- //Added by Max Areshkau JBIDE-1554
- if (!update) visualBuilder.updateNode((Node)notifier);
- } else if (type == Node.COMMENT_NODE) {
- if("yes".equals(VpePreference.SHOW_COMMENTS.getValue())) { //$NON-NLS-1$
- visualBuilder.setSelectionRectangle(null);
- visualBuilder.updateNode((Node)notifier);
- }
- } else if (feature != null && ((Node)feature).getNodeType() == Node.ATTRIBUTE_NODE) {
- if (newValue != null) {
- String attrName = ((Attr)feature).getName();
- if ((Attr)feature == lastRemovedAttr && !attrName.equals(lastRemovedAttrName)) {
- lastRemovedAttr = null;
- visualBuilder.removeAttribute((Element)notifier, lastRemovedAttrName);
- }
- visualBuilder.setAttribute((Element)notifier, ((Attr)feature).getName(), (String)newValue);
- } else {
- lastRemovedAttr = (Attr)feature;
- lastRemovedAttrName = ((Attr)feature).getName();
- visualBuilder.removeAttribute((Element)notifier, lastRemovedAttrName);
- }
- }
- visualEditor.showResizer();
- break;
+ }
+ visualEditor.showResizer();
+ break;
- case INodeNotifier.ADD:
- //we should remove all parent nodes from vpe cash
- visualBuilder.removeNode((Node)newValue);
- break;
-
- case INodeNotifier.REMOVE:
- visualBuilder.stopToggle((Node)feature);
- visualBuilder.removeNode((Node)feature);
- break;
-
- case INodeNotifier.STRUCTURE_CHANGED:
- visualEditor.hideResizer();
- visualBuilder.setSelectionRectangle(null);
- visualBuilder.updateNode((Node)notifier);
- break;
- case INodeNotifier.CONTENT_CHANGED:
- if (!sourceChangeFlag) {
- if (feature != null && ((Node)feature).getNodeType() == Node.TEXT_NODE) {
- //if (((Node)notifier).getNodeName().equalsIgnoreCase("style")) {
- visualEditor.hideResizer();
- visualBuilder.setSelectionRectangle(null);
- visualBuilder.setText((Node)feature);
- visualEditor.showResizer();
- //}
- }
- } else {
- sourceChangeFlag = false;
- }
- break;
+ case INodeNotifier.ADD:
+ // we should remove all parent nodes from vpe cash
+ visualBuilder.removeNode((Node) newValue);
+ break;
+
+ case INodeNotifier.REMOVE:
+ visualBuilder.stopToggle((Node) feature);
+ visualBuilder.removeNode((Node) feature);
+ break;
+
+ case INodeNotifier.STRUCTURE_CHANGED:
+ visualEditor.hideResizer();
+ visualBuilder.setSelectionRectangle(null);
+ visualBuilder.updateNode((Node) notifier);
+ break;
+ case INodeNotifier.CONTENT_CHANGED:
+ if (!sourceChangeFlag) {
+ if (feature != null
+ && ((Node) feature).getNodeType() == Node.TEXT_NODE) {
+ // if
+ // (((Node)notifier).getNodeName().equalsIgnoreCase("style"))
+ // {
+ visualEditor.hideResizer();
+ visualBuilder.setSelectionRectangle(null);
+ visualBuilder.setText((Node) feature);
+ visualEditor.showResizer();
+ // }
}
- switcher.stopActiveEditor();
+ } else {
+ sourceChangeFlag = false;
+ }
+ break;
}
+ switcher.stopActiveEditor();
+ }
- // INodeSelectionListener implementation
- public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- List<?> nodes = event.getSelectedNodes();
- if (nodes != null && nodes.size() > 0) {
- Node sourceNode = (Node)nodes.get(0);
- if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> nodeSelectionChanged sourceNode: " + sourceNode.getNodeName() + " " + event.getCaretPosition()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (event.getSource() instanceof IContentOutlinePage) {
- sourceSelectionChanged();
- }
- }
- switcher.stopActiveEditor();
+ // INodeSelectionListener implementation
+ public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
+ List<?> nodes = event.getSelectedNodes();
+ if (nodes != null && nodes.size() > 0) {
+ Node sourceNode = (Node) nodes.get(0);
+ if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
+ System.out
+ .println(">>>>>>>>>>>>>> nodeSelectionChanged sourceNode: " + sourceNode.getNodeName() + " " + event.getCaretPosition()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (event.getSource() instanceof IContentOutlinePage) {
+ sourceSelectionChanged();
+ }
+ }
+ switcher.stopActiveEditor();
+ }
- // ITextSelectionListener implementation
- //TODO Max Areshau looks like this method don't used
- public void textSelectionChanged(TextSelectionChangedEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> textSelectionChanged " + event.getSource()); //$NON-NLS-1$
- }
-// if (event.getSource() instanceof StyledText) {
- sourceSelectionChanged();
-// }
- switcher.stopActiveEditor();
+ // ITextSelectionListener implementation
+ // TODO Max Areshau looks like this method don't used
+ public void textSelectionChanged(TextSelectionChangedEvent event) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
+ if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
+ System.out
+ .println(">>>>>>>>>>>>>> textSelectionChanged " + event.getSource()); //$NON-NLS-1$
+ }
+ // if (event.getSource() instanceof StyledText) {
+ sourceSelectionChanged();
+ // }
+ switcher.stopActiveEditor();
+ }
- // SelectionListener implementation
- public void widgetSelected(SelectionEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> widgetSelected"); //$NON-NLS-1$
- }
- if (event.getSource() instanceof StyledText) {
- sourceSelectionChanged();
- }
- switcher.stopActiveEditor();
+ // SelectionListener implementation
+ public void widgetSelected(SelectionEvent event) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
+ if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
+ System.out.println(">>>>>>>>>>>>>> widgetSelected"); //$NON-NLS-1$
+ }
+ if (event.getSource() instanceof StyledText) {
+ sourceSelectionChanged();
+ }
+ switcher.stopActiveEditor();
+ }
- public void widgetDefaultSelected(SelectionEvent event) {
- if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> widgetDefaultSelected"); //$NON-NLS-1$
- }
+ public void widgetDefaultSelected(SelectionEvent event) {
+ if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
+ System.out.println(">>>>>>>>>>>>>> widgetDefaultSelected"); //$NON-NLS-1$
}
-
- public void sourceSelectionChanged() {
- sourceSelectionChanged(false);
+ }
+
+ public void sourceSelectionChanged() {
+ sourceSelectionChanged(false);
+ }
+
+ public void sourceSelectionChanged(boolean showCaret) {
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ int anchorPosition = range.x;
+ int focusPosition = range.x + range.y;
+
+ boolean extendFlag = range.y != 0;
+ boolean reversionFlag = extendFlag
+ && anchorPosition == VpeSelectionHelper
+ .getCaretOffset(sourceEditor);
+ if (reversionFlag) {
+ anchorPosition = focusPosition;
+ focusPosition = range.x;
}
-
- public void sourceSelectionChanged(boolean showCaret) {
- Point range = sourceEditor.getTextViewer().getSelectedRange();
- int anchorPosition = range.x;
- int focusPosition = range.x + range.y;
-
- boolean extendFlag = range.y != 0;
- boolean reversionFlag = extendFlag && anchorPosition == VpeSelectionHelper.getCaretOffset(sourceEditor);
- if (reversionFlag) {
- anchorPosition = focusPosition;
- focusPosition = range.x;
- }
-
- VpeTemplate template = TemplateManagingUtil
- .getTemplateBySourceSelection(pageContext, focusPosition,
- anchorPosition);
-
- if (template instanceof ITemplateSelectionManager) {
- ((ITemplateSelectionManager) template).setSelectionBySource(
- pageContext, visualSelectionController, focusPosition,
- anchorPosition);
- return;
- }
- Node focusNode = getSourceNodeAt(focusPosition);
- if (focusNode == null) {
- return;
+ VpeTemplate template = TemplateManagingUtil
+ .getTemplateBySourceSelection(pageContext, focusPosition,
+ anchorPosition);
+
+ if (template instanceof ITemplateSelectionManager) {
+ ((ITemplateSelectionManager) template).setSelectionBySource(
+ pageContext, visualSelectionController, focusPosition,
+ anchorPosition);
+ return;
+ }
+
+ Node focusNode = getSourceNodeAt(focusPosition);
+ if (focusNode == null) {
+ return;
+ }
+ int focusOffset = getSourceNodeOffset(focusNode, focusPosition,
+ extendFlag && !reversionFlag);
+ Node anchorNode = null;
+ int anchorOffset = 0;
+ if (extendFlag) {
+ anchorNode = getSourceNodeAt(anchorPosition);
+ anchorOffset = getSourceNodeOffset(anchorNode, anchorPosition,
+ reversionFlag);
+ } else {
+ anchorNode = focusNode;
+ anchorOffset = focusOffset;
+ }
+
+ if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
+ System.out.println("sourceSelectionChanged"); //$NON-NLS-1$
+ System.out
+ .println(" anchorNode: " + anchorNode.getNodeName() + " anchorOffset: " + anchorOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out
+ .println(" focusNode: " + focusNode.getNodeName() + " focusOffset: " + focusOffset + " focusPosition: " + focusPosition); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ try {
+ if (anchorNode.getNodeType() == Node.TEXT_NODE
+ || anchorNode.getNodeType() == Node.ATTRIBUTE_NODE) {
+ String text;
+ if (anchorNode.getNodeType() == Node.TEXT_NODE) {
+ IndexedRegion region = (IndexedRegion) anchorNode;
+ text = sourceEditor.getTextViewer().getDocument().get(
+ region.getStartOffset(),
+ region.getEndOffset() - region.getStartOffset());
+ } else {
+ text = ((AttrImpl) anchorNode).getValueRegionText();
}
- int focusOffset = getSourceNodeOffset(focusNode, focusPosition, extendFlag && !reversionFlag);
- Node anchorNode = null;
- int anchorOffset = 0;
- if (extendFlag) {
- anchorNode = getSourceNodeAt(anchorPosition);
- anchorOffset = getSourceNodeOffset(anchorNode, anchorPosition, reversionFlag);
+ anchorOffset = TextUtil.visualPosition(text, anchorOffset);
+ }
+ if (focusNode.getNodeType() == Node.TEXT_NODE
+ || focusNode.getNodeType() == Node.ATTRIBUTE_NODE) {
+ IndexedRegion region = (IndexedRegion) focusNode;
+ String text;
+ if (focusNode.getNodeType() == Node.TEXT_NODE) {
+ text = sourceEditor.getTextViewer().getDocument().get(
+ region.getStartOffset(),
+ region.getEndOffset() - region.getStartOffset());
} else {
- anchorNode = focusNode;
- anchorOffset = focusOffset;
+ text = ((AttrImpl) focusNode).getValueRegionText();
}
+ focusOffset = TextUtil.visualPosition(text, focusOffset);
+ }
+ } catch (Exception ex) {
+ VpePlugin.reportProblem(ex);
+ }
- if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println("sourceSelectionChanged"); //$NON-NLS-1$
- System.out.println(" anchorNode: " + anchorNode.getNodeName() + " anchorOffset: " + anchorOffset); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println(" focusNode: " + focusNode.getNodeName() + " focusOffset: " + focusOffset + " focusPosition: " + focusPosition); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- try{
- if(anchorNode.getNodeType() == Node.TEXT_NODE || anchorNode.getNodeType() == Node.ATTRIBUTE_NODE){
- String text;
- if (anchorNode.getNodeType() == Node.TEXT_NODE) {
- IndexedRegion region = (IndexedRegion)anchorNode;
- text = sourceEditor.getTextViewer().getDocument().get(region.getStartOffset(), region.getEndOffset()-region.getStartOffset());
- } else {
- text = ((AttrImpl)anchorNode).getValueRegionText();
- }
- anchorOffset = TextUtil.visualPosition(text, anchorOffset);
- }
- if(focusNode.getNodeType() == Node.TEXT_NODE || focusNode.getNodeType() == Node.ATTRIBUTE_NODE){
- IndexedRegion region = (IndexedRegion)focusNode;
- String text;
- if (focusNode.getNodeType() == Node.TEXT_NODE) {
- text = sourceEditor.getTextViewer().getDocument().get(region.getStartOffset(), region.getEndOffset()-region.getStartOffset());
- } else {
- text = ((AttrImpl)focusNode).getValueRegionText();
- }
- focusOffset = TextUtil.visualPosition(text, focusOffset);
- }
- }catch(Exception ex){
- VpePlugin.reportProblem(ex);
- }
-
- selectionBuilder.setVisualSelection(anchorNode, anchorOffset, focusNode, focusOffset, reversionFlag, showCaret);
+ selectionBuilder.setVisualSelection(anchorNode, anchorOffset,
+ focusNode, focusOffset, reversionFlag, showCaret);
+ }
+
+ public void sourceSelectionToVisualSelection(boolean showCaret) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
-
- public void sourceSelectionToVisualSelection(boolean showCaret) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- sourceSelectionChanged(showCaret);
- switcher.stopActiveEditor();
+ sourceSelectionChanged(showCaret);
+ switcher.stopActiveEditor();
+ }
+
+ // IModelLifecycleListener implementation
+ public void processPreModelEvent(ModelLifecycleEvent event) {
+ }
+
+ public void processPostModelEvent(ModelLifecycleEvent event) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
- // IModelLifecycleListener implementation
- public void processPreModelEvent(ModelLifecycleEvent event) {
+ /*
+ * Added by Max Areshkau JBIDE-1457 ModelLifecycleEvent.MODEL_RELEASED
+ * generated when model in model calls methods releaseFromRead() or
+ * releaseFromEdit(). When editor is open he has only when href on
+ * model, so nothing can generated this event.When editor closes
+ * generation of this event depends from cantains any service href on
+ * model or not. It's can be a reason of problems on reopen file.
+ *
+ * We shouldn't call here rebuild dom.
+ */
+ if (event.getType() == ModelLifecycleEvent.MODEL_RELEASED) {
+ if (VpeDebug.PRINT_SOURCE_MODEL_LIFECYCLE_EVENT) {
+ System.out
+ .println(">>> processPostModelEvent: " + event.toString()); //$NON-NLS-1$
+ }
+ visualBuilder.setSelectionRectangle(null);
+ IStructuredModel model = event.getModel();
+ model.removeModelLifecycleListener(this);
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ sourceModel.addModelLifecycleListener(this);
+ bundle.clearAll();
+ bundle.refresh();
+ visualBuilder.setSelectionRectangle(null);
+ IDOMDocument sourceDocument = sourceModel.getDocument();
+ // JBIDE-1457
+ // visualBuilder.rebuildDom(sourceDocument);
+ // pageContext.fireTaglibsChanged();
}
+ switcher.stopActiveEditor();
+ }
- public void processPostModelEvent(ModelLifecycleEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- /* Added by Max Areshkau JBIDE-1457
- * ModelLifecycleEvent.MODEL_RELEASED generated when model in
- * model calls methods releaseFromRead() or releaseFromEdit().
- * When editor is open he has only when href on model, so nothing can generated
- * this event.When editor closes generation of this event depends from cantains
- * any service href on model or not. It's can be a reason of problems
- * on reopen file.
- *
- * We shouldn't call here rebuild dom.
- */
- if (event.getType() == ModelLifecycleEvent.MODEL_RELEASED) {
- if (VpeDebug.PRINT_SOURCE_MODEL_LIFECYCLE_EVENT) {
- System.out.println(">>> processPostModelEvent: " + event.toString()); //$NON-NLS-1$
- }
- visualBuilder.setSelectionRectangle(null);
- IStructuredModel model = event.getModel();
- model.removeModelLifecycleListener(this);
- IDOMModel sourceModel = (IDOMModel)getModel();
- sourceModel.addModelLifecycleListener(this);
- bundle.clearAll();
- bundle.refresh();
- visualBuilder.setSelectionRectangle(null);
- IDOMDocument sourceDocument = sourceModel.getDocument();
- // JBIDE-1457
-// visualBuilder.rebuildDom(sourceDocument);
-// pageContext.fireTaglibsChanged();
- }
- switcher.stopActiveEditor();
+ // EditorDomEventListener implementation
+ public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ switcher.stopActiveEditor();
+ }
- // EditorDomEventListener implementation
- public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- switcher.stopActiveEditor();
+ public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ nsIDOMNode targetNode = mutationEvent.getRelatedNode();
+ if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
+ sourceBuilder.addNode(targetNode);
+ visualBuilder.resetPseudoElement(targetNode);
+ }
+ switcher.stopActiveEditor();
+ }
- public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- nsIDOMNode targetNode = mutationEvent.getRelatedNode();
- if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
- sourceBuilder.addNode(targetNode);
- visualBuilder.resetPseudoElement(targetNode);
- }
- switcher.stopActiveEditor();
+ public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
+ if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
+ visualBuilder.setSelectionRectangle(null);
+ sourceBuilder.removeNode(targetNode);
+ visualBuilder.resetPseudoElement(targetNode);
+ }
+ switcher.stopActiveEditor();
+ }
- public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
- if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
- visualBuilder.setSelectionRectangle(null);
- sourceBuilder.removeNode(targetNode);
- visualBuilder.resetPseudoElement(targetNode);
- }
- switcher.stopActiveEditor();
+ public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ switcher.stopActiveEditor();
+ }
- public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- switcher.stopActiveEditor();
+ public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ switcher.stopActiveEditor();
+ }
- public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- switcher.stopActiveEditor();
+ public void attrModified(nsIDOMMutationEvent mutationEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ switcher.stopActiveEditor();
+ }
- public void attrModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- switcher.stopActiveEditor();
+ public void characterDataModified(nsIDOMMutationEvent mutationEvent) {
+
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+ printVisualEvent(mutationEvent);
+ }
+ nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
+ sourceBuilder.setText(targetNode);
+ visualBuilder.resetPseudoElement(targetNode);
+ switcher.stopActiveEditor();
+ }
- public void characterDataModified(nsIDOMMutationEvent mutationEvent) {
-
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
+ public void notifySelectionChanged(nsIDOMDocument doc,
+ nsISelection selection, short reason) {
+ if (switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) > 0;
+ if (mouseUpSelectionReasonFlag
+ || reason == nsISelectionListener.NO_REASON
+ || reason == nsISelectionListener.KEYPRESS_REASON
+ || reason == nsISelectionListener.SELECTALL_REASON
+ || (reason & nsISelectionListener.MOUSEDOWN_REASON) > 0) {
+ if (VpeDebug.PRINT_VISUAL_SELECTION_EVENT) {
+ System.out.println("<<< notifySelectionChanged: " + reason); //$NON-NLS-1$
}
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
- sourceBuilder.setText(targetNode);
- visualBuilder.resetPseudoElement(targetNode);
- switcher.stopActiveEditor();
+ selectionBuilder.setSelection(selection);
+ }
+ switcher.stopActiveEditor();
}
+ }
- public void notifySelectionChanged(nsIDOMDocument doc, nsISelection selection, short reason) {
- if (switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) > 0;
- if (mouseUpSelectionReasonFlag || reason == nsISelectionListener.NO_REASON || reason == nsISelectionListener.KEYPRESS_REASON || reason == nsISelectionListener.SELECTALL_REASON || (reason & nsISelectionListener.MOUSEDOWN_REASON) > 0) {
- if (VpeDebug.PRINT_VISUAL_SELECTION_EVENT) {
- System.out.println("<<< notifySelectionChanged: " + reason); //$NON-NLS-1$
- }
- selectionBuilder.setSelection(selection);
- }
- switcher.stopActiveEditor();
- }
+ public void mouseDown(nsIDOMMouseEvent mouseEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ mouseDownSelectionFlag = false;
- public void mouseDown(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
-
- mouseDownSelectionFlag = false;
-
- VpeTemplate template = TemplateManagingUtil
- .getTemplateByVisualSelection(pageContext, VisualDomUtil
- .getTargetNode(mouseEvent));
-
- if (template instanceof ITemplateSelectionManager) {
+ VpeTemplate template = TemplateManagingUtil
+ .getTemplateByVisualSelection(pageContext, VisualDomUtil
+ .getTargetNode(mouseEvent));
- ((ITemplateSelectionManager) template).setSelectionByMouse(
- pageContext, visualSelectionController, mouseEvent);
-
- mouseDownSelectionFlag = true;
+ if (template instanceof ITemplateSelectionManager) {
- }
- else {
- nsIDOMElement visualDragElement = selectionBuilder.getDragElement(mouseEvent);
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- System.out.println("<<< mouseDown targetNode: " + visualNode.getNodeName() + " (" + visualNode + ") selectedElement: " + (visualDragElement != null ? visualDragElement.getNodeName() + " (" + visualDragElement + ")" : null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
-
- if (visualDragElement != null) {
-
- //we shouldn't change selection when we click on <input type="text" /> element,
- //because if we change after resizing the input element lost selection
- // if(!(HTML.TAG_INPUT.equalsIgnoreCase(visualDragElement.getNodeName())&&
- // HTML.ATTR_TEXT.equalsIgnoreCase(visualDragElement.getAttribute(HTML.ATTR_TYPE))
- // &&visualDragElement.getAttribute(HTML.ATTR_TYPE)!=null)) {
-
- selectionBuilder.setVisualElementSelection(visualDragElement);
- mouseDownSelectionFlag = true;
- // }
- } else {
- selectionBuilder.setCaretAtMouse(mouseEvent);
- }
- }
- switcher.stopActiveEditor();
+ ((ITemplateSelectionManager) template).setSelectionByMouse(
+ pageContext, visualSelectionController, mouseEvent);
+
+ mouseDownSelectionFlag = true;
+
+ } else {
+ nsIDOMElement visualDragElement = selectionBuilder
+ .getDragElement(mouseEvent);
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+ System.out
+ .println("<<< mouseDown targetNode: " + visualNode.getNodeName() + " (" + visualNode + ") selectedElement: " + (visualDragElement != null ? visualDragElement.getNodeName() + " (" + visualDragElement + ")" : null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
+ if (visualDragElement != null) {
+
+ // we shouldn't change selection when we click on <input
+ // type="text" /> element,
+ // because if we change after resizing the input element lost
+ // selection
+ // if(!(HTML.TAG_INPUT.equalsIgnoreCase(visualDragElement.getNodeName())&&
+ // HTML.ATTR_TEXT.equalsIgnoreCase(visualDragElement.getAttribute(HTML.ATTR_TYPE))
+ // &&visualDragElement.getAttribute(HTML.ATTR_TYPE)!=null)) {
+
+ selectionBuilder.setVisualElementSelection(visualDragElement);
+ mouseDownSelectionFlag = true;
+ // }
+ } else {
+ selectionBuilder.setCaretAtMouse(mouseEvent);
+ }
}
+ switcher.stopActiveEditor();
+ }
- public void mouseUp(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
+ public void mouseUp(nsIDOMMouseEvent mouseEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
+ }
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("<<< mouseUp"); //$NON-NLS-1$
+ }
+ if (mouseDownSelectionFlag) {
+ mouseEvent.preventDefault();
+ mouseEvent.stopPropagation();
+ mouseDownSelectionFlag = false;
+ }
+ switcher.stopActiveEditor();
+ }
+
+ public void mouseClick(nsIDOMMouseEvent mouseEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
+ }
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+
+ if (visualNode != null) {
+ if (!mouseUpSelectionReasonFlag) {
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseUp"); //$NON-NLS-1$
+ System.out
+ .println("<<< mouseClick visualNode: " + visualNode.getNodeName() + " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- if (mouseDownSelectionFlag) {
- mouseEvent.preventDefault();
- mouseEvent.stopPropagation();
- mouseDownSelectionFlag = false;
+ if (visualBuilder.isContentArea(visualNode)) {
+ selectionBuilder.setClickContentAreaSelection();
}
- switcher.stopActiveEditor();
+ } else {
+ mouseUpSelectionReasonFlag = false;
+ }
+
+ if (visualBuilder.doToggle(VisualDomUtil.getTargetNode(mouseEvent))) {
+ selectionBuilder.setClickContentAreaSelection();
+ }
}
-
- public void mouseClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
-
- if (visualNode != null) {
- if (!mouseUpSelectionReasonFlag) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseClick visualNode: " + visualNode.getNodeName() + " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- if (visualBuilder.isContentArea(visualNode)) {
- selectionBuilder.setClickContentAreaSelection();
- }
- } else {
- mouseUpSelectionReasonFlag = false;
- }
+ switcher.stopActiveEditor();
+ }
- if (visualBuilder.doToggle(VisualDomUtil.getTargetNode(mouseEvent))) {
- selectionBuilder.setClickContentAreaSelection();
- }
- }
- switcher.stopActiveEditor();
+ public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+ if (visualNode != null) {
+ if (!sourceBuilder.openBundleEditors(visualNode)) {
+ sourceBuilder.openIncludeEditor(visualNode);
+ }
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out
+ .println("<<< mouseDblClick visualNode: " + visualNode.getNodeName() + " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+ switcher.stopActiveEditor();
+ }
- public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- if (visualNode != null) {
- if (!sourceBuilder.openBundleEditors(visualNode)) {
- sourceBuilder.openIncludeEditor(visualNode);
- }
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseDblClick visualNode: " + visualNode.getNodeName() + " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
- switcher.stopActiveEditor();
+ public void mouseMove(nsIDOMMouseEvent mouseEvent) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+ if (visualNode != null) {
+ if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
+ System.out.println("<<< mouseMove visualNode: "
+ + visualNode.getNodeName() + " (" + visualNode + ")");
+ }
+ visualBuilder.setMoveCursor(mouseEvent);
+ }
+ switcher.stopActiveEditor();
+ }
- public void mouseMove(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- if (visualNode != null) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseMove visualNode: " + visualNode.getNodeName() + " (" + visualNode + ")");
- }
- visualBuilder.setMoveCursor(mouseEvent);
- }
- switcher.stopActiveEditor();
+ public void keyPress(nsIDOMKeyEvent keyEvent) {
+ if (VpeDebug.PRINT_VISUAL_KEY_EVENT) {
+ System.out
+ .println("<<< keyPress type: " + keyEvent.getType() + " Ctrl: " + keyEvent.getCtrlKey() + " Shift: " + keyEvent.getShiftKey() + " CharCode: " + keyEvent.getCharCode() + " KeyCode: " + keyEvent.getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
-
- public void keyPress(nsIDOMKeyEvent keyEvent) {
- if (VpeDebug.PRINT_VISUAL_KEY_EVENT) {
- System.out.println("<<< keyPress type: " + keyEvent.getType() + " Ctrl: " + keyEvent.getCtrlKey() + " Shift: " + keyEvent.getShiftKey() + " 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)) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ switcher.stopActiveEditor();
+ return;
+ }
+
+ visualEditor.hideResizer();
+ switcher.stopActiveEditor();
+
+ try {
+ if (visualKeyHandler.keyPressHandler(keyEvent)) {
+ switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
+ // Edward
+ sourceSelectionChanged(true);
+ visualSelectionController.setCaretEnabled(true);
switcher.stopActiveEditor();
- return;
+ } 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 = xulRunnerEditor.getBrowser();
+
+ keyboardEvent.stateMask = (keyEvent.getAltKey() ? SWT.ALT : 0)
+ | (keyEvent.getCtrlKey() ? SWT.CTRL : 0)
+ | (keyEvent.getShiftKey() ? SWT.SHIFT : 0)
+ | (keyEvent.getMetaKey() ? SWT.MOD1 : 0);
+ keyboardEvent.x = 0;
+ keyboardEvent.y = 0;
+ keyboardEvent.type = SWT.KeyDown;
+
+ if (keyEvent.getKeyCode() == 0) {
+
+ keyboardEvent.keyCode = (int) keyEvent.getCharCode();
+ } else {
+ keyboardEvent.keyCode = (int) keyEvent.getKeyCode();
}
-
- visualEditor.hideResizer();
- switcher.stopActiveEditor();
-
- try {
- if (visualKeyHandler.keyPressHandler(keyEvent)) {
- switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
- // Edward
- 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 = xulRunnerEditor.getBrowser();
-
- keyboardEvent.stateMask = (keyEvent.getAltKey() ? SWT.ALT : 0) | (keyEvent.getCtrlKey() ? SWT.CTRL : 0) | (keyEvent.getShiftKey() ? SWT.SHIFT : 0) | (keyEvent.getMetaKey() ? SWT.MOD1 : 0);
- keyboardEvent.x=0;
- keyboardEvent.y=0;
- keyboardEvent.type=SWT.KeyDown;
-
- if(keyEvent.getKeyCode()==0) {
-
- keyboardEvent.keyCode=(int)keyEvent.getCharCode();
- } else{
- keyboardEvent.keyCode=(int)keyEvent.getKeyCode();
- }
-
- // JBIDE-1627
- List<KeyStroke> possibleKeyStrokes = WorkbenchKeyboard.generatePossibleKeyStrokes(keyboardEvent);
- IWorkbench iWorkbench = VpePlugin.getDefault().getWorkbench();
- if(iWorkbench.hasService(IBindingService.class)){
- IBindingService iBindingService = (IBindingService) iWorkbench.getService(IBindingService.class);
+ // JBIDE-1627
+ List<KeyStroke> 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<KeyStroke> iterator = possibleKeyStrokes.iterator(); iterator
- .hasNext();){
- KeySequence sequenceAfterKeyStroke = KeySequence.getInstance(
- sequenceBeforeKeyStroke, iterator.next());
- if(iBindingService.isPerfectMatch(sequenceAfterKeyStroke)){
- final Binding binding = iBindingService.getPerfectMatch(sequenceAfterKeyStroke);
-
- if((binding!=null)
- && (binding.getParameterizedCommand()!=null)
- && (binding.getParameterizedCommand().getCommand()!=null)
- && ContentAssistCommandAdapter.CONTENT_PROPOSAL_COMMAND.equals(binding.getParameterizedCommand().getCommand().getId())){
- keyboardEvent.type = SWT.NONE;
- }
- }
- }
- }
- //sends xulrunner event to eclipse environment
- getXulRunnerEditor().getBrowser().notifyListeners(keyboardEvent.type, keyboardEvent);
-
+ KeySequence sequenceBeforeKeyStroke = KeySequence
+ .getInstance();
+ for (Iterator<KeyStroke> iterator = possibleKeyStrokes
+ .iterator(); iterator.hasNext();) {
+ KeySequence sequenceAfterKeyStroke = KeySequence
+ .getInstance(sequenceBeforeKeyStroke, iterator
+ .next());
+ if (iBindingService
+ .isPerfectMatch(sequenceAfterKeyStroke)) {
+ final Binding binding = iBindingService
+ .getPerfectMatch(sequenceAfterKeyStroke);
+
+ if ((binding != null)
+ && (binding.getParameterizedCommand() != null)
+ && (binding.getParameterizedCommand()
+ .getCommand() != null)
+ && ContentAssistCommandAdapter.CONTENT_PROPOSAL_COMMAND
+ .equals(binding
+ .getParameterizedCommand()
+ .getCommand().getId())) {
+ keyboardEvent.type = SWT.NONE;
+ }
}
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- visualRefresh();
+ }
}
+ // sends xulrunner event to eclipse environment
+ getXulRunnerEditor().getBrowser().notifyListeners(
+ keyboardEvent.type, keyboardEvent);
+ }
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ visualRefresh();
}
- public void elementResized(nsIDOMElement element, int resizerConstrains, int top, int left, int width, int height) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- visualEditor.hideResizer();
- switcher.stopActiveEditor();
+ }
- visualBuilder.resize(element, resizerConstrains, top, left, width, height);
- sourceSelectionChanged();
+ public void elementResized(nsIDOMElement element, int resizerConstrains,
+ int top, int left, int width, int height) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
-
- public void dragGesture(nsIDOMEvent domEvent) {
+ visualEditor.hideResizer();
+ switcher.stopActiveEditor();
- nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- boolean canDragFlag = canInnerDrag(mouseEvent);
- //start drag sessionvpe-element
- if(canDragFlag) {
- startDragSession(domEvent);
- }
+ visualBuilder.resize(element, resizerConstrains, top, left, width,
+ height);
+ sourceSelectionChanged();
+ }
+
+ public void dragGesture(nsIDOMEvent domEvent) {
+
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ boolean canDragFlag = canInnerDrag(mouseEvent);
+ // start drag sessionvpe-element
+ if (canDragFlag) {
+ startDragSession(domEvent);
}
-
- private void createMenuForNode(Node node, MenuManager manager) {
- createMenuForNode(node, manager, false);
- }
-
- private void createMenuForNode(Node node, MenuManager manager, boolean topLevelFlag) {
- NodeActionManager.setTextNodeSplitter(null);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(node);
- if (elementMapping != null && elementMapping.getTemplate() != null) {
- manager.add(new VpeAction("<"+node.getNodeName()+"> Attributes", node) { //$NON-NLS-1$ //$NON-NLS-2$
- public void run() {
- showProperties(actionNode);
- }
- });
-
- if (!topLevelFlag) {
- manager.add(new VpeAction("Select This Tag", node) { //$NON-NLS-1$
- public void run() {
- selectionBuilder.setVisualSelection(actionNode,0,actionNode,0,false,true);
+ }
- }
- });
+ private void createMenuForNode(Node node, MenuManager manager) {
+ createMenuForNode(node, manager, false);
+ }
+
+ private void createMenuForNode(Node node, MenuManager manager,
+ boolean topLevelFlag) {
+ NodeActionManager.setTextNodeSplitter(null);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(node);
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ manager.add(new VpeAction(
+ "<" + node.getNodeName() + "> Attributes", node) { //$NON-NLS-1$ //$NON-NLS-2$
+ public void run() {
+ showProperties(actionNode);
+ }
+ });
+
+ if (!topLevelFlag) {
+ manager.add(new VpeAction("Select This Tag", node) { //$NON-NLS-1$
+ public void run() {
+ selectionBuilder.setVisualSelection(
+ actionNode, 0, actionNode, 0,
+ false, true);
+
}
- Node parent = node.getParentNode();
- if(parent != null && parent.getNodeType() == Node.ELEMENT_NODE){
- MenuManager menuManager = new MenuManager("Parent Tag"); //$NON-NLS-1$
- menuManager.setParent(manager);
- manager.add(menuManager);
- createMenuForNode(parent, menuManager);
- }
-
- manager.add(new Separator());
- }
+ });
}
- NodeActionManager actionManager = new NodeActionManager(getModel(), null);
-
- if (node.getNodeType() == Node.TEXT_NODE) {
- Point range = sourceEditor.getTextViewer().getSelectedRange();
- TextNodeSplitterImpl splitter = new TextNodeSplitterImpl(range, (Text)node);
- NodeActionManager.setTextNodeSplitter(splitter);
+ Node parent = node.getParentNode();
+ if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
+ MenuManager menuManager = new MenuManager("Parent Tag"); //$NON-NLS-1$
+ menuManager.setParent(manager);
+ manager.add(menuManager);
+ createMenuForNode(parent, menuManager);
}
-
- if (actionManager != null) {
- StructuredSelection structuredSelection = new StructuredSelection(node);
- actionManager.fillContextMenuForVpe(manager, structuredSelection);
-
- }
+ manager.add(new Separator());
+ }
+ }
+ NodeActionManager actionManager = new NodeActionManager(getModel(),
+ null);
- IContributionItem[] items = manager.getItems();
-
- for(int i=0;i< items.length;i++){
- if(items[i] instanceof MenuManager){
- MenuManager mm = (MenuManager)items[i];
- if(NodeActionManager.INSERT_AROUND_MENU.equals(mm.getMenuText())){
- listenContextMenu(mm, (IndexedRegion)node, AROUND_MENU);
- }else if(NodeActionManager.INSERT_BEFORE_MENU.equals(mm.getMenuText())){
- listenContextMenu(mm, (IndexedRegion)node, BEFORE_MENU);
- }else if(NodeActionManager.INSERT_AFTER_MENU.equals(mm.getMenuText())){
- listenContextMenu(mm, (IndexedRegion)node, AFTER_MENU);
- }
- }
+ if (node.getNodeType() == Node.TEXT_NODE) {
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ TextNodeSplitterImpl splitter = new TextNodeSplitterImpl(range,
+ (Text) node);
+ NodeActionManager.setTextNodeSplitter(splitter);
+ }
+
+ if (actionManager != null) {
+ StructuredSelection structuredSelection = new StructuredSelection(
+ node);
+ actionManager.fillContextMenuForVpe(manager, structuredSelection);
+
+ }
+
+ IContributionItem[] items = manager.getItems();
+
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] instanceof MenuManager) {
+ MenuManager mm = (MenuManager) items[i];
+ if (NodeActionManager.INSERT_AROUND_MENU.equals(mm
+ .getMenuText())) {
+ listenContextMenu(mm, (IndexedRegion) node, AROUND_MENU);
+ } else if (NodeActionManager.INSERT_BEFORE_MENU.equals(mm
+ .getMenuText())) {
+ listenContextMenu(mm, (IndexedRegion) node, BEFORE_MENU);
+ } else if (NodeActionManager.INSERT_AFTER_MENU.equals(mm
+ .getMenuText())) {
+ listenContextMenu(mm, (IndexedRegion) node, AFTER_MENU);
}
-
- manager.add(new Separator());
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- VpeElementMapping elementMapping = (VpeElementMapping)domMapping.getNodeMapping(node);
- if (elementMapping != null && elementMapping.getTemplate() != null && elementMapping.getTemplate().getType() == VpeHtmlTemplate.TYPE_ANY) {
- final VpeTemplate selectedTemplate = elementMapping.getTemplate();
- manager.add(new VpeAction("Template", node) { //$NON-NLS-1$
- public void run() {
- boolean isCorrectNS = pageContext.isCorrectNS(actionNode);
- VpeAnyData data = null;
- if (isCorrectNS) {
- data = selectedTemplate.getAnyData();
- data.setUri(pageContext.getSourceTaglibUri(actionNode));
- data.setName(actionNode.getNodeName());
- }
- data = editAnyData(sourceEditor, isCorrectNS, data);
- if (data != null && data.isChanged()) templateManager.setAnyTemplate(data);
- }
- });
+ }
+ }
- manager.add(new Separator());
- }
-
-
- manager.add(new VpeTextOperationAction("Cut", ActionFactory.CUT.getId(), (IndexedRegion)node)); //$NON-NLS-1$
- manager.add(new VpeTextOperationAction("Copy", ActionFactory.COPY.getId(), (IndexedRegion)node)); //$NON-NLS-1$
- manager.add(new VpeTextOperationAction("Paste", ActionFactory.PASTE.getId(), (IndexedRegion)node)); //$NON-NLS-1$
- }else if(node.getNodeType() == Node.TEXT_NODE){
- manager.add(new Action("Cut") { //$NON-NLS-1$
- public void run() {
- sourceEditor.getAction(ActionFactory.CUT.getId()).run();
+ manager.add(new Separator());
+
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(node);
+ if (elementMapping != null
+ && elementMapping.getTemplate() != null
+ && elementMapping.getTemplate().getType() == VpeHtmlTemplate.TYPE_ANY) {
+ final VpeTemplate selectedTemplate = elementMapping
+ .getTemplate();
+ manager.add(new VpeAction("Template", node) { //$NON-NLS-1$
+ public void run() {
+ boolean isCorrectNS = pageContext
+ .isCorrectNS(actionNode);
+ VpeAnyData data = null;
+ if (isCorrectNS) {
+ data = selectedTemplate.getAnyData();
+ data.setUri(pageContext
+ .getSourceTaglibUri(actionNode));
+ data.setName(actionNode.getNodeName());
}
+ data = editAnyData(sourceEditor, isCorrectNS,
+ data);
+ if (data != null && data.isChanged())
+ templateManager.setAnyTemplate(data);
+ }
});
- manager.add(new Action("Copy") { //$NON-NLS-1$
- public void run() {
- sourceEditor.getAction(ActionFactory.COPY.getId()).run();
- }
- });
- manager.add(new Action("Paste") { //$NON-NLS-1$
- public void run() {
- sourceEditor.getAction(ActionFactory.PASTE.getId()).run();
- }
- });
- }
+
manager.add(new Separator());
-
- if (actionManager != null) {
- StructuredSelection structuredSelection = node.getNodeType() == Node.ELEMENT_NODE ? new StructuredSelection(node) : null;
- actionManager.addContextMenuForVpe(manager, structuredSelection);
- }
-
- if(node.getNodeType() == Node.ELEMENT_NODE){
- boolean stripEnable = false;
- NodeImpl impl = (NodeImpl)node;
- if(impl.isContainer()){
- NodeList list = impl.getChildNodes();
- if(list.getLength() > 0){
- if(list.getLength() == 1){
- Node child = list.item(0);
- if(child.getNodeType() == Node.TEXT_NODE){
- if("".equals(child.getNodeValue().trim()))stripEnable = false; //$NON-NLS-1$
- else stripEnable = true;
- }else stripEnable = true;
- }else stripEnable = true;
- }
+ }
+
+ manager.add(new VpeTextOperationAction(
+ "Cut", ActionFactory.CUT.getId(), (IndexedRegion) node)); //$NON-NLS-1$
+ manager.add(new VpeTextOperationAction(
+ "Copy", ActionFactory.COPY.getId(), (IndexedRegion) node)); //$NON-NLS-1$
+ manager
+ .add(new VpeTextOperationAction(
+ "Paste", ActionFactory.PASTE.getId(), (IndexedRegion) node)); //$NON-NLS-1$
+ } else if (node.getNodeType() == Node.TEXT_NODE) {
+ manager.add(new Action("Cut") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor.getAction(ActionFactory.CUT.getId())
+ .run();
}
- if(stripEnable)
- manager.add(new VpeAction("Strip Tag", node) { //$NON-NLS-1$
- public void run() {
- Node parent = actionNode.getParentNode();
- if(parent != null){
- int index = ((NodeImpl)actionNode).getIndex();
- parent.removeChild(actionNode);
- NodeList children = actionNode.getChildNodes();
- int lengh = children.getLength();
- Node child;
- for(int i=0; i < lengh; i++){
- child = children.item(0);
- actionNode.removeChild(child);
- insertNode(parent, child, index++);
- }
- }
- }
-
- private void insertNode(Node parent, Node node, int index){
- Node oldNode=null;
- int childSize = parent.getChildNodes().getLength();
-
- if(index <= (childSize-1))oldNode = parent.getChildNodes().item(index);
- if(oldNode != null)parent.insertBefore(node, oldNode);
- else parent.appendChild(node);
- }
- });
+ });
+ manager.add(new Action("Copy") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor.getAction(ActionFactory.COPY.getId())
+ .run();
+ }
+ });
+ manager.add(new Action("Paste") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor.getAction(ActionFactory.PASTE.getId())
+ .run();
+ }
+ });
+ }
+ manager.add(new Separator());
+
+ if (actionManager != null) {
+ StructuredSelection structuredSelection = node.getNodeType() == Node.ELEMENT_NODE ? new StructuredSelection(
+ node)
+ : null;
+ actionManager.addContextMenuForVpe(manager, structuredSelection);
+ }
+
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ boolean stripEnable = false;
+ NodeImpl impl = (NodeImpl) node;
+ if (impl.isContainer()) {
+ NodeList list = impl.getChildNodes();
+ if (list.getLength() > 0) {
+ if (list.getLength() == 1) {
+ Node child = list.item(0);
+ if (child.getNodeType() == Node.TEXT_NODE) {
+ if ("".equals(child.getNodeValue().trim()))stripEnable = false; //$NON-NLS-1$
+ else
+ stripEnable = true;
+ } else
+ stripEnable = true;
+ } else
+ stripEnable = true;
}
- if(node.getNodeType() == Node.TEXT_NODE){
- manager.add(new Action("Delete") { //$NON-NLS-1$
- public void run() {
- sourceEditor.getAction(ActionFactory.DELETE.getId()).run();
+ }
+ if (stripEnable)
+ manager.add(new VpeAction("Strip Tag", node) { //$NON-NLS-1$
+ public void run() {
+ Node parent = actionNode.getParentNode();
+ if (parent != null) {
+ int index = ((NodeImpl) actionNode)
+ .getIndex();
+ parent.removeChild(actionNode);
+ NodeList children = actionNode
+ .getChildNodes();
+ int lengh = children.getLength();
+ Node child;
+ for (int i = 0; i < lengh; i++) {
+ child = children.item(0);
+ actionNode.removeChild(child);
+ insertNode(parent, child, index++);
+ }
}
- });
- }
+ }
- if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_SOURCE) {
- manager.add(new Action("Dump Source") { //$NON-NLS-1$
- public void run() {
- DOMTreeDumper dumper = new DOMTreeDumper(VpeDebug.VISUAL_DUMP_PRINT_HASH);
- dumper.dumpToStream(System.out, visualEditor.getDomDocument());
- }
+ private void insertNode(Node parent, Node node,
+ int index) {
+ Node oldNode = null;
+ int childSize = parent.getChildNodes()
+ .getLength();
+
+ if (index <= (childSize - 1))
+ oldNode = parent.getChildNodes()
+ .item(index);
+ if (oldNode != null)
+ parent.insertBefore(node, oldNode);
+ else
+ parent.appendChild(node);
+ }
});
- }
-
- if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_MAPPING) {
- manager.add(new Action("Dump Mapping") { //$NON-NLS-1$
- public void run() {
- printMapping();
- }
- });
- }
-
- if (VpeDebug.VISUAL_CONTEXTMENU_TEST) {
- manager.add(new VpeAction("Test", node) { //$NON-NLS-1$
- public void run() {
- test(actionNode);
- }
- });
- }
}
-
- /**
- * Calls when on when browser receive context menu event.
- *
- * @param contextFlags -not used in this function, just for becouse this parametr
- * exist in nsIContextMenuListener
- * @param event event from browser used here
- * @param node where this event are occur
- */
- public void onShowContextMenu(long contextFlags, nsIDOMEvent event, nsIDOMNode node) {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
-
- if (visualNode != null) {
- Node selectedSourceNode = null;
- selectedSourceNode = selectionBuilder.setContextMenuSelection(visualNode);
- if (selectedSourceNode != null) {
+ if (node.getNodeType() == Node.TEXT_NODE) {
+ manager.add(new Action("Delete") { //$NON-NLS-1$
+ public void run() {
+ sourceEditor
+ .getAction(ActionFactory.DELETE.getId())
+ .run();
+ }
+ });
+ }
- MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
- final Menu contextMenu = menuManager.createContextMenu(visualEditor.getControl());
- contextMenu.addMenuListener(
- new MenuListener(){
- Menu menu = contextMenu;
- public void menuHidden(MenuEvent e) {
- Display.getCurrent().asyncExec(
- new Runnable() {
- public void run() {
- menu.dispose();
- }
- }
- );
- }
- public void menuShown(MenuEvent e) {
- }
- }
- );
- createMenuForNode(selectedSourceNode, menuManager, true);
-
- contextMenu.setVisible(true);
-
+ if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_SOURCE) {
+ manager.add(new Action("Dump Source") { //$NON-NLS-1$
+ public void run() {
+ DOMTreeDumper dumper = new DOMTreeDumper(
+ VpeDebug.VISUAL_DUMP_PRINT_HASH);
+ dumper.dumpToStream(System.out, visualEditor
+ .getDomDocument());
}
- }
+ });
}
-
- private VpeAnyData editAnyData(StructuredTextEditor sourceEditor, boolean isCorrectNS, VpeAnyData data) {
- Shell shell = sourceEditor.getEditorPart().getSite().getShell();
- if (isCorrectNS) {
- VpeEditAnyDialog editDialog = new VpeEditAnyDialog(shell, data);
- editDialog.open();
- } else {
- MessageBox message = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
- message.setMessage(VpeUIMessages.NAMESPACE_NOT_DEFINED);
- message.open();
- }
- return data;
+ if (VpeDebug.VISUAL_CONTEXTMENU_DUMP_MAPPING) {
+ manager.add(new Action("Dump Mapping") { //$NON-NLS-1$
+ public void run() {
+ printMapping();
+ }
+ });
}
- // VpeTemplateListener implementation
- public void templateReloaded() {
- visualRefresh();
+ if (VpeDebug.VISUAL_CONTEXTMENU_TEST) {
+ manager.add(new VpeAction("Test", node) { //$NON-NLS-1$
+ public void run() {
+ test(actionNode);
+ }
+ });
}
-
+ }
- public void visualRefresh() {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- visualRefreshImpl();
+ /**
+ * Calls when on when browser receive context menu event.
+ *
+ * @param contextFlags
+ * -not used in this function, just for becouse this parametr
+ * exist in nsIContextMenuListener
+ * @param event
+ * event from browser used here
+ * @param node
+ * where this event are occur
+ */
+ public void onShowContextMenu(long contextFlags, nsIDOMEvent event,
+ nsIDOMNode node) {
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
- switcher.stopActiveEditor();
+ if (visualNode != null) {
+ Node selectedSourceNode = null;
+ selectedSourceNode = selectionBuilder
+ .setContextMenuSelection(visualNode);
+ if (selectedSourceNode != null) {
+
+ MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
+ final Menu contextMenu = menuManager
+ .createContextMenu(visualEditor.getControl());
+ contextMenu.addMenuListener(new MenuListener() {
+ Menu menu = contextMenu;
+
+ public void menuHidden(MenuEvent e) {
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ menu.dispose();
+ }
+ });
+ }
+
+ public void menuShown(MenuEvent e) {
+ }
+ });
+ createMenuForNode(selectedSourceNode, menuManager, true);
+
+ contextMenu.setVisible(true);
+
+ }
}
-
- void visualRefreshImpl() {
- visualEditor.hideResizer();
- visualBuilder.setSelectionRectangle(null);
- IDOMModel sourceModel = (IDOMModel)getModel();
- if (sourceModel != null) {
- IDOMDocument sourceDocument = sourceModel.getDocument();
- visualBuilder.rebuildDom(sourceDocument);
- } else {
- visualBuilder.rebuildDom(null);
- }
+ }
+
+ private VpeAnyData editAnyData(StructuredTextEditor sourceEditor,
+ boolean isCorrectNS, VpeAnyData data) {
+ Shell shell = sourceEditor.getEditorPart().getSite().getShell();
+ if (isCorrectNS) {
+ VpeEditAnyDialog editDialog = new VpeEditAnyDialog(shell, data);
+ editDialog.open();
+ } else {
+ MessageBox message = new MessageBox(shell, SWT.ICON_WARNING
+ | SWT.OK);
+ message.setMessage(VpeUIMessages.NAMESPACE_NOT_DEFINED);
+ message.open();
}
-
- public void preLongOperation() {
- switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
+ return data;
+ }
+
+ // VpeTemplateListener implementation
+ public void templateReloaded() {
+ visualRefresh();
+ }
+
+ public void visualRefresh() {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
+ visualRefreshImpl();
- public void postLongOperation() {
- switcher.stopActiveEditor();
- visualRefresh();
+ switcher.stopActiveEditor();
+ }
+
+ void visualRefreshImpl() {
+ visualEditor.hideResizer();
+ visualBuilder.setSelectionRectangle(null);
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel != null) {
+ IDOMDocument sourceDocument = sourceModel.getDocument();
+ visualBuilder.rebuildDom(sourceDocument);
+ } else {
+ visualBuilder.rebuildDom(null);
}
-
- // for debug
- private void printSourceEvent(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int pos) {
- System.out.println(">>> eventType: " + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " pos: " + pos + " notifier: " + ((Node)notifier).getNodeName() + " hashCode: " + notifier.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (feature != null) {
- if (feature instanceof Node) {
- System.out.println(" feature: " + ((Node)feature).getNodeType() + " " + ((Node)feature).getNodeName() + " hashCode: " + feature.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- System.out.println(" feature: " + feature); //$NON-NLS-1$
- }
- }
- if (oldValue != null) {
- if (oldValue instanceof Node) {
- System.out.println(" oldValue: " + ((Node)oldValue).getNodeName() + " hashCode: " + oldValue.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- System.out.println(" oldValue: " + oldValue); //$NON-NLS-1$
- }
- }
- if (newValue != null) {
- if (newValue instanceof Node) {
- System.out.println(" newValue: " + ((Node)newValue).getNodeName() + " hashCode: " + newValue.hashCode() + " " + ((Node)newValue).getNodeType()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- System.out.println(" newValue: " + newValue); //$NON-NLS-1$
- }
- }
+ }
+
+ public void preLongOperation() {
+ switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
+ }
+
+ public void postLongOperation() {
+ switcher.stopActiveEditor();
+ visualRefresh();
+ }
+
+ // for debug
+ private void printSourceEvent(INodeNotifier notifier, int eventType,
+ Object feature, Object oldValue, Object newValue, int pos) {
+ System.out
+ .println(">>> eventType: " + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " pos: " + pos + " notifier: " + ((Node) notifier).getNodeName() + " hashCode: " + notifier.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ if (feature != null) {
+ if (feature instanceof Node) {
+ System.out
+ .println(" feature: " + ((Node) feature).getNodeType() + " " + ((Node) feature).getNodeName() + " hashCode: " + feature.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ System.out.println(" feature: " + feature); //$NON-NLS-1$
+ }
}
+ if (oldValue != null) {
+ if (oldValue instanceof Node) {
+ System.out
+ .println(" oldValue: " + ((Node) oldValue).getNodeName() + " hashCode: " + oldValue.hashCode()); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ System.out.println(" oldValue: " + oldValue); //$NON-NLS-1$
+ }
+ }
+ if (newValue != null) {
+ if (newValue instanceof Node) {
+ System.out
+ .println(" newValue: " + ((Node) newValue).getNodeName() + " hashCode: " + newValue.hashCode() + " " + ((Node) newValue).getNodeType()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else {
+ System.out.println(" newValue: " + newValue); //$NON-NLS-1$
+ }
+ }
+ }
- private void printVisualEvent(nsIDOMEvent event) {
- System.out.print("<<< " + event.getType()); //$NON-NLS-1$
+ private void printVisualEvent(nsIDOMEvent event) {
+ System.out.print("<<< " + event.getType()); //$NON-NLS-1$
- if (event instanceof nsIDOMMutationEvent) {
- nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent)event;
+ if (event instanceof nsIDOMMutationEvent) {
+ nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent) event;
- System.out.print(" EventPhase: " + mutationEvent.getEventPhase()); //$NON-NLS-1$
+ System.out.print(" EventPhase: " + mutationEvent.getEventPhase()); //$NON-NLS-1$
- nsIDOMNode relatedNode = mutationEvent.getRelatedNode();
- System.out.print(" RelatedNode: " + (relatedNode == null ? null : relatedNode.getNodeName())); //$NON-NLS-1$
-
- nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
- String name = targetNode != null ? targetNode.getNodeName() : null;
- System.out.print(" TargetNode: " + name + " (" + targetNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ nsIDOMNode relatedNode = mutationEvent.getRelatedNode();
+ System.out
+ .print(" RelatedNode: " + (relatedNode == null ? null : relatedNode.getNodeName())); //$NON-NLS-1$
- System.out.print(" PrevValue: " + mutationEvent.getPrevValue().trim()); //$NON-NLS-1$
- System.out.print(" NewValue: " + mutationEvent.getNewValue().trim()); //$NON-NLS-1$
- }
- System.out.println();
+ nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
+ String name = targetNode != null ? targetNode.getNodeName() : null;
+ System.out.print(" TargetNode: " + name + " (" + targetNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ System.out
+ .print(" PrevValue: " + mutationEvent.getPrevValue().trim()); //$NON-NLS-1$
+ System.out
+ .print(" NewValue: " + mutationEvent.getNewValue().trim()); //$NON-NLS-1$
}
-
- private void printMapping() {
- domMapping.printMapping();
+ System.out.println();
+ }
+
+ private void printMapping() {
+ domMapping.printMapping();
+ }
+
+ private class ActiveEditorSwitcher {
+ private static final int ACTIVE_EDITOR_CANNOT = 0;
+ private static final int ACTIVE_EDITOR_NONE = 1;
+ private static final int ACTIVE_EDITOR_SOURCE = 2;
+ private static final int ACTIVE_EDITOR_VISUAL = 3;
+
+ private int type = ACTIVE_EDITOR_CANNOT;
+
+ private void initActiveEditor() {
+ type = ACTIVE_EDITOR_NONE;
}
-
- private class ActiveEditorSwitcher {
- private static final int ACTIVE_EDITOR_CANNOT = 0;
- private static final int ACTIVE_EDITOR_NONE = 1;
- private static final int ACTIVE_EDITOR_SOURCE = 2;
- private static final int ACTIVE_EDITOR_VISUAL = 3;
-
- private int type = ACTIVE_EDITOR_CANNOT;
-
- private void initActiveEditor() {
- type = ACTIVE_EDITOR_NONE;
+
+ private void destroyActiveEditor() {
+ type = ACTIVE_EDITOR_CANNOT;
+ }
+
+ private boolean startActiveEditor(int newType) {
+ if (type == ACTIVE_EDITOR_NONE) {
+ if (newType == ACTIVE_EDITOR_SOURCE
+ && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
+ return false;
}
-
- private void destroyActiveEditor() {
- type = ACTIVE_EDITOR_CANNOT;
- }
-
- private boolean startActiveEditor(int newType) {
- if (type == ACTIVE_EDITOR_NONE) {
- if( newType == ACTIVE_EDITOR_SOURCE &&
- editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
- return false;
- }
- type = newType;
- return true;
- } else {
- return false;
- }
- }
-
- private void stopActiveEditor() {
- onRefresh();
- type = ACTIVE_EDITOR_NONE;
- }
+ type = newType;
+ return true;
+ } else {
+ return false;
+ }
}
-
- private void showProperties(Node node){
- ExtendedProperties p = createExtendedProperties(node);
- if(p != null) ExtendedPropertiesWizard.run(p);
+
+ private void stopActiveEditor() {
+ onRefresh();
+ type = ACTIVE_EDITOR_NONE;
}
-
- ExtendedProperties createExtendedProperties(Node node) {
- try {
- Class c = ModelFeatureFactory.getInstance().getFeatureClass("org.jboss.tools.jst.jsp.outline.VpeProperties"); //$NON-NLS-1$
- return (ExtendedProperties)c.getDeclaredConstructor(new Class[]{Node.class}).newInstance(new Object[]{node});
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- return null;
- }
+ }
+
+ private void showProperties(Node node) {
+ ExtendedProperties p = createExtendedProperties(node);
+ if (p != null)
+ ExtendedPropertiesWizard.run(p);
+ }
+
+ ExtendedProperties createExtendedProperties(Node node) {
+ try {
+ Class c = ModelFeatureFactory.getInstance().getFeatureClass(
+ "org.jboss.tools.jst.jsp.outline.VpeProperties"); //$NON-NLS-1$
+ return (ExtendedProperties) c.getDeclaredConstructor(
+ new Class[] { Node.class }).newInstance(
+ new Object[] { node });
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ return null;
}
-
-
- private void test(Node node) {
+ }
+
+ private void test(Node node) {
+ }
+
+ void refreshBundleValues() {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
+ if (bundle != null) {
+ bundle.refresh();
+ if (pageContext != null) {
+ pageContext.refreshBundleValues();
+ }
+ }
+ switcher.stopActiveEditor();
+ }
- void refreshBundleValues() {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
+ void refreshTemplates() {
+ if (includeList.includesRefresh()) {
+ visualRefresh();
+ }
+ if (templateManager != null) {
+ templateManager.reload();
+ }
+ if (bundle != null) {
+ bundle.refresh();
+ if (pageContext != null) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
- if (bundle != null) {
- bundle.refresh();
- if (pageContext != null) {
- pageContext.refreshBundleValues();
- }
- }
+ pageContext.refreshBundleValues();
switcher.stopActiveEditor();
+ }
}
+ }
- void refreshTemplates() {
- if (includeList.includesRefresh()) {
- visualRefresh();
- }
- if (templateManager != null) {
- templateManager.reload();
- }
- if (bundle != null) {
- bundle.refresh();
- if (pageContext != null) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
- }
- pageContext.refreshBundleValues();
- switcher.stopActiveEditor();
- }
- }
- }
-
- // implements XModelTreeListener
- public void nodeChanged(XModelTreeEvent event) {
- visualRefresh();
- }
-
- public void structureChanged(XModelTreeEvent event) {
- }
-
- private Node getSourceNodeAt(int offset) {
- if (sourceEditor != null && getModel() != null) {
- IndexedRegion node = getModel().getIndexedRegion(offset);
- if (node instanceof IDOMNode) {
+ // implements XModelTreeListener
+ public void nodeChanged(XModelTreeEvent event) {
+ visualRefresh();
+ }
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping((IDOMNode) node);
+ public void structureChanged(XModelTreeEvent event) {
+ }
- if (elementMapping != null) {
-
- if (node instanceof IDOMElement) {
- IDOMElement element = (IDOMElement) node;
+ private Node getSourceNodeAt(int offset) {
+ if (sourceEditor != null && getModel() != null) {
+ IndexedRegion node = getModel().getIndexedRegion(offset);
+ if (node instanceof IDOMNode) {
- if (offset < element.getEndStartOffset()) {
- NamedNodeMap attrs = element.getAttributes();
- if (attrs != null) {
- for (int i = 0; i < attrs.getLength(); i++) {
- if (attrs.item(i) instanceof AttrImpl) {
- AttrImpl attr = (AttrImpl) attrs
- .item(i);
- if (getSourceAttributeOffset(attr,
- offset) != -1) {
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping((IDOMNode) node);
- String[] atributeNames = elementMapping
- .getTemplate()
- .getOutputAtributeNames();
- if (atributeNames != null
- && atributeNames.length > 0
- && attr
- .getName()
- .equalsIgnoreCase(
- atributeNames[0])) {
- return attr;
- }
- }
- }
- }
- }
- }
+ if (elementMapping != null) {
+
+ if (node instanceof IDOMElement) {
+ IDOMElement element = (IDOMElement) node;
+
+ if (offset < element.getEndStartOffset()) {
+ NamedNodeMap attrs = element.getAttributes();
+ if (attrs != null) {
+ for (int i = 0; i < attrs.getLength(); i++) {
+ if (attrs.item(i) instanceof AttrImpl) {
+ AttrImpl attr = (AttrImpl) attrs
+ .item(i);
+ if (getSourceAttributeOffset(attr,
+ offset) != -1) {
+
+ String[] atributeNames = elementMapping
+ .getTemplate()
+ .getOutputAtributeNames();
+ if (atributeNames != null
+ && atributeNames.length > 0
+ && attr
+ .getName()
+ .equalsIgnoreCase(
+ atributeNames[0])) {
+ return attr;
+ }
}
+ }
}
+ }
}
- if (node == null) {
- node = getModel().getIndexedRegion(offset - 1);
- }
- if (node instanceof Node) {
- return (Node) node;
- }
+ }
}
- return null;
+ }
+ if (node == null) {
+ node = getModel().getIndexedRegion(offset - 1);
+ }
+ if (node instanceof Node) {
+ return (Node) node;
+ }
}
-
- private int getSourceNodeOffset(Node node, int pos, boolean endFlag) {
- if (node == null) return 0;
- int start = ((IndexedRegion)node).getStartOffset();
- int end = ((IndexedRegion)node).getEndOffset();
-
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE:
- if (node instanceof AttrImpl) {
- return getSourceAttributeOffset((AttrImpl)node, pos);
- }
- case Node.TEXT_NODE:
- if (pos < start) {
- return 0;
- } else if (pos > end) {
- return end - start;
- } else {
- return pos - start;
- }
- case Node.COMMENT_NODE:
- if (pos > end) {
- pos = end;
- }
- int offset = pos - start - 4;
- return offset < 0 ? 0 : offset;
- case Node.ELEMENT_NODE:
- ElementImpl element = (ElementImpl)node;
- if (element.isContainer()) {
- if (pos < element.getStartEndOffset()) {
- return 0;
- } else {
- return 1;
- }
- } else {
- return endFlag ? 1 : 0;
- }
- default:
- return endFlag ? 1 : 0;
+ return null;
+ }
+
+ private int getSourceNodeOffset(Node node, int pos, boolean endFlag) {
+ if (node == null)
+ return 0;
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
+
+ switch (node.getNodeType()) {
+ case Node.ATTRIBUTE_NODE:
+ if (node instanceof AttrImpl) {
+ return getSourceAttributeOffset((AttrImpl) node, pos);
+ }
+ case Node.TEXT_NODE:
+ if (pos < start) {
+ return 0;
+ } else if (pos > end) {
+ return end - start;
+ } else {
+ return pos - start;
+ }
+ case Node.COMMENT_NODE:
+ if (pos > end) {
+ pos = end;
+ }
+ int offset = pos - start - 4;
+ return offset < 0 ? 0 : offset;
+ case Node.ELEMENT_NODE:
+ ElementImpl element = (ElementImpl) node;
+ if (element.isContainer()) {
+ if (pos < element.getStartEndOffset()) {
+ return 0;
+ } else {
+ return 1;
}
- }
-
- private int getSourceAttributeOffset(AttrImpl attr, int pos) {
- if (attr.getValueRegion() != null) {
- int start = attr.getValueRegionStartOffset();
- String value = attr.getValueRegionText();
- int len = value.length();
- if (pos >= start && pos <= start + len) {
- int offset = pos - start;
- if (len > 1 && value.charAt(0) == '"' && value.charAt(len - 1) == '"') {
- if (offset <= 0 || offset >= len) {
- return -1;
- }
- offset--;
- }
- return offset;
- }
- }
- return -1;
+ } else {
+ return endFlag ? 1 : 0;
+ }
+ default:
+ return endFlag ? 1 : 0;
}
+ }
- private int getSourceNodeOffset1(Node node, int pos, boolean endFlag) {
- if (node == null) return 0;
- int start = ((IndexedRegion)node).getStartOffset();
- int end = ((IndexedRegion)node).getEndOffset();
-
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE:
- if (node instanceof AttrImpl) {
- AttrImpl attr = (AttrImpl)node;
- start = attr.getValueRegionStartOffset();
- end = start + attr.getValueRegion().getLength();
- int ret = 0;
- if (pos > end) {
- ret = end - start;
- } else {
- ret = pos - start;
- }
- if (ret > 0 && attr.getValueRegionText().charAt(0) == '"') {
- ret--;
- }
- return ret;
- }
- case Node.TEXT_NODE:
- if (pos < start) {
- return 0;
- } else if (pos > end) {
- return end - start;
- } else {
- return pos - start;
- }
- case Node.COMMENT_NODE:
- if (pos > end) {
- pos = end;
- }
- int offset = pos - start - 4;
- return offset < 0 ? 0 : offset;
- case Node.ELEMENT_NODE:
- ElementImpl element = (ElementImpl)node;
- if (element.isContainer()) {
- if (pos < element.getStartEndOffset()) {
- return 0;
- } else if (pos < element.getStartEndOffset()) {
- return 1;
- } else if (pos == element.getStartEndOffset()) {
- return 2;
- }
- } else {
- return endFlag ? 1 : 0;
- }
- default:
- return endFlag ? 1 : 0;
+ private int getSourceAttributeOffset(AttrImpl attr, int pos) {
+ if (attr.getValueRegion() != null) {
+ int start = attr.getValueRegionStartOffset();
+ String value = attr.getValueRegionText();
+ int len = value.length();
+ if (pos >= start && pos <= start + len) {
+ int offset = pos - start;
+ if (len > 1 && value.charAt(0) == '"'
+ && value.charAt(len - 1) == '"') {
+ if (offset <= 0 || offset >= len) {
+ return -1;
+ }
+ offset--;
}
+ return offset;
+ }
}
+ return -1;
+ }
- private void listenContextMenu(MenuManager manager, IndexedRegion region, int type){
- MenuManager mm = new MyMenuManager("From Palette",true); //$NON-NLS-1$
- manager.add(mm);
- manager.addMenuListener(new VpeMenuListener(mm, region, type));
- }
-
- class VpeMenuListener implements IMenuListener{
- private MenuManager manager;
- private IndexedRegion region;
- private int type;
- private boolean loaded=false;
-
- public VpeMenuListener(MenuManager manager, IndexedRegion region, int type){
- this.manager = manager;
- this.region = region;
- this.type = type;
- }
- public void menuAboutToShow(IMenuManager m) {
- if(loaded)return;
- loaded=true;
- fillContextMenuFromPalette(manager, region, type);
- manager.getParent().update(true);
+ private int getSourceNodeOffset1(Node node, int pos, boolean endFlag) {
+ if (node == null)
+ return 0;
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
+
+ switch (node.getNodeType()) {
+ case Node.ATTRIBUTE_NODE:
+ if (node instanceof AttrImpl) {
+ AttrImpl attr = (AttrImpl) node;
+ start = attr.getValueRegionStartOffset();
+ end = start + attr.getValueRegion().getLength();
+ int ret = 0;
+ if (pos > end) {
+ ret = end - start;
+ } else {
+ ret = pos - start;
}
- }
- private MenuManager fillContextMenuFromPalette(MenuManager manager, IndexedRegion region, int type){
- XModelObject model = ModelUtilities.getPreferenceModel().getByPath("%Palette%"); //$NON-NLS-1$
-
- XModelObject[] folders = model.getChildren();
- for(int i=0;i<folders.length;i++){
- if ("yes".equals(folders[i].getAttributeValue("hidden"))) continue; //$NON-NLS-1$ //$NON-NLS-2$
- MenuManager mm = new MenuManager(folders[i].getAttributeValue("name")); //$NON-NLS-1$
- manager.add(mm);
- fillPaletteFolder(mm, region, folders[i], type);
+ if (ret > 0 && attr.getValueRegionText().charAt(0) == '"') {
+ ret--;
}
- return manager;
- }
-
- private void fillPaletteFolder(MenuManager menu, IndexedRegion region, XModelObject folder, int type){
- XModelObject[] groups = folder.getChildren();
- for(int i=0;i<groups.length;i++){
- if ("yes".equals(groups[i].getAttributeValue("hidden"))) continue; //$NON-NLS-1$ //$NON-NLS-2$
- MenuManager mm = new MenuManager(groups[i].getAttributeValue("name")); //$NON-NLS-1$
- menu.add(mm);
- fillPaletteGroup(mm, region, groups[i], type);
+ return ret;
+ }
+ case Node.TEXT_NODE:
+ if (pos < start) {
+ return 0;
+ } else if (pos > end) {
+ return end - start;
+ } else {
+ return pos - start;
+ }
+ case Node.COMMENT_NODE:
+ if (pos > end) {
+ pos = end;
+ }
+ int offset = pos - start - 4;
+ return offset < 0 ? 0 : offset;
+ case Node.ELEMENT_NODE:
+ ElementImpl element = (ElementImpl) node;
+ if (element.isContainer()) {
+ if (pos < element.getStartEndOffset()) {
+ return 0;
+ } else if (pos < element.getStartEndOffset()) {
+ return 1;
+ } else if (pos == element.getStartEndOffset()) {
+ return 2;
}
- }
-
- private void fillPaletteGroup(MenuManager menu, IndexedRegion region, XModelObject group, int type){
- XModelObject[] items = group.getChildren();
- String endText;
-
- for(int i=0;i<items.length;i++){
- if ("yes".equals(items[i].getAttributeValue("hidden"))) continue; //$NON-NLS-1$ //$NON-NLS-2$
- endText = items[i].getAttributeValue("end text"); //$NON-NLS-1$
-
- if(type == AROUND_MENU && (endText == null || "".equals(endText))) continue; //$NON-NLS-1$
- createInsertAction(menu, region, items[i], type);
- }
- }
-
- private void createInsertAction(MenuManager menu, IndexedRegion region, XModelObject item, int type){
-
+ } else {
+ return endFlag ? 1 : 0;
+ }
+ default:
+ return endFlag ? 1 : 0;
+ }
+ }
- XModelObject parent = item.getParent();
- String uri = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
- String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
- String[] texts = new String[]{"<"+tagName+">"}; //$NON-NLS-1$ //$NON-NLS-2$
- if(tagName.indexOf("taglib") < 0) //$NON-NLS-1$
- PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagName, uri, defaultPrefix);
- tagName = texts[0];
-
- menu.add(new InsertAction(tagName, region, item, type));
- }
-
- class InsertAction extends Action{
- private XModelObject item;
- private int type;
- private IndexedRegion region;
-
- public InsertAction(String title, IndexedRegion region, XModelObject item, int type){
- super(title);
- this.item = item;
- this.type = type;
- this.region = region;
- }
- public void run(){
- try {
- String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
-
- XModelObject parent = item.getParent();
- String uri = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String libraryVersion = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_VERSION); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
- VpeSelectionProvider selProvider = new VpeSelectionProvider(region);
+ private void listenContextMenu(MenuManager manager, IndexedRegion region,
+ int type) {
+ MenuManager mm = new MyMenuManager("From Palette", true); //$NON-NLS-1$
+ manager.add(mm);
+ manager.addMenuListener(new VpeMenuListener(mm, region, type));
+ }
- String startText = "" + item.getAttributeValue("start text"); //$NON-NLS-1$ //$NON-NLS-2$
- String endText = "" + item.getAttributeValue("end text"); //$NON-NLS-1$ //$NON-NLS-2$
- if(type == AROUND_MENU){
- }else if(type == BEFORE_MENU){
- selProvider = new VpeSelectionProvider(region.getStartOffset());
- }else if(type == AFTER_MENU){
- selProvider = new VpeSelectionProvider(region.getEndOffset());
- }
-
- Properties p = new Properties();
- p.setProperty("tag name", tagName); //$NON-NLS-1$
- p.setProperty("start text", startText); //$NON-NLS-1$
- p.setProperty("end text", endText); //$NON-NLS-1$
- p.setProperty("automatically reformat tag body", "" + item.getAttributeValue("automatically reformat tag body")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- p.setProperty(URIConstants.LIBRARY_URI, uri);
- p.setProperty(URIConstants.LIBRARY_VERSION, libraryVersion);
- String addTaglib = item.getParent().getAttributeValue(TLDToPaletteHelper.ADD_TAGLIB);
- p.setProperty(URIConstants.DEFAULT_PREFIX, defaultPrefix);
- p.setProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, addTaglib);
- if(((Node)region).getNodeType() == Node.ELEMENT_NODE)
- p.put("selectionProvider", selProvider); //$NON-NLS-1$
- PaletteInsertHelper.insertIntoEditor(sourceEditor.getTextViewer(), p);
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
-
- }
-
- }
-
- class VpeSelectionProvider implements ISelectionProvider{
- VpeSelection selection;
-
- public VpeSelectionProvider(IndexedRegion region){
- selection = new VpeSelection(region);
- }
- public VpeSelectionProvider(int position){
- selection = new VpeSelection(position);
- }
- public VpeSelectionProvider(int offset, int length){
- selection = new VpeSelection(offset, length);
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- }
- public ISelection getSelection() {
- return selection;
- }
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ class VpeMenuListener implements IMenuListener {
+ private MenuManager manager;
+ private IndexedRegion region;
+ private int type;
+ private boolean loaded = false;
- }
- public void setSelection(ISelection selection) {
- }
- }
-
- class VpeSelection implements ITextSelection{
- String text=""; //$NON-NLS-1$
- int offset, length;
+ public VpeMenuListener(MenuManager manager, IndexedRegion region,
+ int type) {
+ this.manager = manager;
+ this.region = region;
+ this.type = type;
+ }
- public VpeSelection(int position){
- offset = position;
- length = 0;
- }
-
- public VpeSelection(int offset, int length){
- this.offset = offset;
- this.length = length;
- if (length > 0) {
- try{
- text = sourceEditor.getTextViewer().getDocument().get(offset, length);
- }catch(Exception ex){
- VpePlugin.reportProblem(ex);
- }
- }
- }
-
- public VpeSelection(IndexedRegion region){
- offset = region.getStartOffset();
- length = region.getEndOffset() - offset;
- try{
- text = sourceEditor.getTextViewer().getDocument().get(offset, length);
- }catch(Exception ex){
- VpePlugin.reportProblem(ex);
- }
- }
-
- public int getEndLine() {
- return 0;
- }
- public int getLength() {
- return length;
- }
- public int getOffset() {
- return offset;
- }
- public int getStartLine() {
- return 0;
- }
- public String getText() {
- return text;
- }
- public boolean isEmpty() {
- return false;
- }
-}
+ public void menuAboutToShow(IMenuManager m) {
+ if (loaded)
+ return;
+ loaded = true;
+ fillContextMenuFromPalette(manager, region, type);
+ manager.getParent().update(true);
+ }
+ }
- class VpeAction extends Action{
- public Node actionNode;
- public VpeAction(String name, Node node){
- super(name);
- this.actionNode = node;
- }
+ private MenuManager fillContextMenuFromPalette(MenuManager manager,
+ IndexedRegion region, int type) {
+ XModelObject model = ModelUtilities.getPreferenceModel().getByPath(
+ "%Palette%"); //$NON-NLS-1$
+
+ XModelObject[] folders = model.getChildren();
+ for (int i = 0; i < folders.length; i++) {
+ if ("yes".equals(folders[i].getAttributeValue("hidden")))continue; //$NON-NLS-1$ //$NON-NLS-2$
+ MenuManager mm = new MenuManager(folders[i]
+ .getAttributeValue("name")); //$NON-NLS-1$
+ manager.add(mm);
+ fillPaletteFolder(mm, region, folders[i], type);
}
-
- class VpeTextOperationAction extends Action{
- private String id;
- private IndexedRegion region;
- public VpeTextOperationAction(String name, String id, IndexedRegion region){
- super(name);
- this.id = id;
- this.region = region;
- }
- public void run(){
- sourceEditor.getSelectionProvider().setSelection(new VpeSelection(region));
- sourceEditor.getAction(id).run();
- }
+ return manager;
+ }
+
+ private void fillPaletteFolder(MenuManager menu, IndexedRegion region,
+ XModelObject folder, int type) {
+ XModelObject[] groups = folder.getChildren();
+ for (int i = 0; i < groups.length; i++) {
+ if ("yes".equals(groups[i].getAttributeValue("hidden")))continue; //$NON-NLS-1$ //$NON-NLS-2$
+ MenuManager mm = new MenuManager(groups[i]
+ .getAttributeValue("name")); //$NON-NLS-1$
+ menu.add(mm);
+ fillPaletteGroup(mm, region, groups[i], type);
}
+ }
- public void refreshExternalLinks() {
- pageContext.getVisualBuilder().refreshExternalLinks();
+ private void fillPaletteGroup(MenuManager menu, IndexedRegion region,
+ XModelObject group, int type) {
+ XModelObject[] items = group.getChildren();
+ String endText;
+
+ for (int i = 0; i < items.length; i++) {
+ if ("yes".equals(items[i].getAttributeValue("hidden")))continue; //$NON-NLS-1$ //$NON-NLS-2$
+ endText = items[i].getAttributeValue("end text"); //$NON-NLS-1$
+
+ if (type == AROUND_MENU && (endText == null || "".equals(endText)))continue; //$NON-NLS-1$
+ createInsertAction(menu, region, items[i], type);
+ }
}
- public IPath getPath() {
- if (editPart != null) {
- IEditorInput input = editPart.getEditorInput();
- if (input != null && input instanceof IFileEditorInput) {
- return ((IFileEditorInput)input).getFile().getFullPath();
- }
- }
- return null;
+ private void createInsertAction(MenuManager menu, IndexedRegion region,
+ XModelObject item, int type) {
+
+ XModelObject parent = item.getParent();
+ String uri = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
+ String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
+ String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
+ String[] texts = new String[] { "<" + tagName + ">" }; //$NON-NLS-1$ //$NON-NLS-2$
+ if (tagName.indexOf("taglib") < 0) //$NON-NLS-1$
+ PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagName, uri,
+ defaultPrefix);
+ tagName = texts[0];
+
+ menu.add(new InsertAction(tagName, region, item, type));
}
- public void changed(Object source) {
- if(cssReferenceListListener == source) {
- pageContext.getVisualBuilder().refreshExternalLinks();
- } else if (absoluteFolderReferenceListListener == source ||
- relativeFolderReferenceListListener == source ||
- taglibReferenceListListener == source) {
- visualRefresh();
- }
- }
-
- public void dragEnter(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<< DragEnter"); //$NON-NLS-1$
- }
+ class InsertAction extends Action {
+ private XModelObject item;
+ private int type;
+ private IndexedRegion region;
+
+ public InsertAction(String title, IndexedRegion region,
+ XModelObject item, int type) {
+ super(title);
+ this.item = item;
+ this.type = type;
+ this.region = region;
}
- public void dragExit(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<< dragExit"); //$NON-NLS-1$
+ public void run() {
+ try {
+ String tagName = item.getAttributeValue("name"); //$NON-NLS-1$
+
+ XModelObject parent = item.getParent();
+ String uri = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
+ String libraryVersion = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_VERSION); //$NON-NLS-1$
+ String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
+ VpeSelectionProvider selProvider = new VpeSelectionProvider(
+ region);
+
+ String startText = "" + item.getAttributeValue("start text"); //$NON-NLS-1$ //$NON-NLS-2$
+ String endText = "" + item.getAttributeValue("end text"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (type == AROUND_MENU) {
+ } else if (type == BEFORE_MENU) {
+ selProvider = new VpeSelectionProvider(region
+ .getStartOffset());
+ } else if (type == AFTER_MENU) {
+ selProvider = new VpeSelectionProvider(region
+ .getEndOffset());
}
- // TODO Sergey Vasilyev figure out with drag caret
-// xulRunnerEditor.hideDragCaret();
+
+ Properties p = new Properties();
+ p.setProperty("tag name", tagName); //$NON-NLS-1$
+ p.setProperty("start text", startText); //$NON-NLS-1$
+ p.setProperty("end text", endText); //$NON-NLS-1$
+ p
+ .setProperty(
+ "automatically reformat tag body", "" + item.getAttributeValue("automatically reformat tag body")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ p.setProperty(URIConstants.LIBRARY_URI, uri);
+ p.setProperty(URIConstants.LIBRARY_VERSION, libraryVersion);
+ String addTaglib = item.getParent().getAttributeValue(
+ TLDToPaletteHelper.ADD_TAGLIB);
+ p.setProperty(URIConstants.DEFAULT_PREFIX, defaultPrefix);
+ p.setProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB,
+ addTaglib);
+ /*
+ * Added by Dzmitry Sakovich Fix for JBIDE-1626
+ */
+ // if(((Node)region).getNodeType() == Node.ELEMENT_NODE)
+ p.put("selectionProvider", selProvider); //$NON-NLS-1$
+ PaletteInsertHelper.insertIntoEditor(sourceEditor
+ .getTextViewer(), p);
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+
}
-
- public void dragOver(nsIDOMEvent event) {
- visualBuilder.getDnd().dragOver(event, this);
+ }
+ class VpeSelectionProvider implements ISelectionProvider {
+ VpeSelection selection;
+
+ public VpeSelectionProvider(IndexedRegion region) {
+ selection = new VpeSelection(region);
}
-
- public void _dragOver(nsIDOMEvent event) {
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<< dragOver"); //$NON-NLS-1$
- }
-
-// browser.computeDropPosition(event);
-
- boolean canDrop = !xulRunnerEditor.isMozillaDragFlavor();
- if (canDrop) {
- Clipboard clipboard = new Clipboard(Display.getCurrent());
- canDrop = clipboard.getContents(ModelTransfer.getInstance()) != null;
- }
- if (canDrop) {
- canDrop = VpeDndUtil.isDropEnabled((IModelObjectEditorInput)sourceEditor.getEditorInput());
- }
- if (canDrop) {
- VpeVisualCaretInfo caretInfo = selectionBuilder.getVisualCaretInfo(event);
- canDrop = caretInfo.exist();
- if (canDrop) {
- caretInfo.showCaret();
- } else {
- caretInfo.hideCaret();
- }
- }
- if (!canDrop) {
- event.stopPropagation();
- event.preventDefault();
- }
- switcher.stopActiveEditor();
+
+ public VpeSelectionProvider(int position) {
+ selection = new VpeSelection(position);
}
- public void drop(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<< outerDrop"); //$NON-NLS-1$
- }
- event.preventDefault();
+ public VpeSelectionProvider(int offset, int length) {
+ selection = new VpeSelection(offset, length);
}
- public boolean canInnerDrag(nsIDOMMouseEvent event) {
- onHideTooltip();
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print("<<<<<< canInnerDrag"); //$NON-NLS-1$
- }
- if (innerDragInfo != null) {
- innerDragInfo.Release();
- innerDragInfo = null;
- }
- boolean canDrag = false;
- VpeVisualInnerDragInfo dragInfo = selectionBuilder.getInnerDragInfo(event);
- if (dragInfo != null) {
- nsIDOMNode dragNode = dragInfo.getNode();
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print(" dragNode: " + dragNode.getNodeName() + "(" + dragNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- switch (dragNode.getNodeType()) {
- case nsIDOMNode.ELEMENT_NODE:
- canDrag = visualBuilder.canInnerDrag((nsIDOMElement)dragNode);
- case nsIDOMNode.TEXT_NODE:
- canDrag = visualBuilder.isTextEditable(dragNode);
- }
- if (canDrag) {
- VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder.getSourceInnerDragInfo(dragInfo);
- if (sourceInnerDragInfo.getNode() != null) {
- innerDragInfo = dragInfo;
- InnerDragBuffer.object = sourceInnerDragInfo.getNode();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- InnerDragBuffer.object = null;
- }
- });
- } else {
- canDrag = false;
- }
- }
- if (!canDrag) {
- dragInfo.Release();
- }
- }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrag: " + canDrag); //$NON-NLS-1$
- }
- return canDrag;
+ public ISelection getSelection() {
+ return selection;
}
-
- VpeDropWindow dropWindow = null;
-
- public MozillaDropInfo canInnerDrop(nsIDOMMouseEvent event) {
- onHideTooltip();
- if(dropWindow.active) {
- if(!event.getAltKey()) {
- dropWindow.close();
- } else {
- return null;
- }
- }
- if(event.getAltKey()) {
- nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
- Node sourceNode = domMapping.getNearSourceNode(visualNode);
- if(sourceNode != null) {
- dropWindow.active = true;
- dropWindow.setEventPosition(event.getScreenX(), event.getScreenY());
- dropWindow.setInitialTargetNode(sourceNode);
- dropWindow.open();
- event.stopPropagation();
- event.preventDefault();
- return null;
- }
- }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print("<<<<<< canInnerDrop"); //$NON-NLS-1$
- }
- boolean canDrop = false;;
- nsIDOMNode caretParent = null;
- long caretOffset = 0;
- if (innerDragInfo != null) {
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(event);
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print(" x: " + visualDropInfo.getMouseX() + " y: " + visualDropInfo.getMouseY() + //$NON-NLS-1$ //$NON-NLS-2$
- " container: " + visualDropInfo.getDropContainer().getNodeName() + //$NON-NLS-1$
- "(" + visualDropInfo.getDropContainer() + ")" + //$NON-NLS-1$ //$NON-NLS-2$
- " parent: " + visualDropInfo.getDropContainer().getParentNode().getNodeName() + //$NON-NLS-1$
- "(" + visualDropInfo.getDropContainer().getParentNode() + ")" + //$NON-NLS-1$ //$NON-NLS-2$
- " offset: " + visualDropInfo.getDropOffset()); //$NON-NLS-1$
- }
- VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder.getSourceInnerDragInfo(innerDragInfo);
- VpeSourceInnerDropInfo sourceDropInfo = visualBuilder.getSourceInnerDropInfo(sourceInnerDragInfo.getNode(), visualDropInfo, true);
- canDrop = sourceDropInfo.canDrop();
- if (canDrop) {
- VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder.getInnerDropInfo(sourceDropInfo.getContainer(), sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- visualBuilder.correctVisualDropPosition(newVisualDropInfo, visualDropInfo);
- caretParent = newVisualDropInfo.getDropContainer();
- caretOffset = newVisualDropInfo.getDropOffset();
- }
- }
- }
- visualDropInfo.Release();
- }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrop: " + canDrop); //$NON-NLS-1$
- }
- return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+
}
- public void innerDrop(nsIDOMMouseEvent event) {
- onHideTooltip();
+ public void setSelection(ISelection selection) {
+ }
+ }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print("<<<<<< innerDrop"); //$NON-NLS-1$
- }
- if (innerDragInfo != null) {
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(event);
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print(" container: " + visualDropInfo.getDropContainer().getNodeName() + //$NON-NLS-1$
- "(" + visualDropInfo.getDropContainer() + ")" + //$NON-NLS-1$ //$NON-NLS-2$
- " offset: " + visualDropInfo.getDropOffset()); //$NON-NLS-1$
- }
+ class VpeSelection implements ITextSelection {
+ String text = ""; //$NON-NLS-1$
+ int offset, length;
- VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder.getSourceInnerDragInfo(innerDragInfo);
- VpeSourceInnerDropInfo sourceDropInfo = visualBuilder.getSourceInnerDropInfo(sourceInnerDragInfo.getNode(), visualDropInfo, true);
- if(sourceDropInfo.canDrop()){
- VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder.getInnerDropInfo(sourceDropInfo.getContainer(), sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- visualBuilder.correctVisualDropPosition(newVisualDropInfo, visualDropInfo);
- sourceDropInfo.setTop(visualDropInfo.getMouseY());
- sourceDropInfo.setLeft(visualDropInfo.getMouseX());
- visualBuilder.innerDrop(sourceInnerDragInfo, sourceDropInfo);
- if (innerDragInfo != null) {
- innerDragInfo.Release();
- innerDragInfo = null;
- }
- }
- }
- }
+ public VpeSelection(int position) {
+ offset = position;
+ length = 0;
+ }
+
+ public VpeSelection(int offset, int length) {
+ this.offset = offset;
+ this.length = length;
+ if (length > 0) {
+ try {
+ text = sourceEditor.getTextViewer().getDocument().get(
+ offset, length);
+ } catch (Exception ex) {
+ VpePlugin.reportProblem(ex);
}
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println();
- }
+ }
}
- public MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
- InnerDragBuffer.object = null;
- onHideTooltip();
+ public VpeSelection(IndexedRegion region) {
+ offset = region.getStartOffset();
+ length = region.getEndOffset() - offset;
+ try {
+ text = sourceEditor.getTextViewer().getDocument().get(offset,
+ length);
+ } catch (Exception ex) {
+ VpePlugin.reportProblem(ex);
+ }
+ }
- if(dropWindow.active) {
- if(!mouseEvent.getAltKey()) {
- dropWindow.close();
- } else {
- return new MozillaDropInfo(false, null, 0);
- }
- }
- if(mouseEvent.getAltKey()) {
- nsIDOMEvent event = (nsIDOMEvent) mouseEvent.queryInterface(nsIDOMEvent.NS_IDOMEVENT_IID);
- nsIDOMNode visualNode = (nsIDOMNode) event.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
- Node sourceNode = domMapping.getNearSourceNode(visualNode);
- if(sourceNode != null) {
- if(ModelTransfer.MODEL.equals(flavor)){ //$NON-NLS-1$
-// XModelObject object = PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
-// InnerDragBuffer.object = object;
- } else {
- dropWindow.flavor = flavor;
- }
- dropWindow.active = true;
- dropWindow.setEventPosition(mouseEvent.getScreenX(), mouseEvent.getScreenY());
- dropWindow.setInitialTargetNode(sourceNode);
- dropWindow.open();
- mouseEvent.stopPropagation();
- mouseEvent.preventDefault();
- return new MozillaDropInfo(false, null, 0);
- }
- }
- boolean canDrop = false;
- nsIDOMNode caretParent = null;
- long caretOffset = 0;
+ public int getEndLine() {
+ return 0;
+ }
- if(MODEL_FLAVOR.equals(flavor)){
- XModelObject object = PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
- if(object.getFileType() == XModelObject.FILE && !TLDUtil.isTaglib(object)) {
- IFile f = (IFile)EclipseResourceUtil.getResource(object);
- canDrop = f != null;
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(mouseEvent);
- caretParent = visualDropInfo.getDropContainer();
- caretOffset = visualDropInfo.getDropOffset();
- } else {
- String tagname = getTagName(object);
- if(tagname.indexOf("taglib") >= 0) tagname= "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document)getModel().getAdapter(Document.class)).createElement(tagname);
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(mouseEvent);
- if (visualDropInfo.getDropContainer() != null) {
- VpeSourceInnerDropInfo sourceDropInfo = visualBuilder.getSourceInnerDropInfo(sourceDragNode, visualDropInfo, true);
- canDrop = sourceDropInfo.canDrop();
- if (canDrop) {
- VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder.getInnerDropInfo(sourceDropInfo.getContainer(), sourceDropInfo.getOffset());
- if (newVisualDropInfo != null) {
- visualBuilder.correctVisualDropPosition(newVisualDropInfo, visualDropInfo);
- caretParent = newVisualDropInfo.getDropContainer();
- caretOffset = newVisualDropInfo.getDropOffset();
- }
- }
- }
- visualDropInfo.Release();
- }
- }else if(XulRunnerEditor.TRANS_FLAVOR_kFileMime.equals(flavor) ||
- XulRunnerEditor.TRANS_FLAVOR_kURLMime.equals(flavor)) {
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(mouseEvent);
- caretParent = visualDropInfo.getDropContainer();
- caretOffset = visualDropInfo.getDropOffset();
- try {
- canDrop = true;
- } catch (Exception ex) {
- VpePlugin.reportProblem(ex);
- }
- }
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrop: " + canDrop + (canDrop ? " container: " + caretParent.getNodeName() + " offset: " + caretOffset : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- return new MozillaDropInfo(canDrop, caretParent, caretOffset);
-
+ public int getLength() {
+ return length;
}
- public VpeSourceInnerDropInfo canExternalDropMacro(XModelObject object, Node parentNode, int offset) {
- String tagname = getTagName(object);
- Node sourceDragNode = ((Document)getModel().getAdapter(Document.class)).createElement(tagname);
- return visualBuilder.getSourceInnerDropInfo(sourceDragNode, parentNode, offset, false);
+ public int getOffset() {
+ return offset;
}
- public void externalDropAny(final String flavor, final String data, final Point range, Node container) {
- if(flavor == null || flavor.length() == 0) return;
- IDropCommand dropCommand = DropCommandFactory.getInstance().getDropCommand(flavor, JSPTagProposalFactory.getInstance());
+ public int getStartLine() {
+ return 0;
+ }
- boolean promptAttributes = "yes".equals(VpePreference.ALWAYS_REQUEST_FOR_ATTRIBUTE.getValue());
- dropCommand.getDefaultModel().setPromptForTagAttributesRequired(promptAttributes);
+ public String getText() {
+ return text;
+ }
- dropCommand.execute(
- new DropData(
- flavor,
- data,
- sourceEditor.getEditorInput(),
- (ISourceViewer)sourceEditor.getAdapter(ISourceViewer.class),
- new VpeSelectionProvider(range.x,range.y),
- container
- )
- );
+ public boolean isEmpty() {
+ return false;
}
+ }
- private String getTagName(XModelObject object) {
- String tagname = object.getAttributeValue("name"); //$NON-NLS-1$
+ class VpeAction extends Action {
+ public Node actionNode;
- XModelObject parent = object.getParent();
- String uri = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
-
- String[] texts = new String[]{"<"+tagname+">"}; //$NON-NLS-1$ //$NON-NLS-2$
- PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri, defaultPrefix);
- tagname = texts[0].substring(1,texts[0].length()-1);
-
- return tagname;
+ public VpeAction(String name, Node node) {
+ super(name);
+ this.actionNode = node;
}
+ }
- public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
- onHideTooltip();
+ class VpeTextOperationAction extends Action {
+ private String id;
+ private IndexedRegion region;
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(mouseEvent);
- Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(visualDropInfo.getDropContainer(), (int)visualDropInfo.getDropOffset());
- VpeSourceInnerDropInfo sourceDropInfo = null;
-
- if(MODEL_FLAVOR.equals(flavor)){
- XModelObject object = PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
- if(object.getFileType() == XModelObject.FILE && !TLDUtil.isTaglib(object)) {
- flavor = "application/x-moz-file"; //$NON-NLS-1$
- IFile f = (IFile)EclipseResourceUtil.getResource(object);
- try {
- data = f.getLocation().toFile().toURL().toString();
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- }
- } else {
- String tagname = getTagName(object);
- if(tagname.indexOf("taglib") >= 0) tagname= "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document)getModel().getAdapter(Document.class)).createElement(tagname);
- if (visualDropInfo.getDropContainer() != null) {
- sourceDropInfo = visualBuilder.getSourceInnerDropInfo(sourceDragNode, visualDropInfo, true);
- range = selectionBuilder.getSourceSelectionRange(sourceDropInfo.getContainer(), sourceDropInfo.getOffset());
- }
- }
- }
-
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
- }
- externalDropAny(flavor, data, range, sourceDropInfo == null?null:sourceDropInfo.getContainer());
- }
+ public VpeTextOperationAction(String name, String id,
+ IndexedRegion region) {
+ super(name);
+ this.id = id;
+ this.region = region;
}
-
- public void onShowTooltip(int x, int y, final String text) {
-
- if (tip != null && !tip.isDisposed()) tip.dispose();
-
- Display display = visualEditor.getControl().getDisplay();
- Shell parent = visualEditor.getControl().getShell();
-
- tip = new Shell(parent, SWT.NO_FOCUS| SWT.ON_TOP);
- Color bckgColor = new Color(tip.getDisplay(), 255, 250, 236);
- tip.setBackground(bckgColor);
-
- Composite composite = tip;
- GridLayout layout= new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.verticalSpacing= 0;
- layout.horizontalSpacing= 0;
- composite.setLayout(layout);
- GridData gd= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
-
- final StyledText tipControlHeaderText = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY);
-
- tipControlHeaderText.setForeground(bckgColor);
- tipControlHeaderText.setBackground(bckgColor);
-
- String formatText = text.trim();
-
- /** attributeString string containing the pairs attribute and it's value as one string*/
- String[] attributeString = formatText.split("\n"); //$NON-NLS-1$
- /** buffer string containing the attribute and the value in the different succeding string*/
- String[] buffer = attributeString[0].split(" "); //$NON-NLS-1$
-
- tipControlHeaderText.setText(buffer[0].toString());
-
- tipControlHeaderText.addLineStyleListener(
- new LineStyleListener() {
- public void lineGetStyle(LineStyleEvent event){
- Color color = new Color(tipControlHeaderText.getDisplay(), 201, 51, 40);
- if (event.lineOffset == 0) {
- StyleRange st = new StyleRange();
- st.fontStyle = SWT.BOLD;
- st.foreground = color;
- event.styles = new StyleRange[]{st};
- st.start = event.lineOffset;
- st.length = event.lineText.length();
- }
- }
- }
- );
-
- GridData gridData = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- gridData.horizontalAlignment = GridData.FILL;
- gridData.horizontalSpan = 2;
- tipControlHeaderText.setLayoutData(gridData);
-
- StringBuffer tempAttr = new StringBuffer();
- StringBuffer tempValue = new StringBuffer();
-
- if (attributeString.length >= 2) {
- for (int i = 1; i < attributeString.length; i++) {
- buffer = attributeString[i].split(" ", 2); //$NON-NLS-1$
- if (i == 1) {
- tempAttr.append(buffer[0] + " "); //$NON-NLS-1$
- tempValue.append((buffer.length>=2?buffer[1]:"") + " "); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- tempAttr.append("\n" + buffer[0] + " "); //$NON-NLS-1$ //$NON-NLS-2$
- tempValue.append(" \n" + (buffer.length>=2?buffer[1]:"") + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- final StyledText tipControlAttributeText = new StyledText(composite,
- SWT.MULTI | SWT.READ_ONLY);
-
- tipControlAttributeText.setForeground(bckgColor);
- tipControlAttributeText.setBackground(bckgColor);
-
- tipControlAttributeText.setText(tempAttr.toString());
- tipControlAttributeText
- .addLineStyleListener(new LineStyleListener() {
- public void lineGetStyle(LineStyleEvent event) {
- Color color = new Color(tipControlHeaderText
- .getDisplay(), 42, 148, 0);
- StyleRange st = new StyleRange();
- st.start = event.lineOffset;
- st.length = event.lineText.length();
- st.foreground = color;
- st.fontStyle = SWT.NORMAL;
- event.styles = new StyleRange[] { st };
- }
- });
- GridData gridData1 = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- gridData1.horizontalAlignment = GridData.FILL;
- tipControlAttributeText.setLayoutData(gridData1);
-
- final StyledText tipControlValueText = new StyledText(composite,
- SWT.MULTI | SWT.READ_ONLY);
-
- tipControlValueText.setBackground(bckgColor);
-
- tipControlValueText.setText(tempValue.toString());
-
-
-
- GridData gridData2 = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- gridData2.horizontalAlignment = GridData.FILL;
- tipControlValueText.setLayoutData(gridData2);
- }
- /*
- * Bug in Mozilla embedded API. Tooltip coordinates are wrong for
- * elements inside an inline frame (IFrame tag). The workaround is
- * to position the tooltip based on the mouse cursor location.
- */
- Point point = display.getCursorLocation();
- /* Assuming cursor is 21x21 because this is the size of
- * the arrow cursor on Windows
- */
- point.y += 21;
- tip.setLocation(point);
- tip.pack();
- tip.setVisible(true);
+
+ public void run() {
+ sourceEditor.getSelectionProvider().setSelection(
+ new VpeSelection(region));
+ sourceEditor.getAction(id).run();
}
-
- public void onHideTooltip() {
- if (tip != null && !tip.isDisposed()) tip.dispose();
- tip = null;
+ }
+
+ public void refreshExternalLinks() {
+ pageContext.getVisualBuilder().refreshExternalLinks();
+ }
+
+ public IPath getPath() {
+ if (editPart != null) {
+ IEditorInput input = editPart.getEditorInput();
+ if (input != null && input instanceof IFileEditorInput) {
+ return ((IFileEditorInput) input).getFile().getFullPath();
+ }
}
-
- public VpePageContext getPageContext() {
-
- return pageContext;
+ return null;
+ }
+
+ public void changed(Object source) {
+ if (cssReferenceListListener == source) {
+ pageContext.getVisualBuilder().refreshExternalLinks();
+ } else if (absoluteFolderReferenceListListener == source
+ || relativeFolderReferenceListListener == source
+ || taglibReferenceListListener == source) {
+ visualRefresh();
}
+ }
- public StructuredTextEditor getSourceEditor() {
- return sourceEditor;
+ public void dragEnter(nsIDOMEvent event) {
+ if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+ System.out.println("<<<<<<<<<<<<<<<<<<<< DragEnter"); //$NON-NLS-1$
}
+ }
- public FormatControllerManager getToolbarFormatControllerManager() {
- return toolbarFormatControllerManager;
+ public void dragExit(nsIDOMEvent event) {
+ if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+ System.out.println("<<<<<<<<<<<<<<<<<<<< dragExit"); //$NON-NLS-1$
}
+ // TODO Sergey Vasilyev figure out with drag caret
+ // xulRunnerEditor.hideDragCaret();
+ }
- public void setToolbarFormatControllerManager(FormatControllerManager formatControllerManager) {
- toolbarFormatControllerManager = formatControllerManager;
+ public void dragOver(nsIDOMEvent event) {
+
+ visualBuilder.getDnd().dragOver(event, this);
+
+ }
+
+ public void _dragOver(nsIDOMEvent event) {
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ return;
}
- public void setSelectionBarController(SelectionBar selectionBar) {
- this.selectionBar = selectionBar;
+ if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+ System.out.println("<<<<<<<<<<<<<<<<<<<< dragOver"); //$NON-NLS-1$
}
- public IStructuredModel getModel() {
- return sourceEditor.getModel();
+ // browser.computeDropPosition(event);
+
+ boolean canDrop = !xulRunnerEditor.isMozillaDragFlavor();
+ if (canDrop) {
+ Clipboard clipboard = new Clipboard(Display.getCurrent());
+ canDrop = clipboard.getContents(ModelTransfer.getInstance()) != null;
}
+ if (canDrop) {
+ canDrop = VpeDndUtil
+ .isDropEnabled((IModelObjectEditorInput) sourceEditor
+ .getEditorInput());
+ }
+ if (canDrop) {
+ VpeVisualCaretInfo caretInfo = selectionBuilder
+ .getVisualCaretInfo(event);
+ canDrop = caretInfo.exist();
+ if (canDrop) {
+ caretInfo.showCaret();
+ } else {
+ caretInfo.hideCaret();
+ }
+ }
+ if (!canDrop) {
+ event.stopPropagation();
+ event.preventDefault();
+ }
+ switcher.stopActiveEditor();
+ }
- public VpeDomMapping getDomMapping() {
- return domMapping;
+ public void drop(nsIDOMEvent event) {
+ if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+ System.out.println("<<< outerDrop"); //$NON-NLS-1$
}
-
- public VpeIncludeList getIncludeList(){
- try {
- if(includeList == null)
- throw new Exception("includeList - NULL!!!"); //$NON-NLS-1$
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
+ event.preventDefault();
+ }
+
+ public boolean canInnerDrag(nsIDOMMouseEvent event) {
+ onHideTooltip();
+
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.print("<<<<<< canInnerDrag"); //$NON-NLS-1$
+ }
+ if (innerDragInfo != null) {
+ innerDragInfo.Release();
+ innerDragInfo = null;
+ }
+ boolean canDrag = false;
+ VpeVisualInnerDragInfo dragInfo = selectionBuilder
+ .getInnerDragInfo(event);
+ if (dragInfo != null) {
+ nsIDOMNode dragNode = dragInfo.getNode();
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .print(" dragNode: " + dragNode.getNodeName() + "(" + dragNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ switch (dragNode.getNodeType()) {
+ case nsIDOMNode.ELEMENT_NODE:
+ canDrag = visualBuilder.canInnerDrag((nsIDOMElement) dragNode);
+ case nsIDOMNode.TEXT_NODE:
+ canDrag = visualBuilder.isTextEditable(dragNode);
+ }
+ if (canDrag) {
+ VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
+ .getSourceInnerDragInfo(dragInfo);
+ if (sourceInnerDragInfo.getNode() != null) {
+ innerDragInfo = dragInfo;
+ InnerDragBuffer.object = sourceInnerDragInfo.getNode();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ InnerDragBuffer.object = null;
+ }
+ });
+ } else {
+ canDrag = false;
}
- return includeList;
+ }
+ if (!canDrag) {
+ dragInfo.Release();
+ }
}
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.println(" canDrag: " + canDrag); //$NON-NLS-1$
+ }
+ return canDrag;
+ }
- public void selectionChanged(SelectionChangedEvent event) {
- if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
- if(toolbarFormatControllerManager != null) toolbarFormatControllerManager.selectionChanged();
+ VpeDropWindow dropWindow = null;
+
+ public MozillaDropInfo canInnerDrop(nsIDOMMouseEvent event) {
+ onHideTooltip();
+
+ if (dropWindow.active) {
+ if (!event.getAltKey()) {
+ dropWindow.close();
+ } else {
+ return null;
+ }
+ }
+ if (event.getAltKey()) {
+ nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
+ Node sourceNode = domMapping.getNearSourceNode(visualNode);
+ if (sourceNode != null) {
+ dropWindow.active = true;
+ dropWindow.setEventPosition(event.getScreenX(), event
+ .getScreenY());
+ dropWindow.setInitialTargetNode(sourceNode);
+ dropWindow.open();
+ event.stopPropagation();
+ event.preventDefault();
+ return null;
+ }
+ }
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.print("<<<<<< canInnerDrop"); //$NON-NLS-1$
+ }
+ boolean canDrop = false;
+ ;
+ nsIDOMNode caretParent = null;
+ long caretOffset = 0;
+ if (innerDragInfo != null) {
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(event);
+ if (visualDropInfo.getDropContainer() != null) {
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .print(" x: " + visualDropInfo.getMouseX() + " y: " + visualDropInfo.getMouseY() + //$NON-NLS-1$ //$NON-NLS-2$
+ " container: "
+ + visualDropInfo.getDropContainer()
+ .getNodeName()
+ + //$NON-NLS-1$
+ "("
+ + visualDropInfo.getDropContainer()
+ + ")" + //$NON-NLS-1$ //$NON-NLS-2$
+ " parent: "
+ + visualDropInfo.getDropContainer()
+ .getParentNode().getNodeName()
+ + //$NON-NLS-1$
+ "("
+ + visualDropInfo.getDropContainer()
+ .getParentNode() + ")" + //$NON-NLS-1$ //$NON-NLS-2$
+ " offset: "
+ + visualDropInfo.getDropOffset()); //$NON-NLS-1$
}
+ VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
+ .getSourceInnerDragInfo(innerDragInfo);
+ VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
+ .getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
+ visualDropInfo, true);
+ canDrop = sourceDropInfo.canDrop();
+ if (canDrop) {
+ VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
+ .getInnerDropInfo(sourceDropInfo.getContainer(),
+ sourceDropInfo.getOffset());
+ if (newVisualDropInfo != null) {
+ visualBuilder.correctVisualDropPosition(
+ newVisualDropInfo, visualDropInfo);
+ caretParent = newVisualDropInfo.getDropContainer();
+ caretOffset = newVisualDropInfo.getDropOffset();
+ }
+ }
+ }
+ visualDropInfo.Release();
+ }
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.println(" canDrop: " + canDrop); //$NON-NLS-1$
+ }
+ return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+ }
- if(selectionBar != null) selectionBar.selectionChanged();
-
- if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- return;
+ public void innerDrop(nsIDOMMouseEvent event) {
+ onHideTooltip();
+
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.print("<<<<<< innerDrop"); //$NON-NLS-1$
+ }
+ if (innerDragInfo != null) {
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(event);
+ if (visualDropInfo.getDropContainer() != null) {
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .print(" container: " + visualDropInfo.getDropContainer().getNodeName() + //$NON-NLS-1$
+ "(" + visualDropInfo.getDropContainer()
+ + ")" + //$NON-NLS-1$ //$NON-NLS-2$
+ " offset: "
+ + visualDropInfo.getDropOffset()); //$NON-NLS-1$
}
- if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> selectionChanged " + event.getSource()); //$NON-NLS-1$
+
+ VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
+ .getSourceInnerDragInfo(innerDragInfo);
+ VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
+ .getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
+ visualDropInfo, true);
+ if (sourceDropInfo.canDrop()) {
+ VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
+ .getInnerDropInfo(sourceDropInfo.getContainer(),
+ sourceDropInfo.getOffset());
+ if (newVisualDropInfo != null) {
+ visualBuilder.correctVisualDropPosition(
+ newVisualDropInfo, visualDropInfo);
+ sourceDropInfo.setTop(visualDropInfo.getMouseY());
+ sourceDropInfo.setLeft(visualDropInfo.getMouseX());
+ visualBuilder.innerDrop(sourceInnerDragInfo,
+ sourceDropInfo);
+ if (innerDragInfo != null) {
+ innerDragInfo.Release();
+ innerDragInfo = null;
+ }
+ }
}
- sourceSelectionChanged();
- switcher.stopActiveEditor();
+ }
}
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out.println();
+ }
+ }
- // nsIClipboardDragDropHooks implementation
- public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
- onHideTooltip();
+ public MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent,
+ String flavor, String data) {
+ InnerDragBuffer.object = null;
+ onHideTooltip();
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(mouseEvent);
- Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(visualDropInfo.getDropContainer(), (int)visualDropInfo.getDropOffset());
- VpeSourceInnerDropInfo sourceDropInfo = null;
+ if (dropWindow.active) {
+ if (!mouseEvent.getAltKey()) {
+ dropWindow.close();
+ } else {
+ return new MozillaDropInfo(false, null, 0);
+ }
+ }
+ if (mouseEvent.getAltKey()) {
+ nsIDOMEvent event = (nsIDOMEvent) mouseEvent
+ .queryInterface(nsIDOMEvent.NS_IDOMEVENT_IID);
+ nsIDOMNode visualNode = (nsIDOMNode) event.getTarget()
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+ Node sourceNode = domMapping.getNearSourceNode(visualNode);
+ if (sourceNode != null) {
+ if (ModelTransfer.MODEL.equals(flavor)) { //$NON-NLS-1$
+ // XModelObject object =
+ // PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
+ // InnerDragBuffer.object = object;
+ } else {
+ dropWindow.flavor = flavor;
+ }
+ dropWindow.active = true;
+ dropWindow.setEventPosition(mouseEvent.getScreenX(), mouseEvent
+ .getScreenY());
+ dropWindow.setInitialTargetNode(sourceNode);
+ dropWindow.open();
+ mouseEvent.stopPropagation();
+ mouseEvent.preventDefault();
+ return new MozillaDropInfo(false, null, 0);
+ }
+ }
+ boolean canDrop = false;
+ nsIDOMNode caretParent = null;
+ long caretOffset = 0;
- XModelObject object = PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
-
+ if (MODEL_FLAVOR.equals(flavor)) {
+ XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+ .getModelBuffer().source();
+ if (object.getFileType() == XModelObject.FILE
+ && !TLDUtil.isTaglib(object)) {
+ IFile f = (IFile) EclipseResourceUtil.getResource(object);
+ canDrop = f != null;
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ caretParent = visualDropInfo.getDropContainer();
+ caretOffset = visualDropInfo.getDropOffset();
+ } else {
String tagname = getTagName(object);
- if(tagname.indexOf("taglib") >= 0) tagname= "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document)getModel().getAdapter(Document.class)).createElement(tagname);
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
+ Node sourceDragNode = ((Document) getModel().getAdapter(
+ Document.class)).createElement(tagname);
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
if (visualDropInfo.getDropContainer() != null) {
- sourceDropInfo = visualBuilder.getSourceInnerDropInfo(sourceDragNode, visualDropInfo, true);
- range = selectionBuilder.getSourceSelectionRange(sourceDropInfo.getContainer(), sourceDropInfo.getOffset());
+ VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
+ .getSourceInnerDropInfo(sourceDragNode,
+ visualDropInfo, true);
+ canDrop = sourceDropInfo.canDrop();
+ if (canDrop) {
+ VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
+ .getInnerDropInfo(
+ sourceDropInfo.getContainer(),
+ sourceDropInfo.getOffset());
+ if (newVisualDropInfo != null) {
+ visualBuilder.correctVisualDropPosition(
+ newVisualDropInfo, visualDropInfo);
+ caretParent = newVisualDropInfo.getDropContainer();
+ caretOffset = newVisualDropInfo.getDropOffset();
+ }
+ }
}
-
+ visualDropInfo.Release();
+ }
+ } else if (XulRunnerEditor.TRANS_FLAVOR_kFileMime.equals(flavor)
+ || XulRunnerEditor.TRANS_FLAVOR_kURLMime.equals(flavor)) {
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ caretParent = visualDropInfo.getDropContainer();
+ caretOffset = visualDropInfo.getDropOffset();
+ try {
+ canDrop = true;
+ } catch (Exception ex) {
+ VpePlugin.reportProblem(ex);
+ }
+ }
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .println(" canDrop: " + canDrop + (canDrop ? " container: " + caretParent.getNodeName() + " offset: " + caretOffset : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+
+ }
+
+ public VpeSourceInnerDropInfo canExternalDropMacro(XModelObject object,
+ Node parentNode, int offset) {
+ String tagname = getTagName(object);
+ Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
+ .createElement(tagname);
+ return visualBuilder.getSourceInnerDropInfo(sourceDragNode, parentNode,
+ offset, false);
+ }
+
+ public void externalDropAny(final String flavor, final String data,
+ final Point range, Node container) {
+ if (flavor == null || flavor.length() == 0)
+ return;
+ IDropCommand dropCommand = DropCommandFactory.getInstance()
+ .getDropCommand(flavor, JSPTagProposalFactory.getInstance());
+
+ boolean promptAttributes = "yes"
+ .equals(VpePreference.ALWAYS_REQUEST_FOR_ATTRIBUTE.getValue());
+ dropCommand.getDefaultModel().setPromptForTagAttributesRequired(
+ promptAttributes);
+
+ dropCommand.execute(new DropData(flavor, data, sourceEditor
+ .getEditorInput(), (ISourceViewer) sourceEditor
+ .getAdapter(ISourceViewer.class), new VpeSelectionProvider(
+ range.x, range.y), container));
+ }
+
+ private String getTagName(XModelObject object) {
+ String tagname = object.getAttributeValue("name"); //$NON-NLS-1$
+
+ XModelObject parent = object.getParent();
+ String uri = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
+ String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
+
+ String[] texts = new String[] { "<" + tagname + ">" }; //$NON-NLS-1$ //$NON-NLS-2$
+ PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri,
+ defaultPrefix);
+ tagname = texts[0].substring(1, texts[0].length() - 1);
+
+ return tagname;
+ }
+
+ public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor,
+ String data) {
+ onHideTooltip();
+
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
+ visualDropInfo.getDropContainer(), (int) visualDropInfo
+ .getDropOffset());
+ VpeSourceInnerDropInfo sourceDropInfo = null;
+
+ if (MODEL_FLAVOR.equals(flavor)) {
+ XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+ .getModelBuffer().source();
+ if (object.getFileType() == XModelObject.FILE
+ && !TLDUtil.isTaglib(object)) {
+ flavor = "application/x-moz-file"; //$NON-NLS-1$
+ IFile f = (IFile) EclipseResourceUtil.getResource(object);
+ try {
+ data = f.getLocation().toFile().toURL().toString();
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ } else {
+ String tagname = getTagName(object);
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
+ Node sourceDragNode = ((Document) getModel().getAdapter(
+ Document.class)).createElement(tagname);
if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
- }
- final String finalFlavor = flavor;
- final String finalData = data;
- final Point finalRange = range;
- final Node finalDropContainer = sourceDropInfo == null ? null : sourceDropInfo.getContainer();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- externalDropAny(finalFlavor, finalData, finalRange, finalDropContainer);
- }
- });
+ sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
+ sourceDragNode, visualDropInfo, true);
+ range = selectionBuilder.getSourceSelectionRange(
+ sourceDropInfo.getContainer(), sourceDropInfo
+ .getOffset());
}
+ }
}
- public void drop(Node node, Node parentNode, int offset) {
- visualBuilder.innerDrop(node, parentNode, offset);
+ if (visualDropInfo.getDropContainer() != null) {
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ }
+ externalDropAny(flavor, data, range, sourceDropInfo == null ? null
+ : sourceDropInfo.getContainer());
}
+ }
- /* (non-Javadoc)
- * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ public void onShowTooltip(int x, int y, final String text) {
+
+ if (tip != null && !tip.isDisposed())
+ tip.dispose();
+
+ Display display = visualEditor.getControl().getDisplay();
+ Shell parent = visualEditor.getControl().getShell();
+
+ tip = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP);
+ Color bckgColor = new Color(tip.getDisplay(), 255, 250, 236);
+ tip.setBackground(bckgColor);
+
+ Composite composite = tip;
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
+ composite.setLayout(layout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(gd);
+
+ final StyledText tipControlHeaderText = new StyledText(composite,
+ SWT.MULTI | SWT.READ_ONLY);
+
+ tipControlHeaderText.setForeground(bckgColor);
+ tipControlHeaderText.setBackground(bckgColor);
+
+ String formatText = text.trim();
+
+ /**
+ * attributeString string containing the pairs attribute and it's value
+ * as one string
*/
- public nsISupports queryInterface(String arg0) {
- return Mozilla.getInstance().queryInterface(this, arg0);
- }
+ String[] attributeString = formatText.split("\n"); //$NON-NLS-1$
/**
- * Calls when editor content should be refreshed
+ * buffer string containing the attribute and the value in the different
+ * succeding string
*/
- public void onRefresh() {
- //when we using separate thread to display selection rectangle
- //it's working better than without
- /*
- * HACK
- * We need wait some time while standart event will be handled
- * and in process event handles some components are repainted(like buttons)
- * and flasher are not repainted, so we should paint flasher
- */
+ String[] buffer = attributeString[0].split(" "); //$NON-NLS-1$
-
- Display.getDefault().asyncExec(new Thread(){
- public void run(){
-
- getXulRunnerEditor().showSelectionRectangle();
- }
- });
-
+ tipControlHeaderText.setText(buffer[0].toString());
+
+ tipControlHeaderText.addLineStyleListener(new LineStyleListener() {
+ public void lineGetStyle(LineStyleEvent event) {
+ Color color = new Color(tipControlHeaderText.getDisplay(), 201,
+ 51, 40);
+ if (event.lineOffset == 0) {
+ StyleRange st = new StyleRange();
+ st.fontStyle = SWT.BOLD;
+ st.foreground = color;
+ event.styles = new StyleRange[] { st };
+ st.start = event.lineOffset;
+ st.length = event.lineText.length();
+ }
+ }
+ });
+
+ GridData gridData = new GridData(GridData.BEGINNING
+ | GridData.FILL_BOTH);
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 2;
+ tipControlHeaderText.setLayoutData(gridData);
+
+ StringBuffer tempAttr = new StringBuffer();
+ StringBuffer tempValue = new StringBuffer();
+
+ if (attributeString.length >= 2) {
+ for (int i = 1; i < attributeString.length; i++) {
+ buffer = attributeString[i].split(" ", 2); //$NON-NLS-1$
+ if (i == 1) {
+ tempAttr.append(buffer[0] + " "); //$NON-NLS-1$
+ tempValue
+ .append((buffer.length >= 2 ? buffer[1] : "") + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ tempAttr.append("\n" + buffer[0] + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ tempValue
+ .append(" \n" + (buffer.length >= 2 ? buffer[1] : "") + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ final StyledText tipControlAttributeText = new StyledText(
+ composite, SWT.MULTI | SWT.READ_ONLY);
+
+ tipControlAttributeText.setForeground(bckgColor);
+ tipControlAttributeText.setBackground(bckgColor);
+
+ tipControlAttributeText.setText(tempAttr.toString());
+ tipControlAttributeText
+ .addLineStyleListener(new LineStyleListener() {
+ public void lineGetStyle(LineStyleEvent event) {
+ Color color = new Color(tipControlHeaderText
+ .getDisplay(), 42, 148, 0);
+ StyleRange st = new StyleRange();
+ st.start = event.lineOffset;
+ st.length = event.lineText.length();
+ st.foreground = color;
+ st.fontStyle = SWT.NORMAL;
+ event.styles = new StyleRange[] { st };
+ }
+ });
+ GridData gridData1 = new GridData(GridData.BEGINNING
+ | GridData.FILL_BOTH);
+ gridData1.horizontalAlignment = GridData.FILL;
+ tipControlAttributeText.setLayoutData(gridData1);
+
+ final StyledText tipControlValueText = new StyledText(composite,
+ SWT.MULTI | SWT.READ_ONLY);
+
+ tipControlValueText.setBackground(bckgColor);
+
+ tipControlValueText.setText(tempValue.toString());
+
+ GridData gridData2 = new GridData(GridData.BEGINNING
+ | GridData.FILL_BOTH);
+ gridData2.horizontalAlignment = GridData.FILL;
+ tipControlValueText.setLayoutData(gridData2);
}
+ /*
+ * Bug in Mozilla embedded API. Tooltip coordinates are wrong for
+ * elements inside an inline frame (IFrame tag). The workaround is to
+ * position the tooltip based on the mouse cursor location.
+ */
+ Point point = display.getCursorLocation();
+ /*
+ * Assuming cursor is 21x21 because this is the size of the arrow cursor
+ * on Windows
+ */
+ point.y += 21;
+ tip.setLocation(point);
+ tip.pack();
+ tip.setVisible(true);
+ }
- /**
- * @return the xulRunnerEditor
- */
- public XulRunnerEditor getXulRunnerEditor() {
- return xulRunnerEditor;
+ public void onHideTooltip() {
+ if (tip != null && !tip.isDisposed())
+ tip.dispose();
+ tip = null;
+ }
+
+ public VpePageContext getPageContext() {
+
+ return pageContext;
+ }
+
+ public StructuredTextEditor getSourceEditor() {
+ return sourceEditor;
+ }
+
+ public FormatControllerManager getToolbarFormatControllerManager() {
+ return toolbarFormatControllerManager;
+ }
+
+ public void setToolbarFormatControllerManager(
+ FormatControllerManager formatControllerManager) {
+ toolbarFormatControllerManager = formatControllerManager;
+ }
+
+ public void setSelectionBarController(SelectionBar selectionBar) {
+ this.selectionBar = selectionBar;
+ }
+
+ public IStructuredModel getModel() {
+ return sourceEditor.getModel();
+ }
+
+ public VpeDomMapping getDomMapping() {
+ return domMapping;
+ }
+
+ public VpeIncludeList getIncludeList() {
+ try {
+ if (includeList == null)
+ throw new Exception("includeList - NULL!!!"); //$NON-NLS-1$
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
}
+ return includeList;
+ }
- /**
- * @param xulRunnerEditor the xulRunnerEditor to set
- */
- public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
- this.xulRunnerEditor = xulRunnerEditor;
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (editPart.getVisualMode() != VpeEditorPart.SOURCE_MODE) {
+ if (toolbarFormatControllerManager != null)
+ toolbarFormatControllerManager.selectionChanged();
}
-
- /**
- * Start drag session
- */
- public void startDragSession(nsIDOMEvent domEvent) {
-
- visualBuilder.getDnd().startDragSession(domEvent);
+
+ if (selectionBar != null)
+ selectionBar.selectionChanged();
+
+ if (!switcher
+ .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ return;
}
+ if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
+ System.out
+ .println(">>>>>>>>>>>>>> selectionChanged " + event.getSource()); //$NON-NLS-1$
+ }
+ sourceSelectionChanged();
+ switcher.stopActiveEditor();
+ }
- public void dragDrop(nsIDOMEvent domEvent) {
-
- visualBuilder.getDnd().dragDrop(domEvent,this);
+ // nsIClipboardDragDropHooks implementation
+ public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor,
+ String data) {
+ onHideTooltip();
+
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+ .getInnerDropInfo(mouseEvent);
+ Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
+ visualDropInfo.getDropContainer(), (int) visualDropInfo
+ .getDropOffset());
+ VpeSourceInnerDropInfo sourceDropInfo = null;
+
+ XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+ .getModelBuffer().source();
+
+ String tagname = getTagName(object);
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
+ Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
+ .createElement(tagname);
+ if (visualDropInfo.getDropContainer() != null) {
+ sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
+ sourceDragNode, visualDropInfo, true);
+ range = selectionBuilder.getSourceSelectionRange(sourceDropInfo
+ .getContainer(), sourceDropInfo.getOffset());
}
- /**
- * @return the selectionBuilder
- */
- public VpeSelectionBuilder getSelectionBuilder() {
- return selectionBuilder;
+ if (visualDropInfo.getDropContainer() != null) {
+ if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+ System.out
+ .println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+ }
+ final String finalFlavor = flavor;
+ final String finalData = data;
+ final Point finalRange = range;
+ final Node finalDropContainer = sourceDropInfo == null ? null
+ : sourceDropInfo.getContainer();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ externalDropAny(finalFlavor, finalData, finalRange,
+ finalDropContainer);
+ }
+ });
}
+ }
- /**
- * @param selectionBuilder the selectionBuilder to set
+ public void drop(Node node, Node parentNode, int offset) {
+ visualBuilder.innerDrop(node, parentNode, offset);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ */
+ public nsISupports queryInterface(String arg0) {
+ return Mozilla.getInstance().queryInterface(this, arg0);
+ }
+
+ /**
+ * Calls when editor content should be refreshed
+ */
+ public void onRefresh() {
+ // when we using separate thread to display selection rectangle
+ // it's working better than without
+ /*
+ * HACK We need wait some time while standart event will be handled and
+ * in process event handles some components are repainted(like buttons)
+ * and flasher are not repainted, so we should paint flasher
*/
- public void setSelectionBuilder(VpeSelectionBuilder selectionBuilder) {
- this.selectionBuilder = selectionBuilder;
- }
+ Display.getDefault().asyncExec(new Thread() {
+ public void run() {
+
+ getXulRunnerEditor().showSelectionRectangle();
+ }
+ });
+
+ }
+
+ /**
+ * @return the xulRunnerEditor
+ */
+ public XulRunnerEditor getXulRunnerEditor() {
+ return xulRunnerEditor;
+ }
+
+ /**
+ * @param xulRunnerEditor
+ * the xulRunnerEditor to set
+ */
+ public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
+ this.xulRunnerEditor = xulRunnerEditor;
+ }
+
+ /**
+ * Start drag session
+ */
+ public void startDragSession(nsIDOMEvent domEvent) {
+
+ visualBuilder.getDnd().startDragSession(domEvent);
+ }
+
+ public void dragDrop(nsIDOMEvent domEvent) {
+
+ visualBuilder.getDnd().dragDrop(domEvent, this);
+ }
+
+ /**
+ * @return the selectionBuilder
+ */
+ public VpeSelectionBuilder getSelectionBuilder() {
+ return selectionBuilder;
+ }
+
+ /**
+ * @param selectionBuilder
+ * the selectionBuilder to set
+ */
+ public void setSelectionBuilder(VpeSelectionBuilder selectionBuilder) {
+ this.selectionBuilder = selectionBuilder;
+ }
+
}
17 years, 8 months
JBoss Tools SVN: r7379 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-04-07 08:17:45 -0400 (Mon, 07 Apr 2008)
New Revision: 7379
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/WizardKeys.java
Log:
JBIDE-1998
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/WizardKeys.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/WizardKeys.java 2008-04-07 11:58:46 UTC (rev 7378)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/WizardKeys.java 2008-04-07 12:17:45 UTC (rev 7379)
@@ -118,10 +118,10 @@
int k = st.countTokens();
for (int i = 0; i < k; i++) {
String t = st.nextToken();
- if(i > 0 && (t.length() < 3 || LOWER_CASE_WORDS.contains(t))) {
+ if(UPPER_CASE_WORDS.contains(t)) {
+ sb.append(t.toUpperCase());
+ } else if(i > 0 && (t.length() < 3 || LOWER_CASE_WORDS.contains(t))) {
sb.append(t);
- } else if(UPPER_CASE_WORDS.contains(t)) {
- sb.append(t.toUpperCase());
} else {
sb.append(t.substring(0, 1).toUpperCase()).append(t.substring(1));
}
17 years, 8 months
JBoss Tools SVN: r7378 - trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-04-07 07:58:46 -0400 (Mon, 07 Apr 2008)
New Revision: 7378
Modified:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java
Log:
JBIDE-893
Modified: trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java 2008-04-07 11:37:37 UTC (rev 7377)
+++ trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/MetaModelTest.java 2008-04-07 11:58:46 UTC (rev 7378)
@@ -28,6 +28,7 @@
import org.jboss.tools.common.meta.impl.XModelEntityImpl;
import org.jboss.tools.common.meta.impl.XModelMetaDataImpl;
import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.engines.impl.EnginesLoader;
import org.jboss.tools.common.model.event.XModelTreeEvent;
@@ -336,7 +337,11 @@
XModelObjectLoaderUtil.setTempBody(object2, body);
loader.load(object2);
MergeListener m = new MergeListener(model);
- EnginesLoader.merge(object, object2);
+ try {
+ EnginesLoader.merge(object, object2);
+ } catch (XModelException e) {
+ fail(e.getMessage());
+ }
m.dispose();
if(!m.equal) {
errors++;
17 years, 8 months
JBoss Tools SVN: r7377 - trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-04-07 07:37:37 -0400 (Mon, 07 Apr 2008)
New Revision: 7377
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2008
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java 2008-04-07 10:27:11 UTC (rev 7376)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java 2008-04-07 11:37:37 UTC (rev 7377)
@@ -35,7 +35,7 @@
*/
public class SaveQueryEditorListener implements IPropertyListener {
- public static final String id = "AbstractQueryEditor.ReplaceString";
+ public static final String id = "AbstractQueryEditor.ReplaceString"; //$NON-NLS-1$
public static final int HQLEditor = 0;
@@ -95,6 +95,24 @@
String editorTitle = fromEditorPart.getTitle();
if (IEditorPart.PROP_DIRTY == propId && !editor.isDirty()){
+ IDocumentProvider docProvider = fromEditorPart.getDocumentProvider();
+
+ IDocument doc = docProvider.getDocument( fromEditorPart.getEditorInput() );
+ boolean isDocChanged = true;
+ try {
+ if (query.equals(doc.get(position.x, position.y))){
+ isDocChanged = false;
+ }
+ } catch (BadLocationException e1) {
+ //document changed and we can get the exception
+ }
+
+ if (isDocChanged){
+ String confirm_changed = NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion_confirm, query, editorTitle);
+ MessageDialog.openConfirm( null, JdtUIMessages.SaveQueryEditorListener_replaceTitle_confirm, confirm_changed);
+ return;
+ }
+
String newQuery = editor.getQueryString();
String question = NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion, new String[]{query, editorTitle, newQuery});
@@ -112,25 +130,7 @@
if (Window.CANCEL == ans){
return;
}
-
- IDocumentProvider docProvider = fromEditorPart.getDocumentProvider();
-
- IDocument doc = docProvider.getDocument( fromEditorPart.getEditorInput() );
- boolean isDocChanged = true;
- try {
- if (query.equals(doc.get(position.x, position.y))){
- isDocChanged = false;
- }
- } catch (BadLocationException e1) {
- //document changed and we can get the exception
- }
- if (isDocChanged){
- String confirm_changed = NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion_confirm, query, editorTitle);
- MessageDialog.openConfirm( null, JdtUIMessages.SaveQueryEditorListener_replaceTitle_confirm, confirm_changed);
- return;
- }
-
try {
// replace old string with new one and change positions
doc.replace(position.x, position.y, newQuery);
17 years, 8 months
JBoss Tools SVN: r7376 - trunk/jsf/docs/userguide/en/modules.
by jbosstools-commits@lists.jboss.org
Author: ykryvinchanka
Date: 2008-04-07 06:27:11 -0400 (Mon, 07 Apr 2008)
New Revision: 7376
Modified:
trunk/jsf/docs/userguide/en/modules/palette.xml
Log:
http://jira.jboss.com/jira/browse/JBDS-232 Some corrections in xml code
Modified: trunk/jsf/docs/userguide/en/modules/palette.xml
===================================================================
--- trunk/jsf/docs/userguide/en/modules/palette.xml 2008-04-07 09:35:04 UTC (rev 7375)
+++ trunk/jsf/docs/userguide/en/modules/palette.xml 2008-04-07 10:27:11 UTC (rev 7376)
@@ -9,9 +9,9 @@
</keywordset>
</chapterinfo>
<title>JBoss Tools Palette</title>
- <para>This chapter will introduce you to the functionality provide by <property>JBoss Tools
- Palette</property>. Palette allows you to quickly and easily create your JSP or JSF
- page. Now you can do it more faster without additional knowledge.</para>
+ <para>This chapter will introduce you to the functionality provided by <property>JBoss Tools
+ Palette</property>. The Palette allows you to quickly and easily create your JSP or JSF
+ pages. Now you can do it more faster without additional knowledge.</para>
<para>The <property>JBoss Tools Palette</property> allows you to:</para>
<itemizedlist>
<listitem>
@@ -23,7 +23,7 @@
</itemizedlist>
<para>The JBoss Tools Palette contains a developer's project tag libraries and provides
possibility to add any tag libraries to it. Also you can choose a necessary one from the
- list of already existent tag libraries:</para>
+ list of already existed tag libraries:</para>
<itemizedlist>
<listitem>
<para>HTML</para>
@@ -51,7 +51,7 @@
</listitem>
</itemizedlist>
<figure>
- <title>JBoss Tools Palette</title>
+ <title>Default View of The JBoss Tools Palette</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/palette/palette_1.png"/>
@@ -67,8 +67,8 @@
<section id="PaletteOptions">
<?dbhtml filename="PaletteOptions.html"?>
<title>Palette Options</title>
- <para>To ease your work, you can configure the Palette for your own, by selecting the
- corresponding icon on the Palette toolbar.</para>
+ <para>To facilitate your work, you can configure the Palette in your own way, by selecting
+ the corresponding icon on the Palette toolbar.</para>
<para>There is a possibility to configure the JBoss Tools Palette:</para>
<itemizedlist>
<listitem>
@@ -98,7 +98,7 @@
new one, as well.</para>
<para>To open the editor, click on the <emphasis>
<property>Palette Editor</property>
- </emphasis> icon: <itemizedlist>
+ </emphasis> icon:
<figure>
<title>Palette Editor Icon</title>
<mediaobject>
@@ -132,7 +132,8 @@
</figure>
<para>The Palette Editor provides the following possibilities when working with
existing tags or icons:</para>
- <listitem>
+ <itemizedlist>
+ <listitem>
<para>to work with a set of icons</para>
<para><emphasis>
<property>Icons</property>
@@ -296,29 +297,30 @@
</imageobject>
</mediaobject>
</figure>
- </listitem>
- <para>After all the attributes are set, click <emphasis>
+ <para>After all the attributes are set, click <emphasis>
<property>Finish</property>
</emphasis> button.</para>
- <note>
- <title>Note:</title>
- <para>If you do not choose an icon the default one will be assigned.</para>
- </note>
- <para>You are allowed to edit or delete the tag . If you'd like to
- change the attributes of the tag or choose another icon for it, use the
- right editing window of the palette editor or the <emphasis>
- <property>Edit...</property>
- </emphasis> option from the pop-up menu. In order to remove the tag, right
- click on the tag that you wish to remove and chose the <emphasis>
- <property>Delete</property>
- </emphasis> option or click the <emphasis>
- <property>Delete</property>
- </emphasis> keyboard button.</para>
- <important>
- <title>Important:</title>
- <para>The removal option is enabled only for custom tags. JBoss Palette tags
- can not be removed but can be modified.</para>
- </important>
+ <note>
+ <title>Note:</title>
+ <para>If you do not choose an icon the default one will be assigned.</para>
+ </note>
+ <para>You are also allowed to edit or delete the tag. If you'd like to
+ change the attributes of the tag or choose another icon for it, use the
+ right editing window of the palette editor or the <emphasis>
+ <property>Edit...</property>
+ </emphasis> option from the pop-up menu. In order to remove the tag, right
+ click on the tag that you wish to remove and chose the <emphasis>
+ <property>Delete</property>
+ </emphasis> option or click the <emphasis>
+ <property>Delete</property>
+ </emphasis> keyboard button.</para>
+ <important>
+ <title>Important:</title>
+ <para>The removal option is enabled only for custom tags. JBoss Palette tags
+ can not be removed but can be modified.</para>
+ </important>
+ </listitem>
+
</itemizedlist>
</para>
</section>
@@ -378,8 +380,8 @@
</imageobject>
</mediaobject>
</figure>
- <para>The name of the elements is compound. The first part is the group’s name and the
- second is the library’s name.</para>
+ <para>The names of the elements are compound. The first part is the group name and the
+ second is the library name.</para>
</section>
<section id="Import">
<?dbhtml filename="Import.html"?>
@@ -387,7 +389,7 @@
<para>The Import button lets you add a custom or 3rd party tag library to JBoss Tools
Palette. Find out more information on how to add particular tags see the <link
linkend="ImportButton521">Adding Custom JSF Tags</link> section.
- <!--<link linkend="CreatingAndWorkingCustomCapability">Learn how to import</link>. --></para>
+ <!--<link linkend="CreatingAndWorkingCustomCapability">Learn how to import</link>. --></para>
</section>
</section>
<section id="UsingThePalette(IncludingOne-ClickTagInsertion)">
@@ -505,7 +507,7 @@
</emphasis> are detected, thus just need to set the <emphasis>
<property>Group</property>
</emphasis> name to which you wish to place this tag library. You can either add
- this tag library to an existing Group or just create a new one.</para>
+ this tag library to an existing Group or just create a new one.</para>
<figure>
<title>Import Tags From TLD File Form</title>
<mediaobject>
17 years, 8 months
JBoss Tools SVN: r7375 - in trunk/jsf/docs/userguide/en: modules and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: ykryvinchanka
Date: 2008-04-07 05:35:04 -0400 (Mon, 07 Apr 2008)
New Revision: 7375
Modified:
trunk/jsf/docs/userguide/en/images/editors_features/editors_features_25.png
trunk/jsf/docs/userguide/en/images/editors_features/editors_features_26.png
trunk/jsf/docs/userguide/en/modules/editors.xml
Log:
http://jira.jboss.com/jira/browse/JBDS-226 VWT. Editor chapter. Screens correction + scale param redefined
Modified: trunk/jsf/docs/userguide/en/images/editors_features/editors_features_25.png
===================================================================
(Binary files differ)
Modified: trunk/jsf/docs/userguide/en/images/editors_features/editors_features_26.png
===================================================================
(Binary files differ)
Modified: trunk/jsf/docs/userguide/en/modules/editors.xml
===================================================================
--- trunk/jsf/docs/userguide/en/modules/editors.xml 2008-04-07 09:31:19 UTC (rev 7374)
+++ trunk/jsf/docs/userguide/en/modules/editors.xml 2008-04-07 09:35:04 UTC (rev 7375)
@@ -429,7 +429,7 @@
<mediaobject>
<imageobject>
<imagedata
- fileref="images/editors_features/editors_features_21.png"/>
+ fileref="images/editors_features/editors_features_21.png" scale="75"/>
</imageobject>
</mediaobject>
</figure>
@@ -462,7 +462,7 @@
<mediaobject>
<imageobject>
<imagedata
- fileref="images/editors_features/editors_features_23.png" />
+ fileref="images/editors_features/editors_features_23.png" scale="75"/>
</imageobject>
</mediaobject>
</figure>
@@ -476,7 +476,7 @@
<mediaobject>
<imageobject>
<imagedata
- fileref="images/editors_features/editors_features_24.png"/>
+ fileref="images/editors_features/editors_features_24.png" scale="75"/>
</imageobject>
</mediaobject>
</figure>
@@ -490,7 +490,7 @@
<mediaobject>
<imageobject>
<imagedata
- fileref="images/editors_features/editors_features_25.png"/>
+ fileref="images/editors_features/editors_features_25.png" scale="60"/>
</imageobject>
</mediaobject>
</figure>
@@ -500,7 +500,7 @@
<mediaobject>
<imageobject>
<imagedata
- fileref="images/editors_features/editors_features_26.png"/>
+ fileref="images/editors_features/editors_features_26.png" scale="60"/>
</imageobject>
</mediaobject>
</figure>
@@ -513,7 +513,7 @@
<mediaobject>
<imageobject>
<imagedata
- fileref="images/editors_features/editors_features_27.png"/>
+ fileref="images/editors_features/editors_features_27.png" scale="75"/>
</imageobject>
</mediaobject>
</figure>
@@ -533,8 +533,7 @@
<title>Content Assist for Rich Faces Components</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/editors_features/editors_features_29.png"
- />
+ <imagedata fileref="images/editors_features/editors_features_29.png" scale="65"/>
</imageobject>
</mediaobject>
</figure>
@@ -557,7 +556,7 @@
<mediaobject>
<imageobject>
<imagedata
- fileref="images/editors_features/editors_features_30.png"
+ fileref="images/editors_features/editors_features_30.png" scale="75"
/>
</imageobject>
</mediaobject>
@@ -571,7 +570,7 @@
<title>Rich Faces Component</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/editors_features/editors_features_31.png"
+ <imagedata fileref="images/editors_features/editors_features_31.png" scale="75"
/>
</imageobject>
</mediaobject>
17 years, 8 months
JBoss Tools SVN: r7374 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2008-04-07 05:31:19 -0400 (Mon, 07 Apr 2008)
New Revision: 7374
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1588, nested groups and items indentation added
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-04-07 08:29:45 UTC (rev 7373)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-04-07 09:31:19 UTC (rev 7374)
@@ -78,6 +78,9 @@
private static final String WIDTH_100_PERSENTS = "width: 100%; "; //$NON-NLS-1$
private static final String MARGIN_TOP = "margin-top: 3px; "; //$NON-NLS-1$
+ private static final String NO_SIZE_VALUE = "0"; //$NON-NLS-1$
+ private static final String DEFAULT_SIZE_VALUE = "16"; //$NON-NLS-1$
+
/*
* rich:panelMenu attributes for groups
*/
@@ -207,7 +210,7 @@
.encode(pageContext, creationData,
sourceParentElement,
(Element) child, visualDocument,
- div);
+ div, childId);
}
}
@@ -253,6 +256,23 @@
nsIDOMElement tableBodyRow = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(tableBodyRow);
+
+ /*
+ * Add indentation for nested gruops
+ */
+ String[] ids = activeChildId.split(GROUP_COUNT_SEPARATOR);
+ if (ids.length > 1) {
+ for (int i = 1; i <= ids.length - 1; i++) {
+ nsIDOMElement spacerTd = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ nsIDOMElement spacerImg = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ spacerTd.appendChild(spacerImg);
+ ComponentUtil.setImg(spacerImg, PANEL_MENU_GROUP_ICON_SPACER_PATH);
+ setDefaultImgAttributes(spacerImg);
+ tableBodyRow.appendChild(spacerTd);
+ }
+ }
nsIDOMElement column1 = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TD);
@@ -355,6 +375,15 @@
table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, tableStyle);
}
+ private static void setDefaultImgAttributes(nsIDOMElement element) {
+ element.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH,
+ DEFAULT_SIZE_VALUE);
+ element.setAttribute("vspace", NO_SIZE_VALUE); //$NON-NLS-1$
+ element.setAttribute("hspace", NO_SIZE_VALUE); //$NON-NLS-1$
+ element.setAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT,
+ DEFAULT_SIZE_VALUE);
+ }
+
private static final Element getRichPanelParent(Element sourceElement) {
Element parent = (Element) sourceElement.getParentNode();
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-04-07 08:29:45 UTC (rev 7373)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-04-07 09:31:19 UTC (rev 7374)
@@ -120,7 +120,7 @@
public static VpeCreationData encode(VpePageContext pageContext,
VpeCreationData creationData, Element sourceParentElement,
Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement parentVisualElement) {
+ nsIDOMElement parentVisualElement, String childId) {
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
@@ -158,6 +158,30 @@
nsIDOMElement tr = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(tr);
+
+ /*
+ * Add indentation for nested items
+ */
+ String[] ids = childId.split(RichFacesPanelMenuGroupTemplate.GROUP_COUNT_SEPARATOR);
+ if (ids.length > 0) {
+ for (int i = 1; i <= ids.length; i++) {
+ /*
+ * Skip indentation in top menu items
+ */
+ if (EMPTY.equalsIgnoreCase(ids[0])) {
+ continue;
+ }
+ nsIDOMElement spacerTd = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ nsIDOMElement spacerImg = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ spacerTd.appendChild(spacerImg);
+ ComponentUtil.setImg(spacerImg, IMG_SPACER_SRC);
+ setDefaultImgAttributes(spacerImg);
+ tr.appendChild(spacerTd);
+ }
+ }
+
nsIDOMElement tdNowrap = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TD);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2008-04-07 08:29:45 UTC (rev 7373)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2008-04-07 09:31:19 UTC (rev 7374)
@@ -103,6 +103,7 @@
private static final String PANEL_MENU_ITEM_END = ":panelMenuItem"; //$NON-NLS-1$
private static final String TRUE = "true"; //$NON-NLS-1$
private static final String MARGIN_TOP = "margin-top: 3px; "; //$NON-NLS-1$
+ private static final String TOP_MENU_ITEM_ID = ""; //$NON-NLS-1$
private List<String> activeIds = new ArrayList<String>();
@@ -148,7 +149,7 @@
} else if (child.getNodeName().endsWith(PANEL_MENU_ITEM_END)) {
RichFacesPanelMenuItemTemplate.encode(pageContext,
vpeCreationData, sourceElement, (Element) child,
- visualDocument, div);
+ visualDocument, div, TOP_MENU_ITEM_ID);
} else {
nsIDOMElement childDiv = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
17 years, 8 months
JBoss Tools SVN: r7373 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-04-07 04:29:45 -0400 (Mon, 07 Apr 2008)
New Revision: 7373
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2005
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-04-07 08:21:36 UTC (rev 7372)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-04-07 08:29:45 UTC (rev 7373)
@@ -11,7 +11,6 @@
package org.jboss.tools.jsf.vpe.jsf.template;
import java.util.ArrayList;
-import java.util.List;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.vpe.editor.context.VpePageContext;
17 years, 8 months
JBoss Tools SVN: r7372 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-04-07 04:21:36 -0400 (Mon, 07 Apr 2008)
New Revision: 7372
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2005
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-04-07 08:18:53 UTC (rev 7371)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-04-07 08:21:36 UTC (rev 7372)
@@ -10,9 +10,13 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.template;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.EditableTemplateAdapter;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
@@ -39,24 +43,53 @@
Element element = (Element) sourceNode;
+ // create span
nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
+ // get children
NodeList list = element.getChildNodes();
- if (list.getLength() != 0) {
- Node firstNode = list.item(0);
- Node lastNode = list.item(list.getLength() - 1);
+ // creation data
+ VpeCreationData creationData = new VpeCreationData(span);
- String text = TemplateManagingUtil.getSourceText(pageContext,
- ((IDOMNode) firstNode).getStartOffset(),
- ((IDOMNode) lastNode).getEndOffset() - 1);
+ // for each child
+ for (int i = 0; i < list.getLength(); i++) {
- span.appendChild(visualDocument.createTextNode(text));
+ Node child = list.item(i);
+ // create span for child
+ nsIDOMElement childSpan = visualDocument
+ .createElement(HTML.TAG_SPAN);
+ span.appendChild(childSpan);
+
+ // if child is text or not html tag
+ if ((child.getNodeType() == Node.ELEMENT_NODE && child.getPrefix() != null)
+ || (child.getNodeType() == Node.TEXT_NODE)) {
+
+ // create children info and add to creationData
+ VpeChildrenInfo childSpanInfo = new VpeChildrenInfo(childSpan);
+ childSpanInfo.addSourceChild(child);
+ creationData.addChildrenInfo(childSpanInfo);
+
+ } else {
+ // get text by positions and add to span
+ String text = TemplateManagingUtil.getSourceText(pageContext,
+ ((IDOMNode) child).getStartOffset(), ((IDOMNode) child)
+ .getEndOffset() - 1);
+ span.appendChild(visualDocument.createTextNode(text));
+ }
+
}
- VpeCreationData creationData = new VpeCreationData(span);
+ // for case when all children are html tags
+ if ((list.getLength() != 0)
+ && (creationData.getChildrenInfoList() == null)) {
+ // set empty children info list to visualDomBuilder doesn't
+ // search children himself
+ creationData.setChildrenInfoList(new ArrayList<VpeChildrenInfo>());
+ }
+
return creationData;
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-04-07 08:18:53 UTC (rev 7371)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-04-07 08:21:36 UTC (rev 7372)
@@ -12,7 +12,7 @@
<vpe:tag name="f:verbatim" case-sensitive="yes">
<vpe:if test="(@escape='true')">
- <vpe:template children="no" modify="yes"
+ <vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.jsf.template.JsfVerbatim">
<vpe:dnd>
<vpe:drag start-enable="yes" />
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2008-04-07 08:18:53 UTC (rev 7371)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2008-04-07 08:21:36 UTC (rev 7372)
@@ -7,13 +7,12 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.ArrayList;
import java.util.List;
-import org.jboss.tools.common.model.util.XMLUtil;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
@@ -24,7 +23,7 @@
private nsIDOMNode node;
private List<VpeChildrenInfo> childrenInfoList;
private List<Node> illegalChildren;
-
+
/**
* @deprecated - You must use elementData. If VpeElementData has not
* necessary functionality you must extend its
@@ -39,29 +38,33 @@
public nsIDOMNode getNode() {
return node;
}
-
- public void addChildrenInfo(VpeChildrenInfo info) {
+
+ public void addChildrenInfo(VpeChildrenInfo info) {
if (childrenInfoList == null) {
childrenInfoList = new ArrayList<VpeChildrenInfo>();
}
childrenInfoList.add(info);
}
-
+
+ public void setChildrenInfoList(List<VpeChildrenInfo> childrenInfoList) {
+ this.childrenInfoList = childrenInfoList;
+ }
+
public List<VpeChildrenInfo> getChildrenInfoList() {
return childrenInfoList;
}
-
+
public void addIllegalChild(Node child) {
if (illegalChildren == null) {
illegalChildren = new ArrayList<Node>();
}
illegalChildren.add(child);
}
-
+
public List<Node> getIllegalChildren() {
return illegalChildren;
}
-
+
/**
* @deprecated - You must use elementData. If VpeElementData has not
* necessary functionality you must extend its
@@ -73,15 +76,16 @@
/**
* @deprecated - You must use elementData. If VpeElementData has not
- * necessary functionality you must extend its
+ * necessary functionality you must extend its
* @return
*/
public Object getData() {
return data;
}
-
+
/**
* get element data
+ *
* @return
*/
public VpeElementData getElementData() {
@@ -90,38 +94,39 @@
/**
* set element data
+ *
* @param elementData
*/
public void setElementData(VpeElementData elementData) {
this.elementData = elementData;
}
-
+
/**
- * Added method for creation copy which will
- * placed in cash to improve perfomance of VPE
- * Added by Max Areshkau JBIDE-675.
- * Here copyed only nsI****
+ * Added method for creation copy which will placed in cash to improve
+ * perfomance of VPE Added by Max Areshkau JBIDE-675. Here copyed only
+ * nsI****
+ *
* @return
*/
public VpeCreationData createHashCopy() {
- nsIDOMNode node=null;
- if(this.node!=null) {
- node = XmlUtil.createClone(this.node);
- } else {
- VpeDebugUtil.debugInfo("Node is Null");
- }
- if(node.getNodeType()!=nsIDOMNode.ELEMENT_NODE) {
+ nsIDOMNode node = null;
+ if (this.node != null) {
+ node = XmlUtil.createClone(this.node);
+ } else {
+ VpeDebugUtil.debugInfo("Node is Null");
+ }
+ if (node.getNodeType() != nsIDOMNode.ELEMENT_NODE) {
VpeDebugUtil.debugInfo("It's Not Element");
}
-
+
VpeCreationData data = new VpeCreationData(node);
- if(this.childrenInfoList!=null) {
- data.childrenInfoList= new ArrayList<VpeChildrenInfo>();
- for (VpeChildrenInfo childrenInfo : this.childrenInfoList) {
- data.childrenInfoList.add(childrenInfo.createCashCopy());
+ if (this.childrenInfoList != null) {
+ data.childrenInfoList = new ArrayList<VpeChildrenInfo>();
+ for (VpeChildrenInfo childrenInfo : this.childrenInfoList) {
+ data.childrenInfoList.add(childrenInfo.createCashCopy());
+ }
}
- }
- data.illegalChildren =this.illegalChildren;
+ data.illegalChildren = this.illegalChildren;
data.data = this.data;
data.elementData = this.elementData;
return data;
17 years, 8 months