Skip to content
This repository was archived by the owner on May 24, 2025. It is now read-only.

Commit e7d34a0

Browse files
author
schyzo99
committed
1 parent a83977b commit e7d34a0

File tree

5 files changed

+235
-4
lines changed

5 files changed

+235
-4
lines changed

RoFage/src/RoFage.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
rofage_version=3000
12
#############################################
23
################### JAVA ####################
34
#############################################

RoFage/src/rofage/Main.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package rofage;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
35
import javax.swing.SwingUtilities;
4-
import rofage.swingworkers.SWinitializer;
6+
import rofage.swingworkers.SWTasks;
7+
import rofage.tasks.Task;
8+
import rofage.tasks.TaskCheckJavaVersion;
9+
import rofage.tasks.TaskFirstLaunch;
10+
import rofage.tasks.db.TaskInitDB;
511
import rofage.ui.InitializerFrame;
12+
import rofage.ui.MainWindow;
613

714
/**
815
*
@@ -14,10 +21,18 @@ public static void main(String[] args) {
1421
SwingUtilities.invokeLater(new Runnable(){
1522
@Override
1623
public void run() {
17-
InitializerFrame initFrame = new InitializerFrame();
24+
/*InitializerFrame initFrame = new InitializerFrame();
1825
initFrame.setVisible(true);
19-
SWinitializer swInitializer = new SWinitializer(initFrame);
20-
swInitializer.execute();
26+
27+
List<Task> listTasks = new ArrayList<Task>();
28+
// We build the initialization tasks
29+
listTasks.add(new TaskCheckJavaVersion());
30+
listTasks.add(new TaskInitDB());
31+
listTasks.add(new TaskFirstLaunch());
32+
SWTasks swInitializer = new SWTasks(initFrame.pgrSplash, listTasks);
33+
swInitializer.execute();*/
34+
MainWindow mainW = new MainWindow();
35+
mainW.setVisible(true);
2136
}
2237
});
2338

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package rofage.tasks;
2+
3+
4+
import java.sql.Connection;
5+
import java.sql.PreparedStatement;
6+
import java.sql.ResultSet;
7+
import java.sql.SQLException;
8+
import org.apache.commons.logging.Log;
9+
import org.apache.commons.logging.LogFactory;
10+
import rofage.exceptions.CommonException;
11+
import rofage.objects.MainConfiguration;
12+
import rofage.toolkits.DerbyDBToolkit;
13+
14+
/**
15+
* Update the MainConfiguration Object and saves it into the DB
16+
* @author Pierre Chastagner
17+
*/
18+
public class TaskUpdateMainConfiguration extends AbstractTask{
19+
private final static Log logger = LogFactory.getLog(TaskUpdateMainConfiguration.class);
20+
private String folderIcon;
21+
private String folderImage;
22+
private String folderNfo;
23+
private String folderDat;
24+
private Integer lastOpenedId;
25+
26+
public TaskUpdateMainConfiguration (String folderIcon, String folderImage,
27+
String folderNfo, String folderDat, Integer lastOpenedId) {
28+
super ("Updating Main Configuration");
29+
this.folderIcon = folderIcon;
30+
this.folderImage = folderImage;
31+
this.folderNfo = folderNfo;
32+
this.folderDat = folderDat;
33+
this.lastOpenedId = lastOpenedId;
34+
}
35+
36+
@Override
37+
public Task runTask() {
38+
try {
39+
logger.info("Updating Main Configuration");
40+
MainConfiguration mainConf = MainConfiguration.getInstance();
41+
if (folderIcon != null) {
42+
mainConf.setFolderIcon(folderIcon);
43+
}
44+
if (folderImage != null) {
45+
mainConf.setFolderImage(folderImage);
46+
}
47+
if (folderNfo != null) {
48+
mainConf.setFolderNfo(folderNfo);
49+
}
50+
if (folderDat != null) {
51+
mainConf.setFolderDat(folderDat);
52+
}
53+
if (lastOpenedId != null) {
54+
mainConf.setLastOpenedDatId(lastOpenedId);
55+
}
56+
// Once we saved the java object, we have to save it into the DB
57+
// First we check if the config exists
58+
String sql;
59+
ResultSet rs = DerbyDBToolkit.executeSQLQuery("SELECT COUNT(*) FROM CONFIG");
60+
rs.next();
61+
if (rs.getInt(1) == 0) {
62+
sql = "INSERT INTO CONFIG (IMAGEFOLDER, NFOFOLDER, ICONFOLDER, DATFOLDER) VALUES (?, ?, ?, ?)";
63+
} else {
64+
sql = "UPDATE CONFIG SET IMAGEFOLDER=?, NFOFOLDER=?, ICONFOLDER=?, DATFOLDER=?";
65+
}
66+
Connection conn = DerbyDBToolkit.connect();
67+
PreparedStatement ps = conn.prepareStatement(sql);
68+
ps.setString(1, folderImage);
69+
ps.setString(2, folderNfo);
70+
ps.setString(3, folderIcon);
71+
ps.setString(4, folderDat);
72+
ps.executeUpdate();
73+
conn.close();
74+
} catch (SQLException ex) {
75+
new CommonException(DerbyDBToolkit.ERROR_EXECUTING, ex);
76+
}
77+
return null;
78+
}
79+
}

RoFage/src/rofage/ui/MainWindow.form

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
4+
<NonVisualComponents>
5+
<Component class="org.jdesktop.swingx.action.ActionFactory" name="actionFactory1">
6+
</Component>
7+
</NonVisualComponents>
8+
<Properties>
9+
<Property name="defaultCloseOperation" type="int" value="3"/>
10+
</Properties>
11+
<SyntheticProperties>
12+
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
13+
</SyntheticProperties>
14+
<AuxValues>
15+
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
16+
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
17+
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
18+
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
19+
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
20+
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
21+
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
22+
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
23+
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
24+
</AuxValues>
25+
26+
<Layout>
27+
<DimensionLayout dim="0">
28+
<Group type="103" groupAlignment="0" attributes="0">
29+
<EmptySpace min="0" pref="681" max="32767" attributes="0"/>
30+
</Group>
31+
</DimensionLayout>
32+
<DimensionLayout dim="1">
33+
<Group type="103" groupAlignment="0" attributes="0">
34+
<EmptySpace min="0" pref="589" max="32767" attributes="0"/>
35+
</Group>
36+
</DimensionLayout>
37+
</Layout>
38+
</Form>

RoFage/src/rofage/ui/MainWindow.java

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package rofage.ui;
2+
3+
import java.awt.BorderLayout;
4+
import java.awt.FlowLayout;
5+
import javax.swing.JButton;
6+
import javax.swing.JLabel;
7+
import javax.swing.JPanel;
8+
import javax.swing.JScrollPane;
9+
import javax.swing.JTextField;
10+
import javax.swing.JTree;
11+
import javax.swing.border.TitledBorder;
12+
import org.jdesktop.swingx.JXCollapsiblePane;
13+
import org.jdesktop.swingx.JXFrame;
14+
15+
/**
16+
*
17+
* @author Pierrot
18+
*/
19+
public class MainWindow extends javax.swing.JFrame {
20+
21+
/** Creates new form MainWindow */
22+
public MainWindow() {
23+
JXCollapsiblePane cp = new JXCollapsiblePane();
24+
25+
// JXCollapsiblePane can be used like any other container
26+
cp.setLayout(new BorderLayout());
27+
28+
// the Controls panel with a textfield to filter the tree
29+
JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 0));
30+
controls.add(new JLabel("Search:"));
31+
controls.add(new JTextField(10));
32+
controls.add(new JButton("Refresh"));
33+
controls.setBorder(new TitledBorder("Filters"));
34+
cp.add("Center", controls);
35+
36+
JXFrame frame = new JXFrame();
37+
frame.setLayout(new BorderLayout());
38+
39+
// Put the "Controls" first
40+
frame.add("North", cp);
41+
42+
// Then the tree - we assume the Controls would somehow filter the tree
43+
JScrollPane scroll = new JScrollPane(new JTree());
44+
frame.add("Center", scroll);
45+
46+
// Show/hide the "Controls"
47+
JButton toggle = new JButton(cp.getActionMap().get("toggle"));
48+
frame.add("South", toggle);
49+
50+
frame.pack();
51+
frame.setVisible(true);
52+
53+
54+
}
55+
56+
/** This method is called from within the constructor to
57+
* initialize the form.
58+
* WARNING: Do NOT modify this code. The content of this method is
59+
* always regenerated by the Form Editor.
60+
*/
61+
@SuppressWarnings("unchecked")
62+
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
63+
private void initComponents() {
64+
65+
actionFactory1 = new org.jdesktop.swingx.action.ActionFactory();
66+
67+
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
68+
69+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
70+
getContentPane().setLayout(layout);
71+
layout.setHorizontalGroup(
72+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
73+
.addGap(0, 681, Short.MAX_VALUE)
74+
);
75+
layout.setVerticalGroup(
76+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
77+
.addGap(0, 589, Short.MAX_VALUE)
78+
);
79+
80+
pack();
81+
}// </editor-fold>//GEN-END:initComponents
82+
83+
/**
84+
* @param args the command line arguments
85+
*/
86+
public static void main(String args[]) {
87+
java.awt.EventQueue.invokeLater(new Runnable() {
88+
public void run() {
89+
new MainWindow().setVisible(true);
90+
}
91+
});
92+
}
93+
94+
// Variables declaration - do not modify//GEN-BEGIN:variables
95+
private org.jdesktop.swingx.action.ActionFactory actionFactory1;
96+
// End of variables declaration//GEN-END:variables
97+
98+
}

0 commit comments

Comments
 (0)