Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
schyzo99 committed Apr 19, 2009
1 parent a83977b commit e7d34a0
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 4 deletions.
1 change: 1 addition & 0 deletions RoFage/src/RoFage.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
rofage_version=3000
#############################################
################### JAVA ####################
#############################################
Expand Down
23 changes: 19 additions & 4 deletions RoFage/src/rofage/Main.java
Original file line number Diff line number Diff line change
@@ -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;

/**
*
Expand All @@ -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<Task> listTasks = new ArrayList<Task>();
// 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);
}
});

Expand Down
79 changes: 79 additions & 0 deletions RoFage/src/rofage/tasks/TaskUpdateMainConfiguration.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
38 changes: 38 additions & 0 deletions RoFage/src/rofage/ui/MainWindow.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Component class="org.jdesktop.swingx.action.ActionFactory" name="actionFactory1">
</Component>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="681" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="589" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>
98 changes: 98 additions & 0 deletions RoFage/src/rofage/ui/MainWindow.java
Original file line number Diff line number Diff line change
@@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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

}

0 comments on commit e7d34a0

Please sign in to comment.