diff options
author | ncazottes | 2018-04-08 20:37:58 +0000 |
---|---|---|
committer | Leo Ufimtsev | 2018-04-13 20:09:48 +0000 |
commit | 624fe0d237e0e92c9ffdc3054ab74ad1325da881 (patch) | |
tree | c27c6841fb31b23bc24f86b4331df82991cc052a /bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt | |
parent | f894bab36d1d8d6bf87a55af6e74c42eb00fb145 (diff) | |
download | eclipse.platform.swt-624fe0d237e0e92c9ffdc3054ab74ad1325da881.tar.gz eclipse.platform.swt-624fe0d237e0e92c9ffdc3054ab74ad1325da881.tar.xz eclipse.platform.swt-624fe0d237e0e92c9ffdc3054ab74ad1325da881.zip |
Bug 533124 - Allow multi line text in CTabFolder.I20180413-2000
CTabFolderRenderer with flag that take into account carriage return for multi line.
Addition of Snippet371.
Addition of Javadoc on CTabItem.setText.
Addition of same cross platform behavior relating to the drop-down menu for additional tabs.
Change-Id: Ib45891dcc90727830262887745c8ec1ad9be451d
Signed-off-by: ncazottes <nicolas@cazottes.net>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt')
3 files changed, 14 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java index f2f875a314..3c3d6ce74c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java @@ -3674,7 +3674,8 @@ void showList (Rectangle rect) { CTabItem tab = items[i]; if (tab.showing) continue; MenuItem item = new MenuItem(showMenu, SWT.NONE); - item.setText(tab.getText()); + // Bug 533124 In the case where you have multi line tab text, we force the drop-down menu to have single line entries to ensure consistent behavior across platforms. + item.setText(tab.getText().replace("\n", " ")); item.setImage(tab.getImage()); item.setData(id, tab); item.addSelectionListener(new SelectionAdapter() { diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java index 9d9bc6f608..9a966a435d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java @@ -93,7 +93,7 @@ public class CTabFolderRenderer { static final int ITEM_LEFT_MARGIN = 4; static final int ITEM_RIGHT_MARGIN = 4; static final int INTERNAL_SPACING = 4; - static final int FLAGS = SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC; + static final int FLAGS = SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC | SWT.DRAW_DELIMITER; static final String ELLIPSIS = "..."; //$NON-NLS-1$ //Part constants diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java index 20dc1aa0e1..5b30686160 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java @@ -398,6 +398,17 @@ public void setShowClose(boolean close) { showClose = close; parent.updateFolder(CTabFolder.REDRAW_TABS); } +/** + * Sets the text to display on the tab. + * A carriage return '\n' allows to display multi line text. + * + * @param string the tab name + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ @Override public void setText (String string) { checkWidget(); |