Author: dmaliarevich
Date: 2009-04-25 07:29:26 -0400 (Sat, 25 Apr 2009)
New Revision: 14919
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_bottom.gif
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_left.gif
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_right.gif
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_top.gif
Modified:
trunk/common/plugins/org.jboss.tools.common.model/resources/meta/studio_eclipse_option.meta
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
Log:
https://jira.jboss.org/jira/browse/JBIDE-4152, possibility of editors rotation was added.
Modified:
trunk/common/plugins/org.jboss.tools.common.model/resources/meta/studio_eclipse_option.meta
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/resources/meta/studio_eclipse_option.meta 2009-04-24
17:14:46 UTC (rev 14918)
+++
trunk/common/plugins/org.jboss.tools.common.model/resources/meta/studio_eclipse_option.meta 2009-04-25
11:29:26 UTC (rev 14919)
@@ -1315,13 +1315,15 @@
</Constraint>
<Editor name="List"/>
</XModelAttribute>
- <XModelAttribute default="Vertical"
+ <XModelAttribute default="Vertical Source on top"
name="Visual/Source editors splitting"
xmlname="visual_source_editors_splitting">
<Constraint loader="List">
- <value name="Horizontal"/>
- <value name="Vertical"/>
+ <value name="Vertical Source on top"/>
+ <value name="Vertical Visual on top"/>
+ <value name="Horizontal Source to the left"/>
+ <value name="Horizontal Visual to the left"/>
</Constraint>
- <Editor name="RadioArray"/>
+ <Editor name="List"/>
</XModelAttribute>
<XModelAttribute default="500"
name="Size of Visual Editor pane 0-100%"
xmlname="source_visual_editors_weights">
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_bottom.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_bottom.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_left.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_left.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_right.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_right.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_top.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_top.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
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-04-24
17:14:46 UTC (rev 14918)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2009-04-25
11:29:26 UTC (rev 14919)
@@ -97,11 +97,13 @@
private IContextActivation fContextActivation;
private IHandlerActivation sourceActivation,visualActivation, jumpingActivation;
private IHandler sourceMaxmin,visualMaxmin, jumping;
+ private Composite cmpEd;
private CustomSashForm container;
protected EditorSettings editorSettings;
private StructuredTextEditor sourceEditor = null;
private MozillaEditor visualEditor;
private IEditorPart activeEditor;
+ private ControlListener controlListener;
private XModelTreeListener listener;
private XModelObject optionsObject;
private SelectionBar selectionBar = new SelectionBar();
@@ -479,7 +481,7 @@
cmpEdTl.setLayout(layoutEdTl);
cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
- Composite cmpEd = new Composite(cmpEdTl, SWT.NATIVE);
+ cmpEd = new Composite(cmpEdTl, SWT.NATIVE);
GridLayout layoutEd = new GridLayout(1, false);
layoutEd.marginBottom = 0;
layoutEd.marginHeight = 1;
@@ -492,23 +494,33 @@
cmpEd.setLayoutData(new GridData(GridData.FILL_BOTH));
// /////////////////////////////////////////////////////////////////
//container = new SashForm(cmpEd, SWT.VERTICAL);
- String sashOrientation = VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING.getValue();
/*
- *
https://jira.jboss.org/jira/browse/JBIDE-4152
- * Sash orientation can be changed to either vertical or horizontal.
+ *
https://jira.jboss.org/jira/browse/JBIDE-4152
+ * Editors orientation is based on preference's settings.
*/
- container = new CustomSashForm(cmpEd, (CustomSashForm.LAYOUT_HORIZONTAL
- .equalsIgnoreCase(sashOrientation) ? SWT.HORIZONTAL : SWT.VERTICAL));
- container.setSashOrientation(sashOrientation);
- if (editorSettings != null)
- editorSettings.addSetting(new SashSetting(container));
+ container = new CustomSashForm(cmpEd, CustomSashForm
+ .getSplittingFromPreferences());
+ if (editorSettings != null) {
+ editorSettings.addSetting(new SashSetting(container));
+ }
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- sourceContent = new Composite(container, SWT.NONE);
+ String splitting = VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING
+ .getValue();
+ if (CustomSashForm.LAYOUT_HORIZONTAL_SOURCE_LEFT
+ .equalsIgnoreCase(splitting)
+ || CustomSashForm.LAYOUT_VERTICAL_SOURCE_TOP
+ .equalsIgnoreCase(splitting)) {
+ sourceContent = new Composite(container, SWT.NONE);
+ visualContent = new Composite(container, SWT.NONE);
+ } else {
+ visualContent = new Composite(container, SWT.NONE);
+ 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());
@@ -543,11 +555,8 @@
}
});
- final ControlListener controlListener = new ControlListener() {
- public void controlMoved(ControlEvent event) {
-
- }
-
+ controlListener = new ControlListener() {
+ public void controlMoved(ControlEvent event) {}
public void controlResized(ControlEvent event) {
container.layout();
}
@@ -682,8 +691,8 @@
listener = new XModelTreeListener() {
public void nodeChanged(XModelTreeEvent event) {
- selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
- container.changeOrientation();
+ fillContainer();
+ selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
}
public void structureChanged(XModelTreeEvent event) {
@@ -756,7 +765,94 @@
}
};
}
+
+ private void fillContainer() {
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-4152
+ *
+ * To re-layout editors new sash form will be created.
+ * Source, visual and preview content will stay the same,
+ * cause there are no changes to the model.
+ *
+ * Content should be added to a new container.
+ */
+ CustomSashForm newContainer = new CustomSashForm(cmpEd, CustomSashForm
+ .getSplittingFromPreferences());
+ /*
+ * Reset editor's settings.
+ */
+ if (editorSettings != null) {
+ editorSettings.dispose();
+ 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.
+ */
+ String splitting = VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING
+ .getValue();
+ if (CustomSashForm.LAYOUT_HORIZONTAL_SOURCE_LEFT
+ .equalsIgnoreCase(splitting)
+ || CustomSashForm.LAYOUT_VERTICAL_SOURCE_TOP
+ .equalsIgnoreCase(splitting)) {
+ sourceContent.setParent(newContainer);
+ visualContent.setParent(newContainer);
+ } else {
+ visualContent.setParent(newContainer);
+ sourceContent.setParent(newContainer);
+ }
+ previewContent.setParent(newContainer);
+
+ /*
+ * Dispose the old container:
+ * it'll be excluded from parent composite's layout.
+ */
+ if (null != container) {
+ container.dispose();
+ }
+
+ /*
+ * Reset the container.
+ */
+ container = newContainer;
+ int[] weights = loadSplitterPosition();
+ if (weights != null) {
+ container.setWeights(weights);
+ }
+ container.setSashBorders(new boolean[] { true, true, true });
+ /*
+ * Reinit listeners on the new container.
+ */
+ final PropertyChangeListener weightsChangeListener = new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ saveSplitterPosition(container.getWeights());
+ }
+ };
+ container.addWeightsChangeListener(weightsChangeListener);
+ container.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ container.removeWeightsChangeListener(weightsChangeListener);
+ container.removeDisposeListener(this);
+ }
+
+ });
+ controlListener = new ControlListener() {
+ public void controlMoved(ControlEvent event) {}
+ public void controlResized(ControlEvent event) {
+ container.layout();
+ }
+ };
+
+ /*
+ * Layout parent composite.
+ */
+ cmpEd.layout(true, true);
+ }
+
public void createVisualEditor() {
visualEditor = new MozillaEditor();
try {
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-04-24
17:14:46 UTC (rev 14918)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2009-04-25
11:29:26 UTC (rev 14919)
@@ -13,6 +13,10 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
@@ -53,6 +57,7 @@
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.part.EditorPart;
+import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
@@ -65,6 +70,7 @@
import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.xpl.CustomSashForm;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.resref.VpeResourcesDialog;
import org.jboss.tools.vpe.xulrunner.XPCOM;
@@ -103,6 +109,24 @@
private Link link = null;
private boolean isRefreshPage = false;
private String doctype;
+
+ private static Map<String, String> layoutIcons;
+ private static List<String> layoutNames;
+ static {
+ layoutIcons = new HashMap<String, String>();
+ layoutIcons.put(CustomSashForm.LAYOUT_HORIZONTAL_SOURCE_LEFT,
"icons/source_left.gif"); //$NON-NLS-1$
+ layoutIcons.put(CustomSashForm.LAYOUT_VERTICAL_SOURCE_TOP,
"icons/source_top.gif"); //$NON-NLS-1$
+ layoutIcons.put(CustomSashForm.LAYOUT_HORIZONTAL_VISUAL_LEFT,
"icons/source_right.gif"); //$NON-NLS-1$
+ layoutIcons.put(CustomSashForm.LAYOUT_VERTICAL_VISUAL_TOP,
"icons/source_bottom.gif"); //$NON-NLS-1$
+
+ layoutNames = new ArrayList<String>();
+ layoutNames.add(CustomSashForm.LAYOUT_HORIZONTAL_SOURCE_LEFT);
+ layoutNames.add(CustomSashForm.LAYOUT_VERTICAL_SOURCE_TOP);
+ layoutNames.add(CustomSashForm.LAYOUT_HORIZONTAL_VISUAL_LEFT);
+ layoutNames.add(CustomSashForm.LAYOUT_VERTICAL_VISUAL_TOP);
+
+ }
+
/**
* Used for manupalation of browser in design mode,
* for example enable or disable readOnlyMode
@@ -270,8 +294,54 @@
}
}
});
-
+
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-4152
+ * Compute initial icon state and add it to the tool bar.
+ */
+ int currentOrientationIndex =
layoutNames.indexOf(VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING.getValue());
+ int newIndx = currentOrientationIndex+1;
+ if (newIndx == layoutNames.size()) {
+ newIndx = newIndx % layoutNames.size();
+ }
+ String newOrientation = layoutNames.get(newIndx);
+
+ final ToolItem rotateEditorsItem = createToolItem(verBar, SWT.BUTTON1,
+ layoutIcons.get(newOrientation), newOrientation);
+ rotateEditorsItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ try {
+ /*
+ * Rotate editors orientation clockwise.
+ * Store this new orientation to the preferences.
+ */
+ int currentOrientationIndex =
layoutNames.indexOf(VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING.getValue());
+ int newIndx = currentOrientationIndex+1;
+ if (newIndx == layoutNames.size()) {
+ newIndx = newIndx % layoutNames.size();
+ }
+ String newOrientation = layoutNames.get(newIndx);
+ VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING.setValue(newOrientation);
+
+ /*
+ * Compute next step orientation and display appropriate icon.
+ */
+ currentOrientationIndex =
layoutNames.indexOf(VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING.getValue());
+ newIndx = currentOrientationIndex+1;
+ if (newIndx == layoutNames.size()) {
+ newIndx = newIndx % layoutNames.size();
+ }
+ newOrientation = layoutNames.get(newIndx);
+ rotateEditorsItem.setImage(ImageDescriptor
+ .createFromFile(MozillaEditor.class,
layoutIcons.get(newOrientation)).createImage());
+ rotateEditorsItem.setToolTipText(newOrientation);
+ } catch (XModelException e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ }
+ });
+
verBar.pack();
//Create a composite to the Editor
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-04-24
17:14:46 UTC (rev 14918)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java 2009-04-25
11:29:26 UTC (rev 14919)
@@ -46,8 +46,10 @@
public class CustomSashForm extends SashForm {
public static final String copyright = "(c) Copyright IBM Corporation 2002.";
//$NON-NLS-1$
- public static final String LAYOUT_HORIZONTAL = "Horizontal"; //$NON-NLS-1$
- public static final String LAYOUT_VERTICAL = "Vertical"; //$NON-NLS-1$
+ public static final String LAYOUT_VERTICAL_SOURCE_TOP = "Vertical Source on
top"; //$NON-NLS-1$
+ public static final String LAYOUT_VERTICAL_VISUAL_TOP = "Vertical Visual on
top"; //$NON-NLS-1$
+ public static final String LAYOUT_HORIZONTAL_SOURCE_LEFT = "Horizontal Source to
the left"; //$NON-NLS-1$
+ public static final String LAYOUT_HORIZONTAL_VISUAL_LEFT = "Horizontal Visual to
the left"; //$NON-NLS-1$
/**
* Custom style bits. They set whether max to one side of the other
* is not permitted. For example, if NO_MAX_UP, then there will be only
@@ -112,11 +114,6 @@
WIDTH_INDEX = 4,
HEIGHT_INDEX = 5;
- /*
- * Stores current sash orientation
- */
- private String sashOrientation = Constants.EMPTY;
-
/**
* Constructor for CustomSashForm.
* @param parent
@@ -942,24 +939,22 @@
public void removeWeightsChangeListener(PropertyChangeListener listener) {
listeners.removePropertyChangeListener(listener);
}
-
- public String getSashOrientation() {
- return sashOrientation;
+
+ public void changeOrientation() {
+ int prefsOrientation = getSplittingFromPreferences();
+ if (getOrientation() != prefsOrientation) {
+ setOrientation(prefsOrientation);
+ }
}
-
- public void setSashOrientation(String sashOrientation) {
- this.sashOrientation = sashOrientation;
- }
- public boolean changeOrientation() {
- String orientation = VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING.getValue();
- if (!getSashOrientation().equalsIgnoreCase(orientation)) {
- setOrientation(CustomSashForm.LAYOUT_HORIZONTAL
- .equalsIgnoreCase(orientation) ? SWT.HORIZONTAL : SWT.VERTICAL);
- setSashOrientation(orientation);
- return true;
+ public static int getSplittingFromPreferences() {
+ String splitting = VpePreference.VISUAL_SOURCE_EDITORS_SPLITTING.getValue();
+ if (LAYOUT_HORIZONTAL_SOURCE_LEFT.equalsIgnoreCase(splitting)
+ || LAYOUT_HORIZONTAL_VISUAL_LEFT.equalsIgnoreCase(splitting)) {
+ return SWT.HORIZONTAL;
+ } else {
+ return SWT.VERTICAL;
}
- return false;
}
}