I am trying to create some content for tabItems. I created methods to create each tab. For example:
private static void initSolutionsTab (TabFolder folder){
TabItem solutions = new TabItem(folder, SWT.NONE);
solutions.setText("Solutions");
Composite solutionTop = new Composite(folder, SWT.NONE);
ScrolledComposite topScroller = new ScrolledComposite(solutionTop, SWT.V_SCROLL);
//Should later hold many groups
Composite groupHolder = new Composite(topScroller,SWT.NONE);
Group solutionsGroup = new Group(groupHolder, SWT.BORDER_DOT);
Label solutionLabel = new Label(solutionsGroup, SWT.NONE);
solutionLabel.setText("TEST");
topScroller.setContent(groupHolder);
solutions.setControl(solutionTop);
}
But it is just showing a blank space in the tab. I am missing (or not understanding) something, I know, but I just don't find the mistake.
Can somebody please give me a hint?
try to use setSize() for your TabFolder
Related
I have a composite, which has 3 UI controls - SWT Group, SWT TabFolder, and a child composite that has a label and a link. In some use-cases the SWT Group is hidden, and I would like that the blank space is not seen instead the composite has to be redrawn and show only the SWT TabFolder and the child composite, without any space.
I'm using composite.layout(true), but still there is blank space of the SWT Group when it is made hidden.
Could someone help me solve this issue
TestComposite extends Composite{
private Label childlabel;
private Group group;
private TabFolder tabFolder;
private Button button;
TestComposite(Compossite parent){
super(parent, SWT.NONE);
setLayout(new GridLayout(1, true));
setFont(parent.getFont());
setBackground(parent.getBackground());
GridDataFactory.fillDefaults().grab(true, true).applyTo(this);
createControl();
}
public void createControl() {
this.group = new Group(this, SWT.SHADOW_IN);
this.group.setSize(this.getDisplay().getActiveShell().getSize());
this.button = new Button(this.group, SWT.PUSH);
GridDataFactory.swtDefaults().applyTo(this.button);
this.tabFolder = new TabFolder(this, SWT.TOP);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(this.tabFolder);
Composite childComposite = new Composite(this, SWT.NONE);
childComposite .setLayout(new GridLayout(2, false));
GridDataFactory.swtDefaults().grab(true, false).align(SWT.LEFT,
SWT.TOP).applyTo(childComposite );
this.childLabel = new Label(childComposite, SWT.NONE);
GridDataFactory.swtDefaults().grab(true, false).applyTo(childlabel);
setInput(abc);
enableVisibilityOfGroup(false);
}
public void enableVisibilityOfGroup(Boolean visible){
this.group.setVisible(visible);
// this shoudl redraw the UI and shown only tabFolder and label in the
// whole wizard page, but there is blank space in place of group
this.layout(true);
}
}
Set GridData on the Group
GridDataFactory.swtDefaults().applyTo(this.group);
Use GridData.exclude to exclude/include the group in the layout:
public void enableVisibilityOfGroup(boolean visible) {
this.group.setVisible(visible);
GridData gridData = (GridData)this.group.getLayoutData();
gridData.exclude = !visible;
this.layout(true);
}
I'm Doing a Eclipse Plug-in which is a Multi-page-FormEditor.
On one Page i want some Data to be presented in Tables and Trees.
I want to split the Page vertical in to half's.
In order to achieve this i wanted to use Groups(Left Group,Right Group).
public class UtilityPage extends FormPage {
public UtilityPage(FormEditor editor, String id, String title) {
super(editor, id, title);
// TODO Auto-generated constructor stub
}
#Override
protected void createFormContent(IManagedForm managedForm) {
ScrolledForm scrolledForm = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
Composite body = scrolledForm.getBody();
GridLayout layout = new GridLayout();
body.setLayout(layout);
layout.makeColumnsEqualWidth = true;
layout.numColumns = 2;
Group leftGroup = new Group(body, SWT.SHADOW_IN);
Group rightGroup = new Group(body, SWT.SHADOW_IN);
leftGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
rightGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
Label testLabel = new Label(rightGroup, SWT.CENTER);
testLabel.setText("<Test>");
Label testLabel2 = new Label(leftGroup, SWT.CENTER);
testLabel2.setText("<Test>");
leftGroup.pack();
rightGroup.pack();
}
}
My Problem is that this results in two Empty Groups without any Content.
https://i.imgur.com/5B7sXqS.png
This has happened to me multiple Times before, but i always worked around it.
But since i got no better idea how to accomplish my desired Layout, im here to ask if you guys have any other ideas. Or if you know what im doing wrong.
Since Group extends Composite you must set a layout on the group.
Something like:
Group leftGroup = new Group(body, SWT.SHADOW_IN);
leftGroup.setLayout(new GridLayout());
Group rightGroup = new Group(body, SWT.SHADOW_IN);
rightGroup.setLayout(new GridLayout());
When using layouts every Composite should have a layout. This includes classes such as Group which extend Composite.
I'm trying to put a ScrolledComposite on my UI with SWT.
but now it only shows blank area or something wrong.
The area to show ScrolledComposite is blank without the code,
"optionCompositeAtLeft.setSize(optionCompositeAtLeft.computeSize(SWT.DEFAULT, SWT.DEFAULT)); "
This is the pic of screenshot.
The optionTab should have the buttons with Scroll....
and with the code, it shows scroll, but too long height and narrow width.
Somehow, the upper is gone, but come back when I extend the size of window with scroll disappearing.
I set the color of background red to make it easier to see for you.
Can anyone help me make "optionCompositeAtLeft" filled in ScrolledComposite?
I want the left area of Option tab to be filled with a red background from "optionCompositeAtLef".
Below is my code.
private BomCloneDialog dialog = null;
private TabFolder tabFolder = null;
private TabItem tabOption = null;
public CreateOptionTab(TabFolder tabFolder, TabItem tabOption) {
this.tabFolder = tabFolder;
this.tabOption = tabOption;
}
public void createOptionTabUI() {
GridData gdWithFillBoth = new GridData(GridData.FILL_BOTH);
Composite optionComposite = new Composite(tabFolder, SWT.NONE);
optionComposite.setLayout(new GridLayout(2, true));
tabOption.setControl(optionComposite);
ScrolledComposite scrolledCompositeForOption = new ScrolledComposite(optionComposite,SWT.V_SCROLL | SWT.BORDER);
scrolledCompositeForOption.setLayoutData(gdWithFillBoth);
Composite optionCompositeAtLeft = new Composite(scrolledCompositeForOption, SWT.BORDER);
scrolledCompositeForOption.setContent(optionCompositeAtLeft);
optionCompositeAtLeft.setLayout(new GridLayout(1, true));
optionCompositeAtLeft.setLayoutData(gdWithFillBoth);
optionCompositeAtLeft.setBackground(new Color(Display.getCurrent(), 255,0,0));
Button b [] = new Button[30];
for(int a=0; a<30; a++){
b[a] = new Button(optionCompositeAtLeft, SWT.PUSH);
b[a].setText("button"+a);
}
**optionCompositeAtLeft.setSize(optionCompositeAtLeft.computeSize(SWT.DEFAULT, SWT.DEFAULT));**
Composite optionButtonComposite = new Composite(optionComposite, SWT.BORDER);
optionButtonComposite.setLayout(new GridLayout(1, true));
optionButtonComposite.setLayoutData(gdWithFillBoth);
Button optionSaveButton = new Button(optionButtonComposite, SWT.NONE);
optionSaveButton.setLayoutData(gdWithFillBoth);
optionSaveButton.setText("Save");
Button optionAddButton = new Button(optionButtonComposite, SWT.NONE);
optionAddButton.setLayoutData(gdWithFillBoth);
optionAddButton.setText("Add");
}
You need to configure ScrolledComposite to resize the content:
scrolledCompositeForOption.setExpandHorizontal(true);
scrolledCompositeForOption.setExpandVertical(true);
I need your help... I attached an image, I want that the right grid appears at the bottom, below of Estadisticas1, Estadisticas2, Estadisticas3, Estadisticas4
I tried a lot of ways, with GridData, FormLayout and no way!
Also, I tried with setSize and setBounds and in no cases the size or position change, I donĀ“t know why!
There are many ways to do this depending on exactly what you want which you haven't really specified. For example:
public void createPartControl(final Composite parent)
{
Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new FillLayout(SWT.VERTICAL));
Composite topArea = new Composite(body, SWT.BORDER);
// TODO add your 'EstadisticasX' controls to 'topArea'
Composite bottomArea = new Composite(body, SWT.BORDER);
// TODO add bottom grid to 'bottomArea'
}
I am trying to embed a JFace TableViewer in a SWT TabFolder, but when I do so, the table does not show up. The current (working code) in my GitToDo code looks like (see this Git repos):
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Git ToDo");
FillLayout layout = new FillLayout();
shell.setLayout(layout);
final GitToDoTree tableViewer = new GitToDoTree(shell);
Where the latter GitToDoTree extends TableViewer, with this constructor:
super(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.FILL);
this.shell = parent;
table = this.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
So, when I construct the TableViewer-extending GitToDoTree from a Shell it works, but as soon as I try to build it from a TabFolder or (tried that too) a Composite, nothing shows up anymore.
How can I get my TableViewer to show up in the TabFolder?
If your TableViewer class isn't showing up when you add it to a Composite I would say that chances are that you are not setting a layout for the nested Composite.
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Git ToDo");
FillLayout layout = new FillLayout();
shell.setLayout(layout);
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new FillLayout()); // Possible missing layout?
final GitToDoTree tableViewer = new GitToDoTree(composite);
And as for the TabFolder that may be that you are not setting the client control on the TabItem
TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText("Table");
GitToDoTree viewer = new GitToDoTree(tabFolder);
item.setControl(viewer.getTable()); // Possible setControl call?
TabItem item2= new TabItem(tabFolder, SWT.NONE);
item2.setText("Empty");