I create a subclass of DefaultDialogDockableBarHolder to create a modal dialog.
In this modal dialog I have a problem: tha layout is not saved, because when I try to save the layout the variable _loadingLayoutData of the class AbstractLayoutPersistence has the true value (because the loading is never ended in the modal dialog I think).
I have writed a wrong code, or the problem is elsewere?
The code to reproduce the problem is
- Code: Select all
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.jidesoft.action.*;
import com.jidesoft.swing.*;
public class DockableBarBug extends DefaultDialogDockableBarHolder {
private static final String PROFILE_NAME = "ppppprofile";
public DockableBarBug(Frame parent) {
super(parent);
getLayoutPersistence().setProfileKey(PROFILE_NAME);
DockableBarManager dbm = this.getDockableBarManager();
dbm.setProfileKey(PROFILE_NAME);
getLayoutPersistence().beginLoadLayoutData();
dbm.addDockableBar(createCommandBar());
((ContentContainer)getContentPane().getComponent(0)).add(new JTextArea("test test test\ntest test test\ntest test"));
setLocationRelativeTo(parent);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
//save the last used layout on closing
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
getLayoutPersistence().saveLayoutData();
}
});
setModal(true);
pack();
JideSwingUtilities.globalCenterWindow(this);
getLayoutPersistence().loadLayoutData();
}
private CommandBar createCommandBar() {
CommandBar argr = new CommandBar();
argr.setInitSide(DockableBarContext.DOCK_SIDE_NORTH);
argr.setInitMode(DockableBarContext.STATE_HORI_DOCKED);
argr.setInitIndex(1);
argr.setFloatable(true);
JideButton bt = new JideButton("b1");
argr.add(bt);
bt = new JideButton("b2");
argr.add(bt);
argr.addSeparator();
bt = new JideButton("b3");
argr.add(bt);
bt = new JideButton("b4");
argr.add(bt);
return argr;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
final JFrame f = new JFrame("test");
JButton b = new JButton("show dialog");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
new DockableBarBug(f);
}
});
}
});
f.getContentPane().setLayout(new FlowLayout());
f.getContentPane().add(b);
f.pack();
JideSwingUtilities.globalCenterWindow(f);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
});
}
}