Author: yradtsevich
Date: 2009-09-18 09:27:39 -0400 (Fri, 18 Sep 2009)
New Revision: 17661
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java
Log:
RESOLVED - issue JBIDE-4735: Set items in expanded formatting tool bar into Vertical
position.
https://jira.jboss.org/jira/browse/JBIDE-4735
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java 2009-09-18
12:42:33 UTC (rev 17660)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java 2009-09-18
13:27:39 UTC (rev 17661)
@@ -22,9 +22,9 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -97,8 +97,9 @@
* bounds, then it is partially hidden, and all
* remaining tools are completely hidden.
*/
- if (!intersection.equals(toolBounds))
+ if (!intersection.equals(toolBounds)) {
break;
+ }
i++;
}
@@ -108,24 +109,48 @@
*/
final Shell floatingShell = new Shell(coolBar.getShell(),
SWT.ON_TOP);
- floatingShell.setLayout(new GridLayout());
- final ToolBar floatingBar = new ToolBar(floatingShell,
- SWT.FLAT | SWT.WRAP);
+ FillLayout shellLayout = new FillLayout(SWT.VERTICAL);
+ shellLayout.marginHeight = 5;
+ shellLayout.marginWidth = 5;
+ shellLayout.spacing = 5;
+
+ floatingShell.setLayout(shellLayout);
SelectionListener selectionListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
floatingShell.dispose();
}
};
+
+ ToolBar floatingBar = null;
for (int j = i; j < tools.length; j++) {
- cloneToolItem(floatingBar, tools[j], selectionListener);
+ ToolItem tool = tools[j];
+ int style = tool.getStyle();
+
+ if ((style & SWT.SEPARATOR) != 0) {
+ Control control = tool.getControl();
+ if (control instanceof Combo) {
+ cloneCombo(floatingShell, selectionListener,
+ (Combo) control);
+ }
+ } else {
+ if (floatingBar == null) {
+ floatingBar = new ToolBar(floatingShell,
+ SWT.FLAT | SWT.WRAP);
+ }
+ cloneItem(floatingBar, tool, selectionListener);
+ }
}
+// Point size = floatingBar.computeSize (300, SWT.DEFAULT);
+// System.out.println(size);
+// floatingBar.setSize (size);
+// floatingBar.pack();
+ floatingShell.pack();
/*
* Drop down the menu below the chevron, with the left edges
* aligned.
*/
pt = coolBar.toDisplay(new Point(event.x, event.y));
- floatingShell.pack();
arrange(floatingShell, pt);
floatingShell.setVisible(true);
floatingShell.setFocus();
@@ -235,31 +260,30 @@
* Creates a copy of {@code item} in the {@code destBar} and
* adds given {@code selectionListener} to the created control.
*/
- protected void cloneToolItem(ToolBar destBar, ToolItem item,
+ protected void cloneItem(ToolBar destBar, ToolItem item,
SelectionListener selectionListener) {
- int style = item.getStyle();
+ ToolItem copiedItem = createToolItem(destBar, item.getStyle(),
+ item.getImage(), item.getToolTipText());
+ copiedItem.setEnabled(item.getEnabled());
+ copiedItem.setSelection(item.getSelection());
+ copySelectionListeners(item, copiedItem);
+ copiedItem.addSelectionListener(selectionListener);
+ }
- if ((style & SWT.SEPARATOR) != 0) {
- Control control = item.getControl();
- if (control instanceof Combo) {
- Combo combo = (Combo) control;
- Combo copiedCombo = createComboToolItem(destBar, combo.getStyle(),
- combo.getToolTipText(),
- Arrays.asList(combo.getItems()),
- combo.getSelectionIndex());
- copiedCombo.setEnabled(combo.getEnabled());
- copiedCombo.setVisible(combo.getVisible());
- copySelectionListeners(combo, copiedCombo);
- copiedCombo.addSelectionListener(selectionListener);
- }
- } else {
- ToolItem copiedItem = createToolItem(destBar, item.getStyle(),
- item.getImage(), item.getToolTipText());
- copiedItem.setEnabled(item.getEnabled());
- copiedItem.setSelection(item.getSelection());
- copySelectionListeners(item, copiedItem);
- copiedItem.addSelectionListener(selectionListener);
- }
+ /**
+ * Creates a copy of {@code combo} in the {@code parent} and
+ * adds given {@code selectionListener} to the created control.
+ */
+ protected void cloneCombo(Composite parent,
+ SelectionListener selectionListener, Combo combo) {
+ Combo copiedCombo = createCombo(parent, combo.getStyle(),
+ combo.getToolTipText(),
+ Arrays.asList(combo.getItems()),
+ combo.getSelectionIndex());
+ copiedCombo.setEnabled(combo.getEnabled());
+ copiedCombo.setVisible(combo.getVisible());
+ copySelectionListeners(combo, copiedCombo);
+ copiedCombo.addSelectionListener(selectionListener);
}
/**
@@ -292,21 +316,22 @@
*/
protected Combo createComboToolItem(ToolBar bar, int style,
String toolTipText, List<String> comboItems, int selectionIndex) {
- Combo combo = createCombo(bar, style, comboItems);
+ Combo combo = createCombo(bar, style,
+ toolTipText, comboItems, selectionIndex);
ToolItem sep = new ToolItem(bar, SWT.SEPARATOR);
sep.setWidth(combo.getSize().x);
- combo.setToolTipText(toolTipText);
- combo.select(selectionIndex);
sep.setControl(combo);
return combo;
}
protected Combo createCombo(Composite parent, int style,
- List<String> comboItems) {
+ String toolTipText, List<String> comboItems, int selectionIndex) {
Combo combo = new Combo(parent, style);
- combo.setLayoutData(new RowData());
+// combo.setLayoutData(new RowData());
combo.setItems(comboItems.toArray(new String[comboItems.size()]));
+ combo.setToolTipText(toolTipText);
+ combo.select(selectionIndex);
combo.pack();
return combo;
}
@@ -343,3 +368,4 @@
return result;
}
}
+
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java 2009-09-18
12:42:33 UTC (rev 17660)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java 2009-09-18
13:27:39 UTC (rev 17661)
@@ -41,7 +41,10 @@
*/
public class TextFormattingToolBar extends SplitToolBar {
- private static final String NORMAL_FONT = "Normal"; //$NON-NLS-1$
+ private static final String NORMAL_BLOCK_FORMAT
+ = "- Block Format -"; //$NON-NLS-1$
+ private static final String NORMAL_FONT = "- Font Name -"; //$NON-NLS-1$
+ private static final String NORMAL_SIZE = "- Font Size -"; //$NON-NLS-1$
private static final String ID = "TEXT_FORMATTING_TOOLBAR"; //$NON-NLS-1$
@@ -92,7 +95,7 @@
emptySeparator.setWidth(1);
List<String> blockFormatItems = new ArrayList<String>();
- blockFormatItems.add("Normal"); //$NON-NLS-1$
+ blockFormatItems.add(NORMAL_BLOCK_FORMAT);
blockFormatItems.add("Address"); //$NON-NLS-1$
// blockFormatItems.add("Numbered List");
// blockFormatItems.add("Bulleted List");
@@ -122,7 +125,7 @@
// itemDescriptors.add(new ToolItemDescriptor(sep, false, null, false));
List<String> fontSizes = new ArrayList<String>();
- fontSizes.add(NORMAL_FONT);
+ fontSizes.add(NORMAL_SIZE);
for (int i = 1; i < 8; i++) {
fontSizes.add(Integer.toString(i)); //$NON-NLS-1$
}