Author: dmaliarevich
Date: 2009-09-25 07:34:43 -0400 (Fri, 25 Sep 2009)
New Revision: 17726
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/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/SashSetting.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4935, editors flipping was fixed.
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 2009-09-25
08:17:28 UTC (rev 17725)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2009-09-25
11:34:43 UTC (rev 17726)
@@ -546,13 +546,15 @@
* Editors orientation is based on preference's settings.
*/
container = new CustomSashForm(cmpEd, CustomSashForm
- .getSplittingFromPreferences());
+ .getSplittingDirection(JspEditorPlugin.getDefault().getPreferenceStore()
+ .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING)));
if (editorSettings != null) {
editorSettings.addSetting(new SashSetting(container));
}
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- if (CustomSashForm.isSourceEditorFirst()) {
+ if
(CustomSashForm.isSourceEditorFirst(JspEditorPlugin.getDefault().getPreferenceStore()
+ .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING))) {
sourceContent = new Composite(container, SWT.NONE);
visualContent = new Composite(container, SWT.NONE);
} else {
@@ -687,7 +689,7 @@
listener = new XModelTreeListener() {
public void nodeChanged(XModelTreeEvent event) {
- fillContainer();
+ fillContainer(false, null);
selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
}
@@ -762,7 +764,16 @@
};
}
- public void fillContainer() {
+ /**
+ * Re-fills the VPE container according to new settings.
+ *
+ * @param useCurrentEditorSettings
+ * if <code>true</code> VPE will hold its current state
+ * otherwise values from preference page will be used,
+ * @param currentOrientation
+ * current source-visual editors splitting value
+ */
+ public void fillContainer(boolean useCurrentEditorSettings, String currentOrientation)
{
/*
*
https://jira.jboss.org/jira/browse/JBIDE-4152
*
@@ -772,9 +783,15 @@
*
* Content should be added to a new container.
*/
+ String splitting;
+ if (useCurrentEditorSettings) {
+ splitting = currentOrientation;
+ } else {
+ splitting = JspEditorPlugin.getDefault().getPreferenceStore()
+ .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING);
+ }
CustomSashForm newContainer = new CustomSashForm(cmpEd, CustomSashForm
- .getSplittingFromPreferences());
- newContainer.setOrientation(CustomSashForm.getSplittingFromPreferences());
+ .getSplittingDirection(splitting));
/*
* Reset editor's settings.
@@ -784,18 +801,13 @@
editorSettings.addSetting(new SashSetting(newContainer));
}
newContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- /*
- * Read stored preference settings.
- * Correct layout by selecting the order of components adding.
- * All three editors should be added to the new container.
- */
- if (CustomSashForm.isSourceEditorFirst()) {
- sourceContent.setParent(newContainer);
- visualContent.setParent(newContainer);
+
+ if (CustomSashForm.isSourceEditorFirst(splitting)) {
+ sourceContent.setParent(newContainer);
+ visualContent.setParent(newContainer);
} else {
- visualContent.setParent(newContainer);
- sourceContent.setParent(newContainer);
+ visualContent.setParent(newContainer);
+ sourceContent.setParent(newContainer);
}
previewContent.setParent(newContainer);
@@ -825,29 +837,33 @@
int defaultWeight = JspEditorPlugin.getDefault().getPreferenceStore()
.getInt(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_WEIGHTS);
int[] weights = container.getWeights();
- if (defaultWeight == 0) {
- if (CustomSashForm.isSourceEditorFirst()) {
- container.maxDown();
- } else {
- container.maxUp();
- }
- } else if (defaultWeight == 1000) {
- if (CustomSashForm.isSourceEditorFirst()) {
- container.maxUp();
- } else {
- container.maxDown();
- }
+ if (useCurrentEditorSettings) {
+ newContainer.setWeights(weights);
} else {
- if (CustomSashForm.isSourceEditorFirst()) {
- weights[0] = 1000 - defaultWeight;
- weights[1] = defaultWeight;
+ if (defaultWeight == 0) {
+ if (CustomSashForm.isSourceEditorFirst(splitting)) {
+ container.maxDown();
+ } else {
+ container.maxUp();
+ }
+ } else if (defaultWeight == 1000) {
+ if (CustomSashForm.isSourceEditorFirst(splitting)) {
+ container.maxUp();
+ } else {
+ container.maxDown();
+ }
} else {
- weights[0] = defaultWeight;
- weights[1] = 1000 - defaultWeight;
+ if (CustomSashForm.isSourceEditorFirst(splitting)) {
+ weights[0] = 1000 - defaultWeight;
+ weights[1] = defaultWeight;
+ } else {
+ weights[0] = defaultWeight;
+ weights[1] = 1000 - defaultWeight;
+ }
+ if ((weights != null) && !container.isDisposed()){
+ container.setWeights(weights);
+ }
}
- if ((weights != null) && !container.isDisposed()){
- container.setWeights(weights);
- }
}
container.setSashBorders(new boolean[] { true, true, true });
@@ -1118,7 +1134,8 @@
public void maximizeSource() {
if (container != null) {
- if (CustomSashForm.isSourceEditorFirst()) {
+ if
(CustomSashForm.isSourceEditorFirst(JspEditorPlugin.getDefault().getPreferenceStore()
+ .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING))) {
container.maxDown();
} else {
container.maxUp();
@@ -1134,7 +1151,8 @@
public void maximizeVisual() {
if (container != null) {
- if (CustomSashForm.isSourceEditorFirst()) {
+ if
(CustomSashForm.isSourceEditorFirst(JspEditorPlugin.getDefault().getPreferenceStore()
+ .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING))) {
container.maxUp();
} else {
container.maxDown();
@@ -1178,7 +1196,7 @@
*/
if (getController() != null) {
selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
- fillContainer();
+ fillContainer(false, null);
getController().getVisualBuilder().setShowInvisibleTags(JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
IVpePreferencesPage.SHOW_NON_VISUAL_TAGS));
getController().getPageContext().getBundle().updateShowBundleUsageAsEL();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2009-09-25
08:17:28 UTC (rev 17725)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2009-09-25
11:34:43 UTC (rev 17726)
@@ -134,6 +134,7 @@
private static Map<String, String> layoutIcons;
private static Map<String, String> layoutNames;
private static List<String> layoutValues;
+ private int currentOrientationIndex = 1;
static {
layoutIcons = new HashMap<String, String>();
layoutIcons.put(IVpePreferencesPage.SPLITTING_HORIZ_LEFT_SOURCE_VALUE,
ICON_ORIENTATION_SOURCE_LEFT);
@@ -265,7 +266,7 @@
*
https://jira.jboss.org/jira/browse/JBIDE-4152
* Compute initial icon state and add it to the tool bar.
*/
- int currentOrientationIndex = layoutValues.indexOf(JspEditorPlugin
+ currentOrientationIndex = layoutValues.indexOf(JspEditorPlugin
.getDefault().getPreferenceStore().getString(
IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING));
int newIndx = currentOrientationIndex+1;
@@ -285,35 +286,11 @@
* Rotate editors orientation clockwise. Store this new
* orientation to the preferences.
*/
- int currentOrientationIndex = layoutValues
- .indexOf(JspEditorPlugin
- .getDefault()
- .getPreferenceStore()
- .getString(
- IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING));
- int newIndx = currentOrientationIndex + 1;
- if (newIndx == layoutValues.size()) {
- newIndx = newIndx % layoutValues.size();
+ currentOrientationIndex++;
+ if (currentOrientationIndex == layoutValues.size()) {
+ currentOrientationIndex = currentOrientationIndex % layoutValues.size();
}
- String newOrientation = layoutValues.get(newIndx);
- JspEditorPlugin.getDefault().getPreferenceStore().setValue(
- IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING,
- newOrientation);
-
- /*
- * Compute next step orientation and display appropriate icon.
- */
- currentOrientationIndex = layoutValues
- .indexOf(JspEditorPlugin
- .getDefault()
- .getPreferenceStore()
- .getString(
- IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING));
- newIndx = currentOrientationIndex + 1;
- if (newIndx == layoutValues.size()) {
- newIndx = newIndx % layoutValues.size();
- }
- newOrientation = layoutValues.get(newIndx);
+ String newOrientation = layoutValues.get(currentOrientationIndex);
rotateEditorsItem.setImage(ImageDescriptor.createFromFile(
MozillaEditor.class, layoutIcons.get(newOrientation))
.createImage());
@@ -322,10 +299,10 @@
* Call <code>filContainer()</code> from VpeEditorPart
* to redraw CustomSashForm with new layout.
*/
- getController().getPageContext().getEditPart().fillContainer();
+ getController().getPageContext().getEditPart().fillContainer(true, newOrientation);
}
});
-
+
verBar.pack();
return verBar;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java 2009-09-25
08:17:28 UTC (rev 17725)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java 2009-09-25
11:34:43 UTC (rev 17726)
@@ -1154,15 +1154,21 @@
}
public void changeOrientation() {
- int prefsOrientation = getSplittingFromPreferences();
+ int prefsOrientation =
getSplittingDirection(JspEditorPlugin.getDefault().getPreferenceStore()
+ .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING));
if (getOrientation() != prefsOrientation) {
setOrientation(prefsOrientation);
}
}
- public static int getSplittingFromPreferences() {
- String splitting = JspEditorPlugin.getDefault().getPreferenceStore()
- .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING);
+ /**
+ * Computes the splitting style:
+ * SWT.HORIZONTAL or SWT.VERTICAL
+ *
+ * @param splitting source-visual editors splitting value
+ * @return integer style value
+ */
+ public static int getSplittingDirection(String splitting) {
if (IVpePreferencesPage.SPLITTING_HORIZ_LEFT_SOURCE_VALUE
.equalsIgnoreCase(splitting)
|| IVpePreferencesPage.SPLITTING_HORIZ_LEFT_VISUAL_VALUE
@@ -1173,15 +1179,20 @@
}
}
- public static boolean isSourceEditorFirst() {
- boolean sourceEditorFirst = false;
- String splitting = JspEditorPlugin.getDefault().getPreferenceStore()
- .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING);
- if (IVpePreferencesPage.SPLITTING_HORIZ_LEFT_SOURCE_VALUE
+ /**
+ * Checks if the source editor is displayed on the first place,
+ * i.e. on the top, or to the left.
+ *
+ * @param splitting source-visual editors splitting value
+ * @return <code>true</code> when the source goes first
+ */
+ public static boolean isSourceEditorFirst(String splitting) {
+ boolean sourceEditorFirst = true;
+ if (IVpePreferencesPage.SPLITTING_HORIZ_LEFT_VISUAL_VALUE
.equalsIgnoreCase(splitting)
- || IVpePreferencesPage.SPLITTING_VERT_TOP_SOURCE_VALUE
+ || IVpePreferencesPage.SPLITTING_VERT_TOP_VISUAL_VALUE
.equalsIgnoreCase(splitting)) {
- sourceEditorFirst = true;
+ sourceEditorFirst = false;
}
return sourceEditorFirst;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/SashSetting.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/SashSetting.java 2009-09-25
08:17:28 UTC (rev 17725)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/SashSetting.java 2009-09-25
11:34:43 UTC (rev 17726)
@@ -46,20 +46,22 @@
.getInt(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_WEIGHTS);
int[] weights = sash.getWeights();
if (weights.length > 2) {
+ String splitting = JspEditorPlugin.getDefault().getPreferenceStore()
+ .getString(IVpePreferencesPage.VISUAL_SOURCE_EDITORS_SPLITTING);
if (defaultWeight == 0) {
- if (CustomSashForm.isSourceEditorFirst()) {
+ if (CustomSashForm.isSourceEditorFirst(splitting)) {
sash.maxDown();
} else {
sash.maxUp();
}
} else if (defaultWeight == 1000) {
- if (CustomSashForm.isSourceEditorFirst()) {
+ if (CustomSashForm.isSourceEditorFirst(splitting)) {
sash.maxUp();
} else {
sash.maxDown();
}
} else {
- if (CustomSashForm.isSourceEditorFirst()) {
+ if (CustomSashForm.isSourceEditorFirst(splitting)) {
weights[0] = 1000 - defaultWeight;
weights[1] = defaultWeight;
} else {