diff --git a/RoFage/src/RoFage.properties b/RoFage/src/RoFage.properties index 7bdfae9..57a1b09 100644 --- a/RoFage/src/RoFage.properties +++ b/RoFage/src/RoFage.properties @@ -1,3 +1,4 @@ +rofage_version=3000 ############################################# ################### JAVA #################### ############################################# diff --git a/RoFage/src/rofage/Main.java b/RoFage/src/rofage/Main.java index 818ac59..096c8db 100644 --- a/RoFage/src/rofage/Main.java +++ b/RoFage/src/rofage/Main.java @@ -1,8 +1,15 @@ package rofage; +import java.util.ArrayList; +import java.util.List; import javax.swing.SwingUtilities; -import rofage.swingworkers.SWinitializer; +import rofage.swingworkers.SWTasks; +import rofage.tasks.Task; +import rofage.tasks.TaskCheckJavaVersion; +import rofage.tasks.TaskFirstLaunch; +import rofage.tasks.db.TaskInitDB; import rofage.ui.InitializerFrame; +import rofage.ui.MainWindow; /** * @@ -14,10 +21,18 @@ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ @Override public void run() { - InitializerFrame initFrame = new InitializerFrame(); + /*InitializerFrame initFrame = new InitializerFrame(); initFrame.setVisible(true); - SWinitializer swInitializer = new SWinitializer(initFrame); - swInitializer.execute(); + + List listTasks = new ArrayList(); + // We build the initialization tasks + listTasks.add(new TaskCheckJavaVersion()); + listTasks.add(new TaskInitDB()); + listTasks.add(new TaskFirstLaunch()); + SWTasks swInitializer = new SWTasks(initFrame.pgrSplash, listTasks); + swInitializer.execute();*/ + MainWindow mainW = new MainWindow(); + mainW.setVisible(true); } }); diff --git a/RoFage/src/rofage/tasks/TaskUpdateMainConfiguration.java b/RoFage/src/rofage/tasks/TaskUpdateMainConfiguration.java new file mode 100644 index 0000000..a2c984c --- /dev/null +++ b/RoFage/src/rofage/tasks/TaskUpdateMainConfiguration.java @@ -0,0 +1,79 @@ +package rofage.tasks; + + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import rofage.exceptions.CommonException; +import rofage.objects.MainConfiguration; +import rofage.toolkits.DerbyDBToolkit; + +/** + * Update the MainConfiguration Object and saves it into the DB + * @author Pierre Chastagner + */ +public class TaskUpdateMainConfiguration extends AbstractTask{ + private final static Log logger = LogFactory.getLog(TaskUpdateMainConfiguration.class); + private String folderIcon; + private String folderImage; + private String folderNfo; + private String folderDat; + private Integer lastOpenedId; + + public TaskUpdateMainConfiguration (String folderIcon, String folderImage, + String folderNfo, String folderDat, Integer lastOpenedId) { + super ("Updating Main Configuration"); + this.folderIcon = folderIcon; + this.folderImage = folderImage; + this.folderNfo = folderNfo; + this.folderDat = folderDat; + this.lastOpenedId = lastOpenedId; + } + + @Override + public Task runTask() { + try { + logger.info("Updating Main Configuration"); + MainConfiguration mainConf = MainConfiguration.getInstance(); + if (folderIcon != null) { + mainConf.setFolderIcon(folderIcon); + } + if (folderImage != null) { + mainConf.setFolderImage(folderImage); + } + if (folderNfo != null) { + mainConf.setFolderNfo(folderNfo); + } + if (folderDat != null) { + mainConf.setFolderDat(folderDat); + } + if (lastOpenedId != null) { + mainConf.setLastOpenedDatId(lastOpenedId); + } + // Once we saved the java object, we have to save it into the DB + // First we check if the config exists + String sql; + ResultSet rs = DerbyDBToolkit.executeSQLQuery("SELECT COUNT(*) FROM CONFIG"); + rs.next(); + if (rs.getInt(1) == 0) { + sql = "INSERT INTO CONFIG (IMAGEFOLDER, NFOFOLDER, ICONFOLDER, DATFOLDER) VALUES (?, ?, ?, ?)"; + } else { + sql = "UPDATE CONFIG SET IMAGEFOLDER=?, NFOFOLDER=?, ICONFOLDER=?, DATFOLDER=?"; + } + Connection conn = DerbyDBToolkit.connect(); + PreparedStatement ps = conn.prepareStatement(sql); + ps.setString(1, folderImage); + ps.setString(2, folderNfo); + ps.setString(3, folderIcon); + ps.setString(4, folderDat); + ps.executeUpdate(); + conn.close(); + } catch (SQLException ex) { + new CommonException(DerbyDBToolkit.ERROR_EXECUTING, ex); + } + return null; + } +} diff --git a/RoFage/src/rofage/ui/MainWindow.form b/RoFage/src/rofage/ui/MainWindow.form new file mode 100644 index 0000000..a7f2ad2 --- /dev/null +++ b/RoFage/src/rofage/ui/MainWindow.form @@ -0,0 +1,38 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/RoFage/src/rofage/ui/MainWindow.java b/RoFage/src/rofage/ui/MainWindow.java new file mode 100644 index 0000000..bf77e53 --- /dev/null +++ b/RoFage/src/rofage/ui/MainWindow.java @@ -0,0 +1,98 @@ +package rofage.ui; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.border.TitledBorder; +import org.jdesktop.swingx.JXCollapsiblePane; +import org.jdesktop.swingx.JXFrame; + +/** + * + * @author Pierrot + */ +public class MainWindow extends javax.swing.JFrame { + + /** Creates new form MainWindow */ + public MainWindow() { +JXCollapsiblePane cp = new JXCollapsiblePane(); + + // JXCollapsiblePane can be used like any other container + cp.setLayout(new BorderLayout()); + + // the Controls panel with a textfield to filter the tree + JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 0)); + controls.add(new JLabel("Search:")); + controls.add(new JTextField(10)); + controls.add(new JButton("Refresh")); + controls.setBorder(new TitledBorder("Filters")); + cp.add("Center", controls); + + JXFrame frame = new JXFrame(); + frame.setLayout(new BorderLayout()); + + // Put the "Controls" first + frame.add("North", cp); + + // Then the tree - we assume the Controls would somehow filter the tree + JScrollPane scroll = new JScrollPane(new JTree()); + frame.add("Center", scroll); + + // Show/hide the "Controls" + JButton toggle = new JButton(cp.getActionMap().get("toggle")); + frame.add("South", toggle); + + frame.pack(); + frame.setVisible(true); + + + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + actionFactory1 = new org.jdesktop.swingx.action.ActionFactory(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 681, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 589, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new MainWindow().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private org.jdesktop.swingx.action.ActionFactory actionFactory1; + // End of variables declaration//GEN-END:variables + +}