tags:

views:

138

answers:

2

Hello StackOverflow Experts

Description

I have an SWT Page with a TabFolder with a number of dynamically created TabItems.

On each TabItem i crate a Composite and set the TabItem.setControl() to the Composite. I then use this Composite as the page on which i draw my items. I draw a set of Controls, including Textbox's and Labels.

For the First, Default Tab, this works fine. No problems.

Problem

On tabs that is not the first tab i have the following problems:

  • I am unable to visually alter then Edited/Enabled state of my Controls.
  • I am unable to visually set the Text content of my elements

My Controls look disabled and have a Greyed out look.

But i am able to Select the content with my mouse and use CTRL+C to copy it out. So the text contet is there and they are Editable.

Visually it is just not updated.

Any comments are appeciated, Any requests for code, examples will be supplied and help Welcommed.

Updates

I tried added the suggest debug loop to the code, where i attempt to enable my Controls. This was the result:

[main] INFO [dk.viking.controller.LayerController] - f038.stklok is now Editable [true] and enabled [true]

[main] INFO [dk.viking.controller.LayerController] - true Text {}

[main] INFO [dk.viking.controller.LayerController] - true Composite {}

[main] INFO [dk.viking.controller.LayerController] - true TabFolder {}

[main] INFO [dk.viking.controller.LayerController] - true Shell {Viking GUI}

+1  A: 

My guess is that the TabItem itself is disabled. I suggest to add a loop in some place of your code which takes a text control and prints it's enable state and then continues with the parent composite and does the same:

 Control c = text;
 while (c != null) {
      System.out.println(c.getEnabled()+" "+c);
      c = c.getParent();
 }

This should give you an idea if this is the cause of your problem. If not, then set a breakpoint in Text.setEditable() and check who calls it.

[EDIT] If the text is editable but not visible (i.e. gray on gray), check what getBackground () and getForeground () return. Maybe someone set both to the same color.

Aaron Digulla
My problem is that i think my Controls are indeed Editable.I just dont think the UI is showing this fact.I can Mark the content with my mouse and Copy it with CTRL+C, but while doing this, the Control always looks disabled and never shows the content, the mouse or the marking.Its simply, greyed out.
JesperGJensen
This behavior is the default when you set Editable to false (copy works, but you can't edit the text). Check who calls `setEditable()`.
Aaron Digulla
I only have 1 call to setEditable(true); in my code.But it's not a problem of the content being un-editable.The content is not visible. I only see grey background inside the TextBox. There is no text. The greyed out look stays no matter what i do in my code.
JesperGJensen
Ah. Check the result of `getBackground ()` and `getForeground ()`. Maybe someone set both to the same color.
Aaron Digulla
A: 

I have found the problem.

The problem was that the Code to populate the TabItem's Composite with Controls was being called Twice.

So all Controls were duplikated and our Controller only had active references to half of the actually Controls.

Im unable to accurately explain the Drawing behavier we saw, but removing one of these calls, caused the problem to go away.

I hope my problems can one day help someone else.

JesperGJensen