-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
schyzo99
committed
Apr 19, 2009
1 parent
a83977b
commit e7d34a0
Showing
5 changed files
with
235 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} |