18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.action;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.Gestion;
|
|
|
17 |
import org.openconcerto.erp.core.finance.accounting.ui.ComptaPrefTreeNode;
|
156 |
ilm |
18 |
import org.openconcerto.erp.modules.ModuleManager;
|
18 |
ilm |
19 |
import org.openconcerto.sql.Configuration;
|
|
|
20 |
import org.openconcerto.ui.preferences.PreferenceFrame;
|
|
|
21 |
import org.openconcerto.ui.state.WindowStateManager;
|
|
|
22 |
|
|
|
23 |
import java.awt.Dimension;
|
|
|
24 |
import java.awt.event.ActionEvent;
|
|
|
25 |
import java.io.File;
|
|
|
26 |
|
|
|
27 |
import javax.swing.AbstractAction;
|
|
|
28 |
import javax.swing.Action;
|
|
|
29 |
import javax.swing.JFrame;
|
|
|
30 |
|
|
|
31 |
public class PreferencesAction extends AbstractAction {
|
|
|
32 |
|
156 |
ilm |
33 |
private final ModuleManager moduleManager;
|
|
|
34 |
|
|
|
35 |
public PreferencesAction(final ModuleManager mngr) {
|
18 |
ilm |
36 |
super();
|
|
|
37 |
this.putValue(Action.NAME, "Préférences");
|
156 |
ilm |
38 |
this.moduleManager = mngr;
|
18 |
ilm |
39 |
}
|
|
|
40 |
|
|
|
41 |
@Override
|
|
|
42 |
public void actionPerformed(final ActionEvent e) {
|
156 |
ilm |
43 |
final JFrame frame = new PreferenceFrame(new ComptaPrefTreeNode(this.moduleManager));
|
18 |
ilm |
44 |
frame.setIconImages(Gestion.getFrameIcon());
|
|
|
45 |
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
|
46 |
frame.pack();
|
|
|
47 |
// Evite les saute de Layout
|
|
|
48 |
frame.setMinimumSize(new Dimension(frame.getSize()));
|
|
|
49 |
frame.setLocationRelativeTo(null);
|
|
|
50 |
// Charge la taille et les dimensions sauvegardées
|
|
|
51 |
final String fileName = "Configuration" + File.separator + "Frame" + File.separator + this.getValue(Action.NAME).toString() + ".xml";
|
|
|
52 |
final WindowStateManager stateManager = new WindowStateManager(frame, new File(Configuration.getInstance().getConfDir(), fileName), true);
|
|
|
53 |
stateManager.loadState();
|
|
|
54 |
frame.setVisible(true);
|
|
|
55 |
}
|
|
|
56 |
}
|