Problems when updating title of dockable

How can the title of a dockable be updated? (e.g. when switching the application language from German to English)

We iterate through the component tree and then use DefaultCDockable.setTitleText(String) to update the title of a dockable.

To find out which components are dockables we used the following code in dockingFrames 1.0.7:


if (component instanceof RexTabbedComponent) {
    for (int i= 0; i < ((RexTabbedComponent) component).getTabCount(); i++) {
        Dockable dock= ((RexTabbedComponent) component).getTabAt(i);
        if (dock instanceof CommonDockable) {
            CDockable cdock= ((CommonDockable) dock).getDockable();
            if (cdock instanceof DefaultCDockable) {
                ((DefaultCDockable) cdock).setTitleText(getTitle());
                System.out.println(cdock.intern().getTitleText());
            }
        }
    }
}

With that code everything worked fine.
Now we updated to dockingFrames 1.0.8 and now the updating of the dockable title seems not to work anymore.

We are using the following code to find out which components are dockables:


if (component instanceof BaseTabComponent) {
    final Dockable dock= ((BaseTabComponent) component).getDockable();
    if (dock instanceof CommonDockable) {
        final CDockable cdock= ((CommonDockable) dock).getDockable();
        if (cdock instanceof DefaultCDockable) {
            ((DefaultCDockable) cdock).setTitleText(getTitle());
            System.out.println(cdock.intern().getTitleText());
        }
    }
}

According to the system.out.println output cdock has the correct (updated) title text set, but it is not visible in the application.

I also wrote a simple test application to check if DefaultCDockable.setTitleText(String) is the correct method to use. In the class src/commonsLayouts/bibliothek.layouts.Core.java of the dockingFrames sources I added the following lines after line 153 (frame.setBounds( 20, 20, 600, 400 ) :


control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);
JButton updateTitleButton= new JButton("Update Title");
updateTitleButton.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed (ActionEvent e) {
        environment.setTitleText(environment.getTitleText() + "E");
        storage.setTitleText(storage.getTitleText() + "S");
    }
});

JButton updateAllButton= new JButton("Update All"); 
updateAllButton.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed (ActionEvent e) {
        for (Component comp : frame.getContentPane().getComponents()) {
            if (comp instanceof JComponent) {
                updateComponents((JComponent) comp);
            }
        }
    }
});

final JPanel buttonPanel= new JPanel();
buttonPanel.add(updateTitleButton, BorderLayout.PAGE_START);
buttonPanel.add(updateAllButton, BorderLayout.PAGE_END);
frame.add(buttonPanel, BorderLayout.SOUTH);

The method updateComponents is


private static void updateComponents (JComponent component) {
    for (Component comp : ((JComponent) component).getComponents()) {
//            System.out.println("updateComponents " + component.getClass());
        if (component instanceof BaseTabComponent) {
            final Dockable dock= ((BaseTabComponent) component).getDockable();
            if (dock instanceof CommonDockable) {
                final CDockable cdock= ((CommonDockable) dock).getDockable();
                if (cdock instanceof DefaultCDockable) {
                    ((DefaultCDockable) cdock).setTitleText(cdock.intern().getTitleText() + "T");
                }
                System.out.println(cdock.intern().getTitleText());
            }
        }

        if (comp instanceof JComponent) {
            updateComponents((JComponent) comp);
        }
    }
}

In the demo code everything works fine. But in my application the debugging output is correct but the title in the GUI does not change.

Have you any idea why the title of the dockable is not updated (or respectively the update is not visible) when I use the above code to traverse the component tree and update the title of all dockables?

Thanks in adavance

You are using the EclipseTheme? There is a bug in it which I did not yet repair… but I soon will.

Btw: CControl offers a method „getRegister“, it returns an object that offers a lot of methods including one that returns all CDockables in the system. :wink:

oh … ok :wink:

Hi Beni,
i also fell over this bug. Can you please tell me any workaround until this bug is fixed?
Thanks in advance, -chris-

Download the newest version from the repository, using name=anonymous, pw=anon. Then you have the fixed version. Compiling the project should not be a problem, it’s just a bunch of Eclipse-Projects without the need of any additional tools.

Thanks very much, it works.
Greetings, -chris-