[chronojump] ExecuteAuto save sequence. Done!
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ExecuteAuto save sequence. Done!
- Date: Sun, 12 Oct 2014 17:59:54 +0000 (UTC)
commit dca70ca40857f97c7d9a7172be877c86d415dee8
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Oct 12 19:59:08 2014 +0200
ExecuteAuto save sequence. Done!
diagrams/sqlite/chronojump_sqlite.dia | Bin 14185 -> 14455 bytes
diagrams/sqlite/chronojump_sqlite.png | Bin 212548 -> 225383 bytes
diagrams/sqlite/chronojump_sqlite_2014_jun_16.png | Bin 0 -> 212548 bytes
glade/chronojump.glade | 94 ++++++++++++++++-----
src/Makefile.am | 1 +
src/constants.cs | 1 +
src/executeAuto.cs | 28 ++++---
src/gui/executeAuto.cs | 53 ++++++------
src/sqlite/executeAuto.cs | 80 +++++++++++++++++
src/sqlite/main.cs | 16 ++++-
10 files changed, 214 insertions(+), 59 deletions(-)
---
diff --git a/diagrams/sqlite/chronojump_sqlite.dia b/diagrams/sqlite/chronojump_sqlite.dia
index b6031fd..ec9d0c9 100644
Binary files a/diagrams/sqlite/chronojump_sqlite.dia and b/diagrams/sqlite/chronojump_sqlite.dia differ
diff --git a/diagrams/sqlite/chronojump_sqlite.png b/diagrams/sqlite/chronojump_sqlite.png
index 79c9971..ce209ee 100644
Binary files a/diagrams/sqlite/chronojump_sqlite.png and b/diagrams/sqlite/chronojump_sqlite.png differ
diff --git a/diagrams/sqlite/chronojump_sqlite_2014_jun_16.png
b/diagrams/sqlite/chronojump_sqlite_2014_jun_16.png
new file mode 100644
index 0000000..79c9971
Binary files /dev/null and b/diagrams/sqlite/chronojump_sqlite_2014_jun_16.png differ
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 52274cd..8d58c08 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -25016,8 +25016,8 @@ comments</property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="radio_by_series">
- <property name="label" translatable="yes">By series</property>
+ <widget class="GtkRadioButton" id="radio_by_sets">
+ <property name="label" translatable="yes">By sets</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -25036,7 +25036,7 @@ comments</property>
</packing>
</child>
<child>
- <widget class="GtkImage" id="image_auto_by_series">
+ <widget class="GtkImage" id="image_auto_by_sets">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -25119,9 +25119,9 @@ all the persons perform second test ...</property>
<child>
<widget class="GtkLabel" id="label_series_info">
<property name="can_focus">False</property>
- <property name="label" translatable="yes">All the persons perform first
serie,
-all the persons perform second serie ...
-One serie can contain several tests.</property>
+ <property name="label" translatable="yes">All the persons perform first set,
+all the persons perform second set ...
+One set can contain several tests.</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -25306,7 +25306,7 @@ One serie can contain several tests.</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
- <property name="label" translatable="yes">Serie 1</property>
+ <property name="label" translatable="yes">Set 1</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -25346,7 +25346,7 @@ One serie can contain several tests.</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
- <property name="label" translatable="yes">Serie 2</property>
+ <property name="label" translatable="yes">Set 2</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -25387,7 +25387,7 @@ One serie can contain several tests.</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
- <property name="label" translatable="yes">Serie 3</property>
+ <property name="label" translatable="yes">Set 3</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -25456,10 +25456,35 @@ One serie can contain several tests.</property>
<property name="border_width">10</property>
<property name="spacing">8</property>
<child>
- <widget class="GtkLabel" id="label6">
+ <widget class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Name</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Name</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.4699999988079071</property>
+ <property name="label" translatable="yes">Description
(optional)</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -25468,16 +25493,45 @@ One serie can contain several tests.</property>
</packing>
</child>
<child>
- <widget class="GtkEntry" id="entry_save">
+ <widget class="GtkVBox" id="vbox11">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- <signal name="changed" handler="on_entry_save_changed" swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkEntry" id="entry_save_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <signal name="changed" handler="on_entry_save_name_changed"
swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="entry_save_description">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index 0be9be5..65326b5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -85,6 +85,7 @@ SOURCES = \
sqlite/preferences.cs\
sqlite/session.cs\
sqlite/encoder.cs\
+ sqlite/executeAuto.cs\
sqlite/jump.cs\
sqlite/jumpRj.cs\
sqlite/jumpType.cs\
diff --git a/src/constants.cs b/src/constants.cs
index f9e2878..f04e1b2 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -132,6 +132,7 @@ public class Constants
public const string EncoderSignalCurveTable = "encoderSignalCurve";
public const string EncoderExerciseTable = "encoderExercise";
public const string Encoder1RMTable = "encoder1RM";
+ public const string ExecuteAutoTable = "executeAuto";
//tests types
public const string JumpTypeTable = "jumpType";
diff --git a/src/executeAuto.cs b/src/executeAuto.cs
index b4e1794..3eb6685 100644
--- a/src/executeAuto.cs
+++ b/src/executeAuto.cs
@@ -23,10 +23,10 @@ using System.Collections; //ArrayList
using System.Collections.Generic; //List<T>
public class ExecuteAuto {
- public enum ModeTypes { BY_PERSONS, BY_TESTS, BY_SERIES }
+ public enum ModeTypes { BY_PERSONS, BY_TESTS, BY_SETS }
private ModeTypes mode;
- public int serieID; //only in BY_SERIES (in BY_PERSONS or BY_TESTS, value is -1)
+ public int serieID; //only in BY_SETS (in BY_PERSONS or BY_TESTS, value is -1)
public int personUniqueID;
public string personName;
public int testUniqueID;
@@ -118,21 +118,22 @@ public class ExecuteAuto {
~ExecuteAuto() {}
}
+//sequence saved or loaded on SQL
public class ExecuteAutoSQL
{
- private string name;
+ public string name;
private ExecuteAuto.ModeTypes mode;
+ private string description;
private List<int> serie1IDs;
private List<int> serie2IDs;
private List<int> serie3IDs;
- //private string future1;
- //private string future2;
- //private string future3;
- public ExecuteAutoSQL(string name, ExecuteAuto.ModeTypes mode, List<int> serie1IDs, List<int>
serie2IDs, List<int> serie3IDs)
+ public ExecuteAutoSQL(string name, ExecuteAuto.ModeTypes mode, string description,
+ List<int> serie1IDs, List<int> serie2IDs, List<int> serie3IDs)
{
this.name = name;
this.mode = mode;
+ this.description = description;
this.serie1IDs = serie1IDs;
this.serie2IDs = serie2IDs;
this.serie3IDs = serie3IDs;
@@ -149,13 +150,16 @@ public class ExecuteAutoSQL
}
return str;
}
- public void SaveToSQL()
+
+ public bool SaveToSQL()
{
- Log.WriteLine(name + "\n" + mode + "\n" + serieIDsToStr(serie1IDs) + "\n" +
serieIDsToStr(serie2IDs) + "\n" + serieIDsToStr(serie3IDs));
-
- //TODO: send this to SQL, and add there the future1, future2, future3 strs
- //SqliteExecuteAuto.Save(false, name, mode, serieIDsToStr(serie1IDs),
serieIDsToStr(serie2IDs), serieIDsToStr(serie3IDs));
+ if(Sqlite.Exists(false, Constants.ExecuteAutoTable, name))
+ return false; //not saved because name exists
+ SqliteExecuteAuto.Insert(false, name, mode.ToString(), description,
+ serieIDsToStr(serie1IDs), serieIDsToStr(serie2IDs), serieIDsToStr(serie3IDs));
+
+ return true; //saved
}
~ExecuteAutoSQL() {}
diff --git a/src/gui/executeAuto.cs b/src/gui/executeAuto.cs
index 82cb1d6..799c9f7 100644
--- a/src/gui/executeAuto.cs
+++ b/src/gui/executeAuto.cs
@@ -37,10 +37,10 @@ public class ExecuteAutoWindow
//1st tab
[Widget] Gtk.RadioButton radio_by_persons;
[Widget] Gtk.RadioButton radio_by_tests;
- [Widget] Gtk.RadioButton radio_by_series;
+ [Widget] Gtk.RadioButton radio_by_sets;
[Widget] Gtk.Image image_auto_by_persons;
[Widget] Gtk.Image image_auto_by_tests;
- [Widget] Gtk.Image image_auto_by_series;
+ [Widget] Gtk.Image image_auto_by_sets;
[Widget] Gtk.Label label_persons_info;
[Widget] Gtk.Label label_tests_info;
[Widget] Gtk.Label label_series_info;
@@ -61,7 +61,8 @@ public class ExecuteAutoWindow
[Widget] Gtk.TreeView treeview_serie2;
[Widget] Gtk.TreeView treeview_serie3;
- [Widget] Gtk.Entry entry_save;
+ [Widget] Gtk.Entry entry_save_name;
+ [Widget] Gtk.Entry entry_save_description;
[Widget] Gtk.Button button_save;
//3rd tab
@@ -135,11 +136,11 @@ public class ExecuteAutoWindow
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "auto-by-tests.png");
image_auto_by_tests.Pixbuf = pixbuf;
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "auto-by-series.png");
- image_auto_by_series.Pixbuf = pixbuf;
+ image_auto_by_sets.Pixbuf = pixbuf;
image_auto_by_tests.Sensitive = false;
- image_auto_by_series.Sensitive = false;
+ image_auto_by_sets.Sensitive = false;
label_persons_info.Visible = true;
label_tests_info.Visible = false;
label_series_info.Visible = false;
@@ -152,7 +153,7 @@ public class ExecuteAutoWindow
//know if "serie" has to be plotted or not
ExecuteAuto eaFirst = (ExecuteAuto) orderedData[0];
- createTreeview(eaFirst.serieID != -1); //BY_SERIES != -1
+ createTreeview(eaFirst.serieID != -1); //BY_SETS != -1
fillTreeview();
//set the selected
@@ -177,11 +178,11 @@ public class ExecuteAutoWindow
private void on_radio_mode_toggled(object o, EventArgs args) {
image_auto_by_persons.Sensitive = radio_by_persons.Active;
image_auto_by_tests.Sensitive = radio_by_tests.Active;
- image_auto_by_series.Sensitive = radio_by_series.Active;
+ image_auto_by_sets.Sensitive = radio_by_sets.Active;
label_persons_info.Visible = radio_by_persons.Active;
label_tests_info.Visible = radio_by_tests.Active;
- label_series_info.Visible = radio_by_series.Active;
+ label_series_info.Visible = radio_by_sets.Active;
}
@@ -273,29 +274,29 @@ public class ExecuteAutoWindow
new String [] { treeviewSerie3Array.Count.ToString(), tc.trName } );
}
- button_save.Sensitive = (treeviewSerie1Array.Count > 0 && entry_save.Text.ToString().Length >
0);
+ button_save.Sensitive = (treeviewSerie1Array.Count > 0 &&
entry_save_name.Text.ToString().Length > 0);
//a test is added, sensitivize "next" button
button_next.Sensitive = true;
}
- private void on_entry_save_changed(object o, EventArgs args)
+ private void on_entry_save_name_changed(object o, EventArgs args)
{
- button_save.Sensitive = (treeviewSerie1Array.Count > 0 && entry_save.Text.ToString().Length >
0);
+ button_save.Sensitive = (treeviewSerie1Array.Count > 0 &&
entry_save_name.Text.ToString().Length > 0);
}
private void on_button_save_clicked(object o, EventArgs args)
{
- //si no existeix a la BD amab aquest nom...
- //new DialogMessage(Constants.MessageTypes.INFO, string.Format(
- // //Catalog.GetString("Sorry, this sport '{0}' already exists in
database"),
- // "will save this stuff: '{0}'",
- // entry_save.Text.ToString()));
-
- ExecuteAutoSQL eaSQL = new ExecuteAutoSQL(entry_save.Text.ToString(), mode,
+ ExecuteAutoSQL eaSQL = new ExecuteAutoSQL(entry_save_name.Text.ToString(), mode,
entry_save_description.Text.ToString(),
getTrComboInts(treeviewSerie1Array), getTrComboInts(treeviewSerie2Array),
getTrComboInts(treeviewSerie3Array));
- eaSQL.SaveToSQL();
+ bool saved = eaSQL.SaveToSQL();
+
+ if(saved)
+ new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Saved"));
+ else
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ String.Format(Catalog.GetString("Sorry, this sequence '{0}' already
exists in database"), eaSQL.name));
}
private List<int> getTrComboInts(ArrayList arrayTrCombo) {
@@ -328,8 +329,8 @@ public class ExecuteAutoWindow
}
TreeStore store;
- private void createTreeview(bool by_series) {
- if(by_series)
+ private void createTreeview(bool by_sets) {
+ if(by_sets)
store = new TreeStore(typeof (string), typeof (string), typeof (string)); //serie,
person, test
else
store = new TreeStore(typeof (string), typeof (string)); //person, test
@@ -338,7 +339,7 @@ public class ExecuteAutoWindow
treeview.HeadersVisible=true;
int i = 0;
- if(by_series) {
+ if(by_sets) {
UtilGtk.CreateCols(treeview, store, Catalog.GetString("Serie"), i++, true);
}
@@ -358,10 +359,10 @@ public class ExecuteAutoWindow
mode = ExecuteAuto.ModeTypes.BY_PERSONS;
if(radio_by_tests.Active)
mode = ExecuteAuto.ModeTypes.BY_TESTS;
- else if(radio_by_series.Active)
- mode = ExecuteAuto.ModeTypes.BY_SERIES;
+ else if(radio_by_sets.Active)
+ mode = ExecuteAuto.ModeTypes.BY_SETS;
- showSeriesStuff(radio_by_series.Active);
+ showSeriesStuff(radio_by_sets.Active);
notebook.NextPage();
//next button will be sensitive when first test is added
@@ -372,7 +373,7 @@ public class ExecuteAutoWindow
orderedData = ExecuteAuto.CreateOrder(mode, persons,
treeviewSerie1Array, treeviewSerie2Array, treeviewSerie3Array);
- createTreeview(radio_by_series.Active);
+ createTreeview(radio_by_sets.Active);
fillTreeview();
button_next.Label = Catalog.GetString("Accept");
diff --git a/src/sqlite/executeAuto.cs b/src/sqlite/executeAuto.cs
new file mode 100644
index 0000000..00861ed
--- /dev/null
+++ b/src/sqlite/executeAuto.cs
@@ -0,0 +1,80 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2004-2014 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+using System.Data;
+using System.IO;
+using System.Collections; //ArrayList
+using Mono.Data.Sqlite;
+
+
+class SqliteExecuteAuto : Sqlite
+{
+ public SqliteExecuteAuto() {
+ }
+
+ ~SqliteExecuteAuto() {}
+
+ /*
+ * create and initialize tables
+ */
+
+ protected internal static void createTableExecuteAuto()
+ {
+ dbcmd.CommandText =
+ "CREATE TABLE " + Constants.ExecuteAutoTable + " ( " +
+ "uniqueID INTEGER PRIMARY KEY, " +
+ "name TEXT, " +
+ "mode TEXT, " +
+ "description TEXT, " +
+ "serie1IDs TEXT, " +
+ "serie2IDs TEXT, " +
+ "serie3IDs TEXT, " +
+ "future1 TEXT, " +
+ "future2 TEXT, " +
+ "future3 TEXT )";
+ dbcmd.ExecuteNonQuery();
+ }
+
+ /*
+ * class methods
+ */
+
+ public static void Insert(bool dbconOpened, string name, string mode, string description, string
serie1IDs, string serie2IDs, string serie3IDs)
+ {
+ if(! dbconOpened)
+ dbcon.Open();
+
+ dbcmd.CommandText = "INSERT INTO " + Constants.ExecuteAutoTable +
+ " (uniqueID, name, mode, description, " +
+ " serie1IDs, serie2IDs, serie3IDs, " +
+ " future1, future2, future3)" +
+ " VALUES ( NULL, '" +
+ name + "', '" + mode + "', '" + description + "', '" +
+ serie1IDs + "', '" + serie2IDs + "', '" + serie3IDs + "', " +
+ "'', '', '')"; //future1, future2, future3
+ Log.WriteLine(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ if(! dbconOpened)
+ dbcon.Close();
+ }
+
+}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index a2aa73d..67db621 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -74,7 +74,7 @@ class Sqlite
* Important, change this if there's any update to database
* Important2: if database version get numbers higher than 1, check if the comparisons with
currentVersion works ok
*/
- static string lastChronojumpDatabaseVersion = "1.12";
+ static string lastChronojumpDatabaseVersion = "1.13";
public Sqlite() {
}
@@ -1649,6 +1649,17 @@ class Sqlite
currentVersion = "1.12";
}
+ if(currentVersion == "1.12") {
+ dbcon.Open();
+
+ Log.WriteLine("Added ExecuteAuto table");
+
+ SqliteExecuteAuto.createTableExecuteAuto();
+ SqlitePreferences.Update ("databaseVersion", "1.13", true);
+ dbcon.Close();
+
+ currentVersion = "1.13";
+ }
}
@@ -1788,8 +1799,11 @@ class Sqlite
creationRate ++;
SqliteCountry.createTable();
SqliteCountry.initialize();
+
+ SqliteExecuteAuto.createTableExecuteAuto();
//changes [from - to - desc]
+ //1.12 - 1.13 Converted DB to 1.13 Added ExecuteAuto table
//1.11 - 1.12 Converted DB to 1.12 URLs from absolute to relative
//1.10 - 1.11 Converted DB to 1.11 Added option on autosave curves on capture
(all/bestmeanpower/none)
//1.09 - 1.10 Converted DB to 1.10 Added RSA RAST on runType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]