Open fyudanov opened 1 year ago
Just curious, have you checked if that works in CTabFolder?
@iloveeclipse
I tried it with this snippet. CTabFolder works fine.
package org.eclipse.swt.bug;
import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class CTabsIssueSnippet {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Tab Text Resizing Issue Snippet");
final int insetX = 4, insetY = 4;
GridLayout formLayout = new GridLayout();
formLayout.marginWidth = insetX;
formLayout.marginHeight = insetY;
shell.setLayout(formLayout);
CTabFolder folder = new CTabFolder(shell, SWT.BORDER);
for (int i = 0; i < 4; i++) {
CTabItem item = new CTabItem(folder, SWT.CLOSE);
item.setText("Item "+i);
Text text = new Text(folder, SWT.MULTI);
text.setText("Content for Item "+i);
item.setControl(text);
}
final CTabItem specialItem = new CTabItem(folder, SWT.CLOSE);
specialItem.setText("Don't Close Me");
Text text = new Text(folder, SWT.MULTI);
text.setText("This tab can never be closed");
specialItem.setControl(text);
folder.addCTabFolder2Listener(CTabFolder2Listener.closeAdapter(event -> {
if (event.item.equals(specialItem)) {
event.doit = false;
}
}));
final CTabItem noCloseItem = new CTabItem(folder, SWT.NONE);
noCloseItem.setText("No Close Button");
Text text2 = new Text(folder, SWT.MULTI);
text2.setText("This tab does not have a close button");
noCloseItem.setControl(text2);
Button button = new Button(shell, SWT.PUSH);
button.setText("Set long tab name");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
noCloseItem.setText("Loooooooooooooooong");
shell.layout();
shell.redraw();
}
});
}
});
shell.setSize(800, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
This is the output:
Tried on : Eclipse SDK Version: 2023-09 (4.29) Build id: I20230705-1800 OS: Mac OS X, v.13.4.1, aarch64 / cocoa Java vendor: Eclipse Adoptium Java runtime version: 17.0.6+10 Java version: 17.0.6
But Tab is not getting resized.
Hi,
Both TabFolder and CTabFolder works fine on windows. Tried on below environment Eclipse SDK Version: 2023-09 (4.29) Build id: I20230712-1800 OS: Windows 11, v.10.0, x86_64 / win32 Java vendor: Eclipse Adoptium Java runtime version: 20+36 Java version: 20
Works as expected on Linux too
Eclipse SDK Version: 2024-06 (4.32) Build id: I20240327-1800 OS: Ubuntu 20.04 (x86_64) / X11 / GNome 3.36.8 java.version=17.0.7 java.vendor=Amazon.com Inc.
Describe the bug On changing tab title with
tab.setText()
, the tab is not getting resized even aftershell.layout()
orshell.redraw()
call. It's getting resized properly only on explicit dialog resize (manual or pragmatical withshell.setSize()
).This is not happening in case of FormLayout applied to Shell, seems to be only reproducible for GridLayout with GridData.FILL_BOTH on TabFolder..
To Reproduce Snippet:
Expected behavior
shell.layout()
call should resize tab according to it's current title size.Screenshots
Environment
Select the platform(s) on which the behavior is seen:
Additional OS info: MacOS 10.13; 12.6
JRE/JDK version: JDK 20.
Version since Known to be reproducible on SWT 3.120 and SWT 4.28.
Workaround (or) Additional context Explicit window resizing helps.