[jbosstools-commits] JBoss Tools SVN: r39443 - in trunk: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Mar 12 12:23:08 EDT 2012


Author: yradtsevich
Date: 2012-03-12 12:23:07 -0400 (Mon, 12 Mar 2012)
New Revision: 39443

Modified:
   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/VpeEditorPart.java
Log:
https://issues.jboss.org/browse/JBIDE-10711 - patch2 has been applied: when xulrunner is not supported -- source tab will be loaded by default.

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	2012-03-12 16:09:32 UTC (rev 39442)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java	2012-03-12 16:23:07 UTC (rev 39443)
@@ -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,18 +257,64 @@
 	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 (isXulRunnerBrowserNotSupported() && vpeIsCreating) {
+						/*
+						 * Set Source tab as default
+						 */
+						visualEditor.setVisualMode(IVisualEditor.SOURCE_MODE);
+						selectedPageIndex = IVisualEditor.SOURCE_MODE;
+						setActivePage(selectedPageIndex);
+					} else {
+						/*
+						 * Use default behavior for tab switching
+						 * when the JSPEditor has already been initialized,
+						 * but visual part is loaded for the first time.
+						 */
+						visualEditor.setVisualMode(IVisualEditor.VISUALSOURCE_MODE);
+					}
+				} else {
+					/*
+					 * https://issues.jboss.org/browse/JBIDE-10711
+					 * Use default behavior for tab switching
+					 * when visual editor is not null.
+					 */
+					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();
+					/*
+					 * https://issues.jboss.org/browse/JBIDE-10711
+					 */
+					if (isXulRunnerBrowserNotSupported() && vpeIsCreating) {
+						/*
+						 * Set Source tab as default
+						 */
+						visualEditor.setVisualMode(IVisualEditor.SOURCE_MODE);
+						selectedPageIndex = IVisualEditor.SOURCE_MODE;
+						setActivePage(selectedPageIndex);
+					} else {
+						/*
+						 * Use default behavior for tab switching
+						 * when the JSPEditor has already been initialized,
+						 * but preview part is loaded for the first time.
+						 */
+						visualEditor.setVisualMode(IVisualEditor.PREVIEW_MODE);
+					}
+				} else {
+					visualEditor.setVisualMode(IVisualEditor.PREVIEW_MODE);
 				}
-				visualEditor.setVisualMode(IVisualEditor.PREVIEW_MODE);
 			}
 		}
 		
@@ -266,7 +323,7 @@
 		commandService.refreshElements(SelectionBarHandler.COMMAND_ID, null);
 		getSelectionBar().refreshVisibility();
 		
-		superPageChange(newPageIndex);
+		superPageChange(selectedPageIndex);
 		JspEditorPlugin.getDefault().getPreferenceStore().
 			setValue(IVpePreferencesPage.DEFAULT_VPE_TAB, selectedPageIndex);
 	}
@@ -422,11 +479,9 @@
 	}
 
 	protected void createPages() {
-
 		try {
 			createPagesForVPE();
 			loadSelectedTab();
-
 			switch (selectedPageIndex) {
 				case 0: {
 					// source/visual mode
@@ -460,6 +515,11 @@
 			}
 		} catch (PartInitException e) {
 			JspEditorPlugin.getPluginLog().logError(e);
+		} finally {
+			/*
+			 * Indicate that VPE pages have been created.
+			 */
+			vpeIsCreating = false;
 		}
 
 	}
@@ -856,6 +916,15 @@
 		return pr;
 	}
 
+	public boolean isXulRunnerBrowserNotSupported() {
+		return xulRunnerBrowserIsNotSupported;
+	}
+
+	public void setXulRunnerBrowserIsNotSupported(
+			boolean xulRunnerBrowserIsNotSupported) {
+		this.xulRunnerBrowserIsNotSupported = xulRunnerBrowserIsNotSupported;
+	}
+
 class ResourceChangeListener implements IResourceChangeListener {
 	IEditorPart editorPart;
 

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	2012-03-12 16:09:32 UTC (rev 39442)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java	2012-03-12 16:23:07 UTC (rev 39443)
@@ -64,6 +64,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;
@@ -76,6 +77,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 
@@ -765,6 +767,18 @@
 		} catch (PartInitException e) {
 			VpePlugin.reportProblem(e);
 		}
+		/*
+		 * 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);
+			}
+		}
 	}
 
 	@Override



More information about the jbosstools-commits mailing list