Improved functionality of "Load Layout" dock button.

This commit is contained in:
7Durandal7
2012-05-11 21:03:14 +00:00
parent 407fd5787c
commit e850a3f872
2 changed files with 18 additions and 6 deletions

View File

@@ -93,10 +93,16 @@ public enum CDock implements ICDoc {
@Override @Override
public Void doInBackground() { public Void doInBackground() {
SaveOpenDialog dlgOpen = new SaveOpenDialog(); SaveOpenDialog dlgOpen = new SaveOpenDialog();
File LoadFile = new File(SIOUtil.FILE_PREFERRED); File DefFile = new File(SIOUtil.FILE_PREFERRED);
LoadFile = dlgOpen.OpenDialog(LoadFile, null); File LoadFile = dlgOpen.OpenDialog(DefFile, Filetypes.LAYOUT);
if (LoadFile!=null) {
SIOUtil.loadLayout(LoadFile); SIOUtil.loadLayout(LoadFile);
}
else {
SIOUtil.loadLayout(DefFile);
}
SIOUtil.saveLayout();
SOverlayUtils.hideOverlay(); SOverlayUtils.hideOverlay();
return null; return null;
} }

View File

@@ -53,13 +53,18 @@ public class SaveOpenDialog extends JPanel {
} }
} }
/**
*
* constructor for a save or open dialog
*/
public SaveOpenDialog() { public SaveOpenDialog() {
fc = new JFileChooser(); fc = new JFileChooser();
} }
/** /**
* Shows the open dialog for files. If no file selected, returns default. Pass null * Shows the open dialog for files. If no file selected, returns null. Pass null
* to Type and Extension to allow all files to be viewed/opened. * to Type to allow all files to be viewed/opened.
* @param defFileName pass the default file to use, also determines directory * @param defFileName pass the default file to use, also determines directory
* @param type label to tell what type of file to filter * @param type label to tell what type of file to filter
* *
@@ -79,9 +84,10 @@ public class SaveOpenDialog extends JPanel {
int RetValue = fc.showOpenDialog(getParent()); int RetValue = fc.showOpenDialog(getParent());
if (RetValue == JFileChooser.APPROVE_OPTION) { if (RetValue == JFileChooser.APPROVE_OPTION) {
RetFile = fc.getSelectedFile(); RetFile = fc.getSelectedFile();
}
return RetFile; return RetFile;
} }
return null;
}
/** /**
* Shows the save dialog. Not implemented anywhere yet. * Shows the save dialog. Not implemented anywhere yet.