Author: vyemialyanchyk
Date: 2007-12-17 14:42:46 -0500 (Mon, 17 Dec 2007)
New Revision: 5353
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
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/VpeDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-788
http://jira.jboss.com/jira/browse/JBIDE-1457
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 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -89,6 +89,7 @@
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
import org.jboss.tools.jst.jsp.editor.IVisualController;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.jst.web.tld.TLDToPaletteHelper;
@@ -158,7 +159,6 @@
// TODO Max Areshkau figure out with nsISelectionController
private VpeSelectionController visualSelectionController;
VpeDomMapping domMapping;
- private VpeTemplateManager templateManager;
private VpeSourceDomBuilder sourceBuilder;
public VpeVisualDomBuilder visualBuilder;
private VpeSelectionBuilder selectionBuilder;
@@ -202,13 +202,15 @@
}
this.visualEditor = visualEditor;
visualEditor.setController(this);
- templateManager = VpeTemplateManager.getInstance();
bundle = new BundleMap();
bundle.init(sourceEditor);
- pageContext = new VpePageContext(templateManager, bundle, editPart);
+ pageContext = new VpePageContext(bundle, editPart);
+ // vitali - temp solution
+ pageContext.setVisualContext(getPageContext());
+
domMapping = new VpeDomMapping(pageContext);
- sourceBuilder = new VpeSourceDomBuilder(domMapping, this, templateManager,
sourceEditor, pageContext);
- visualBuilder = new VpeVisualDomBuilder(domMapping, this, templateManager,
visualEditor, pageContext);
+ sourceBuilder = new VpeSourceDomBuilder(domMapping, this, sourceEditor, pageContext);
+ visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor, pageContext);
pageContext.setSourceDomBuilder(sourceBuilder);
pageContext.setVisualDomBuilder(visualBuilder);
IDOMModel sourceModel = (IDOMModel)getModel();
@@ -220,6 +222,7 @@
visualBuilder.refreshExternalLinks();
visualBuilder.buildDom(sourceDocument);
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
templateManager.addTemplateListener(this);
xulRunnerEditor = visualEditor.getXulRunnerEditor();
@@ -265,15 +268,16 @@
relativeFolderReferenceListListener = RelativeFolderReferenceList.getInstance();
relativeFolderReferenceListListener.addChangeListener(this);
- pageContext.fireTaglibsChanged();
+ //vitali
+ //pageContext.fireTaglibsChanged();
}
public void dispose() {
switcher.destroyActiveEditor();
- if (templateManager != null) {
- templateManager.removeTemplateListener(this);
- }
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
+ templateManager.removeTemplateListener(this);
+
if (visualBuilder != null) {
visualBuilder.dispose();
visualBuilder = null;
@@ -396,10 +400,14 @@
break;
}
if (visualBuilder.rebuildFlag) {
- pageContext.fireTaglibsChanged();
- } else if (pageContext.isTaglibChanged()) {
+ //vitali
+ //pageContext.fireTaglibsChanged();
+ //vitali
+ //} else if (pageContext.isTaglibChanged()) {
+ } else if (true) {
visualRefreshImpl();
- pageContext.fireTaglibsChanged();
+ //vitali
+ //pageContext.fireTaglibsChanged();
}
switcher.stopActiveEditor();
}
@@ -551,7 +559,8 @@
visualBuilder.setSelectionRectangle(null);
IDOMDocument sourceDocument = sourceModel.getDocument();
visualBuilder.rebuildDom(sourceDocument);
- pageContext.fireTaglibsChanged();
+ //vitali
+ //pageContext.fireTaglibsChanged();
}
switcher.stopActiveEditor();
}
@@ -906,7 +915,9 @@
data.setName(actionNode.getNodeName());
}
data = editAnyData(sourceEditor, isCorrectNS, data);
- if (data != null && data.isChanged())
templateManager.setAnyTemplate(data);
+ if (data != null && data.isChanged()) {
+ VpeTemplateManager.getInstance().setAnyTemplate(data);
+ }
}
});
@@ -1099,7 +1110,8 @@
return;
}
visualRefreshImpl();
- pageContext.fireTaglibsChanged();
+ //vitali
+ //pageContext.fireTaglibsChanged();
switcher.stopActiveEditor();
}
@@ -1236,8 +1248,8 @@
}
if (bundle != null) {
bundle.refresh();
- if (pageContext != null) {
- pageContext.refreshBundleValues();
+ if (getPageContext() != null) {
+ getPageContext().refreshBundleValues();
}
}
switcher.stopActiveEditor();
@@ -1247,16 +1259,16 @@
if (includeList.includesRefresh()) {
visualRefresh();
}
- if (templateManager != null) {
- templateManager.reload();
- }
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
+ templateManager.reload();
+
if (bundle != null) {
bundle.refresh();
- if (pageContext != null) {
+ if (getPageContext() != null) {
if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
- pageContext.refreshBundleValues();
+ getPageContext().refreshBundleValues();
switcher.stopActiveEditor();
}
}
@@ -1642,8 +1654,12 @@
}
}
+ public VpeVisualDomBuilder getVisualBuilder(){
+ return visualBuilder;
+ }
+
public void refreshExternalLinks() {
- pageContext.getVisualBuilder().refreshExternalLinks();
+ getVisualBuilder().refreshExternalLinks();
}
public IPath getPath() {
@@ -1658,7 +1674,7 @@
public void changed(Object source) {
if(cssReferenceListListener == source) {
- pageContext.getVisualBuilder().refreshExternalLinks();
+ getVisualBuilder().refreshExternalLinks();
} else if (absoluteFolderReferenceListListener == source ||
relativeFolderReferenceListListener == source ||
taglibReferenceListListener == source) {
@@ -2159,8 +2175,12 @@
tip = null;
}
- public VpePageContext getPageContext() {
- return pageContext;
+ public IVisualContext getPageContext() {
+ IVisualContext visualContext = null;
+ if (sourceEditor instanceof IJSPTextEditor) {
+ visualContext = ((IJSPTextEditor)sourceEditor).getPageContext();
+ }
+ return visualContext;
}
public StructuredTextEditor getSourceEditor() {
@@ -2319,6 +2339,10 @@
public VpeSourceDomBuilder getSourceBuilder() {
return sourceBuilder;
}
+
+ public VpeEditorPart getVpeEditorPart() {
+ return editPart;
+ }
/**
* @param selectionBuilder the selectionBuilder to set
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -20,23 +20,16 @@
public class VpeDomBuilder {
protected VpeDomMapping domMapping;
-
- protected VpeTemplateManager templateManager;
private INodeAdapter sorceAdapter;
- public VpeDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
VpeTemplateManager templateManager) {
+ public VpeDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter) {
this.domMapping = domMapping;
this.sorceAdapter = sorceAdapter;
- this.templateManager = templateManager;
}
public VpeDomMapping getDomMapping () {
return domMapping;
}
-
- public VpeTemplateManager getTemplateManager () {
- return templateManager;
- }
public void registerNodes(VpeNodeMapping nodeMapping) {
if (sorceAdapter == null) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -50,8 +50,8 @@
* @param visualEditor
* @param pageContext
*/
- public VpePreviewDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
VpeTemplateManager templateManager, MozillaEditor visualEditor, VpePageContext
pageContext) {
- super(domMapping, sorceAdapter, templateManager, visualEditor, pageContext);
+ public VpePreviewDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
MozillaEditor visualEditor, VpePageContext pageContext) {
+ super(domMapping, sorceAdapter, visualEditor, pageContext);
}
@@ -69,6 +69,7 @@
Map xmlnsMap = createXmlns((Element)sourceNode);
Set ifDependencySet = new HashSet();
getPageContext().setCurrentVisualNode(visualOldContainer);
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
VpeTemplate template = templateManager.getTemplate(getPageContext(),
(Element)sourceNode, ifDependencySet);
VpeCreationData creationData;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -55,8 +55,8 @@
private VpePageContext pageContext;
private StructuredTextEditor sourceEditor;
- public VpeSourceDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
VpeTemplateManager templateManager, StructuredTextEditor sourceEditor, VpePageContext
pageContext) {
- super(domMapping, sorceAdapter, templateManager);
+ public VpeSourceDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
StructuredTextEditor sourceEditor, VpePageContext pageContext) {
+ super(domMapping, sorceAdapter);
this.sourceEditor = sourceEditor;
structuredTextViewer = sourceEditor.getTextViewer();
outline = (IContentOutlinePage)sourceEditor.getAdapter(IContentOutlinePage.class);
@@ -224,6 +224,7 @@
Set ifDependencySet = new HashSet();
//VpeVisualDomBuilder visualBuildet =
pageContext.getVisualBuilder();
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
VpeTemplate template = templateManager.getTemplate(pageContext, sourceNewElement,
ifDependencySet);
registerNodes(new VpeElementMapping(sourceNewElement, (nsIDOMElement)visualNewNode,
null, template, ifDependencySet, null));
addChildren(visualNewNode, sourceNewElement);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -159,9 +159,8 @@
private VpeDnd dropper;
public VpeVisualDomBuilder(VpeDomMapping domMapping,
- INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
- MozillaEditor visualEditor, VpePageContext pageContext) {
- super(domMapping, sorceAdapter, templateManager);
+ INodeAdapter sorceAdapter, MozillaEditor visualEditor, VpePageContext pageContext)
{
+ super(domMapping, sorceAdapter);
this.visualEditor = visualEditor;
xulRunnerEditor = visualEditor.getXulRunnerEditor();
this.visualDocument = visualEditor.getDomDocument();
@@ -186,11 +185,10 @@
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) input).getFile();
if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file, pageContext
+ includeStack.add(new VpeIncludeInfo(null, file, visualEditor.getController()
.getSourceBuilder().getSourceDocument()));
}
}
- pageContext.refreshConnector();
pageContext.installIncludeElements();
addChildren(null, sourceDocument, visualContentArea);
registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
@@ -365,6 +363,7 @@
Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
Set<Node> ifDependencySet = new HashSet<Node>();
pageContext.setCurrentVisualNode(visualOldContainer);
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
VpeTemplate template = templateManager.getTemplate(pageContext,
(Element) sourceNode, ifDependencySet);
@@ -676,17 +675,18 @@
}
private void addPseudoElementImpl(nsIDOMNode visualParent) {
- if (!templateManager.isWithoutPseudoElementContainer(visualParent
- .getNodeName())) {
- if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
- System.out.println("-------------------- addPseudoElement: "
- + visualParent.getNodeName());
- }
- nsIDOMElement visualPseudoElement = visualDocument
- .createElement(PSEUDO_ELEMENT);
- visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, "yes");
- visualParent.appendChild(visualPseudoElement);
- }
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent
+ .getNodeName())) {
+ if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
+ System.out.println("-------------------- addPseudoElement: "
+ + visualParent.getNodeName());
+ }
+ nsIDOMElement visualPseudoElement = visualDocument
+ .createElement(PSEUDO_ELEMENT);
+ visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, "yes");
+ visualParent.appendChild(visualPseudoElement);
+ }
}
public boolean isEmptyElement(nsIDOMNode visualParent) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -113,7 +113,7 @@
case VK_F4:
IWorkbenchPage workbenchPage =
VpePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(keyEvent.getShiftKey()) workbenchPage.closeAllEditors(true);
- else workbenchPage.closeEditor(pageContext.getEditPart().getParentEditor(),true);
+ else
workbenchPage.closeEditor(getController().getVpeEditorPart().getParentEditor(),true);
break;
case VK_HOME:
if (keyEvent.getShiftKey()) {
@@ -379,11 +379,11 @@
if(focusNode.getNodeType() == Node.TEXT_NODE){
IndexedRegion region = (IndexedRegion)focusNode;
try{
- String sourceText =
sourceEditor.getTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
+ String sourceText =
getStructuredTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
String escString = TextUtil.isEcsToRight(sourceText, offset);
if(escString != null){
- Point range = sourceEditor.getTextViewer().getSelectedRange();
- sourceEditor.getTextViewer().getTextWidget().replaceTextRange(range.x,
escString.length(), "");
+ Point range = getStructuredTextViewer().getSelectedRange();
+ getStructuredTextViewer().getTextWidget().replaceTextRange(range.x,
escString.length(), "");
atLeastOneCharIsDeleted = true;
continue;
}
@@ -410,8 +410,8 @@
while(chars.length > (offset+endPos) &&
TextUtil.isWhitespace(chars[offset+endPos])){
endPos++;
}
- Point range = sourceEditor.getTextViewer().getSelectedRange();
- sourceEditor.getTextViewer().getTextWidget().replaceTextRange(range.x, endPos,
"");
+ Point range = getStructuredTextViewer().getSelectedRange();
+ getStructuredTextViewer().getTextWidget().replaceTextRange(range.x, endPos,
"");
selection = sourceSelectionBuilder.getSelection();
atLeastOneCharIsDeleted = true;
break;
@@ -721,12 +721,12 @@
if(focusNode.getNodeType() == Node.TEXT_NODE){
IndexedRegion region = (IndexedRegion)focusNode;
try {
- String sourceText =
sourceEditor.getTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
+ String sourceText =
getStructuredTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
String escString = TextUtil.isEcsToLeft(sourceText,offset);
if(escString != null){
- Point range = sourceEditor.getTextViewer().getSelectedRange();
- sourceEditor.getTextViewer().getTextWidget().replaceTextRange(range.x-escString.length(),
escString.length(), "");
+ Point range = getStructuredTextViewer().getSelectedRange();
+ getStructuredTextViewer().getTextWidget().replaceTextRange(range.x-escString.length(),
escString.length(), "");
atLeastOneCharIsDeleted = true;
return selection;
@@ -744,8 +744,8 @@
}
endPos--;
if(endPos!=0){
- Point range = sourceEditor.getTextViewer().getSelectedRange();
- sourceEditor.getTextViewer().getTextWidget().replaceTextRange(range.x-endPos,
endPos, "");
+ Point range = getStructuredTextViewer().getSelectedRange();
+ getStructuredTextViewer().getTextWidget().replaceTextRange(range.x-endPos, endPos,
"");
selection = sourceSelectionBuilder.getSelection();
atLeastOneCharIsDeleted = true;
}
@@ -921,7 +921,7 @@
private boolean isVisualNodeEmpty(Node node) {
try {
nsIDOMNode visualNode = domMapping.getVisualNode(node);
- return pageContext.getVisualBuilder().isEmptyElement(visualNode);
+ return getController().getVisualBuilder().isEmptyElement(visualNode);
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
}
@@ -989,14 +989,18 @@
}
}
+ private StructuredTextViewer getStructuredTextViewer() {
+ return sourceEditor.getTextViewer();
+ }
+
private void setSourceFocus(int offset) {
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(offset, 0);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(offset, 0);
+ getStructuredTextViewer().setSelectedRange(offset, 0);
+ getStructuredTextViewer().revealRange(offset, 0);
}
private void setSelectionRange(int startOffset, int endOffset) {
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(endOffset,
startOffset - endOffset);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(endOffset,
startOffset - endOffset);
+ getStructuredTextViewer().setSelectedRange(endOffset, startOffset - endOffset);
+ getStructuredTextViewer().revealRange(endOffset, startOffset - endOffset);
}
private void removeNode(Node focusNode) {
@@ -1016,7 +1020,7 @@
if (selection != null) {
Node sourceNode = selection.getFocusNode();
if (sourceNode != null) {
- VpeDomMapping mapping = pageContext.getDomMapping();
+ VpeDomMapping mapping = getController().getDomMapping();
if (mapping != null) {
nsIDOMNode visualNode = mapping.getVisualNode(sourceNode);
if (visualNode != null) {
@@ -1037,11 +1041,11 @@
isEditable = true;
}
if (isEditable) {
- start = sourceEditor.getTextViewer().getSelectedRange().x;
+ start = getStructuredTextViewer().getSelectedRange().x;
}
}
}
- } else if (pageContext.getSourceBuilder().isEmptyDocument()) {
+ } else if (getController().getSourceBuilder().isEmptyDocument()) {
isEditable = true;
start = 0;
}
@@ -1053,9 +1057,9 @@
if(TextUtil.containsKey(s[0])){
str = TextUtil.getValue(s[0]);
}
- sourceEditor.getTextViewer().getTextWidget().replaceTextRange(start, 0, str);
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(start +
str.length(), 0);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(start +
str.length(), 0);
+ getStructuredTextViewer().getTextWidget().replaceTextRange(start, 0, str);
+ getStructuredTextViewer().setSelectedRange(start + str.length(), 0);
+ getStructuredTextViewer().revealRange(start + str.length(), 0);
return true;
}
return false;
@@ -1094,7 +1098,7 @@
}
if (!handled && focusNode.getParentNode().getNodeType() ==
Node.DOCUMENT_NODE) {
if (focusNode.getNodeType() == Node.TEXT_NODE) {
- Point range = sourceEditor.getTextViewer().getSelectedRange();
+ Point range = getStructuredTextViewer().getSelectedRange();
Node p1 = focusNode.getOwnerDocument().createElement(HTML.TAG_P);
Node p2 = focusNode.getOwnerDocument().createElement(HTML.TAG_P);
Text newNode = ((Text)focusNode).splitText(getSourceNodeOffset(focusNode,
range.x));
@@ -1104,7 +1108,7 @@
newNode = (Text)newNode.getParentNode().removeChild(newNode);
p1.appendChild(focusNode);
p2.appendChild(newNode);
- setCursor(pageContext, newNode);
+ setCursor(newNode);
}
}
} else if (focusNode instanceof Comment) {
@@ -1165,7 +1169,7 @@
if (!handled) {
if (focusNode.getNodeType() == Node.TEXT_NODE) {
if (focusNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
- Point range = sourceEditor.getTextViewer().getSelectedRange();
+ Point range = getStructuredTextViewer().getSelectedRange();
Node p1 = focusNode.getOwnerDocument().createElement("p");
Node p2 = focusNode.getOwnerDocument().createElement("p");
Text newNode = ((Text)focusNode).splitText(getSourceNodeOffset(focusNode,
range.x));
@@ -1175,7 +1179,7 @@
newNode = (Text)newNode.getParentNode().removeChild(newNode);
p1.appendChild(focusNode);
p2.appendChild(newNode);
- setCursor(pageContext, newNode);
+ setCursor(newNode);
int p1Start = ((IndexedRegion)p1).getStartOffset();
int p2End = ((IndexedRegion)p2).getEndOffset();
@@ -1197,7 +1201,7 @@
Text newNode1 =
(Text)focusNode.getParentNode().insertBefore(focusNode.getOwnerDocument().createTextNode("\r\n"
+ getLinePrefix(n1Start + focusOffset) + newNode.getData()), newNode);
focusNode.getParentNode().removeChild(newNode);
newNode = newNode1;
- setCursor(pageContext, newNode);
+ setCursor(newNode);
int n2End = ((IndexedRegion)newNode).getEndOffset();
region = new Region(n1Start, n2End - n1Start);
}
@@ -1215,10 +1219,10 @@
}
try {
- StructuredTextViewer viewer = sourceEditor.getTextViewer();
+ StructuredTextViewer viewer = getStructuredTextViewer();
if (region != null){
if (sourceEditor instanceof ITextFormatter) {
- ((ITextFormatter)sourceEditor).formatTextRegion(sourceEditor.getTextViewer().getDocument(),
region);
+ ((ITextFormatter)sourceEditor).formatTextRegion(viewer.getDocument(), region);
}
}
} catch (Exception x) {
@@ -1231,7 +1235,7 @@
private String getLinePrefix(int offset) {
try {
- final IDocument document = sourceEditor.getTextViewer().getDocument();
+ final IDocument document = getStructuredTextViewer().getDocument();
final int linePrefixBeginning =
document.getLineInformationOfOffset(offset).getOffset();
String linePrefix = document.get(linePrefixBeginning, offset - linePrefixBeginning);
int linePrefixLength = 0;
@@ -1319,14 +1323,14 @@
return 0;
}
- private void setCursor(VpePageContext pageContext, Node node) {
+ private void setCursor(Node node) {
int nodeOffset = ((IndexedRegion)node).getStartOffset();
if (node.getNodeType() == Node.ELEMENT_NODE) {
ElementImpl element = (ElementImpl)node;
nodeOffset = element.getStartEndOffset();
}
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(nodeOffset,
0);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(nodeOffset, 0);
+ getStructuredTextViewer().setSelectedRange(nodeOffset, 0);
+ getStructuredTextViewer().revealRange(nodeOffset, 0);
}
private boolean moveForward() {
@@ -1336,8 +1340,8 @@
Node node = getNextNode(selection.getStartNode());
if (node != null) {
int nodeOffset = ((IndexedRegion)node).getStartOffset();
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(nodeOffset,
0);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(nodeOffset, 0);
+ getStructuredTextViewer().setSelectedRange(nodeOffset, 0);
+ getStructuredTextViewer().revealRange(nodeOffset, 0);
return true;
}
}
@@ -1476,8 +1480,8 @@
Node node = getPrevNode(selection.getStartNode());
if (node != null) {
int nodeOffset = ((IndexedRegion)node).getStartOffset();
- pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(nodeOffset,
0);
- pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(nodeOffset, 0);
+ getStructuredTextViewer().setSelectedRange(nodeOffset, 0);
+ getStructuredTextViewer().revealRange(nodeOffset, 0);
return true;
}
}
@@ -1800,18 +1804,18 @@
}
}
- return nearestElement;
+ return nearestElement;
}
-
+ private VpeController getController() {
+ return pageContext.getEditPart().getController();
+ }
private VpeSelectionBuilder getSelectionBuilder() {
-
- return pageContext.getEditPart().getController().getSelectionBuilder();
+ return getController().getSelectionBuilder();
}
- private nsIDOMElement getSelectedNode() {
-
- return pageContext.getEditPart().getController().getXulRunnerEditor().getLastSelectedElement();
+ private nsIDOMElement getSelectedNode() {
+ return getController().getXulRunnerEditor().getLastSelectedElement();
}
}
\ No newline at end of file
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -1,443 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.context;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
-import org.jboss.tools.common.kb.KbConnectorFactory;
-import org.jboss.tools.common.kb.KbConnectorType;
-import org.jboss.tools.common.kb.KbTldResource;
-import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
-import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.jsp.editor.IVisualContext;
-import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibListener;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.vpe.VpeDebug;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.VpeEditorPart;
-import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
-import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
-import org.jboss.tools.vpe.editor.bundle.BundleMap;
-import org.jboss.tools.vpe.editor.css.AbsoluteFolderReferenceList;
-import org.jboss.tools.vpe.editor.css.CSSReferenceList;
-import org.jboss.tools.vpe.editor.css.RelativeFolderReferenceList;
-import org.jboss.tools.vpe.editor.css.ResourceReference;
-import org.jboss.tools.vpe.editor.css.TaglibReferenceList;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.FileUtil;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Contains the information on edited page.
- */
-
-public class VpePageContext implements VpeTaglibManager, IVisualContext {
- private VpeTemplateManager templateManager;
- private ArrayList taglibs = new ArrayList();
- private Map taglibMap = new HashMap();
- private VpeTaglibListener[] taglibListeners = new VpeTaglibListener[0];
- private BundleMap bundle;
- private Set bundleDependencySet = new HashSet();
- private VpeSourceDomBuilder sourceBuilder;
- private VpeVisualDomBuilder visualBuilder;
- private VpeEditorPart editPart;
- private List lastTaglibs = new ArrayList();
- private boolean taglibChanged = false;
- WtpKbConnector connector;
- private nsIDOMNode currentVisualNode;
-
- public VpePageContext(VpeTemplateManager templateManager, BundleMap bundle,
VpeEditorPart editPart) {
- this.templateManager = templateManager;
- this.bundle = bundle;
- this.editPart = editPart;
- }
-
- public VpeSourceDomBuilder getSourceBuilder(){
- return sourceBuilder;
- }
-
- public boolean isAbsolutePosition(){
- if("yes".equals(VpePreference.USE_ABSOLUTE_POSITION.getValue()))return true;
- else return false;
- }
-
- public void setSourceDomBuilder(VpeSourceDomBuilder sourceBuilder) {
- this.sourceBuilder = sourceBuilder;
- refreshConnector();
- }
-
- public void refreshConnector() {
- try {
- IDocument document = sourceBuilder.getStructuredTextViewer().getDocument();
- connector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
document);
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- }
- }
-
- public VpeVisualDomBuilder getVisualBuilder(){
- return visualBuilder;
- }
-
- public void setVisualDomBuilder(VpeVisualDomBuilder visualBuilder) {
- this.visualBuilder = visualBuilder;
- }
-
- public VpeDomMapping getDomMapping () {
- return visualBuilder.getDomMapping();
- }
-
- public void clearAll() {
- taglibs.clear();
- taglibMap.clear();
- bundleDependencySet.clear();
- bundle.clearAll();
- }
-
- public void dispose() {
- bundle.dispose();
- clearAll();
- }
-
- public void setTaglib(int id, String newUri, String newPrefix, boolean ns) {
- for (int i = 0; i < taglibs.size(); i++) {
- TaglibData taglib = (TaglibData)taglibs.get(i);
- if (taglib.getId() == id) {
- if (newUri != null && newPrefix != null) {
- if (!newUri.equals(taglib.getUri()) || !newPrefix.equals(taglib.getPrefix())) {
- taglibs.set(i, new TaglibData(id, newUri, newPrefix, ns));
- rebuildTaglibMap();
- }
- } else {
- taglibs.remove(i);
- rebuildTaglibMap();
- }
- return;
- }
- }
- if (newUri != null && newPrefix != null) {
- taglibs.add(new TaglibData(id, newUri, newPrefix, ns));
- rebuildTaglibMap();
- }
- }
-
- public String getTemplateTaglibPrefix(String sourceTaglibPrefix) {
- return (String) taglibMap.get(sourceTaglibPrefix);
- }
-
- private void rebuildTaglibMap() {
- taglibMap.clear();
- Set prefixSet = new HashSet();
- for (int i = 0; i < taglibs.size(); i++) {
- TaglibData taglib = (TaglibData)taglibs.get(i);
- String prefix = taglib.getPrefix();
- if (!prefixSet.contains(prefix)) {
- String templatePrefix = templateManager.getTemplateTaglibPrefix(taglib.getUri());
- if (templatePrefix != null) {
- taglibMap.put(prefix, templatePrefix);
- }
- prefixSet.add(prefix);
- }
- }
- taglibChanged = true;
-
- try {
- registerTaglibs(connector, this,
getSourceBuilder().getStructuredTextViewer().getDocument());
- } catch (Exception e) {
- VpePlugin.getPluginLog().logError(e);
- }
- }
-
- public void addTaglibListener(VpeTaglibListener listener) {
- if (listener != null) {
- VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length
+ 1];
- System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, taglibListeners.length);
- taglibListeners = newTaglibListeners;
- taglibListeners[taglibListeners.length - 1] = listener;
- }
- }
-
- public void removeTaglibListener(VpeTaglibListener listener) {
- if (listener == null || taglibListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < taglibListeners.length; i++) {
- if (listener == taglibListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (taglibListeners.length == 1) {
- taglibListeners = new VpeTaglibListener[0];
- return;
- }
- VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length -
1];
- System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, index);
- System.arraycopy(taglibListeners, index + 1, newTaglibListeners, index,
taglibListeners.length - index - 1);
- taglibListeners = newTaglibListeners;
- }
-
- public BundleMap getBundle() {
- return bundle;
- }
-
- public void addBundleDependency(Element sourceNode) {
- bundleDependencySet.add(sourceNode);
- }
-
- public void removeBundleDependency(Element sourceNode) {
- bundleDependencySet.remove(sourceNode);
- }
-
- public void refreshBundleValues() {
- Iterator iterator = bundleDependencySet.iterator();
- while (iterator.hasNext()) {
- Element sourceElement = (Element) iterator.next();
- visualBuilder.refreshBundleValues(sourceElement);
- }
- }
-
- public boolean isCorrectNS(Node sourceNode) {
- String sourcePrefix = sourceNode.getPrefix();
- if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
- return true;
- }
- for (int i = 0; i < taglibs.size(); i++) {
- TaglibData taglib = (TaglibData)taglibs.get(i);
- if (sourcePrefix.equals(taglib.getPrefix())) {
- return true;
- }
- }
- return false;
- }
-
- public String getSourceTaglibUri(Node sourceNode) {
- String sourcePrefix = sourceNode.getPrefix();
- if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
- return null;
- }
- for (int i = 0; i < taglibs.size(); i++) {
- TaglibData taglib = (TaglibData)taglibs.get(i);
- if (sourcePrefix.equals(taglib.getPrefix())) {
- return taglib.getUri();
- }
- }
- return null;
- }
-
- public VpeEditorPart getEditPart() {
- return editPart;
- }
-
- public void openIncludeFile(String file) {
- IEditorInput input = editPart.getEditorInput();
- IWorkbenchPage workbenchPage =
VpePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- try{
- IFile f = FileUtil.getFile(input, file);
- if (f != null) {
- IDE.openEditor(workbenchPage, f, true);
- }
- }catch(Exception ex){
- VpePlugin.reportProblem(ex);
- }
- }
-
- public ResourceReference[] getIncludeTaglibs() {
- IEditorInput input = getEditPart().getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput)input).getFile();
- }
- ResourceReference[] resourceReferences = new ResourceReference[0];
- if (file != null) {
- resourceReferences = TaglibReferenceList.getInstance().getAllResources(file);
- }
- return resourceReferences;
- }
-
- public ResourceReference[] getIncludeCss() {
- IEditorInput input = getEditPart().getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput)input).getFile();
- }
- ResourceReference[] resourceReferences = new ResourceReference[0];
- if (file != null) {
- resourceReferences = CSSReferenceList.getInstance().getAllResources(file);
- }
- return resourceReferences;
- }
-
- public void installIncludeElements() {
- ResourceReference[] list = getIncludeTaglibs();
- for (int i = 0; i < list.length; i++) {
- ResourceReference reference = list[i];
- setTaglib(i, reference.getLocation(), reference.getProperties(), false);
- }
-
- list = getIncludeCss();
- for (int i = 0; i < list.length; i++) {
- visualBuilder.addLinkNodeToHead(list[i].getLocation(), "yes");
- }
- }
-
- public ResourceReference getRuntimeRelativeFolder(IFile file) {
- ResourceReference[] list =
RelativeFolderReferenceList.getInstance().getAllResources(file);
- if (list.length > 0) {
- return list[list.length - 1];
- }
- return null;
- }
-
- public ResourceReference getRuntimeAbsoluteFolder(IFile file) {
- ResourceReference[] list =
AbsoluteFolderReferenceList.getInstance().getAllResources(file);
- if (list.length > 0) {
- return list[list.length - 1];
- }
- return null;
- }
-
- public List<TaglibData> getTagLibs() {
- List<TaglibData> clone = new ArrayList<TaglibData>();
- Iterator iter = taglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- if (!taglib.inList(clone)) {
- clone.add(taglib);
- }
- }
- return clone;
- }
-
- private boolean buildTaglibsDifferences(List newTaglibs, List delTaglibs) {
- Iterator lastIter = lastTaglibs.iterator();
- while (lastIter.hasNext()) {
- TaglibData oldTaglib = (TaglibData)lastIter.next();
- Iterator newIter = newTaglibs.iterator();
- while (newIter.hasNext()) {
- if (oldTaglib.isEquals((TaglibData)newIter.next())) {
- newIter.remove();
- oldTaglib = null;
- break;
- }
- }
- if (oldTaglib != null) {
- delTaglibs.add(oldTaglib);
- }
- }
- return newTaglibs.size() > 0 || delTaglibs.size() > 0;
- }
-
- public void fireTaglibsChanged() {
- List newTaglibs = getTagLibs();
- List delTaglibs = new ArrayList();
- if (buildTaglibsDifferences(newTaglibs, delTaglibs)) {
- if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
- System.out.println(">>> TaglibsChanged");
- }
- for (int i = 0; i < taglibListeners.length; i++) {
- taglibListeners[i].taglibPrefixChanged(null);
- fireTaglibChanged(taglibListeners[i], newTaglibs, delTaglibs);
- }
- lastTaglibs = getTagLibs();
- }
- taglibChanged = false;
- }
-
- private void fireTaglibChanged(VpeTaglibListener taglibListener, List newTaglibs, List
delTaglibs) {
- Iterator iter = delTaglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- taglibListener.removeTaglib(taglib.getUri(), taglib.getPrefix());
- }
- iter = newTaglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- taglibListener.addTaglib(taglib.getUri(), taglib.getPrefix());
- }
- }
-
- public boolean isTaglibChanged() {
- if (!taglibChanged) return false;
- List newTaglibs = getTagLibs();
- List delTaglibs = new ArrayList();
- return buildTaglibsDifferences(newTaglibs, delTaglibs);
- }
-
- public WtpKbConnector getConnector() {
- return connector;
- }
-
- boolean registerTaglibs(WtpKbConnector wtpKbConnector, VpeTaglibManager taglibManager,
IDocument document) {
- if(wtpKbConnector == null) return false;
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
- if(taglibManager != null) {
- List list = taglibManager.getTagLibs();
- if(list != null) {
- Iterator it = list.iterator();
- while(it.hasNext()) {
- TaglibData data = (TaglibData)it.next();
- IEditorInput ei = editPart.getEditorInput();
- TLDRegisterHelper.registerTld(data, (JspWtpKbConnector)wtpKbConnector, document,
ei);
- }
- return true;
- }
- }
- if(manager != null) {
- List list = manager.getTaglibTrackers();
- for (int i = 0; i < list.size(); i++) {
- TaglibTracker tracker = (TaglibTracker)list.get(i);
- if(tracker == null) continue;
- String version = TLDVersionHelper.getTldVersion(tracker);
- KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
- wtpKbConnector.registerResource(resource);
- }
- return true;
- }
- return false;
- }
-
- public nsIDOMNode getCurrentVisualNode() {
- return currentVisualNode;
- }
-
- public void setCurrentVisualNode(nsIDOMNode currentVisualNode) {
- this.currentVisualNode = currentVisualNode;
- }
-
-}
\ No newline at end of file
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -0,0 +1,488 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.context;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.jboss.tools.common.kb.KbConnectorFactory;
+import org.jboss.tools.common.kb.KbConnectorType;
+import org.jboss.tools.common.kb.KbTldResource;
+import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
+import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
+import org.jboss.tools.common.kb.wtp.WtpKbConnector;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
+import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.jst.web.tld.VpeTaglibListener;
+import org.jboss.tools.jst.web.tld.VpeTaglibManager;
+import org.jboss.tools.vpe.VpeDebug;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
+import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
+import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
+import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.vpe.editor.css.AbsoluteFolderReferenceList;
+import org.jboss.tools.vpe.editor.css.CSSReferenceList;
+import org.jboss.tools.vpe.editor.css.RelativeFolderReferenceList;
+import org.jboss.tools.vpe.editor.css.ResourceReference;
+import org.jboss.tools.vpe.editor.css.TaglibReferenceList;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.FileUtil;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Contains the information on edited page.
+ */
+
+// vitali: Attention!!! this is refactoring intermediate version
+// because of bugfixing
+//
http://jira.jboss.com/jira/browse/JBIDE-788 and
+//
http://jira.jboss.com/jira/browse/JBIDE-1457
+
+//public class VpePageContext implements IVisualContext {
+public class VpePageContext {
+
+ // vitali: time solution - set connector from JSPTextEditorPageContext
+ public WtpKbConnector getConnector() {
+ return getVisualContext().getConnector();
+ }
+ IVisualContext visualContext;
+ public void setVisualContext(IVisualContext visualContext) {
+ this.visualContext = visualContext;
+ }
+ public IVisualContext getVisualContext() {
+ return visualContext;
+ }
+
+
+
+ private ArrayList taglibs = new ArrayList();
+ private Map taglibMap = new HashMap();
+ private VpeTaglibListener[] taglibListeners = new VpeTaglibListener[0];
+ private BundleMap bundle;
+ private Set bundleDependencySet = new HashSet();
+ private VpeSourceDomBuilder sourceBuilder;
+ private VpeVisualDomBuilder visualBuilder;
+ private VpeEditorPart editPart;
+ private List lastTaglibs = new ArrayList();
+ private boolean taglibChanged = false;
+ WtpKbConnector connector;
+ private nsIDOMNode currentVisualNode;
+
+ public VpePageContext(BundleMap bundle, VpeEditorPart editPart) {
+ this.bundle = bundle;
+ this.editPart = editPart;
+ }
+
+ //public VpeSourceDomBuilder getSourceBuilder(){
+ // return sourceBuilder;
+ //}
+
+ // vitali: delete this function with the class
+ public void setSourceDomBuilder(VpeSourceDomBuilder sourceBuilder) {
+ this.sourceBuilder = sourceBuilder;
+ //refreshConnector();
+ }
+ public VpeSourceDomBuilder getSourceBuilder() {
+ return sourceBuilder;
+ }
+
+ // vitali: delete this function with the class - use VpeController
+ public VpeVisualDomBuilder getVisualBuilder(){
+ return visualBuilder;
+ }
+
+ // vitali: delete this function with the class - delete from MozillaPreview
+ public void setVisualDomBuilder(VpeVisualDomBuilder visualBuilder) {
+ this.visualBuilder = visualBuilder;
+ }
+
+ // vitali: delete this function with the class - use
VpeController->getVisualBuilder()
+ public VpeDomMapping getDomMapping () {
+ return visualBuilder.getDomMapping();
+ }
+
+ // vitali: delete this function with the class
+ public void clearAll() {
+ taglibs.clear();
+ taglibMap.clear();
+ bundleDependencySet.clear();
+ bundle.clearAll();
+ }
+
+ // vitali: delete this function with the class
+ public void dispose() {
+ bundle.dispose();
+ clearAll();
+ }
+
+ // vitali: delete this function with the class - from all places
+ public void setTaglib(int id, String newUri, String newPrefix, boolean ns) {
+ for (int i = 0; i < taglibs.size(); i++) {
+ TaglibData taglib = (TaglibData)taglibs.get(i);
+ if (taglib.getId() == id) {
+ if (newUri != null && newPrefix != null) {
+ if (!newUri.equals(taglib.getUri()) || !newPrefix.equals(taglib.getPrefix())) {
+ taglibs.set(i, new TaglibData(id, newUri, newPrefix, ns));
+ rebuildTaglibMap();
+ }
+ } else {
+ taglibs.remove(i);
+ rebuildTaglibMap();
+ }
+ return;
+ }
+ }
+ if (newUri != null && newPrefix != null) {
+ taglibs.add(new TaglibData(id, newUri, newPrefix, ns));
+ rebuildTaglibMap();
+ }
+ }
+
+ // vitali: put taglibMap to VpeTemplateManager
+ public String getTemplateTaglibPrefix(String sourceTaglibPrefix) {
+ return (String) taglibMap.get(sourceTaglibPrefix);
+ }
+
+ private void rebuildTaglibMap() {
+ taglibMap.clear();
+ VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
+ Set prefixSet = new HashSet();
+ for (int i = 0; i < taglibs.size(); i++) {
+ TaglibData taglib = (TaglibData)taglibs.get(i);
+ String prefix = taglib.getPrefix();
+ if (!prefixSet.contains(prefix)) {
+ String templatePrefix = templateManager.getTemplateTaglibPrefix(taglib.getUri());
+ if (templatePrefix != null) {
+ taglibMap.put(prefix, templatePrefix);
+ }
+ prefixSet.add(prefix);
+ }
+ }
+ taglibChanged = true;
+
+ /** /
+ try {
+ registerTaglibs(connector, this,
getSourceBuilder().getStructuredTextViewer().getDocument());
+ } catch (Exception e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ /**/
+ }
+
+ /** /
+ // vitali: parent
+ public void addTaglibListener(VpeTaglibListener listener) {
+ if (listener != null) {
+ VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length
+ 1];
+ System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, taglibListeners.length);
+ taglibListeners = newTaglibListeners;
+ taglibListeners[taglibListeners.length - 1] = listener;
+ }
+ }
+
+ // vitali: parent
+ public void removeTaglibListener(VpeTaglibListener listener) {
+ if (listener == null || taglibListeners.length == 0) return;
+ int index = -1;
+ for (int i = 0; i < taglibListeners.length; i++) {
+ if (listener == taglibListeners[i]){
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) return;
+ if (taglibListeners.length == 1) {
+ taglibListeners = new VpeTaglibListener[0];
+ return;
+ }
+ VpeTaglibListener[] newTaglibListeners = new VpeTaglibListener[taglibListeners.length -
1];
+ System.arraycopy(taglibListeners, 0, newTaglibListeners, 0, index);
+ System.arraycopy(taglibListeners, index + 1, newTaglibListeners, index,
taglibListeners.length - index - 1);
+ taglibListeners = newTaglibListeners;
+ }
+ /**/
+
+ // vitali: delete this function with the class - save and getBundle() from other place
+ // for examle visualBuilder
+ public BundleMap getBundle() {
+ return bundle;
+ }
+
+ // vitali: delete this function with the class - save and getBundle() from other place
+ // for examle visualBuilder
+ public void addBundleDependency(Element sourceNode) {
+ bundleDependencySet.add(sourceNode);
+ }
+
+ // vitali: delete this function with the class - save and getBundle() from other place
+ // for examle visualBuilder
+ public void removeBundleDependency(Element sourceNode) {
+ bundleDependencySet.remove(sourceNode);
+ }
+
+ /** /
+ // vitali: parent
+ public void refreshBundleValues() {
+ Iterator iterator = bundleDependencySet.iterator();
+ while (iterator.hasNext()) {
+ Element sourceElement = (Element) iterator.next();
+ visualBuilder.refreshBundleValues(sourceElement);
+ }
+ }
+ /**/
+
+ // vitali: put this function in to JSPTextEditorPageContext
+ // VpeController ask JSPTextEditorPageContext via sourceEditor
+ public boolean isCorrectNS(Node sourceNode) {
+ String sourcePrefix = sourceNode.getPrefix();
+ if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
+ return true;
+ }
+ for (int i = 0; i < taglibs.size(); i++) {
+ TaglibData taglib = (TaglibData)taglibs.get(i);
+ if (sourcePrefix.equals(taglib.getPrefix())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // vitali: 2 places - RichFacesDataDefinitionListTemplate & VpeController
+ // should implement this function & get taglibs from
sourceEditor->JSPTextEditorPageContext
+ public String getSourceTaglibUri(Node sourceNode) {
+ String sourcePrefix = sourceNode.getPrefix();
+ if (sourcePrefix == null || ((ElementImpl)sourceNode).isJSPTag()) {
+ return null;
+ }
+ for (int i = 0; i < taglibs.size(); i++) {
+ TaglibData taglib = (TaglibData)taglibs.get(i);
+ if (sourcePrefix.equals(taglib.getPrefix())) {
+ return taglib.getUri();
+ }
+ }
+ return null;
+ }
+
+ // vitali: 24 places - !!! use other way to get VpeEditorPart
+ public VpeEditorPart getEditPart() {
+ return editPart;
+ }
+
+ // vitali: this is not right place to the function - put in into editPart -
VpeEditorPart
+ public void openIncludeFile(String file) {
+ IEditorInput input = editPart.getEditorInput();
+ IWorkbenchPage workbenchPage =
VpePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try{
+ IFile f = FileUtil.getFile(input, file);
+ if (f != null) {
+ IDE.openEditor(workbenchPage, f, true);
+ }
+ }catch(Exception ex){
+ VpePlugin.reportProblem(ex);
+ }
+ }
+
+ // vitali: public - can be protected!
+ protected ResourceReference[] getIncludeTaglibs() {
+ IEditorInput input = getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput)input).getFile();
+ }
+ ResourceReference[] resourceReferences = new ResourceReference[0];
+ if (file != null) {
+ resourceReferences = TaglibReferenceList.getInstance().getAllResources(file);
+ }
+ return resourceReferences;
+ }
+
+ // vitali: public - can be protected!
+ protected ResourceReference[] getIncludeCss() {
+ IEditorInput input = getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput)input).getFile();
+ }
+ ResourceReference[] resourceReferences = new ResourceReference[0];
+ if (file != null) {
+ resourceReferences = CSSReferenceList.getInstance().getAllResources(file);
+ }
+ return resourceReferences;
+ }
+
+ // vitali: 1 place - VpeVisualDomBuilder - put this into VpeVisualDomBuilder
+ // and getIncludeTaglibs and getIncludeCss
+ public void installIncludeElements() {
+ ResourceReference[] list = getIncludeTaglibs();
+ for (int i = 0; i < list.length; i++) {
+ ResourceReference reference = list[i];
+ setTaglib(i, reference.getLocation(), reference.getProperties(), false);
+ }
+
+ list = getIncludeCss();
+ for (int i = 0; i < list.length; i++) {
+ visualBuilder.addLinkNodeToHead(list[i].getLocation(), "yes");
+ }
+ }
+
+ /** /
+ // vitali: parent
+ public List<TaglibData> getTagLibs() {
+ List<TaglibData> clone = new ArrayList<TaglibData>();
+ Iterator iter = taglibs.iterator();
+ while (iter.hasNext()) {
+ TaglibData taglib = (TaglibData)iter.next();
+ if (!taglib.inList(clone)) {
+ clone.add(taglib);
+ }
+ }
+ return clone;
+ }
+ /**/
+
+ // vitali: public
+ private boolean buildTaglibsDifferences(List newTaglibs, List delTaglibs) {
+ Iterator lastIter = lastTaglibs.iterator();
+ while (lastIter.hasNext()) {
+ TaglibData oldTaglib = (TaglibData)lastIter.next();
+ Iterator newIter = newTaglibs.iterator();
+ while (newIter.hasNext()) {
+ if (oldTaglib.isEquals((TaglibData)newIter.next())) {
+ newIter.remove();
+ oldTaglib = null;
+ break;
+ }
+ }
+ if (oldTaglib != null) {
+ delTaglibs.add(oldTaglib);
+ }
+ }
+ return newTaglibs.size() > 0 || delTaglibs.size() > 0;
+ }
+
+ /** /
+ // vitali: 5 places - all in VpeController -
+ public void fireTaglibsChanged() {
+ List newTaglibs = getTagLibs();
+ List delTaglibs = new ArrayList();
+ if (buildTaglibsDifferences(newTaglibs, delTaglibs)) {
+ if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
+ System.out.println(">>> TaglibsChanged");
+ }
+ for (int i = 0; i < taglibListeners.length; i++) {
+ taglibListeners[i].taglibPrefixChanged(null);
+ fireTaglibChanged(taglibListeners[i], newTaglibs, delTaglibs);
+ }
+ lastTaglibs = getTagLibs();
+ }
+ taglibChanged = false;
+ }
+ /**/
+
+ private void fireTaglibChanged(VpeTaglibListener taglibListener, List newTaglibs, List
delTaglibs) {
+ Iterator iter = delTaglibs.iterator();
+ while (iter.hasNext()) {
+ TaglibData taglib = (TaglibData)iter.next();
+ taglibListener.removeTaglib(taglib.getUri(), taglib.getPrefix());
+ }
+ iter = newTaglibs.iterator();
+ while (iter.hasNext()) {
+ TaglibData taglib = (TaglibData)iter.next();
+ taglibListener.addTaglib(taglib.getUri(), taglib.getPrefix());
+ }
+ }
+
+ // vitali: 1 place VpeController -
+ public boolean isTaglibChanged() {
+ if (!taglibChanged) return false;
+ //vitali
+ List newTaglibs = null;//getTagLibs();
+ List delTaglibs = new ArrayList();
+ return buildTaglibsDifferences(newTaglibs, delTaglibs);
+ }
+
+ /** /
+ // vitali: parent
+ public WtpKbConnector getConnector() {
+ return connector;
+ }
+ /**/
+
+ boolean registerTaglibs(WtpKbConnector wtpKbConnector, VpeTaglibManager taglibManager,
IDocument document) {
+ if(wtpKbConnector == null) return false;
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+ if(taglibManager != null) {
+ List list = taglibManager.getTagLibs();
+ if(list != null) {
+ Iterator it = list.iterator();
+ while(it.hasNext()) {
+ TaglibData data = (TaglibData)it.next();
+ IEditorInput ei = editPart.getEditorInput();
+ TLDRegisterHelper.registerTld(data, (JspWtpKbConnector)wtpKbConnector, document,
ei);
+ }
+ return true;
+ }
+ }
+ if(manager != null) {
+ List list = manager.getTaglibTrackers();
+ for (int i = 0; i < list.size(); i++) {
+ TaglibTracker tracker = (TaglibTracker)list.get(i);
+ if(tracker == null) continue;
+ String version = TLDVersionHelper.getTldVersion(tracker);
+ KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
+ wtpKbConnector.registerResource(resource);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ // vitali: 2 places - VpeDataTableColumnCreator & VpeDataTableCreator
+ public nsIDOMNode getCurrentVisualNode() {
+ return currentVisualNode;
+ }
+
+ // vitali: 8 places in VpePreviewDomBuilder & VpeVisualDomBuilder
+ // use - setCurrentVisualNode(XXX)
+ // - getCurrentVisualNode()
+ // then - setCurrentVisualNode(null)
+ // just use other way to send current node as parameter
+ public void setCurrentVisualNode(nsIDOMNode currentVisualNode) {
+ this.currentVisualNode = currentVisualNode;
+ }
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -47,14 +47,12 @@
private EditorLoadWindowListener editorLoadWindowListener;
private EditorDomEventListener editorDomEventListener;
- private VpeTemplateManager templateManager;
private VpePageContext pageContext;
private StructuredTextEditor sourceEditor;
private VpeEditorPart editPart;
private IDOMDocument sourceDocument;
public MozillaPreview(VpeEditorPart editPart, StructuredTextEditor sourceEditor) {
- setTemplateManager(VpeTemplateManager.getInstance());
setSourceEditor(sourceEditor);
setEditPart(editPart);
}
@@ -164,11 +162,11 @@
BundleMap bundle = new BundleMap();
bundle.init(getSourceEditor());
- setPageContext(new VpePageContext(getTemplateManager(), bundle, getEditPart()));
+ setPageContext(new VpePageContext(bundle, getEditPart()));
VpeDomMapping domMapping = new VpeDomMapping(getPageContext());
- VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null,
getTemplateManager(), getSourceEditor(), getPageContext());
- VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null,
getTemplateManager(), this, getPageContext());
+ VpeSourceDomBuilder sourceBuilder = new VpeSourceDomBuilder(domMapping, null,
getSourceEditor(), getPageContext());
+ VpeVisualDomBuilder visualBuilder = new VpePreviewDomBuilder(domMapping, null, this,
getPageContext());
getPageContext().setSourceDomBuilder(sourceBuilder);
getPageContext().setVisualDomBuilder(visualBuilder);
@@ -228,27 +226,7 @@
this.editPart = editPart;
}
-
-
/**
- * @return the templateManager
- */
- private VpeTemplateManager getTemplateManager() {
- return templateManager;
- }
-
-
-
- /**
- * @param templateManager the templateManager to set
- */
- private void setTemplateManager(VpeTemplateManager templateManager) {
- this.templateManager = templateManager;
- }
-
-
-
- /**
* @return the sourceEditor
*/
private StructuredTextEditor getSourceEditor() {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -307,9 +307,9 @@
private static final String PREFIX_SEPARATOR = ":";
private String getPageLocale(VpePageContext pageContext, IDOMElement sourceElement) {
- IStructuredModel model = null;
- try {
- List<TaglibData> taglibs = pageContext.getTagLibs();
+ try {
+ //vitali: temp solution
+ List<TaglibData> taglibs = pageContext.getVisualContext().getTagLibs();
// Find F tracker
TaglibData fTD = null;
for (int i = 0; i < taglibs.size(); i++) {
@@ -345,8 +345,6 @@
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
return null;
- } finally {
- if (model != null) model.releaseFromRead();
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -48,12 +48,14 @@
public void setAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name, String value) {
setBundle(pageContext, sourceElement);
- pageContext.refreshBundleValues();
+ //vitali: temp solution
+ pageContext.getVisualContext().refreshBundleValues();
}
public void removeAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name) {
setBundle(pageContext, sourceElement);
- pageContext.refreshBundleValues();
+ //vitali: temp solution
+ pageContext.getVisualContext().refreshBundleValues();
}
private void setBundle(VpePageContext pageContext, Element sourceElement) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/dnd/VpeDnd.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -12,6 +12,7 @@
import java.util.HashSet;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
import org.jboss.tools.vpe.editor.VpeSourceInnerDropInfo;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -104,7 +105,7 @@
}
public boolean isDropEnabled(VpePageContext pageContext, Node container, Node node){
- if(!pageContext.isAbsolutePosition() && isAncestor(container, node)) return
false;
+ if(!VpePreference.isAbsolutePosition() && isAncestor(container, node)) return
false;
if(isContainer){
if(enabledTags != null && enabledTags.size() > 0){
String name = node.getNodeType() == Node.ELEMENT_NODE ?
node.getLocalName().toLowerCase() : node.getNodeName();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -33,6 +33,8 @@
import org.jboss.tools.jst.web.tld.IFilePathEncoder;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.css.AbsoluteFolderReferenceList;
+import org.jboss.tools.vpe.editor.css.RelativeFolderReferenceList;
import org.jboss.tools.vpe.editor.css.ResourceReference;
import org.w3c.dom.Node;
@@ -86,10 +88,10 @@
if (null != file) {
ResourceReference resourceReference = null;
if ("/".equals(tagValue.substring(0, 1))) {
- resourceReference = pageContext.getRuntimeAbsoluteFolder(file);
+ resourceReference = getRuntimeAbsoluteFolder(file);
tagValue = tagValue.substring(1);
} else {
- resourceReference = pageContext.getRuntimeRelativeFolder(file);
+ resourceReference = getRuntimeRelativeFolder(file);
}
String location = null;
@@ -113,6 +115,22 @@
return new VpeValue(getUnresolved());
}
+ public static ResourceReference getRuntimeRelativeFolder(IFile file) {
+ ResourceReference[] list =
RelativeFolderReferenceList.getInstance().getAllResources(file);
+ if (list.length > 0) {
+ return list[list.length - 1];
+ }
+ return null;
+ }
+
+ public static ResourceReference getRuntimeAbsoluteFolder(IFile file) {
+ ResourceReference[] list =
AbsoluteFolderReferenceList.getInstance().getAllResources(file);
+ if (list.length > 0) {
+ return list[list.length - 1];
+ }
+ return null;
+ }
+
protected IPath getInputParentPath(IEditorInput input) {
IPath inputPath = null;
if (input instanceof ILocationProvider) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/resize/VpeResizer.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -81,13 +81,6 @@
}
}
- public boolean isAbsolutePosition(){
- if ("yes".equals(VpePreference.USE_ABSOLUTE_POSITION.getValue())) {
- return true;
- }
- return false;
- }
-
/**
*
* @param pageContext
@@ -103,7 +96,7 @@
*/
public void resize(VpePageContext pageContext, Element sourceElement, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Object data, int resizeConstrant, int top,
int left, int width, int height) {
pageContext.getEditPart().getSourceEditor().getTextViewer().getUndoManager().beginCompoundChange();
- if (isAbsolutePosition() && (
+ if (VpePreference.isAbsolutePosition() && (
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_BOTTOMLEFT||
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_LEFT||
resizeConstrant == VpeTagDescription.RESIZE_CONSTRAINS_TOPLEFT||
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FormatControllerManager.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -82,7 +82,7 @@
ElementImpl elementImpl = (ElementImpl)newNode;
int startOffset = elementImpl.getStartOffset();
int startEndOffset = elementImpl.getStartEndOffset();
- StructuredTextViewer viewer =
getVpeController().getPageContext().getSourceBuilder().getStructuredTextViewer();
+ StructuredTextViewer viewer =
getVpeController().getSourceBuilder().getStructuredTextViewer();
try {
String newSelectedTagValue = viewer.getDocument().get(startOffset,
startEndOffset-startOffset);
if(currentSelectedTagValue!=null &&
currentSelectedTagValue.equals(newSelectedTagValue)) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/BlockFormatHandler.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -47,7 +47,7 @@
Node selectedNode = manager.getCurrentSelectedNodeInfo().getNode();
- StructuredTextViewer viewer =
manager.getVpeController().getPageContext().getSourceBuilder().getStructuredTextViewer();
+ StructuredTextViewer viewer =
manager.getVpeController().getSourceBuilder().getStructuredTextViewer();
Node replacedNode = null;
Node parentNode = selectedNode.getParentNode();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java 2007-12-17
19:30:09 UTC (rev 5352)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/handler/SimpleTagHandler.java 2007-12-17
19:42:46 UTC (rev 5353)
@@ -33,7 +33,7 @@
* @see org.jboss.tools.vpe.editor.toolbar.format.handler.FormatHandler#run()
*/
protected void run() {
- StructuredTextViewer viewer =
manager.getVpeController().getPageContext().getSourceBuilder().getStructuredTextViewer();
+ StructuredTextViewer viewer =
manager.getVpeController().getSourceBuilder().getStructuredTextViewer();
Node selectedNode = manager.getCurrentSelectedNodeInfo().getNode();
if(selectedNode==null) {
return;