Author: vyemialyanchyk
Date: 2007-12-20 12:41:46 -0500 (Thu, 20 Dec 2007)
New Revision: 5409
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/VpeEditorPart.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/VpeSelectionBuilder.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/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.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/VpeTemplateManager.java
Log:
code revert for
http://jira.jboss.com/jira/browse/JBIDE-1457 &
http://jira.jboss.com/jira/browse/JBIDE-788
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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -89,7 +89,6 @@
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;
@@ -159,6 +158,7 @@
// 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,17 +202,15 @@
}
this.visualEditor = visualEditor;
visualEditor.setController(this);
+ templateManager = VpeTemplateManager.getInstance();
bundle = new BundleMap();
bundle.init(sourceEditor);
- pageContext = new VpePageContext(bundle, editPart);
- // vitali - temp solution
- pageContext.setVisualContext(getPageContext());
-
+ pageContext = new VpePageContext(templateManager, bundle, editPart);
domMapping = new VpeDomMapping(pageContext);
- sourceBuilder = new VpeSourceDomBuilder(domMapping, this, sourceEditor, pageContext);
- visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor, pageContext);
- pageContext.setSourceBuilder(sourceBuilder);
- pageContext.setVisualBuilder(visualBuilder);
+ 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;
@@ -222,7 +220,6 @@
visualBuilder.refreshExternalLinks();
visualBuilder.buildDom(sourceDocument);
- VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
templateManager.addTemplateListener(this);
xulRunnerEditor = visualEditor.getXulRunnerEditor();
@@ -268,16 +265,15 @@
relativeFolderReferenceListListener = RelativeFolderReferenceList.getInstance();
relativeFolderReferenceListListener.addChangeListener(this);
- //vitali
- //pageContext.fireTaglibsChanged();
+ pageContext.fireTaglibsChanged();
}
public void dispose() {
switcher.destroyActiveEditor();
- VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
- templateManager.removeTemplateListener(this);
-
+ if (templateManager != null) {
+ templateManager.removeTemplateListener(this);
+ }
if (visualBuilder != null) {
visualBuilder.dispose();
visualBuilder = null;
@@ -400,14 +396,10 @@
break;
}
if (visualBuilder.rebuildFlag) {
- //vitali
- //pageContext.fireTaglibsChanged();
- //vitali
- //} else if (pageContext.isTaglibChanged()) {
- } else if (true) {
+ pageContext.fireTaglibsChanged();
+ } else if (pageContext.isTaglibChanged()) {
visualRefreshImpl();
- //vitali
- //pageContext.fireTaglibsChanged();
+ pageContext.fireTaglibsChanged();
}
switcher.stopActiveEditor();
}
@@ -559,8 +551,7 @@
visualBuilder.setSelectionRectangle(null);
IDOMDocument sourceDocument = sourceModel.getDocument();
visualBuilder.rebuildDom(sourceDocument);
- //vitali
- //pageContext.fireTaglibsChanged();
+ pageContext.fireTaglibsChanged();
}
switcher.stopActiveEditor();
}
@@ -698,7 +689,7 @@
return;
}
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< mouseUp " + (mouseDownSelectionFlag ?
"true" : "false")); //$NON-NLS-1$
+ System.out.println("<<< mouseUp"); //$NON-NLS-1$
}
if (mouseDownSelectionFlag) {
mouseEvent.preventDefault();
@@ -915,9 +906,7 @@
data.setName(actionNode.getNodeName());
}
data = editAnyData(sourceEditor, isCorrectNS, data);
- if (data != null && data.isChanged()) {
- VpeTemplateManager.getInstance().setAnyTemplate(data);
- }
+ if (data != null && data.isChanged())
templateManager.setAnyTemplate(data);
}
});
@@ -1110,8 +1099,7 @@
return;
}
visualRefreshImpl();
- //vitali
- //pageContext.fireTaglibsChanged();
+ pageContext.fireTaglibsChanged();
switcher.stopActiveEditor();
}
@@ -1248,8 +1236,8 @@
}
if (bundle != null) {
bundle.refresh();
- if (getPageContext() != null) {
- getPageContext().refreshBundleValues();
+ if (pageContext != null) {
+ pageContext.refreshBundleValues();
}
}
switcher.stopActiveEditor();
@@ -1259,16 +1247,16 @@
if (includeList.includesRefresh()) {
visualRefresh();
}
- VpeTemplateManager templateManager = VpeTemplateManager.getInstance();
- templateManager.reload();
-
+ if (templateManager != null) {
+ templateManager.reload();
+ }
if (bundle != null) {
bundle.refresh();
- if (getPageContext() != null) {
+ if (pageContext != null) {
if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
- getPageContext().refreshBundleValues();
+ pageContext.refreshBundleValues();
switcher.stopActiveEditor();
}
}
@@ -1654,12 +1642,8 @@
}
}
- public VpeVisualDomBuilder getVisualBuilder(){
- return visualBuilder;
- }
-
public void refreshExternalLinks() {
- getVisualBuilder().refreshExternalLinks();
+ pageContext.getVisualBuilder().refreshExternalLinks();
}
public IPath getPath() {
@@ -1674,7 +1658,7 @@
public void changed(Object source) {
if(cssReferenceListListener == source) {
- getVisualBuilder().refreshExternalLinks();
+ pageContext.getVisualBuilder().refreshExternalLinks();
} else if (absoluteFolderReferenceListListener == source ||
relativeFolderReferenceListListener == source ||
taglibReferenceListListener == source) {
@@ -2175,12 +2159,8 @@
tip = null;
}
- public IVisualContext getPageContext() {
- IVisualContext visualContext = null;
- if (sourceEditor instanceof IJSPTextEditor) {
- visualContext = ((IJSPTextEditor)sourceEditor).getPageContext();
- }
- return visualContext;
+ public VpePageContext getPageContext() {
+ return pageContext;
}
public StructuredTextEditor getSourceEditor() {
@@ -2332,17 +2312,6 @@
public VpeSelectionBuilder getSelectionBuilder() {
return selectionBuilder;
}
-
- /**
- * @return the sourceBuilder
- */
- 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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -20,16 +20,23 @@
public class VpeDomBuilder {
protected VpeDomMapping domMapping;
+
+ protected VpeTemplateManager templateManager;
private INodeAdapter sorceAdapter;
- public VpeDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter) {
+ public VpeDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
VpeTemplateManager templateManager) {
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/VpeEditorPart.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-12-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -66,11 +66,15 @@
public class VpeEditorPart extends EditorPart implements ITextEditor,
ITextEditorExtension, IReusableEditor, IVisualEditor {
private SashForm container;
+ private StructuredTextEditor sourceEditor = null;
+ private MozillaEditor visualEditor;
private IEditorPart activeEditor;
private XModelTreeListener listener;
XModelObject optionsObject;
private SelectionBar selectionBar = new SelectionBar();
private ActivationListener activationListener = new ActivationListener();
+ private int visualMode = 0;
+ private EditorPart multiPageEditor;
private static final QualifiedName SPLITTER_POSITION_KEY1 = new QualifiedName(
"", "splitter_position1");
private static final QualifiedName SPLITTER_POSITION_KEY2 = new QualifiedName(
@@ -80,27 +84,16 @@
private int controlCount = 0;
- // parent editor
- private EditorPart multiPageEditor;
-
- // 4 tabs - VISUALSOURCE_MODE, VISUAL_MODE, SOURCE_MODE, PREVIEW_MODE
- private int visualMode = 0;
/** default web-browser */
- // visible in Preview tab
private MozillaPreview previewWebBrowser = null;
- // visible in Visual/Source and in Visual tabs
- private MozillaEditor visualEditor = null;
- // visible in Visual/Source and in Source tabs - created in anycase active tab
- private StructuredTextEditor sourceEditor = null;
/** preview content */
- // preview
private Composite previewContent = null;
- // visual
- private Composite visualContent = null;
- // source
- private Composite sourceContent = null;
+ public StructuredTextEditor getSourceEditor() {
+ return sourceEditor;
+ }
+
// returns JSPMultipageEditor for closing by ctrl+F4 and ctrl+shift+F4 keys
public EditorPart getParentEditor() {
return multiPageEditor;
@@ -230,7 +223,7 @@
}
public IAction getAction(String actionID) {
- return getSourceEditor().getAction(actionID);
+ return sourceEditor.getAction(actionID);
}
public VpeEditorPart() {
@@ -257,7 +250,7 @@
public void setInput(IEditorInput input) {
super.setInput(input);
- if (null != visualEditor && visualEditor.getEditorInput() != null
+ if (visualEditor != null && visualEditor.getEditorInput() != null
&& visualEditor.getEditorInput() != getEditorInput()) {
visualEditor.setInput(input);
}
@@ -329,65 +322,80 @@
}
}
- protected void setVisualMode(String showSelBar,
- boolean flagSC, boolean flagVC, boolean flagPC) {
+ Composite sourceContent = null;
+ Composite visualContent = null;
- if (null != selectionBar) {
- if (flagPC) {
- getSourceEditor();
- }
- selectionBar.showBar(showSelBar);
- }
- if (null != sourceContent) {
- sourceContent.setVisible(flagSC);
- //Added by Max Areshkau
- //was fixed bug(border which drawed by iflasher doesn't hide on MACOS when we
swith
- // to souce view)
- //if(Platform.getOS().equals(Platform.OS_MACOSX)&&controller!=null) {
- // getVE().getController().visualRefresh();
- //}
- }
- if (null != visualContent) {
- if (flagVC) {
- getVE();
- }
- visualContent.setVisible(flagVC);
- }
- if (null != previewContent) {
- if (flagPC) {
- getWB();
- getWB().rebuildDom();
- }
- previewContent.setVisible(flagPC);
- }
- }
-
public void setVisualMode(int type) {
- String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR.getValue();
+ String showSelectionBar = VpePreference.SHOW_SELECTION_TAG_BAR
+ .getValue();
switch (type) {
case VISUALSOURCE_MODE:
- setVisualMode(showSelectionBar, true, true, false);
+ selectionBar.showBar(showSelectionBar);
+ if (sourceContent != null)
+ sourceContent.setVisible(true);
+ if (visualContent != null)
+ visualContent.setVisible(true);
+ if (previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
case VISUAL_MODE:
- setVisualMode(showSelectionBar, false, true, false);
+ selectionBar.showBar(showSelectionBar);
+ if (sourceContent != null)
+ sourceContent.setVisible(false);
+ if (visualContent != null)
+ visualContent.setVisible(true);
+ if (previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
case SOURCE_MODE:
- setVisualMode(showSelectionBar, true, false, false);
+ selectionBar.showBar(showSelectionBar);
+ if (sourceContent != null) {
+ sourceContent.setVisible(true);
+
+ //Added by Max Areshkau
+ //was fixed bug(border which drawed by iflasher doesn't hide on MACOS when we
swith
+ // to souce view)
+// if(Platform.getOS().equals(Platform.OS_MACOSX)&&controller!=null) {
+//
+// visualEditor.getController().visualRefresh();
+// }
+ }
+ if (visualContent != null)
+ visualContent.setVisible(false);
+ if (previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
case PREVIEW_MODE:
- setVisualMode("no", false, false, true);
+ if (selectionBar != null) {
+ selectionBar.showBar("no");
+ }
+ if (sourceContent != null) {
+ sourceContent.setVisible(false);
+ }
+
+ if (visualContent != null) {
+ visualContent.setVisible(false);
+ }
+
+ if (previewContent != null) {
+ previewWebBrowser.rebuildDom();
+ previewContent.setVisible(true);
+ }
break;
}
container.layout();
if (visualMode == SOURCE_MODE && type != SOURCE_MODE) {
visualMode = type;
- if (getVE().getController() != null) {
- getVE().getController().visualRefresh();
- if (type != PREVIEW_MODE) {
- getVE().getController().sourceSelectionChanged();
+ if (visualEditor.getController() != null) {
+ visualEditor.getController().visualRefresh();
+ if(type!=PREVIEW_MODE) {
+ visualEditor.getController().sourceSelectionChanged();
}
}
}
@@ -400,10 +408,10 @@
public void createPartControl(Composite parent) {
controlCount++;
- if (controlCount > 1) {
+ if (controlCount > 1)
return;
- }
// //////////////////////////////////////////////////////////////
+
Composite cmpEdTl = new Composite(parent, SWT.NONE);
GridLayout layoutEdTl = new GridLayout(1, false);
layoutEdTl.verticalSpacing = 0;
@@ -425,21 +433,30 @@
cmpEd.setLayout(layoutEd);
cmpEd.setLayoutData(new GridData(GridData.FILL_BOTH));
// /////////////////////////////////////////////////////////////////
-
container = new SashForm(cmpEd, SWT.VERTICAL);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
+ sourceContent = new Composite(container, SWT.NONE);
+ sourceContent.setLayout(new FillLayout());
+ visualContent = new Composite(container, SWT.NONE);
+ visualContent.setLayout(new FillLayout());
+
+ // Create a preview content
+ previewContent = new Composite(container, SWT.NONE);
+ previewContent.setLayout(new FillLayout());
+
// ////////////////////////////////////////////////////
+
selectionBar.createToolBarComposite(cmpEdTl, true);
// ///////////////////////////////////////////////////
-
- getSC();
- getVC();
- getPC();
+ if (sourceEditor == null)
+ sourceEditor = new StructuredTextEditor() {
+ public void safelySanityCheckState(IEditorInput input) {
+ super.safelySanityCheckState(input);
+ }
+ };
int[] weights = loadSplitterPosition();
- if (weights != null) {
+ if (weights != null)
container.setWeights(weights);
- }
container.addWeightsChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
saveSplitterPosition(container.getWeights());
@@ -454,11 +471,106 @@
container.layout();
}
});
- activeEditor = setupSourceEditor();
+ visualEditor = new MozillaEditor();
try {
+ visualEditor.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+
+ previewWebBrowser = new MozillaPreview(this, sourceEditor);
+ try {
+ previewWebBrowser.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+
+ try {
+ sourceEditor.addPropertyListener(new IPropertyListener() {
+ public void propertyChanged(Object source, int propId) {
+ if (propId == IWorkbenchPartConstants.PROP_TITLE) {
+ VpeEditorPart.this.setPartName(sourceEditor.getTitle());
+ }
+ VpeEditorPart.this.firePropertyChange(propId);
+ }
+ });
+ sourceEditor.init(getEditorSite(), getEditorInput());
+
+ if (sourceContent != null) {
+ sourceEditor.createPartControl(sourceContent);
+ }
+ if (visualEditor != null) {
+ visualEditor
+ .setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ visualEditor.setEditorLoadWindowListener(null);
+ visualEditor.setController(new VpeController(
+ VpeEditorPart.this));
+ selectionBar.setVpeController(visualEditor.getController());
+ visualEditor.getController().setSelectionBarController(selectionBar);
+ try {
+ visualEditor.getController().init(sourceEditor, visualEditor);
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+ }
+ });
+ visualEditor.createPartControl(visualContent);
+ }
+
+ if (previewWebBrowser != null) {
+ previewWebBrowser
+ .setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ previewWebBrowser
+ .setEditorLoadWindowListener(null);
+ previewWebBrowser.buildDom();
+ }
+ });
+ previewWebBrowser.createPartControl(previewContent);
+ }
+
+ activeEditor = sourceEditor;
+
+ sourceContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (activeEditor != sourceEditor) {
+ activeEditor = sourceEditor;
+ setFocus();
+ }
+ }
+ }
+ });
+
+ visualContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (visualEditor != null
+ && activeEditor != visualEditor) {
+ activeEditor = visualEditor;
+ setFocus();
+ }
+ }
+ }
+ });
+
+ previewContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (previewWebBrowser != null
+ && activeEditor != previewWebBrowser) {
+ activeEditor = previewWebBrowser;
+ setFocus();
+ }
+ }
+ }
+ });
+
IWorkbenchWindow window = getSite().getWorkbenchWindow();
window.getPartService().addPartListener(activationListener);
window.getShell().addShellListener(activationListener);
+
} catch (Exception e) {
VpePlugin.reportProblem(e);
}
@@ -572,6 +684,9 @@
fIsHandlingActivation = true;
try {
if (sourceEditor != null) {
+ if (visualEditor.getController() != null) {
+ visualEditor.getController().refreshTemplates();
+ }
sourceEditor.safelySanityCheckState(getEditorInput());
}
} finally {
@@ -582,146 +697,7 @@
}
public VpeController getController() {
- return getVE().getController();
+ return visualEditor.getController();
}
- public StructuredTextEditor getSourceEditor() {
- return sourceEditor;
- }
-
- public Composite getSC() {
- if (null != sourceContent) {
- return sourceContent;
- }
- sourceContent = new Composite(container, SWT.NONE);
- sourceContent.setLayout(new FillLayout());
- return sourceContent;
- }
-
- public StructuredTextEditor setupSourceEditor() {
- if (null == sourceEditor) {
- sourceEditor = new StructuredTextEditor() {
- public void safelySanityCheckState(IEditorInput input) {
- super.safelySanityCheckState(input);
- }
- };
- }
- sourceEditor.addPropertyListener(new IPropertyListener() {
- public void propertyChanged(Object source, int propId) {
- if (propId == IWorkbenchPartConstants.PROP_TITLE) {
- VpeEditorPart.this.setPartName(sourceEditor.getTitle());
- }
- VpeEditorPart.this.firePropertyChange(propId);
- }
- });
- try {
- sourceEditor.init(getEditorSite(), getEditorInput());
- } catch (PartInitException e) {
- VpePlugin.reportProblem(e);
- }
- sourceEditor.createPartControl(getSC());
- getSC().addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (activeEditor != sourceEditor) {
- activeEditor = sourceEditor;
- setFocus();
- }
- }
- }
- });
- return sourceEditor;
- }
-
- public Composite getVC() {
- if (null != visualContent) {
- return visualContent;
- }
- visualContent = new Composite(container, SWT.NONE);
- visualContent.setLayout(new FillLayout());
- return visualContent;
- }
-
- public MozillaEditor getVE() {
- if (null != visualEditor) {
- return visualEditor;
- }
- visualEditor = new MozillaEditor();
- try {
- visualEditor.init(getEditorSite(), getEditorInput());
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
- if (null == visualEditor) {
- return visualEditor;
- }
- visualEditor.setEditorLoadWindowListener(new EditorLoadWindowListener() {
- public void load() {
- visualEditor.setEditorLoadWindowListener(null);
- visualEditor.setController(new VpeController(VpeEditorPart.this));
- selectionBar.setVpeController(visualEditor.getController());
- visualEditor.getController().setSelectionBarController(selectionBar);
- try {
- visualEditor.getController().init(sourceEditor, visualEditor);
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
- }
- });
- visualEditor.createPartControl(getVC());
- getVC().addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (null != visualEditor && activeEditor != visualEditor) {
- activeEditor = visualEditor;
- setFocus();
- }
- }
- }
- });
- return visualEditor;
- }
-
- public Composite getPC() {
- if (null != previewContent) {
- return previewContent;
- }
- previewContent = new Composite(container, SWT.NONE);
- previewContent.setLayout(new FillLayout());
- return previewContent;
- }
-
- public MozillaPreview getWB() {
- if (null != previewWebBrowser) {
- return previewWebBrowser;
- }
- previewWebBrowser = new MozillaPreview(this, sourceEditor);
- try {
- previewWebBrowser.init(getEditorSite(), getEditorInput());
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- }
- if (null == previewWebBrowser) {
- return previewWebBrowser;
- }
- previewWebBrowser.setEditorLoadWindowListener(new EditorLoadWindowListener() {
- public void load() {
- previewWebBrowser.setEditorLoadWindowListener(null);
- previewWebBrowser.buildDom();
- }
- });
- previewWebBrowser.createPartControl(getPC());
- getPC().addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.Activate) {
- if (null != previewWebBrowser && activeEditor != previewWebBrowser) {
- activeEditor = previewWebBrowser;
- setFocus();
- }
- }
- }
- });
- return previewWebBrowser;
- }
-
}
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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -50,8 +50,8 @@
* @param visualEditor
* @param pageContext
*/
- public VpePreviewDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
MozillaEditor visualEditor, VpePageContext pageContext) {
- super(domMapping, sorceAdapter, visualEditor, pageContext);
+ public VpePreviewDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
VpeTemplateManager templateManager, MozillaEditor visualEditor, VpePageContext
pageContext) {
+ super(domMapping, sorceAdapter, templateManager, visualEditor, pageContext);
}
@@ -66,14 +66,9 @@
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
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/VpeSelectionBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-12-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -69,9 +69,6 @@
}
public void setSelection(nsISelection selection) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("VpeSelectionBuilder.setSelection: selection.getIsCollapsed()
" + selection.getIsCollapsed());
- }
if (selection.getIsCollapsed()) {
VisualSelectionInfo info = getVisualFocusSelectedInfo(selection);
if (info != null) {
@@ -375,22 +372,12 @@
private Node getSelectedTextOnly(nsIDOMNode element) {
Node selectedText = null;
nsISelection selection =
visualSelectionController.getSelection(nsISelectionController.SELECTION_NORMAL);
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("VpeSelectionBuilder.getSelectedTextOnly: selection " +
- (selection) +
- " selection.getIsCollapsed() " +
- (selection.getIsCollapsed()));
- }
if (!selection.getIsCollapsed()) {
nsIDOMNode anchorNode = selection.getAnchorNode();
nsIDOMNode focusNode = selection.getFocusNode();
if (anchorNode != null && anchorNode.getNodeType() == Node.TEXT_NODE
&& anchorNode.equals(focusNode)) {
nsIDOMNode anchorParent = anchorNode.getParentNode();
if (anchorParent != null) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("VpeSelectionBuilder.getSelectedTextOnly:
anchorParent.equals(element) " +
- (anchorParent.equals(element)));
- }
if (anchorParent.equals(element)) {
selectedText = domMapping.getSourceNode(anchorNode);
}
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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -28,7 +28,6 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
@@ -37,7 +36,6 @@
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.util.TextUtil;
-import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
@@ -56,8 +54,8 @@
private VpePageContext pageContext;
private StructuredTextEditor sourceEditor;
- public VpeSourceDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
StructuredTextEditor sourceEditor, VpePageContext pageContext) {
- super(domMapping, sorceAdapter);
+ public VpeSourceDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter,
VpeTemplateManager templateManager, StructuredTextEditor sourceEditor, VpePageContext
pageContext) {
+ super(domMapping, sorceAdapter, templateManager);
this.sourceEditor = sourceEditor;
structuredTextViewer = sourceEditor.getTextViewer();
outline = (IContentOutlinePage)sourceEditor.getAdapter(IContentOutlinePage.class);
@@ -164,10 +162,6 @@
}
void setSelection(Node sourceNode, int offset, int length, boolean innerFlag) {
- if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("VpeSourceDomBuilder.setSelection: offset " + offset +
- " length " + length + " innerFlag " + innerFlag);
- }
if (sourceNode != null) {
int start = ((IndexedRegion)sourceNode).getStartOffset() + offset;
if (innerFlag && offset == 0 && sourceNode instanceof ElementImpl) {
@@ -225,7 +219,6 @@
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);
@@ -386,7 +379,7 @@
return structuredTextViewer;
}
- public Document getSourceDocument() {
+ Document getSourceDocument() {
return sourceDocument;
}
}
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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -159,8 +159,9 @@
private VpeDnd dropper;
public VpeVisualDomBuilder(VpeDomMapping domMapping,
- INodeAdapter sorceAdapter, MozillaEditor visualEditor, VpePageContext pageContext)
{
- super(domMapping, sorceAdapter);
+ INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
+ MozillaEditor visualEditor, VpePageContext pageContext) {
+ super(domMapping, sorceAdapter, templateManager);
this.visualEditor = visualEditor;
xulRunnerEditor = visualEditor.getXulRunnerEditor();
this.visualDocument = visualEditor.getDomDocument();
@@ -185,9 +186,11 @@
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) input).getFile();
if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file, visualEditor.getSourceDocument()));
+ includeStack.add(new VpeIncludeInfo(null, file, pageContext
+ .getSourceBuilder().getSourceDocument()));
}
}
+ pageContext.refreshConnector();
pageContext.installIncludeElements();
addChildren(null, sourceDocument, visualContentArea);
registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
@@ -359,14 +362,9 @@
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
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);
@@ -398,11 +396,7 @@
VpeElementMapping elementMapping = new VpeElementMapping(
(Element) sourceNode, visualNewElement, border,
template, ifDependencySet, creationData.getData());
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
elementMapping.setXmlnsMap(xmlnsMap);
- /**/
registerNodes(elementMapping);
}
if (template.isChildren()) {
@@ -682,18 +676,17 @@
}
private void addPseudoElementImpl(nsIDOMNode visualParent) {
- 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);
- }
+ 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) {
@@ -907,11 +900,7 @@
updateElement(sourceElement);
}
}
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
setXmlnsAttribute(elementMapping, name, value);
- /**/
template.setAttribute(pageContext, sourceElement,
visualDocument, visualElement, elementMapping
.getData(), name, value);
@@ -1017,11 +1006,7 @@
name, null)) {
updateElement(sourceElement);
} else {
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
removeXmlnsAttribute(elementMapping, name);
- /**/
template.removeAttribute(pageContext, sourceElement,
visualDocument, (nsIDOMElement) elementMapping
.getVisualNode(), elementMapping.getData(),
@@ -1887,9 +1872,6 @@
pageContext.dispose();
}
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
protected Map createXmlns(Element sourceNode) {
NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
if (attrs != null) {
@@ -1904,11 +1886,7 @@
}
return null;
}
- /**/
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
private void setXmlnsAttribute(VpeElementMapping elementMapping,
String name, String value) {
Element sourceElement = (Element) elementMapping.getSourceNode();
@@ -1920,11 +1898,7 @@
elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
}
}
- /**/
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
private void removeXmlnsAttribute(VpeElementMapping elementMapping,
String name) {
Element sourceElement = (Element) elementMapping.getSourceNode();
@@ -1941,22 +1915,16 @@
}
}
}
- /**/
- /**/
- // vitali TODO: this is wrong temporary way - get rid of it
- //-
private void addTaglib(Element sourceElement, Map xmlnsMap,
String attrName, boolean ns) {
Attr attr = sourceElement.getAttributeNode(attrName);
if (ATTR_XMLNS.equals(attr.getPrefix())) {
- //vitali
- //xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
+ xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
.getLocalName(), ns);
}
}
- /**/
/**
* @return the dnd
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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -113,7 +113,7 @@
case VK_F4:
IWorkbenchPage workbenchPage =
VpePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(keyEvent.getShiftKey()) workbenchPage.closeAllEditors(true);
- else
workbenchPage.closeEditor(getController().getVpeEditorPart().getParentEditor(),true);
+ else workbenchPage.closeEditor(pageContext.getEditPart().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 =
getStructuredTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
+ String sourceText =
sourceEditor.getTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
String escString = TextUtil.isEcsToRight(sourceText, offset);
if(escString != null){
- Point range = getStructuredTextViewer().getSelectedRange();
- getStructuredTextViewer().getTextWidget().replaceTextRange(range.x,
escString.length(), "");
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ sourceEditor.getTextViewer().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 = getStructuredTextViewer().getSelectedRange();
- getStructuredTextViewer().getTextWidget().replaceTextRange(range.x, endPos,
"");
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ sourceEditor.getTextViewer().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 =
getStructuredTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
+ String sourceText =
sourceEditor.getTextViewer().getDocument().get(region.getStartOffset(),
region.getEndOffset()-region.getStartOffset());
String escString = TextUtil.isEcsToLeft(sourceText,offset);
if(escString != null){
- Point range = getStructuredTextViewer().getSelectedRange();
- getStructuredTextViewer().getTextWidget().replaceTextRange(range.x-escString.length(),
escString.length(), "");
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ sourceEditor.getTextViewer().getTextWidget().replaceTextRange(range.x-escString.length(),
escString.length(), "");
atLeastOneCharIsDeleted = true;
return selection;
@@ -744,8 +744,8 @@
}
endPos--;
if(endPos!=0){
- Point range = getStructuredTextViewer().getSelectedRange();
- getStructuredTextViewer().getTextWidget().replaceTextRange(range.x-endPos, endPos,
"");
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
+ sourceEditor.getTextViewer().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 getController().getVisualBuilder().isEmptyElement(visualNode);
+ return pageContext.getVisualBuilder().isEmptyElement(visualNode);
} catch (Exception e) {
VpePlugin.getPluginLog().logError(e);
}
@@ -989,18 +989,14 @@
}
}
- private StructuredTextViewer getStructuredTextViewer() {
- return sourceEditor.getTextViewer();
- }
-
private void setSourceFocus(int offset) {
- getStructuredTextViewer().setSelectedRange(offset, 0);
- getStructuredTextViewer().revealRange(offset, 0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(offset, 0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(offset, 0);
}
private void setSelectionRange(int startOffset, int endOffset) {
- getStructuredTextViewer().setSelectedRange(endOffset, startOffset - endOffset);
- getStructuredTextViewer().revealRange(endOffset, startOffset - endOffset);
+ pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(endOffset,
startOffset - endOffset);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(endOffset,
startOffset - endOffset);
}
private void removeNode(Node focusNode) {
@@ -1020,7 +1016,7 @@
if (selection != null) {
Node sourceNode = selection.getFocusNode();
if (sourceNode != null) {
- VpeDomMapping mapping = getController().getDomMapping();
+ VpeDomMapping mapping = pageContext.getDomMapping();
if (mapping != null) {
nsIDOMNode visualNode = mapping.getVisualNode(sourceNode);
if (visualNode != null) {
@@ -1041,11 +1037,11 @@
isEditable = true;
}
if (isEditable) {
- start = getStructuredTextViewer().getSelectedRange().x;
+ start = sourceEditor.getTextViewer().getSelectedRange().x;
}
}
}
- } else if (getController().getSourceBuilder().isEmptyDocument()) {
+ } else if (pageContext.getSourceBuilder().isEmptyDocument()) {
isEditable = true;
start = 0;
}
@@ -1057,9 +1053,9 @@
if(TextUtil.containsKey(s[0])){
str = TextUtil.getValue(s[0]);
}
- getStructuredTextViewer().getTextWidget().replaceTextRange(start, 0, str);
- getStructuredTextViewer().setSelectedRange(start + str.length(), 0);
- getStructuredTextViewer().revealRange(start + str.length(), 0);
+ sourceEditor.getTextViewer().getTextWidget().replaceTextRange(start, 0, str);
+ pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(start +
str.length(), 0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(start +
str.length(), 0);
return true;
}
return false;
@@ -1098,7 +1094,7 @@
}
if (!handled && focusNode.getParentNode().getNodeType() ==
Node.DOCUMENT_NODE) {
if (focusNode.getNodeType() == Node.TEXT_NODE) {
- Point range = getStructuredTextViewer().getSelectedRange();
+ Point range = sourceEditor.getTextViewer().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));
@@ -1108,7 +1104,7 @@
newNode = (Text)newNode.getParentNode().removeChild(newNode);
p1.appendChild(focusNode);
p2.appendChild(newNode);
- setCursor(newNode);
+ setCursor(pageContext, newNode);
}
}
} else if (focusNode instanceof Comment) {
@@ -1169,7 +1165,7 @@
if (!handled) {
if (focusNode.getNodeType() == Node.TEXT_NODE) {
if (focusNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
- Point range = getStructuredTextViewer().getSelectedRange();
+ Point range = sourceEditor.getTextViewer().getSelectedRange();
Node p1 = focusNode.getOwnerDocument().createElement("p");
Node p2 = focusNode.getOwnerDocument().createElement("p");
Text newNode = ((Text)focusNode).splitText(getSourceNodeOffset(focusNode,
range.x));
@@ -1179,7 +1175,7 @@
newNode = (Text)newNode.getParentNode().removeChild(newNode);
p1.appendChild(focusNode);
p2.appendChild(newNode);
- setCursor(newNode);
+ setCursor(pageContext, newNode);
int p1Start = ((IndexedRegion)p1).getStartOffset();
int p2End = ((IndexedRegion)p2).getEndOffset();
@@ -1201,7 +1197,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(newNode);
+ setCursor(pageContext, newNode);
int n2End = ((IndexedRegion)newNode).getEndOffset();
region = new Region(n1Start, n2End - n1Start);
}
@@ -1219,10 +1215,10 @@
}
try {
- StructuredTextViewer viewer = getStructuredTextViewer();
+ StructuredTextViewer viewer = sourceEditor.getTextViewer();
if (region != null){
if (sourceEditor instanceof ITextFormatter) {
- ((ITextFormatter)sourceEditor).formatTextRegion(viewer.getDocument(), region);
+ ((ITextFormatter)sourceEditor).formatTextRegion(sourceEditor.getTextViewer().getDocument(),
region);
}
}
} catch (Exception x) {
@@ -1235,7 +1231,7 @@
private String getLinePrefix(int offset) {
try {
- final IDocument document = getStructuredTextViewer().getDocument();
+ final IDocument document = sourceEditor.getTextViewer().getDocument();
final int linePrefixBeginning =
document.getLineInformationOfOffset(offset).getOffset();
String linePrefix = document.get(linePrefixBeginning, offset - linePrefixBeginning);
int linePrefixLength = 0;
@@ -1323,14 +1319,14 @@
return 0;
}
- private void setCursor(Node node) {
+ private void setCursor(VpePageContext pageContext, Node node) {
int nodeOffset = ((IndexedRegion)node).getStartOffset();
if (node.getNodeType() == Node.ELEMENT_NODE) {
ElementImpl element = (ElementImpl)node;
nodeOffset = element.getStartEndOffset();
}
- getStructuredTextViewer().setSelectedRange(nodeOffset, 0);
- getStructuredTextViewer().revealRange(nodeOffset, 0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(nodeOffset,
0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(nodeOffset, 0);
}
private boolean moveForward() {
@@ -1340,8 +1336,8 @@
Node node = getNextNode(selection.getStartNode());
if (node != null) {
int nodeOffset = ((IndexedRegion)node).getStartOffset();
- getStructuredTextViewer().setSelectedRange(nodeOffset, 0);
- getStructuredTextViewer().revealRange(nodeOffset, 0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(nodeOffset,
0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(nodeOffset, 0);
return true;
}
}
@@ -1480,8 +1476,8 @@
Node node = getPrevNode(selection.getStartNode());
if (node != null) {
int nodeOffset = ((IndexedRegion)node).getStartOffset();
- getStructuredTextViewer().setSelectedRange(nodeOffset, 0);
- getStructuredTextViewer().revealRange(nodeOffset, 0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(nodeOffset,
0);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(nodeOffset, 0);
return true;
}
}
@@ -1804,18 +1800,18 @@
}
}
- return nearestElement;
+ return nearestElement;
}
- private VpeController getController() {
- return pageContext.getEditPart().getController();
- }
+
private VpeSelectionBuilder getSelectionBuilder() {
- return getController().getSelectionBuilder();
+
+ return pageContext.getEditPart().getController().getSelectionBuilder();
}
- private nsIDOMElement getSelectedNode() {
- return getController().getXulRunnerEditor().getLastSelectedElement();
+ private nsIDOMElement getSelectedNode() {
+
+ return pageContext.getEditPart().getController().getXulRunnerEditor().getLastSelectedElement();
}
}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-12-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -340,7 +340,7 @@
case BREAKER_TYPE_IGNORE:
return true;
case BREAKER_TYPE_SELECTITEM:
- return VpeBreackerHelper.selectItem(pageContext.getSourceBuilder(), sourceDocument,
sourceNode, visualNode, data, charCode, selection);
+ return VpeBreackerHelper.selectItem(pageContext, sourceDocument, sourceNode,
visualNode, data, charCode, selection);
default:
return nonctrlKeyPressHandlerImpl(pageContext, sourceDocument, sourceNode,
visualNode, data, charCode, selection, formatter);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.java 2007-12-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeBreackerHelper.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -16,14 +16,14 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMNode;
public class VpeBreackerHelper {
- public static boolean selectItem(VpeSourceDomBuilder sourceBuilder, Document
sourceDocument, Node sourceNode, nsIDOMNode visualNode, Object data, long charCode,
VpeSourceSelection selection) {
+ public static boolean selectItem(VpePageContext pageContext, Document sourceDocument,
Node sourceNode, nsIDOMNode visualNode, Object data, long charCode, VpeSourceSelection
selection) {
Attr attr = selection.getFocusAttribute();
if (attr != null) {
Point range = selection.getFocusAttributeRange();
@@ -43,7 +43,7 @@
if (newAttr != null) {
newAttr.setNodeValue(newAttr.getNodeValue().substring(0, range.x));
}
- sourceBuilder.setAttributeSelection((Attr)attr, 0, 0);
+ pageContext.getSourceBuilder().setAttributeSelection((Attr)attr, 0, 0);
return true;
}
}
@@ -51,7 +51,7 @@
return false;
}
- public static boolean breakInline(VpeSourceDomBuilder sourceBuilder, Document
sourceDocument, Node sourceNode, Node visualNode, Object data, int charCode,
VpeSourceSelection selection) {
+ public static boolean breakInline(VpePageContext pageContext, Document sourceDocument,
Node sourceNode, Node visualNode, Object data, int charCode, VpeSourceSelection selection)
{
Attr attr = selection.getFocusAttribute();
if (attr != null) {
Point range = selection.getFocusAttributeRange();
@@ -72,7 +72,7 @@
if (newAttr != null) {
newAttr.setNodeValue(newAttr.getNodeValue().substring(0, range.x));
}
- sourceBuilder.setAttributeSelection((Attr)attr, 0, 0);
+ pageContext.getSourceBuilder().setAttributeSelection((Attr)attr, 0, 0);
}
Node parent = selectItemNode.getParentNode();
if (parent != null) {
@@ -85,7 +85,7 @@
selectItemNode = parent.removeChild(newSelectItemNode);
p2.appendChild(newSelectItemNode);
- sourceBuilder.getStructuredTextViewer()
+ pageContext.getSourceBuilder().getStructuredTextViewer()
.setSelectedRange(((IndexedRegion)p1).getStartOffset(),
((IndexedRegion)p2).getEndOffset() - ((IndexedRegion)p1).getStartOffset());
return true;
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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -307,9 +307,9 @@
private static final String PREFIX_SEPARATOR = ":";
private String getPageLocale(VpePageContext pageContext, IDOMElement sourceElement) {
- try {
- //vitali: temp solution
- List<TaglibData> taglibs = pageContext.getVisualContext().getTagLibs();
+ IStructuredModel model = null;
+ try {
+ List<TaglibData> taglibs = pageContext.getTagLibs();
// Find F tracker
TaglibData fTD = null;
for (int i = 0; i < taglibs.size(); i++) {
@@ -345,6 +345,8 @@
} 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-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLoadBundleCreator.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -48,14 +48,12 @@
public void setAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name, String value) {
setBundle(pageContext, sourceElement);
- //vitali: temp solution
- pageContext.getVisualContext().refreshBundleValues();
+ pageContext.refreshBundleValues();
}
public void removeAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name) {
setBundle(pageContext, sourceElement);
- //vitali: temp solution
- pageContext.getVisualContext().refreshBundleValues();
+ pageContext.refreshBundleValues();
}
private void setBundle(VpePageContext pageContext, Element sourceElement) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2007-12-20
17:41:29 UTC (rev 5408)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2007-12-20
17:41:46 UTC (rev 5409)
@@ -32,7 +32,6 @@
import org.w3c.dom.NodeList;
import org.jboss.tools.common.xml.XMLUtilities;
-import org.jboss.tools.jst.jsp.editor.IVisualContext;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -794,8 +793,4 @@
defTemplate.init(createDefTemplateElement(), true);
return defTemplate;
}
-
- public void initVisualContext(IVisualContext visualContext) {
- visualContext.setTemplateTaglibs(templateTaglibs);
- }
}