Author: dmaliarevich
Date: 2009-06-18 11:01:29 -0400 (Thu, 18 Jun 2009)
New Revision: 16044
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
Log:
https://jira.jboss.org/jira/browse/JBIDE-4429, toolbar was moved to the fixed vertical
left position.
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-06-18
14:57:06 UTC (rev 16043)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2009-06-18
15:01:29 UTC (rev 16044)
@@ -13,12 +13,14 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.eclipse.compare.Splitter;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.action.IAction;
@@ -44,6 +46,7 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -121,8 +124,15 @@
/** default web-browser */
private MozillaPreview previewWebBrowser = null;
- /** preview content */
+ /*
+ * VPE visual components.
+ */
+ private Composite sourceContent = null;
+ private Composite visualContent = null;
private Composite previewContent = null;
+ private Splitter verticalToolbarSplitter = null;
+ private Composite verticalToolbarEmpty = null;
+ private ToolBar toolBar = null;
public StructuredTextEditor getSourceEditor() {
return sourceEditor;
@@ -362,13 +372,11 @@
}
}
- Composite sourceContent = null;
- Composite visualContent = null;
-
public void setVisualMode(int type) {
switch (type) {
case VISUALSOURCE_MODE:
selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
+ setVerticalToolbarVisible(true);
/*
* Fixes
https://jira.jboss.org/jira/browse/JBIDE-3140
* author Denis Maliarevich.
@@ -396,6 +404,7 @@
case SOURCE_MODE:
selectionBar.setVisible(selectionBar.getAlwaysVisibleOption());
+ setVerticalToolbarVisible(false);
if (sourceContent != null) {
sourceContent.setVisible(true);
/*
@@ -427,6 +436,7 @@
if (selectionBar != null) {
selectionBar.setVisible(false);
}
+ setVerticalToolbarVisible(false);
/*
* Fixes
https://jira.jboss.org/jira/browse/JBIDE-3140
* author Denis Maliarevich.
@@ -462,17 +472,39 @@
public int getVisualMode() {
return visualMode;
}
-
+
+ /**
+ * Sets the visibility of the vertical toolbar for visual editor part.
+ *
+ * @param visible if visible
+ */
+ public void setVerticalToolbarVisible(boolean visible) {
+ if ((null == verticalToolbarSplitter) || (null == verticalToolbarEmpty)
+ || (null == toolBar)) {
+ return;
+ }
+ if (visible) {
+ verticalToolbarSplitter.setVisible(toolBar, true);
+ verticalToolbarSplitter.setVisible(verticalToolbarEmpty, false);
+ } else {
+ verticalToolbarSplitter.setVisible(toolBar, false);
+ verticalToolbarSplitter.setVisible(verticalToolbarEmpty, true);
+ }
+ verticalToolbarSplitter.getParent().layout(true, true);
+ }
+
public void createPartControl(final Composite parent) {
+
controlCount++;
if (controlCount > 1)
return;
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
IVpeHelpContextIds.VISUAL_PAGE_EDITOR);
- // //////////////////////////////////////////////////////////////
-
+ /*
+ * Container composite for editor part
+ */
Composite cmpEdTl = new Composite(parent, SWT.NONE);
- GridLayout layoutEdTl = new GridLayout(1, false);
+ GridLayout layoutEdTl = new GridLayout(2, false);
layoutEdTl.verticalSpacing = 0;
layoutEdTl.marginHeight = 0;
layoutEdTl.marginBottom = 3;
@@ -480,7 +512,36 @@
cmpEdTl.setLayout(layoutEdTl);
cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
- cmpEd = new Composite(cmpEdTl, SWT.NATIVE);
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-4429
+ * Composite for the left vertical toolbar
+ */
+ verticalToolbarSplitter = new Splitter(cmpEdTl, SWT.NONE);
+ GridLayout layout = new GridLayout(1,false);
+ layout.marginHeight = 2;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 0;
+ layout.horizontalSpacing = 0;
+ verticalToolbarSplitter.setLayout(layout);
+ verticalToolbarSplitter.setLayoutData(new GridData(SWT.CENTER, SWT.TOP | SWT.FILL,
false, true, 1, 2));
+
+ /*
+ * The empty vertical toolbar component
+ */
+ verticalToolbarEmpty = new Composite(verticalToolbarSplitter, SWT.NONE) {
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ Point point = super.computeSize(wHint, hHint, changed);
+ point.x = 1;
+ return point;
+ }
+ };
+ verticalToolbarEmpty.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ verticalToolbarEmpty.setVisible(true);
+
+ /*
+ * The Visual Page Editor itself
+ */
+ cmpEd = new Composite(cmpEdTl, SWT.BORDER);
GridLayout layoutEd = new GridLayout(1, false);
layoutEd.marginBottom = 0;
layoutEd.marginHeight = 1;
@@ -490,8 +551,13 @@
layoutEd.verticalSpacing = 0;
layoutEd.horizontalSpacing = 0;
cmpEd.setLayout(layoutEd);
- cmpEd.setLayoutData(new GridData(GridData.FILL_BOTH));
- // /////////////////////////////////////////////////////////////////
+ cmpEd.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+ /*
+ * Creating selection bar at the bottom of the editor
+ */
+ selectionBar.createToolBarComposite(cmpEdTl, true);
+
//container = new SashForm(cmpEd, SWT.VERTICAL);
/*
*
https://jira.jboss.org/jira/browse/JBIDE-4152
@@ -525,10 +591,6 @@
//previewContent.setLayout(new FillLayout());
previewContent.setLayout(new GridLayout());
- // ////////////////////////////////////////////////////
-
- selectionBar.createToolBarComposite(cmpEdTl, true);
- // ///////////////////////////////////////////////////
if (sourceEditor == null)
sourceEditor = new StructuredTextEditor() {
public void safelySanityCheckState(IEditorInput input) {
@@ -869,9 +931,10 @@
createShowSelectionBarMenuItem();
visualEditor.getController().init(sourceEditor, visualEditor);
}
-
});
- visualEditor.createPartControl(visualContent);
+
+ toolBar = visualEditor.createVisualToolbar(verticalToolbarSplitter);
+ visualEditor.createPartControl(visualContent);
}
/**
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-06-18
14:57:06 UTC (rev 16043)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2009-06-18
15:01:29 UTC (rev 16044)
@@ -153,6 +153,7 @@
*/
private nsIEditor editor;
private VpeDropDownMenu dropDownMenu = null;
+ private ToolBar verBar = null;
public void doSave(IProgressMonitor monitor) {
}
@@ -184,106 +185,11 @@
formatControllerManager.setVpeController(controller);
controller.setToolbarFormatControllerManager(formatControllerManager);
}
- /*
- * (non-Javadoc)
- * @see
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createPartControl(final Composite parent) {
-
- //Setting Layout for the parent Composite
- parent.setLayout(new FillLayout());
-
- /*
- *
https://jira.jboss.org/jira/browse/JBIDE-4062
- * Creating scrollable eclipse element.
- */
- ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL |
SWT.BORDER);
- sc.setLayout(new FillLayout());
- Composite composite = new Composite(sc, SWT.NATIVE);
-
- GridLayout layout = new GridLayout(2,false);
- layout.marginHeight = 0;
- layout.marginWidth = 2;
- layout.verticalSpacing = 2;
- layout.horizontalSpacing = 2;
- layout.marginBottom = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // Composite for the left Vertical toolbar
- Composite cmpVerticalToolbar = new Composite(composite, SWT.NONE);
- layout = new GridLayout(1,false);
- layout.marginHeight = 2;
- layout.marginWidth = 0;
- layout.verticalSpacing = 0;
- cmpVerticalToolbar.setLayout(layout);
- cmpVerticalToolbar.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
-
- // Editors and Toolbar composite
- Composite cmpEdTl = new Composite(composite, SWT.NONE);
- GridLayout layoutEdTl = new GridLayout(1, false);
- layoutEdTl.verticalSpacing = 0;
- layoutEdTl.marginHeight = 0;
- layoutEdTl.marginBottom = 3;
- layoutEdTl.marginWidth = 0;
- cmpEdTl.setLayout(layoutEdTl);
- cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-
- ToolBar verBar = new ToolBar(cmpVerticalToolbar, SWT.VERTICAL|SWT.FLAT);
+
+ public ToolBar createVisualToolbar(Composite parent) {
+ verBar = new ToolBar(parent, SWT.VERTICAL|SWT.FLAT);
verBar.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- dropDownMenu = new VpeDropDownMenu(verBar, VpeUIMessages.MENU);
-
- // Use vpeToolBarManager to create a horizontal toolbar.
- vpeToolBarManager = new VpeToolBarManager(dropDownMenu
- .getDropDownMenu());
- if (vpeToolBarManager != null) {
- vpeToolBarManager.createToolBarComposite(cmpEdTl);
- vpeToolBarManager.addToolBar(new TextFormattingToolBar(
- formatControllerManager));
- }
-
- // add Invisible tags support to menu
-
- // create menu item
- MenuItem menuItem = new MenuItem(dropDownMenu.getDropDownMenu(),
- SWT.PUSH);
-
- // get default value of flag
- boolean showInvisibleTags = Constants.YES_STRING
- .equals(VpePreference.SHOW_INVISIBLE_TAGS.getValue());
-
- // set text
- menuItem.setText(showInvisibleTags ? VpeUIMessages.HIDE_NON_VISUAL_TAGS
- : VpeUIMessages.SHOW_NON_VISUAL_TAGS);
-
- // add listener
- menuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- MenuItem selectedItem = (MenuItem) e.widget;
-
- // get current value of flag
- boolean showInvisibleTags = !controller.getVisualBuilder()
- .isShowInvisibleTags();
-
- // change text
- selectedItem
- .setText((showInvisibleTags ? VpeUIMessages.HIDE
- : VpeUIMessages.SHOW)
- + Constants.WHITE_SPACE
- + VpeUIMessages.NON_VISUAL_TAGS);
-
- // change flag
- controller.getVisualBuilder().setShowInvisibleTags(
- showInvisibleTags);
- // update vpe
- controller.visualRefresh();
- }
- });
-
ToolItem item = null;
item = createToolItem(verBar, SWT.BUTTON1, ICON_PREFERENCE,
ICON_PREFERENCE_DISABLED, VpeUIMessages.PREFERENCES, true);
@@ -385,7 +291,100 @@
});
verBar.pack();
+ return verBar;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createPartControl(final Composite parent) {
+ //Setting Layout for the parent Composite
+ parent.setLayout(new FillLayout());
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-4062
+ * Creating scrollable eclipse element.
+ */
+ ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL |
SWT.BORDER);
+ sc.setLayout(new FillLayout());
+ Composite composite = new Composite(sc, SWT.NATIVE);
+
+ GridLayout layout = new GridLayout(2,false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 2;
+ layout.verticalSpacing = 2;
+ layout.horizontalSpacing = 2;
+ layout.marginBottom = 0;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+
+ // Editors and Toolbar composite
+ Composite cmpEdTl = new Composite(composite, SWT.NONE);
+ GridLayout layoutEdTl = new GridLayout(1, false);
+ layoutEdTl.verticalSpacing = 0;
+ layoutEdTl.marginHeight = 0;
+ layoutEdTl.marginBottom = 3;
+ layoutEdTl.marginWidth = 0;
+ cmpEdTl.setLayout(layoutEdTl);
+ cmpEdTl.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-4429
+ * Toolbar was moved to VpeEditorPart.
+ * 'verBar' should be created in createVisualToolbar(..) in VpeEditorPart
+ * and only after that MozillaEditor should be created itself.
+ */
+ if (null != verBar) {
+ dropDownMenu = new VpeDropDownMenu(verBar, VpeUIMessages.MENU);
+ // add Invisible tags support to menu
+ // create menu item
+ MenuItem menuItem = new MenuItem(dropDownMenu.getDropDownMenu(), SWT.PUSH);
+ // get default value of flag
+ boolean showInvisibleTags = Constants.YES_STRING
+ .equals(VpePreference.SHOW_INVISIBLE_TAGS.getValue());
+
+ // set text
+ menuItem.setText(showInvisibleTags ? VpeUIMessages.HIDE_NON_VISUAL_TAGS
+ : VpeUIMessages.SHOW_NON_VISUAL_TAGS);
+
+ // add listener
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MenuItem selectedItem = (MenuItem) e.widget;
+
+ // get current value of flag
+ boolean showInvisibleTags = !controller.getVisualBuilder()
+ .isShowInvisibleTags();
+
+ // change text
+ selectedItem
+ .setText((showInvisibleTags ? VpeUIMessages.HIDE
+ : VpeUIMessages.SHOW)
+ + Constants.WHITE_SPACE
+ + VpeUIMessages.NON_VISUAL_TAGS);
+
+ // change flag
+ controller.getVisualBuilder().setShowInvisibleTags(
+ showInvisibleTags);
+ // update vpe
+ controller.visualRefresh();
+ }
+ });
+ // Use vpeToolBarManager to create a horizontal toolbar.
+ vpeToolBarManager = new VpeToolBarManager(dropDownMenu
+ .getDropDownMenu());
+ if (vpeToolBarManager != null) {
+ vpeToolBarManager.createToolBarComposite(cmpEdTl);
+ vpeToolBarManager.addToolBar(new TextFormattingToolBar(formatControllerManager));
+ }
+ }
+
+
+
//Create a composite to the Editor
Composite cmpEd = new Composite (cmpEdTl, SWT.NATIVE);
GridLayout layoutEd = new GridLayout(1, false);