But the saveLayout seem to not work correctly.
In the example that i will post next I display a DefaultDialogDockableBarDockableHolder and on the menu file i save the layout, but the registry will not be updated, so when i close and reopen the Dialog the layout is not the layout saved.
If I change the DefaultDialogDockableBarDockableHolder with DefaultDockableBarDockableHolder in extends all seem to work correctly (both the save and the load) and if I come back restoring the DefaultDialogDockableBarDockableHolder as superclass, the load operation correctly load the latest layout previously saved.
Where is the problem? I wrote wrong code or there are errors?
The example code is:
- Code: Select all
- import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
 import com.jidesoft.action.*;
 import com.jidesoft.swing.*;
 public class DefaultDialogDockableBarDockableHolderBug extends DefaultDialogDockableBarDockableHolder{
 public DefaultDialogDockableBarDockableHolderBug(Frame parent) {
 super(parent);
 init();
 }
 private void init() {
 setLocationRelativeTo(getParent());
 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 getLayoutPersistence().setProfileKey("bug.test");
 
 getLayoutPersistence().beginLoadLayoutData();
 this.getDockableBarManager().addDockableBar(CommandBarFactory.createLookAndFeelCommandBar(this));
 this.getDockableBarManager().addDockableBar(getMyMenuBar());
 
 JTextArea ta = new JTextArea("test test test test\n test test test test\n"+
 "test test test test\n test test test test\n"+
 "test test test test\n test test test test\n"+
 "test test test test\n test test test test\n");
 getDockingManager().getWorkspace().add(ta,BorderLayout.CENTER);
 // setModal(true);
 getLayoutPersistence().loadLayoutData();
 
 
 }
 
 private CommandBar getMyMenuBar() {
 CommandBar commandBar = new CommandMenuBar("Menu Bar");
 commandBar.setInitSide(DockableBarContext.DOCK_SIDE_NORTH);
 commandBar.setInitIndex(0);
 commandBar.setPaintBackground(false);
 commandBar.setStretch(true);
 commandBar.setFloatable(true);
 commandBar.setHidable(false);
 
 JideMenu file= new JideMenu("File");
 
 AbstractAction a = new AbstractAction("SaveLayout"){
 public void actionPerformed(ActionEvent e) {
 getLayoutPersistence().saveLayoutData();
 JOptionPane.showMessageDialog(DefaultDialogDockableBarDockableHolderBug.this, "Layout saved");
 }
 };
 
 a.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
 
 JMenuItem i = new JMenuItem(a);
 file.add(i);
 commandBar.add(file);
 
 commandBar.getContext().setInitMode(DockableBarContext.STATE_HORI_DOCKED);
 return commandBar;
 }
 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 DefaultDialogDockableBarDockableHolderBug(f);
 }
 });
 }
 });
 
 f.getContentPane().add(b);
 
 f.pack();
 JideSwingUtilities.globalCenterWindow(f);
 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 f.setVisible(true);
 }
 });
 }
 }

