Author: mareshkau
Date: 2007-07-17 04:02:16 -0400 (Tue, 17 Jul 2007)
New Revision: 2452
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPEditorMessages.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.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/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml
Log:
resolve
http://jira.jboss.com/jira/browse/JBIDE-531.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditor.java 2007-07-16
21:36:37 UTC (rev 2451)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/editor/IVisualEditor.java 2007-07-17
08:02:16 UTC (rev 2452)
@@ -17,6 +17,9 @@
public static final int VISUALSOURCE_MODE = 0;
public static final int VISUAL_MODE = 1;
public static final int SOURCE_MODE = 2;
+
+ /** PREVIEW_MODE */
+ public static final int PREVIEW_MODE = 3;
public void setVisualMode(int mode);
public IVisualController getController();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPEditorMessages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPEditorMessages.properties 2007-07-16
21:36:37 UTC (rev 2451)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPEditorMessages.properties 2007-07-17
08:02:16 UTC (rev 2452)
@@ -1,4 +1,4 @@
JSPMultiPageEditor.TabLabel.VisualSource = Visual/Source
JSPMultiPageEditor.TabLabel.Visual = Visual
JSPMultiPageEditor.TabLabel.Source = Source
-JSPMultiPageEditor.TabLabel.DefaultWebBrowser = Default web browser
\ No newline at end of file
+JSPMultiPageEditor.TabLabel.Preview = Preview
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2007-07-16
21:36:37 UTC (rev 2451)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2007-07-17
08:02:16 UTC (rev 2452)
@@ -22,8 +22,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
-import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
-import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.text.IRegion;
@@ -50,7 +48,6 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
-import org.eclipse.ui.part.MultiPageEditorSite;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IStatusField;
@@ -62,27 +59,28 @@
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.editor.IVisualContext;
-import org.jboss.tools.jst.jsp.editor.IVisualController;
-import org.jboss.tools.jst.jsp.editor.IVisualEditor;
-import org.jboss.tools.jst.jsp.editor.IVisualEditorFactory;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
-import org.osgi.framework.Bundle;
-
+import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.filesystems.impl.DiscardFileHandler;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.editor.EditorDescriptor;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.common.text.ext.IMultiPageEditor;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
+import org.jboss.tools.jst.jsp.editor.IVisualController;
+import org.jboss.tools.jst.jsp.editor.IVisualEditor;
+import org.jboss.tools.jst.jsp.editor.IVisualEditorFactory;
+import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
+import org.osgi.framework.Bundle;
// Fix for EXIN-232: The IMultiPageEditor interface implementation is added.
public class JSPMultiPageEditor extends JSPMultiPageEditorPart implements
@@ -95,6 +93,9 @@
private static final String VISUAL_TAB_LABEL =
"JSPMultiPageEditor.TabLabel.Visual";
private static final String SOURCE_TAB_LABEL =
"JSPMultiPageEditor.TabLabel.Source";
+
+ /** PREVIEW_TAB_LABEL */
+ private static final String PREVIEW_TAB_LABEL =
"JSPMultiPageEditor.TabLabel.Preview";
private IVisualEditor visualEditor;
@@ -105,6 +106,12 @@
JSPTextEditor sourceEditor;
private int sourceIndex;
+
+ /** composite control for default web-browser */
+ private IVisualEditor previewWebBrowser;
+
+ /** index of tab contain default web-browser */
+ private int previewIndex;
private boolean osWindows = true;
@@ -208,13 +215,17 @@
visualEditor.setVisualMode(IVisualEditor.VISUAL_MODE);
else if (newPageIndex == sourceIndex)
visualEditor.setVisualMode(IVisualEditor.SOURCE_MODE);
+ else if (newPageIndex == previewIndex) {
+ visualEditor.setVisualMode(IVisualEditor.PREVIEW_MODE);
+ }
+
superPageChange(newPageIndex);
} else {
super.pageChange(newPageIndex);
}
oldPage = newPageIndex;
}
-
+
public void setInput(IEditorInput input) {
super.setInput(XModelObjectEditorInput.checkInput(input));
if (getEditorInput() instanceof IModelObjectEditorInput) {
@@ -407,6 +418,17 @@
} catch (PartInitException e) {
JspEditorPlugin.getPluginLog().logError(e);
}
+
+ // Add tab contain default web-browser
+ try {
+ previewIndex = addPage(visualEditor, getEditorInput());
+ setPageText(previewIndex, JSPEditorMessages
+ .getString(PREVIEW_TAB_LABEL));
+ setPartName(visualEditor.getTitle());
+ } catch (PartInitException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+
}
public void doSave(IProgressMonitor monitor) {
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-07-16
21:36:37 UTC (rev 2451)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2007-07-17
08:02:16 UTC (rev 2452)
@@ -38,7 +38,11 @@
return templateManager;
}
- public void registerNodes(VpeNodeMapping nodeMapping) {
+ public void registerNodes(VpeNodeMapping nodeMapping) {
+ if (sorceAdapter == null) {
+ return;
+ }
+
domMapping.mapNodes(nodeMapping);
Node sourceNode = nodeMapping.getSourceNode();
if (((INodeNotifier) sourceNode).getExistingAdapter(sorceAdapter) == null) {
Modified:
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-07-16
21:36:37 UTC (rev 2451)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2007-07-17
08:02:16 UTC (rev 2452)
@@ -28,7 +28,6 @@
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
@@ -49,10 +48,10 @@
import org.eclipse.ui.texteditor.ITextEditorExtension;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
-
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.mozilla.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.mozilla.MozillaPreview;
import org.jboss.tools.vpe.editor.xpl.SashForm;
public class VpeEditorPart extends EditorPart implements ITextEditor,
ITextEditorExtension, IReusableEditor, IVisualEditor {
@@ -68,6 +67,12 @@
private static final QualifiedName SPLITTER_POSITION_KEY2 = new
QualifiedName("", "splitter_position2");
private int controlCount = 0;
+ /** default web-browser */
+ private MozillaPreview previewWebBrowser = null;
+
+ /** preview content */
+ private Composite previewContent = null;
+
public StructuredTextEditor getSourceEditor(){
return sourceEditor;
}
@@ -150,10 +155,10 @@
if(sourceEditor!=null)sourceEditor.removeRulerContextMenuListener(listener);
}
public void setStatusField(IStatusField field, String category) {
- if(visualMode == VISUAL_MODE){
- if(field != null){
- field.setImage(null);
- field.setText(null);
+ if(visualMode == VISUAL_MODE) {
+ if(field != null) {
+ field.setImage(null);
+ field.setText(null);
}
}else
if(sourceEditor!=null)sourceEditor.setStatusField(field, category);
@@ -256,15 +261,41 @@
case VISUALSOURCE_MODE:
if(sourceContent!= null)sourceContent.setVisible(true);
if(visualContent!= null)visualContent.setVisible(true);
+ if(previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
+
case VISUAL_MODE:
if(sourceContent!= null)sourceContent.setVisible(false);
if(visualContent!= null)visualContent.setVisible(true);
+ if(previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
+
case SOURCE_MODE:
if(sourceContent!= null)sourceContent.setVisible(true);
if(visualContent!= null)visualContent.setVisible(false);
+ if(previewContent != null) {
+ previewContent.setVisible(false);
+ }
break;
+
+ case PREVIEW_MODE:
+ if(sourceContent!= null) {
+ sourceContent.setVisible(false);
+ }
+
+ if(visualContent!= null) {
+ visualContent.setVisible(false);
+ }
+
+ if(previewContent != null) {
+ previewWebBrowser.rebuildDom();
+ previewContent.setVisible(true);
+ }
+ break;
}
container.layout();
if(visualMode == SOURCE_MODE && type != SOURCE_MODE) {
@@ -290,6 +321,12 @@
sourceContent.setLayout(new FillLayout());
visualContent = new Composite(container, SWT.NONE);
visualContent.setLayout(new FillLayout());
+
+
+ // Create a preview content
+ previewContent = new Composite(container, SWT.NONE);
+ previewContent.setLayout(new FillLayout());
+
if(sourceEditor == null)sourceEditor = new StructuredTextEditor() {
public void safelySanityCheckState(IEditorInput input) {
super.safelySanityCheckState(input);
@@ -318,6 +355,13 @@
VpePlugin.reportProblem(e);
}
+ previewWebBrowser = new MozillaPreview(this, sourceEditor);
+ try {
+ previewWebBrowser.init(getEditorSite(), getEditorInput());
+ } catch (Exception e) {
+ VpePlugin.reportProblem(e);
+ }
+
try {
sourceEditor.addPropertyListener(
new IPropertyListener() {
@@ -347,6 +391,18 @@
});
visualEditor.createPartControl(visualContent);
}
+
+
+ if(previewWebBrowser!=null) {
+ previewWebBrowser.setEditorLoadWindowListener(new EditorLoadWindowListener() {
+ public void load() {
+ previewWebBrowser.setEditorLoadWindowListener(null);
+ previewWebBrowser.buildDom();
+ }
+ });
+ previewWebBrowser.createPartControl(previewContent);
+ }
+
activeEditor = sourceEditor;
sourceContent.addListener(SWT.Activate, new Listener() {
@@ -371,6 +427,19 @@
}
});
+
+ previewContent.addListener(SWT.Activate, new Listener() {
+ public void handleEvent(Event event) {
+ if (event.type == SWT.Activate) {
+ if (previewWebBrowser!=null && activeEditor != previewWebBrowser) {
+ activeEditor = previewWebBrowser;
+ setFocus();
+ }
+ }
+ }
+ });
+
+
IWorkbenchWindow window = getSite().getWorkbenchWindow();
window.getPartService().addPartListener(activationListener);
window.getShell().addShellListener(activationListener);
@@ -414,6 +483,11 @@
visualEditor.dispose();
visualEditor = null;
}
+
+ if (previewContent != null) {
+ previewContent.dispose();
+ previewContent = null;
+ }
}
public Object getAdapter(Class adapter) {
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-07-16
21:36:37 UTC (rev 2451)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-07-17
08:02:16 UTC (rev 2452)
@@ -39,6 +39,9 @@
protected boolean caseSensitive;
protected boolean children;
protected boolean modify;
+
+ protected boolean haveVisualPreview;
+
private VpeResizer resizer;
private VpeDnd dragger;
private TextFormatingData textFormatingData;
@@ -145,6 +148,16 @@
this.caseSensitive = caseSensitive;
children =
"yes".equals(templateElement.getAttribute(VpeTemplateManager.ATTR_TEMPLATE_CHILDREN));
modify =
"yes".equals(templateElement.getAttribute(VpeTemplateManager.ATTR_TEMPLATE_MODIFY));
+
+ String strHaveVisualPreview =
templateElement.getAttribute(VpeTemplateManager.ATTR_TEMPLATE_HAVE_VISUAL_PREVIEW);
+
+ if (strHaveVisualPreview != null && strHaveVisualPreview.length() != 0 ) {
+ haveVisualPreview = "yes".equals(strHaveVisualPreview);
+ } else {
+ haveVisualPreview = true;
+ }
+
+
init(templateElement);
}
@@ -892,4 +905,8 @@
public boolean containsText() {
return true;
}
+
+ public boolean isHaveVisualPreview() {
+ return haveVisualPreview;
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2007-07-16
21:36:37 UTC (rev 2451)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2007-07-17
08:02:16 UTC (rev 2452)
@@ -194,7 +194,13 @@
*/
boolean isCaseSensitive();
+
/**
+ * @return <code>true</code> if the element is have visual preview
+ */
+ boolean isHaveVisualPreview();
+
+ /**
* Returns the data for formatting an element of source tree
* @return <code>TextFormatingData</code>
*/
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-07-16
21:36:37 UTC (rev 2451)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2007-07-17
08:02:16 UTC (rev 2452)
@@ -112,6 +112,9 @@
static final String ATTR_TEMPLATE_CLASS = "class";
static final String ATTR_TEMPLATE_CHILDREN = "children";
static final String ATTR_TEMPLATE_MODIFY = "modify";
+
+ /** ATTR_TEMPLATE_HAVE_VISUAL_PREVIEW */
+ static final String ATTR_TEMPLATE_HAVE_VISUAL_PREVIEW = "haveVisualPreview";
static final String ATTR_COPY_ATTRS = "attrs";
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml 2007-07-16
21:36:37 UTC (rev 2451)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml 2007-07-17
08:02:16 UTC (rev 2452)
@@ -1060,7 +1060,7 @@
</vpe:tag>
<vpe:tag name="f:view" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
+ <vpe:template children="yes" modify="yes"
haveVisualPreview="no">
<div style="border:1px dotted #FF6600;padding: 5px;"
title="{tagstring()}"/>
<vpe:dnd>
<vpe:drag start-enable="yes"/>
@@ -1078,7 +1078,7 @@
</vpe:tag>
<vpe:tag name="f:subview" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
+ <vpe:template children="yes" modify="yes"
haveVisualPreview="no">
<div style="border:1px dotted #FF6600;padding: 5px;"
title="{tagstring()}"/>
<vpe:dnd>
<vpe:drag start-enable="yes"/>
@@ -1096,7 +1096,7 @@
</vpe:tag>
<vpe:tag name="h:form" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
+ <vpe:template children="yes" modify="yes"
haveVisualPreview="no">
<div style="border:1px dotted #FF6600;padding: 5px;"
title="{tagstring()}"/>
<vpe:dnd>
<vpe:drag start-enable="yes"/>