### Eclipse Workspace Patch 1.0 #P org.jboss.tools.jst.jsp Index: src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java =================================================================== --- src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java (revision 39266) +++ src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java (working copy) @@ -107,6 +107,17 @@ private static final String VISUAL_EDITOR_IMPL_EXTENSION_POINT_NAME = "visulaEditorImplementations"; //$NON-NLS-1$ private IVisualEditor visualEditor; + /* + * https://issues.jboss.org/browse/JBIDE-10711 + * Set the xulRunnerBrowser state. + */ + private boolean xulRunnerBrowserIsNotSupported = false; + /* + * Flag that indicates that the editor + * is being creating for the first time, + * i.e. part is initializing. + */ + private boolean vpeIsCreating = true; private int visualSourceIndex; private int sourceIndex; @@ -246,14 +257,38 @@ public void pageChange(int newPageIndex) { selectedPageIndex = newPageIndex; if (visualEditor != null) { - if (newPageIndex == visualSourceIndex) { + if (selectedPageIndex == visualSourceIndex) { if (visualEditor.getVisualEditor() == null) { visualEditor.createVisualEditor(); + /* + * https://issues.jboss.org/browse/JBIDE-10711 + * XulRunnerBrowser could be not supported. + * So there should be special handling when + * VisualEditor is created for the first time. + */ + if (isXulRunnerBrowserIsNotSupported() && vpeIsCreating) { + /* + * Set Source tab as default + */ + visualEditor.setVisualMode(IVisualEditor.SOURCE_MODE); + selectedPageIndex = IVisualEditor.SOURCE_MODE; + setActivePage(selectedPageIndex); + } else { + /* + * Use default behavior for tab switching + */ + visualEditor.setVisualMode(IVisualEditor.VISUALSOURCE_MODE); + } + } else { + /* + * https://issues.jboss.org/browse/JBIDE-10711 + * Use default behavior for tab switching + */ + visualEditor.setVisualMode(IVisualEditor.VISUALSOURCE_MODE); } - visualEditor.setVisualMode(IVisualEditor.VISUALSOURCE_MODE); - } else if (newPageIndex == sourceIndex) + } else if (selectedPageIndex == sourceIndex) visualEditor.setVisualMode(IVisualEditor.SOURCE_MODE); - else if (newPageIndex == getPreviewIndex()) { + else if (selectedPageIndex == getPreviewIndex()) { if (visualEditor.getPreviewWebBrowser() == null) { visualEditor.createPreviewBrowser(); } @@ -266,7 +301,7 @@ commandService.refreshElements(SelectionBarHandler.COMMAND_ID, null); getSelectionBar().refreshVisibility(); - superPageChange(newPageIndex); + superPageChange(selectedPageIndex); JspEditorPlugin.getDefault().getPreferenceStore(). setValue(IVpePreferencesPage.DEFAULT_VPE_TAB, selectedPageIndex); } @@ -422,11 +457,9 @@ } protected void createPages() { - try { createPagesForVPE(); loadSelectedTab(); - switch (selectedPageIndex) { case 0: { // source/visual mode @@ -460,6 +493,11 @@ } } catch (PartInitException e) { JspEditorPlugin.getPluginLog().logError(e); + } finally { + /* + * Indicate that VPE pages have been created. + */ + vpeIsCreating = false; } } @@ -856,6 +894,15 @@ return pr; } + public boolean isXulRunnerBrowserIsNotSupported() { + return xulRunnerBrowserIsNotSupported; + } + + public void setXulRunnerBrowserIsNotSupported( + boolean xulRunnerBrowserIsNotSupported) { + this.xulRunnerBrowserIsNotSupported = xulRunnerBrowserIsNotSupported; + } + class ResourceChangeListener implements IResourceChangeListener { IEditorPart editorPart; #P org.jboss.tools.vpe Index: src/org/jboss/tools/vpe/editor/VpeEditorPart.java =================================================================== --- src/org/jboss/tools/vpe/editor/VpeEditorPart.java (revision 39266) +++ src/org/jboss/tools/vpe/editor/VpeEditorPart.java (working copy) @@ -66,6 +66,7 @@ import org.jboss.tools.jst.jsp.JspEditorPlugin; import org.jboss.tools.jst.jsp.bundle.BundleMap; import org.jboss.tools.jst.jsp.editor.IVisualEditor; +import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor; import org.jboss.tools.jst.jsp.jspeditor.StorageRevisionEditorInputAdapter; import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage; import org.jboss.tools.jst.jsp.preferences.VpePreference; @@ -78,6 +79,7 @@ import org.jboss.tools.vpe.editor.xpl.CustomSashForm.ICustomSashFormListener; import org.jboss.tools.vpe.editor.xpl.EditorSettings; import org.jboss.tools.vpe.editor.xpl.SashSetting; +import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser; @SuppressWarnings("restriction") public class VpeEditorPart extends EditorPart implements @@ -804,7 +806,18 @@ toolBar = visualEditor.createVisualToolbar(verticalToolbarSplitter); visualEditor.createPartControl(visualContent); - + /* + * https://issues.jboss.org/browse/JBIDE-10711 + */ + if (!XulRunnerBrowser.isCurrentPlatformOfficiallySupported()) { + if (multiPageEditor instanceof JSPMultiPageEditor) { + JSPMultiPageEditor jspMultiPageEditor = (JSPMultiPageEditor) multiPageEditor; + /* + * Set the flag in JSPMultiPageEditor + */ + jspMultiPageEditor.setXulRunnerBrowserIsNotSupported(true); + } + } // initialize editor // this method must be invoked before any visual // node is created, see JBIDE-5105